@codexhost/cli-win32-x64 0.32.0 → 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 +589 -30
- package/app/console-web.js +558 -30
- package/app/desktop-controller.mjs +883 -150
- package/app/host-runtime.mjs +8165 -3548
- package/app/plugins/antigravity/plugin.mjs +493 -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 +1106 -193
- package/app/plugins/codebuddy/plugin.mjs +465 -27
- package/app/plugins/codex-usage/plugin.mjs +367 -7
- package/app/plugins/copilot/assets/icon.svg +1 -1
- package/app/plugins/copilot/manifest.json +1 -1
- package/app/plugins/copilot/plugin.mjs +369 -9
- package/app/plugins/cursor-cli/plugin.mjs +367 -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 +806 -148
- package/app/plugins/devin/assets/icon.svg +1 -1
- package/app/plugins/devin/manifest.json +1 -1
- package/app/plugins/devin/plugin.mjs +369 -8
- package/app/plugins/grok/plugin.mjs +367 -7
- package/app/plugins/hermes/plugin.mjs +367 -7
- package/app/plugins/kimi-code/plugin.mjs +367 -7
- package/app/plugins/kiro-cli/plugin.mjs +367 -7
- package/app/plugins/omp/assets/icon.svg +1 -1
- package/app/plugins/omp/plugin.mjs +393 -7
- package/app/plugins/opencode/plugin.mjs +371 -8
- package/app/plugins/pi/assets/icon.svg +1 -1
- package/app/plugins/pi/manifest.json +1 -1
- package/app/plugins/pi/plugin.mjs +395 -9
- package/app/plugins/qoder/assets/icon.svg +1 -1
- package/app/plugins/qoder/plugin.mjs +393 -7
- package/app/plugins/qoder-cn/assets/icon.svg +1 -1
- package/app/plugins/qoder-cn/plugin.mjs +393 -7
- package/app/plugins/qwen-code/assets/icon.svg +1 -1
- package/app/plugins/qwen-code/plugin.mjs +396 -7
- package/app/plugins/workbuddy/plugin.mjs +465 -27
- package/app/plugins/zcode/plugin.mjs +387 -14
- package/app/renderer-extension.js +581 -41
- package/app/web/assets/{abnfDiagram-XWFEHMT6-CnJyN70L.js → abnfDiagram-XWFEHMT6-VnfRaHM6.js} +1 -1
- package/app/web/assets/{architectureDiagram-CSQXQB3N-DH0ITYVE.js → architectureDiagram-CSQXQB3N-BA1ehtvi.js} +1 -1
- package/app/web/assets/{blockDiagram-BEDRHYPZ-WL3ZKoKg.js → blockDiagram-BEDRHYPZ-31BZSfd4.js} +1 -1
- package/app/web/assets/{c4Diagram-M2UUVUY5-XwSPKj5H.js → c4Diagram-M2UUVUY5-CNzGWc5k.js} +1 -1
- package/app/web/assets/{chunk-2Q5K7J3B-CKEzexjg.js → chunk-2Q5K7J3B-ahAIR-NM.js} +1 -1
- package/app/web/assets/{chunk-3GCGMST5-BdEgLpab.js → chunk-3GCGMST5-BIV5YeRJ.js} +1 -1
- package/app/web/assets/{chunk-5VM5RSS4-DyxL5-Ts.js → chunk-5VM5RSS4-CluTMPJG.js} +1 -1
- package/app/web/assets/{chunk-7U7NFRK5-FXLb4tYa.js → chunk-7U7NFRK5-4NIQuFbE.js} +1 -1
- package/app/web/assets/{chunk-CNRTWJTD-DcdC1OYr.js → chunk-CNRTWJTD-_0bEfGn3.js} +1 -1
- package/app/web/assets/{chunk-D5HYT7QG-BOz9vBX9.js → chunk-D5HYT7QG-_kTC6f8F.js} +1 -1
- package/app/web/assets/{chunk-EBZ3SEQC-Dmc_Z53x.js → chunk-EBZ3SEQC-CykaYOrL.js} +2 -2
- package/app/web/assets/{chunk-JWPE2WC7-CrFwSwYi.js → chunk-JWPE2WC7-3vVOQ_py.js} +1 -1
- package/app/web/assets/{chunk-KTR4FSNJ-BY3AzFaI.js → chunk-KTR4FSNJ-aVg5vgrm.js} +1 -1
- package/app/web/assets/{chunk-XXDRQBXY-CHgNy82n.js → chunk-XXDRQBXY-_gVwGeSp.js} +1 -1
- package/app/web/assets/{classDiagram-v2-KXABOMEV-ClM3-y5Z.js → classDiagram-v2-KXABOMEV-fI1LfeBf.js} +1 -1
- package/app/web/assets/{cose-bilkent-JH36ORCC-I7nd8GgO.js → cose-bilkent-JH36ORCC-DFXMlWov.js} +1 -1
- package/app/web/assets/{cynefin-EF2NZ3EQ-DzsXmyBH.js → cynefin-EF2NZ3EQ-lZy7X6FO.js} +1 -1
- package/app/web/assets/{cynefinDiagram-NJNITYFG-DLHq6igy.js → cynefinDiagram-NJNITYFG-N4DwFSW1.js} +1 -1
- package/app/web/assets/{dagre-KIHZ2IZ3-BK991Mno.js → dagre-KIHZ2IZ3-B7-8baTH.js} +1 -1
- package/app/web/assets/{diagram-7YQZDPLS-C4qiWdQU.js → diagram-7YQZDPLS-DLfjiBXV.js} +1 -1
- package/app/web/assets/{diagram-QBROCOUO-C_ZyBohC.js → diagram-QBROCOUO-CQnRzSTi.js} +1 -1
- package/app/web/assets/{diagram-RJJCUUZO-C5Aezm94.js → diagram-RJJCUUZO-DPnxazRT.js} +1 -1
- package/app/web/assets/{diagram-WERXNKYE-Ckc_umlF.js → diagram-WERXNKYE-BBuEFRvD.js} +1 -1
- package/app/web/assets/{diagram-YHHI257C-BHjReoZZ.js → diagram-YHHI257C-BQ92JNJs.js} +1 -1
- package/app/web/assets/{diagram-YR4HJLHV-DVTGi_y9.js → diagram-YR4HJLHV-Ce6BQO3J.js} +1 -1
- package/app/web/assets/{ebnfDiagram-N527522P-getuz1AR.js → ebnfDiagram-N527522P-DYknE2Jy.js} +1 -1
- package/app/web/assets/{elk-O5DQBFGD-C7mhTIuK.js → elk-O5DQBFGD-4S6_JJFF.js} +1 -1
- package/app/web/assets/{erDiagram-K3K3BIDK-sV-HZvUV.js → erDiagram-K3K3BIDK-DRtF7JVQ.js} +1 -1
- package/app/web/assets/{flowDiagram-Z6JWZHQI-D0L4wXUs.js → flowDiagram-Z6JWZHQI-7Ho8CyR9.js} +1 -1
- package/app/web/assets/{ganttDiagram-3PRQTZWP-BNt9Bjjo.js → ganttDiagram-3PRQTZWP-CW8Ig5y4.js} +1 -1
- package/app/web/assets/{gitGraphDiagram-VXDFKS5L-BABZzhHw.js → gitGraphDiagram-VXDFKS5L-CzS8Xg2D.js} +1 -1
- package/app/web/assets/{grid-E2QIVN74-DLe2FQ_d.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-BKDuUqcr.js → infoDiagram-EZ3ZOAHP-BZgN6qlY.js} +1 -1
- package/app/web/assets/{ishikawaDiagram-S3EKX5GW-C75EGghg.js → ishikawaDiagram-S3EKX5GW-BH9YHc-1.js} +1 -1
- package/app/web/assets/{journeyDiagram-POQNLL5X-q7Obruqa.js → journeyDiagram-POQNLL5X-D50KYOLe.js} +1 -1
- package/app/web/assets/{kanban-definition-BH5XI6FM-CzAqhFED.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-Bysx44LR.js → mermaid.core-o2Qjrppc.js} +5 -5
- package/app/web/assets/{mindmap-definition-WVAN44T4-Ds5rXTrF.js → mindmap-definition-WVAN44T4-B_bEbpAH.js} +1 -1
- package/app/web/assets/{pegDiagram-D4NLKWP3-hmdERwtT.js → pegDiagram-D4NLKWP3-VecAHoyw.js} +1 -1
- package/app/web/assets/{pieDiagram-36ENHN4W-DfTnyG8D.js → pieDiagram-36ENHN4W-o3ei2T-6.js} +1 -1
- package/app/web/assets/{quadrantDiagram-ZQUDMS73-CreQWjZQ.js → quadrantDiagram-ZQUDMS73-DHndOAcn.js} +1 -1
- package/app/web/assets/{railroadDiagram-JIZHGYPL-Bhc_eO9G.js → railroadDiagram-JIZHGYPL-DRd_lfii.js} +1 -1
- package/app/web/assets/{render-VIF2ZAQL-BS1Zgk8K.js → render-VIF2ZAQL-awM3hUqB.js} +2 -2
- package/app/web/assets/{requirementDiagram-AXW2TVFA-Dlp7d6QT.js → requirementDiagram-AXW2TVFA-Ce1ePsOe.js} +1 -1
- package/app/web/assets/{sankeyDiagram-FBCJTAIF-DGBchL30.js → sankeyDiagram-FBCJTAIF-cP-LtgW-.js} +1 -1
- package/app/web/assets/{sequenceDiagram-3LA2ROMG-DauFg5_R.js → sequenceDiagram-3LA2ROMG-C3JStTuW.js} +1 -1
- package/app/web/assets/{sizeCapture-2Q2CQKSF-DR-zy7an.js → sizeCapture-2Q2CQKSF-Dyyelr9K.js} +1 -1
- package/app/web/assets/{stateDiagram-v2-ATKHQDJO-BSRBSGUi.js → stateDiagram-v2-ATKHQDJO-DkYRBVTd.js} +1 -1
- package/app/web/assets/{swimlanes-YQL5WMAO-BwzOr5Dv.js → swimlanes-YQL5WMAO-B2FwJU5_.js} +1 -1
- package/app/web/assets/swimlanesDiagram-UCCPES4V-BkMsxCPb.js +8 -0
- package/app/web/assets/{timeline-definition-7Z437IG3-BoZ-mNKc.js → timeline-definition-7Z437IG3-Di-qRIIi.js} +1 -1
- package/app/web/assets/{usecaseDiagram-RDK6N6HP-DikhgH2m.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-DY_oIxwl.js → vennDiagram-SHRQU5PJ-BEv8jpfv.js} +1 -1
- package/app/web/assets/{wardleyDiagram-F3OXNVQS-DrRIiB_M.js → wardleyDiagram-F3OXNVQS-7irksA0b.js} +1 -1
- package/app/web/assets/{xychartDiagram-GDYJKCDI-CzSPgHV7.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 +66 -66
- 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-attachment/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +75 -75
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +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 +1324 -252
- 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-BLmkBEoq.js +0 -205
- package/app/web/assets/index-Dwdnvinl.css +0 -1
- package/app/web/assets/swimlanesDiagram-UCCPES4V-CNV63-us.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,19 +72930,20 @@ 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
|
|
|
72842
72944
|
// packages/shared-contracts/dist/host-extension-management.js
|
|
72843
72945
|
var HOST_EXTENSION_ZIP_MAX_BYTES = DESKTOP_EXTENSION_ZIP_MAX_BYTES;
|
|
72844
|
-
var HOST_EXTENSION_UPLOAD_PATH = "/api/extensions/upload", HOST_EXTENSION_CATALOG_ICON_PATH = "/api/extensions/catalog-icon", hostExtensionRevisionSchema = external_exports.int().nonnegative(), hostExtensionConfigurationSchema = external_exports.strictObject({
|
|
72946
|
+
var HOST_EXTENSION_UPLOAD_PATH = "/api/extensions/upload", HOST_EXTENSION_CATALOG_ICON_PATH = "/api/extensions/catalog-icon", HOST_EXTENSION_CATALOG_SCREENSHOT_PATH = "/api/extensions/catalog-screenshot", hostExtensionRevisionSchema = external_exports.int().nonnegative(), hostExtensionConfigurationSchema = external_exports.strictObject({
|
|
72845
72947
|
revision: hostExtensionRevisionSchema,
|
|
72846
72948
|
enabled: external_exports.array(hostExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs")
|
|
72847
72949
|
}), hostExtensionDefaultSeedsSchema = external_exports.strictObject({
|
|
@@ -72954,6 +73056,7 @@ var hostExtensionGitHubSourceSchema = external_exports.strictObject({
|
|
|
72954
73056
|
snapshot: "codexhost/extensions/snapshot",
|
|
72955
73057
|
catalog: "codexhost/extensions/catalog",
|
|
72956
73058
|
catalogIcon: "codexhost/extensions/catalogIcon",
|
|
73059
|
+
catalogScreenshot: "codexhost/extensions/catalogScreenshot",
|
|
72957
73060
|
install: "codexhost/extensions/install",
|
|
72958
73061
|
update: "codexhost/extensions/update",
|
|
72959
73062
|
enable: "codexhost/extensions/enable",
|
|
@@ -72983,6 +73086,9 @@ var noParams = external_exports.strictObject({}), expectedRevision = { expectedR
|
|
|
72983
73086
|
}), hostExtensionsCatalogIconResultSchema = external_exports.strictObject({
|
|
72984
73087
|
mimeType: external_exports.enum(["image/png", "image/jpeg", "image/webp"]),
|
|
72985
73088
|
base64: base643(DESKTOP_EXTENSION_ICON_MAX_BYTES)
|
|
73089
|
+
}), hostExtensionCatalogScreenshotIndexSchema = external_exports.int().min(0).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT - 1), hostExtensionsCatalogScreenshotResultSchema = external_exports.strictObject({
|
|
73090
|
+
mimeType: external_exports.enum(["image/png", "image/jpeg", "image/webp"]),
|
|
73091
|
+
base64: base643(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)
|
|
72986
73092
|
}), hostExtensionSettingsSchema = external_exports.strictObject({
|
|
72987
73093
|
settingsRevision: hostExtensionRevisionSchema,
|
|
72988
73094
|
values: jsonObjectSchema
|
|
@@ -73000,6 +73106,10 @@ var noParams = external_exports.strictObject({}), expectedRevision = { expectedR
|
|
|
73000
73106
|
params: external_exports.strictObject({ ...id }),
|
|
73001
73107
|
result: hostExtensionsCatalogIconResultSchema
|
|
73002
73108
|
},
|
|
73109
|
+
[HOST_EXTENSIONS_RPC.catalogScreenshot]: {
|
|
73110
|
+
params: external_exports.strictObject({ ...id, index: hostExtensionCatalogScreenshotIndexSchema }),
|
|
73111
|
+
result: hostExtensionsCatalogScreenshotResultSchema
|
|
73112
|
+
},
|
|
73003
73113
|
[HOST_EXTENSIONS_RPC.install]: {
|
|
73004
73114
|
params: external_exports.strictObject({ source: hostExtensionInstallSourceSchema }),
|
|
73005
73115
|
result: installationResult
|
|
@@ -73057,6 +73167,151 @@ var noParams = external_exports.strictObject({}), expectedRevision = { expectedR
|
|
|
73057
73167
|
}
|
|
73058
73168
|
};
|
|
73059
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
|
+
|
|
73060
73315
|
// packages/shared-contracts/dist/thread-archive-confirm.js
|
|
73061
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();
|
|
73062
73317
|
|
|
@@ -73161,7 +73416,7 @@ var NATIVE_CODEX_GOAL_METHOD = "codexhost/thread/goal", nativeCodexGoalInvocatio
|
|
|
73161
73416
|
|
|
73162
73417
|
// packages/shared-contracts/dist/client-channel.js
|
|
73163
73418
|
var CLIENT_CHANNEL_VERSION = 1, CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
|
|
73164
|
-
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({
|
|
73165
73420
|
icon: external_exports.string().nullable(),
|
|
73166
73421
|
color: external_exports.string().nullable()
|
|
73167
73422
|
}), clientThreadSectionAppearanceSchema = threadSectionAppearance.nullable(), CLIENT_THREAD_SECTION_MUTATIONS = {
|
|
@@ -73195,6 +73450,22 @@ var THREAD_SECTION_CAPABILITY = "threadSectionsV1", threadSectionName = external
|
|
|
73195
73450
|
})
|
|
73196
73451
|
]), CLIENT_CHANNEL_METHODS = [
|
|
73197
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,
|
|
73198
73469
|
"codexhost/voice/status",
|
|
73199
73470
|
"codexhost/voice/transcribe",
|
|
73200
73471
|
"codexhost/harness/display-settings/get",
|
|
@@ -73345,6 +73616,11 @@ var THREAD_SECTION_CAPABILITY = "threadSectionsV1", threadSectionName = external
|
|
|
73345
73616
|
}),
|
|
73346
73617
|
external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
|
|
73347
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
|
+
}),
|
|
73348
73624
|
external_exports.object({
|
|
73349
73625
|
type: external_exports.literal("preferences-changed"),
|
|
73350
73626
|
cursor: clientChannelCursorSchema,
|
|
@@ -73467,6 +73743,7 @@ var THREAD_SECTION_CAPABILITY = "threadSectionsV1", threadSectionName = external
|
|
|
73467
73743
|
status: external_exports.object({ type: external_exports.string() }).passthrough(),
|
|
73468
73744
|
name: external_exports.string().nullable().optional(),
|
|
73469
73745
|
preview: external_exports.string().optional(),
|
|
73746
|
+
roleSnapshot: threadRoleSnapshotSchema.optional(),
|
|
73470
73747
|
codexhostImportSource: clientThreadImportSourceSchema.optional(),
|
|
73471
73748
|
turns: external_exports.array(clientTurnSchema).length(0)
|
|
73472
73749
|
}).passthrough(),
|
|
@@ -74439,6 +74716,9 @@ function webToolOutputPreviews(meta3) {
|
|
|
74439
74716
|
return result.success ? result.data : [];
|
|
74440
74717
|
}
|
|
74441
74718
|
|
|
74719
|
+
// packages/shared-contracts/dist/desktop-shell.js
|
|
74720
|
+
var desktopShellOpenParamsSchema = external_exports.strictObject({}), desktopShellOpenResultSchema = external_exports.strictObject({});
|
|
74721
|
+
|
|
74442
74722
|
// packages/shared-contracts/dist/console.js
|
|
74443
74723
|
var consoleAnnouncementSchema = external_exports.strictObject({
|
|
74444
74724
|
title: external_exports.string().trim().min(1).max(200),
|
|
@@ -75336,7 +75616,7 @@ var HostClientChannel = class {
|
|
|
75336
75616
|
throw new Error("Host unavailable");
|
|
75337
75617
|
this.descriptor = descriptor;
|
|
75338
75618
|
let url2 = new URL(`http://127.0.0.1:${descriptor.port}/v1/events`);
|
|
75339
|
-
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)));
|
|
75340
75620
|
let response = await fetch(url2, {
|
|
75341
75621
|
redirect: "error",
|
|
75342
75622
|
headers: { authorization: `Bearer ${descriptor.token}` },
|
|
@@ -75378,7 +75658,8 @@ var HostClientChannel = class {
|
|
|
75378
75658
|
}
|
|
75379
75659
|
}
|
|
75380
75660
|
async post(route, body, timeoutMs = 12e4) {
|
|
75381
|
-
|
|
75661
|
+
let connection = this.controller;
|
|
75662
|
+
if (this.stopped || !this.online || !connection || connection.signal.aborted)
|
|
75382
75663
|
throw new Error("CH is disconnected; reconnect before submitting an operation");
|
|
75383
75664
|
let generation = this.generation, response, value;
|
|
75384
75665
|
try {
|
|
@@ -75390,7 +75671,7 @@ var HostClientChannel = class {
|
|
|
75390
75671
|
"content-type": "application/json"
|
|
75391
75672
|
},
|
|
75392
75673
|
body: JSON.stringify(body),
|
|
75393
|
-
signal: AbortSignal.timeout(timeoutMs)
|
|
75674
|
+
signal: AbortSignal.any([connection.signal, AbortSignal.timeout(timeoutMs)])
|
|
75394
75675
|
});
|
|
75395
75676
|
let parsed = await response.json();
|
|
75396
75677
|
if (!parsed || typeof parsed != "object" || Array.isArray(parsed))
|
|
@@ -75501,7 +75782,7 @@ async function ensureHostService(options) {
|
|
|
75501
75782
|
throw new Error("Shared Host Launcher must be an absolute path");
|
|
75502
75783
|
let env = Object.fromEntries(Object.entries({ ...process.env, ...options.environment }).filter(([key, value]) => {
|
|
75503
75784
|
let upper = key.toUpperCase();
|
|
75504
|
-
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" : [
|
|
75505
75786
|
"CODEXHOST_NPM_NODE_PATH",
|
|
75506
75787
|
"CODEXHOST_NPM_CLI_PATH",
|
|
75507
75788
|
"CODEXHOST_NPM_LAUNCHER_PATH",
|
|
@@ -78029,6 +78310,8 @@ async function pinnedPeerGetJson(record6, path7, options = {}) {
|
|
|
78029
78310
|
});
|
|
78030
78311
|
req.on("error", () => {
|
|
78031
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"));
|
|
78032
78315
|
}), req.on("response", (res) => {
|
|
78033
78316
|
let status = res.statusCode ?? 0;
|
|
78034
78317
|
if (status >= 300 && status < 400) {
|
|
@@ -78281,7 +78564,10 @@ var INITIAL_CONNECTION_WAIT_MS = 2e3, MAX_TRACKED_SNAPSHOT_THREADS = 64, MAX_TRA
|
|
|
78281
78564
|
this.changed(this.hostId);
|
|
78282
78565
|
}
|
|
78283
78566
|
if (this.life.signal.aborted) return;
|
|
78284
|
-
let query = new URLSearchParams({
|
|
78567
|
+
let query = new URLSearchParams({
|
|
78568
|
+
[THREAD_SECTION_CAPABILITY]: "1",
|
|
78569
|
+
[GROUP_ROOMS_CAPABILITY]: "1"
|
|
78570
|
+
});
|
|
78285
78571
|
this.cursor && (query.set("epoch", this.cursor.epoch), query.set("after", String(this.cursor.sequence)));
|
|
78286
78572
|
let response = await this.fetch(
|
|
78287
78573
|
`/api/ch/v1/events?${query}`,
|
|
@@ -79170,7 +79456,7 @@ var DEFAULT_MODEL_INSPECT_TIMEOUT_MS = 5e3, INSPECT_TIMED_OUT = /* @__PURE__ */
|
|
|
79170
79456
|
inspection
|
|
79171
79457
|
});
|
|
79172
79458
|
}
|
|
79173
|
-
let
|
|
79459
|
+
let groups2 = values2.flatMap(
|
|
79174
79460
|
({ id: id2, name: name2, inspection }) => inspection.status === "ready" ? [groupOf(id2, name2, inspection)] : []
|
|
79175
79461
|
), ready = values2.filter(
|
|
79176
79462
|
(value) => value.inspection.status === "ready" && value.inspection.catalog.models.length
|
|
@@ -79197,8 +79483,8 @@ var DEFAULT_MODEL_INSPECT_TIMEOUT_MS = 5e3, INSPECT_TIMED_OUT = /* @__PURE__ */
|
|
|
79197
79483
|
let catalog = withHarnessDisplayOrder(
|
|
79198
79484
|
{
|
|
79199
79485
|
...selection2 ? { default: selection2 } : {},
|
|
79200
|
-
groups,
|
|
79201
|
-
routableProviders:
|
|
79486
|
+
groups: groups2,
|
|
79487
|
+
routableProviders: groups2.map((group) => group.id),
|
|
79202
79488
|
failures,
|
|
79203
79489
|
notInstalled
|
|
79204
79490
|
},
|
|
@@ -83661,7 +83947,10 @@ var MAX_LINKED_PEER_IDS = 128, normalizedPeerOrigin = (origin) => URL.parse(orig
|
|
|
83661
83947
|
events;
|
|
83662
83948
|
clients = /* @__PURE__ */ new Map();
|
|
83663
83949
|
sources = /* @__PURE__ */ new Map();
|
|
83950
|
+
peerHosts = /* @__PURE__ */ new Map();
|
|
83664
83951
|
peerRealtimeCleanups = /* @__PURE__ */ new Map();
|
|
83952
|
+
peerGroupCleanups = /* @__PURE__ */ new Map();
|
|
83953
|
+
groupChangeListeners = /* @__PURE__ */ new Set();
|
|
83665
83954
|
allowLoopback;
|
|
83666
83955
|
localNodeId;
|
|
83667
83956
|
streamIdleTimeoutMs;
|
|
@@ -83693,8 +83982,10 @@ var MAX_LINKED_PEER_IDS = 128, normalizedPeerOrigin = (origin) => URL.parse(orig
|
|
|
83693
83982
|
}
|
|
83694
83983
|
install(record6, client) {
|
|
83695
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);
|
|
83696
|
-
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) {
|
|
83697
|
-
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, {
|
|
83698
83989
|
sourcePeerNodes: next.manifest?.peerNodes,
|
|
83699
83990
|
hostIdForNodeId: (nodeId) => this.hostIdForNodeId(nodeId)
|
|
83700
83991
|
}), source = new PeerThreadSource({
|
|
@@ -83707,7 +83998,9 @@ var MAX_LINKED_PEER_IDS = 128, normalizedPeerOrigin = (origin) => URL.parse(orig
|
|
|
83707
83998
|
onUsageChanged: (threadId) => this.onUsageChanged?.(next.hostId, threadId),
|
|
83708
83999
|
onCatalogInspectionChanged: () => this.onCatalogInspectionChanged?.(next.hostId),
|
|
83709
84000
|
onSkillsChanged: () => this.onSkillsChanged?.(next.hostId),
|
|
83710
|
-
onConnection: (online) =>
|
|
84001
|
+
onConnection: (online) => {
|
|
84002
|
+
this.emitGroupChange({ hostId: next.hostId }), this.onConnection?.(next.hostId, online);
|
|
84003
|
+
},
|
|
83711
84004
|
onReset: (epoch, full) => this.onReset?.(next.hostId, epoch, full),
|
|
83712
84005
|
projector: (threadId) => {
|
|
83713
84006
|
let base = this.projector?.(threadId);
|
|
@@ -83721,12 +84014,55 @@ var MAX_LINKED_PEER_IDS = 128, normalizedPeerOrigin = (origin) => URL.parse(orig
|
|
|
83721
84014
|
};
|
|
83722
84015
|
}
|
|
83723
84016
|
});
|
|
83724
|
-
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(
|
|
83725
84026
|
record6.peerId,
|
|
83726
84027
|
this.onPeerRealtime(next.hostId, host.realtime)
|
|
83727
84028
|
);
|
|
83728
84029
|
}
|
|
83729
|
-
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
|
+
};
|
|
83730
84066
|
}
|
|
83731
84067
|
selfNodeId() {
|
|
83732
84068
|
return this.localNodeId;
|
|
@@ -84077,7 +84413,7 @@ var MAX_LINKED_PEER_IDS = 128, normalizedPeerOrigin = (origin) => URL.parse(orig
|
|
|
84077
84413
|
let { peerId } = remotePeerIdParamsSchema.parse(input3), client = this.get(peerId);
|
|
84078
84414
|
switch (action) {
|
|
84079
84415
|
case "remove":
|
|
84080
|
-
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 };
|
|
84081
84417
|
case "update": {
|
|
84082
84418
|
let p = remotePeerUpdateParamsSchema.parse(input3), old = client.record, conn = p.connectionUrl || p.origin || p.token ? parseConnectionLink(
|
|
84083
84419
|
p.connectionUrl ? p : {
|
|
@@ -84116,7 +84452,7 @@ var MAX_LINKED_PEER_IDS = 128, normalizedPeerOrigin = (origin) => URL.parse(orig
|
|
|
84116
84452
|
throw probedClient?.close(), error62;
|
|
84117
84453
|
}
|
|
84118
84454
|
if (record6.enabled === old.enabled && record6.origin === old.origin && record6.token === old.token)
|
|
84119
|
-
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) };
|
|
84120
84456
|
let next = this.install(record6, probedClient);
|
|
84121
84457
|
return this.changed(next.hostId), { peer: this.summarize(next) };
|
|
84122
84458
|
}
|
|
@@ -84146,8 +84482,10 @@ var MAX_LINKED_PEER_IDS = 128, normalizedPeerOrigin = (origin) => URL.parse(orig
|
|
|
84146
84482
|
close() {
|
|
84147
84483
|
for (let stop of this.peerRealtimeCleanups.values()) stop();
|
|
84148
84484
|
this.peerRealtimeCleanups.clear();
|
|
84485
|
+
for (let stop of this.peerGroupCleanups.values()) stop();
|
|
84486
|
+
this.peerGroupCleanups.clear(), this.groupChangeListeners.clear();
|
|
84149
84487
|
for (let s of this.sources.values()) s.close();
|
|
84150
|
-
this.sources.clear();
|
|
84488
|
+
this.sources.clear(), this.peerHosts.clear();
|
|
84151
84489
|
for (let p of this.clients.values()) p.close();
|
|
84152
84490
|
}
|
|
84153
84491
|
};
|
|
@@ -86871,9 +87209,9 @@ var core, hasRequiredCore;
|
|
|
86871
87209
|
function requireCore() {
|
|
86872
87210
|
return hasRequiredCore || (hasRequiredCore = 1, core = requireJson()), core;
|
|
86873
87211
|
}
|
|
86874
|
-
var
|
|
87212
|
+
var timestamp2, hasRequiredTimestamp;
|
|
86875
87213
|
function requireTimestamp() {
|
|
86876
|
-
if (hasRequiredTimestamp) return
|
|
87214
|
+
if (hasRequiredTimestamp) return timestamp2;
|
|
86877
87215
|
hasRequiredTimestamp = 1;
|
|
86878
87216
|
let Type2 = requireType(), YAML_DATE_REGEXP = new RegExp(
|
|
86879
87217
|
"^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
|
|
@@ -86905,13 +87243,13 @@ function requireTimestamp() {
|
|
|
86905
87243
|
function representYamlTimestamp(object4) {
|
|
86906
87244
|
return object4.toISOString();
|
|
86907
87245
|
}
|
|
86908
|
-
return
|
|
87246
|
+
return timestamp2 = new Type2("tag:yaml.org,2002:timestamp", {
|
|
86909
87247
|
kind: "scalar",
|
|
86910
87248
|
resolve: resolveYamlTimestamp,
|
|
86911
87249
|
construct: constructYamlTimestamp,
|
|
86912
87250
|
instanceOf: Date,
|
|
86913
87251
|
represent: representYamlTimestamp
|
|
86914
|
-
}),
|
|
87252
|
+
}), timestamp2;
|
|
86915
87253
|
}
|
|
86916
87254
|
var merge2, hasRequiredMerge;
|
|
86917
87255
|
function requireMerge() {
|
|
@@ -100080,9 +100418,9 @@ var LocalTerminalHandle = class {
|
|
|
100080
100418
|
}
|
|
100081
100419
|
this.signalMembers(members2, "SIGKILL");
|
|
100082
100420
|
}
|
|
100083
|
-
unionMembers(...
|
|
100421
|
+
unionMembers(...groups2) {
|
|
100084
100422
|
let members2 = [], seen = /* @__PURE__ */ new Set();
|
|
100085
|
-
for (let group of
|
|
100423
|
+
for (let group of groups2)
|
|
100086
100424
|
for (let member of group) {
|
|
100087
100425
|
let key = `${member.pid}:${member.started}`;
|
|
100088
100426
|
seen.has(key) || (seen.add(key), members2.push(member));
|
|
@@ -102832,7 +103170,8 @@ var RemotePeerAttachments = class {
|
|
|
102832
103170
|
let response = await peerFetch(activePeer.record, "/api/peer/v1/prompt", {
|
|
102833
103171
|
method: "POST",
|
|
102834
103172
|
body: validated.data,
|
|
102835
|
-
timeoutMs: this.requestTimeoutMs
|
|
103173
|
+
timeoutMs: this.requestTimeoutMs,
|
|
103174
|
+
...activePeer.outboundFetchOptions?.()
|
|
102836
103175
|
}), payload = await readPeerJson(
|
|
102837
103176
|
response,
|
|
102838
103177
|
"remote/request-failed",
|
|
@@ -103045,13 +103384,13 @@ async function loadCatalog(target2, call) {
|
|
|
103045
103384
|
}
|
|
103046
103385
|
return {};
|
|
103047
103386
|
})
|
|
103048
|
-
),
|
|
103387
|
+
), groups2 = rows.flatMap((row) => row.group ? [row.group] : []), first = rows.find((row) => row.group && row.preferred);
|
|
103049
103388
|
if (!first?.group || !first.preferred)
|
|
103050
103389
|
throw new SessionRuntimeError("remote/no-harness", "No ready Harness in the selected remote project.");
|
|
103051
103390
|
return {
|
|
103052
103391
|
default: { provider: first.group.id, model: first.preferred },
|
|
103053
|
-
groups,
|
|
103054
|
-
routableProviders:
|
|
103392
|
+
groups: groups2,
|
|
103393
|
+
routableProviders: groups2.map((g) => g.id),
|
|
103055
103394
|
failures: rows.flatMap((row) => row.failure ? [row.failure] : [])
|
|
103056
103395
|
};
|
|
103057
103396
|
}
|
|
@@ -104000,7 +104339,7 @@ function remoteWorkspaceGroups(hosts, threads) {
|
|
|
104000
104339
|
}, normalize2 = (path7) => {
|
|
104001
104340
|
let p = path7.replaceAll("\\", "/").replace(/\/+$/u, "");
|
|
104002
104341
|
return /^[a-z]:/iu.test(p) ? p.toLowerCase() : p;
|
|
104003
|
-
}, projects = host.projects ?? [],
|
|
104342
|
+
}, projects = host.projects ?? [], groups2 = [
|
|
104004
104343
|
...projects.map((project2) => ({ project: project2, ids: [] })),
|
|
104005
104344
|
{ project: void 0, ids: [] }
|
|
104006
104345
|
];
|
|
@@ -104009,9 +104348,9 @@ function remoteWorkspaceGroups(hosts, threads) {
|
|
|
104009
104348
|
let root = normalize2(project2.path);
|
|
104010
104349
|
return cwd === root || cwd.startsWith(root + "/");
|
|
104011
104350
|
}).sort((a, b) => b.path.length - a.path.length)[0];
|
|
104012
|
-
|
|
104351
|
+
groups2.find((group) => group.project === match)?.ids.push(row.sessionId);
|
|
104013
104352
|
}
|
|
104014
|
-
return
|
|
104353
|
+
return groups2.filter((group) => group.project || group.ids.length || projects.length === 0).map(({ project: project2, ids }) => ({
|
|
104015
104354
|
workspaceId: remoteWorkspaceId(host.hostId, project2?.id ?? null),
|
|
104016
104355
|
path: project2?.path ?? "",
|
|
104017
104356
|
title: project2?.name ?? remote.displayName,
|
|
@@ -105188,17 +105527,17 @@ var RemoteSessions = class {
|
|
|
105188
105527
|
]);
|
|
105189
105528
|
}
|
|
105190
105529
|
syncGroups() {
|
|
105191
|
-
let
|
|
105192
|
-
for (let group of
|
|
105530
|
+
let groups2 = this.remoteGroupsSnapshot(), bySession = /* @__PURE__ */ new Map();
|
|
105531
|
+
for (let group of groups2)
|
|
105193
105532
|
for (let sessionId of group.sessionIds)
|
|
105194
105533
|
bySession.set(sessionId, group.workspaceId);
|
|
105195
|
-
this.remoteWorkspaceBySession = bySession, this.workspaces?.setRemoteGroups(
|
|
105534
|
+
this.remoteWorkspaceBySession = bySession, this.workspaces?.setRemoteGroups(groups2);
|
|
105196
105535
|
}
|
|
105197
105536
|
workspaceMapForListing() {
|
|
105198
105537
|
if (this.remoteWorkspaceBySession.size > 0 || this.entries.size === 0)
|
|
105199
105538
|
return this.remoteWorkspaceBySession;
|
|
105200
|
-
let
|
|
105201
|
-
for (let group of
|
|
105539
|
+
let groups2 = this.remoteGroupsSnapshot(), bySession = /* @__PURE__ */ new Map();
|
|
105540
|
+
for (let group of groups2)
|
|
105202
105541
|
for (let sessionId of group.sessionIds)
|
|
105203
105542
|
bySession.set(sessionId, group.workspaceId);
|
|
105204
105543
|
return this.remoteWorkspaceBySession = bySession, bySession;
|
|
@@ -106354,10 +106693,10 @@ var RemoteSessions = class {
|
|
|
106354
106693
|
let peerCatalog = await peerSource2.catalog.models().catch(() => {
|
|
106355
106694
|
});
|
|
106356
106695
|
if (!peerCatalog?.groups.length) return base2;
|
|
106357
|
-
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;
|
|
106358
106697
|
return {
|
|
106359
106698
|
...base2,
|
|
106360
|
-
groups,
|
|
106699
|
+
groups: groups2,
|
|
106361
106700
|
...peerCatalog.harnessOrder ? { harnessOrder: peerCatalog.harnessOrder } : {}
|
|
106362
106701
|
};
|
|
106363
106702
|
}
|
|
@@ -107102,7 +107441,7 @@ var RemotePeerWorkspaceFiles = class {
|
|
|
107102
107441
|
var import_qrcode_terminal = __toESM(require_main(), 1);
|
|
107103
107442
|
import { existsSync as existsSync16, readFileSync as readFileSync18 } from "node:fs";
|
|
107104
107443
|
import { homedir as homedir11, hostname as hostname4 } from "node:os";
|
|
107105
|
-
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";
|
|
107106
107445
|
import { parseArgs } from "node:util";
|
|
107107
107446
|
|
|
107108
107447
|
// packages/web-server/src/workspace-video.ts
|
|
@@ -107110,14 +107449,15 @@ import { constants as constants9 } from "node:fs";
|
|
|
107110
107449
|
import { open as open9 } from "node:fs/promises";
|
|
107111
107450
|
import { extname as extname7, resolve as resolve11 } from "node:path";
|
|
107112
107451
|
import { pipeline as pipeline3 } from "node:stream/promises";
|
|
107113
|
-
var
|
|
107452
|
+
var MEDIA_TYPES = {
|
|
107114
107453
|
".mp4": "video/mp4",
|
|
107115
107454
|
".m4v": "video/mp4",
|
|
107116
107455
|
".mov": "video/quicktime",
|
|
107117
107456
|
".webm": "video/webm",
|
|
107118
|
-
".ogv": "video/ogg"
|
|
107457
|
+
".ogv": "video/ogg",
|
|
107458
|
+
".mp3": "audio/mpeg"
|
|
107119
107459
|
};
|
|
107120
|
-
function
|
|
107460
|
+
function byteRange(header2, size) {
|
|
107121
107461
|
let match = /^bytes=(\d*)-(\d*)$/iu.exec(header2.trim());
|
|
107122
107462
|
if (!match || !match[1] && !match[2]) return;
|
|
107123
107463
|
if (!match[1]) {
|
|
@@ -107128,16 +107468,17 @@ function videoRange(header2, size) {
|
|
|
107128
107468
|
if (!(match[2] && end < start))
|
|
107129
107469
|
return start >= size ? null : [start, Math.min(end, size - 1)];
|
|
107130
107470
|
}
|
|
107131
|
-
async function
|
|
107471
|
+
async function serveWorkspaceMedia(request3, response, url2, workspace) {
|
|
107132
107472
|
response.setHeader("Cache-Control", "private, no-store");
|
|
107133
107473
|
let root = workspace(url2.searchParams.get("sessionId") ?? ""), path7 = url2.searchParams.get("path");
|
|
107134
107474
|
if (!root || !path7 || path7.includes("\0")) {
|
|
107135
107475
|
response.writeHead(404).end();
|
|
107136
107476
|
return;
|
|
107137
107477
|
}
|
|
107138
|
-
let mediaType =
|
|
107478
|
+
let mediaType = MEDIA_TYPES[extname7(path7).toLowerCase()], file3;
|
|
107139
107479
|
try {
|
|
107140
|
-
|
|
107480
|
+
let nativePath = process.platform === "win32" ? path7.replace(/^\/(?=[a-z]:[/\\])/iu, "") : path7;
|
|
107481
|
+
file3 = await open9(resolve11(root, nativePath), constants9.O_RDONLY | constants9.O_NONBLOCK);
|
|
107141
107482
|
let meta3 = await file3.stat();
|
|
107142
107483
|
if (!meta3.isFile()) throw new Error("not a regular file");
|
|
107143
107484
|
if (mediaType === void 0) {
|
|
@@ -107145,7 +107486,7 @@ async function serveWorkspaceVideo(request3, response, url2, workspace) {
|
|
|
107145
107486
|
return;
|
|
107146
107487
|
}
|
|
107147
107488
|
response.setHeader("Content-Type", mediaType), response.setHeader("Content-Disposition", "inline"), response.setHeader("X-Content-Type-Options", "nosniff"), response.setHeader("Accept-Ranges", "bytes");
|
|
107148
|
-
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;
|
|
107149
107490
|
if (range === null) {
|
|
107150
107491
|
response.writeHead(416, { "Content-Range": `bytes */${meta3.size}`, "Content-Length": "0" }).end();
|
|
107151
107492
|
return;
|
|
@@ -107614,7 +107955,7 @@ var updateParams = hostExtensionsRpcSchemas[HOST_EXTENSIONS_RPC.update].params.o
|
|
|
107614
107955
|
source: !0
|
|
107615
107956
|
});
|
|
107616
107957
|
function isHostExtensionHttpPath(pathname) {
|
|
107617
|
-
return pathname === HOST_EXTENSION_UPLOAD_PATH || pathname === HOST_EXTENSION_CATALOG_ICON_PATH || pathname.startsWith(HOST_EXTENSION_ASSETS_PREFIX);
|
|
107958
|
+
return pathname === HOST_EXTENSION_UPLOAD_PATH || pathname === HOST_EXTENSION_CATALOG_ICON_PATH || pathname === HOST_EXTENSION_CATALOG_SCREENSHOT_PATH || pathname.startsWith(HOST_EXTENSION_ASSETS_PREFIX);
|
|
107618
107959
|
}
|
|
107619
107960
|
function parseAssetPath(pathname) {
|
|
107620
107961
|
let [id2, activationId, digest2, ...parts] = pathname.slice(HOST_EXTENSION_ASSETS_PREFIX.length).split("/"), segments = parts.map(decodeURIComponent);
|
|
@@ -107739,8 +108080,36 @@ async function serveCatalogIcon(channel, request3, response) {
|
|
|
107739
108080
|
"Cache-Control": "private, max-age=86400"
|
|
107740
108081
|
}).end(request3.method === "HEAD" ? void 0 : bytes);
|
|
107741
108082
|
}
|
|
108083
|
+
async function serveCatalogScreenshot(channel, request3, response) {
|
|
108084
|
+
let url2 = request3.url ?? "", queryStart = url2.indexOf("?"), query = new URLSearchParams(queryStart === -1 ? "" : url2.slice(queryStart + 1)), ids = query.getAll("id"), indexes = query.getAll("index"), parsedId = ids.length === 1 ? hostExtensionIdSchema.safeParse(ids[0]) : null, rawIndex = indexes.length === 1 ? indexes[0] : void 0, parsedIndex = rawIndex !== void 0 && /^\d+$/u.test(rawIndex) ? hostExtensionCatalogScreenshotIndexSchema.safeParse(Number(rawIndex)) : null;
|
|
108085
|
+
if (!parsedId?.success || !parsedIndex?.success) {
|
|
108086
|
+
response.writeHead(400).end();
|
|
108087
|
+
return;
|
|
108088
|
+
}
|
|
108089
|
+
let result;
|
|
108090
|
+
try {
|
|
108091
|
+
result = await channel.request(HOST_EXTENSIONS_RPC.catalogScreenshot, {
|
|
108092
|
+
id: parsedId.data,
|
|
108093
|
+
index: parsedIndex.data
|
|
108094
|
+
});
|
|
108095
|
+
} catch {
|
|
108096
|
+
response.writeHead(404).end();
|
|
108097
|
+
return;
|
|
108098
|
+
}
|
|
108099
|
+
let screenshot = hostExtensionsCatalogScreenshotResultSchema.safeParse(result);
|
|
108100
|
+
if (!screenshot.success) {
|
|
108101
|
+
response.writeHead(502).end();
|
|
108102
|
+
return;
|
|
108103
|
+
}
|
|
108104
|
+
let bytes = Buffer.from(screenshot.data.base64, "base64");
|
|
108105
|
+
response.writeHead(200, {
|
|
108106
|
+
"Content-Type": screenshot.data.mimeType,
|
|
108107
|
+
"Content-Length": bytes.length,
|
|
108108
|
+
"Cache-Control": "private, max-age=86400"
|
|
108109
|
+
}).end(request3.method === "HEAD" ? void 0 : bytes);
|
|
108110
|
+
}
|
|
107742
108111
|
async function serveHostExtensionHttp(host, trust2, request3, response, pathname, { requestAuth, safeMode = !1 }) {
|
|
107743
|
-
let upload = pathname === HOST_EXTENSION_UPLOAD_PATH, catalogIcon = pathname === HOST_EXTENSION_CATALOG_ICON_PATH;
|
|
108112
|
+
let upload = pathname === HOST_EXTENSION_UPLOAD_PATH, catalogIcon = pathname === HOST_EXTENSION_CATALOG_ICON_PATH, catalogScreenshot = pathname === HOST_EXTENSION_CATALOG_SCREENSHOT_PATH;
|
|
107744
108113
|
if (response.setHeader("Cache-Control", "private, no-store"), response.setHeader("X-Content-Type-Options", "nosniff"), upload || response.setHeader("Cross-Origin-Resource-Policy", "same-origin"), requestAuth === void 0 || safeMode || !trust2.sameOrigin(request3)) {
|
|
107745
108114
|
response.writeHead(403).end();
|
|
107746
108115
|
return;
|
|
@@ -107754,7 +108123,7 @@ async function serveHostExtensionHttp(host, trust2, request3, response, pathname
|
|
|
107754
108123
|
response.writeHead(503).end();
|
|
107755
108124
|
return;
|
|
107756
108125
|
}
|
|
107757
|
-
upload ? await serveUpload(channel, request3, response) : catalogIcon ? await serveCatalogIcon(channel, request3, response) : await serveAsset(channel, request3, response, pathname);
|
|
108126
|
+
upload ? await serveUpload(channel, request3, response) : catalogIcon ? await serveCatalogIcon(channel, request3, response) : catalogScreenshot ? await serveCatalogScreenshot(channel, request3, response) : await serveAsset(channel, request3, response, pathname);
|
|
107758
108127
|
}
|
|
107759
108128
|
|
|
107760
108129
|
// packages/web-server/src/workspace-file-actions.ts
|
|
@@ -110165,19 +110534,32 @@ function registerRelayRpc(rpc2, tokens, relay2) {
|
|
|
110165
110534
|
}
|
|
110166
110535
|
|
|
110167
110536
|
// packages/shared-contracts/dist/desktop-screenshot.js
|
|
110168
|
-
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 = [
|
|
110169
110538
|
"unsupported",
|
|
110170
110539
|
"permission-denied",
|
|
110171
110540
|
"display-unavailable",
|
|
110541
|
+
"invalid-display",
|
|
110172
110542
|
"capture-failed",
|
|
110173
110543
|
"image-too-large",
|
|
110174
110544
|
"busy",
|
|
110175
110545
|
"timeout",
|
|
110176
110546
|
"unavailable"
|
|
110177
|
-
];
|
|
110547
|
+
], CANONICAL_UINT32_PATTERN = /^(?:0|[1-9][0-9]{0,9})$/u;
|
|
110178
110548
|
function isDesktopScreenshotError(value) {
|
|
110179
110549
|
return typeof value == "string" && DESKTOP_SCREENSHOT_ERRORS.some((code) => code === value);
|
|
110180
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
|
+
}
|
|
110181
110563
|
|
|
110182
110564
|
// packages/web-server/src/desktop-screenshot.ts
|
|
110183
110565
|
import { spawn as spawn5 } from "node:child_process";
|
|
@@ -110185,12 +110567,42 @@ var STATUS = {
|
|
|
110185
110567
|
unsupported: 501,
|
|
110186
110568
|
"permission-denied": 403,
|
|
110187
110569
|
"display-unavailable": 409,
|
|
110570
|
+
"invalid-display": 400,
|
|
110188
110571
|
"capture-failed": 502,
|
|
110189
110572
|
"image-too-large": 413,
|
|
110190
110573
|
busy: 429,
|
|
110191
110574
|
timeout: 504,
|
|
110192
110575
|
unavailable: 503
|
|
110193
|
-
},
|
|
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 {
|
|
110194
110606
|
constructor(command, timeoutMs = 15e3) {
|
|
110195
110607
|
this.command = command;
|
|
110196
110608
|
this.timeoutMs = timeoutMs;
|
|
@@ -110202,7 +110614,7 @@ var STATUS = {
|
|
|
110202
110614
|
close() {
|
|
110203
110615
|
this.closed = !0, this.active?.abort();
|
|
110204
110616
|
}
|
|
110205
|
-
async
|
|
110617
|
+
async serveDisplays(request3, response) {
|
|
110206
110618
|
response.setHeader("Cache-Control", "private, no-store"), response.setHeader("X-Content-Type-Options", "nosniff");
|
|
110207
110619
|
let fail = (error62) => {
|
|
110208
110620
|
response.destroyed || response.writeHead(STATUS[error62], { "content-type": "application/json" }).end(JSON.stringify({ error: error62 }));
|
|
@@ -110218,7 +110630,36 @@ var STATUS = {
|
|
|
110218
110630
|
};
|
|
110219
110631
|
response.once("close", disconnected), response.destroyed && controller.abort(), request3.resume();
|
|
110220
110632
|
try {
|
|
110221
|
-
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);
|
|
110222
110663
|
response.destroyed || response.writeHead(200, {
|
|
110223
110664
|
"content-type": "image/png",
|
|
110224
110665
|
"content-length": image.length,
|
|
@@ -110230,13 +110671,13 @@ var STATUS = {
|
|
|
110230
110671
|
this.active = void 0, response.off("close", disconnected);
|
|
110231
110672
|
}
|
|
110232
110673
|
}
|
|
110233
|
-
|
|
110674
|
+
runNative(args, maxBytes, signal, oversizeError) {
|
|
110234
110675
|
return new Promise((resolve26, reject) => {
|
|
110235
110676
|
if (signal.aborted) {
|
|
110236
110677
|
reject("capture-failed");
|
|
110237
110678
|
return;
|
|
110238
110679
|
}
|
|
110239
|
-
let [executable, ...prefix] = this.command, child = spawn5(executable, [...prefix, "desktop-screenshot"], {
|
|
110680
|
+
let [executable, ...prefix] = this.command, child = spawn5(executable, [...prefix, "desktop-screenshot", ...args], {
|
|
110240
110681
|
stdio: ["ignore", "pipe", "pipe"],
|
|
110241
110682
|
windowsHide: !0
|
|
110242
110683
|
}), chunks = [], bytes = 0, stderr = "", failure3, stop = (error62) => {
|
|
@@ -110245,7 +110686,7 @@ var STATUS = {
|
|
|
110245
110686
|
signal.addEventListener("abort", abort, { once: !0 });
|
|
110246
110687
|
let timeout = setTimeout(() => stop("timeout"), this.timeoutMs);
|
|
110247
110688
|
child.stdout.on("data", (chunk) => {
|
|
110248
|
-
failure3 === void 0 && (bytes += chunk.length, bytes >
|
|
110689
|
+
failure3 === void 0 && (bytes += chunk.length, bytes > maxBytes ? stop(oversizeError) : chunks.push(chunk));
|
|
110249
110690
|
}), child.stderr.on("data", (chunk) => {
|
|
110250
110691
|
stderr.length < 2048 && (stderr += chunk.toString("utf8").slice(0, 2048 - stderr.length));
|
|
110251
110692
|
}), child.once("error", () => {
|
|
@@ -110260,16 +110701,42 @@ var STATUS = {
|
|
|
110260
110701
|
reject(isDesktopScreenshotError(native2) ? native2 : "capture-failed");
|
|
110261
110702
|
return;
|
|
110262
110703
|
}
|
|
110263
|
-
|
|
110264
|
-
let image = Buffer.concat(chunks, bytes);
|
|
110265
|
-
if (inspectImage(image).ref.mediaType !== "image/png") throw new Error("Unexpected image type");
|
|
110266
|
-
resolve26(image);
|
|
110267
|
-
} catch {
|
|
110268
|
-
reject("capture-failed");
|
|
110269
|
-
}
|
|
110704
|
+
resolve26(Buffer.concat(chunks, bytes));
|
|
110270
110705
|
});
|
|
110271
110706
|
});
|
|
110272
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
|
+
}
|
|
110273
110740
|
};
|
|
110274
110741
|
|
|
110275
110742
|
// packages/shared-contracts/dist/sidebar-browser.js
|
|
@@ -114493,14 +114960,14 @@ function appendRfc3550Padding(payload, paddingSize) {
|
|
|
114493
114960
|
}
|
|
114494
114961
|
function createRtxPaddingPacket({
|
|
114495
114962
|
paddingSize,
|
|
114496
|
-
timestamp:
|
|
114963
|
+
timestamp: timestamp3,
|
|
114497
114964
|
payloadType,
|
|
114498
114965
|
ssrc
|
|
114499
114966
|
}) {
|
|
114500
114967
|
return new RtpPacket(
|
|
114501
114968
|
new RtpHeader({
|
|
114502
114969
|
sequenceNumber: 0,
|
|
114503
|
-
timestamp:
|
|
114970
|
+
timestamp: timestamp3,
|
|
114504
114971
|
payloadType,
|
|
114505
114972
|
ssrc,
|
|
114506
114973
|
extension: !0,
|
|
@@ -123797,10 +124264,10 @@ var RTCRtpTransceiver = class {
|
|
|
123797
124264
|
)?.payloadType;
|
|
123798
124265
|
}
|
|
123799
124266
|
getCodecStats() {
|
|
123800
|
-
let
|
|
123801
|
-
return this.collectCodecStats(
|
|
124267
|
+
let timestamp3 = getStatsTimestamp();
|
|
124268
|
+
return this.collectCodecStats(timestamp3);
|
|
123802
124269
|
}
|
|
123803
|
-
collectCodecStats(
|
|
124270
|
+
collectCodecStats(timestamp3) {
|
|
123804
124271
|
let stats = [];
|
|
123805
124272
|
if (!this.dtlsTransport)
|
|
123806
124273
|
return stats;
|
|
@@ -123809,7 +124276,7 @@ var RTCRtpTransceiver = class {
|
|
|
123809
124276
|
let codecStats = {
|
|
123810
124277
|
type: "codec",
|
|
123811
124278
|
id: generateCodecStatsId(transportId, codec2.payloadType, this.id),
|
|
123812
|
-
timestamp:
|
|
124279
|
+
timestamp: timestamp3,
|
|
123813
124280
|
payloadType: codec2.payloadType,
|
|
123814
124281
|
transportId,
|
|
123815
124282
|
mimeType: codec2.mimeType,
|
|
@@ -124662,11 +125129,11 @@ var RTCDtlsTransport = class _RTCDtlsTransport {
|
|
|
124662
125129
|
(error62) => log32("onStopped listener failed", error62)
|
|
124663
125130
|
), this.notifySafely("onStopped", () => this.onStopped.complete());
|
|
124664
125131
|
}
|
|
124665
|
-
async getStats(
|
|
125132
|
+
async getStats(timestamp3 = getStatsTimestamp()) {
|
|
124666
125133
|
let stats = [], transportId = generateStatsId("transport", this.id), transportStats = {
|
|
124667
125134
|
type: "transport",
|
|
124668
125135
|
id: transportId,
|
|
124669
|
-
timestamp:
|
|
125136
|
+
timestamp: timestamp3,
|
|
124670
125137
|
bytesSent: this.bytesSent,
|
|
124671
125138
|
bytesReceived: this.bytesReceived,
|
|
124672
125139
|
packetsSent: this.packetsSent,
|
|
@@ -124693,7 +125160,7 @@ var RTCDtlsTransport = class _RTCDtlsTransport {
|
|
|
124693
125160
|
let certStats = {
|
|
124694
125161
|
type: "certificate",
|
|
124695
125162
|
id: generateStatsId("certificate", this.id, "local"),
|
|
124696
|
-
timestamp:
|
|
125163
|
+
timestamp: timestamp3,
|
|
124697
125164
|
fingerprint: fingerprints[0].value,
|
|
124698
125165
|
fingerprintAlgorithm: fingerprints[0].algorithm,
|
|
124699
125166
|
base64Certificate: Buffer.from(
|
|
@@ -124707,7 +125174,7 @@ var RTCDtlsTransport = class _RTCDtlsTransport {
|
|
|
124707
125174
|
let certStats = {
|
|
124708
125175
|
type: "certificate",
|
|
124709
125176
|
id: generateStatsId("certificate", this.id, "remote"),
|
|
124710
|
-
timestamp:
|
|
125177
|
+
timestamp: timestamp3,
|
|
124711
125178
|
fingerprint: this.remoteParameters.fingerprints[0].value,
|
|
124712
125179
|
fingerprintAlgorithm: this.remoteParameters.fingerprints[0].algorithm,
|
|
124713
125180
|
base64Certificate: Buffer.from(this.dtls.remoteCertificate).toString(
|
|
@@ -124716,7 +125183,7 @@ var RTCDtlsTransport = class _RTCDtlsTransport {
|
|
|
124716
125183
|
};
|
|
124717
125184
|
stats.push(certStats);
|
|
124718
125185
|
}
|
|
124719
|
-
let iceStats = await this.iceTransport.getStats(
|
|
125186
|
+
let iceStats = await this.iceTransport.getStats(timestamp3, transportId);
|
|
124720
125187
|
return stats.push(...iceStats), stats;
|
|
124721
125188
|
}
|
|
124722
125189
|
};
|
|
@@ -125297,13 +125764,13 @@ var RTCIceTransport = class {
|
|
|
125297
125764
|
let waitStart = this.waitStart;
|
|
125298
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();
|
|
125299
125766
|
}
|
|
125300
|
-
async getStats(
|
|
125767
|
+
async getStats(timestamp3 = getStatsTimestamp(), transportId = generateStatsId("transport", this.id)) {
|
|
125301
125768
|
let stats = [];
|
|
125302
125769
|
for (let candidate of this.connection.localCandidates) {
|
|
125303
125770
|
let candidateStats = {
|
|
125304
125771
|
type: "local-candidate",
|
|
125305
125772
|
id: generateStatsId("local-candidate", candidate.id),
|
|
125306
|
-
timestamp:
|
|
125773
|
+
timestamp: timestamp3,
|
|
125307
125774
|
transportId,
|
|
125308
125775
|
address: candidate.host,
|
|
125309
125776
|
port: candidate.port,
|
|
@@ -125322,7 +125789,7 @@ var RTCIceTransport = class {
|
|
|
125322
125789
|
let candidateStats = {
|
|
125323
125790
|
type: "remote-candidate",
|
|
125324
125791
|
id: generateStatsId("remote-candidate", candidate.id),
|
|
125325
|
-
timestamp:
|
|
125792
|
+
timestamp: timestamp3,
|
|
125326
125793
|
transportId,
|
|
125327
125794
|
address: candidate.host,
|
|
125328
125795
|
port: candidate.port,
|
|
@@ -125345,7 +125812,7 @@ var RTCIceTransport = class {
|
|
|
125345
125812
|
let pairStats = {
|
|
125346
125813
|
type: "candidate-pair",
|
|
125347
125814
|
id: generateStatsId("candidate-pair", pair.id),
|
|
125348
|
-
timestamp:
|
|
125815
|
+
timestamp: timestamp3,
|
|
125349
125816
|
transportId,
|
|
125350
125817
|
localCandidateId: generateStatsId(
|
|
125351
125818
|
"local-candidate",
|
|
@@ -131324,11 +131791,11 @@ var TransceiverManager = class {
|
|
|
131324
131791
|
!t.stopping || t.stopped || (t.mid == null || !negotiatedMids.has(t.mid)) && t.commitStopped({ rejected: !1 });
|
|
131325
131792
|
return this.transceivers.some((t) => t.stopping && !t.stopped);
|
|
131326
131793
|
}
|
|
131327
|
-
collectStats(
|
|
131794
|
+
collectStats(timestamp3) {
|
|
131328
131795
|
let stats = [];
|
|
131329
131796
|
for (let transceiver of this.transceivers) {
|
|
131330
|
-
transceiver.sender && stats.push(...transceiver.sender.collectStats(
|
|
131331
|
-
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);
|
|
131332
131799
|
codecStats && stats.push(...codecStats);
|
|
131333
131800
|
}
|
|
131334
131801
|
return stats;
|
|
@@ -131422,8 +131889,8 @@ var PendingSsrcRoutes = class _PendingSsrcRoutes {
|
|
|
131422
131889
|
* the timestamps of the packets received around the gap, in either order
|
|
131423
131890
|
* (frames sent out of display order) and widened by `slack`.
|
|
131424
131891
|
*/
|
|
131425
|
-
canRepair(ssrc, sequenceNumber,
|
|
131426
|
-
return this.streams.get(ssrc)?.canRepair(sequenceNumber,
|
|
131892
|
+
canRepair(ssrc, sequenceNumber, timestamp3, slack) {
|
|
131893
|
+
return this.streams.get(ssrc)?.canRepair(sequenceNumber, timestamp3, slack) ?? !1;
|
|
131427
131894
|
}
|
|
131428
131895
|
/** Reset `ssrc`: its NACK requests and holes end together. */
|
|
131429
131896
|
forget(ssrc) {
|
|
@@ -131469,9 +131936,9 @@ var PendingSsrcRoutes = class _PendingSsrcRoutes {
|
|
|
131469
131936
|
get holeCount() {
|
|
131470
131937
|
return this.holes.size;
|
|
131471
131938
|
}
|
|
131472
|
-
addPacket(sequenceNumber,
|
|
131939
|
+
addPacket(sequenceNumber, timestamp3) {
|
|
131473
131940
|
if (this.newestExt === void 0) {
|
|
131474
|
-
this.newestExt = sequenceNumber, this.newestTimestamp =
|
|
131941
|
+
this.newestExt = sequenceNumber, this.newestTimestamp = timestamp3;
|
|
131475
131942
|
return;
|
|
131476
131943
|
}
|
|
131477
131944
|
let ext = this.extend(sequenceNumber);
|
|
@@ -131484,17 +131951,17 @@ var PendingSsrcRoutes = class _PendingSsrcRoutes {
|
|
|
131484
131951
|
this.holes.set(missing, {
|
|
131485
131952
|
sequenceNumber: missing & 65535,
|
|
131486
131953
|
timestampBefore: this.newestTimestamp,
|
|
131487
|
-
timestampAfter:
|
|
131954
|
+
timestampAfter: timestamp3,
|
|
131488
131955
|
requests: 0
|
|
131489
131956
|
});
|
|
131490
|
-
this.newestExt = ext, this.newestTimestamp =
|
|
131957
|
+
this.newestExt = ext, this.newestTimestamp = timestamp3, this.pruneHoles(), from < ext && this.startLoop();
|
|
131491
131958
|
}
|
|
131492
131959
|
/** Whether an RTX packet with this original number and timestamp fills a hole. */
|
|
131493
|
-
canRepair(sequenceNumber,
|
|
131960
|
+
canRepair(sequenceNumber, timestamp3, slack) {
|
|
131494
131961
|
if (this.newestExt === void 0) return !1;
|
|
131495
131962
|
let hole = this.holes.get(this.extend(sequenceNumber));
|
|
131496
131963
|
if (!hole) return !1;
|
|
131497
|
-
let before = hole.timestampBefore - hole.timestampAfter | 0, offset =
|
|
131964
|
+
let before = hole.timestampBefore - hole.timestampAfter | 0, offset = timestamp3 - hole.timestampAfter | 0;
|
|
131498
131965
|
return offset >= Math.min(before, 0) - slack && offset <= Math.max(before, 0) + slack;
|
|
131499
131966
|
}
|
|
131500
131967
|
/**
|
|
@@ -132276,7 +132743,7 @@ var StreamStatistics = class {
|
|
|
132276
132743
|
getStatsRootIds(selector) {
|
|
132277
132744
|
return this.reportedTracks.filter((track) => selector ? track === selector : !0).filter((track) => track.ssrc !== void 0).map((track) => this.getInboundRtpStatsId(track));
|
|
132278
132745
|
}
|
|
132279
|
-
collectStats(
|
|
132746
|
+
collectStats(timestamp3) {
|
|
132280
132747
|
let stats = [], transportId = this.dtlsTransport ? generateStatsId("transport", this.dtlsTransport.id) : void 0, activeCodec = this.codecArray[0], emittedCodecIds = /* @__PURE__ */ new Set();
|
|
132281
132748
|
for (let track of this.reportedTracks) {
|
|
132282
132749
|
if (track.ssrc === void 0) continue;
|
|
@@ -132290,7 +132757,7 @@ var StreamStatistics = class {
|
|
|
132290
132757
|
let codecStats = {
|
|
132291
132758
|
type: "codec",
|
|
132292
132759
|
id: codecId,
|
|
132293
|
-
timestamp:
|
|
132760
|
+
timestamp: timestamp3,
|
|
132294
132761
|
payloadType: activeCodec.payloadType,
|
|
132295
132762
|
transportId,
|
|
132296
132763
|
mimeType: activeCodec.mimeType,
|
|
@@ -132303,7 +132770,7 @@ var StreamStatistics = class {
|
|
|
132303
132770
|
let inboundRtpStats = {
|
|
132304
132771
|
type: "inbound-rtp",
|
|
132305
132772
|
id: this.getInboundRtpStatsId(track),
|
|
132306
|
-
timestamp:
|
|
132773
|
+
timestamp: timestamp3,
|
|
132307
132774
|
ssrc: track.ssrc,
|
|
132308
132775
|
kind: this.kind,
|
|
132309
132776
|
transportId,
|
|
@@ -132324,7 +132791,7 @@ var StreamStatistics = class {
|
|
|
132324
132791
|
let remoteOutboundStats = {
|
|
132325
132792
|
type: "remote-outbound-rtp",
|
|
132326
132793
|
id: this.getRemoteOutboundRtpStatsId(track),
|
|
132327
|
-
timestamp:
|
|
132794
|
+
timestamp: timestamp3,
|
|
132328
132795
|
ssrc: track.ssrc,
|
|
132329
132796
|
kind: this.kind,
|
|
132330
132797
|
transportId,
|
|
@@ -132341,8 +132808,8 @@ var StreamStatistics = class {
|
|
|
132341
132808
|
return stats;
|
|
132342
132809
|
}
|
|
132343
132810
|
async getStats() {
|
|
132344
|
-
let
|
|
132345
|
-
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());
|
|
132346
132813
|
}
|
|
132347
132814
|
/**
|
|
132348
132815
|
* Internal: whether PLI is negotiated for `mediaSsrc`, and the payload type
|
|
@@ -133943,11 +134410,11 @@ var SENDER_REPORT_HISTORY_MAX_ENTRIES = 32, SENDER_REPORT_HISTORY_MAX_AGE_SEC =
|
|
|
133943
134410
|
* outbound-rtp, media-source (with a track), codec (with a codec and a
|
|
133944
134411
|
* transport), and remote-inbound-rtp (once a report arrived) entries.
|
|
133945
134412
|
*/
|
|
133946
|
-
collect(context,
|
|
134413
|
+
collect(context, timestamp3) {
|
|
133947
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 = {
|
|
133948
134415
|
type: "outbound-rtp",
|
|
133949
134416
|
id: senderStatsIds(context.trackId).outboundRtp,
|
|
133950
|
-
timestamp:
|
|
134417
|
+
timestamp: timestamp3,
|
|
133951
134418
|
ssrc: context.ssrc,
|
|
133952
134419
|
kind: context.kind,
|
|
133953
134420
|
transportId,
|
|
@@ -133969,7 +134436,7 @@ var SENDER_REPORT_HISTORY_MAX_ENTRIES = 32, SENDER_REPORT_HISTORY_MAX_AGE_SEC =
|
|
|
133969
134436
|
let mediaSourceStats = {
|
|
133970
134437
|
type: "media-source",
|
|
133971
134438
|
id: mediaSourceId,
|
|
133972
|
-
timestamp:
|
|
134439
|
+
timestamp: timestamp3,
|
|
133973
134440
|
trackIdentifier: context.trackIdentifier,
|
|
133974
134441
|
kind: context.kind
|
|
133975
134442
|
};
|
|
@@ -133979,7 +134446,7 @@ var SENDER_REPORT_HISTORY_MAX_ENTRIES = 32, SENDER_REPORT_HISTORY_MAX_AGE_SEC =
|
|
|
133979
134446
|
let codecStats = {
|
|
133980
134447
|
type: "codec",
|
|
133981
134448
|
id: codecId,
|
|
133982
|
-
timestamp:
|
|
134449
|
+
timestamp: timestamp3,
|
|
133983
134450
|
payloadType: codec2.payloadType,
|
|
133984
134451
|
transportId,
|
|
133985
134452
|
mimeType: codec2.mimeType,
|
|
@@ -133993,7 +134460,7 @@ var SENDER_REPORT_HISTORY_MAX_ENTRIES = 32, SENDER_REPORT_HISTORY_MAX_AGE_SEC =
|
|
|
133993
134460
|
let remoteInboundStats = {
|
|
133994
134461
|
type: "remote-inbound-rtp",
|
|
133995
134462
|
id: remoteInboundId,
|
|
133996
|
-
timestamp:
|
|
134463
|
+
timestamp: timestamp3,
|
|
133997
134464
|
ssrc: context.ssrc,
|
|
133998
134465
|
kind: context.kind,
|
|
133999
134466
|
transportId,
|
|
@@ -134826,7 +135293,7 @@ var log41 = debug("werift:packages/webrtc/src/media/rtpSender.ts"), RTP_HISTORY_
|
|
|
134826
135293
|
getStatsRootIds() {
|
|
134827
135294
|
return [senderStatsIds(this.trackId).outboundRtp];
|
|
134828
135295
|
}
|
|
134829
|
-
collectStats(
|
|
135296
|
+
collectStats(timestamp3) {
|
|
134830
135297
|
return this.stats.collect(
|
|
134831
135298
|
{
|
|
134832
135299
|
trackId: this.trackId,
|
|
@@ -134838,12 +135305,12 @@ var log41 = debug("werift:packages/webrtc/src/media/rtpSender.ts"), RTP_HISTORY_
|
|
|
134838
135305
|
rtxSsrc: this.rtxPayloadType ? this.rtxSsrc : void 0,
|
|
134839
135306
|
trackIdentifier: this.track ? this.track.id ?? this.trackId : void 0
|
|
134840
135307
|
},
|
|
134841
|
-
|
|
135308
|
+
timestamp3
|
|
134842
135309
|
);
|
|
134843
135310
|
}
|
|
134844
135311
|
async getStats() {
|
|
134845
|
-
let
|
|
134846
|
-
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());
|
|
134847
135314
|
}
|
|
134848
135315
|
};
|
|
134849
135316
|
function sendCodecOf(codecs) {
|
|
@@ -136553,13 +137020,13 @@ var RETIRED_UFRAG_HISTORY = 64, NegotiationTransaction = class {
|
|
|
136553
137020
|
async close() {
|
|
136554
137021
|
this.sctpTransport && (await this.sctpTransport.stop(), await new Promise((resolve26) => setImmediate(resolve26))), this.onDataChannel.allUnsubscribe();
|
|
136555
137022
|
}
|
|
136556
|
-
async getStats(
|
|
137023
|
+
async getStats(timestamp3 = getStatsTimestamp()) {
|
|
136557
137024
|
let stats = [];
|
|
136558
137025
|
for (let channel of this.dataChannels) {
|
|
136559
137026
|
let channelStats = {
|
|
136560
137027
|
type: "data-channel",
|
|
136561
137028
|
id: generateStatsId("data-channel", channel.id ?? channel.statsId),
|
|
136562
|
-
timestamp:
|
|
137029
|
+
timestamp: timestamp3,
|
|
136563
137030
|
label: channel.label,
|
|
136564
137031
|
protocol: channel.protocol,
|
|
136565
137032
|
dataChannelIdentifier: channel.id ?? void 0,
|
|
@@ -137044,10 +137511,10 @@ var log44 = debug(
|
|
|
137044
137511
|
state2
|
|
137045
137512
|
));
|
|
137046
137513
|
}
|
|
137047
|
-
async getStats(
|
|
137514
|
+
async getStats(timestamp3) {
|
|
137048
137515
|
let stats = [];
|
|
137049
137516
|
for (let dtlsTransport of this.dtlsTransports) {
|
|
137050
|
-
let transportStats = await dtlsTransport.getStats(
|
|
137517
|
+
let transportStats = await dtlsTransport.getStats(timestamp3);
|
|
137051
137518
|
transportStats && stats.push(...transportStats);
|
|
137052
137519
|
}
|
|
137053
137520
|
return stats;
|
|
@@ -138267,21 +138734,21 @@ var srtpProfiles = [
|
|
|
138267
138734
|
setSignalingState(state2) {
|
|
138268
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"));
|
|
138269
138736
|
}
|
|
138270
|
-
createPeerConnectionStats(
|
|
138737
|
+
createPeerConnectionStats(timestamp3) {
|
|
138271
138738
|
return {
|
|
138272
138739
|
type: "peer-connection",
|
|
138273
138740
|
id: generateStatsId("peer-connection", this.id),
|
|
138274
|
-
timestamp:
|
|
138741
|
+
timestamp: timestamp3,
|
|
138275
138742
|
dataChannelsOpened: this.sctpManager.dataChannelsOpened,
|
|
138276
138743
|
dataChannelsClosed: this.sctpManager.dataChannelsClosed
|
|
138277
138744
|
};
|
|
138278
138745
|
}
|
|
138279
138746
|
async getStats(selector) {
|
|
138280
|
-
let
|
|
138281
|
-
selector || stats.push(this.createPeerConnectionStats(
|
|
138282
|
-
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);
|
|
138283
138750
|
if (stats.push(...transportStats), !selector && this.sctpTransport) {
|
|
138284
|
-
let dataChannelStats = await this.sctpManager.getStats(
|
|
138751
|
+
let dataChannelStats = await this.sctpManager.getStats(timestamp3);
|
|
138285
138752
|
dataChannelStats && stats.push(...dataChannelStats);
|
|
138286
138753
|
}
|
|
138287
138754
|
return selector ? buildStatsReport(
|
|
@@ -140388,13 +140855,13 @@ var Workspaces = class {
|
|
|
140388
140855
|
remoteGroups = [];
|
|
140389
140856
|
officialPinnedWorkspaceIds = [];
|
|
140390
140857
|
publishedPinnedWorkspaces = [];
|
|
140391
|
-
setRemoteGroups(
|
|
140858
|
+
setRemoteGroups(groups2) {
|
|
140392
140859
|
let previousOrder = this.list().map((group) => group.workspaceId), previous = new Map(this.remoteGroups.map((group) => [group.workspaceId, group]));
|
|
140393
|
-
this.remoteGroups =
|
|
140394
|
-
let current = new Set(
|
|
140860
|
+
this.remoteGroups = groups2;
|
|
140861
|
+
let current = new Set(groups2.map((group) => group.workspaceId));
|
|
140395
140862
|
for (let id2 of previous.keys())
|
|
140396
140863
|
current.has(id2) || this.broadcast({ type: "remove", workspaceId: id2 });
|
|
140397
|
-
for (let workspace of
|
|
140864
|
+
for (let workspace of groups2)
|
|
140398
140865
|
JSON.stringify(previous.get(workspace.workspaceId)) !== JSON.stringify(workspace) && this.broadcast({ type: "upsert", workspace });
|
|
140399
140866
|
let nextOrder = this.list().map((group) => group.workspaceId);
|
|
140400
140867
|
JSON.stringify(previousOrder) !== JSON.stringify(nextOrder) && this.broadcast({
|
|
@@ -140513,9 +140980,9 @@ var Workspaces = class {
|
|
|
140513
140980
|
get usesNativeProjects() {
|
|
140514
140981
|
return this.nativeWorkspaces !== void 0;
|
|
140515
140982
|
}
|
|
140516
|
-
syncNativeProjects(projects,
|
|
140983
|
+
syncNativeProjects(projects, groups2, legacyAssignments, roots) {
|
|
140517
140984
|
let before = this.list(), previous = new Map(this.nativeWorkspaces?.map((item) => [item.projectId, item])), members2 = /* @__PURE__ */ new Map();
|
|
140518
|
-
for (let [sessionId, projectId] of
|
|
140985
|
+
for (let [sessionId, projectId] of groups2) {
|
|
140519
140986
|
if (projectId === void 0) continue;
|
|
140520
140987
|
let entries = members2.get(projectId) ?? [];
|
|
140521
140988
|
members2.has(projectId) || members2.set(projectId, entries), entries.push(sessionId);
|
|
@@ -140563,9 +141030,9 @@ var Workspaces = class {
|
|
|
140563
141030
|
next2.length !== workspace.sessionIds.length && (workspace.sessionIds = next2, this.broadcast({ type: "upsert", workspace }));
|
|
140564
141031
|
return;
|
|
140565
141032
|
}
|
|
140566
|
-
let before = this.list(),
|
|
141033
|
+
let before = this.list(), groups2 = new Map(this.referenceGroups), projectless = new Set(this.referenceProjectless);
|
|
140567
141034
|
for (let id2 of sessionIds)
|
|
140568
|
-
|
|
141035
|
+
groups2.set(id2, workspace.path), projectless.delete(id2);
|
|
140569
141036
|
if ([.../* @__PURE__ */ new Set([...workspace.sessionIds, ...sessionIds])].length !== workspace.sessionIds.length) {
|
|
140570
141037
|
let state2 = {
|
|
140571
141038
|
...this.state,
|
|
@@ -140575,7 +141042,7 @@ var Workspaces = class {
|
|
|
140575
141042
|
};
|
|
140576
141043
|
this.data.writeJson(FILE2, state2), this.state = state2;
|
|
140577
141044
|
}
|
|
140578
|
-
this.referenceGroups =
|
|
141045
|
+
this.referenceGroups = groups2, this.referenceProjectless = projectless, this.publishWorkspaceChanges(before);
|
|
140579
141046
|
}
|
|
140580
141047
|
/** Show a session only in its native project, at the requested place; Codex owns membership. */
|
|
140581
141048
|
placeNativeSession(workspaceId, sessionId, beforeSessionId) {
|
|
@@ -140605,9 +141072,9 @@ var Workspaces = class {
|
|
|
140605
141072
|
projectless
|
|
140606
141073
|
);
|
|
140607
141074
|
}
|
|
140608
|
-
setReferenceGroups(
|
|
141075
|
+
setReferenceGroups(groups2, projectless = /* @__PURE__ */ new Set()) {
|
|
140609
141076
|
let before = this.list();
|
|
140610
|
-
this.referenceGroups =
|
|
141077
|
+
this.referenceGroups = groups2, this.referenceProjectless = projectless;
|
|
140611
141078
|
let after = this.list(), ids = new Set(after.map((workspace) => workspace.workspaceId));
|
|
140612
141079
|
for (let workspace of before)
|
|
140613
141080
|
ids.has(workspace.workspaceId) || this.broadcast({ type: "remove", workspaceId: workspace.workspaceId });
|
|
@@ -140921,11 +141388,12 @@ var Workspaces = class {
|
|
|
140921
141388
|
}
|
|
140922
141389
|
byExactPath(path7) {
|
|
140923
141390
|
if (this.nativeWorkspaces) {
|
|
140924
|
-
|
|
141391
|
+
if (!isAbsolute20(path7)) return;
|
|
141392
|
+
let absolute2 = resolve16(path7), multiRootMatch;
|
|
140925
141393
|
for (let item of this.nativeWorkspaces) {
|
|
140926
141394
|
if (!item.projectId) continue;
|
|
140927
141395
|
let roots = this.nativeRoots.get(item.projectId);
|
|
140928
|
-
if (roots?.
|
|
141396
|
+
if (roots?.some((root) => isAbsolute20(root) && resolve16(root) === absolute2)) {
|
|
140929
141397
|
if (roots.length === 1) return item;
|
|
140930
141398
|
multiRootMatch ??= item;
|
|
140931
141399
|
}
|
|
@@ -141038,7 +141506,7 @@ var Workspaces = class {
|
|
|
141038
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;
|
|
141039
141507
|
}
|
|
141040
141508
|
/** Mirror one complete CH workspace snapshot, saving and publishing only final changes. */
|
|
141041
|
-
syncReferencedSessions(sessions2,
|
|
141509
|
+
syncReferencedSessions(sessions2, groups2, projectless = /* @__PURE__ */ new Set(), projects = []) {
|
|
141042
141510
|
let before = new Map(
|
|
141043
141511
|
this.list().map((workspace) => [workspace.workspaceId, JSON.stringify(workspace)])
|
|
141044
141512
|
), items = this.state.items.map((workspace) => ({
|
|
@@ -141099,7 +141567,7 @@ var Workspaces = class {
|
|
|
141099
141567
|
};
|
|
141100
141568
|
this.data.writeJson(FILE2, state2), this.state = state2;
|
|
141101
141569
|
}
|
|
141102
|
-
this.referenceProjectRoots = rootPaths, this.referenceGroups =
|
|
141570
|
+
this.referenceProjectRoots = rootPaths, this.referenceGroups = groups2, this.referenceProjectless = projectless;
|
|
141103
141571
|
let after = this.list(), ids = new Set(after.map((workspace) => workspace.workspaceId));
|
|
141104
141572
|
for (let workspaceId of before.keys())
|
|
141105
141573
|
ids.has(workspaceId) || this.broadcast({ type: "remove", workspaceId });
|
|
@@ -141383,10 +141851,9 @@ var ChThreadEditing = class {
|
|
|
141383
141851
|
let dispatched = !1, reverted = !1;
|
|
141384
141852
|
try {
|
|
141385
141853
|
if (!displayed) throw new Error("Edit history expired. Reopen the conversation.");
|
|
141386
|
-
|
|
141854
|
+
if (!threadInspectionSchema.parse(
|
|
141387
141855
|
await host.request("codexhost/thread/inspect", { threadId })
|
|
141388
|
-
)
|
|
141389
|
-
if (owner.owner !== "external" || !owner.history.rollbackLastTurn)
|
|
141856
|
+
).history?.rollbackLastTurn)
|
|
141390
141857
|
throw new Error("This Harness does not support editing the last sent message.");
|
|
141391
141858
|
let view = await input3.read();
|
|
141392
141859
|
if (view !== displayed || view.thread.parentThreadId || view.thread.canAcceptDirectInput === !1)
|
|
@@ -142141,6 +142608,12 @@ function globalProjectionValues(values2) {
|
|
|
142141
142608
|
Object.entries(values2).filter(([key]) => !WEB_FOLLOW_PROJECTION_KEYS.has(key))
|
|
142142
142609
|
);
|
|
142143
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
|
+
}
|
|
142144
142617
|
var ChSessions = class {
|
|
142145
142618
|
constructor(host, workspaces2, events2, images2, files2, displayEntries2, preferences2, harnesses, openFile, fileSearchCache) {
|
|
142146
142619
|
this.host = host;
|
|
@@ -142236,6 +142709,10 @@ var ChSessions = class {
|
|
|
142236
142709
|
rows = /* @__PURE__ */ new Map();
|
|
142237
142710
|
publishedCatalog;
|
|
142238
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();
|
|
142239
142716
|
/** Loaded rows accumulate across partial official pages; drafts are not Host Threads. */
|
|
142240
142717
|
threads = new WebThreadStates();
|
|
142241
142718
|
nativeGoals;
|
|
@@ -142590,13 +143067,13 @@ var ChSessions = class {
|
|
|
142590
143067
|
async syncWorkspace(timing = new SessionListTiming(), snapshot) {
|
|
142591
143068
|
let projects = snapshot ?? await timing.measure("projects", () => this.host.projects([...this.rows.keys()]));
|
|
142592
143069
|
timing.count("projects", projects.projects.length), !this.closed && timing.measureSync("workspace_sync", () => {
|
|
142593
|
-
let
|
|
143070
|
+
let groups2 = /* @__PURE__ */ new Map();
|
|
142594
143071
|
if (projects.nativeProjects) {
|
|
142595
143072
|
let roots = nativeProjectRootOwners(projects.projects), projectFor = this.nativeProjectResolver(projects, roots);
|
|
142596
|
-
for (let row of this.rows.values())
|
|
143073
|
+
for (let row of this.rows.values()) groups2.set(row.id, projectFor(row));
|
|
142597
143074
|
for (let draft of this.drafts.values())
|
|
142598
|
-
draft.canonicalId ||
|
|
142599
|
-
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);
|
|
142600
143077
|
return;
|
|
142601
143078
|
}
|
|
142602
143079
|
if (this.workspaces.usesNativeProjects) return;
|
|
@@ -142604,7 +143081,7 @@ var ChSessions = class {
|
|
|
142604
143081
|
for (let row of this.rows.values()) {
|
|
142605
143082
|
row.workspaceKind === "projectless" && !row.projectId && !projects.assignments[row.id] && projectless.add(row.id);
|
|
142606
143083
|
let root = row.cwd && !projectless.has(row.id) ? projectGroupRoot(projects, row.id, row.cwd) : void 0;
|
|
142607
|
-
if (
|
|
143084
|
+
if (groups2.set(row.id, root), root) {
|
|
142608
143085
|
let title = projects.projects.find((project3) => project3.rootPaths.includes(root)) === void 0 ? void 0 : rootTitles.get(resolve19(root));
|
|
142609
143086
|
references.push({
|
|
142610
143087
|
sessionId: row.id,
|
|
@@ -142614,8 +143091,8 @@ var ChSessions = class {
|
|
|
142614
143091
|
}
|
|
142615
143092
|
}
|
|
142616
143093
|
for (let draft of this.drafts.values())
|
|
142617
|
-
draft.canonicalId || (
|
|
142618
|
-
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);
|
|
142619
143096
|
});
|
|
142620
143097
|
}
|
|
142621
143098
|
nativeProjectResolver(projects, roots = nativeProjectRootOwners(projects.projects)) {
|
|
@@ -142645,15 +143122,21 @@ var ChSessions = class {
|
|
|
142645
143122
|
this.archiveForkParent(row),
|
|
142646
143123
|
row.canAcceptDirectInput !== !1,
|
|
142647
143124
|
row.codexhostImportSource ?? null,
|
|
142648
|
-
this.threads.harnessId(row.id)
|
|
143125
|
+
this.threads.harnessId(row.id),
|
|
143126
|
+
this.roleSnapshotOf(row)
|
|
142649
143127
|
]);
|
|
142650
143128
|
}
|
|
143129
|
+
roleSnapshotOf(row) {
|
|
143130
|
+
let parsed = threadRoleSnapshotSchema.safeParse(row.roleSnapshot);
|
|
143131
|
+
return parsed.success ? parsed.data : this.roleSnapshots.get(row.id) ?? null;
|
|
143132
|
+
}
|
|
142651
143133
|
catalogProjections(row) {
|
|
142652
143134
|
return {
|
|
142653
143135
|
title: threadListTitle(row),
|
|
142654
143136
|
threadTreeParent: this.tree.parent(row.id),
|
|
142655
143137
|
archiveForkParent: this.archiveForkParent(row),
|
|
142656
|
-
codexhostImportSource: row.codexhostImportSource ?? null
|
|
143138
|
+
codexhostImportSource: row.codexhostImportSource ?? null,
|
|
143139
|
+
roleSnapshot: this.roleSnapshotOf(row)
|
|
142657
143140
|
};
|
|
142658
143141
|
}
|
|
142659
143142
|
async publishCatalogChanges(timing, headIds, sectionIds, archivedIds, archiveChanges, deletedIds) {
|
|
@@ -142699,7 +143182,7 @@ var ChSessions = class {
|
|
|
142699
143182
|
next.has(row.sessionId) && this.events.emit("api-session/added", row);
|
|
142700
143183
|
if (before)
|
|
142701
143184
|
for (let id2 of before.keys())
|
|
142702
|
-
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));
|
|
142703
143186
|
}
|
|
142704
143187
|
}
|
|
142705
143188
|
async owner(id2) {
|
|
@@ -142709,7 +143192,16 @@ var ChSessions = class {
|
|
|
142709
143192
|
let inspection = threadInspectionSchema.parse(
|
|
142710
143193
|
await this.host.request("codexhost/thread/inspect", { threadId: resolved })
|
|
142711
143194
|
);
|
|
142712
|
-
|
|
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 {
|
|
142713
143205
|
...inspection,
|
|
142714
143206
|
harnessId: inspection.owner === "codex" ? "codex" : inspection.harnessId
|
|
142715
143207
|
};
|
|
@@ -142787,12 +143279,18 @@ var ChSessions = class {
|
|
|
142787
143279
|
), view.log.setProjection(
|
|
142788
143280
|
"nativeDiscovery",
|
|
142789
143281
|
!view.thread.parentThreadId && view.thread.canAcceptDirectInput !== !1
|
|
142790
|
-
), view.ownerSnapshot ? (this.handoffs.set(id2, view.ownerSnapshot.handoff ?? null), view.log.setProjection(WEB_HANDOFF_PROJECTION, view.ownerSnapshot.handoff ?? null)) : this.handoffs.has(id2) && view.log.setProjection(WEB_HANDOFF_PROJECTION, this.handoffs.get(id2) ?? null), (this.threads.get(id2)?.configurationRevision ?? 0) === configurationRevision) {
|
|
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) {
|
|
142791
143283
|
let mode = view.ownerSnapshot?.configuration.codexCollaborationMode;
|
|
142792
143284
|
this.projectCodexPlanMode(
|
|
142793
143285
|
view,
|
|
142794
143286
|
harnessId === "codex" && !view.thread.parentThreadId && view.thread.canAcceptDirectInput !== !1 && mode !== void 0 ? mode === "plan" : null
|
|
142795
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));
|
|
142796
143294
|
}
|
|
142797
143295
|
view.ownerSnapshot && this.hostOnline && !this.closed && (this.syncedRunningInteractions.add(id2), this.interactions?.update(view.ownerSnapshot)), this.realtime && view.log.setProjection("nativeConnection", {
|
|
142798
143296
|
state: this.hostOnline ? "connected" : "reconnecting"
|
|
@@ -142834,34 +143332,39 @@ var ChSessions = class {
|
|
|
142834
143332
|
}
|
|
142835
143333
|
})();
|
|
142836
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
|
+
}
|
|
142837
143346
|
loadControls(view, harnessId, force, configurationRevision) {
|
|
142838
143347
|
let id2 = view.thread.id;
|
|
142839
143348
|
if ((this.threads.get(id2)?.configurationRevision ?? 0) !== configurationRevision || !force && this.threads.get(id2)?.controls) return;
|
|
142840
|
-
let loading =
|
|
142841
|
-
view.ownerSnapshot ? Promise.resolve(
|
|
142842
|
-
|
|
142843
|
-
|
|
142844
|
-
|
|
142845
|
-
return;
|
|
142846
|
-
|
|
142847
|
-
|
|
142848
|
-
|
|
142849
|
-
|
|
142850
|
-
|
|
142851
|
-
|
|
142852
|
-
|
|
142853
|
-
|
|
142854
|
-
)
|
|
142855
|
-
|
|
142856
|
-
|
|
142857
|
-
model: owner.effectiveModel ? harnessModelRefKey(owner.effectiveModel) : "harness",
|
|
142858
|
-
...owner.effectiveThinkingOptionId ? { reasoningEffort: owner.effectiveThinkingOptionId } : {}
|
|
142859
|
-
};
|
|
142860
|
-
view.log.setProjection("modelSelection", { lastUsed: selection2, next: selection2 });
|
|
142861
|
-
}).catch(() => {
|
|
142862
|
-
}).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(() => {
|
|
142863
143366
|
let current = this.threads.get(id2);
|
|
142864
|
-
current
|
|
143367
|
+
current && current.controls === loading && delete current.controls;
|
|
142865
143368
|
});
|
|
142866
143369
|
this.threads.ensure(id2).controls = loading;
|
|
142867
143370
|
}
|
|
@@ -142885,6 +143388,7 @@ var ChSessions = class {
|
|
|
142885
143388
|
threadReference: { hostId: "local" },
|
|
142886
143389
|
title: threadListTitle(row),
|
|
142887
143390
|
codexhostImportSource: row.codexhostImportSource ?? null,
|
|
143391
|
+
roleSnapshot: this.roleSnapshotOf(row),
|
|
142888
143392
|
harnessIdentity: { id: harnessId, name: await this.catalog.name(harnessId) },
|
|
142889
143393
|
sessionListMetadata: { blank: !1, lastPromptAt: threadRecencyMs(row) }
|
|
142890
143394
|
};
|
|
@@ -142938,7 +143442,7 @@ var ChSessions = class {
|
|
|
142938
143442
|
this.planChanges.delete(id2), this.realtime?.invalidate(id2);
|
|
142939
143443
|
}
|
|
142940
143444
|
}
|
|
142941
|
-
async draftSummary(draft, includeControls = !0) {
|
|
143445
|
+
async draftSummary(draft, includeControls = !0, includeClearedRole = !1) {
|
|
142942
143446
|
let controls;
|
|
142943
143447
|
do {
|
|
142944
143448
|
let provider = draft.selection.provider, [inspection2, supportsPlan2, name3] = await Promise.all([
|
|
@@ -142967,8 +143471,10 @@ var ChSessions = class {
|
|
|
142967
143471
|
imageLimits: WEB_IMAGE_LIMITS
|
|
142968
143472
|
} : {},
|
|
142969
143473
|
modelSelection: { lastUsed: null, next: draft.selection },
|
|
142970
|
-
codexPlanMode: draft.selection.provider === "codex" && supportsPlan ? draft.codexPlanMode === !0 : null
|
|
142971
|
-
|
|
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 } : {},
|
|
142972
143478
|
harnessIdentity: {
|
|
142973
143479
|
id: draft.selection.provider,
|
|
142974
143480
|
name: name2
|
|
@@ -142988,12 +143494,16 @@ var ChSessions = class {
|
|
|
142988
143494
|
};
|
|
142989
143495
|
}
|
|
142990
143496
|
async create(args, configuration) {
|
|
142991
|
-
let request3 = requestOf(args), workspace = request3.workspaceId ? this.workspaces.get(request3.workspaceId) : void 0, cwd = request3.cwd ?? workspace?.path, byCwd = cwd ? this.workspaces.byPath(resolve19(cwd)) : void 0, projectId = workspace?.projectId ?? (cwd && this.workspaces.usesNativeProjects ? byCwd?.projectId : void 0), project2 = workspace ?? byCwd, projectHarnessId2 = !configuration && project2 ? projectHarnessId(this.workspaces, project2.workspaceId) : void 0;
|
|
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;
|
|
142992
143498
|
if ((request3.workspaceId !== void 0 || request3.cwd !== void 0) && !cwd)
|
|
142993
143499
|
throw new SessionRuntimeError("workspace/invalid-path", "Choose a valid computer working directory.");
|
|
142994
143500
|
let id2 = request3.sessionId ?? `draft-${randomUUID23()}`, existing = this.drafts.get(id2);
|
|
142995
143501
|
if (existing && !existing.canonicalId && !existing.creating && !existing.started && existing.cwd === cwd && existing.projectId === projectId) {
|
|
142996
|
-
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") {
|
|
142997
143507
|
if (existing.projectHarnessId !== projectHarnessId2)
|
|
142998
143508
|
throw new SessionRuntimeError("session/writer-held", "Start a new draft with the project default.", {
|
|
142999
143509
|
sessionId: id2
|
|
@@ -143017,7 +143527,7 @@ var ChSessions = class {
|
|
|
143017
143527
|
if (existing || this.rows.has(id2))
|
|
143018
143528
|
throw new SessionRuntimeError("session/busy", "This Session already exists; start a new draft.");
|
|
143019
143529
|
let preferences2 = configuration ? void 0 : this.preferences?.get().catch(() => {
|
|
143020
|
-
}), 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);
|
|
143021
143531
|
if (!selection2)
|
|
143022
143532
|
throw new SessionRuntimeError(
|
|
143023
143533
|
"host/no-harness",
|
|
@@ -143028,6 +143538,7 @@ var ChSessions = class {
|
|
|
143028
143538
|
...cwd ? { cwd } : {},
|
|
143029
143539
|
...projectId ? { projectId } : {},
|
|
143030
143540
|
...projectHarnessId2 ? { projectHarnessId: projectHarnessId2 } : {},
|
|
143541
|
+
...typeof roleSlug == "string" ? { roleSlug, explicitSelection: !0 } : {},
|
|
143031
143542
|
selection: selection2,
|
|
143032
143543
|
createdAt: Date.now()
|
|
143033
143544
|
};
|
|
@@ -143044,6 +143555,25 @@ var ChSessions = class {
|
|
|
143044
143555
|
if (this.closed) throw new SessionRuntimeError("session/closed", "Web sessions are closing.");
|
|
143045
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" });
|
|
143046
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
|
+
}
|
|
143047
143577
|
/** Materialize a source-neutral draft without reading or writing global defaults. */
|
|
143048
143578
|
async prepareDraft(request3, configuration) {
|
|
143049
143579
|
await this.create({ request: request3 }, configuration);
|
|
@@ -143068,6 +143598,7 @@ var ChSessions = class {
|
|
|
143068
143598
|
(item) => item.id === draft.selection.provider
|
|
143069
143599
|
), result = await this.host.request("thread/start", {
|
|
143070
143600
|
historyMode: "paginated",
|
|
143601
|
+
...draft.roleSlug ? { roleSlug: draft.roleSlug } : {},
|
|
143071
143602
|
...draft.projectId ? { projectId: draft.projectId } : {},
|
|
143072
143603
|
...draft.cwd ? { cwd: draft.cwd } : { projectlessWorkspace: { prompt: prompt.slice(0, 16384) } },
|
|
143073
143604
|
...plugin ? {
|
|
@@ -143214,12 +143745,12 @@ var ChSessions = class {
|
|
|
143214
143745
|
}
|
|
143215
143746
|
syncBackgroundRunningInteractions() {
|
|
143216
143747
|
for (let row of this.rows.values())
|
|
143217
|
-
row.status.type === "active" ? !this.syncedRunningInteractions.has(row.id) && !this.interactionReads.has(row.id) && !this.threads.view(row.id) && this.reconcileBackgroundInteractions(row.id) :
|
|
143748
|
+
row.status.type === "active" ? !this.syncedRunningInteractions.has(row.id) && !this.interactionReads.has(row.id) && !this.threads.view(row.id) && this.reconcileBackgroundInteractions(row.id) : this.syncedRunningInteractions.delete(row.id) && this.interactions?.hasPending(row.id) && !this.threads.view(row.id) && this.reconcileBackgroundInteractions(row.id);
|
|
143218
143749
|
}
|
|
143219
143750
|
forgetDeleted(id2) {
|
|
143220
143751
|
this.refreshingDeletedIds?.add(id2), this.archiveOperations.delete(id2), this.queueOperations.delete(id2), this.titleRequests.delete(id2), this.syncedRunningInteractions.delete(id2);
|
|
143221
143752
|
let activeRead = this.interactionReads.get(id2);
|
|
143222
|
-
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);
|
|
143223
143754
|
let archived = this.workspaces.localArchivedSessionIds();
|
|
143224
143755
|
archived.includes(id2) && this.workspaces.setReferenceArchives(archived.filter((item) => item !== id2));
|
|
143225
143756
|
let pinned = this.workspaces.localPinnedSessionIds();
|
|
@@ -143484,8 +144015,9 @@ var ChSessions = class {
|
|
|
143484
144015
|
let request3 = requestOf(args);
|
|
143485
144016
|
return this.catalog.models(request3?.refresh === !0, request3?.harnessId);
|
|
143486
144017
|
}), rpc2.register("session/selectModel", async (args) => {
|
|
143487
|
-
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);
|
|
143488
144019
|
if (draft && !draft.canonicalId) {
|
|
144020
|
+
let roleSlug = requestedRoleSlug(rawRoleSlug);
|
|
143489
144021
|
if (draft.creating || draft.started)
|
|
143490
144022
|
throw new SessionRuntimeError("session/busy", "Draft creation is in progress.");
|
|
143491
144023
|
let before = draft.selection;
|
|
@@ -143501,7 +144033,8 @@ var ChSessions = class {
|
|
|
143501
144033
|
);
|
|
143502
144034
|
delete draft.codexPlanMode, delete draft.permissionModeId, permissionModeId && (draft.permissionModeId = permissionModeId);
|
|
143503
144035
|
}
|
|
143504
|
-
|
|
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, {
|
|
143505
144038
|
model: model2,
|
|
143506
144039
|
thinkingOptionId: request3.reasoningEffort,
|
|
143507
144040
|
permissionModeId: draft.permissionModeId
|
|
@@ -143510,7 +144043,10 @@ var ChSessions = class {
|
|
|
143510
144043
|
"codexhost/preferences-error",
|
|
143511
144044
|
"New session defaults could not be saved."
|
|
143512
144045
|
)
|
|
143513
|
-
), this.events.emit(
|
|
144046
|
+
), this.events.emit(
|
|
144047
|
+
"api-session/added",
|
|
144048
|
+
await this.draftSummary(draft, !1, hadRole && draft.roleSlug === void 0)
|
|
144049
|
+
);
|
|
143514
144050
|
for (let sink of this.controls) {
|
|
143515
144051
|
let s = await this.draftSummary(draft);
|
|
143516
144052
|
for (let [key, value] of Object.entries(s.projections.values))
|
|
@@ -143535,8 +144071,12 @@ var ChSessions = class {
|
|
|
143535
144071
|
provider: owner.harnessId,
|
|
143536
144072
|
model: harnessModelRefKey(configuration2.effectiveModel),
|
|
143537
144073
|
...configuration2.effectiveThinkingOptionId ? { reasoningEffort: configuration2.effectiveThinkingOptionId } : {}
|
|
143538
|
-
};
|
|
143539
|
-
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;
|
|
143540
144080
|
}, configuration = publish(
|
|
143541
144081
|
owner.owner === "codex" && sameHarnessModelRef(owner.effectiveModel, model2) ? {
|
|
143542
144082
|
effectiveModel: owner.effectiveModel,
|
|
@@ -144095,7 +144635,7 @@ var ChSessions = class {
|
|
|
144095
144635
|
if (draft && !draft.canonicalId) {
|
|
144096
144636
|
if (draft.creating || draft.started || draft.selection.provider !== harnessId)
|
|
144097
144637
|
throw new SessionRuntimeError("session/busy", "Draft selection changed.");
|
|
144098
|
-
draft.permissionModeId = modeId, await this.preferences?.remember(harnessId, {
|
|
144638
|
+
draft.permissionModeId = modeId, draft.roleSlug || await this.preferences?.remember(harnessId, {
|
|
144099
144639
|
model: harnessModelRefFromKey(draft.selection.model),
|
|
144100
144640
|
thinkingOptionId: draft.selection.reasoningEffort,
|
|
144101
144641
|
permissionModeId: modeId
|
|
@@ -144453,7 +144993,21 @@ var exec3 = promisify7(execFile6), METHODS = /* @__PURE__ */ new Set([
|
|
|
144453
144993
|
THREAD_HANDOFF_METHOD,
|
|
144454
144994
|
"codexhost/harness/session-import/sources",
|
|
144455
144995
|
"codexhost/harness/session-import/list",
|
|
144456
|
-
"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
|
|
144457
145011
|
]);
|
|
144458
145012
|
async function requestPins(request3, change) {
|
|
144459
145013
|
let value = await request3(
|
|
@@ -144660,7 +145214,7 @@ async function serveChClientGateway(host, request3, response, { authenticated =
|
|
|
144660
145214
|
let after = url2.searchParams.has("epoch") ? clientChannelCursorSchema.parse({
|
|
144661
145215
|
epoch: url2.searchParams.get("epoch"),
|
|
144662
145216
|
sequence: Number(url2.searchParams.get("after"))
|
|
144663
|
-
}) : 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) => {
|
|
144664
145218
|
if (event.type === "connection") {
|
|
144665
145219
|
!event.online && !response.writableEnded && !response.destroyed && (response.headersSent ? response.end() : response.writeHead(503, {
|
|
144666
145220
|
"content-type": "application/json; charset=utf-8",
|
|
@@ -144676,7 +145230,7 @@ async function serveChClientGateway(host, request3, response, { authenticated =
|
|
|
144676
145230
|
response.destroy();
|
|
144677
145231
|
return;
|
|
144678
145232
|
}
|
|
144679
|
-
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;
|
|
144680
145234
|
response.write(JSON.stringify(frame) + `
|
|
144681
145235
|
`);
|
|
144682
145236
|
}, after), heartbeat = setInterval(() => {
|
|
@@ -145764,6 +146318,7 @@ ${head.join(`
|
|
|
145764
146318
|
".webmanifest": "application/manifest+json; charset=utf-8",
|
|
145765
146319
|
".svg": "image/svg+xml",
|
|
145766
146320
|
".png": "image/png",
|
|
146321
|
+
".webp": "image/webp",
|
|
145767
146322
|
".ico": "image/x-icon",
|
|
145768
146323
|
".woff2": "font/woff2",
|
|
145769
146324
|
".woff": "font/woff",
|
|
@@ -145983,10 +146538,474 @@ async function serveFileUpload(sessions2, request3, response, viaRelay = !1, rem
|
|
|
145983
146538
|
}
|
|
145984
146539
|
}
|
|
145985
146540
|
|
|
145986
|
-
// 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
|
|
145987
146835
|
import { randomUUID as randomUUID25 } from "node:crypto";
|
|
145988
|
-
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";
|
|
145989
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";
|
|
145990
147009
|
function registerVoiceStatus(rpc2, host) {
|
|
145991
147010
|
rpc2.register("codexhost/voice/status", async () => {
|
|
145992
147011
|
try {
|
|
@@ -146019,8 +147038,8 @@ async function serveVoiceTranscription(host, dataRoot2, request3, response) {
|
|
|
146019
147038
|
send(413, voiceFailure("audio-too-large"));
|
|
146020
147039
|
return;
|
|
146021
147040
|
}
|
|
146022
|
-
let directory =
|
|
146023
|
-
await
|
|
147041
|
+
let directory = join34(dataRoot2, "voice");
|
|
147042
|
+
await mkdir8(directory, { recursive: !0, mode: 448 }), path7 = join34(directory, randomUUID26());
|
|
146024
147043
|
let file3 = await open12(path7, "wx", 384), size = 0;
|
|
146025
147044
|
try {
|
|
146026
147045
|
for await (let chunk of request3.iterator({ destroyOnReturn: !1 })) {
|
|
@@ -146049,63 +147068,63 @@ async function serveVoiceTranscription(host, dataRoot2, request3, response) {
|
|
|
146049
147068
|
} catch {
|
|
146050
147069
|
send(200, voiceFailure("network"));
|
|
146051
147070
|
} finally {
|
|
146052
|
-
path7 && await
|
|
147071
|
+
path7 && await rm8(path7, { force: !0 }), request3.resume();
|
|
146053
147072
|
}
|
|
146054
147073
|
}
|
|
146055
147074
|
|
|
146056
147075
|
// packages/web-server/src/data-paths.ts
|
|
146057
147076
|
import { homedir as homedir10 } from "node:os";
|
|
146058
|
-
import { join as
|
|
147077
|
+
import { join as join35, resolve as resolve24 } from "node:path";
|
|
146059
147078
|
function defaultWebDataDirectory(hostDataDirectory) {
|
|
146060
|
-
return
|
|
147079
|
+
return join35(resolve24(hostDataDirectory ?? join35(homedir10(), ".codexhost")), "web");
|
|
146061
147080
|
}
|
|
146062
147081
|
|
|
146063
147082
|
// packages/web-server/src/packaged-host.ts
|
|
146064
147083
|
import { createHash as createHash17 } from "node:crypto";
|
|
146065
|
-
import { cp, mkdir as
|
|
146066
|
-
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";
|
|
146067
147086
|
async function hashDirectory(root, hash4, relative14 = "") {
|
|
146068
|
-
for (let name2 of (await readdir10(
|
|
146069
|
-
let file3 =
|
|
146070
|
-
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))));
|
|
146071
147090
|
}
|
|
146072
147091
|
}
|
|
146073
147092
|
async function snapshotPackagedHost(distribution, data2) {
|
|
146074
|
-
let builds =
|
|
146075
|
-
await
|
|
146076
|
-
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-"));
|
|
146077
147096
|
try {
|
|
146078
|
-
await
|
|
147097
|
+
await mkdir9(join36(staging, "app")), await cp(join36(distribution, "app/host-runtime.mjs"), join36(staging, "app/host-runtime.mjs"));
|
|
146079
147098
|
for (let directory of ["native", "adapters"])
|
|
146080
|
-
await cp(
|
|
147099
|
+
await cp(join36(distribution, directory), join36(staging, directory), {
|
|
146081
147100
|
recursive: !0,
|
|
146082
147101
|
dereference: !0
|
|
146083
147102
|
});
|
|
146084
147103
|
let hash4 = createHash17("sha256");
|
|
146085
147104
|
await hashDirectory(staging, hash4);
|
|
146086
|
-
let destination =
|
|
147105
|
+
let destination = join36(builds, hash4.digest("hex"));
|
|
146087
147106
|
try {
|
|
146088
|
-
await
|
|
147107
|
+
await rename6(staging, destination);
|
|
146089
147108
|
} catch (error62) {
|
|
146090
147109
|
if (!(await stat14(destination).catch(() => null))?.isDirectory()) throw error62;
|
|
146091
147110
|
}
|
|
146092
147111
|
return destination;
|
|
146093
147112
|
} finally {
|
|
146094
|
-
await
|
|
147113
|
+
await rm9(staging, { recursive: !0, force: !0 });
|
|
146095
147114
|
}
|
|
146096
147115
|
}
|
|
146097
147116
|
|
|
146098
147117
|
// packages/web-server/src/main.ts
|
|
146099
|
-
var RELEASE_WEB = !0, DISTRIBUTION_ROOT = resolve25(import.meta.dirname, ".."), PACKED_WEB =
|
|
146100
|
-
"0.
|
|
146101
|
-
[
|
|
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")]
|
|
146102
147121
|
);
|
|
146103
147122
|
if (PACKED) {
|
|
146104
|
-
let runner =
|
|
147123
|
+
let runner = join37(import.meta.dirname, "subprocess-runner.mjs");
|
|
146105
147124
|
existsSync16(runner) && (process.env.CODEXHOST_SUBPROCESS_RUNNER ??= runner);
|
|
146106
147125
|
}
|
|
146107
147126
|
function defaultAdapterRoots() {
|
|
146108
|
-
return PACKED ?
|
|
147127
|
+
return PACKED ? join37(DISTRIBUTION_ROOT, "adapters") : resolve25(REPO_ROOT, "packages/host-runtime/dist/plugins");
|
|
146109
147128
|
}
|
|
146110
147129
|
var developmentOptions = {
|
|
146111
147130
|
"ch-cdp": { type: "string" },
|
|
@@ -146135,7 +147154,7 @@ var developmentOptions = {
|
|
|
146135
147154
|
harness: { type: "string", default: process.env.CODEXHOST_HARNESSES },
|
|
146136
147155
|
workspace: {
|
|
146137
147156
|
type: "string",
|
|
146138
|
-
default: process.env.CODEXHOST_DEFAULT_WORKSPACE ??
|
|
147157
|
+
default: process.env.CODEXHOST_DEFAULT_WORKSPACE ?? join37(homedir11(), "codexhost-workspace")
|
|
146139
147158
|
},
|
|
146140
147159
|
token: { type: "string", default: process.env.CODEXHOST_WEB_TOKEN },
|
|
146141
147160
|
"trusted-proxy": { type: "string" },
|
|
@@ -146162,9 +147181,9 @@ if (values["save-service-options"])
|
|
|
146162
147181
|
var serviceOptions = readServiceOptions(data), background = values.background ? serviceOptions : void 0;
|
|
146163
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");
|
|
146164
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(
|
|
146165
|
-
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"))
|
|
146166
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(
|
|
146167
|
-
values["ch-launcher"] ?? (PACKED ?
|
|
147186
|
+
values["ch-launcher"] ?? (PACKED ? join37(packagedHost, "native", process.platform === "win32" ? "codexhost.exe" : "codexhost") : join37(
|
|
146168
147187
|
REPO_ROOT,
|
|
146169
147188
|
"target/debug",
|
|
146170
147189
|
process.platform === "win32" ? "codexhost.exe" : "codexhost"
|
|
@@ -146174,16 +147193,16 @@ var publicUrl = background ? background.publicUrl : values["public-url"] ?? proc
|
|
|
146174
147193
|
launcher,
|
|
146175
147194
|
...values["ch-node"] ? { node: resolve25(values["ch-node"]) } : {},
|
|
146176
147195
|
runtime: resolve25(
|
|
146177
|
-
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"))
|
|
146178
147197
|
),
|
|
146179
147198
|
dataDirectory: resolve25(
|
|
146180
|
-
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"))
|
|
146181
147200
|
),
|
|
146182
|
-
bundledPlugins: PACKED && pluginSource === resolve25(DISTRIBUTION_ROOT, "adapters") ?
|
|
147201
|
+
bundledPlugins: PACKED && pluginSource === resolve25(DISTRIBUTION_ROOT, "adapters") ? join37(packagedHost, "adapters") : pluginSource,
|
|
146183
147202
|
...values["ch-codex-home"] ? { codexHome: resolve25(values["ch-codex-home"]) } : {},
|
|
146184
147203
|
environment: npmEntrypoint
|
|
146185
147204
|
},
|
|
146186
|
-
...values["ch-data"] && !values["ch-control-directory"] ? { directory:
|
|
147205
|
+
...values["ch-data"] && !values["ch-control-directory"] ? { directory: join37(resolve25(values["ch-data"]), "client-hosts") } : {},
|
|
146187
147206
|
...values["ch-cdp"] ? { cdp: values["ch-cdp"] } : {},
|
|
146188
147207
|
...values["ch-control-directory"] ? { directory: values["ch-control-directory"] } : {}
|
|
146189
147208
|
}), displaySettings = new WebHarnessDisplaySettings(
|
|
@@ -146208,7 +147227,7 @@ var publicUrl = background ? background.publicUrl : values["public-url"] ?? proc
|
|
|
146208
147227
|
...RELEASE_WEB ? {
|
|
146209
147228
|
ensureOfficeEngine: createOfficeEngine(
|
|
146210
147229
|
dataRoot,
|
|
146211
|
-
JSON.parse(readFileSync18(
|
|
147230
|
+
JSON.parse(readFileSync18(join37(import.meta.dirname, "office-engines.json"), "utf8"))
|
|
146212
147231
|
)
|
|
146213
147232
|
} : {}
|
|
146214
147233
|
}).catch((error62) => {
|
|
@@ -146258,7 +147277,7 @@ if (!values["safe-mode"])
|
|
|
146258
147277
|
builtins: builtInAssets.clientSources(),
|
|
146259
147278
|
address: () => ({ host: values.host, port: listeningPort }),
|
|
146260
147279
|
reserved: [
|
|
146261
|
-
...["/api", "/plugins", "/assets", "/harness-icons"].map((path7) => ({
|
|
147280
|
+
...["/api", "/plugins", "/assets", "/harness-icons", "/role-avatars"].map((path7) => ({
|
|
146262
147281
|
kind: "prefix",
|
|
146263
147282
|
path: path7
|
|
146264
147283
|
})),
|
|
@@ -146302,7 +147321,7 @@ workspaces.register(
|
|
|
146302
147321
|
sessions.register(rpc, streams);
|
|
146303
147322
|
sessions.registerCommands(rpc);
|
|
146304
147323
|
sessions.registerImport(rpc);
|
|
146305
|
-
var peerEpoch = chHost.realtime ? void 0 :
|
|
147324
|
+
var peerEpoch = chHost.realtime ? void 0 : randomUUID27(), peerEpochWaiters = /* @__PURE__ */ new Set(), stopEpoch = chHost.realtime?.subscribe((event) => {
|
|
146306
147325
|
if (event.type === "hello") {
|
|
146307
147326
|
peerEpoch = event.cursor.epoch;
|
|
146308
147327
|
for (let notify of peerEpochWaiters) notify();
|
|
@@ -146385,6 +147404,13 @@ sessions.setRemoteFileSearch(
|
|
|
146385
147404
|
);
|
|
146386
147405
|
streams.setFallback((endpoint, args, sink) => remoteWorkspaceFiles.handleStream(endpoint, args, sink) ? !0 : dsh ? dsh.stream(endpoint, args, sink) : !1);
|
|
146387
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);
|
|
146388
147414
|
displaySettings.register(rpc);
|
|
146389
147415
|
settings.register(rpc);
|
|
146390
147416
|
push.register(rpc);
|
|
@@ -146500,8 +147526,8 @@ var server = createWebServer((request3, response) => {
|
|
|
146500
147526
|
);
|
|
146501
147527
|
return;
|
|
146502
147528
|
}
|
|
146503
|
-
if (pathname === "/api/workspace-file/video" && (request3.method === "GET" || request3.method === "HEAD")) {
|
|
146504
|
-
await
|
|
147529
|
+
if ((pathname === "/api/workspace-file/media" || pathname === "/api/workspace-file/video") && (request3.method === "GET" || request3.method === "HEAD")) {
|
|
147530
|
+
await serveWorkspaceMedia(
|
|
146505
147531
|
request3,
|
|
146506
147532
|
response,
|
|
146507
147533
|
new URL(url2, "http://localhost"),
|
|
@@ -146648,6 +147674,10 @@ var server = createWebServer((request3, response) => {
|
|
|
146648
147674
|
await desktopScreenshots.serve(request3, response);
|
|
146649
147675
|
return;
|
|
146650
147676
|
}
|
|
147677
|
+
if (pathname === DESKTOP_SCREENSHOT_DISPLAYS_PATH) {
|
|
147678
|
+
await desktopScreenshots.serveDisplays(request3, response);
|
|
147679
|
+
return;
|
|
147680
|
+
}
|
|
146651
147681
|
if (pathname === "/api/voice/transcribe") {
|
|
146652
147682
|
await serveVoiceTranscription(chHost, dataRoot, request3, response);
|
|
146653
147683
|
return;
|
|
@@ -146662,6 +147692,14 @@ var server = createWebServer((request3, response) => {
|
|
|
146662
147692
|
);
|
|
146663
147693
|
return;
|
|
146664
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
|
+
}
|
|
146665
147703
|
if (pathname === "/api/workspace-file/download-ticket") {
|
|
146666
147704
|
let body2 = await readBody(request3, response);
|
|
146667
147705
|
if (body2 === void 0) return;
|
|
@@ -146748,6 +147786,40 @@ var server = createWebServer((request3, response) => {
|
|
|
146748
147786
|
);
|
|
146749
147787
|
return;
|
|
146750
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
|
+
}
|
|
146751
147823
|
if (pathname.startsWith("/harness-icons/peer/")) {
|
|
146752
147824
|
let asset = await resolvePeerHarnessIcon(peerManager, pathname);
|
|
146753
147825
|
if (!asset) {
|
|
@@ -146801,7 +147873,7 @@ var server = createWebServer((request3, response) => {
|
|
|
146801
147873
|
registerRelayRpc(rpc, accessTokens, relay);
|
|
146802
147874
|
serviceOptions.relayEnabled && relay.start();
|
|
146803
147875
|
var wss = createBrowserWebSocketServer(), sidebarBrowser = new SidebarBrowser({
|
|
146804
|
-
profileDirectory:
|
|
147876
|
+
profileDirectory: join37(dataRoot, "sidebar-browser"),
|
|
146805
147877
|
...auth === void 0 ? {} : { direct: new SidebarBrowserDirect(data, connections, directIceServers) }
|
|
146806
147878
|
});
|
|
146807
147879
|
server.on("upgrade", (request3, socket, head) => {
|
|
@@ -146874,7 +147946,7 @@ var shuttingDown;
|
|
|
146874
147946
|
function shutdown(exitCode = 0) {
|
|
146875
147947
|
return shuttingDown ??= (async () => {
|
|
146876
147948
|
try {
|
|
146877
|
-
stopEpoch?.(), webTelemetry.close(), await peerDelegationBridge?.close(), peerManager.close(), relay.close(), shellReload?.close(), accessTokens?.close(), server.close(), desktopScreenshots.close(), await sidebarBrowser.close(), await dsh?.close(), await extensions2.cleanup(!0), pushNotifications?.close(), await sessions.close(), sharedWorkspaceSearchCache.close(), remoteSessions.close(), await preferences?.close(), displaySettings.close();
|
|
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();
|
|
146878
147950
|
} catch (error62) {
|
|
146879
147951
|
console.error("[web] shutdown failed", error62), exitCode ||= 1;
|
|
146880
147952
|
} finally {
|