@codexhost/cli-win32-x64 0.32.1 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +372 -10
- package/app/console-web.js +435 -28
- package/app/desktop-controller.mjs +357 -7
- package/app/host-runtime.mjs +7829 -3478
- package/app/plugins/antigravity/plugin.mjs +483 -55
- package/app/plugins/claude-code/assets/icon.svg +1 -1
- package/app/plugins/claude-code/manifest.json +1 -1
- package/app/plugins/claude-code/plugin.mjs +1093 -193
- package/app/plugins/codebuddy/plugin.mjs +444 -25
- package/app/plugins/codex-usage/plugin.mjs +357 -7
- package/app/plugins/copilot/assets/icon.svg +1 -1
- package/app/plugins/copilot/manifest.json +1 -1
- package/app/plugins/copilot/plugin.mjs +359 -9
- package/app/plugins/cursor-cli/plugin.mjs +357 -7
- package/app/plugins/deepseek-harness/assets/icon.svg +1 -1
- package/app/plugins/deepseek-harness/manifest.json +1 -1
- package/app/plugins/deepseek-harness/plugin.mjs +796 -148
- package/app/plugins/devin/assets/icon.svg +1 -1
- package/app/plugins/devin/manifest.json +1 -1
- package/app/plugins/devin/plugin.mjs +359 -8
- package/app/plugins/grok/plugin.mjs +357 -7
- package/app/plugins/hermes/plugin.mjs +357 -7
- package/app/plugins/kimi-code/plugin.mjs +357 -7
- package/app/plugins/kiro-cli/plugin.mjs +357 -7
- package/app/plugins/omp/assets/icon.svg +1 -1
- package/app/plugins/omp/plugin.mjs +383 -7
- package/app/plugins/opencode/plugin.mjs +361 -8
- package/app/plugins/pi/assets/icon.svg +1 -1
- package/app/plugins/pi/manifest.json +1 -1
- package/app/plugins/pi/plugin.mjs +385 -9
- package/app/plugins/qoder/assets/icon.svg +1 -1
- package/app/plugins/qoder/plugin.mjs +383 -7
- package/app/plugins/qoder-cn/assets/icon.svg +1 -1
- package/app/plugins/qoder-cn/plugin.mjs +383 -7
- package/app/plugins/qwen-code/assets/icon.svg +1 -1
- package/app/plugins/qwen-code/plugin.mjs +386 -7
- package/app/plugins/workbuddy/plugin.mjs +444 -25
- package/app/plugins/zcode/plugin.mjs +377 -14
- package/app/renderer-extension.js +457 -37
- package/app/web/assets/{abnfDiagram-XWFEHMT6-7XITZmBH.js → abnfDiagram-XWFEHMT6-VnfRaHM6.js} +1 -1
- package/app/web/assets/{architectureDiagram-CSQXQB3N-C8Usdzd8.js → architectureDiagram-CSQXQB3N-BA1ehtvi.js} +1 -1
- package/app/web/assets/{blockDiagram-BEDRHYPZ-CyN9yE_Q.js → blockDiagram-BEDRHYPZ-31BZSfd4.js} +1 -1
- package/app/web/assets/{c4Diagram-M2UUVUY5-CjhY1l3g.js → c4Diagram-M2UUVUY5-CNzGWc5k.js} +1 -1
- package/app/web/assets/{chunk-2Q5K7J3B-o24_rh4_.js → chunk-2Q5K7J3B-ahAIR-NM.js} +1 -1
- package/app/web/assets/{chunk-3GCGMST5-D7bw3E1a.js → chunk-3GCGMST5-BIV5YeRJ.js} +1 -1
- package/app/web/assets/{chunk-5VM5RSS4-D0v4acf7.js → chunk-5VM5RSS4-CluTMPJG.js} +1 -1
- package/app/web/assets/{chunk-7U7NFRK5-CYJxP4rV.js → chunk-7U7NFRK5-4NIQuFbE.js} +1 -1
- package/app/web/assets/{chunk-CNRTWJTD-DTgCtcCl.js → chunk-CNRTWJTD-_0bEfGn3.js} +1 -1
- package/app/web/assets/{chunk-D5HYT7QG-qRNelehW.js → chunk-D5HYT7QG-_kTC6f8F.js} +1 -1
- package/app/web/assets/{chunk-EBZ3SEQC-BgJPPYdu.js → chunk-EBZ3SEQC-CykaYOrL.js} +2 -2
- package/app/web/assets/{chunk-JWPE2WC7-C50ZnSQQ.js → chunk-JWPE2WC7-3vVOQ_py.js} +1 -1
- package/app/web/assets/{chunk-KTR4FSNJ-Cifh4XHc.js → chunk-KTR4FSNJ-aVg5vgrm.js} +1 -1
- package/app/web/assets/{chunk-XXDRQBXY-D23WAHPW.js → chunk-XXDRQBXY-_gVwGeSp.js} +1 -1
- package/app/web/assets/{classDiagram-v2-KXABOMEV-B3cezFGj.js → classDiagram-v2-KXABOMEV-fI1LfeBf.js} +1 -1
- package/app/web/assets/{cose-bilkent-JH36ORCC-VSMi4La2.js → cose-bilkent-JH36ORCC-DFXMlWov.js} +1 -1
- package/app/web/assets/{cynefin-EF2NZ3EQ-qQnfHq16.js → cynefin-EF2NZ3EQ-lZy7X6FO.js} +1 -1
- package/app/web/assets/{cynefinDiagram-NJNITYFG-BJELApXD.js → cynefinDiagram-NJNITYFG-N4DwFSW1.js} +1 -1
- package/app/web/assets/{dagre-KIHZ2IZ3-C8B5ZMVs.js → dagre-KIHZ2IZ3-B7-8baTH.js} +1 -1
- package/app/web/assets/{diagram-7YQZDPLS-HIWoNpzV.js → diagram-7YQZDPLS-DLfjiBXV.js} +1 -1
- package/app/web/assets/{diagram-QBROCOUO-3_vS1jbp.js → diagram-QBROCOUO-CQnRzSTi.js} +1 -1
- package/app/web/assets/{diagram-RJJCUUZO-C_Kndn_e.js → diagram-RJJCUUZO-DPnxazRT.js} +1 -1
- package/app/web/assets/{diagram-WERXNKYE-BLWdOwya.js → diagram-WERXNKYE-BBuEFRvD.js} +1 -1
- package/app/web/assets/{diagram-YHHI257C-DJeOs6eS.js → diagram-YHHI257C-BQ92JNJs.js} +1 -1
- package/app/web/assets/{diagram-YR4HJLHV-BKNULu-g.js → diagram-YR4HJLHV-Ce6BQO3J.js} +1 -1
- package/app/web/assets/{ebnfDiagram-N527522P-Bu8aReoF.js → ebnfDiagram-N527522P-DYknE2Jy.js} +1 -1
- package/app/web/assets/{elk-O5DQBFGD-CIp7Z0ER.js → elk-O5DQBFGD-4S6_JJFF.js} +1 -1
- package/app/web/assets/{erDiagram-K3K3BIDK-BTsor1Lp.js → erDiagram-K3K3BIDK-DRtF7JVQ.js} +1 -1
- package/app/web/assets/{flowDiagram-Z6JWZHQI-p_h5PKQr.js → flowDiagram-Z6JWZHQI-7Ho8CyR9.js} +1 -1
- package/app/web/assets/{ganttDiagram-3PRQTZWP-DKjfPPJ1.js → ganttDiagram-3PRQTZWP-CW8Ig5y4.js} +1 -1
- package/app/web/assets/{gitGraphDiagram-VXDFKS5L-RnPOf2fj.js → gitGraphDiagram-VXDFKS5L-CzS8Xg2D.js} +1 -1
- package/app/web/assets/{grid-E2QIVN74-C96GnBO1.js → grid-E2QIVN74-Cq284lCe.js} +1 -1
- package/app/web/assets/index-CINZ6P-q.css +1 -0
- package/app/web/assets/index-CvV6veuY.js +208 -0
- package/app/web/assets/{infoDiagram-EZ3ZOAHP-B68eZHsb.js → infoDiagram-EZ3ZOAHP-BZgN6qlY.js} +1 -1
- package/app/web/assets/{ishikawaDiagram-S3EKX5GW-BLj7PFLt.js → ishikawaDiagram-S3EKX5GW-BH9YHc-1.js} +1 -1
- package/app/web/assets/{journeyDiagram-POQNLL5X-Bo-_In0d.js → journeyDiagram-POQNLL5X-D50KYOLe.js} +1 -1
- package/app/web/assets/{kanban-definition-BH5XI6FM-BpHvxprW.js → kanban-definition-BH5XI6FM-Crw_5mMP.js} +1 -1
- package/app/web/assets/langs/{graphql-D6Z3qcRW.js → graphql-2R4AZ1iu.js} +1 -1
- package/app/web/assets/langs/{http-XiU9G9In.js → http-q2Qm0vBh.js} +1 -1
- package/app/web/assets/langs/{php-DL3xwS-7.js → php-Cz2gDBnd.js} +1 -1
- package/app/web/assets/langs/{rst-DudRVJ9g.js → rst-_9muvx-X.js} +1 -1
- package/app/web/assets/langs/{ruby-_FqsfqJi.js → ruby-cn7REk4H.js} +1 -1
- package/app/web/assets/langs/{svelte-ClsVJoBT.js → svelte-CPnL2mcy.js} +1 -1
- package/app/web/assets/langs/{vue-BiKMXCyK.js → vue-DO0YwyVz.js} +1 -1
- package/app/web/assets/{mermaid.core-COb9i2Gl.js → mermaid.core-o2Qjrppc.js} +5 -5
- package/app/web/assets/{mindmap-definition-WVAN44T4-DG15AlXd.js → mindmap-definition-WVAN44T4-B_bEbpAH.js} +1 -1
- package/app/web/assets/{pegDiagram-D4NLKWP3-GMBk8RM6.js → pegDiagram-D4NLKWP3-VecAHoyw.js} +1 -1
- package/app/web/assets/{pieDiagram-36ENHN4W-BzeJgVnn.js → pieDiagram-36ENHN4W-o3ei2T-6.js} +1 -1
- package/app/web/assets/{quadrantDiagram-ZQUDMS73-C--Kif6a.js → quadrantDiagram-ZQUDMS73-DHndOAcn.js} +1 -1
- package/app/web/assets/{railroadDiagram-JIZHGYPL-NPLVu_R7.js → railroadDiagram-JIZHGYPL-DRd_lfii.js} +1 -1
- package/app/web/assets/{render-VIF2ZAQL-DdpQ8E0J.js → render-VIF2ZAQL-awM3hUqB.js} +2 -2
- package/app/web/assets/{requirementDiagram-AXW2TVFA-WWRwRbkA.js → requirementDiagram-AXW2TVFA-Ce1ePsOe.js} +1 -1
- package/app/web/assets/{sankeyDiagram-FBCJTAIF-hBr6pZ0V.js → sankeyDiagram-FBCJTAIF-cP-LtgW-.js} +1 -1
- package/app/web/assets/{sequenceDiagram-3LA2ROMG-DvzZWy5J.js → sequenceDiagram-3LA2ROMG-C3JStTuW.js} +1 -1
- package/app/web/assets/{sizeCapture-2Q2CQKSF-C2B86W70.js → sizeCapture-2Q2CQKSF-Dyyelr9K.js} +1 -1
- package/app/web/assets/{stateDiagram-v2-ATKHQDJO-Jwj3XqMx.js → stateDiagram-v2-ATKHQDJO-DkYRBVTd.js} +1 -1
- package/app/web/assets/{swimlanes-YQL5WMAO-DxI0hC09.js → swimlanes-YQL5WMAO-B2FwJU5_.js} +1 -1
- package/app/web/assets/swimlanesDiagram-UCCPES4V-BkMsxCPb.js +8 -0
- package/app/web/assets/{timeline-definition-7Z437IG3-m8Ew8iuN.js → timeline-definition-7Z437IG3-Di-qRIIi.js} +1 -1
- package/app/web/assets/{usecaseDiagram-RDK6N6HP-BsiPSzIT.js → usecaseDiagram-RDK6N6HP-yAImn62t.js} +1 -1
- package/app/web/assets/{vendor-BKfNgqAm.js → vendor-BMCjWFMy.js} +20 -20
- package/app/web/assets/{vennDiagram-SHRQU5PJ-yYfXhiGp.js → vennDiagram-SHRQU5PJ-BEv8jpfv.js} +1 -1
- package/app/web/assets/{wardleyDiagram-F3OXNVQS-DHLEfnsg.js → wardleyDiagram-F3OXNVQS-7irksA0b.js} +1 -1
- package/app/web/assets/{xychartDiagram-GDYJKCDI-Drn_UxYt.js → xychartDiagram-GDYJKCDI-BokJGG2y.js} +1 -1
- package/app/web/codex-agent.png +0 -0
- package/app/web/codex.png +0 -0
- package/app/web/codexhost-settings.js +61 -61
- package/app/web/index.html +3 -3
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +65 -65
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
- 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 +78 -73
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +92 -92
- package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +114 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +79 -79
- 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 +70 -70
- package/app/web/role-avatars/builtin/architect-otter.webp +0 -0
- package/app/web/role-avatars/builtin/audio-otter.webp +0 -0
- package/app/web/role-avatars/builtin/backend-otter.webp +0 -0
- package/app/web/role-avatars/builtin/classic-otter.webp +0 -0
- package/app/web/role-avatars/builtin/data-otter.webp +0 -0
- package/app/web/role-avatars/builtin/debugger-otter.webp +0 -0
- package/app/web/role-avatars/builtin/frontend-otter.webp +0 -0
- package/app/web/role-avatars/builtin/idea-otter.webp +0 -0
- package/app/web/role-avatars/builtin/ops-otter.webp +0 -0
- package/app/web/role-avatars/builtin/pm-otter.webp +0 -0
- package/app/web/role-avatars/builtin/researcher-otter.webp +0 -0
- package/app/web/role-avatars/builtin/reviewer-otter.webp +0 -0
- package/app/web/role-avatars/builtin/scholar-otter.webp +0 -0
- package/app/web/role-avatars/builtin/security-otter.webp +0 -0
- package/app/web/role-avatars/builtin/tester-otter.webp +0 -0
- package/app/web/role-avatars/builtin/writer-otter.webp +0 -0
- package/app/web-modules/node_modules/@deepseek-ai/dsh-host-webserver/index.js +7 -1
- package/app/web-modules/server.mjs +1281 -246
- 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-CDRWzs-u.js +0 -205
- package/app/web/assets/index-Dwdnvinl.css +0 -1
- package/app/web/assets/swimlanesDiagram-UCCPES4V-CR0nv8kJ.js +0 -8
|
@@ -35535,8 +35535,8 @@ Caused by: `, $causeStack = /* @__PURE__ */ Symbol("causeStack");
|
|
|
35535
35535
|
let left = host.slice(0, compressionIndex), right = host.slice(compressionIndex + 2), leftGroups = left ? left.split(":") : [], rightGroups = right ? right.split(":") : [];
|
|
35536
35536
|
return leftGroups.length + rightGroups.length < 8 && leftGroups.every(isIPv6ZeroGroup) && rightGroups.every(isIPv6ZeroGroup);
|
|
35537
35537
|
}
|
|
35538
|
-
let
|
|
35539
|
-
return
|
|
35538
|
+
let groups2 = host.split(":");
|
|
35539
|
+
return groups2.length === 8 && groups2.every(isIPv6ZeroGroup);
|
|
35540
35540
|
}, isIPv6Loopback = (host) => {
|
|
35541
35541
|
if (host === "::1") return !0;
|
|
35542
35542
|
let v4MappedDotted = host.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/i);
|
|
@@ -35546,11 +35546,11 @@ Caused by: `, $causeStack = /* @__PURE__ */ Symbol("causeStack");
|
|
|
35546
35546
|
let high = parseInt(v4MappedHex[1], 16);
|
|
35547
35547
|
return high >= 32512 && high <= 32767;
|
|
35548
35548
|
}
|
|
35549
|
-
let
|
|
35550
|
-
if (
|
|
35549
|
+
let groups2 = host.split(":");
|
|
35550
|
+
if (groups2.length === 8) {
|
|
35551
35551
|
for (let i = 0; i < 7; i++)
|
|
35552
|
-
if (!/^0+$/.test(
|
|
35553
|
-
return /^0*1$/.test(
|
|
35552
|
+
if (!/^0+$/.test(groups2[i])) return !1;
|
|
35553
|
+
return /^0*1$/.test(groups2[7]);
|
|
35554
35554
|
}
|
|
35555
35555
|
return !1;
|
|
35556
35556
|
}, isLoopback = (host) => host ? LOOPBACK_HOSTNAMES.has(host) || isIPv4Loopback(host) || isIPv6Unspecified(host) ? !0 : isIPv6Loopback(host) : !1, DEFAULT_PORTS2 = {
|
|
@@ -35587,14 +35587,14 @@ Caused by: `, $causeStack = /* @__PURE__ */ Symbol("causeStack");
|
|
|
35587
35587
|
let halves = host.split("::");
|
|
35588
35588
|
if (halves.length > 2)
|
|
35589
35589
|
return null;
|
|
35590
|
-
let
|
|
35590
|
+
let groups2 = halves[0] ? halves[0].split(":") : [];
|
|
35591
35591
|
if (halves.length === 2) {
|
|
35592
|
-
let rear = halves[1] ? halves[1].split(":") : [], missing = 8 -
|
|
35592
|
+
let rear = halves[1] ? halves[1].split(":") : [], missing = 8 - groups2.length - rear.length;
|
|
35593
35593
|
if (missing < 1)
|
|
35594
35594
|
return null;
|
|
35595
|
-
|
|
35595
|
+
groups2.push(...new Array(missing).fill("0"), ...rear);
|
|
35596
35596
|
}
|
|
35597
|
-
return
|
|
35597
|
+
return groups2.length !== 8 || groups2.some((group) => !IPV6_GROUP_RE.test(group)) ? null : groups2.flatMap((group) => {
|
|
35598
35598
|
let value = Number.parseInt(group, 16);
|
|
35599
35599
|
return [value >> 8 & 255, value & 255];
|
|
35600
35600
|
});
|
|
@@ -35715,11 +35715,11 @@ Caused by: `, $causeStack = /* @__PURE__ */ Symbol("causeStack");
|
|
|
35715
35715
|
};
|
|
35716
35716
|
}
|
|
35717
35717
|
function throttle(fn, freq) {
|
|
35718
|
-
let
|
|
35719
|
-
|
|
35718
|
+
let timestamp3 = 0, threshold = 1e3 / freq, lastArgs, timer, invoke = (args, now = Date.now()) => {
|
|
35719
|
+
timestamp3 = now, lastArgs = null, timer && (clearTimeout(timer), timer = null), fn(...args);
|
|
35720
35720
|
};
|
|
35721
35721
|
return [(...args) => {
|
|
35722
|
-
let now = Date.now(), passed = now -
|
|
35722
|
+
let now = Date.now(), passed = now - timestamp3;
|
|
35723
35723
|
passed >= threshold ? invoke(args, now) : (lastArgs = args, timer || (timer = setTimeout(() => {
|
|
35724
35724
|
timer = null, invoke(lastArgs);
|
|
35725
35725
|
}, threshold - passed)));
|
|
@@ -35759,8 +35759,8 @@ Caused by: `, $causeStack = /* @__PURE__ */ Symbol("causeStack");
|
|
|
35759
35759
|
charCode === 47 || // /
|
|
35760
35760
|
charCode === 45 || // - (base64url)
|
|
35761
35761
|
charCode === 95, isBase64Whitespace = (charCode) => charCode === 9 || charCode === 10 || charCode === 12 || charCode === 13 || charCode === 32, base64Bytes = (significant) => {
|
|
35762
|
-
let
|
|
35763
|
-
return
|
|
35762
|
+
let groups2 = Math.floor(significant / 4), remainder = significant % 4;
|
|
35763
|
+
return groups2 * 3 + (remainder === 2 ? 1 : remainder === 3 ? 2 : 0);
|
|
35764
35764
|
}, estimateBase64BufferAllocation = (body) => {
|
|
35765
35765
|
let len = body.length, padding = 0;
|
|
35766
35766
|
return len > 0 && body.charCodeAt(len - 1) === 61 && (padding++, len > 1 && body.charCodeAt(len - 2) === 61 && padding++), Math.floor((len - padding) * 3 / 4);
|
|
@@ -51134,8 +51134,8 @@ var require_pkcs7 = __commonJS({
|
|
|
51134
51134
|
else if (attr.type === forge.pki.oids.signingTime) {
|
|
51135
51135
|
var jan_1_1950 = /* @__PURE__ */ new Date("1950-01-01T00:00:00Z"), jan_1_2050 = /* @__PURE__ */ new Date("2050-01-01T00:00:00Z"), date5 = attr.value;
|
|
51136
51136
|
if (typeof date5 == "string") {
|
|
51137
|
-
var
|
|
51138
|
-
isNaN(
|
|
51137
|
+
var timestamp3 = Date.parse(date5);
|
|
51138
|
+
isNaN(timestamp3) ? date5.length === 13 ? date5 = asn1.utcTimeToDate(date5) : date5 = asn1.generalizedTimeToDate(date5) : date5 = new Date(timestamp3);
|
|
51139
51139
|
}
|
|
51140
51140
|
date5 >= jan_1_1950 && date5 < jan_1_2050 ? value = asn1.create(
|
|
51141
51141
|
asn1.Class.UNIVERSAL,
|
|
@@ -56853,7 +56853,7 @@ var require_src4 = __commonJS({
|
|
|
56853
56853
|
});
|
|
56854
56854
|
|
|
56855
56855
|
// packages/web-server/src/main.ts
|
|
56856
|
-
import { randomUUID as
|
|
56856
|
+
import { randomUUID as randomUUID27 } from "node:crypto";
|
|
56857
56857
|
|
|
56858
56858
|
// node_modules/zod/v4/classic/external.js
|
|
56859
56859
|
var external_exports = {};
|
|
@@ -72106,7 +72106,7 @@ var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za
|
|
|
72106
72106
|
// packages/shared-contracts/dist/ids.js
|
|
72107
72107
|
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
72108
72108
|
message: "Identifier must not be empty or whitespace"
|
|
72109
|
-
}), harnessIdSchema = opaqueIdSchema.brand(), hostThreadIdSchema = opaqueIdSchema.brand(), hostTurnIdSchema = opaqueIdSchema.brand(), hostItemIdSchema = opaqueIdSchema.brand(), hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
72109
|
+
}), harnessIdSchema = opaqueIdSchema.brand(), hostThreadIdSchema = opaqueIdSchema.brand(), hostTurnIdSchema = opaqueIdSchema.brand(), hostItemIdSchema = opaqueIdSchema.brand(), HARNESS_THINKING_OPTION_ID_MAX_LENGTH = 128, harnessThinkingOptionIdSchema = opaqueIdSchema.max(HARNESS_THINKING_OPTION_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Thinking option ID must use transport-safe characters").brand(), hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
72110
72110
|
|
|
72111
72111
|
// packages/shared-contracts/dist/harness-permission-modes.js
|
|
72112
72112
|
var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128, HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256, HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024, HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32, nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
@@ -72166,6 +72166,90 @@ var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim
|
|
|
72166
72166
|
handoff: threadHandoffMetadataSchema
|
|
72167
72167
|
}).strict();
|
|
72168
72168
|
|
|
72169
|
+
// packages/shared-contracts/dist/agent-role.js
|
|
72170
|
+
var roleSlugSchema = external_exports.string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/u), roleModelSchema = external_exports.string().min(1).max(512).refine((value) => !new RegExp("\\p{Cc}", "u").test(value), "Role model must not contain control characters"), roleAccentColorSchema = external_exports.enum(["stone", "rose", "mist", "sage", "amber", "aqua"]), BUILTIN_ROLE_AVATAR_IDS = [
|
|
72171
|
+
"pm-otter",
|
|
72172
|
+
"frontend-otter",
|
|
72173
|
+
"backend-otter",
|
|
72174
|
+
"reviewer-otter",
|
|
72175
|
+
"idea-otter",
|
|
72176
|
+
"researcher-otter",
|
|
72177
|
+
"writer-otter",
|
|
72178
|
+
"architect-otter",
|
|
72179
|
+
"debugger-otter",
|
|
72180
|
+
"tester-otter",
|
|
72181
|
+
"classic-otter",
|
|
72182
|
+
"ops-otter",
|
|
72183
|
+
"security-otter",
|
|
72184
|
+
"audio-otter",
|
|
72185
|
+
"scholar-otter",
|
|
72186
|
+
"data-otter"
|
|
72187
|
+
], builtinRoleAvatarSchema = external_exports.templateLiteral([
|
|
72188
|
+
"builtin:",
|
|
72189
|
+
external_exports.enum(BUILTIN_ROLE_AVATAR_IDS)
|
|
72190
|
+
]), ROLE_AVATAR_FILENAME_PATTERN = /^[a-zA-Z0-9_-]{1,64}\.(png|jpg|jpeg|webp)$/u, customRoleAvatarSchema = external_exports.templateLiteral([
|
|
72191
|
+
"custom:",
|
|
72192
|
+
external_exports.string().regex(ROLE_AVATAR_FILENAME_PATTERN)
|
|
72193
|
+
]), catalogRoleAvatarSchema = external_exports.templateLiteral([
|
|
72194
|
+
"catalog:",
|
|
72195
|
+
external_exports.string().regex(ROLE_AVATAR_FILENAME_PATTERN)
|
|
72196
|
+
]), roleAvatarSchema = external_exports.union([builtinRoleAvatarSchema, customRoleAvatarSchema]), roleCatalogAvatarSchema = external_exports.union([builtinRoleAvatarSchema, catalogRoleAvatarSchema]), saveRoleAvatarSchema = external_exports.union([roleAvatarSchema, catalogRoleAvatarSchema]);
|
|
72197
|
+
var httpsUrlSchema = external_exports.string().url().max(2048).refine((value) => /^https:\/\//i.test(value), "URL must use https://"), localizedRoleTextSchema = external_exports.object({
|
|
72198
|
+
en: external_exports.string().trim().min(1).max(2e3),
|
|
72199
|
+
"zh-CN": external_exports.string().trim().min(1).max(2e3)
|
|
72200
|
+
}), roleCatalogEntrySchema = external_exports.object({
|
|
72201
|
+
slug: roleSlugSchema,
|
|
72202
|
+
name: localizedRoleTextSchema,
|
|
72203
|
+
description: localizedRoleTextSchema,
|
|
72204
|
+
avatar: roleCatalogAvatarSchema,
|
|
72205
|
+
accentColor: roleAccentColorSchema,
|
|
72206
|
+
recommendedHarnessId: harnessIdSchema.optional(),
|
|
72207
|
+
author: external_exports.string().trim().min(1).max(128),
|
|
72208
|
+
authorUrl: httpsUrlSchema.optional(),
|
|
72209
|
+
sourceUrl: httpsUrlSchema.optional(),
|
|
72210
|
+
license: external_exports.string().trim().min(1).max(64).optional(),
|
|
72211
|
+
official: external_exports.boolean().optional(),
|
|
72212
|
+
instructions: external_exports.string().trim().min(1).max(1e5),
|
|
72213
|
+
updatedAt: external_exports.iso.datetime()
|
|
72214
|
+
}), roleCatalogDocumentSchema = external_exports.object({
|
|
72215
|
+
formatVersion: external_exports.literal(1),
|
|
72216
|
+
generatedAt: external_exports.iso.datetime(),
|
|
72217
|
+
roles: external_exports.array(roleCatalogEntrySchema)
|
|
72218
|
+
}), roleIdentitySchema = external_exports.object({
|
|
72219
|
+
slug: roleSlugSchema,
|
|
72220
|
+
name: external_exports.string().refine((name2) => name2.trim().length > 0),
|
|
72221
|
+
avatar: roleAvatarSchema,
|
|
72222
|
+
accentColor: roleAccentColorSchema
|
|
72223
|
+
}), threadRoleSnapshotSchema = roleIdentitySchema.readonly(), agentRoleSchema = roleIdentitySchema.extend({
|
|
72224
|
+
description: external_exports.string(),
|
|
72225
|
+
harnessId: harnessIdSchema,
|
|
72226
|
+
model: roleModelSchema.optional(),
|
|
72227
|
+
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
72228
|
+
instructions: external_exports.string(),
|
|
72229
|
+
updatedAt: external_exports.iso.datetime()
|
|
72230
|
+
}), saveAgentRoleInputSchema = agentRoleSchema.omit({ updatedAt: !0, avatar: !0 }).extend({ avatar: saveRoleAvatarSchema }).partial({ slug: !0 }), ROLES_LIST_METHOD = "codexhost/roles/list", ROLES_GET_METHOD = "codexhost/roles/get", ROLES_SAVE_METHOD = "codexhost/roles/save", ROLES_DELETE_METHOD = "codexhost/roles/delete", ROLES_CATALOG_METHOD = "codexhost/roles/catalog", ROLES_LIKE_METHOD = "codexhost/roles/like", ROLE_LIKES_MAX_PER_ROLE = 5;
|
|
72231
|
+
var ROLE_CATALOG_ASSET_BASE_URL = "https://raw.githubusercontent.com/BytePioneer-AI/codexhost-extensions-registry/main/roles/assets", ROLE_CATALOG_ASSET_MIRROR_BASE_URL = "https://cdn.jsdelivr.net/gh/BytePioneer-AI/codexhost-extensions-registry@main/roles/assets";
|
|
72232
|
+
var rolesListParamsSchema = external_exports.object({
|
|
72233
|
+
locale: external_exports.string().trim().min(1).max(64).optional()
|
|
72234
|
+
}), rolesListResultSchema = external_exports.object({ roles: external_exports.array(agentRoleSchema) }), rolesGetParamsSchema = external_exports.object({ slug: roleSlugSchema }), rolesGetResultSchema = external_exports.object({ role: agentRoleSchema.nullable() }), rolesSaveParamsSchema = saveAgentRoleInputSchema, rolesSaveResultSchema = external_exports.object({ role: agentRoleSchema }), rolesDeleteParamsSchema = rolesGetParamsSchema, rolesDeleteResultSchema = external_exports.object({ deleted: external_exports.boolean() }), rolesCatalogParamsSchema = external_exports.object({
|
|
72235
|
+
refresh: external_exports.boolean().optional()
|
|
72236
|
+
}), rolesCatalogResultSchema = external_exports.object({
|
|
72237
|
+
roles: external_exports.array(roleCatalogEntrySchema),
|
|
72238
|
+
fetchedAt: external_exports.iso.datetime(),
|
|
72239
|
+
likes: external_exports.record(roleSlugSchema, external_exports.number().int().nonnegative()).optional(),
|
|
72240
|
+
myLikes: external_exports.record(roleSlugSchema, external_exports.number().int().min(0).max(ROLE_LIKES_MAX_PER_ROLE)).optional(),
|
|
72241
|
+
stale: external_exports.boolean().optional(),
|
|
72242
|
+
error: external_exports.string().optional()
|
|
72243
|
+
}), rolesLikeParamsSchema = external_exports.object({
|
|
72244
|
+
slug: roleSlugSchema
|
|
72245
|
+
}), rolesLikeResultSchema = external_exports.object({
|
|
72246
|
+
slug: roleSlugSchema,
|
|
72247
|
+
likes: external_exports.number().int().nonnegative(),
|
|
72248
|
+
myLikes: external_exports.number().int().min(0).max(ROLE_LIKES_MAX_PER_ROLE),
|
|
72249
|
+
maxLikes: external_exports.literal(ROLE_LIKES_MAX_PER_ROLE),
|
|
72250
|
+
limitReached: external_exports.boolean().optional()
|
|
72251
|
+
});
|
|
72252
|
+
|
|
72169
72253
|
// packages/shared-contracts/dist/thread-usage.js
|
|
72170
72254
|
var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative(), finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative(), cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100), usageOutputTimingSchema = external_exports.object({
|
|
72171
72255
|
version: external_exports.union([external_exports.literal(3), external_exports.literal(4)]).optional(),
|
|
@@ -72309,7 +72393,7 @@ var usageMeasurementSchema = external_exports.object({
|
|
|
72309
72393
|
}).strict();
|
|
72310
72394
|
|
|
72311
72395
|
// packages/shared-contracts/dist/harness-models.js
|
|
72312
|
-
var HARNESS_MODEL_REF_MAX_LENGTH = 512, HARNESS_MODEL_LABEL_MAX_LENGTH = 256,
|
|
72396
|
+
var HARNESS_MODEL_REF_MAX_LENGTH = 512, HARNESS_MODEL_LABEL_MAX_LENGTH = 256, THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100, nonBlankTextSchema3 = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
72313
72397
|
message: "Value must not be empty or whitespace"
|
|
72314
72398
|
}), harnessModelRefIdSchema = external_exports.string().min(1).max(HARNESS_MODEL_REF_MAX_LENGTH).refine((id2) => !new RegExp("\\p{Cc}", "u").test(id2), "Model Ref must not contain control characters").brand(), harnessModelServiceTierSchema = external_exports.enum(["priority", "ultrafast"]), harnessModelRefSchema = external_exports.object({
|
|
72315
72399
|
id: harnessModelRefIdSchema,
|
|
@@ -72325,7 +72409,18 @@ function harnessModelRefFromKey(key) {
|
|
|
72325
72409
|
let separator = key.indexOf("");
|
|
72326
72410
|
return harnessModelRefSchema.parse(separator === -1 ? { id: key } : { id: key.slice(0, separator), serviceTier: key.slice(separator + 1) });
|
|
72327
72411
|
}
|
|
72328
|
-
var
|
|
72412
|
+
var ROLE_MODEL_TIER_SUFFIX = /~(fast|ultrafast)$/u;
|
|
72413
|
+
function parseRoleModelRef(model2) {
|
|
72414
|
+
let checked = roleModelSchema.parse(model2), match = ROLE_MODEL_TIER_SUFFIX.exec(checked);
|
|
72415
|
+
return match && match.index > 0 ? harnessModelRefSchema.parse({
|
|
72416
|
+
id: checked.slice(0, match.index),
|
|
72417
|
+
serviceTier: match[1] === "fast" ? "priority" : "ultrafast"
|
|
72418
|
+
}) : harnessModelRefSchema.parse({ id: checked });
|
|
72419
|
+
}
|
|
72420
|
+
function roleModelToSelectionKey(model2) {
|
|
72421
|
+
return harnessModelRefKey(parseRoleModelRef(model2));
|
|
72422
|
+
}
|
|
72423
|
+
var harnessResolvedModelLabelSchema = nonBlankTextSchema3.max(HARNESS_MODEL_LABEL_MAX_LENGTH), harnessThinkingOptionSchema = external_exports.object({
|
|
72329
72424
|
id: harnessThinkingOptionIdSchema,
|
|
72330
72425
|
label: nonBlankTextSchema3.max(HARNESS_MODEL_LABEL_MAX_LENGTH)
|
|
72331
72426
|
}).strict(), harnessModelSchema = external_exports.object({
|
|
@@ -72488,8 +72583,10 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
|
|
|
72488
72583
|
effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
|
|
72489
72584
|
history: harnessHistoryCapabilitiesSchema.optional(),
|
|
72490
72585
|
supportsThreadReferences: external_exports.literal(!0).optional(),
|
|
72491
|
-
handoff: threadHandoffMetadataSchema.optional()
|
|
72492
|
-
|
|
72586
|
+
handoff: threadHandoffMetadataSchema.optional(),
|
|
72587
|
+
roleSnapshot: threadRoleSnapshotSchema.optional(),
|
|
72588
|
+
nativeSessionRef: external_exports.never().optional()
|
|
72589
|
+
}), externalThreadInspectionSchema = external_exports.object({
|
|
72493
72590
|
owner: external_exports.literal("external"),
|
|
72494
72591
|
harnessId: nonBlankTextSchema3.max(256),
|
|
72495
72592
|
transportModelId: nonBlankTextSchema3.max(8192),
|
|
@@ -72503,8 +72600,10 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
|
|
|
72503
72600
|
history: harnessHistoryCapabilitiesSchema,
|
|
72504
72601
|
usage: threadUsageSnapshotSchema.optional(),
|
|
72505
72602
|
handoff: threadHandoffMetadataSchema.optional(),
|
|
72603
|
+
roleSnapshot: threadRoleSnapshotSchema.optional(),
|
|
72604
|
+
nativeSessionRef: external_exports.never().optional(),
|
|
72506
72605
|
locked: external_exports.literal(!0)
|
|
72507
|
-
})
|
|
72606
|
+
}), threadInspectionSchema = external_exports.discriminatedUnion("owner", [
|
|
72508
72607
|
codexThreadInspectionSchema,
|
|
72509
72608
|
externalThreadInspectionSchema
|
|
72510
72609
|
]), threadOwnershipListParamsSchema = external_exports.object({
|
|
@@ -72820,7 +72919,9 @@ function targetsForCapabilities({ hasPage, hasWidget, hasDesktop, hasWeb, hasBac
|
|
|
72820
72919
|
var hostExtensionBackendMethodSchema = desktopExtensionBackendMethodSchema, HOST_EXTENSION_ASSETS_PREFIX = "/api/extensions/assets/";
|
|
72821
72920
|
|
|
72822
72921
|
// packages/shared-contracts/dist/thread-tree-watch.js
|
|
72823
|
-
var THREAD_TREE_MAX_NODES = 5e3, threadTreeStatusSchema = external_exports.enum(["running", "waiting", "idle", "unknown"]),
|
|
72922
|
+
var THREAD_TREE_MAX_NODES = 5e3, threadTreeStatusSchema = external_exports.enum(["running", "waiting", "idle", "unknown"]), threadTreeDelegationSchema = external_exports.object({
|
|
72923
|
+
createdAtMs: external_exports.number().int().nonnegative()
|
|
72924
|
+
}), threadTreeHandoffSchema = external_exports.strictObject({
|
|
72824
72925
|
sourceThreadId: hostThreadIdSchema,
|
|
72825
72926
|
createdAtMs: external_exports.number().int().nonnegative()
|
|
72826
72927
|
}), threadTreeNodeSchema = external_exports.strictObject({
|
|
@@ -72829,13 +72930,14 @@ var THREAD_TREE_MAX_NODES = 5e3, threadTreeStatusSchema = external_exports.enum(
|
|
|
72829
72930
|
status: threadTreeStatusSchema,
|
|
72830
72931
|
archived: external_exports.boolean(),
|
|
72831
72932
|
updatedAtMs: external_exports.number().int().nonnegative().optional()
|
|
72832
|
-
}), threadTreeSnapshotSchema = external_exports.
|
|
72933
|
+
}), threadTreeSnapshotSchema = external_exports.object({
|
|
72833
72934
|
revision: external_exports.int().nonnegative(),
|
|
72834
72935
|
parents: external_exports.record(hostThreadIdSchema, hostThreadIdSchema),
|
|
72936
|
+
delegations: external_exports.record(hostThreadIdSchema, threadTreeDelegationSchema).optional(),
|
|
72835
72937
|
handoffs: external_exports.record(hostThreadIdSchema, threadTreeHandoffSchema).optional(),
|
|
72836
72938
|
nodes: external_exports.record(hostThreadIdSchema, threadTreeNodeSchema),
|
|
72837
72939
|
truncated: external_exports.boolean()
|
|
72838
|
-
}).refine((snapshot) => Object.keys(snapshot.nodes).length <= THREAD_TREE_MAX_NODES, "Too many Thread tree nodes").refine(({ parents, handoffs, nodes }) => Object.entries(parents).every(([child, parent]) => Object.hasOwn(nodes, child) && Object.hasOwn(nodes, parent)) && Object.entries(handoffs ?? {}).every(([target2, { sourceThreadId }]) => Object.hasOwn(nodes, target2) && Object.hasOwn(nodes, sourceThreadId)), "Missing Thread tree node"), subscriptionId = external_exports.string().min(1).max(128), threadTreeWatchParamsSchema = external_exports.strictObject({}), threadTreeUnwatchParamsSchema = external_exports.strictObject({ subscriptionId }), threadTreeUnwatchResultSchema = external_exports.strictObject({}), threadTreeWatchResultSchema = threadTreeUnwatchParamsSchema.extend({
|
|
72940
|
+
}).refine((snapshot) => Object.keys(snapshot.nodes).length <= THREAD_TREE_MAX_NODES, "Too many Thread tree nodes").refine(({ parents, handoffs, nodes }) => Object.entries(parents).every(([child, parent]) => Object.hasOwn(nodes, child) && Object.hasOwn(nodes, parent)) && Object.entries(handoffs ?? {}).every(([target2, { sourceThreadId }]) => Object.hasOwn(nodes, target2) && Object.hasOwn(nodes, sourceThreadId)), "Missing Thread tree node").refine(({ parents, delegations }) => Object.keys(delegations ?? {}).every((child) => Object.hasOwn(parents, child)), "Delegation metadata requires a matching parent edge"), subscriptionId = external_exports.string().min(1).max(128), threadTreeWatchParamsSchema = external_exports.strictObject({}), threadTreeUnwatchParamsSchema = external_exports.strictObject({ subscriptionId }), threadTreeUnwatchResultSchema = external_exports.strictObject({}), threadTreeWatchResultSchema = threadTreeUnwatchParamsSchema.extend({
|
|
72839
72941
|
snapshot: threadTreeSnapshotSchema
|
|
72840
72942
|
});
|
|
72841
72943
|
|
|
@@ -73065,6 +73167,151 @@ var noParams = external_exports.strictObject({}), expectedRevision = { expectedR
|
|
|
73065
73167
|
}
|
|
73066
73168
|
};
|
|
73067
73169
|
|
|
73170
|
+
// packages/shared-contracts/dist/group-chat.js
|
|
73171
|
+
var DEFAULT_GROUP_MAX_AGENT_HOPS = 5, MAX_GROUP_AGENT_HOPS = 20, remoteGroupRoomIdSchema = external_exports.string().regex(/^remote:[A-Za-z0-9_-]{8,512}$/u), groupRoomIdSchema = external_exports.union([external_exports.uuidv4(), remoteGroupRoomIdSchema]), groupMemberIdSchema = external_exports.uuidv4(), groupMemberHandleSchema = external_exports.string().regex(/^[a-z0-9][a-z0-9_-]{0,47}$/u), groupUnmentionedPolicySchema = external_exports.enum(["none", "last_speaker", "all"]), groupMemberStatusSchema = external_exports.enum(["active", "muted", "removed"]), nonnegativeInteger = external_exports.int().nonnegative(), positiveInteger = external_exports.int().positive(), maxAgentHopsSchema = positiveInteger.max(MAX_GROUP_AGENT_HOPS), nonblankString = external_exports.string().refine((value) => value.trim().length > 0), timestamp = external_exports.iso.datetime(), optionalMemberEdits = {
|
|
73172
|
+
handle: groupMemberHandleSchema.optional(),
|
|
73173
|
+
displayName: nonblankString.optional(),
|
|
73174
|
+
note: external_exports.string().optional()
|
|
73175
|
+
}, groupMemberSchema = external_exports.object({
|
|
73176
|
+
memberId: groupMemberIdSchema,
|
|
73177
|
+
threadId: hostThreadIdSchema,
|
|
73178
|
+
handle: groupMemberHandleSchema,
|
|
73179
|
+
displayName: nonblankString,
|
|
73180
|
+
note: external_exports.string().optional(),
|
|
73181
|
+
roleSlug: roleSlugSchema.optional(),
|
|
73182
|
+
roleSnapshot: threadRoleSnapshotSchema.optional(),
|
|
73183
|
+
harnessId: harnessIdSchema,
|
|
73184
|
+
status: groupMemberStatusSchema,
|
|
73185
|
+
joinedAtSeq: nonnegativeInteger,
|
|
73186
|
+
lastDeliveredSeq: nonnegativeInteger,
|
|
73187
|
+
lastRosterVersion: nonnegativeInteger,
|
|
73188
|
+
createdAt: timestamp
|
|
73189
|
+
}), groupRoomRemoteHostSchema = external_exports.object({
|
|
73190
|
+
hostId: nonblankString,
|
|
73191
|
+
displayName: nonblankString,
|
|
73192
|
+
state: nonblankString.optional(),
|
|
73193
|
+
color: external_exports.string().optional(),
|
|
73194
|
+
filePreview: external_exports.boolean().optional()
|
|
73195
|
+
}), groupRoomSchema = external_exports.object({
|
|
73196
|
+
roomId: groupRoomIdSchema,
|
|
73197
|
+
title: nonblankString,
|
|
73198
|
+
defaultCwd: nonblankString,
|
|
73199
|
+
unmentionedPolicy: groupUnmentionedPolicySchema.default("none"),
|
|
73200
|
+
allowAgentMentions: external_exports.boolean().default(!0),
|
|
73201
|
+
maxAgentHops: maxAgentHopsSchema.default(DEFAULT_GROUP_MAX_AGENT_HOPS),
|
|
73202
|
+
lastSeq: nonnegativeInteger,
|
|
73203
|
+
lastSpeakerMemberId: groupMemberIdSchema.optional(),
|
|
73204
|
+
rosterVersion: nonnegativeInteger,
|
|
73205
|
+
humanEpoch: nonnegativeInteger,
|
|
73206
|
+
relayPaused: external_exports.boolean(),
|
|
73207
|
+
pinned: external_exports.boolean(),
|
|
73208
|
+
createdAt: timestamp,
|
|
73209
|
+
updatedAt: timestamp,
|
|
73210
|
+
members: external_exports.array(groupMemberSchema),
|
|
73211
|
+
remote: groupRoomRemoteHostSchema.optional()
|
|
73212
|
+
}).superRefine(({ members: members2 }, context) => {
|
|
73213
|
+
let handles = /* @__PURE__ */ new Set();
|
|
73214
|
+
for (let [index, { handle, status }] of members2.entries())
|
|
73215
|
+
status !== "removed" && (handles.has(handle) && context.addIssue({
|
|
73216
|
+
code: "custom",
|
|
73217
|
+
path: ["members", index, "handle"],
|
|
73218
|
+
message: "Handle must be unique among non-removed members"
|
|
73219
|
+
}), handles.add(handle));
|
|
73220
|
+
});
|
|
73221
|
+
var groupAttachmentSchema = external_exports.object({
|
|
73222
|
+
kind: external_exports.enum(["image", "file"]),
|
|
73223
|
+
attachmentId: nonblankString.max(256),
|
|
73224
|
+
name: nonblankString.max(256),
|
|
73225
|
+
path: nonblankString.max(4096),
|
|
73226
|
+
bytes: nonnegativeInteger,
|
|
73227
|
+
mediaType: nonblankString.max(128).optional(),
|
|
73228
|
+
width: positiveInteger.optional(),
|
|
73229
|
+
height: positiveInteger.optional()
|
|
73230
|
+
}), groupMessageSchema = external_exports.object({
|
|
73231
|
+
roomId: groupRoomIdSchema,
|
|
73232
|
+
seq: positiveInteger,
|
|
73233
|
+
messageId: nonblankString,
|
|
73234
|
+
senderType: external_exports.enum(["user", "agent", "system"]),
|
|
73235
|
+
senderMemberId: groupMemberIdSchema.optional(),
|
|
73236
|
+
senderHandle: groupMemberHandleSchema.optional(),
|
|
73237
|
+
senderName: external_exports.string().optional(),
|
|
73238
|
+
senderThreadId: hostThreadIdSchema.optional(),
|
|
73239
|
+
sourceTurnId: nonblankString.optional(),
|
|
73240
|
+
replyToSeq: positiveInteger.optional(),
|
|
73241
|
+
content: external_exports.string(),
|
|
73242
|
+
attachments: external_exports.array(groupAttachmentSchema).max(12).optional(),
|
|
73243
|
+
mentionedMemberIds: external_exports.array(groupMemberIdSchema),
|
|
73244
|
+
mentionAll: external_exports.boolean().optional(),
|
|
73245
|
+
hopCount: nonnegativeInteger,
|
|
73246
|
+
createdAt: timestamp
|
|
73247
|
+
}), newThreadOptions = {
|
|
73248
|
+
...optionalMemberEdits,
|
|
73249
|
+
model: roleModelSchema.optional(),
|
|
73250
|
+
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
73251
|
+
worktree: external_exports.boolean().optional()
|
|
73252
|
+
}, groupCreateMemberInputSchema = external_exports.discriminatedUnion("kind", [
|
|
73253
|
+
external_exports.strictObject({ kind: external_exports.literal("role"), roleSlug: roleSlugSchema, ...newThreadOptions }),
|
|
73254
|
+
external_exports.strictObject({ kind: external_exports.literal("harness"), harnessId: harnessIdSchema, ...newThreadOptions }),
|
|
73255
|
+
external_exports.strictObject({
|
|
73256
|
+
kind: external_exports.literal("existing"),
|
|
73257
|
+
threadId: hostThreadIdSchema,
|
|
73258
|
+
...optionalMemberEdits,
|
|
73259
|
+
includeRecentHistory: external_exports.boolean().default(!0).optional()
|
|
73260
|
+
})
|
|
73261
|
+
]), GROUPS_LIST_METHOD = "codexhost/groups/list", GROUPS_GET_METHOD = "codexhost/groups/get", GROUPS_CREATE_METHOD = "codexhost/groups/create", GROUPS_UPDATE_METHOD = "codexhost/groups/update", GROUPS_DELETE_METHOD = "codexhost/groups/delete", GROUPS_ADD_MEMBER_METHOD = "codexhost/groups/member/add", GROUPS_UPDATE_MEMBER_METHOD = "codexhost/groups/member/update", GROUPS_REMOVE_MEMBER_METHOD = "codexhost/groups/member/remove", GROUPS_POST_MESSAGE_METHOD = "codexhost/groups/message/post", GROUPS_READ_MESSAGES_METHOD = "codexhost/groups/messages/read", GROUPS_CHANGED_EVENT = "codexhost/groups/changed", roomIdentity = { roomId: groupRoomIdSchema }, memberIdentity = { ...roomIdentity, memberId: groupMemberIdSchema }, roomEdits = {
|
|
73262
|
+
title: nonblankString.optional(),
|
|
73263
|
+
unmentionedPolicy: groupUnmentionedPolicySchema.optional(),
|
|
73264
|
+
allowAgentMentions: external_exports.boolean().optional(),
|
|
73265
|
+
maxAgentHops: maxAgentHopsSchema.optional()
|
|
73266
|
+
}, groupsListParamsSchema = external_exports.strictObject({}), groupsListResultSchema = external_exports.object({ rooms: external_exports.array(groupRoomSchema) }), groupsGetParamsSchema = external_exports.strictObject({
|
|
73267
|
+
...roomIdentity,
|
|
73268
|
+
limit: positiveInteger.optional(),
|
|
73269
|
+
beforeSeq: positiveInteger.optional()
|
|
73270
|
+
}), groupsGetResultSchema = external_exports.object({
|
|
73271
|
+
room: groupRoomSchema.nullable(),
|
|
73272
|
+
messages: external_exports.array(groupMessageSchema),
|
|
73273
|
+
hasMore: external_exports.boolean()
|
|
73274
|
+
}), groupsCreateParamsSchema = external_exports.strictObject({
|
|
73275
|
+
...roomEdits,
|
|
73276
|
+
defaultCwd: nonblankString,
|
|
73277
|
+
members: external_exports.array(groupCreateMemberInputSchema)
|
|
73278
|
+
}), groupsCreateResultSchema = external_exports.object({ room: groupRoomSchema }), groupsUpdateParamsSchema = external_exports.strictObject({
|
|
73279
|
+
...roomIdentity,
|
|
73280
|
+
...roomEdits,
|
|
73281
|
+
pinned: external_exports.boolean().optional(),
|
|
73282
|
+
relayPaused: external_exports.boolean().optional()
|
|
73283
|
+
}), groupsUpdateResultSchema = groupsCreateResultSchema, groupsDeleteParamsSchema = external_exports.strictObject(roomIdentity), groupsDeleteResultSchema = external_exports.object({ deleted: external_exports.boolean() }), groupsAddMemberParamsSchema = external_exports.strictObject({
|
|
73284
|
+
...roomIdentity,
|
|
73285
|
+
member: groupCreateMemberInputSchema
|
|
73286
|
+
}), groupsAddMemberResultSchema = external_exports.object({
|
|
73287
|
+
room: groupRoomSchema,
|
|
73288
|
+
member: groupMemberSchema
|
|
73289
|
+
}), groupsUpdateMemberParamsSchema = external_exports.strictObject({
|
|
73290
|
+
...memberIdentity,
|
|
73291
|
+
...optionalMemberEdits,
|
|
73292
|
+
status: groupMemberStatusSchema.optional()
|
|
73293
|
+
}), groupsUpdateMemberResultSchema = groupsAddMemberResultSchema, groupsRemoveMemberParamsSchema = external_exports.strictObject(memberIdentity), groupsRemoveMemberResultSchema = groupsCreateResultSchema, groupsPostMessageParamsSchema = external_exports.strictObject({
|
|
73294
|
+
...roomIdentity,
|
|
73295
|
+
content: external_exports.string().max(64e3),
|
|
73296
|
+
attachments: external_exports.array(groupAttachmentSchema).max(12).optional(),
|
|
73297
|
+
replyToSeq: positiveInteger.optional(),
|
|
73298
|
+
targetMemberIds: external_exports.array(groupMemberIdSchema).optional(),
|
|
73299
|
+
mentionAll: external_exports.boolean().optional()
|
|
73300
|
+
}).refine((value) => value.content.trim().length > 0 || (value.attachments?.length ?? 0) > 0, "Message content or at least one attachment is required"), groupsPostMessageResultSchema = external_exports.object({
|
|
73301
|
+
room: groupRoomSchema,
|
|
73302
|
+
message: groupMessageSchema,
|
|
73303
|
+
awakenedMemberIds: external_exports.array(groupMemberIdSchema)
|
|
73304
|
+
}), groupsReadMessagesParamsSchema = external_exports.strictObject({
|
|
73305
|
+
...roomIdentity,
|
|
73306
|
+
fromSeq: positiveInteger.optional(),
|
|
73307
|
+
toSeq: positiveInteger.optional(),
|
|
73308
|
+
limit: positiveInteger.optional()
|
|
73309
|
+
}), groupsReadMessagesResultSchema = external_exports.object({
|
|
73310
|
+
...roomIdentity,
|
|
73311
|
+
messages: external_exports.array(groupMessageSchema),
|
|
73312
|
+
totalSeq: nonnegativeInteger
|
|
73313
|
+
});
|
|
73314
|
+
|
|
73068
73315
|
// packages/shared-contracts/dist/thread-archive-confirm.js
|
|
73069
73316
|
var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm", threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict(), threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
|
|
73070
73317
|
|
|
@@ -73169,7 +73416,7 @@ var NATIVE_CODEX_GOAL_METHOD = "codexhost/thread/goal", nativeCodexGoalInvocatio
|
|
|
73169
73416
|
|
|
73170
73417
|
// packages/shared-contracts/dist/client-channel.js
|
|
73171
73418
|
var CLIENT_CHANNEL_VERSION = 1, CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
|
|
73172
|
-
var THREAD_SECTION_CAPABILITY = "threadSectionsV1", threadSectionName = external_exports.string().trim().min(1), threadSectionId = external_exports.string().min(1), threadSectionAppearance = external_exports.object({
|
|
73419
|
+
var THREAD_SECTION_CAPABILITY = "threadSectionsV1", GROUP_ROOMS_CAPABILITY = "groupRoomsV1", threadSectionName = external_exports.string().trim().min(1), threadSectionId = external_exports.string().min(1), threadSectionAppearance = external_exports.object({
|
|
73173
73420
|
icon: external_exports.string().nullable(),
|
|
73174
73421
|
color: external_exports.string().nullable()
|
|
73175
73422
|
}), clientThreadSectionAppearanceSchema = threadSectionAppearance.nullable(), CLIENT_THREAD_SECTION_MUTATIONS = {
|
|
@@ -73203,6 +73450,22 @@ var THREAD_SECTION_CAPABILITY = "threadSectionsV1", threadSectionName = external
|
|
|
73203
73450
|
})
|
|
73204
73451
|
]), CLIENT_CHANNEL_METHODS = [
|
|
73205
73452
|
"codexhost/skills/list",
|
|
73453
|
+
ROLES_LIST_METHOD,
|
|
73454
|
+
ROLES_GET_METHOD,
|
|
73455
|
+
ROLES_SAVE_METHOD,
|
|
73456
|
+
ROLES_DELETE_METHOD,
|
|
73457
|
+
ROLES_CATALOG_METHOD,
|
|
73458
|
+
ROLES_LIKE_METHOD,
|
|
73459
|
+
GROUPS_LIST_METHOD,
|
|
73460
|
+
GROUPS_GET_METHOD,
|
|
73461
|
+
GROUPS_CREATE_METHOD,
|
|
73462
|
+
GROUPS_UPDATE_METHOD,
|
|
73463
|
+
GROUPS_DELETE_METHOD,
|
|
73464
|
+
GROUPS_ADD_MEMBER_METHOD,
|
|
73465
|
+
GROUPS_UPDATE_MEMBER_METHOD,
|
|
73466
|
+
GROUPS_REMOVE_MEMBER_METHOD,
|
|
73467
|
+
GROUPS_POST_MESSAGE_METHOD,
|
|
73468
|
+
GROUPS_READ_MESSAGES_METHOD,
|
|
73206
73469
|
"codexhost/voice/status",
|
|
73207
73470
|
"codexhost/voice/transcribe",
|
|
73208
73471
|
"codexhost/harness/display-settings/get",
|
|
@@ -73353,6 +73616,11 @@ var THREAD_SECTION_CAPABILITY = "threadSectionsV1", threadSectionName = external
|
|
|
73353
73616
|
}),
|
|
73354
73617
|
external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
|
|
73355
73618
|
external_exports.object({ type: external_exports.literal("sections-changed"), cursor: clientChannelCursorSchema }),
|
|
73619
|
+
external_exports.object({
|
|
73620
|
+
type: external_exports.literal("groups-changed"),
|
|
73621
|
+
cursor: clientChannelCursorSchema,
|
|
73622
|
+
roomId: external_exports.string().optional()
|
|
73623
|
+
}),
|
|
73356
73624
|
external_exports.object({
|
|
73357
73625
|
type: external_exports.literal("preferences-changed"),
|
|
73358
73626
|
cursor: clientChannelCursorSchema,
|
|
@@ -73475,6 +73743,7 @@ var THREAD_SECTION_CAPABILITY = "threadSectionsV1", threadSectionName = external
|
|
|
73475
73743
|
status: external_exports.object({ type: external_exports.string() }).passthrough(),
|
|
73476
73744
|
name: external_exports.string().nullable().optional(),
|
|
73477
73745
|
preview: external_exports.string().optional(),
|
|
73746
|
+
roleSnapshot: threadRoleSnapshotSchema.optional(),
|
|
73478
73747
|
codexhostImportSource: clientThreadImportSourceSchema.optional(),
|
|
73479
73748
|
turns: external_exports.array(clientTurnSchema).length(0)
|
|
73480
73749
|
}).passthrough(),
|
|
@@ -74447,6 +74716,9 @@ function webToolOutputPreviews(meta3) {
|
|
|
74447
74716
|
return result.success ? result.data : [];
|
|
74448
74717
|
}
|
|
74449
74718
|
|
|
74719
|
+
// packages/shared-contracts/dist/desktop-shell.js
|
|
74720
|
+
var desktopShellOpenParamsSchema = external_exports.strictObject({}), desktopShellOpenResultSchema = external_exports.strictObject({});
|
|
74721
|
+
|
|
74450
74722
|
// packages/shared-contracts/dist/console.js
|
|
74451
74723
|
var consoleAnnouncementSchema = external_exports.strictObject({
|
|
74452
74724
|
title: external_exports.string().trim().min(1).max(200),
|
|
@@ -75344,7 +75616,7 @@ var HostClientChannel = class {
|
|
|
75344
75616
|
throw new Error("Host unavailable");
|
|
75345
75617
|
this.descriptor = descriptor;
|
|
75346
75618
|
let url2 = new URL(`http://127.0.0.1:${descriptor.port}/v1/events`);
|
|
75347
|
-
url2.searchParams.set(THREAD_SECTION_CAPABILITY, "1"), this.cursor && (url2.searchParams.set("epoch", this.cursor.epoch), url2.searchParams.set("after", String(this.cursor.sequence)));
|
|
75619
|
+
url2.searchParams.set(THREAD_SECTION_CAPABILITY, "1"), url2.searchParams.set(GROUP_ROOMS_CAPABILITY, "1"), this.cursor && (url2.searchParams.set("epoch", this.cursor.epoch), url2.searchParams.set("after", String(this.cursor.sequence)));
|
|
75348
75620
|
let response = await fetch(url2, {
|
|
75349
75621
|
redirect: "error",
|
|
75350
75622
|
headers: { authorization: `Bearer ${descriptor.token}` },
|
|
@@ -75386,7 +75658,8 @@ var HostClientChannel = class {
|
|
|
75386
75658
|
}
|
|
75387
75659
|
}
|
|
75388
75660
|
async post(route, body, timeoutMs = 12e4) {
|
|
75389
|
-
|
|
75661
|
+
let connection = this.controller;
|
|
75662
|
+
if (this.stopped || !this.online || !connection || connection.signal.aborted)
|
|
75390
75663
|
throw new Error("CH is disconnected; reconnect before submitting an operation");
|
|
75391
75664
|
let generation = this.generation, response, value;
|
|
75392
75665
|
try {
|
|
@@ -75398,7 +75671,7 @@ var HostClientChannel = class {
|
|
|
75398
75671
|
"content-type": "application/json"
|
|
75399
75672
|
},
|
|
75400
75673
|
body: JSON.stringify(body),
|
|
75401
|
-
signal: AbortSignal.timeout(timeoutMs)
|
|
75674
|
+
signal: AbortSignal.any([connection.signal, AbortSignal.timeout(timeoutMs)])
|
|
75402
75675
|
});
|
|
75403
75676
|
let parsed = await response.json();
|
|
75404
75677
|
if (!parsed || typeof parsed != "object" || Array.isArray(parsed))
|
|
@@ -75509,7 +75782,7 @@ async function ensureHostService(options) {
|
|
|
75509
75782
|
throw new Error("Shared Host Launcher must be an absolute path");
|
|
75510
75783
|
let env = Object.fromEntries(Object.entries({ ...process.env, ...options.environment }).filter(([key, value]) => {
|
|
75511
75784
|
let upper = key.toUpperCase();
|
|
75512
|
-
return upper === "CODEXHOST_WEB_SERVICE" ? value === "0" || value === "1" : upper === "CODEXHOST_EXTERNAL_CLIENT_PORT" ? typeof value == "string" : [
|
|
75785
|
+
return upper === "CODEXHOST_WEB_SERVICE" ? value === "0" || value === "1" : upper === "CODEXHOST_EXTERNAL_CLIENT_PORT" || upper === "CODEXHOST_CLAUDE_CODE_ENTRYPOINT" ? typeof value == "string" : [
|
|
75513
75786
|
"CODEXHOST_NPM_NODE_PATH",
|
|
75514
75787
|
"CODEXHOST_NPM_CLI_PATH",
|
|
75515
75788
|
"CODEXHOST_NPM_LAUNCHER_PATH",
|
|
@@ -78037,6 +78310,8 @@ async function pinnedPeerGetJson(record6, path7, options = {}) {
|
|
|
78037
78310
|
});
|
|
78038
78311
|
req.on("error", () => {
|
|
78039
78312
|
fail(new SessionRuntimeError("remote/offline", "Remote peer is unreachable"));
|
|
78313
|
+
}), req.once("upgrade", (_res, socket) => {
|
|
78314
|
+
socket.destroy(), req.destroy(), fail(new SessionRuntimeError("remote/offline", "Remote peer is unreachable"));
|
|
78040
78315
|
}), req.on("response", (res) => {
|
|
78041
78316
|
let status = res.statusCode ?? 0;
|
|
78042
78317
|
if (status >= 300 && status < 400) {
|
|
@@ -78289,7 +78564,10 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
78289
78564
|
this.changed(this.hostId);
|
|
78290
78565
|
}
|
|
78291
78566
|
if (this.life.signal.aborted) return;
|
|
78292
|
-
let query = new URLSearchParams({
|
|
78567
|
+
let query = new URLSearchParams({
|
|
78568
|
+
[THREAD_SECTION_CAPABILITY]: "1",
|
|
78569
|
+
[GROUP_ROOMS_CAPABILITY]: "1"
|
|
78570
|
+
});
|
|
78293
78571
|
this.cursor && (query.set("epoch", this.cursor.epoch), query.set("after", String(this.cursor.sequence)));
|
|
78294
78572
|
let response = await this.fetch(
|
|
78295
78573
|
`/api/ch/v1/events?${query}`,
|
|
@@ -79178,7 +79456,7 @@ var DEFAULT_MODEL_INSPECT_TIMEOUT_MS = 5e3, INSPECT_TIMED_OUT = /* @__PURE__ */
|
|
|
79178
79456
|
inspection
|
|
79179
79457
|
});
|
|
79180
79458
|
}
|
|
79181
|
-
let
|
|
79459
|
+
let groups2 = values2.flatMap(
|
|
79182
79460
|
({ id: id2, name: name2, inspection }) => inspection.status === "ready" ? [groupOf(id2, name2, inspection)] : []
|
|
79183
79461
|
), ready = values2.filter(
|
|
79184
79462
|
(value) => value.inspection.status === "ready" && value.inspection.catalog.models.length
|
|
@@ -79205,8 +79483,8 @@ var DEFAULT_MODEL_INSPECT_TIMEOUT_MS = 5e3, INSPECT_TIMED_OUT = /* @__PURE__ */
|
|
|
79205
79483
|
let catalog = withHarnessDisplayOrder(
|
|
79206
79484
|
{
|
|
79207
79485
|
...selection2 ? { default: selection2 } : {},
|
|
79208
|
-
groups,
|
|
79209
|
-
routableProviders:
|
|
79486
|
+
groups: groups2,
|
|
79487
|
+
routableProviders: groups2.map((group) => group.id),
|
|
79210
79488
|
failures,
|
|
79211
79489
|
notInstalled
|
|
79212
79490
|
},
|
|
@@ -83669,7 +83947,10 @@ var MAX_LINKED_PEER_IDS = 128, normalizedPeerOrigin = (origin) => URL.parse(orig
|
|
|
83669
83947
|
events;
|
|
83670
83948
|
clients = /* @__PURE__ */ new Map();
|
|
83671
83949
|
sources = /* @__PURE__ */ new Map();
|
|
83950
|
+
peerHosts = /* @__PURE__ */ new Map();
|
|
83672
83951
|
peerRealtimeCleanups = /* @__PURE__ */ new Map();
|
|
83952
|
+
peerGroupCleanups = /* @__PURE__ */ new Map();
|
|
83953
|
+
groupChangeListeners = /* @__PURE__ */ new Set();
|
|
83673
83954
|
allowLoopback;
|
|
83674
83955
|
localNodeId;
|
|
83675
83956
|
streamIdleTimeoutMs;
|
|
@@ -83701,8 +83982,10 @@ var MAX_LINKED_PEER_IDS = 128, normalizedPeerOrigin = (origin) => URL.parse(orig
|
|
|
83701
83982
|
}
|
|
83702
83983
|
install(record6, client) {
|
|
83703
83984
|
let previous = this.clients.get(record6.peerId), inheritedManifest = !client && record6.enabled && previous && previous.record.origin === record6.origin ? previous.manifest : void 0, next = client ?? this.createClient(record6, inheritedManifest);
|
|
83704
|
-
if (this.peerRealtimeCleanups.get(record6.peerId)?.(), this.peerRealtimeCleanups.delete(record6.peerId), this.sources.get(record6.peerId)?.close(), this.sources.delete(record6.peerId), previous?.close(), this.clients.set(record6.peerId, next), record6.enabled) {
|
|
83705
|
-
let host = new PeerChHostClient(next.chTransport())
|
|
83985
|
+
if (this.peerRealtimeCleanups.get(record6.peerId)?.(), this.peerRealtimeCleanups.delete(record6.peerId), this.peerGroupCleanups.get(record6.peerId)?.(), this.peerGroupCleanups.delete(record6.peerId), this.sources.get(record6.peerId)?.close(), this.sources.delete(record6.peerId), this.peerHosts.delete(record6.peerId), previous?.close(), this.clients.set(record6.peerId, next), record6.enabled) {
|
|
83986
|
+
let host = new PeerChHostClient(next.chTransport());
|
|
83987
|
+
this.peerHosts.set(record6.peerId, host);
|
|
83988
|
+
let translateInbound = (text4) => translateThreadLinksFromPeer(text4, {
|
|
83706
83989
|
sourcePeerNodes: next.manifest?.peerNodes,
|
|
83707
83990
|
hostIdForNodeId: (nodeId) => this.hostIdForNodeId(nodeId)
|
|
83708
83991
|
}), source = new PeerThreadSource({
|
|
@@ -83715,7 +83998,9 @@ var MAX_LINKED_PEER_IDS = 128, normalizedPeerOrigin = (origin) => URL.parse(orig
|
|
|
83715
83998
|
onUsageChanged: (threadId) => this.onUsageChanged?.(next.hostId, threadId),
|
|
83716
83999
|
onCatalogInspectionChanged: () => this.onCatalogInspectionChanged?.(next.hostId),
|
|
83717
84000
|
onSkillsChanged: () => this.onSkillsChanged?.(next.hostId),
|
|
83718
|
-
onConnection: (online) =>
|
|
84001
|
+
onConnection: (online) => {
|
|
84002
|
+
this.emitGroupChange({ hostId: next.hostId }), this.onConnection?.(next.hostId, online);
|
|
84003
|
+
},
|
|
83719
84004
|
onReset: (epoch, full) => this.onReset?.(next.hostId, epoch, full),
|
|
83720
84005
|
projector: (threadId) => {
|
|
83721
84006
|
let base = this.projector?.(threadId);
|
|
@@ -83729,12 +84014,55 @@ var MAX_LINKED_PEER_IDS = 128, normalizedPeerOrigin = (origin) => URL.parse(orig
|
|
|
83729
84014
|
};
|
|
83730
84015
|
}
|
|
83731
84016
|
});
|
|
83732
|
-
this.sources.set(record6.peerId, source), this.
|
|
84017
|
+
this.sources.set(record6.peerId, source), this.peerGroupCleanups.set(
|
|
84018
|
+
record6.peerId,
|
|
84019
|
+
host.realtime.subscribe((event) => {
|
|
84020
|
+
event.type === "groups-changed" ? this.emitGroupChange({
|
|
84021
|
+
hostId: next.hostId,
|
|
84022
|
+
...event.roomId !== void 0 ? { roomId: event.roomId } : {}
|
|
84023
|
+
}) : event.type === "hello" && this.emitGroupChange({ hostId: next.hostId });
|
|
84024
|
+
})
|
|
84025
|
+
), this.onPeerRealtime && this.peerRealtimeCleanups.set(
|
|
83733
84026
|
record6.peerId,
|
|
83734
84027
|
this.onPeerRealtime(next.hostId, host.realtime)
|
|
83735
84028
|
);
|
|
83736
84029
|
}
|
|
83737
|
-
return next.start(), next;
|
|
84030
|
+
return this.emitGroupChange({ hostId: next.hostId }), next.start(), next;
|
|
84031
|
+
}
|
|
84032
|
+
emitGroupChange(event) {
|
|
84033
|
+
for (let listener of this.groupChangeListeners)
|
|
84034
|
+
listener(event);
|
|
84035
|
+
}
|
|
84036
|
+
onGroupChange(listener) {
|
|
84037
|
+
return this.groupChangeListeners.add(listener), () => {
|
|
84038
|
+
this.groupChangeListeners.delete(listener);
|
|
84039
|
+
};
|
|
84040
|
+
}
|
|
84041
|
+
groupPeers() {
|
|
84042
|
+
let peers = [];
|
|
84043
|
+
for (let client of this.clients.values()) {
|
|
84044
|
+
let peer = this.toGroupPeer(client);
|
|
84045
|
+
peer !== void 0 && peers.push(peer);
|
|
84046
|
+
}
|
|
84047
|
+
return peers;
|
|
84048
|
+
}
|
|
84049
|
+
groupPeer(hostId2) {
|
|
84050
|
+
let client = this.client(hostId2);
|
|
84051
|
+
return client === void 0 ? void 0 : this.toGroupPeer(client);
|
|
84052
|
+
}
|
|
84053
|
+
toGroupPeer(client) {
|
|
84054
|
+
if (!client.record.enabled) return;
|
|
84055
|
+
let host = this.peerHosts.get(client.record.peerId);
|
|
84056
|
+
if (host)
|
|
84057
|
+
return {
|
|
84058
|
+
hostId: client.hostId,
|
|
84059
|
+
displayName: client.record.name,
|
|
84060
|
+
state: client.state,
|
|
84061
|
+
...client.record.color !== void 0 ? { color: client.record.color } : {},
|
|
84062
|
+
online: client.state === "connected" && client.isStreamOnline,
|
|
84063
|
+
filePreview: client.manifest?.capabilities?.attachments === 1,
|
|
84064
|
+
host
|
|
84065
|
+
};
|
|
83738
84066
|
}
|
|
83739
84067
|
selfNodeId() {
|
|
83740
84068
|
return this.localNodeId;
|
|
@@ -84085,7 +84413,7 @@ var MAX_LINKED_PEER_IDS = 128, normalizedPeerOrigin = (origin) => URL.parse(orig
|
|
|
84085
84413
|
let { peerId } = remotePeerIdParamsSchema.parse(input3), client = this.get(peerId);
|
|
84086
84414
|
switch (action) {
|
|
84087
84415
|
case "remove":
|
|
84088
|
-
return this.store.save(this.records().filter((r) => r.peerId !== peerId)), this.peerRealtimeCleanups.get(peerId)?.(), this.peerRealtimeCleanups.delete(peerId), this.sources.get(peerId)?.close(), this.sources.delete(peerId), client.close(), this.clients.delete(peerId), this.onPeerRemoved?.(client.hostId), this.changed(client.hostId), { removed: !0 };
|
|
84416
|
+
return this.store.save(this.records().filter((r) => r.peerId !== peerId)), this.peerRealtimeCleanups.get(peerId)?.(), this.peerRealtimeCleanups.delete(peerId), this.peerGroupCleanups.get(peerId)?.(), this.peerGroupCleanups.delete(peerId), this.sources.get(peerId)?.close(), this.sources.delete(peerId), this.peerHosts.delete(peerId), client.close(), this.clients.delete(peerId), this.emitGroupChange({ hostId: client.hostId }), this.onPeerRemoved?.(client.hostId), this.changed(client.hostId), { removed: !0 };
|
|
84089
84417
|
case "update": {
|
|
84090
84418
|
let p = remotePeerUpdateParamsSchema.parse(input3), old = client.record, conn = p.connectionUrl || p.origin || p.token ? parseConnectionLink(
|
|
84091
84419
|
p.connectionUrl ? p : {
|
|
@@ -84124,7 +84452,7 @@ var MAX_LINKED_PEER_IDS = 128, normalizedPeerOrigin = (origin) => URL.parse(orig
|
|
|
84124
84452
|
throw probedClient?.close(), error62;
|
|
84125
84453
|
}
|
|
84126
84454
|
if (record6.enabled === old.enabled && record6.origin === old.origin && record6.token === old.token)
|
|
84127
|
-
return client.record = record6, this.changed(client.hostId), { peer: this.summarize(client) };
|
|
84455
|
+
return client.record = record6, this.emitGroupChange({ hostId: client.hostId }), this.changed(client.hostId), { peer: this.summarize(client) };
|
|
84128
84456
|
let next = this.install(record6, probedClient);
|
|
84129
84457
|
return this.changed(next.hostId), { peer: this.summarize(next) };
|
|
84130
84458
|
}
|
|
@@ -84154,8 +84482,10 @@ var MAX_LINKED_PEER_IDS = 128, normalizedPeerOrigin = (origin) => URL.parse(orig
|
|
|
84154
84482
|
close() {
|
|
84155
84483
|
for (let stop of this.peerRealtimeCleanups.values()) stop();
|
|
84156
84484
|
this.peerRealtimeCleanups.clear();
|
|
84485
|
+
for (let stop of this.peerGroupCleanups.values()) stop();
|
|
84486
|
+
this.peerGroupCleanups.clear(), this.groupChangeListeners.clear();
|
|
84157
84487
|
for (let s of this.sources.values()) s.close();
|
|
84158
|
-
this.sources.clear();
|
|
84488
|
+
this.sources.clear(), this.peerHosts.clear();
|
|
84159
84489
|
for (let p of this.clients.values()) p.close();
|
|
84160
84490
|
}
|
|
84161
84491
|
};
|
|
@@ -86879,9 +87209,9 @@ var core, hasRequiredCore;
|
|
|
86879
87209
|
function requireCore() {
|
|
86880
87210
|
return hasRequiredCore || (hasRequiredCore = 1, core = requireJson()), core;
|
|
86881
87211
|
}
|
|
86882
|
-
var
|
|
87212
|
+
var timestamp2, hasRequiredTimestamp;
|
|
86883
87213
|
function requireTimestamp() {
|
|
86884
|
-
if (hasRequiredTimestamp) return
|
|
87214
|
+
if (hasRequiredTimestamp) return timestamp2;
|
|
86885
87215
|
hasRequiredTimestamp = 1;
|
|
86886
87216
|
let Type2 = requireType(), YAML_DATE_REGEXP = new RegExp(
|
|
86887
87217
|
"^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
|
|
@@ -86913,13 +87243,13 @@ function requireTimestamp() {
|
|
|
86913
87243
|
function representYamlTimestamp(object4) {
|
|
86914
87244
|
return object4.toISOString();
|
|
86915
87245
|
}
|
|
86916
|
-
return
|
|
87246
|
+
return timestamp2 = new Type2("tag:yaml.org,2002:timestamp", {
|
|
86917
87247
|
kind: "scalar",
|
|
86918
87248
|
resolve: resolveYamlTimestamp,
|
|
86919
87249
|
construct: constructYamlTimestamp,
|
|
86920
87250
|
instanceOf: Date,
|
|
86921
87251
|
represent: representYamlTimestamp
|
|
86922
|
-
}),
|
|
87252
|
+
}), timestamp2;
|
|
86923
87253
|
}
|
|
86924
87254
|
var merge2, hasRequiredMerge;
|
|
86925
87255
|
function requireMerge() {
|
|
@@ -100088,9 +100418,9 @@ var LocalTerminalHandle = class {
|
|
|
100088
100418
|
}
|
|
100089
100419
|
this.signalMembers(members2, "SIGKILL");
|
|
100090
100420
|
}
|
|
100091
|
-
unionMembers(...
|
|
100421
|
+
unionMembers(...groups2) {
|
|
100092
100422
|
let members2 = [], seen = /* @__PURE__ */ new Set();
|
|
100093
|
-
for (let group of
|
|
100423
|
+
for (let group of groups2)
|
|
100094
100424
|
for (let member of group) {
|
|
100095
100425
|
let key = `${member.pid}:${member.started}`;
|
|
100096
100426
|
seen.has(key) || (seen.add(key), members2.push(member));
|
|
@@ -102840,7 +103170,8 @@ var RemotePeerAttachments = class {
|
|
|
102840
103170
|
let response = await peerFetch(activePeer.record, "/api/peer/v1/prompt", {
|
|
102841
103171
|
method: "POST",
|
|
102842
103172
|
body: validated.data,
|
|
102843
|
-
timeoutMs: this.requestTimeoutMs
|
|
103173
|
+
timeoutMs: this.requestTimeoutMs,
|
|
103174
|
+
...activePeer.outboundFetchOptions?.()
|
|
102844
103175
|
}), payload = await readPeerJson(
|
|
102845
103176
|
response,
|
|
102846
103177
|
"remote/request-failed",
|
|
@@ -103053,13 +103384,13 @@ async function loadCatalog(target2, call) {
|
|
|
103053
103384
|
}
|
|
103054
103385
|
return {};
|
|
103055
103386
|
})
|
|
103056
|
-
),
|
|
103387
|
+
), groups2 = rows.flatMap((row) => row.group ? [row.group] : []), first = rows.find((row) => row.group && row.preferred);
|
|
103057
103388
|
if (!first?.group || !first.preferred)
|
|
103058
103389
|
throw new SessionRuntimeError("remote/no-harness", "No ready Harness in the selected remote project.");
|
|
103059
103390
|
return {
|
|
103060
103391
|
default: { provider: first.group.id, model: first.preferred },
|
|
103061
|
-
groups,
|
|
103062
|
-
routableProviders:
|
|
103392
|
+
groups: groups2,
|
|
103393
|
+
routableProviders: groups2.map((g) => g.id),
|
|
103063
103394
|
failures: rows.flatMap((row) => row.failure ? [row.failure] : [])
|
|
103064
103395
|
};
|
|
103065
103396
|
}
|
|
@@ -104008,7 +104339,7 @@ function remoteWorkspaceGroups(hosts, threads) {
|
|
|
104008
104339
|
}, normalize2 = (path7) => {
|
|
104009
104340
|
let p = path7.replaceAll("\\", "/").replace(/\/+$/u, "");
|
|
104010
104341
|
return /^[a-z]:/iu.test(p) ? p.toLowerCase() : p;
|
|
104011
|
-
}, projects = host.projects ?? [],
|
|
104342
|
+
}, projects = host.projects ?? [], groups2 = [
|
|
104012
104343
|
...projects.map((project2) => ({ project: project2, ids: [] })),
|
|
104013
104344
|
{ project: void 0, ids: [] }
|
|
104014
104345
|
];
|
|
@@ -104017,9 +104348,9 @@ function remoteWorkspaceGroups(hosts, threads) {
|
|
|
104017
104348
|
let root = normalize2(project2.path);
|
|
104018
104349
|
return cwd === root || cwd.startsWith(root + "/");
|
|
104019
104350
|
}).sort((a, b) => b.path.length - a.path.length)[0];
|
|
104020
|
-
|
|
104351
|
+
groups2.find((group) => group.project === match)?.ids.push(row.sessionId);
|
|
104021
104352
|
}
|
|
104022
|
-
return
|
|
104353
|
+
return groups2.filter((group) => group.project || group.ids.length || projects.length === 0).map(({ project: project2, ids }) => ({
|
|
104023
104354
|
workspaceId: remoteWorkspaceId(host.hostId, project2?.id ?? null),
|
|
104024
104355
|
path: project2?.path ?? "",
|
|
104025
104356
|
title: project2?.name ?? remote.displayName,
|
|
@@ -105196,17 +105527,17 @@ var RemoteSessions = class {
|
|
|
105196
105527
|
]);
|
|
105197
105528
|
}
|
|
105198
105529
|
syncGroups() {
|
|
105199
|
-
let
|
|
105200
|
-
for (let group of
|
|
105530
|
+
let groups2 = this.remoteGroupsSnapshot(), bySession = /* @__PURE__ */ new Map();
|
|
105531
|
+
for (let group of groups2)
|
|
105201
105532
|
for (let sessionId of group.sessionIds)
|
|
105202
105533
|
bySession.set(sessionId, group.workspaceId);
|
|
105203
|
-
this.remoteWorkspaceBySession = bySession, this.workspaces?.setRemoteGroups(
|
|
105534
|
+
this.remoteWorkspaceBySession = bySession, this.workspaces?.setRemoteGroups(groups2);
|
|
105204
105535
|
}
|
|
105205
105536
|
workspaceMapForListing() {
|
|
105206
105537
|
if (this.remoteWorkspaceBySession.size > 0 || this.entries.size === 0)
|
|
105207
105538
|
return this.remoteWorkspaceBySession;
|
|
105208
|
-
let
|
|
105209
|
-
for (let group of
|
|
105539
|
+
let groups2 = this.remoteGroupsSnapshot(), bySession = /* @__PURE__ */ new Map();
|
|
105540
|
+
for (let group of groups2)
|
|
105210
105541
|
for (let sessionId of group.sessionIds)
|
|
105211
105542
|
bySession.set(sessionId, group.workspaceId);
|
|
105212
105543
|
return this.remoteWorkspaceBySession = bySession, bySession;
|
|
@@ -106362,10 +106693,10 @@ var RemoteSessions = class {
|
|
|
106362
106693
|
let peerCatalog = await peerSource2.catalog.models().catch(() => {
|
|
106363
106694
|
});
|
|
106364
106695
|
if (!peerCatalog?.groups.length) return base2;
|
|
106365
|
-
let bound = base2.groups[0],
|
|
106696
|
+
let bound = base2.groups[0], groups2 = bound ? peerCatalog.groups.some((group) => group.id === bound.id) ? peerCatalog.groups.map((group) => group.id === bound.id ? bound : group) : [bound, ...peerCatalog.groups] : peerCatalog.groups;
|
|
106366
106697
|
return {
|
|
106367
106698
|
...base2,
|
|
106368
|
-
groups,
|
|
106699
|
+
groups: groups2,
|
|
106369
106700
|
...peerCatalog.harnessOrder ? { harnessOrder: peerCatalog.harnessOrder } : {}
|
|
106370
106701
|
};
|
|
106371
106702
|
}
|
|
@@ -107110,7 +107441,7 @@ var RemotePeerWorkspaceFiles = class {
|
|
|
107110
107441
|
var import_qrcode_terminal = __toESM(require_main(), 1);
|
|
107111
107442
|
import { existsSync as existsSync16, readFileSync as readFileSync18 } from "node:fs";
|
|
107112
107443
|
import { homedir as homedir11, hostname as hostname4 } from "node:os";
|
|
107113
|
-
import { basename as basename15, dirname as dirname19, join as
|
|
107444
|
+
import { basename as basename15, dirname as dirname19, join as join37, resolve as resolve25 } from "node:path";
|
|
107114
107445
|
import { parseArgs } from "node:util";
|
|
107115
107446
|
|
|
107116
107447
|
// packages/web-server/src/workspace-video.ts
|
|
@@ -107118,14 +107449,15 @@ import { constants as constants9 } from "node:fs";
|
|
|
107118
107449
|
import { open as open9 } from "node:fs/promises";
|
|
107119
107450
|
import { extname as extname7, resolve as resolve11 } from "node:path";
|
|
107120
107451
|
import { pipeline as pipeline3 } from "node:stream/promises";
|
|
107121
|
-
var
|
|
107452
|
+
var MEDIA_TYPES = {
|
|
107122
107453
|
".mp4": "video/mp4",
|
|
107123
107454
|
".m4v": "video/mp4",
|
|
107124
107455
|
".mov": "video/quicktime",
|
|
107125
107456
|
".webm": "video/webm",
|
|
107126
|
-
".ogv": "video/ogg"
|
|
107457
|
+
".ogv": "video/ogg",
|
|
107458
|
+
".mp3": "audio/mpeg"
|
|
107127
107459
|
};
|
|
107128
|
-
function
|
|
107460
|
+
function byteRange(header2, size) {
|
|
107129
107461
|
let match = /^bytes=(\d*)-(\d*)$/iu.exec(header2.trim());
|
|
107130
107462
|
if (!match || !match[1] && !match[2]) return;
|
|
107131
107463
|
if (!match[1]) {
|
|
@@ -107136,14 +107468,14 @@ function videoRange(header2, size) {
|
|
|
107136
107468
|
if (!(match[2] && end < start))
|
|
107137
107469
|
return start >= size ? null : [start, Math.min(end, size - 1)];
|
|
107138
107470
|
}
|
|
107139
|
-
async function
|
|
107471
|
+
async function serveWorkspaceMedia(request3, response, url2, workspace) {
|
|
107140
107472
|
response.setHeader("Cache-Control", "private, no-store");
|
|
107141
107473
|
let root = workspace(url2.searchParams.get("sessionId") ?? ""), path7 = url2.searchParams.get("path");
|
|
107142
107474
|
if (!root || !path7 || path7.includes("\0")) {
|
|
107143
107475
|
response.writeHead(404).end();
|
|
107144
107476
|
return;
|
|
107145
107477
|
}
|
|
107146
|
-
let mediaType =
|
|
107478
|
+
let mediaType = MEDIA_TYPES[extname7(path7).toLowerCase()], file3;
|
|
107147
107479
|
try {
|
|
107148
107480
|
let nativePath = process.platform === "win32" ? path7.replace(/^\/(?=[a-z]:[/\\])/iu, "") : path7;
|
|
107149
107481
|
file3 = await open9(resolve11(root, nativePath), constants9.O_RDONLY | constants9.O_NONBLOCK);
|
|
@@ -107154,7 +107486,7 @@ async function serveWorkspaceVideo(request3, response, url2, workspace) {
|
|
|
107154
107486
|
return;
|
|
107155
107487
|
}
|
|
107156
107488
|
response.setHeader("Content-Type", mediaType), response.setHeader("Content-Disposition", "inline"), response.setHeader("X-Content-Type-Options", "nosniff"), response.setHeader("Accept-Ranges", "bytes");
|
|
107157
|
-
let range = request3.method === "GET" && request3.headers.range && !request3.headers["if-range"] ?
|
|
107489
|
+
let range = request3.method === "GET" && request3.headers.range && !request3.headers["if-range"] ? byteRange(request3.headers.range, meta3.size) : void 0;
|
|
107158
107490
|
if (range === null) {
|
|
107159
107491
|
response.writeHead(416, { "Content-Range": `bytes */${meta3.size}`, "Content-Length": "0" }).end();
|
|
107160
107492
|
return;
|
|
@@ -110202,19 +110534,32 @@ function registerRelayRpc(rpc2, tokens, relay2) {
|
|
|
110202
110534
|
}
|
|
110203
110535
|
|
|
110204
110536
|
// packages/shared-contracts/dist/desktop-screenshot.js
|
|
110205
|
-
var DESKTOP_SCREENSHOT_PATH = "/api/desktop/screenshot", DESKTOP_SCREENSHOT_TIME_HEADER = "x-codexhost-captured-at", DESKTOP_SCREENSHOT_ERRORS = [
|
|
110537
|
+
var DESKTOP_SCREENSHOT_PATH = "/api/desktop/screenshot", DESKTOP_SCREENSHOT_DISPLAYS_PATH = "/api/desktop/screenshot/displays", DESKTOP_SCREENSHOT_TIME_HEADER = "x-codexhost-captured-at", DESKTOP_SCREENSHOT_ERRORS = [
|
|
110206
110538
|
"unsupported",
|
|
110207
110539
|
"permission-denied",
|
|
110208
110540
|
"display-unavailable",
|
|
110541
|
+
"invalid-display",
|
|
110209
110542
|
"capture-failed",
|
|
110210
110543
|
"image-too-large",
|
|
110211
110544
|
"busy",
|
|
110212
110545
|
"timeout",
|
|
110213
110546
|
"unavailable"
|
|
110214
|
-
];
|
|
110547
|
+
], CANONICAL_UINT32_PATTERN = /^(?:0|[1-9][0-9]{0,9})$/u;
|
|
110215
110548
|
function isDesktopScreenshotError(value) {
|
|
110216
110549
|
return typeof value == "string" && DESKTOP_SCREENSHOT_ERRORS.some((code) => code === value);
|
|
110217
110550
|
}
|
|
110551
|
+
function isValidDesktopDisplayId(value) {
|
|
110552
|
+
if (typeof value != "string" || !CANONICAL_UINT32_PATTERN.test(value))
|
|
110553
|
+
return !1;
|
|
110554
|
+
let parsed = Number(value);
|
|
110555
|
+
return Number.isSafeInteger(parsed) && parsed >= 0 && parsed <= 4294967295;
|
|
110556
|
+
}
|
|
110557
|
+
function isDesktopScreenshotDisplay(value) {
|
|
110558
|
+
if (value === null || typeof value != "object" || Array.isArray(value))
|
|
110559
|
+
return !1;
|
|
110560
|
+
let candidate = value;
|
|
110561
|
+
return isValidDesktopDisplayId(candidate.id) && typeof candidate.name == "string" && candidate.name.trim().length > 0 && typeof candidate.width == "number" && Number.isSafeInteger(candidate.width) && candidate.width > 0 && typeof candidate.height == "number" && Number.isSafeInteger(candidate.height) && candidate.height > 0 && typeof candidate.isPrimary == "boolean";
|
|
110562
|
+
}
|
|
110218
110563
|
|
|
110219
110564
|
// packages/web-server/src/desktop-screenshot.ts
|
|
110220
110565
|
import { spawn as spawn5 } from "node:child_process";
|
|
@@ -110222,12 +110567,42 @@ var STATUS = {
|
|
|
110222
110567
|
unsupported: 501,
|
|
110223
110568
|
"permission-denied": 403,
|
|
110224
110569
|
"display-unavailable": 409,
|
|
110570
|
+
"invalid-display": 400,
|
|
110225
110571
|
"capture-failed": 502,
|
|
110226
110572
|
"image-too-large": 413,
|
|
110227
110573
|
busy: 429,
|
|
110228
110574
|
timeout: 504,
|
|
110229
110575
|
unavailable: 503
|
|
110230
|
-
},
|
|
110576
|
+
}, MAX_REQUEST_BODY_BYTES = 4096, MAX_DISPLAY_LIST_BYTES = 64 * 1024;
|
|
110577
|
+
async function readCaptureDisplayId(request3) {
|
|
110578
|
+
let contentLength = Number(request3.headers["content-length"]);
|
|
110579
|
+
if (Number.isFinite(contentLength) && contentLength > MAX_REQUEST_BODY_BYTES)
|
|
110580
|
+
return request3.resume(), { ok: !1 };
|
|
110581
|
+
let chunks = [], bytes = 0;
|
|
110582
|
+
try {
|
|
110583
|
+
for await (let chunk of request3.iterator({ destroyOnReturn: !1 })) {
|
|
110584
|
+
let buffer3 = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
110585
|
+
if (bytes += buffer3.length, bytes > MAX_REQUEST_BODY_BYTES)
|
|
110586
|
+
return request3.resume(), { ok: !1 };
|
|
110587
|
+
chunks.push(buffer3);
|
|
110588
|
+
}
|
|
110589
|
+
} catch {
|
|
110590
|
+
return { ok: !1 };
|
|
110591
|
+
}
|
|
110592
|
+
let raw = Buffer.concat(chunks, bytes).toString("utf8").trim();
|
|
110593
|
+
if (raw === "") return { ok: !0, displayId: void 0 };
|
|
110594
|
+
let parsed;
|
|
110595
|
+
try {
|
|
110596
|
+
parsed = JSON.parse(raw);
|
|
110597
|
+
} catch {
|
|
110598
|
+
return { ok: !1 };
|
|
110599
|
+
}
|
|
110600
|
+
if (parsed === null || typeof parsed != "object" || Array.isArray(parsed))
|
|
110601
|
+
return { ok: !1 };
|
|
110602
|
+
let body = parsed;
|
|
110603
|
+
return Object.keys(body).some((key) => key !== "displayId") ? { ok: !1 } : body.displayId === void 0 ? { ok: !0, displayId: void 0 } : isValidDesktopDisplayId(body.displayId) ? { ok: !0, displayId: Number(body.displayId) } : { ok: !1 };
|
|
110604
|
+
}
|
|
110605
|
+
var DesktopScreenshots = class {
|
|
110231
110606
|
constructor(command, timeoutMs = 15e3) {
|
|
110232
110607
|
this.command = command;
|
|
110233
110608
|
this.timeoutMs = timeoutMs;
|
|
@@ -110239,7 +110614,7 @@ var STATUS = {
|
|
|
110239
110614
|
close() {
|
|
110240
110615
|
this.closed = !0, this.active?.abort();
|
|
110241
110616
|
}
|
|
110242
|
-
async
|
|
110617
|
+
async serveDisplays(request3, response) {
|
|
110243
110618
|
response.setHeader("Cache-Control", "private, no-store"), response.setHeader("X-Content-Type-Options", "nosniff");
|
|
110244
110619
|
let fail = (error62) => {
|
|
110245
110620
|
response.destroyed || response.writeHead(STATUS[error62], { "content-type": "application/json" }).end(JSON.stringify({ error: error62 }));
|
|
@@ -110255,7 +110630,36 @@ var STATUS = {
|
|
|
110255
110630
|
};
|
|
110256
110631
|
response.once("close", disconnected), response.destroyed && controller.abort(), request3.resume();
|
|
110257
110632
|
try {
|
|
110258
|
-
let
|
|
110633
|
+
let displays = await this.listDisplays(controller.signal);
|
|
110634
|
+
response.destroyed || response.writeHead(200, { "content-type": "application/json" }).end(JSON.stringify({ displays }));
|
|
110635
|
+
} catch (error62) {
|
|
110636
|
+
fail(isDesktopScreenshotError(error62) ? error62 : "capture-failed");
|
|
110637
|
+
} finally {
|
|
110638
|
+
this.active = void 0, response.off("close", disconnected);
|
|
110639
|
+
}
|
|
110640
|
+
}
|
|
110641
|
+
async serve(request3, response) {
|
|
110642
|
+
response.setHeader("Cache-Control", "private, no-store"), response.setHeader("X-Content-Type-Options", "nosniff");
|
|
110643
|
+
let fail = (error62) => {
|
|
110644
|
+
response.destroyed || response.writeHead(STATUS[error62], { "content-type": "application/json" }).end(JSON.stringify({ error: error62 }));
|
|
110645
|
+
};
|
|
110646
|
+
if (this.closed || this.active !== void 0) {
|
|
110647
|
+
request3.resume(), fail(this.closed ? "unavailable" : "busy");
|
|
110648
|
+
return;
|
|
110649
|
+
}
|
|
110650
|
+
let controller = new AbortController();
|
|
110651
|
+
this.active = controller;
|
|
110652
|
+
let disconnected = () => {
|
|
110653
|
+
response.writableEnded || controller.abort();
|
|
110654
|
+
};
|
|
110655
|
+
response.once("close", disconnected), response.destroyed && controller.abort();
|
|
110656
|
+
try {
|
|
110657
|
+
let parsed = await readCaptureDisplayId(request3);
|
|
110658
|
+
if (!parsed.ok) {
|
|
110659
|
+
fail("invalid-display");
|
|
110660
|
+
return;
|
|
110661
|
+
}
|
|
110662
|
+
let image = await this.capture(controller.signal, parsed.displayId);
|
|
110259
110663
|
response.destroyed || response.writeHead(200, {
|
|
110260
110664
|
"content-type": "image/png",
|
|
110261
110665
|
"content-length": image.length,
|
|
@@ -110267,13 +110671,13 @@ var STATUS = {
|
|
|
110267
110671
|
this.active = void 0, response.off("close", disconnected);
|
|
110268
110672
|
}
|
|
110269
110673
|
}
|
|
110270
|
-
|
|
110674
|
+
runNative(args, maxBytes, signal, oversizeError) {
|
|
110271
110675
|
return new Promise((resolve26, reject) => {
|
|
110272
110676
|
if (signal.aborted) {
|
|
110273
110677
|
reject("capture-failed");
|
|
110274
110678
|
return;
|
|
110275
110679
|
}
|
|
110276
|
-
let [executable, ...prefix] = this.command, child = spawn5(executable, [...prefix, "desktop-screenshot"], {
|
|
110680
|
+
let [executable, ...prefix] = this.command, child = spawn5(executable, [...prefix, "desktop-screenshot", ...args], {
|
|
110277
110681
|
stdio: ["ignore", "pipe", "pipe"],
|
|
110278
110682
|
windowsHide: !0
|
|
110279
110683
|
}), chunks = [], bytes = 0, stderr = "", failure3, stop = (error62) => {
|
|
@@ -110282,7 +110686,7 @@ var STATUS = {
|
|
|
110282
110686
|
signal.addEventListener("abort", abort, { once: !0 });
|
|
110283
110687
|
let timeout = setTimeout(() => stop("timeout"), this.timeoutMs);
|
|
110284
110688
|
child.stdout.on("data", (chunk) => {
|
|
110285
|
-
failure3 === void 0 && (bytes += chunk.length, bytes >
|
|
110689
|
+
failure3 === void 0 && (bytes += chunk.length, bytes > maxBytes ? stop(oversizeError) : chunks.push(chunk));
|
|
110286
110690
|
}), child.stderr.on("data", (chunk) => {
|
|
110287
110691
|
stderr.length < 2048 && (stderr += chunk.toString("utf8").slice(0, 2048 - stderr.length));
|
|
110288
110692
|
}), child.once("error", () => {
|
|
@@ -110297,16 +110701,42 @@ var STATUS = {
|
|
|
110297
110701
|
reject(isDesktopScreenshotError(native2) ? native2 : "capture-failed");
|
|
110298
110702
|
return;
|
|
110299
110703
|
}
|
|
110300
|
-
|
|
110301
|
-
let image = Buffer.concat(chunks, bytes);
|
|
110302
|
-
if (inspectImage(image).ref.mediaType !== "image/png") throw new Error("Unexpected image type");
|
|
110303
|
-
resolve26(image);
|
|
110304
|
-
} catch {
|
|
110305
|
-
reject("capture-failed");
|
|
110306
|
-
}
|
|
110704
|
+
resolve26(Buffer.concat(chunks, bytes));
|
|
110307
110705
|
});
|
|
110308
110706
|
});
|
|
110309
110707
|
}
|
|
110708
|
+
async listDisplays(signal) {
|
|
110709
|
+
let raw = await this.runNative(
|
|
110710
|
+
["--list-displays"],
|
|
110711
|
+
MAX_DISPLAY_LIST_BYTES,
|
|
110712
|
+
signal,
|
|
110713
|
+
"capture-failed"
|
|
110714
|
+
), parsed;
|
|
110715
|
+
try {
|
|
110716
|
+
parsed = JSON.parse(raw.toString("utf8"));
|
|
110717
|
+
} catch {
|
|
110718
|
+
throw "capture-failed";
|
|
110719
|
+
}
|
|
110720
|
+
if (!Array.isArray(parsed) || !parsed.every(isDesktopScreenshotDisplay))
|
|
110721
|
+
throw "capture-failed";
|
|
110722
|
+
if (parsed.length === 0)
|
|
110723
|
+
throw "display-unavailable";
|
|
110724
|
+
return parsed;
|
|
110725
|
+
}
|
|
110726
|
+
async capture(signal, displayId) {
|
|
110727
|
+
let args = displayId === void 0 ? [] : ["--display", String(displayId)], image = await this.runNative(
|
|
110728
|
+
args,
|
|
110729
|
+
WEB_IMAGE_LIMITS.maxImageBytes,
|
|
110730
|
+
signal,
|
|
110731
|
+
"image-too-large"
|
|
110732
|
+
);
|
|
110733
|
+
try {
|
|
110734
|
+
if (inspectImage(image).ref.mediaType !== "image/png") throw new Error("Unexpected image type");
|
|
110735
|
+
return image;
|
|
110736
|
+
} catch {
|
|
110737
|
+
throw "capture-failed";
|
|
110738
|
+
}
|
|
110739
|
+
}
|
|
110310
110740
|
};
|
|
110311
110741
|
|
|
110312
110742
|
// packages/shared-contracts/dist/sidebar-browser.js
|
|
@@ -114530,14 +114960,14 @@ function appendRfc3550Padding(payload, paddingSize) {
|
|
|
114530
114960
|
}
|
|
114531
114961
|
function createRtxPaddingPacket({
|
|
114532
114962
|
paddingSize,
|
|
114533
|
-
timestamp:
|
|
114963
|
+
timestamp: timestamp3,
|
|
114534
114964
|
payloadType,
|
|
114535
114965
|
ssrc
|
|
114536
114966
|
}) {
|
|
114537
114967
|
return new RtpPacket(
|
|
114538
114968
|
new RtpHeader({
|
|
114539
114969
|
sequenceNumber: 0,
|
|
114540
|
-
timestamp:
|
|
114970
|
+
timestamp: timestamp3,
|
|
114541
114971
|
payloadType,
|
|
114542
114972
|
ssrc,
|
|
114543
114973
|
extension: !0,
|
|
@@ -123834,10 +124264,10 @@ var RTCRtpTransceiver = class {
|
|
|
123834
124264
|
)?.payloadType;
|
|
123835
124265
|
}
|
|
123836
124266
|
getCodecStats() {
|
|
123837
|
-
let
|
|
123838
|
-
return this.collectCodecStats(
|
|
124267
|
+
let timestamp3 = getStatsTimestamp();
|
|
124268
|
+
return this.collectCodecStats(timestamp3);
|
|
123839
124269
|
}
|
|
123840
|
-
collectCodecStats(
|
|
124270
|
+
collectCodecStats(timestamp3) {
|
|
123841
124271
|
let stats = [];
|
|
123842
124272
|
if (!this.dtlsTransport)
|
|
123843
124273
|
return stats;
|
|
@@ -123846,7 +124276,7 @@ var RTCRtpTransceiver = class {
|
|
|
123846
124276
|
let codecStats = {
|
|
123847
124277
|
type: "codec",
|
|
123848
124278
|
id: generateCodecStatsId(transportId, codec2.payloadType, this.id),
|
|
123849
|
-
timestamp:
|
|
124279
|
+
timestamp: timestamp3,
|
|
123850
124280
|
payloadType: codec2.payloadType,
|
|
123851
124281
|
transportId,
|
|
123852
124282
|
mimeType: codec2.mimeType,
|
|
@@ -124699,11 +125129,11 @@ var RTCDtlsTransport = class _RTCDtlsTransport {
|
|
|
124699
125129
|
(error62) => log32("onStopped listener failed", error62)
|
|
124700
125130
|
), this.notifySafely("onStopped", () => this.onStopped.complete());
|
|
124701
125131
|
}
|
|
124702
|
-
async getStats(
|
|
125132
|
+
async getStats(timestamp3 = getStatsTimestamp()) {
|
|
124703
125133
|
let stats = [], transportId = generateStatsId("transport", this.id), transportStats = {
|
|
124704
125134
|
type: "transport",
|
|
124705
125135
|
id: transportId,
|
|
124706
|
-
timestamp:
|
|
125136
|
+
timestamp: timestamp3,
|
|
124707
125137
|
bytesSent: this.bytesSent,
|
|
124708
125138
|
bytesReceived: this.bytesReceived,
|
|
124709
125139
|
packetsSent: this.packetsSent,
|
|
@@ -124730,7 +125160,7 @@ var RTCDtlsTransport = class _RTCDtlsTransport {
|
|
|
124730
125160
|
let certStats = {
|
|
124731
125161
|
type: "certificate",
|
|
124732
125162
|
id: generateStatsId("certificate", this.id, "local"),
|
|
124733
|
-
timestamp:
|
|
125163
|
+
timestamp: timestamp3,
|
|
124734
125164
|
fingerprint: fingerprints[0].value,
|
|
124735
125165
|
fingerprintAlgorithm: fingerprints[0].algorithm,
|
|
124736
125166
|
base64Certificate: Buffer.from(
|
|
@@ -124744,7 +125174,7 @@ var RTCDtlsTransport = class _RTCDtlsTransport {
|
|
|
124744
125174
|
let certStats = {
|
|
124745
125175
|
type: "certificate",
|
|
124746
125176
|
id: generateStatsId("certificate", this.id, "remote"),
|
|
124747
|
-
timestamp:
|
|
125177
|
+
timestamp: timestamp3,
|
|
124748
125178
|
fingerprint: this.remoteParameters.fingerprints[0].value,
|
|
124749
125179
|
fingerprintAlgorithm: this.remoteParameters.fingerprints[0].algorithm,
|
|
124750
125180
|
base64Certificate: Buffer.from(this.dtls.remoteCertificate).toString(
|
|
@@ -124753,7 +125183,7 @@ var RTCDtlsTransport = class _RTCDtlsTransport {
|
|
|
124753
125183
|
};
|
|
124754
125184
|
stats.push(certStats);
|
|
124755
125185
|
}
|
|
124756
|
-
let iceStats = await this.iceTransport.getStats(
|
|
125186
|
+
let iceStats = await this.iceTransport.getStats(timestamp3, transportId);
|
|
124757
125187
|
return stats.push(...iceStats), stats;
|
|
124758
125188
|
}
|
|
124759
125189
|
};
|
|
@@ -125334,13 +125764,13 @@ var RTCIceTransport = class {
|
|
|
125334
125764
|
let waitStart = this.waitStart;
|
|
125335
125765
|
this.waitStart = void 0, waitStart && !waitStart.ended && (waitStart.execute(), waitStart.complete()), this.state !== "closed" && (this.setState("closed", !1), await this.connection.close()), this.onStateChange.complete(), this.onIceCandidate.complete(), this.onIceCandidateError.complete(), this.onIceServerReached.complete(), this.onNegotiationNeeded.complete();
|
|
125336
125766
|
}
|
|
125337
|
-
async getStats(
|
|
125767
|
+
async getStats(timestamp3 = getStatsTimestamp(), transportId = generateStatsId("transport", this.id)) {
|
|
125338
125768
|
let stats = [];
|
|
125339
125769
|
for (let candidate of this.connection.localCandidates) {
|
|
125340
125770
|
let candidateStats = {
|
|
125341
125771
|
type: "local-candidate",
|
|
125342
125772
|
id: generateStatsId("local-candidate", candidate.id),
|
|
125343
|
-
timestamp:
|
|
125773
|
+
timestamp: timestamp3,
|
|
125344
125774
|
transportId,
|
|
125345
125775
|
address: candidate.host,
|
|
125346
125776
|
port: candidate.port,
|
|
@@ -125359,7 +125789,7 @@ var RTCIceTransport = class {
|
|
|
125359
125789
|
let candidateStats = {
|
|
125360
125790
|
type: "remote-candidate",
|
|
125361
125791
|
id: generateStatsId("remote-candidate", candidate.id),
|
|
125362
|
-
timestamp:
|
|
125792
|
+
timestamp: timestamp3,
|
|
125363
125793
|
transportId,
|
|
125364
125794
|
address: candidate.host,
|
|
125365
125795
|
port: candidate.port,
|
|
@@ -125382,7 +125812,7 @@ var RTCIceTransport = class {
|
|
|
125382
125812
|
let pairStats = {
|
|
125383
125813
|
type: "candidate-pair",
|
|
125384
125814
|
id: generateStatsId("candidate-pair", pair.id),
|
|
125385
|
-
timestamp:
|
|
125815
|
+
timestamp: timestamp3,
|
|
125386
125816
|
transportId,
|
|
125387
125817
|
localCandidateId: generateStatsId(
|
|
125388
125818
|
"local-candidate",
|
|
@@ -131361,11 +131791,11 @@ var TransceiverManager = class {
|
|
|
131361
131791
|
!t.stopping || t.stopped || (t.mid == null || !negotiatedMids.has(t.mid)) && t.commitStopped({ rejected: !1 });
|
|
131362
131792
|
return this.transceivers.some((t) => t.stopping && !t.stopped);
|
|
131363
131793
|
}
|
|
131364
|
-
collectStats(
|
|
131794
|
+
collectStats(timestamp3) {
|
|
131365
131795
|
let stats = [];
|
|
131366
131796
|
for (let transceiver of this.transceivers) {
|
|
131367
|
-
transceiver.sender && stats.push(...transceiver.sender.collectStats(
|
|
131368
|
-
let codecStats = transceiver.collectCodecStats(
|
|
131797
|
+
transceiver.sender && stats.push(...transceiver.sender.collectStats(timestamp3)), transceiver.receiver && stats.push(...transceiver.receiver.collectStats(timestamp3));
|
|
131798
|
+
let codecStats = transceiver.collectCodecStats(timestamp3);
|
|
131369
131799
|
codecStats && stats.push(...codecStats);
|
|
131370
131800
|
}
|
|
131371
131801
|
return stats;
|
|
@@ -131459,8 +131889,8 @@ var PendingSsrcRoutes = class _PendingSsrcRoutes {
|
|
|
131459
131889
|
* the timestamps of the packets received around the gap, in either order
|
|
131460
131890
|
* (frames sent out of display order) and widened by `slack`.
|
|
131461
131891
|
*/
|
|
131462
|
-
canRepair(ssrc, sequenceNumber,
|
|
131463
|
-
return this.streams.get(ssrc)?.canRepair(sequenceNumber,
|
|
131892
|
+
canRepair(ssrc, sequenceNumber, timestamp3, slack) {
|
|
131893
|
+
return this.streams.get(ssrc)?.canRepair(sequenceNumber, timestamp3, slack) ?? !1;
|
|
131464
131894
|
}
|
|
131465
131895
|
/** Reset `ssrc`: its NACK requests and holes end together. */
|
|
131466
131896
|
forget(ssrc) {
|
|
@@ -131506,9 +131936,9 @@ var PendingSsrcRoutes = class _PendingSsrcRoutes {
|
|
|
131506
131936
|
get holeCount() {
|
|
131507
131937
|
return this.holes.size;
|
|
131508
131938
|
}
|
|
131509
|
-
addPacket(sequenceNumber,
|
|
131939
|
+
addPacket(sequenceNumber, timestamp3) {
|
|
131510
131940
|
if (this.newestExt === void 0) {
|
|
131511
|
-
this.newestExt = sequenceNumber, this.newestTimestamp =
|
|
131941
|
+
this.newestExt = sequenceNumber, this.newestTimestamp = timestamp3;
|
|
131512
131942
|
return;
|
|
131513
131943
|
}
|
|
131514
131944
|
let ext = this.extend(sequenceNumber);
|
|
@@ -131521,17 +131951,17 @@ var PendingSsrcRoutes = class _PendingSsrcRoutes {
|
|
|
131521
131951
|
this.holes.set(missing, {
|
|
131522
131952
|
sequenceNumber: missing & 65535,
|
|
131523
131953
|
timestampBefore: this.newestTimestamp,
|
|
131524
|
-
timestampAfter:
|
|
131954
|
+
timestampAfter: timestamp3,
|
|
131525
131955
|
requests: 0
|
|
131526
131956
|
});
|
|
131527
|
-
this.newestExt = ext, this.newestTimestamp =
|
|
131957
|
+
this.newestExt = ext, this.newestTimestamp = timestamp3, this.pruneHoles(), from < ext && this.startLoop();
|
|
131528
131958
|
}
|
|
131529
131959
|
/** Whether an RTX packet with this original number and timestamp fills a hole. */
|
|
131530
|
-
canRepair(sequenceNumber,
|
|
131960
|
+
canRepair(sequenceNumber, timestamp3, slack) {
|
|
131531
131961
|
if (this.newestExt === void 0) return !1;
|
|
131532
131962
|
let hole = this.holes.get(this.extend(sequenceNumber));
|
|
131533
131963
|
if (!hole) return !1;
|
|
131534
|
-
let before = hole.timestampBefore - hole.timestampAfter | 0, offset =
|
|
131964
|
+
let before = hole.timestampBefore - hole.timestampAfter | 0, offset = timestamp3 - hole.timestampAfter | 0;
|
|
131535
131965
|
return offset >= Math.min(before, 0) - slack && offset <= Math.max(before, 0) + slack;
|
|
131536
131966
|
}
|
|
131537
131967
|
/**
|
|
@@ -132313,7 +132743,7 @@ var StreamStatistics = class {
|
|
|
132313
132743
|
getStatsRootIds(selector) {
|
|
132314
132744
|
return this.reportedTracks.filter((track) => selector ? track === selector : !0).filter((track) => track.ssrc !== void 0).map((track) => this.getInboundRtpStatsId(track));
|
|
132315
132745
|
}
|
|
132316
|
-
collectStats(
|
|
132746
|
+
collectStats(timestamp3) {
|
|
132317
132747
|
let stats = [], transportId = this.dtlsTransport ? generateStatsId("transport", this.dtlsTransport.id) : void 0, activeCodec = this.codecArray[0], emittedCodecIds = /* @__PURE__ */ new Set();
|
|
132318
132748
|
for (let track of this.reportedTracks) {
|
|
132319
132749
|
if (track.ssrc === void 0) continue;
|
|
@@ -132327,7 +132757,7 @@ var StreamStatistics = class {
|
|
|
132327
132757
|
let codecStats = {
|
|
132328
132758
|
type: "codec",
|
|
132329
132759
|
id: codecId,
|
|
132330
|
-
timestamp:
|
|
132760
|
+
timestamp: timestamp3,
|
|
132331
132761
|
payloadType: activeCodec.payloadType,
|
|
132332
132762
|
transportId,
|
|
132333
132763
|
mimeType: activeCodec.mimeType,
|
|
@@ -132340,7 +132770,7 @@ var StreamStatistics = class {
|
|
|
132340
132770
|
let inboundRtpStats = {
|
|
132341
132771
|
type: "inbound-rtp",
|
|
132342
132772
|
id: this.getInboundRtpStatsId(track),
|
|
132343
|
-
timestamp:
|
|
132773
|
+
timestamp: timestamp3,
|
|
132344
132774
|
ssrc: track.ssrc,
|
|
132345
132775
|
kind: this.kind,
|
|
132346
132776
|
transportId,
|
|
@@ -132361,7 +132791,7 @@ var StreamStatistics = class {
|
|
|
132361
132791
|
let remoteOutboundStats = {
|
|
132362
132792
|
type: "remote-outbound-rtp",
|
|
132363
132793
|
id: this.getRemoteOutboundRtpStatsId(track),
|
|
132364
|
-
timestamp:
|
|
132794
|
+
timestamp: timestamp3,
|
|
132365
132795
|
ssrc: track.ssrc,
|
|
132366
132796
|
kind: this.kind,
|
|
132367
132797
|
transportId,
|
|
@@ -132378,8 +132808,8 @@ var StreamStatistics = class {
|
|
|
132378
132808
|
return stats;
|
|
132379
132809
|
}
|
|
132380
132810
|
async getStats() {
|
|
132381
|
-
let
|
|
132382
|
-
return this.dtlsTransport && stats.push(...await this.dtlsTransport.getStats(
|
|
132811
|
+
let timestamp3 = getStatsTimestamp(), stats = this.collectStats(timestamp3);
|
|
132812
|
+
return this.dtlsTransport && stats.push(...await this.dtlsTransport.getStats(timestamp3)), buildStatsReport(stats, this.getStatsRootIds());
|
|
132383
132813
|
}
|
|
132384
132814
|
/**
|
|
132385
132815
|
* Internal: whether PLI is negotiated for `mediaSsrc`, and the payload type
|
|
@@ -133980,11 +134410,11 @@ var SENDER_REPORT_HISTORY_MAX_ENTRIES = 32, SENDER_REPORT_HISTORY_MAX_AGE_SEC =
|
|
|
133980
134410
|
* outbound-rtp, media-source (with a track), codec (with a codec and a
|
|
133981
134411
|
* transport), and remote-inbound-rtp (once a report arrived) entries.
|
|
133982
134412
|
*/
|
|
133983
|
-
collect(context,
|
|
134413
|
+
collect(context, timestamp3) {
|
|
133984
134414
|
let stats = [], transportId = context.dtlsTransport ? generateStatsId("transport", context.dtlsTransport.id) : void 0, codec2 = context.codec, codecId = codec2 && transportId ? generateCodecStatsId(transportId, codec2.payloadType, context.trackId) : void 0, hasRemote = this.remotePacketsLost !== void 0 || this.remoteFractionLost !== void 0, mediaSourceId = senderStatsIds(context.trackId).mediaSource, remoteInboundId = senderStatsIds(context.trackId).remoteInboundRtp, outboundRtpStats = {
|
|
133985
134415
|
type: "outbound-rtp",
|
|
133986
134416
|
id: senderStatsIds(context.trackId).outboundRtp,
|
|
133987
|
-
timestamp:
|
|
134417
|
+
timestamp: timestamp3,
|
|
133988
134418
|
ssrc: context.ssrc,
|
|
133989
134419
|
kind: context.kind,
|
|
133990
134420
|
transportId,
|
|
@@ -134006,7 +134436,7 @@ var SENDER_REPORT_HISTORY_MAX_ENTRIES = 32, SENDER_REPORT_HISTORY_MAX_AGE_SEC =
|
|
|
134006
134436
|
let mediaSourceStats = {
|
|
134007
134437
|
type: "media-source",
|
|
134008
134438
|
id: mediaSourceId,
|
|
134009
|
-
timestamp:
|
|
134439
|
+
timestamp: timestamp3,
|
|
134010
134440
|
trackIdentifier: context.trackIdentifier,
|
|
134011
134441
|
kind: context.kind
|
|
134012
134442
|
};
|
|
@@ -134016,7 +134446,7 @@ var SENDER_REPORT_HISTORY_MAX_ENTRIES = 32, SENDER_REPORT_HISTORY_MAX_AGE_SEC =
|
|
|
134016
134446
|
let codecStats = {
|
|
134017
134447
|
type: "codec",
|
|
134018
134448
|
id: codecId,
|
|
134019
|
-
timestamp:
|
|
134449
|
+
timestamp: timestamp3,
|
|
134020
134450
|
payloadType: codec2.payloadType,
|
|
134021
134451
|
transportId,
|
|
134022
134452
|
mimeType: codec2.mimeType,
|
|
@@ -134030,7 +134460,7 @@ var SENDER_REPORT_HISTORY_MAX_ENTRIES = 32, SENDER_REPORT_HISTORY_MAX_AGE_SEC =
|
|
|
134030
134460
|
let remoteInboundStats = {
|
|
134031
134461
|
type: "remote-inbound-rtp",
|
|
134032
134462
|
id: remoteInboundId,
|
|
134033
|
-
timestamp:
|
|
134463
|
+
timestamp: timestamp3,
|
|
134034
134464
|
ssrc: context.ssrc,
|
|
134035
134465
|
kind: context.kind,
|
|
134036
134466
|
transportId,
|
|
@@ -134863,7 +135293,7 @@ var log41 = debug("werift:packages/webrtc/src/media/rtpSender.ts"), RTP_HISTORY_
|
|
|
134863
135293
|
getStatsRootIds() {
|
|
134864
135294
|
return [senderStatsIds(this.trackId).outboundRtp];
|
|
134865
135295
|
}
|
|
134866
|
-
collectStats(
|
|
135296
|
+
collectStats(timestamp3) {
|
|
134867
135297
|
return this.stats.collect(
|
|
134868
135298
|
{
|
|
134869
135299
|
trackId: this.trackId,
|
|
@@ -134875,12 +135305,12 @@ var log41 = debug("werift:packages/webrtc/src/media/rtpSender.ts"), RTP_HISTORY_
|
|
|
134875
135305
|
rtxSsrc: this.rtxPayloadType ? this.rtxSsrc : void 0,
|
|
134876
135306
|
trackIdentifier: this.track ? this.track.id ?? this.trackId : void 0
|
|
134877
135307
|
},
|
|
134878
|
-
|
|
135308
|
+
timestamp3
|
|
134879
135309
|
);
|
|
134880
135310
|
}
|
|
134881
135311
|
async getStats() {
|
|
134882
|
-
let
|
|
134883
|
-
return this.dtlsTransport && stats.push(...await this.dtlsTransport.getStats(
|
|
135312
|
+
let timestamp3 = getStatsTimestamp(), stats = this.collectStats(timestamp3);
|
|
135313
|
+
return this.dtlsTransport && stats.push(...await this.dtlsTransport.getStats(timestamp3)), buildStatsReport(stats, this.getStatsRootIds());
|
|
134884
135314
|
}
|
|
134885
135315
|
};
|
|
134886
135316
|
function sendCodecOf(codecs) {
|
|
@@ -136590,13 +137020,13 @@ var RETIRED_UFRAG_HISTORY = 64, NegotiationTransaction = class {
|
|
|
136590
137020
|
async close() {
|
|
136591
137021
|
this.sctpTransport && (await this.sctpTransport.stop(), await new Promise((resolve26) => setImmediate(resolve26))), this.onDataChannel.allUnsubscribe();
|
|
136592
137022
|
}
|
|
136593
|
-
async getStats(
|
|
137023
|
+
async getStats(timestamp3 = getStatsTimestamp()) {
|
|
136594
137024
|
let stats = [];
|
|
136595
137025
|
for (let channel of this.dataChannels) {
|
|
136596
137026
|
let channelStats = {
|
|
136597
137027
|
type: "data-channel",
|
|
136598
137028
|
id: generateStatsId("data-channel", channel.id ?? channel.statsId),
|
|
136599
|
-
timestamp:
|
|
137029
|
+
timestamp: timestamp3,
|
|
136600
137030
|
label: channel.label,
|
|
136601
137031
|
protocol: channel.protocol,
|
|
136602
137032
|
dataChannelIdentifier: channel.id ?? void 0,
|
|
@@ -137081,10 +137511,10 @@ var log44 = debug(
|
|
|
137081
137511
|
state2
|
|
137082
137512
|
));
|
|
137083
137513
|
}
|
|
137084
|
-
async getStats(
|
|
137514
|
+
async getStats(timestamp3) {
|
|
137085
137515
|
let stats = [];
|
|
137086
137516
|
for (let dtlsTransport of this.dtlsTransports) {
|
|
137087
|
-
let transportStats = await dtlsTransport.getStats(
|
|
137517
|
+
let transportStats = await dtlsTransport.getStats(timestamp3);
|
|
137088
137518
|
transportStats && stats.push(...transportStats);
|
|
137089
137519
|
}
|
|
137090
137520
|
return stats;
|
|
@@ -138304,21 +138734,21 @@ var srtpProfiles = [
|
|
|
138304
138734
|
setSignalingState(state2) {
|
|
138305
138735
|
this.signalingState === state2 || this.signalingState === "closed" || (log45("signalingStateChange", state2), this.signalingState = state2, this.signalingStateChange.execute(state2), this.onsignalingstatechange && this.onsignalingstatechange(new globalThis.Event("signalingstatechange")), this.emit("signalingstatechange"));
|
|
138306
138736
|
}
|
|
138307
|
-
createPeerConnectionStats(
|
|
138737
|
+
createPeerConnectionStats(timestamp3) {
|
|
138308
138738
|
return {
|
|
138309
138739
|
type: "peer-connection",
|
|
138310
138740
|
id: generateStatsId("peer-connection", this.id),
|
|
138311
|
-
timestamp:
|
|
138741
|
+
timestamp: timestamp3,
|
|
138312
138742
|
dataChannelsOpened: this.sctpManager.dataChannelsOpened,
|
|
138313
138743
|
dataChannelsClosed: this.sctpManager.dataChannelsClosed
|
|
138314
138744
|
};
|
|
138315
138745
|
}
|
|
138316
138746
|
async getStats(selector) {
|
|
138317
|
-
let
|
|
138318
|
-
selector || stats.push(this.createPeerConnectionStats(
|
|
138319
|
-
let transportStats = await this.secureManager.getStats(
|
|
138747
|
+
let timestamp3 = getStatsTimestamp(), stats = [];
|
|
138748
|
+
selector || stats.push(this.createPeerConnectionStats(timestamp3)), stats.push(...this.transceiverManager.collectStats(timestamp3));
|
|
138749
|
+
let transportStats = await this.secureManager.getStats(timestamp3);
|
|
138320
138750
|
if (stats.push(...transportStats), !selector && this.sctpTransport) {
|
|
138321
|
-
let dataChannelStats = await this.sctpManager.getStats(
|
|
138751
|
+
let dataChannelStats = await this.sctpManager.getStats(timestamp3);
|
|
138322
138752
|
dataChannelStats && stats.push(...dataChannelStats);
|
|
138323
138753
|
}
|
|
138324
138754
|
return selector ? buildStatsReport(
|
|
@@ -140425,13 +140855,13 @@ var Workspaces = class {
|
|
|
140425
140855
|
remoteGroups = [];
|
|
140426
140856
|
officialPinnedWorkspaceIds = [];
|
|
140427
140857
|
publishedPinnedWorkspaces = [];
|
|
140428
|
-
setRemoteGroups(
|
|
140858
|
+
setRemoteGroups(groups2) {
|
|
140429
140859
|
let previousOrder = this.list().map((group) => group.workspaceId), previous = new Map(this.remoteGroups.map((group) => [group.workspaceId, group]));
|
|
140430
|
-
this.remoteGroups =
|
|
140431
|
-
let current = new Set(
|
|
140860
|
+
this.remoteGroups = groups2;
|
|
140861
|
+
let current = new Set(groups2.map((group) => group.workspaceId));
|
|
140432
140862
|
for (let id2 of previous.keys())
|
|
140433
140863
|
current.has(id2) || this.broadcast({ type: "remove", workspaceId: id2 });
|
|
140434
|
-
for (let workspace of
|
|
140864
|
+
for (let workspace of groups2)
|
|
140435
140865
|
JSON.stringify(previous.get(workspace.workspaceId)) !== JSON.stringify(workspace) && this.broadcast({ type: "upsert", workspace });
|
|
140436
140866
|
let nextOrder = this.list().map((group) => group.workspaceId);
|
|
140437
140867
|
JSON.stringify(previousOrder) !== JSON.stringify(nextOrder) && this.broadcast({
|
|
@@ -140550,9 +140980,9 @@ var Workspaces = class {
|
|
|
140550
140980
|
get usesNativeProjects() {
|
|
140551
140981
|
return this.nativeWorkspaces !== void 0;
|
|
140552
140982
|
}
|
|
140553
|
-
syncNativeProjects(projects,
|
|
140983
|
+
syncNativeProjects(projects, groups2, legacyAssignments, roots) {
|
|
140554
140984
|
let before = this.list(), previous = new Map(this.nativeWorkspaces?.map((item) => [item.projectId, item])), members2 = /* @__PURE__ */ new Map();
|
|
140555
|
-
for (let [sessionId, projectId] of
|
|
140985
|
+
for (let [sessionId, projectId] of groups2) {
|
|
140556
140986
|
if (projectId === void 0) continue;
|
|
140557
140987
|
let entries = members2.get(projectId) ?? [];
|
|
140558
140988
|
members2.has(projectId) || members2.set(projectId, entries), entries.push(sessionId);
|
|
@@ -140600,9 +141030,9 @@ var Workspaces = class {
|
|
|
140600
141030
|
next2.length !== workspace.sessionIds.length && (workspace.sessionIds = next2, this.broadcast({ type: "upsert", workspace }));
|
|
140601
141031
|
return;
|
|
140602
141032
|
}
|
|
140603
|
-
let before = this.list(),
|
|
141033
|
+
let before = this.list(), groups2 = new Map(this.referenceGroups), projectless = new Set(this.referenceProjectless);
|
|
140604
141034
|
for (let id2 of sessionIds)
|
|
140605
|
-
|
|
141035
|
+
groups2.set(id2, workspace.path), projectless.delete(id2);
|
|
140606
141036
|
if ([.../* @__PURE__ */ new Set([...workspace.sessionIds, ...sessionIds])].length !== workspace.sessionIds.length) {
|
|
140607
141037
|
let state2 = {
|
|
140608
141038
|
...this.state,
|
|
@@ -140612,7 +141042,7 @@ var Workspaces = class {
|
|
|
140612
141042
|
};
|
|
140613
141043
|
this.data.writeJson(FILE2, state2), this.state = state2;
|
|
140614
141044
|
}
|
|
140615
|
-
this.referenceGroups =
|
|
141045
|
+
this.referenceGroups = groups2, this.referenceProjectless = projectless, this.publishWorkspaceChanges(before);
|
|
140616
141046
|
}
|
|
140617
141047
|
/** Show a session only in its native project, at the requested place; Codex owns membership. */
|
|
140618
141048
|
placeNativeSession(workspaceId, sessionId, beforeSessionId) {
|
|
@@ -140642,9 +141072,9 @@ var Workspaces = class {
|
|
|
140642
141072
|
projectless
|
|
140643
141073
|
);
|
|
140644
141074
|
}
|
|
140645
|
-
setReferenceGroups(
|
|
141075
|
+
setReferenceGroups(groups2, projectless = /* @__PURE__ */ new Set()) {
|
|
140646
141076
|
let before = this.list();
|
|
140647
|
-
this.referenceGroups =
|
|
141077
|
+
this.referenceGroups = groups2, this.referenceProjectless = projectless;
|
|
140648
141078
|
let after = this.list(), ids = new Set(after.map((workspace) => workspace.workspaceId));
|
|
140649
141079
|
for (let workspace of before)
|
|
140650
141080
|
ids.has(workspace.workspaceId) || this.broadcast({ type: "remove", workspaceId: workspace.workspaceId });
|
|
@@ -140958,11 +141388,12 @@ var Workspaces = class {
|
|
|
140958
141388
|
}
|
|
140959
141389
|
byExactPath(path7) {
|
|
140960
141390
|
if (this.nativeWorkspaces) {
|
|
140961
|
-
|
|
141391
|
+
if (!isAbsolute20(path7)) return;
|
|
141392
|
+
let absolute2 = resolve16(path7), multiRootMatch;
|
|
140962
141393
|
for (let item of this.nativeWorkspaces) {
|
|
140963
141394
|
if (!item.projectId) continue;
|
|
140964
141395
|
let roots = this.nativeRoots.get(item.projectId);
|
|
140965
|
-
if (roots?.
|
|
141396
|
+
if (roots?.some((root) => isAbsolute20(root) && resolve16(root) === absolute2)) {
|
|
140966
141397
|
if (roots.length === 1) return item;
|
|
140967
141398
|
multiRootMatch ??= item;
|
|
140968
141399
|
}
|
|
@@ -141075,7 +141506,7 @@ var Workspaces = class {
|
|
|
141075
141506
|
return title && workspace.origin !== "web" && workspace.title !== title && (workspace.title = title, this.touch(workspace)), workspace.sessionIds.includes(sessionId) || (workspace.sessionIds.push(sessionId), this.touch(workspace)), workspace;
|
|
141076
141507
|
}
|
|
141077
141508
|
/** Mirror one complete CH workspace snapshot, saving and publishing only final changes. */
|
|
141078
|
-
syncReferencedSessions(sessions2,
|
|
141509
|
+
syncReferencedSessions(sessions2, groups2, projectless = /* @__PURE__ */ new Set(), projects = []) {
|
|
141079
141510
|
let before = new Map(
|
|
141080
141511
|
this.list().map((workspace) => [workspace.workspaceId, JSON.stringify(workspace)])
|
|
141081
141512
|
), items = this.state.items.map((workspace) => ({
|
|
@@ -141136,7 +141567,7 @@ var Workspaces = class {
|
|
|
141136
141567
|
};
|
|
141137
141568
|
this.data.writeJson(FILE2, state2), this.state = state2;
|
|
141138
141569
|
}
|
|
141139
|
-
this.referenceProjectRoots = rootPaths, this.referenceGroups =
|
|
141570
|
+
this.referenceProjectRoots = rootPaths, this.referenceGroups = groups2, this.referenceProjectless = projectless;
|
|
141140
141571
|
let after = this.list(), ids = new Set(after.map((workspace) => workspace.workspaceId));
|
|
141141
141572
|
for (let workspaceId of before.keys())
|
|
141142
141573
|
ids.has(workspaceId) || this.broadcast({ type: "remove", workspaceId });
|
|
@@ -141420,10 +141851,9 @@ var ChThreadEditing = class {
|
|
|
141420
141851
|
let dispatched = !1, reverted = !1;
|
|
141421
141852
|
try {
|
|
141422
141853
|
if (!displayed) throw new Error("Edit history expired. Reopen the conversation.");
|
|
141423
|
-
|
|
141854
|
+
if (!threadInspectionSchema.parse(
|
|
141424
141855
|
await host.request("codexhost/thread/inspect", { threadId })
|
|
141425
|
-
)
|
|
141426
|
-
if (owner.owner !== "external" || !owner.history.rollbackLastTurn)
|
|
141856
|
+
).history?.rollbackLastTurn)
|
|
141427
141857
|
throw new Error("This Harness does not support editing the last sent message.");
|
|
141428
141858
|
let view = await input3.read();
|
|
141429
141859
|
if (view !== displayed || view.thread.parentThreadId || view.thread.canAcceptDirectInput === !1)
|
|
@@ -142178,6 +142608,12 @@ function globalProjectionValues(values2) {
|
|
|
142178
142608
|
Object.entries(values2).filter(([key]) => !WEB_FOLLOW_PROJECTION_KEYS.has(key))
|
|
142179
142609
|
);
|
|
142180
142610
|
}
|
|
142611
|
+
function requestedRoleSlug(value) {
|
|
142612
|
+
if (value == null) return value;
|
|
142613
|
+
let parsed = roleSlugSchema.safeParse(value);
|
|
142614
|
+
if (!parsed.success) throw new SessionRuntimeError("session/role-invalid", "Choose a valid Agent Role.");
|
|
142615
|
+
return parsed.data;
|
|
142616
|
+
}
|
|
142181
142617
|
var ChSessions = class {
|
|
142182
142618
|
constructor(host, workspaces2, events2, images2, files2, displayEntries2, preferences2, harnesses, openFile, fileSearchCache) {
|
|
142183
142619
|
this.host = host;
|
|
@@ -142273,6 +142709,10 @@ var ChSessions = class {
|
|
|
142273
142709
|
rows = /* @__PURE__ */ new Map();
|
|
142274
142710
|
publishedCatalog;
|
|
142275
142711
|
handoffs = /* @__PURE__ */ new Map();
|
|
142712
|
+
/** Role identities confirmed by owner inspection, for reads whose Thread object omits them. */
|
|
142713
|
+
roleSnapshots = /* @__PURE__ */ new Map();
|
|
142714
|
+
/** Latest confirmed Thread configuration, so initial views project modelSelection without waiting for Harness discovery. */
|
|
142715
|
+
ownerConfigurations = /* @__PURE__ */ new Map();
|
|
142276
142716
|
/** Loaded rows accumulate across partial official pages; drafts are not Host Threads. */
|
|
142277
142717
|
threads = new WebThreadStates();
|
|
142278
142718
|
nativeGoals;
|
|
@@ -142627,13 +143067,13 @@ var ChSessions = class {
|
|
|
142627
143067
|
async syncWorkspace(timing = new SessionListTiming(), snapshot) {
|
|
142628
143068
|
let projects = snapshot ?? await timing.measure("projects", () => this.host.projects([...this.rows.keys()]));
|
|
142629
143069
|
timing.count("projects", projects.projects.length), !this.closed && timing.measureSync("workspace_sync", () => {
|
|
142630
|
-
let
|
|
143070
|
+
let groups2 = /* @__PURE__ */ new Map();
|
|
142631
143071
|
if (projects.nativeProjects) {
|
|
142632
143072
|
let roots = nativeProjectRootOwners(projects.projects), projectFor = this.nativeProjectResolver(projects, roots);
|
|
142633
|
-
for (let row of this.rows.values())
|
|
143073
|
+
for (let row of this.rows.values()) groups2.set(row.id, projectFor(row));
|
|
142634
143074
|
for (let draft of this.drafts.values())
|
|
142635
|
-
draft.canonicalId ||
|
|
142636
|
-
this.workspaces.syncNativeProjects(projects.projects,
|
|
143075
|
+
draft.canonicalId || groups2.set(draft.id, draft.projectId);
|
|
143076
|
+
this.workspaces.syncNativeProjects(projects.projects, groups2, projects.assignments, roots), this.workspaces.setReferencePinnedProjects(projects.projects, projects.pinnedProjects);
|
|
142637
143077
|
return;
|
|
142638
143078
|
}
|
|
142639
143079
|
if (this.workspaces.usesNativeProjects) return;
|
|
@@ -142641,7 +143081,7 @@ var ChSessions = class {
|
|
|
142641
143081
|
for (let row of this.rows.values()) {
|
|
142642
143082
|
row.workspaceKind === "projectless" && !row.projectId && !projects.assignments[row.id] && projectless.add(row.id);
|
|
142643
143083
|
let root = row.cwd && !projectless.has(row.id) ? projectGroupRoot(projects, row.id, row.cwd) : void 0;
|
|
142644
|
-
if (
|
|
143084
|
+
if (groups2.set(row.id, root), root) {
|
|
142645
143085
|
let title = projects.projects.find((project3) => project3.rootPaths.includes(root)) === void 0 ? void 0 : rootTitles.get(resolve19(root));
|
|
142646
143086
|
references.push({
|
|
142647
143087
|
sessionId: row.id,
|
|
@@ -142651,8 +143091,8 @@ var ChSessions = class {
|
|
|
142651
143091
|
}
|
|
142652
143092
|
}
|
|
142653
143093
|
for (let draft of this.drafts.values())
|
|
142654
|
-
draft.canonicalId || (
|
|
142655
|
-
timing.count("workspaceReferences", references.length), this.workspaces.syncReferencedSessions(references,
|
|
143094
|
+
draft.canonicalId || (groups2.set(draft.id, draft.cwd), draft.cwd || projectless.add(draft.id));
|
|
143095
|
+
timing.count("workspaceReferences", references.length), this.workspaces.syncReferencedSessions(references, groups2, projectless, projects.projects), this.workspaces.setReferencePinnedProjects(projects.projects, projects.pinnedProjects);
|
|
142656
143096
|
});
|
|
142657
143097
|
}
|
|
142658
143098
|
nativeProjectResolver(projects, roots = nativeProjectRootOwners(projects.projects)) {
|
|
@@ -142682,15 +143122,21 @@ var ChSessions = class {
|
|
|
142682
143122
|
this.archiveForkParent(row),
|
|
142683
143123
|
row.canAcceptDirectInput !== !1,
|
|
142684
143124
|
row.codexhostImportSource ?? null,
|
|
142685
|
-
this.threads.harnessId(row.id)
|
|
143125
|
+
this.threads.harnessId(row.id),
|
|
143126
|
+
this.roleSnapshotOf(row)
|
|
142686
143127
|
]);
|
|
142687
143128
|
}
|
|
143129
|
+
roleSnapshotOf(row) {
|
|
143130
|
+
let parsed = threadRoleSnapshotSchema.safeParse(row.roleSnapshot);
|
|
143131
|
+
return parsed.success ? parsed.data : this.roleSnapshots.get(row.id) ?? null;
|
|
143132
|
+
}
|
|
142688
143133
|
catalogProjections(row) {
|
|
142689
143134
|
return {
|
|
142690
143135
|
title: threadListTitle(row),
|
|
142691
143136
|
threadTreeParent: this.tree.parent(row.id),
|
|
142692
143137
|
archiveForkParent: this.archiveForkParent(row),
|
|
142693
|
-
codexhostImportSource: row.codexhostImportSource ?? null
|
|
143138
|
+
codexhostImportSource: row.codexhostImportSource ?? null,
|
|
143139
|
+
roleSnapshot: this.roleSnapshotOf(row)
|
|
142694
143140
|
};
|
|
142695
143141
|
}
|
|
142696
143142
|
async publishCatalogChanges(timing, headIds, sectionIds, archivedIds, archiveChanges, deletedIds) {
|
|
@@ -142736,7 +143182,7 @@ var ChSessions = class {
|
|
|
142736
143182
|
next.has(row.sessionId) && this.events.emit("api-session/added", row);
|
|
142737
143183
|
if (before)
|
|
142738
143184
|
for (let id2 of before.keys())
|
|
142739
|
-
this.rows.has(id2) || (this.handoffs.delete(id2), this.events.emit("api-session/removed", id2));
|
|
143185
|
+
this.rows.has(id2) || (this.handoffs.delete(id2), this.roleSnapshots.delete(id2), this.ownerConfigurations.delete(id2), this.events.emit("api-session/removed", id2));
|
|
142740
143186
|
}
|
|
142741
143187
|
}
|
|
142742
143188
|
async owner(id2) {
|
|
@@ -142746,7 +143192,16 @@ var ChSessions = class {
|
|
|
142746
143192
|
let inspection = threadInspectionSchema.parse(
|
|
142747
143193
|
await this.host.request("codexhost/thread/inspect", { threadId: resolved })
|
|
142748
143194
|
);
|
|
142749
|
-
|
|
143195
|
+
if (this.handoffs.set(resolved, inspection.handoff ?? null), this.ownerConfigurations.set(resolved, {
|
|
143196
|
+
effectiveModel: inspection.effectiveModel,
|
|
143197
|
+
effectiveThinkingOptionId: inspection.effectiveThinkingOptionId,
|
|
143198
|
+
effectivePermissionModeId: inspection.effectivePermissionModeId
|
|
143199
|
+
}), inspection.roleSnapshot) {
|
|
143200
|
+
this.roleSnapshots.set(resolved, inspection.roleSnapshot);
|
|
143201
|
+
let view = this.threads.view(resolved);
|
|
143202
|
+
view && !threadRoleSnapshotSchema.safeParse(view.thread.roleSnapshot).success && view.log.setProjection("roleSnapshot", inspection.roleSnapshot);
|
|
143203
|
+
}
|
|
143204
|
+
return {
|
|
142750
143205
|
...inspection,
|
|
142751
143206
|
harnessId: inspection.owner === "codex" ? "codex" : inspection.harnessId
|
|
142752
143207
|
};
|
|
@@ -142824,12 +143279,18 @@ var ChSessions = class {
|
|
|
142824
143279
|
), view.log.setProjection(
|
|
142825
143280
|
"nativeDiscovery",
|
|
142826
143281
|
!view.thread.parentThreadId && view.thread.canAcceptDirectInput !== !1
|
|
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) {
|
|
143282
|
+
), view.log.setProjection("roleSnapshot", this.roleSnapshotOf(view.thread)), 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
143283
|
let mode = view.ownerSnapshot?.configuration.codexCollaborationMode;
|
|
142829
143284
|
this.projectCodexPlanMode(
|
|
142830
143285
|
view,
|
|
142831
143286
|
harnessId === "codex" && !view.thread.parentThreadId && view.thread.canAcceptDirectInput !== !1 && mode !== void 0 ? mode === "plan" : null
|
|
142832
143287
|
);
|
|
143288
|
+
let ownerConfig = view.ownerSnapshot?.configuration ?? this.ownerConfigurations.get(id2);
|
|
143289
|
+
ownerConfig && (view.ownerSnapshot && this.ownerConfigurations.set(id2, {
|
|
143290
|
+
effectiveModel: ownerConfig.effectiveModel,
|
|
143291
|
+
effectiveThinkingOptionId: ownerConfig.effectiveThinkingOptionId,
|
|
143292
|
+
effectivePermissionModeId: ownerConfig.effectivePermissionModeId
|
|
143293
|
+
}), this.projectOwnerConfiguration(view, harnessId, ownerConfig));
|
|
142833
143294
|
}
|
|
142834
143295
|
view.ownerSnapshot && this.hostOnline && !this.closed && (this.syncedRunningInteractions.add(id2), this.interactions?.update(view.ownerSnapshot)), this.realtime && view.log.setProjection("nativeConnection", {
|
|
142835
143296
|
state: this.hostOnline ? "connected" : "reconnecting"
|
|
@@ -142871,34 +143332,39 @@ var ChSessions = class {
|
|
|
142871
143332
|
}
|
|
142872
143333
|
})();
|
|
142873
143334
|
}
|
|
143335
|
+
projectOwnerConfiguration(view, harnessId, owner) {
|
|
143336
|
+
view.log.setProjection("permissions", {
|
|
143337
|
+
currentValue: owner.effectivePermissionModeId ?? ""
|
|
143338
|
+
});
|
|
143339
|
+
let selection2 = {
|
|
143340
|
+
provider: harnessId,
|
|
143341
|
+
model: owner.effectiveModel ? harnessModelRefKey(owner.effectiveModel) : "harness",
|
|
143342
|
+
...owner.effectiveThinkingOptionId ? { reasoningEffort: owner.effectiveThinkingOptionId } : {}
|
|
143343
|
+
};
|
|
143344
|
+
view.log.setProjection("modelSelection", { lastUsed: selection2, next: selection2 });
|
|
143345
|
+
}
|
|
142874
143346
|
loadControls(view, harnessId, force, configurationRevision) {
|
|
142875
143347
|
let id2 = view.thread.id;
|
|
142876
143348
|
if ((this.threads.get(id2)?.configurationRevision ?? 0) !== configurationRevision || !force && this.threads.get(id2)?.controls) return;
|
|
142877
|
-
let loading =
|
|
142878
|
-
view.ownerSnapshot ? Promise.resolve(
|
|
142879
|
-
|
|
142880
|
-
|
|
142881
|
-
|
|
142882
|
-
return;
|
|
142883
|
-
|
|
142884
|
-
|
|
142885
|
-
|
|
142886
|
-
|
|
142887
|
-
|
|
142888
|
-
|
|
142889
|
-
|
|
142890
|
-
|
|
142891
|
-
)
|
|
142892
|
-
|
|
142893
|
-
|
|
142894
|
-
model: owner.effectiveModel ? harnessModelRefKey(owner.effectiveModel) : "harness",
|
|
142895
|
-
...owner.effectiveThinkingOptionId ? { reasoningEffort: owner.effectiveThinkingOptionId } : {}
|
|
142896
|
-
};
|
|
142897
|
-
view.log.setProjection("modelSelection", { lastUsed: selection2, next: selection2 });
|
|
142898
|
-
}).catch(() => {
|
|
142899
|
-
}).finally(() => {
|
|
143349
|
+
let loading = (async () => {
|
|
143350
|
+
let isCurrent = () => !this.closed && this.threads.view(id2) === view && this.threads.get(id2)?.controls === loading && (this.threads.get(id2)?.configurationRevision ?? 0) === configurationRevision, ownerTask = view.ownerSnapshot ? Promise.resolve() : this.owner(id2).then((owner) => {
|
|
143351
|
+
isCurrent() && (view.log.setProjection(WEB_HANDOFF_PROJECTION, owner.handoff ?? null), this.projectOwnerConfiguration(view, harnessId, owner));
|
|
143352
|
+
}).catch(() => {
|
|
143353
|
+
}), inspectTask = this.catalog.inspect(harnessId, view.thread.cwd).then((inspection) => {
|
|
143354
|
+
if (!isCurrent()) return;
|
|
143355
|
+
let target2 = view.editableMessage();
|
|
143356
|
+
view.log.setProjection("sentMessageEdit", {
|
|
143357
|
+
seq: target2 && inspection.status === "ready" && inspection.capabilities.history.rollbackLastTurn && !view.thread.parentThreadId && view.thread.canAcceptDirectInput !== !1 && editedNativeInput(target2.input, "") ? target2.seq : null
|
|
143358
|
+
}), view.log.setProjection(
|
|
143359
|
+
"nativePermissions",
|
|
143360
|
+
nativePermissionView(harnessId, inspection, !0)
|
|
143361
|
+
);
|
|
143362
|
+
}).catch(() => {
|
|
143363
|
+
});
|
|
143364
|
+
await Promise.all([ownerTask, inspectTask]);
|
|
143365
|
+
})().finally(() => {
|
|
142900
143366
|
let current = this.threads.get(id2);
|
|
142901
|
-
current
|
|
143367
|
+
current && current.controls === loading && delete current.controls;
|
|
142902
143368
|
});
|
|
142903
143369
|
this.threads.ensure(id2).controls = loading;
|
|
142904
143370
|
}
|
|
@@ -142922,6 +143388,7 @@ var ChSessions = class {
|
|
|
142922
143388
|
threadReference: { hostId: "local" },
|
|
142923
143389
|
title: threadListTitle(row),
|
|
142924
143390
|
codexhostImportSource: row.codexhostImportSource ?? null,
|
|
143391
|
+
roleSnapshot: this.roleSnapshotOf(row),
|
|
142925
143392
|
harnessIdentity: { id: harnessId, name: await this.catalog.name(harnessId) },
|
|
142926
143393
|
sessionListMetadata: { blank: !1, lastPromptAt: threadRecencyMs(row) }
|
|
142927
143394
|
};
|
|
@@ -142975,7 +143442,7 @@ var ChSessions = class {
|
|
|
142975
143442
|
this.planChanges.delete(id2), this.realtime?.invalidate(id2);
|
|
142976
143443
|
}
|
|
142977
143444
|
}
|
|
142978
|
-
async draftSummary(draft, includeControls = !0) {
|
|
143445
|
+
async draftSummary(draft, includeControls = !0, includeClearedRole = !1) {
|
|
142979
143446
|
let controls;
|
|
142980
143447
|
do {
|
|
142981
143448
|
let provider = draft.selection.provider, [inspection2, supportsPlan2, name3] = await Promise.all([
|
|
@@ -143004,8 +143471,10 @@ var ChSessions = class {
|
|
|
143004
143471
|
imageLimits: WEB_IMAGE_LIMITS
|
|
143005
143472
|
} : {},
|
|
143006
143473
|
modelSelection: { lastUsed: null, next: draft.selection },
|
|
143007
|
-
codexPlanMode: draft.selection.provider === "codex" && supportsPlan ? draft.codexPlanMode === !0 : null
|
|
143008
|
-
|
|
143474
|
+
codexPlanMode: draft.selection.provider === "codex" && supportsPlan ? draft.codexPlanMode === !0 : null,
|
|
143475
|
+
draftRoleSlug: draft.roleSlug ?? null,
|
|
143476
|
+
draftSelectionExplicit: draft.explicitSelection === !0
|
|
143477
|
+
} : draft.roleSlug !== void 0 || includeClearedRole ? { draftRoleSlug: draft.roleSlug ?? null } : {},
|
|
143009
143478
|
harnessIdentity: {
|
|
143010
143479
|
id: draft.selection.provider,
|
|
143011
143480
|
name: name2
|
|
@@ -143025,12 +143494,16 @@ var ChSessions = class {
|
|
|
143025
143494
|
};
|
|
143026
143495
|
}
|
|
143027
143496
|
async create(args, configuration) {
|
|
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;
|
|
143497
|
+
let request3 = requestOf(args), roleSlug = configuration ? void 0 : requestedRoleSlug(request3.roleSlug), 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;
|
|
143029
143498
|
if ((request3.workspaceId !== void 0 || request3.cwd !== void 0) && !cwd)
|
|
143030
143499
|
throw new SessionRuntimeError("workspace/invalid-path", "Choose a valid computer working directory.");
|
|
143031
143500
|
let id2 = request3.sessionId ?? `draft-${randomUUID23()}`, existing = this.drafts.get(id2);
|
|
143032
143501
|
if (existing && !existing.canonicalId && !existing.creating && !existing.started && existing.cwd === cwd && existing.projectId === projectId) {
|
|
143033
|
-
if (!configuration && request3.matchProjectDefault)
|
|
143502
|
+
if (!configuration && (typeof roleSlug == "string" ? existing.roleSlug !== roleSlug : (roleSlug === null || request3.matchProjectDefault === !0) && existing.roleSlug !== void 0))
|
|
143503
|
+
throw new SessionRuntimeError("session/writer-held", "Start a new draft with this Agent Role.", {
|
|
143504
|
+
sessionId: id2
|
|
143505
|
+
});
|
|
143506
|
+
if (!configuration && request3.matchProjectDefault && typeof roleSlug != "string") {
|
|
143034
143507
|
if (existing.projectHarnessId !== projectHarnessId2)
|
|
143035
143508
|
throw new SessionRuntimeError("session/writer-held", "Start a new draft with the project default.", {
|
|
143036
143509
|
sessionId: id2
|
|
@@ -143054,7 +143527,7 @@ var ChSessions = class {
|
|
|
143054
143527
|
if (existing || this.rows.has(id2))
|
|
143055
143528
|
throw new SessionRuntimeError("session/busy", "This Session already exists; start a new draft.");
|
|
143056
143529
|
let preferences2 = configuration ? void 0 : this.preferences?.get().catch(() => {
|
|
143057
|
-
}), selection2 = configuration?.selection ?? (await this.catalog.models(!1, void 0, preferences2, projectHarnessId2)).default;
|
|
143530
|
+
}), selection2 = configuration?.selection ?? (typeof roleSlug == "string" ? await this.roleSelection(roleSlug, preferences2) : (await this.catalog.models(!1, void 0, preferences2, projectHarnessId2)).default);
|
|
143058
143531
|
if (!selection2)
|
|
143059
143532
|
throw new SessionRuntimeError(
|
|
143060
143533
|
"host/no-harness",
|
|
@@ -143065,6 +143538,7 @@ var ChSessions = class {
|
|
|
143065
143538
|
...cwd ? { cwd } : {},
|
|
143066
143539
|
...projectId ? { projectId } : {},
|
|
143067
143540
|
...projectHarnessId2 ? { projectHarnessId: projectHarnessId2 } : {},
|
|
143541
|
+
...typeof roleSlug == "string" ? { roleSlug, explicitSelection: !0 } : {},
|
|
143068
143542
|
selection: selection2,
|
|
143069
143543
|
createdAt: Date.now()
|
|
143070
143544
|
};
|
|
@@ -143081,6 +143555,25 @@ var ChSessions = class {
|
|
|
143081
143555
|
if (this.closed) throw new SessionRuntimeError("session/closed", "Web sessions are closing.");
|
|
143082
143556
|
return this.drafts.has(id2) ? this.create(args, configuration) : (this.drafts.set(id2, draft), cwd && selection2.provider !== "codex" && this.skills.prepare(cwd), this.workspaces.usesNativeProjects ? this.workspaces.updateNativeProjectMember(id2, projectId) : (cwd && this.workspaces.attachReferencedSession(id2, cwd), this.workspaces.addDraftReference(id2, cwd)), this.events.emit("api-session/added", await this.draftSummary(draft, !1)), { sessionId: id2, agentPreset: "standard" });
|
|
143083
143557
|
}
|
|
143558
|
+
/** Draft selection from a Role: its Harness, its Model or that Harness's new-thread default. */
|
|
143559
|
+
async roleSelection(slug, preferences2) {
|
|
143560
|
+
let { role } = rolesGetResultSchema.parse(
|
|
143561
|
+
await this.host.request(ROLES_GET_METHOD, { slug })
|
|
143562
|
+
);
|
|
143563
|
+
if (!role)
|
|
143564
|
+
throw new SessionRuntimeError("session/role-not-found", "This Agent Role no longer exists.", {
|
|
143565
|
+
roleSlug: slug
|
|
143566
|
+
});
|
|
143567
|
+
let fallback = (await this.catalog.models(!1, void 0, preferences2, role.harnessId)).default;
|
|
143568
|
+
if (fallback?.provider !== role.harnessId)
|
|
143569
|
+
throw new SessionRuntimeError(
|
|
143570
|
+
"host/no-harness",
|
|
143571
|
+
"The Agent Role's Harness has no available models. Re-detect it in Connections.",
|
|
143572
|
+
{ harnessId: role.harnessId }
|
|
143573
|
+
);
|
|
143574
|
+
let model2 = role.model ? roleModelToSelectionKey(role.model) : fallback.model, reasoningEffort = role.thinkingOptionId ?? (model2 === fallback.model ? fallback.reasoningEffort : void 0);
|
|
143575
|
+
return { provider: role.harnessId, model: model2, ...reasoningEffort ? { reasoningEffort } : {} };
|
|
143576
|
+
}
|
|
143084
143577
|
/** Materialize a source-neutral draft without reading or writing global defaults. */
|
|
143085
143578
|
async prepareDraft(request3, configuration) {
|
|
143086
143579
|
await this.create({ request: request3 }, configuration);
|
|
@@ -143105,6 +143598,7 @@ var ChSessions = class {
|
|
|
143105
143598
|
(item) => item.id === draft.selection.provider
|
|
143106
143599
|
), result = await this.host.request("thread/start", {
|
|
143107
143600
|
historyMode: "paginated",
|
|
143601
|
+
...draft.roleSlug ? { roleSlug: draft.roleSlug } : {},
|
|
143108
143602
|
...draft.projectId ? { projectId: draft.projectId } : {},
|
|
143109
143603
|
...draft.cwd ? { cwd: draft.cwd } : { projectlessWorkspace: { prompt: prompt.slice(0, 16384) } },
|
|
143110
143604
|
...plugin ? {
|
|
@@ -143256,7 +143750,7 @@ var ChSessions = class {
|
|
|
143256
143750
|
forgetDeleted(id2) {
|
|
143257
143751
|
this.refreshingDeletedIds?.add(id2), this.archiveOperations.delete(id2), this.queueOperations.delete(id2), this.titleRequests.delete(id2), this.syncedRunningInteractions.delete(id2);
|
|
143258
143752
|
let activeRead = this.interactionReads.get(id2);
|
|
143259
|
-
activeRead && (activeRead.cancelled = !0, activeRead.dirty = !1, this.interactionReads.delete(id2)), this.interactions?.clearSession(id2), this.rows.delete(id2), this.handoffs.delete(id2), this.threads.delete(id2), this.tree.forget(id2);
|
|
143753
|
+
activeRead && (activeRead.cancelled = !0, activeRead.dirty = !1, this.interactionReads.delete(id2)), this.interactions?.clearSession(id2), this.rows.delete(id2), this.handoffs.delete(id2), this.roleSnapshots.delete(id2), this.ownerConfigurations.delete(id2), this.threads.delete(id2), this.tree.forget(id2);
|
|
143260
143754
|
let archived = this.workspaces.localArchivedSessionIds();
|
|
143261
143755
|
archived.includes(id2) && this.workspaces.setReferenceArchives(archived.filter((item) => item !== id2));
|
|
143262
143756
|
let pinned = this.workspaces.localPinnedSessionIds();
|
|
@@ -143521,8 +144015,9 @@ var ChSessions = class {
|
|
|
143521
144015
|
let request3 = requestOf(args);
|
|
143522
144016
|
return this.catalog.models(request3?.refresh === !0, request3?.harnessId);
|
|
143523
144017
|
}), rpc2.register("session/selectModel", async (args) => {
|
|
143524
|
-
let request3 = requestOf(args), model2 = harnessModelRefFromKey(request3.model), draft = this.drafts.get(request3.sessionId);
|
|
144018
|
+
let { roleSlug: rawRoleSlug, ...request3 } = requestOf(args), model2 = harnessModelRefFromKey(request3.model), draft = this.drafts.get(request3.sessionId);
|
|
143525
144019
|
if (draft && !draft.canonicalId) {
|
|
144020
|
+
let roleSlug = requestedRoleSlug(rawRoleSlug);
|
|
143526
144021
|
if (draft.creating || draft.started)
|
|
143527
144022
|
throw new SessionRuntimeError("session/busy", "Draft creation is in progress.");
|
|
143528
144023
|
let before = draft.selection;
|
|
@@ -143538,7 +144033,8 @@ var ChSessions = class {
|
|
|
143538
144033
|
);
|
|
143539
144034
|
delete draft.codexPlanMode, delete draft.permissionModeId, permissionModeId && (draft.permissionModeId = permissionModeId);
|
|
143540
144035
|
}
|
|
143541
|
-
|
|
144036
|
+
let hadRole = draft.roleSlug !== void 0;
|
|
144037
|
+
draft.selection = request3, draft.explicitSelection = !0, typeof roleSlug == "string" ? draft.roleSlug = roleSlug : (roleSlug === null || before.provider !== request3.provider) && delete draft.roleSlug, before.provider !== request3.provider && this.events.emit("commands/change"), draft.roleSlug || await this.preferences?.remember(request3.provider, {
|
|
143542
144038
|
model: model2,
|
|
143543
144039
|
thinkingOptionId: request3.reasoningEffort,
|
|
143544
144040
|
permissionModeId: draft.permissionModeId
|
|
@@ -143547,7 +144043,10 @@ var ChSessions = class {
|
|
|
143547
144043
|
"codexhost/preferences-error",
|
|
143548
144044
|
"New session defaults could not be saved."
|
|
143549
144045
|
)
|
|
143550
|
-
), this.events.emit(
|
|
144046
|
+
), this.events.emit(
|
|
144047
|
+
"api-session/added",
|
|
144048
|
+
await this.draftSummary(draft, !1, hadRole && draft.roleSlug === void 0)
|
|
144049
|
+
);
|
|
143551
144050
|
for (let sink of this.controls) {
|
|
143552
144051
|
let s = await this.draftSummary(draft);
|
|
143553
144052
|
for (let [key, value] of Object.entries(s.projections.values))
|
|
@@ -143572,8 +144071,12 @@ var ChSessions = class {
|
|
|
143572
144071
|
provider: owner.harnessId,
|
|
143573
144072
|
model: harnessModelRefKey(configuration2.effectiveModel),
|
|
143574
144073
|
...configuration2.effectiveThinkingOptionId ? { reasoningEffort: configuration2.effectiveThinkingOptionId } : {}
|
|
143575
|
-
};
|
|
143576
|
-
return
|
|
144074
|
+
}, previousConfig = this.ownerConfigurations.get(id2);
|
|
144075
|
+
return this.ownerConfigurations.set(id2, {
|
|
144076
|
+
effectiveModel: configuration2.effectiveModel,
|
|
144077
|
+
effectiveThinkingOptionId: configuration2.effectiveThinkingOptionId,
|
|
144078
|
+
effectivePermissionModeId: previousConfig?.effectivePermissionModeId
|
|
144079
|
+
}), state2.view?.log.setProjection("modelSelection", { lastUsed: selection2, next: selection2 }), configuration2;
|
|
143577
144080
|
}, configuration = publish(
|
|
143578
144081
|
owner.owner === "codex" && sameHarnessModelRef(owner.effectiveModel, model2) ? {
|
|
143579
144082
|
effectiveModel: owner.effectiveModel,
|
|
@@ -144132,7 +144635,7 @@ var ChSessions = class {
|
|
|
144132
144635
|
if (draft && !draft.canonicalId) {
|
|
144133
144636
|
if (draft.creating || draft.started || draft.selection.provider !== harnessId)
|
|
144134
144637
|
throw new SessionRuntimeError("session/busy", "Draft selection changed.");
|
|
144135
|
-
draft.permissionModeId = modeId, await this.preferences?.remember(harnessId, {
|
|
144638
|
+
draft.permissionModeId = modeId, draft.roleSlug || await this.preferences?.remember(harnessId, {
|
|
144136
144639
|
model: harnessModelRefFromKey(draft.selection.model),
|
|
144137
144640
|
thinkingOptionId: draft.selection.reasoningEffort,
|
|
144138
144641
|
permissionModeId: modeId
|
|
@@ -144490,7 +144993,21 @@ var exec3 = promisify7(execFile6), METHODS = /* @__PURE__ */ new Set([
|
|
|
144490
144993
|
THREAD_HANDOFF_METHOD,
|
|
144491
144994
|
"codexhost/harness/session-import/sources",
|
|
144492
144995
|
"codexhost/harness/session-import/list",
|
|
144493
|
-
"codexhost/harness/session-import/import"
|
|
144996
|
+
"codexhost/harness/session-import/import",
|
|
144997
|
+
ROLES_LIST_METHOD,
|
|
144998
|
+
ROLES_GET_METHOD,
|
|
144999
|
+
ROLES_SAVE_METHOD,
|
|
145000
|
+
ROLES_DELETE_METHOD,
|
|
145001
|
+
GROUPS_LIST_METHOD,
|
|
145002
|
+
GROUPS_GET_METHOD,
|
|
145003
|
+
GROUPS_CREATE_METHOD,
|
|
145004
|
+
GROUPS_UPDATE_METHOD,
|
|
145005
|
+
GROUPS_DELETE_METHOD,
|
|
145006
|
+
GROUPS_ADD_MEMBER_METHOD,
|
|
145007
|
+
GROUPS_UPDATE_MEMBER_METHOD,
|
|
145008
|
+
GROUPS_REMOVE_MEMBER_METHOD,
|
|
145009
|
+
GROUPS_POST_MESSAGE_METHOD,
|
|
145010
|
+
GROUPS_READ_MESSAGES_METHOD
|
|
144494
145011
|
]);
|
|
144495
145012
|
async function requestPins(request3, change) {
|
|
144496
145013
|
let value = await request3(
|
|
@@ -144697,7 +145214,7 @@ async function serveChClientGateway(host, request3, response, { authenticated =
|
|
|
144697
145214
|
let after = url2.searchParams.has("epoch") ? clientChannelCursorSchema.parse({
|
|
144698
145215
|
epoch: url2.searchParams.get("epoch"),
|
|
144699
145216
|
sequence: Number(url2.searchParams.get("after"))
|
|
144700
|
-
}) : void 0, supportsSections = url2.searchParams.get(THREAD_SECTION_CAPABILITY) === "1", stop = channel.subscribe((event) => {
|
|
145217
|
+
}) : void 0, supportsSections = url2.searchParams.get(THREAD_SECTION_CAPABILITY) === "1", supportsGroups = url2.searchParams.get(GROUP_ROOMS_CAPABILITY) === "1", stop = channel.subscribe((event) => {
|
|
144701
145218
|
if (event.type === "connection") {
|
|
144702
145219
|
!event.online && !response.writableEnded && !response.destroyed && (response.headersSent ? response.end() : response.writeHead(503, {
|
|
144703
145220
|
"content-type": "application/json; charset=utf-8",
|
|
@@ -144713,7 +145230,7 @@ async function serveChClientGateway(host, request3, response, { authenticated =
|
|
|
144713
145230
|
response.destroy();
|
|
144714
145231
|
return;
|
|
144715
145232
|
}
|
|
144716
|
-
let frame = event.type === "sections-changed" && !supportsSections ? { type: "hello", version: 1, cursor: event.cursor, reset: !0 } : event;
|
|
145233
|
+
let frame = event.type === "sections-changed" && !supportsSections || event.type === "groups-changed" && !supportsGroups ? { type: "hello", version: 1, cursor: event.cursor, reset: !0 } : event;
|
|
144717
145234
|
response.write(JSON.stringify(frame) + `
|
|
144718
145235
|
`);
|
|
144719
145236
|
}, after), heartbeat = setInterval(() => {
|
|
@@ -145801,6 +146318,7 @@ ${head.join(`
|
|
|
145801
146318
|
".webmanifest": "application/manifest+json; charset=utf-8",
|
|
145802
146319
|
".svg": "image/svg+xml",
|
|
145803
146320
|
".png": "image/png",
|
|
146321
|
+
".webp": "image/webp",
|
|
145804
146322
|
".ico": "image/x-icon",
|
|
145805
146323
|
".woff2": "font/woff2",
|
|
145806
146324
|
".woff": "font/woff",
|
|
@@ -146020,10 +146538,474 @@ async function serveFileUpload(sessions2, request3, response, viaRelay = !1, rem
|
|
|
146020
146538
|
}
|
|
146021
146539
|
}
|
|
146022
146540
|
|
|
146023
|
-
// packages/web-server/src/
|
|
146541
|
+
// packages/web-server/src/roles.ts
|
|
146542
|
+
var ROLES_CHANGED_EVENT = "codexhost/roles/changed", WebRoles = class {
|
|
146543
|
+
constructor(host, events2) {
|
|
146544
|
+
this.host = host;
|
|
146545
|
+
this.events = events2;
|
|
146546
|
+
}
|
|
146547
|
+
host;
|
|
146548
|
+
events;
|
|
146549
|
+
register(rpc2) {
|
|
146550
|
+
let proxy = (method2, params, result, changes = !1) => {
|
|
146551
|
+
rpc2.register(method2, async (args) => {
|
|
146552
|
+
let parsed = params.safeParse(args);
|
|
146553
|
+
if (!parsed.success) throw new SessionRuntimeError("roles/invalid", "Invalid Role request.");
|
|
146554
|
+
let value = result.parse(
|
|
146555
|
+
await this.host.request(method2, parsed.data)
|
|
146556
|
+
);
|
|
146557
|
+
return changes && this.events.emit(ROLES_CHANGED_EVENT), value;
|
|
146558
|
+
});
|
|
146559
|
+
};
|
|
146560
|
+
proxy(ROLES_LIST_METHOD, rolesListParamsSchema, rolesListResultSchema), proxy(ROLES_GET_METHOD, rolesGetParamsSchema, rolesGetResultSchema), proxy(ROLES_SAVE_METHOD, rolesSaveParamsSchema, rolesSaveResultSchema, !0), proxy(ROLES_DELETE_METHOD, rolesDeleteParamsSchema, rolesDeleteResultSchema, !0), proxy(ROLES_CATALOG_METHOD, rolesCatalogParamsSchema, rolesCatalogResultSchema), proxy(ROLES_LIKE_METHOD, rolesLikeParamsSchema, rolesLikeResultSchema);
|
|
146561
|
+
}
|
|
146562
|
+
};
|
|
146563
|
+
|
|
146564
|
+
// packages/web-server/src/groups.ts
|
|
146565
|
+
var REMOTE_GROUP_PREFIX = "remote:";
|
|
146566
|
+
function remoteGroupRoomId(hostId2, roomId) {
|
|
146567
|
+
return REMOTE_GROUP_PREFIX + Buffer.from(JSON.stringify([hostId2, roomId])).toString("base64url");
|
|
146568
|
+
}
|
|
146569
|
+
function remoteGroupRoomIdentity(id2) {
|
|
146570
|
+
if (id2.startsWith(REMOTE_GROUP_PREFIX)) {
|
|
146571
|
+
try {
|
|
146572
|
+
let value = JSON.parse(
|
|
146573
|
+
Buffer.from(id2.slice(REMOTE_GROUP_PREFIX.length), "base64url").toString("utf8")
|
|
146574
|
+
);
|
|
146575
|
+
if (Array.isArray(value) && value.length === 2 && value.every((item) => typeof item == "string" && item.length > 0) && value[0] !== "local" && value[0] !== "durable" && remoteGroupRoomId(value[0], value[1]) === id2)
|
|
146576
|
+
return { hostId: value[0], roomId: value[1] };
|
|
146577
|
+
} catch {
|
|
146578
|
+
}
|
|
146579
|
+
throw new SessionRuntimeError("remote/identity-invalid", "Invalid remote Group Chat identity");
|
|
146580
|
+
}
|
|
146581
|
+
}
|
|
146582
|
+
function projectRemoteMember(hostId2, member) {
|
|
146583
|
+
return {
|
|
146584
|
+
...member,
|
|
146585
|
+
threadId: hostThreadIdSchema.parse(remoteSessionId(hostId2, member.threadId))
|
|
146586
|
+
};
|
|
146587
|
+
}
|
|
146588
|
+
function projectRemoteRoom(peer, room) {
|
|
146589
|
+
return {
|
|
146590
|
+
...room,
|
|
146591
|
+
roomId: remoteGroupRoomId(peer.hostId, room.roomId),
|
|
146592
|
+
members: room.members.map((member) => projectRemoteMember(peer.hostId, member)),
|
|
146593
|
+
remote: {
|
|
146594
|
+
hostId: peer.hostId,
|
|
146595
|
+
displayName: peer.displayName,
|
|
146596
|
+
state: peer.state,
|
|
146597
|
+
...peer.color !== void 0 ? { color: peer.color } : {},
|
|
146598
|
+
...peer.filePreview === !0 ? { filePreview: !0 } : {}
|
|
146599
|
+
}
|
|
146600
|
+
};
|
|
146601
|
+
}
|
|
146602
|
+
function projectRemoteMessage(hostId2, message2) {
|
|
146603
|
+
return {
|
|
146604
|
+
...message2,
|
|
146605
|
+
roomId: remoteGroupRoomId(hostId2, message2.roomId),
|
|
146606
|
+
...message2.senderThreadId !== void 0 ? {
|
|
146607
|
+
senderThreadId: hostThreadIdSchema.parse(remoteSessionId(hostId2, message2.senderThreadId))
|
|
146608
|
+
} : {}
|
|
146609
|
+
};
|
|
146610
|
+
}
|
|
146611
|
+
function roomUpdatedAtMs(room) {
|
|
146612
|
+
let parsed = Date.parse(room.updatedAt);
|
|
146613
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
146614
|
+
}
|
|
146615
|
+
var WebGroups = class {
|
|
146616
|
+
constructor(host, events2, remotePeers) {
|
|
146617
|
+
this.host = host;
|
|
146618
|
+
this.events = events2;
|
|
146619
|
+
this.remotePeers = remotePeers;
|
|
146620
|
+
this.unsubscribe = host.realtime?.subscribe((event) => {
|
|
146621
|
+
this.closed || (event.type === "groups-changed" ? this.emitChanged(event.roomId) : event.type === "hello" && this.emitChanged());
|
|
146622
|
+
}), this.unsubscribeRemote = remotePeers?.subscribe?.((event) => {
|
|
146623
|
+
this.closed || this.emitChanged(
|
|
146624
|
+
event.roomId !== void 0 ? remoteGroupRoomId(event.hostId, event.roomId) : void 0
|
|
146625
|
+
);
|
|
146626
|
+
});
|
|
146627
|
+
}
|
|
146628
|
+
host;
|
|
146629
|
+
events;
|
|
146630
|
+
remotePeers;
|
|
146631
|
+
unsubscribe;
|
|
146632
|
+
unsubscribeRemote;
|
|
146633
|
+
closed = !1;
|
|
146634
|
+
emitChanged(roomId) {
|
|
146635
|
+
roomId ? this.events.emit(GROUPS_CHANGED_EVENT, { roomId }) : this.events.emit(GROUPS_CHANGED_EVENT);
|
|
146636
|
+
}
|
|
146637
|
+
resolveTarget(roomId) {
|
|
146638
|
+
let remote = remoteGroupRoomIdentity(roomId);
|
|
146639
|
+
if (remote === void 0)
|
|
146640
|
+
return { peer: void 0, nativeRoomId: roomId };
|
|
146641
|
+
let peer = this.remotePeers?.peer(remote.hostId);
|
|
146642
|
+
if (!peer || !peer.online)
|
|
146643
|
+
throw new SessionRuntimeError("remote/offline", "Remote peer is offline.");
|
|
146644
|
+
return { peer, nativeRoomId: remote.roomId };
|
|
146645
|
+
}
|
|
146646
|
+
register(rpc2) {
|
|
146647
|
+
let parseOrThrow = (schema2, args) => {
|
|
146648
|
+
let parsed = schema2.safeParse(args);
|
|
146649
|
+
if (!parsed.success) throw new SessionRuntimeError("groups/invalid", "Invalid Group Chat request.");
|
|
146650
|
+
return parsed.data;
|
|
146651
|
+
};
|
|
146652
|
+
rpc2.register(GROUPS_LIST_METHOD, async (args) => {
|
|
146653
|
+
parseOrThrow(groupsListParamsSchema, args);
|
|
146654
|
+
let localResult = groupsListResultSchema.parse(
|
|
146655
|
+
await this.host.request(GROUPS_LIST_METHOD, {})
|
|
146656
|
+
), onlinePeers = (this.remotePeers?.peers() ?? []).filter((peer) => peer.online);
|
|
146657
|
+
if (onlinePeers.length === 0) return localResult;
|
|
146658
|
+
let remoteBatches = await Promise.all(
|
|
146659
|
+
onlinePeers.map(async (peer) => {
|
|
146660
|
+
try {
|
|
146661
|
+
return groupsListResultSchema.parse(
|
|
146662
|
+
await peer.host.request(GROUPS_LIST_METHOD, {})
|
|
146663
|
+
).rooms.map((room) => projectRemoteRoom(peer, room));
|
|
146664
|
+
} catch {
|
|
146665
|
+
return [];
|
|
146666
|
+
}
|
|
146667
|
+
})
|
|
146668
|
+
);
|
|
146669
|
+
return { rooms: [...localResult.rooms, ...remoteBatches.flat()].sort(
|
|
146670
|
+
(a, b) => roomUpdatedAtMs(b) - roomUpdatedAtMs(a)
|
|
146671
|
+
) };
|
|
146672
|
+
}), rpc2.register(GROUPS_GET_METHOD, async (args) => {
|
|
146673
|
+
let parsed = parseOrThrow(groupsGetParamsSchema, args), { peer, nativeRoomId } = this.resolveTarget(parsed.roomId), raw = await (peer?.host ?? this.host).request(GROUPS_GET_METHOD, {
|
|
146674
|
+
...parsed,
|
|
146675
|
+
roomId: nativeRoomId
|
|
146676
|
+
}), result = groupsGetResultSchema.parse(raw);
|
|
146677
|
+
return peer === void 0 ? result : {
|
|
146678
|
+
room: result.room === null ? null : projectRemoteRoom(peer, result.room),
|
|
146679
|
+
messages: result.messages.map((message2) => projectRemoteMessage(peer.hostId, message2)),
|
|
146680
|
+
hasMore: result.hasMore
|
|
146681
|
+
};
|
|
146682
|
+
}), rpc2.register(GROUPS_CREATE_METHOD, async (args) => {
|
|
146683
|
+
let parsed = parseOrThrow(groupsCreateParamsSchema, args), value = groupsCreateResultSchema.parse(
|
|
146684
|
+
await this.host.request(GROUPS_CREATE_METHOD, parsed)
|
|
146685
|
+
);
|
|
146686
|
+
return this.emitChanged(value.room.roomId), value;
|
|
146687
|
+
}), rpc2.register(GROUPS_UPDATE_METHOD, async (args) => {
|
|
146688
|
+
let parsed = parseOrThrow(groupsUpdateParamsSchema, args), { peer, nativeRoomId } = this.resolveTarget(parsed.roomId), raw = await (peer?.host ?? this.host).request(GROUPS_UPDATE_METHOD, {
|
|
146689
|
+
...parsed,
|
|
146690
|
+
roomId: nativeRoomId
|
|
146691
|
+
}), result = groupsUpdateResultSchema.parse(raw), projected = peer === void 0 ? result : { room: projectRemoteRoom(peer, result.room) };
|
|
146692
|
+
return this.emitChanged(projected.room.roomId), projected;
|
|
146693
|
+
}), rpc2.register(GROUPS_DELETE_METHOD, async (args) => {
|
|
146694
|
+
let parsed = parseOrThrow(groupsDeleteParamsSchema, args), { peer, nativeRoomId } = this.resolveTarget(parsed.roomId), raw = await (peer?.host ?? this.host).request(GROUPS_DELETE_METHOD, {
|
|
146695
|
+
roomId: nativeRoomId
|
|
146696
|
+
}), result = groupsDeleteResultSchema.parse(raw);
|
|
146697
|
+
return this.emitChanged(parsed.roomId), result;
|
|
146698
|
+
}), rpc2.register(GROUPS_ADD_MEMBER_METHOD, async (args) => {
|
|
146699
|
+
let parsed = parseOrThrow(groupsAddMemberParamsSchema, args), { peer, nativeRoomId } = this.resolveTarget(parsed.roomId), memberInput = parsed.member;
|
|
146700
|
+
if (peer !== void 0 && memberInput.kind === "existing") {
|
|
146701
|
+
let identity2 = remoteSessionIdentity(memberInput.threadId);
|
|
146702
|
+
if (identity2 !== void 0) {
|
|
146703
|
+
if (identity2.hostId !== peer.hostId)
|
|
146704
|
+
throw new SessionRuntimeError(
|
|
146705
|
+
"groups/invalid",
|
|
146706
|
+
"Existing member thread must belong to the same remote peer."
|
|
146707
|
+
);
|
|
146708
|
+
memberInput = { ...memberInput, threadId: hostThreadIdSchema.parse(identity2.threadId) };
|
|
146709
|
+
}
|
|
146710
|
+
}
|
|
146711
|
+
let raw = await (peer?.host ?? this.host).request(GROUPS_ADD_MEMBER_METHOD, {
|
|
146712
|
+
roomId: nativeRoomId,
|
|
146713
|
+
member: memberInput
|
|
146714
|
+
}), result = groupsAddMemberResultSchema.parse(raw), projected = peer === void 0 ? result : {
|
|
146715
|
+
room: projectRemoteRoom(peer, result.room),
|
|
146716
|
+
member: projectRemoteMember(peer.hostId, result.member)
|
|
146717
|
+
};
|
|
146718
|
+
return this.emitChanged(projected.room.roomId), projected;
|
|
146719
|
+
}), rpc2.register(GROUPS_UPDATE_MEMBER_METHOD, async (args) => {
|
|
146720
|
+
let parsed = parseOrThrow(groupsUpdateMemberParamsSchema, args), { peer, nativeRoomId } = this.resolveTarget(parsed.roomId), raw = await (peer?.host ?? this.host).request(GROUPS_UPDATE_MEMBER_METHOD, {
|
|
146721
|
+
...parsed,
|
|
146722
|
+
roomId: nativeRoomId
|
|
146723
|
+
}), result = groupsUpdateMemberResultSchema.parse(raw), projected = peer === void 0 ? result : {
|
|
146724
|
+
room: projectRemoteRoom(peer, result.room),
|
|
146725
|
+
member: projectRemoteMember(peer.hostId, result.member)
|
|
146726
|
+
};
|
|
146727
|
+
return this.emitChanged(projected.room.roomId), projected;
|
|
146728
|
+
}), rpc2.register(GROUPS_REMOVE_MEMBER_METHOD, async (args) => {
|
|
146729
|
+
let parsed = parseOrThrow(groupsRemoveMemberParamsSchema, args), { peer, nativeRoomId } = this.resolveTarget(parsed.roomId), raw = await (peer?.host ?? this.host).request(GROUPS_REMOVE_MEMBER_METHOD, {
|
|
146730
|
+
...parsed,
|
|
146731
|
+
roomId: nativeRoomId
|
|
146732
|
+
}), result = groupsRemoveMemberResultSchema.parse(raw), projected = peer === void 0 ? result : { room: projectRemoteRoom(peer, result.room) };
|
|
146733
|
+
return this.emitChanged(projected.room.roomId), projected;
|
|
146734
|
+
}), rpc2.register(GROUPS_POST_MESSAGE_METHOD, async (args) => {
|
|
146735
|
+
let parsed = parseOrThrow(groupsPostMessageParamsSchema, args), { peer, nativeRoomId } = this.resolveTarget(parsed.roomId), raw = await (peer?.host ?? this.host).request(GROUPS_POST_MESSAGE_METHOD, {
|
|
146736
|
+
...parsed,
|
|
146737
|
+
roomId: nativeRoomId
|
|
146738
|
+
}), result = groupsPostMessageResultSchema.parse(raw), projected = peer === void 0 ? result : {
|
|
146739
|
+
room: projectRemoteRoom(peer, result.room),
|
|
146740
|
+
message: projectRemoteMessage(peer.hostId, result.message),
|
|
146741
|
+
awakenedMemberIds: result.awakenedMemberIds
|
|
146742
|
+
};
|
|
146743
|
+
return this.emitChanged(projected.room.roomId), projected;
|
|
146744
|
+
}), rpc2.register(GROUPS_READ_MESSAGES_METHOD, async (args) => {
|
|
146745
|
+
let parsed = parseOrThrow(groupsReadMessagesParamsSchema, args), { peer, nativeRoomId } = this.resolveTarget(parsed.roomId), raw = await (peer?.host ?? this.host).request(GROUPS_READ_MESSAGES_METHOD, {
|
|
146746
|
+
...parsed,
|
|
146747
|
+
roomId: nativeRoomId
|
|
146748
|
+
}), result = groupsReadMessagesResultSchema.parse(raw);
|
|
146749
|
+
return peer === void 0 ? result : {
|
|
146750
|
+
roomId: parsed.roomId,
|
|
146751
|
+
messages: result.messages.map((message2) => projectRemoteMessage(peer.hostId, message2)),
|
|
146752
|
+
totalSeq: result.totalSeq
|
|
146753
|
+
};
|
|
146754
|
+
});
|
|
146755
|
+
}
|
|
146756
|
+
close() {
|
|
146757
|
+
this.closed = !0, this.unsubscribe?.(), this.unsubscribeRemote?.();
|
|
146758
|
+
}
|
|
146759
|
+
};
|
|
146760
|
+
|
|
146761
|
+
// packages/web-server/src/group-attachments-http.ts
|
|
146762
|
+
var GROUP_ATTACHMENT_UPLOAD_PATH = "/api/codexhost/groups/upload", GROUP_ATTACHMENT_IMAGE_PATH = "/api/codexhost/groups/image";
|
|
146763
|
+
async function serveGroupAttachmentUpload(files2, request3, response) {
|
|
146764
|
+
let send = (status, body) => response.writeHead(status, {
|
|
146765
|
+
"content-type": "application/json; charset=utf-8",
|
|
146766
|
+
"cache-control": "no-store"
|
|
146767
|
+
}).end(JSON.stringify(body));
|
|
146768
|
+
try {
|
|
146769
|
+
if (request3.headers["content-type"]?.split(";", 1)[0]?.trim().toLowerCase() !== "application/octet-stream") {
|
|
146770
|
+
send(415, { ok: !1, error: { message: "content type must be application/octet-stream" } });
|
|
146771
|
+
return;
|
|
146772
|
+
}
|
|
146773
|
+
let url2 = new URL(request3.url ?? "", "http://localhost"), parsedRoomId = groupRoomIdSchema.safeParse(url2.searchParams.get("roomId"));
|
|
146774
|
+
if (!parsedRoomId.success) {
|
|
146775
|
+
send(400, { ok: !1, error: { message: "valid roomId is required" } });
|
|
146776
|
+
return;
|
|
146777
|
+
}
|
|
146778
|
+
let name2 = url2.searchParams.get("name") ?? void 0, rawMediaType = url2.searchParams.get("imageMediaType")?.trim(), imageMediaType = rawMediaType && rawMediaType.length > 0 ? rawMediaType : void 0, scopeId = `group:${parsedRoomId.data}`, chunks = async function* () {
|
|
146779
|
+
for await (let chunk of request3.iterator({ destroyOnReturn: !1 }))
|
|
146780
|
+
yield chunk;
|
|
146781
|
+
}, { receiptId } = await files2.upload(scopeId, chunks(), name2, imageMediaType), [saved] = await files2.resolve(scopeId, [receiptId]);
|
|
146782
|
+
if (!saved) {
|
|
146783
|
+
send(500, { ok: !1, error: { message: "Stored attachment unavailable" } });
|
|
146784
|
+
return;
|
|
146785
|
+
}
|
|
146786
|
+
let value = saved.image ? {
|
|
146787
|
+
kind: "image",
|
|
146788
|
+
attachmentId: saved.image.attachmentId,
|
|
146789
|
+
name: saved.file.name,
|
|
146790
|
+
path: saved.path,
|
|
146791
|
+
bytes: saved.image.bytes,
|
|
146792
|
+
mediaType: saved.image.mediaType,
|
|
146793
|
+
width: saved.image.width,
|
|
146794
|
+
height: saved.image.height
|
|
146795
|
+
} : {
|
|
146796
|
+
kind: "file",
|
|
146797
|
+
attachmentId: saved.file.attachmentId,
|
|
146798
|
+
name: saved.file.name,
|
|
146799
|
+
path: saved.path,
|
|
146800
|
+
bytes: saved.file.bytes
|
|
146801
|
+
};
|
|
146802
|
+
send(200, { ok: !0, value });
|
|
146803
|
+
} catch (error62) {
|
|
146804
|
+
send(200, {
|
|
146805
|
+
ok: !1,
|
|
146806
|
+
error: {
|
|
146807
|
+
code: error62 instanceof SessionRuntimeError ? error62.code : "gateway/internal",
|
|
146808
|
+
message: error62 instanceof Error ? error62.message : "Attachment upload failed"
|
|
146809
|
+
}
|
|
146810
|
+
});
|
|
146811
|
+
} finally {
|
|
146812
|
+
request3.resume();
|
|
146813
|
+
}
|
|
146814
|
+
}
|
|
146815
|
+
function serveGroupAttachmentImage(images2, request3, response) {
|
|
146816
|
+
let id2 = new URL(request3.url ?? "", "http://localhost").searchParams.get("id") ?? "";
|
|
146817
|
+
if (!id2.startsWith("web-image:")) {
|
|
146818
|
+
response.writeHead(400, { "cache-control": "no-store" }).end();
|
|
146819
|
+
return;
|
|
146820
|
+
}
|
|
146821
|
+
try {
|
|
146822
|
+
let image = images2.readBytes(id2);
|
|
146823
|
+
response.writeHead(200, {
|
|
146824
|
+
"content-type": image.ref.mediaType,
|
|
146825
|
+
"content-length": String(image.bytes.byteLength),
|
|
146826
|
+
"cache-control": "private, max-age=31536000, immutable",
|
|
146827
|
+
"x-content-type-options": "nosniff"
|
|
146828
|
+
}).end(image.bytes);
|
|
146829
|
+
} catch {
|
|
146830
|
+
response.writeHead(404, { "cache-control": "no-store" }).end();
|
|
146831
|
+
}
|
|
146832
|
+
}
|
|
146833
|
+
|
|
146834
|
+
// packages/web-server/src/role-avatars-http.ts
|
|
146024
146835
|
import { randomUUID as randomUUID25 } from "node:crypto";
|
|
146025
|
-
import { mkdir as mkdir7,
|
|
146836
|
+
import { mkdir as mkdir7, readFile as readFile5, rename as rename5, rm as rm7, writeFile as writeFile5 } from "node:fs/promises";
|
|
146026
146837
|
import { join as join33 } from "node:path";
|
|
146838
|
+
var CUSTOM_ROLE_AVATAR_FILE = /^[a-zA-Z0-9_-]{1,64}\.(png|jpg|jpeg|webp)$/u, ROLE_AVATAR_MAX_BYTES = 2 * 1024 * 1024, ROLE_AVATAR_DIRECTORY = "role-avatars", CATALOG_AVATAR_CACHE_SUBPATH = ["roles", "catalog-avatars"], CATALOG_AVATAR_FETCH_TIMEOUT_MS = 8e3, UPLOAD_CONTENT_TYPES = /* @__PURE__ */ new Set([
|
|
146839
|
+
"application/octet-stream",
|
|
146840
|
+
"image/png",
|
|
146841
|
+
"image/jpeg",
|
|
146842
|
+
"image/webp"
|
|
146843
|
+
]), CONTENT_TYPES2 = {
|
|
146844
|
+
png: "image/png",
|
|
146845
|
+
jpg: "image/jpeg",
|
|
146846
|
+
jpeg: "image/jpeg",
|
|
146847
|
+
webp: "image/webp"
|
|
146848
|
+
};
|
|
146849
|
+
function imageExtension(bytes) {
|
|
146850
|
+
if (bytes.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10])))
|
|
146851
|
+
return "png";
|
|
146852
|
+
if (bytes.length >= 3 && bytes[0] === 255 && bytes[1] === 216 && bytes[2] === 255)
|
|
146853
|
+
return "jpg";
|
|
146854
|
+
if (bytes.length >= 12 && bytes.toString("latin1", 0, 4) === "RIFF" && bytes.toString("latin1", 8, 12) === "WEBP")
|
|
146855
|
+
return "webp";
|
|
146856
|
+
}
|
|
146857
|
+
async function serveCustomRoleAvatar(request3, response, codexhostHome, filename) {
|
|
146858
|
+
let notFound = (status = 404) => response.writeHead(status, { "content-type": "text/plain", "cache-control": "no-store" }).end(request3.method === "HEAD" ? void 0 : "not found");
|
|
146859
|
+
if (request3.method !== "GET" && request3.method !== "HEAD") {
|
|
146860
|
+
response.writeHead(405, { allow: "GET, HEAD", "cache-control": "no-store" }).end();
|
|
146861
|
+
return;
|
|
146862
|
+
}
|
|
146863
|
+
let match = CUSTOM_ROLE_AVATAR_FILE.exec(filename);
|
|
146864
|
+
if (!match?.[1]) {
|
|
146865
|
+
notFound();
|
|
146866
|
+
return;
|
|
146867
|
+
}
|
|
146868
|
+
let body;
|
|
146869
|
+
try {
|
|
146870
|
+
body = await readFile5(join33(codexhostHome, ROLE_AVATAR_DIRECTORY, filename));
|
|
146871
|
+
} catch {
|
|
146872
|
+
notFound();
|
|
146873
|
+
return;
|
|
146874
|
+
}
|
|
146875
|
+
response.writeHead(200, {
|
|
146876
|
+
"Content-Type": CONTENT_TYPES2[match[1]] ?? "application/octet-stream",
|
|
146877
|
+
"Content-Length": body.length,
|
|
146878
|
+
"Content-Security-Policy": "sandbox; default-src 'none'",
|
|
146879
|
+
"X-Content-Type-Options": "nosniff",
|
|
146880
|
+
// Filenames are random and never rewritten.
|
|
146881
|
+
"Cache-Control": "private, max-age=31536000, immutable"
|
|
146882
|
+
}).end(request3.method === "HEAD" ? void 0 : body);
|
|
146883
|
+
}
|
|
146884
|
+
function extensionMatchesDetected(filename, detected) {
|
|
146885
|
+
let lower = filename.toLowerCase();
|
|
146886
|
+
return detected === "png" ? lower.endsWith(".png") : detected === "webp" ? lower.endsWith(".webp") : lower.endsWith(".jpg") || lower.endsWith(".jpeg");
|
|
146887
|
+
}
|
|
146888
|
+
async function serveCatalogRoleAvatar(request3, response, codexhostHome, filename, options) {
|
|
146889
|
+
let notFound = (status = 404) => response.writeHead(status, { "content-type": "text/plain", "cache-control": "no-store" }).end(request3.method === "HEAD" ? void 0 : "not found");
|
|
146890
|
+
if (request3.method !== "GET" && request3.method !== "HEAD") {
|
|
146891
|
+
response.writeHead(405, { allow: "GET, HEAD", "cache-control": "no-store" }).end();
|
|
146892
|
+
return;
|
|
146893
|
+
}
|
|
146894
|
+
let match = CUSTOM_ROLE_AVATAR_FILE.exec(filename);
|
|
146895
|
+
if (!match?.[1]) {
|
|
146896
|
+
notFound();
|
|
146897
|
+
return;
|
|
146898
|
+
}
|
|
146899
|
+
let cacheDir = join33(codexhostHome, ...CATALOG_AVATAR_CACHE_SUBPATH), cachePath = join33(cacheDir, filename), body;
|
|
146900
|
+
try {
|
|
146901
|
+
let cached3 = await readFile5(cachePath), detected = imageExtension(cached3);
|
|
146902
|
+
cached3.length > 0 && cached3.length <= ROLE_AVATAR_MAX_BYTES && detected !== void 0 && extensionMatchesDetected(filename, detected) && (body = cached3);
|
|
146903
|
+
} catch {
|
|
146904
|
+
}
|
|
146905
|
+
if (body === void 0) {
|
|
146906
|
+
let fetchImpl = options?.fetchImpl ?? globalThis.fetch, baseUrls = options?.baseUrls ?? [
|
|
146907
|
+
ROLE_CATALOG_ASSET_BASE_URL,
|
|
146908
|
+
ROLE_CATALOG_ASSET_MIRROR_BASE_URL
|
|
146909
|
+
];
|
|
146910
|
+
for (let base of baseUrls)
|
|
146911
|
+
try {
|
|
146912
|
+
let upstream = await fetchImpl(
|
|
146913
|
+
`${base.replace(/\/+$/u, "")}/${encodeURIComponent(filename)}`,
|
|
146914
|
+
{
|
|
146915
|
+
method: "GET",
|
|
146916
|
+
headers: { "user-agent": "codexhost-role-catalog" },
|
|
146917
|
+
signal: AbortSignal.timeout(CATALOG_AVATAR_FETCH_TIMEOUT_MS)
|
|
146918
|
+
}
|
|
146919
|
+
);
|
|
146920
|
+
if (!upstream.ok) continue;
|
|
146921
|
+
let contentLength = Number(upstream.headers.get("content-length"));
|
|
146922
|
+
if (Number.isFinite(contentLength) && contentLength > ROLE_AVATAR_MAX_BYTES) continue;
|
|
146923
|
+
let candidate = Buffer.from(await upstream.arrayBuffer());
|
|
146924
|
+
if (candidate.length === 0 || candidate.length > ROLE_AVATAR_MAX_BYTES) continue;
|
|
146925
|
+
let detected = imageExtension(candidate);
|
|
146926
|
+
if (detected === void 0 || !extensionMatchesDetected(filename, detected)) continue;
|
|
146927
|
+
body = candidate, await mkdir7(cacheDir, { recursive: !0 });
|
|
146928
|
+
let temp = join33(cacheDir, `.${filename}.${randomUUID25()}.tmp`);
|
|
146929
|
+
try {
|
|
146930
|
+
await writeFile5(temp, candidate, { flag: "wx" }), await rename5(temp, cachePath);
|
|
146931
|
+
} catch {
|
|
146932
|
+
await rm7(temp, { force: !0 }).catch(() => {
|
|
146933
|
+
});
|
|
146934
|
+
}
|
|
146935
|
+
break;
|
|
146936
|
+
} catch {
|
|
146937
|
+
}
|
|
146938
|
+
}
|
|
146939
|
+
if (body === void 0) {
|
|
146940
|
+
notFound();
|
|
146941
|
+
return;
|
|
146942
|
+
}
|
|
146943
|
+
response.writeHead(200, {
|
|
146944
|
+
"Content-Type": CONTENT_TYPES2[match[1]] ?? "application/octet-stream",
|
|
146945
|
+
"Content-Length": body.length,
|
|
146946
|
+
"Content-Security-Policy": "sandbox; default-src 'none'",
|
|
146947
|
+
"X-Content-Type-Options": "nosniff",
|
|
146948
|
+
"Cache-Control": "private, max-age=86400"
|
|
146949
|
+
}).end(request3.method === "HEAD" ? void 0 : body);
|
|
146950
|
+
}
|
|
146951
|
+
async function serveRoleAvatarUpload(request3, response, codexhostHome) {
|
|
146952
|
+
let send = (status, body) => {
|
|
146953
|
+
response.headersSent || response.writeHead(status, {
|
|
146954
|
+
"content-type": "application/json; charset=utf-8",
|
|
146955
|
+
"cache-control": "no-store"
|
|
146956
|
+
}).end(JSON.stringify(body));
|
|
146957
|
+
}, tooLarge = () => send(413, { error: "Avatar images must be at most 2 MiB." });
|
|
146958
|
+
try {
|
|
146959
|
+
let contentType = request3.headers["content-type"]?.split(";", 1)[0]?.trim().toLowerCase();
|
|
146960
|
+
if (!contentType || !UPLOAD_CONTENT_TYPES.has(contentType)) {
|
|
146961
|
+
send(415, { error: "Avatar must be a PNG, JPEG, or WebP image." });
|
|
146962
|
+
return;
|
|
146963
|
+
}
|
|
146964
|
+
if (Number(request3.headers["content-length"]) > ROLE_AVATAR_MAX_BYTES) {
|
|
146965
|
+
tooLarge();
|
|
146966
|
+
return;
|
|
146967
|
+
}
|
|
146968
|
+
let chunks = [], size = 0;
|
|
146969
|
+
for await (let chunk of request3.iterator({ destroyOnReturn: !1 })) {
|
|
146970
|
+
if (size += chunk.length, size > ROLE_AVATAR_MAX_BYTES) {
|
|
146971
|
+
tooLarge();
|
|
146972
|
+
return;
|
|
146973
|
+
}
|
|
146974
|
+
chunks.push(chunk);
|
|
146975
|
+
}
|
|
146976
|
+
let body = Buffer.concat(chunks);
|
|
146977
|
+
if (body.length === 0) {
|
|
146978
|
+
send(400, { error: "Avatar image is empty." });
|
|
146979
|
+
return;
|
|
146980
|
+
}
|
|
146981
|
+
let extension3 = imageExtension(body);
|
|
146982
|
+
if (!extension3) {
|
|
146983
|
+
send(415, { error: "Avatar must be a PNG, JPEG, or WebP image." });
|
|
146984
|
+
return;
|
|
146985
|
+
}
|
|
146986
|
+
let directory = join33(codexhostHome, ROLE_AVATAR_DIRECTORY), filename = `${randomUUID25()}.${extension3}`, temporary = join33(directory, `.${filename}.${process.pid}.tmp`);
|
|
146987
|
+
await mkdir7(directory, { recursive: !0 });
|
|
146988
|
+
try {
|
|
146989
|
+
await writeFile5(temporary, body, { flag: "wx" }), await rename5(temporary, join33(directory, filename));
|
|
146990
|
+
} catch (error62) {
|
|
146991
|
+
throw await rm7(temporary, { force: !0 }).catch(() => {
|
|
146992
|
+
}), error62;
|
|
146993
|
+
}
|
|
146994
|
+
send(200, {
|
|
146995
|
+
avatar: `custom:${filename}`,
|
|
146996
|
+
url: `/role-avatars/custom/${filename}`
|
|
146997
|
+
});
|
|
146998
|
+
} catch (error62) {
|
|
146999
|
+
console.error("[role-avatars] upload failed", error62), send(500, { error: "Avatar could not be saved." });
|
|
147000
|
+
} finally {
|
|
147001
|
+
request3.resume();
|
|
147002
|
+
}
|
|
147003
|
+
}
|
|
147004
|
+
|
|
147005
|
+
// packages/web-server/src/voice-http.ts
|
|
147006
|
+
import { randomUUID as randomUUID26 } from "node:crypto";
|
|
147007
|
+
import { mkdir as mkdir8, open as open12, rm as rm8 } from "node:fs/promises";
|
|
147008
|
+
import { join as join34 } from "node:path";
|
|
146027
147009
|
function registerVoiceStatus(rpc2, host) {
|
|
146028
147010
|
rpc2.register("codexhost/voice/status", async () => {
|
|
146029
147011
|
try {
|
|
@@ -146056,8 +147038,8 @@ async function serveVoiceTranscription(host, dataRoot2, request3, response) {
|
|
|
146056
147038
|
send(413, voiceFailure("audio-too-large"));
|
|
146057
147039
|
return;
|
|
146058
147040
|
}
|
|
146059
|
-
let directory =
|
|
146060
|
-
await
|
|
147041
|
+
let directory = join34(dataRoot2, "voice");
|
|
147042
|
+
await mkdir8(directory, { recursive: !0, mode: 448 }), path7 = join34(directory, randomUUID26());
|
|
146061
147043
|
let file3 = await open12(path7, "wx", 384), size = 0;
|
|
146062
147044
|
try {
|
|
146063
147045
|
for await (let chunk of request3.iterator({ destroyOnReturn: !1 })) {
|
|
@@ -146086,63 +147068,63 @@ async function serveVoiceTranscription(host, dataRoot2, request3, response) {
|
|
|
146086
147068
|
} catch {
|
|
146087
147069
|
send(200, voiceFailure("network"));
|
|
146088
147070
|
} finally {
|
|
146089
|
-
path7 && await
|
|
147071
|
+
path7 && await rm8(path7, { force: !0 }), request3.resume();
|
|
146090
147072
|
}
|
|
146091
147073
|
}
|
|
146092
147074
|
|
|
146093
147075
|
// packages/web-server/src/data-paths.ts
|
|
146094
147076
|
import { homedir as homedir10 } from "node:os";
|
|
146095
|
-
import { join as
|
|
147077
|
+
import { join as join35, resolve as resolve24 } from "node:path";
|
|
146096
147078
|
function defaultWebDataDirectory(hostDataDirectory) {
|
|
146097
|
-
return
|
|
147079
|
+
return join35(resolve24(hostDataDirectory ?? join35(homedir10(), ".codexhost")), "web");
|
|
146098
147080
|
}
|
|
146099
147081
|
|
|
146100
147082
|
// packages/web-server/src/packaged-host.ts
|
|
146101
147083
|
import { createHash as createHash17 } from "node:crypto";
|
|
146102
|
-
import { cp, mkdir as
|
|
146103
|
-
import { join as
|
|
147084
|
+
import { cp, mkdir as mkdir9, mkdtemp as mkdtemp3, readFile as readFile6, readdir as readdir10, rename as rename6, rm as rm9, stat as stat14 } from "node:fs/promises";
|
|
147085
|
+
import { join as join36 } from "node:path";
|
|
146104
147086
|
async function hashDirectory(root, hash4, relative14 = "") {
|
|
146105
|
-
for (let name2 of (await readdir10(
|
|
146106
|
-
let file3 =
|
|
146107
|
-
hash4.update(JSON.stringify([file3, metadata.mode & 511, metadata.isDirectory()])), metadata.isDirectory() ? await hashDirectory(root, hash4, file3) : (hash4.update(String(metadata.size) + ":"), hash4.update(await
|
|
147087
|
+
for (let name2 of (await readdir10(join36(root, relative14))).sort()) {
|
|
147088
|
+
let file3 = join36(relative14, name2), metadata = await stat14(join36(root, file3));
|
|
147089
|
+
hash4.update(JSON.stringify([file3, metadata.mode & 511, metadata.isDirectory()])), metadata.isDirectory() ? await hashDirectory(root, hash4, file3) : (hash4.update(String(metadata.size) + ":"), hash4.update(await readFile6(join36(root, file3))));
|
|
146108
147090
|
}
|
|
146109
147091
|
}
|
|
146110
147092
|
async function snapshotPackagedHost(distribution, data2) {
|
|
146111
|
-
let builds =
|
|
146112
|
-
await
|
|
146113
|
-
let staging = await mkdtemp3(
|
|
147093
|
+
let builds = join36(data2, "host-builds");
|
|
147094
|
+
await mkdir9(builds, { recursive: !0, mode: 448 });
|
|
147095
|
+
let staging = await mkdtemp3(join36(builds, ".preparing-"));
|
|
146114
147096
|
try {
|
|
146115
|
-
await
|
|
147097
|
+
await mkdir9(join36(staging, "app")), await cp(join36(distribution, "app/host-runtime.mjs"), join36(staging, "app/host-runtime.mjs"));
|
|
146116
147098
|
for (let directory of ["native", "adapters"])
|
|
146117
|
-
await cp(
|
|
147099
|
+
await cp(join36(distribution, directory), join36(staging, directory), {
|
|
146118
147100
|
recursive: !0,
|
|
146119
147101
|
dereference: !0
|
|
146120
147102
|
});
|
|
146121
147103
|
let hash4 = createHash17("sha256");
|
|
146122
147104
|
await hashDirectory(staging, hash4);
|
|
146123
|
-
let destination =
|
|
147105
|
+
let destination = join36(builds, hash4.digest("hex"));
|
|
146124
147106
|
try {
|
|
146125
|
-
await
|
|
147107
|
+
await rename6(staging, destination);
|
|
146126
147108
|
} catch (error62) {
|
|
146127
147109
|
if (!(await stat14(destination).catch(() => null))?.isDirectory()) throw error62;
|
|
146128
147110
|
}
|
|
146129
147111
|
return destination;
|
|
146130
147112
|
} finally {
|
|
146131
|
-
await
|
|
147113
|
+
await rm9(staging, { recursive: !0, force: !0 });
|
|
146132
147114
|
}
|
|
146133
147115
|
}
|
|
146134
147116
|
|
|
146135
147117
|
// packages/web-server/src/main.ts
|
|
146136
|
-
var RELEASE_WEB = !0, DISTRIBUTION_ROOT = resolve25(import.meta.dirname, ".."), PACKED_WEB =
|
|
146137
|
-
"0.
|
|
146138
|
-
[
|
|
147118
|
+
var RELEASE_WEB = !0, DISTRIBUTION_ROOT = resolve25(import.meta.dirname, ".."), PACKED_WEB = join37(DISTRIBUTION_ROOT, "web"), PACKED = existsSync16(join37(PACKED_WEB, "plugins.json")), REPO_ROOT = resolve25(import.meta.dirname, "../../.."), SERVER_VERSION = resolveServerVersion(
|
|
147119
|
+
"0.33.0",
|
|
147120
|
+
[join37(DISTRIBUTION_ROOT, "package.json"), join37(REPO_ROOT, "package.json")]
|
|
146139
147121
|
);
|
|
146140
147122
|
if (PACKED) {
|
|
146141
|
-
let runner =
|
|
147123
|
+
let runner = join37(import.meta.dirname, "subprocess-runner.mjs");
|
|
146142
147124
|
existsSync16(runner) && (process.env.CODEXHOST_SUBPROCESS_RUNNER ??= runner);
|
|
146143
147125
|
}
|
|
146144
147126
|
function defaultAdapterRoots() {
|
|
146145
|
-
return PACKED ?
|
|
147127
|
+
return PACKED ? join37(DISTRIBUTION_ROOT, "adapters") : resolve25(REPO_ROOT, "packages/host-runtime/dist/plugins");
|
|
146146
147128
|
}
|
|
146147
147129
|
var developmentOptions = {
|
|
146148
147130
|
"ch-cdp": { type: "string" },
|
|
@@ -146172,7 +147154,7 @@ var developmentOptions = {
|
|
|
146172
147154
|
harness: { type: "string", default: process.env.CODEXHOST_HARNESSES },
|
|
146173
147155
|
workspace: {
|
|
146174
147156
|
type: "string",
|
|
146175
|
-
default: process.env.CODEXHOST_DEFAULT_WORKSPACE ??
|
|
147157
|
+
default: process.env.CODEXHOST_DEFAULT_WORKSPACE ?? join37(homedir11(), "codexhost-workspace")
|
|
146176
147158
|
},
|
|
146177
147159
|
token: { type: "string", default: process.env.CODEXHOST_WEB_TOKEN },
|
|
146178
147160
|
"trusted-proxy": { type: "string" },
|
|
@@ -146199,9 +147181,9 @@ if (values["save-service-options"])
|
|
|
146199
147181
|
var serviceOptions = readServiceOptions(data), background = values.background ? serviceOptions : void 0;
|
|
146200
147182
|
background ? (values.host = background.host, values.port = String(background.port)) : (values.host ??= process.env.CODEXHOST_WEB_HOST ?? "127.0.0.1", values.port ??= process.env.CODEXHOST_WEB_PORT ?? "4400");
|
|
146201
147183
|
var publicUrl = background ? background.publicUrl : values["public-url"] ?? process.env.CODEXHOST_WEB_PUBLIC_URL, trustedProxies = background ? background.trustedProxies : values["trusted-proxy"] ?? process.env.CODEXHOST_WEB_TRUSTED_PROXIES, publicUrls = publicUrl === void 0 ? [] : [{ kind: "public", url: publicAccessUrl(publicUrl) }], trust = new RequestTrust(trustedProxies), accessTokens = values["no-auth"] === !0 ? void 0 : new AccessTokenStore(data, values.token === void 0 ? {} : { token: values.token }), connections = new CredentialConnections(), auth = accessTokens && new AccessAuth(accessTokens, trust, connections), rpc = new RpcRegistry(), streams = new StreamRegistry(), events = new EventHub(homedir11()), displayDirectory = resolve25(
|
|
146202
|
-
values["ch-data"] ?? (values["ch-control-directory"] ? dirname19(resolve25(values["ch-control-directory"])) :
|
|
147184
|
+
values["ch-data"] ?? (values["ch-control-directory"] ? dirname19(resolve25(values["ch-control-directory"])) : join37(homedir11(), ".codexhost"))
|
|
146203
147185
|
), displayEntries = () => displaySettings.entries(), enabledHarnesses = values.harness === void 0 || values.harness === "all" ? void 0 : new Set(values.harness.split(",")), workspaces = new Workspaces(data, resolve25(values.workspace), !0), packagedHost = PACKED && !values["ch-cdp"] && !values["ch-host-runtime"] ? await snapshotPackagedHost(DISTRIBUTION_ROOT, displayDirectory) : DISTRIBUTION_ROOT, pluginSource = resolve25(values["ch-plugins"] ?? values.adapters ?? defaultAdapterRoots()), launcher = resolve25(
|
|
146204
|
-
values["ch-launcher"] ?? (PACKED ?
|
|
147186
|
+
values["ch-launcher"] ?? (PACKED ? join37(packagedHost, "native", process.platform === "win32" ? "codexhost.exe" : "codexhost") : join37(
|
|
146205
147187
|
REPO_ROOT,
|
|
146206
147188
|
"target/debug",
|
|
146207
147189
|
process.platform === "win32" ? "codexhost.exe" : "codexhost"
|
|
@@ -146211,16 +147193,16 @@ var publicUrl = background ? background.publicUrl : values["public-url"] ?? proc
|
|
|
146211
147193
|
launcher,
|
|
146212
147194
|
...values["ch-node"] ? { node: resolve25(values["ch-node"]) } : {},
|
|
146213
147195
|
runtime: resolve25(
|
|
146214
|
-
values["ch-host-runtime"] ?? (PACKED ?
|
|
147196
|
+
values["ch-host-runtime"] ?? (PACKED ? join37(packagedHost, "app/host-runtime.mjs") : join37(REPO_ROOT, "packages/host-runtime/dist/main.js"))
|
|
146215
147197
|
),
|
|
146216
147198
|
dataDirectory: resolve25(
|
|
146217
|
-
values["ch-data"] ?? (values["ch-control-directory"] ? dirname19(resolve25(values["ch-control-directory"])) :
|
|
147199
|
+
values["ch-data"] ?? (values["ch-control-directory"] ? dirname19(resolve25(values["ch-control-directory"])) : join37(homedir11(), ".codexhost"))
|
|
146218
147200
|
),
|
|
146219
|
-
bundledPlugins: PACKED && pluginSource === resolve25(DISTRIBUTION_ROOT, "adapters") ?
|
|
147201
|
+
bundledPlugins: PACKED && pluginSource === resolve25(DISTRIBUTION_ROOT, "adapters") ? join37(packagedHost, "adapters") : pluginSource,
|
|
146220
147202
|
...values["ch-codex-home"] ? { codexHome: resolve25(values["ch-codex-home"]) } : {},
|
|
146221
147203
|
environment: npmEntrypoint
|
|
146222
147204
|
},
|
|
146223
|
-
...values["ch-data"] && !values["ch-control-directory"] ? { directory:
|
|
147205
|
+
...values["ch-data"] && !values["ch-control-directory"] ? { directory: join37(resolve25(values["ch-data"]), "client-hosts") } : {},
|
|
146224
147206
|
...values["ch-cdp"] ? { cdp: values["ch-cdp"] } : {},
|
|
146225
147207
|
...values["ch-control-directory"] ? { directory: values["ch-control-directory"] } : {}
|
|
146226
147208
|
}), displaySettings = new WebHarnessDisplaySettings(
|
|
@@ -146245,7 +147227,7 @@ var publicUrl = background ? background.publicUrl : values["public-url"] ?? proc
|
|
|
146245
147227
|
...RELEASE_WEB ? {
|
|
146246
147228
|
ensureOfficeEngine: createOfficeEngine(
|
|
146247
147229
|
dataRoot,
|
|
146248
|
-
JSON.parse(readFileSync18(
|
|
147230
|
+
JSON.parse(readFileSync18(join37(import.meta.dirname, "office-engines.json"), "utf8"))
|
|
146249
147231
|
)
|
|
146250
147232
|
} : {}
|
|
146251
147233
|
}).catch((error62) => {
|
|
@@ -146295,7 +147277,7 @@ if (!values["safe-mode"])
|
|
|
146295
147277
|
builtins: builtInAssets.clientSources(),
|
|
146296
147278
|
address: () => ({ host: values.host, port: listeningPort }),
|
|
146297
147279
|
reserved: [
|
|
146298
|
-
...["/api", "/plugins", "/assets", "/harness-icons"].map((path7) => ({
|
|
147280
|
+
...["/api", "/plugins", "/assets", "/harness-icons", "/role-avatars"].map((path7) => ({
|
|
146299
147281
|
kind: "prefix",
|
|
146300
147282
|
path: path7
|
|
146301
147283
|
})),
|
|
@@ -146339,7 +147321,7 @@ workspaces.register(
|
|
|
146339
147321
|
sessions.register(rpc, streams);
|
|
146340
147322
|
sessions.registerCommands(rpc);
|
|
146341
147323
|
sessions.registerImport(rpc);
|
|
146342
|
-
var peerEpoch = chHost.realtime ? void 0 :
|
|
147324
|
+
var peerEpoch = chHost.realtime ? void 0 : randomUUID27(), peerEpochWaiters = /* @__PURE__ */ new Set(), stopEpoch = chHost.realtime?.subscribe((event) => {
|
|
146343
147325
|
if (event.type === "hello") {
|
|
146344
147326
|
peerEpoch = event.cursor.epoch;
|
|
146345
147327
|
for (let notify of peerEpochWaiters) notify();
|
|
@@ -146422,6 +147404,13 @@ sessions.setRemoteFileSearch(
|
|
|
146422
147404
|
);
|
|
146423
147405
|
streams.setFallback((endpoint, args, sink) => remoteWorkspaceFiles.handleStream(endpoint, args, sink) ? !0 : dsh ? dsh.stream(endpoint, args, sink) : !1);
|
|
146424
147406
|
preferences.register(rpc);
|
|
147407
|
+
new WebRoles(chHost, events).register(rpc);
|
|
147408
|
+
var groups = new WebGroups(chHost, events, {
|
|
147409
|
+
peers: () => peerManager.groupPeers(),
|
|
147410
|
+
peer: (hostId2) => peerManager.groupPeer(hostId2),
|
|
147411
|
+
subscribe: (listener) => peerManager.onGroupChange(listener)
|
|
147412
|
+
});
|
|
147413
|
+
groups.register(rpc);
|
|
146425
147414
|
displaySettings.register(rpc);
|
|
146426
147415
|
settings.register(rpc);
|
|
146427
147416
|
push.register(rpc);
|
|
@@ -146537,8 +147526,8 @@ var server = createWebServer((request3, response) => {
|
|
|
146537
147526
|
);
|
|
146538
147527
|
return;
|
|
146539
147528
|
}
|
|
146540
|
-
if (pathname === "/api/workspace-file/video" && (request3.method === "GET" || request3.method === "HEAD")) {
|
|
146541
|
-
await
|
|
147529
|
+
if ((pathname === "/api/workspace-file/media" || pathname === "/api/workspace-file/video") && (request3.method === "GET" || request3.method === "HEAD")) {
|
|
147530
|
+
await serveWorkspaceMedia(
|
|
146542
147531
|
request3,
|
|
146543
147532
|
response,
|
|
146544
147533
|
new URL(url2, "http://localhost"),
|
|
@@ -146685,6 +147674,10 @@ var server = createWebServer((request3, response) => {
|
|
|
146685
147674
|
await desktopScreenshots.serve(request3, response);
|
|
146686
147675
|
return;
|
|
146687
147676
|
}
|
|
147677
|
+
if (pathname === DESKTOP_SCREENSHOT_DISPLAYS_PATH) {
|
|
147678
|
+
await desktopScreenshots.serveDisplays(request3, response);
|
|
147679
|
+
return;
|
|
147680
|
+
}
|
|
146688
147681
|
if (pathname === "/api/voice/transcribe") {
|
|
146689
147682
|
await serveVoiceTranscription(chHost, dataRoot, request3, response);
|
|
146690
147683
|
return;
|
|
@@ -146699,6 +147692,14 @@ var server = createWebServer((request3, response) => {
|
|
|
146699
147692
|
);
|
|
146700
147693
|
return;
|
|
146701
147694
|
}
|
|
147695
|
+
if (pathname === "/api/codexhost/roles/avatar") {
|
|
147696
|
+
await serveRoleAvatarUpload(request3, response, displayDirectory);
|
|
147697
|
+
return;
|
|
147698
|
+
}
|
|
147699
|
+
if (pathname === GROUP_ATTACHMENT_UPLOAD_PATH) {
|
|
147700
|
+
await serveGroupAttachmentUpload(files, request3, response);
|
|
147701
|
+
return;
|
|
147702
|
+
}
|
|
146702
147703
|
if (pathname === "/api/workspace-file/download-ticket") {
|
|
146703
147704
|
let body2 = await readBody(request3, response);
|
|
146704
147705
|
if (body2 === void 0) return;
|
|
@@ -146785,6 +147786,40 @@ var server = createWebServer((request3, response) => {
|
|
|
146785
147786
|
);
|
|
146786
147787
|
return;
|
|
146787
147788
|
}
|
|
147789
|
+
if (request3.method === "GET" && pathname === GROUP_ATTACHMENT_IMAGE_PATH) {
|
|
147790
|
+
serveGroupAttachmentImage(images, request3, response);
|
|
147791
|
+
return;
|
|
147792
|
+
}
|
|
147793
|
+
if (pathname.startsWith("/role-avatars/")) {
|
|
147794
|
+
if (pathname.startsWith("/role-avatars/custom/")) {
|
|
147795
|
+
let filename;
|
|
147796
|
+
try {
|
|
147797
|
+
filename = decodeURIComponent(pathname.slice(21));
|
|
147798
|
+
} catch {
|
|
147799
|
+
filename = void 0;
|
|
147800
|
+
}
|
|
147801
|
+
if (filename !== void 0) {
|
|
147802
|
+
await serveCustomRoleAvatar(request3, response, displayDirectory, filename);
|
|
147803
|
+
return;
|
|
147804
|
+
}
|
|
147805
|
+
} else if (pathname.startsWith("/role-avatars/catalog/")) {
|
|
147806
|
+
let filename;
|
|
147807
|
+
try {
|
|
147808
|
+
filename = decodeURIComponent(pathname.slice(22));
|
|
147809
|
+
} catch {
|
|
147810
|
+
filename = void 0;
|
|
147811
|
+
}
|
|
147812
|
+
if (filename !== void 0) {
|
|
147813
|
+
await serveCatalogRoleAvatar(request3, response, displayDirectory, filename);
|
|
147814
|
+
return;
|
|
147815
|
+
}
|
|
147816
|
+
} else if (pathname.startsWith("/role-avatars/builtin/")) {
|
|
147817
|
+
await sendAsset(request3, response, assets.dist(pathname), IMMUTABLE_CACHE);
|
|
147818
|
+
return;
|
|
147819
|
+
}
|
|
147820
|
+
response.writeHead(404, { "cache-control": "no-store" }).end();
|
|
147821
|
+
return;
|
|
147822
|
+
}
|
|
146788
147823
|
if (pathname.startsWith("/harness-icons/peer/")) {
|
|
146789
147824
|
let asset = await resolvePeerHarnessIcon(peerManager, pathname);
|
|
146790
147825
|
if (!asset) {
|
|
@@ -146838,7 +147873,7 @@ var server = createWebServer((request3, response) => {
|
|
|
146838
147873
|
registerRelayRpc(rpc, accessTokens, relay);
|
|
146839
147874
|
serviceOptions.relayEnabled && relay.start();
|
|
146840
147875
|
var wss = createBrowserWebSocketServer(), sidebarBrowser = new SidebarBrowser({
|
|
146841
|
-
profileDirectory:
|
|
147876
|
+
profileDirectory: join37(dataRoot, "sidebar-browser"),
|
|
146842
147877
|
...auth === void 0 ? {} : { direct: new SidebarBrowserDirect(data, connections, directIceServers) }
|
|
146843
147878
|
});
|
|
146844
147879
|
server.on("upgrade", (request3, socket, head) => {
|
|
@@ -146911,7 +147946,7 @@ var shuttingDown;
|
|
|
146911
147946
|
function shutdown(exitCode = 0) {
|
|
146912
147947
|
return shuttingDown ??= (async () => {
|
|
146913
147948
|
try {
|
|
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();
|
|
147949
|
+
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(), groups.close(), displaySettings.close();
|
|
146915
147950
|
} catch (error62) {
|
|
146916
147951
|
console.error("[web] shutdown failed", error62), exitCode ||= 1;
|
|
146917
147952
|
} finally {
|