frizz-server 0.15.45 → 0.15.46

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.
Files changed (97) hide show
  1. package/dist/dev-child.js +755 -328
  2. package/package.json +2 -2
  3. package/web-dist/assets/{abnfDiagram-VRR7QNED-DdcfVlSS.js → abnfDiagram-VRR7QNED-dMKEjsHW.js} +1 -1
  4. package/web-dist/assets/{arc-Dd-9qSR2.js → arc-rNT0YHdg.js} +1 -1
  5. package/web-dist/assets/architecture-TIHT7OUA-NCeuUKT3.js +1 -0
  6. package/web-dist/assets/{architectureDiagram-ZJ3FMSHR-CTtEkoUc.js → architectureDiagram-ZJ3FMSHR-CYD9DZA5.js} +1 -1
  7. package/web-dist/assets/{blockDiagram-677ZJIJ3-DZxjSFDS.js → blockDiagram-677ZJIJ3-CfxVXTmt.js} +1 -1
  8. package/web-dist/assets/{c4Diagram-LMCZKHZV-CLG6s2jp.js → c4Diagram-LMCZKHZV-CURoUkcF.js} +1 -1
  9. package/web-dist/assets/channel-C7OqV6FU.js +1 -0
  10. package/web-dist/assets/{chunk-32BRIVSS-C2MZy9BN.js → chunk-32BRIVSS-yHDsUxjG.js} +1 -1
  11. package/web-dist/assets/{chunk-52WLFC77-BOrpbDoI.js → chunk-52WLFC77-ZOa2pNRf.js} +1 -1
  12. package/web-dist/assets/{chunk-C7G6YPKG-6FSry0ha.js → chunk-C7G6YPKG-6kS80FwC.js} +1 -1
  13. package/web-dist/assets/{chunk-EX3LRPZG-JNDb4Sk2.js → chunk-EX3LRPZG-ChL3TCQ1.js} +1 -1
  14. package/web-dist/assets/{chunk-FWX5IMBZ-DYu4gJrR.js → chunk-FWX5IMBZ-CZA0PJ2q.js} +2 -2
  15. package/web-dist/assets/{chunk-HOUHSVGY-Dr0K_z9k.js → chunk-HOUHSVGY-DADpdwih.js} +1 -1
  16. package/web-dist/assets/{chunk-ICXQ74PX-CIno_8Vw.js → chunk-ICXQ74PX-DsZXrGey.js} +1 -1
  17. package/web-dist/assets/{chunk-MOJQB5TN-D_IVymB_.js → chunk-MOJQB5TN-QXPP07cw.js} +1 -1
  18. package/web-dist/assets/{chunk-OGEWGWER-CvQ5TU0U.js → chunk-OGEWGWER-BnCPcBUr.js} +1 -1
  19. package/web-dist/assets/{chunk-PUDLZKDR-UiJIHeOE.js → chunk-PUDLZKDR-7cwzaMKa.js} +1 -1
  20. package/web-dist/assets/{chunk-Q4XR5HBZ-C4rwW_5T.js → chunk-Q4XR5HBZ-CfaCFnry.js} +1 -1
  21. package/web-dist/assets/{chunk-RYQCIY6F-Go3cYHvE.js → chunk-RYQCIY6F-Dw3inyG6.js} +1 -1
  22. package/web-dist/assets/{chunk-V7JOEXUC-B26l9uIK.js → chunk-V7JOEXUC-BUGdtSDc.js} +1 -1
  23. package/web-dist/assets/{chunk-VAUOI2AC-Bul-Lbfn.js → chunk-VAUOI2AC-BajrAZEY.js} +1 -1
  24. package/web-dist/assets/{chunk-VR4S4FIN-cgPP4htg.js → chunk-VR4S4FIN-CZhwOnY-.js} +1 -1
  25. package/web-dist/assets/{chunk-WYO6CB5R-l-N6lA6o.js → chunk-WYO6CB5R-DPplcyki.js} +1 -1
  26. package/web-dist/assets/{chunk-XXDRQBXY-D0391xrR.js → chunk-XXDRQBXY-Dxvo6Aj4.js} +1 -1
  27. package/web-dist/assets/{chunk-ZGVPDNZ5-chAqCG_5.js → chunk-ZGVPDNZ5-D_nMWwGu.js} +1 -1
  28. package/web-dist/assets/classDiagram-OUVF2IWQ-C0vbHYBX.js +1 -0
  29. package/web-dist/assets/classDiagram-v2-EOCWNBFH-C0vbHYBX.js +1 -0
  30. package/web-dist/assets/{cose-bilkent-JH36ORCC-DK83rOFR.js → cose-bilkent-JH36ORCC-EXH8BJZr.js} +1 -1
  31. package/web-dist/assets/{cynefin-VYW2F7L2-BtxZIfI6.js → cynefin-VYW2F7L2-BRCpSA3J.js} +1 -1
  32. package/web-dist/assets/{cynefinDiagram-TSTJHNR4-adx624Qr.js → cynefinDiagram-TSTJHNR4-DT-zxoY8.js} +1 -1
  33. package/web-dist/assets/{dagre-VKFMJZFB-7S1rjvBP.js → dagre-VKFMJZFB-eCkdmvvX.js} +1 -1
  34. package/web-dist/assets/{diagram-FQU43EPY-YIbh14Tf.js → diagram-FQU43EPY-C0ERgkJs.js} +1 -1
  35. package/web-dist/assets/{diagram-G47NLZAW-CA4OeYTm.js → diagram-G47NLZAW-wnblykLF.js} +1 -1
  36. package/web-dist/assets/{diagram-NH7WQ7WH-1HMUc7_6.js → diagram-NH7WQ7WH-DflsisJs.js} +1 -1
  37. package/web-dist/assets/{diagram-OA4YK3LP-DgDhda4z.js → diagram-OA4YK3LP-Dy8tJizx.js} +1 -1
  38. package/web-dist/assets/{diagram-WEI45ONY-SbpN5qmO.js → diagram-WEI45ONY-C7cuTuRM.js} +1 -1
  39. package/web-dist/assets/{dist-BfPkKz6y.js → dist-lcrHUGwW.js} +1 -1
  40. package/web-dist/assets/{ebnfDiagram-CCIWWBDH-DSAMxLZS.js → ebnfDiagram-CCIWWBDH-Be_-xy5Y.js} +1 -1
  41. package/web-dist/assets/{erDiagram-Q63AITRT-CGBvzS3i.js → erDiagram-Q63AITRT-Ze05Sekz.js} +1 -1
  42. package/web-dist/assets/eventmodeling-45OFAUF4-3mcZ7Om7.js +1 -0
  43. package/web-dist/assets/flowDiagram-23GEKE2U-C1w6bUoP.js +1 -0
  44. package/web-dist/assets/{ganttDiagram-NO4QXBWP-Bj6VO__W.js → ganttDiagram-NO4QXBWP-DXPLAeR9.js} +1 -1
  45. package/web-dist/assets/{gitGraph-TEB2WS4Q-DqEncJ54.js → gitGraph-TEB2WS4Q-qd8HrnTL.js} +1 -1
  46. package/web-dist/assets/{gitGraphDiagram-IHSO6WYX-DCtJAQgP.js → gitGraphDiagram-IHSO6WYX-BUlIs4PU.js} +1 -1
  47. package/web-dist/assets/index-CuESixAT.css +2 -0
  48. package/web-dist/assets/{index-B8GWzUFF.js → index-GV9pE9M2.js} +104 -104
  49. package/web-dist/assets/{info-DKCQHKI2-MQcHubhW.js → info-DKCQHKI2-BzkLurvw.js} +1 -1
  50. package/web-dist/assets/{infoDiagram-FWYZ7A6U-CsDgtZyr.js → infoDiagram-FWYZ7A6U-D9sZ9oDP.js} +1 -1
  51. package/web-dist/assets/{ishikawaDiagram-FXEZZL3T-n4npKpMz.js → ishikawaDiagram-FXEZZL3T-BzF_3YFM.js} +1 -1
  52. package/web-dist/assets/{journeyDiagram-5HDEW3XC-gvFqyFBK.js → journeyDiagram-5HDEW3XC-DFTScR2Z.js} +1 -1
  53. package/web-dist/assets/{kanban-definition-HUTT4EX6-BwGmOtsZ.js → kanban-definition-HUTT4EX6-BLzFoVGW.js} +1 -1
  54. package/web-dist/assets/{line-DVHKI4UD.js → line-Do8dUGBy.js} +1 -1
  55. package/web-dist/assets/{linear-Bl3GAeC5.js → linear-DuRi0RMF.js} +1 -1
  56. package/web-dist/assets/{mermaid-parser.core-CS9sXl26.js → mermaid-parser.core-Cg30o9F2.js} +3 -3
  57. package/web-dist/assets/{mermaid.core-BF2OWOC5.js → mermaid.core-BqJlujeQ.js} +3 -3
  58. package/web-dist/assets/{mindmap-definition-LN4V7U3C-AO9iV-xK.js → mindmap-definition-LN4V7U3C-HQlN-9Bu.js} +1 -1
  59. package/web-dist/assets/{packet-7NZHBO7P-DKlEG9Ea.js → packet-7NZHBO7P-U04BXIOt.js} +1 -1
  60. package/web-dist/assets/{pegDiagram-2B236MQR-C1dCLvv_.js → pegDiagram-2B236MQR-DgY7HtfT.js} +1 -1
  61. package/web-dist/assets/{pie-RZYD4A2V-D1VTnLcn.js → pie-RZYD4A2V-CNmbhkWK.js} +1 -1
  62. package/web-dist/assets/{pieDiagram-ENE6RG2P-CQZmxKs_.js → pieDiagram-ENE6RG2P-DZAgx8HX.js} +1 -1
  63. package/web-dist/assets/{quadrantDiagram-ABIIQ3AL-DBGXvq5A.js → quadrantDiagram-ABIIQ3AL-BgwkFnnW.js} +1 -1
  64. package/web-dist/assets/{radar-I7S5WNFK-dDBNghsQ.js → radar-I7S5WNFK-uSk4Y1ho.js} +1 -1
  65. package/web-dist/assets/{railroad-3IZDKUUU-BATiGbM7.js → railroad-3IZDKUUU-DYUKnC5s.js} +1 -1
  66. package/web-dist/assets/railroad-abnf-AHOZXSZD-IkzutLqe.js +1 -0
  67. package/web-dist/assets/railroad-ebnf-EBAXGLYW-BxRu9OFq.js +1 -0
  68. package/web-dist/assets/railroad-peg-LSFZ7HO6-B_oCO_d6.js +1 -0
  69. package/web-dist/assets/{railroadDiagram-RFXS5EU6-CfMepKHY.js → railroadDiagram-RFXS5EU6-D50qDJK9.js} +1 -1
  70. package/web-dist/assets/{requirementDiagram-TGXJPOKE-CatGfExT.js → requirementDiagram-TGXJPOKE-BcYVVHnq.js} +1 -1
  71. package/web-dist/assets/{sankeyDiagram-HTMAVEWB-BJKlQgBE.js → sankeyDiagram-HTMAVEWB-PzXMSHpA.js} +1 -1
  72. package/web-dist/assets/{sequenceDiagram-DBY2YBRQ-pnjnPsTb.js → sequenceDiagram-DBY2YBRQ-mGrOXhjH.js} +1 -1
  73. package/web-dist/assets/{src-B4MKXuyl.js → src-DgdnlNtf.js} +1 -1
  74. package/web-dist/assets/{stateDiagram-2N3HPSRC-XHE1q90_.js → stateDiagram-2N3HPSRC-DVtnHF84.js} +1 -1
  75. package/web-dist/assets/stateDiagram-v2-6OUMAXLB-SdAGeC8G.js +1 -0
  76. package/web-dist/assets/{swimlanes-5IMT3BWC-Bi6g3R3-.js → swimlanes-5IMT3BWC-CpFBm_uD.js} +1 -1
  77. package/web-dist/assets/swimlanesDiagram-G3AALYLV-DFV8nG2S.js +8 -0
  78. package/web-dist/assets/{timeline-definition-FHXFAJF6-B9fPPKq7.js → timeline-definition-FHXFAJF6-BtulIlxh.js} +1 -1
  79. package/web-dist/assets/{treeView-QDETBFTQ-Dgzve3kG.js → treeView-QDETBFTQ-DvYZWcpI.js} +1 -1
  80. package/web-dist/assets/{treemap-6X3UGDF4-GicQSqLq.js → treemap-6X3UGDF4-BLNXL2Uy.js} +1 -1
  81. package/web-dist/assets/{vennDiagram-L72KCM5P-YFe7_B7_.js → vennDiagram-L72KCM5P-pRoAWpIZ.js} +1 -1
  82. package/web-dist/assets/{wardley-OPB4EBWU-IvaK89qC.js → wardley-OPB4EBWU-Cs-85TFO.js} +1 -1
  83. package/web-dist/assets/{wardleyDiagram-EHGQE667-BMQBcZ-w.js → wardleyDiagram-EHGQE667-CX1pViTS.js} +1 -1
  84. package/web-dist/assets/{xychartDiagram-FW5EYKEG-ChKpZ3CP.js → xychartDiagram-FW5EYKEG-PscAnIL7.js} +1 -1
  85. package/web-dist/index.html +2 -2
  86. package/web-dist/assets/architecture-TIHT7OUA-Dp1_ME8f.js +0 -1
  87. package/web-dist/assets/channel-DLMVcZ_W.js +0 -1
  88. package/web-dist/assets/classDiagram-OUVF2IWQ-BcbTfrpO.js +0 -1
  89. package/web-dist/assets/classDiagram-v2-EOCWNBFH-BcbTfrpO.js +0 -1
  90. package/web-dist/assets/eventmodeling-45OFAUF4-sBAENH7C.js +0 -1
  91. package/web-dist/assets/flowDiagram-23GEKE2U-Beu12Qi8.js +0 -1
  92. package/web-dist/assets/index-D599iquJ.css +0 -2
  93. package/web-dist/assets/railroad-abnf-AHOZXSZD-Bb6r2eps.js +0 -1
  94. package/web-dist/assets/railroad-ebnf-EBAXGLYW-C55U6d71.js +0 -1
  95. package/web-dist/assets/railroad-peg-LSFZ7HO6-B55GNEiw.js +0 -1
  96. package/web-dist/assets/stateDiagram-v2-6OUMAXLB-CHhLO38y.js +0 -1
  97. package/web-dist/assets/swimlanesDiagram-G3AALYLV-DAhPbYdd.js +0 -8
package/dist/dev-child.js CHANGED
@@ -4768,10 +4768,10 @@ var require_resolve_block_map = __commonJS({
4768
4768
  let offset = bm2.offset;
4769
4769
  let commentEnd = null;
4770
4770
  for (const collItem of bm2.items) {
4771
- const { start, key, sep: sep8, value } = collItem;
4771
+ const { start, key, sep: sep9, value } = collItem;
4772
4772
  const keyProps = resolveProps.resolveProps(start, {
4773
4773
  indicator: "explicit-key-ind",
4774
- next: key ?? sep8?.[0],
4774
+ next: key ?? sep9?.[0],
4775
4775
  offset,
4776
4776
  onError,
4777
4777
  parentIndent: bm2.indent,
@@ -4785,7 +4785,7 @@ var require_resolve_block_map = __commonJS({
4785
4785
  else if ("indent" in key && key.indent !== bm2.indent)
4786
4786
  onError(offset, "BAD_INDENT", startColMsg);
4787
4787
  }
4788
- if (!keyProps.anchor && !keyProps.tag && !sep8) {
4788
+ if (!keyProps.anchor && !keyProps.tag && !sep9) {
4789
4789
  commentEnd = keyProps.end;
4790
4790
  if (keyProps.comment) {
4791
4791
  if (map.comment)
@@ -4809,7 +4809,7 @@ var require_resolve_block_map = __commonJS({
4809
4809
  ctx.atKey = false;
4810
4810
  if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
4811
4811
  onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
4812
- const valueProps = resolveProps.resolveProps(sep8 ?? [], {
4812
+ const valueProps = resolveProps.resolveProps(sep9 ?? [], {
4813
4813
  indicator: "map-value-ind",
4814
4814
  next: value,
4815
4815
  offset: keyNode.range[2],
@@ -4825,7 +4825,7 @@ var require_resolve_block_map = __commonJS({
4825
4825
  if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
4826
4826
  onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
4827
4827
  }
4828
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep8, null, valueProps, onError);
4828
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep9, null, valueProps, onError);
4829
4829
  if (ctx.schema.compat)
4830
4830
  utilFlowIndentCheck.flowIndentCheck(bm2.indent, value, onError);
4831
4831
  offset = valueNode.range[2];
@@ -4916,7 +4916,7 @@ var require_resolve_end = __commonJS({
4916
4916
  let comment = "";
4917
4917
  if (end) {
4918
4918
  let hasSpace = false;
4919
- let sep8 = "";
4919
+ let sep9 = "";
4920
4920
  for (const token of end) {
4921
4921
  const { source, type } = token;
4922
4922
  switch (type) {
@@ -4930,13 +4930,13 @@ var require_resolve_end = __commonJS({
4930
4930
  if (!comment)
4931
4931
  comment = cb2;
4932
4932
  else
4933
- comment += sep8 + cb2;
4934
- sep8 = "";
4933
+ comment += sep9 + cb2;
4934
+ sep9 = "";
4935
4935
  break;
4936
4936
  }
4937
4937
  case "newline":
4938
4938
  if (comment)
4939
- sep8 += source;
4939
+ sep9 += source;
4940
4940
  hasSpace = true;
4941
4941
  break;
4942
4942
  default:
@@ -4979,18 +4979,18 @@ var require_resolve_flow_collection = __commonJS({
4979
4979
  let offset = fc2.offset + fc2.start.source.length;
4980
4980
  for (let i = 0; i < fc2.items.length; ++i) {
4981
4981
  const collItem = fc2.items[i];
4982
- const { start, key, sep: sep8, value } = collItem;
4982
+ const { start, key, sep: sep9, value } = collItem;
4983
4983
  const props = resolveProps.resolveProps(start, {
4984
4984
  flow: fcName,
4985
4985
  indicator: "explicit-key-ind",
4986
- next: key ?? sep8?.[0],
4986
+ next: key ?? sep9?.[0],
4987
4987
  offset,
4988
4988
  onError,
4989
4989
  parentIndent: fc2.indent,
4990
4990
  startOnNewline: false
4991
4991
  });
4992
4992
  if (!props.found) {
4993
- if (!props.anchor && !props.tag && !sep8 && !value) {
4993
+ if (!props.anchor && !props.tag && !sep9 && !value) {
4994
4994
  if (i === 0 && props.comma)
4995
4995
  onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
4996
4996
  else if (i < fc2.items.length - 1)
@@ -5044,8 +5044,8 @@ var require_resolve_flow_collection = __commonJS({
5044
5044
  }
5045
5045
  }
5046
5046
  }
5047
- if (!isMap && !sep8 && !props.found) {
5048
- const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep8, null, props, onError);
5047
+ if (!isMap && !sep9 && !props.found) {
5048
+ const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep9, null, props, onError);
5049
5049
  coll.items.push(valueNode);
5050
5050
  offset = valueNode.range[2];
5051
5051
  if (isBlock(value))
@@ -5057,7 +5057,7 @@ var require_resolve_flow_collection = __commonJS({
5057
5057
  if (isBlock(key))
5058
5058
  onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
5059
5059
  ctx.atKey = false;
5060
- const valueProps = resolveProps.resolveProps(sep8 ?? [], {
5060
+ const valueProps = resolveProps.resolveProps(sep9 ?? [], {
5061
5061
  flow: fcName,
5062
5062
  indicator: "map-value-ind",
5063
5063
  next: value,
@@ -5068,8 +5068,8 @@ var require_resolve_flow_collection = __commonJS({
5068
5068
  });
5069
5069
  if (valueProps.found) {
5070
5070
  if (!isMap && !props.found && ctx.options.strict) {
5071
- if (sep8)
5072
- for (const st2 of sep8) {
5071
+ if (sep9)
5072
+ for (const st2 of sep9) {
5073
5073
  if (st2 === valueProps.found)
5074
5074
  break;
5075
5075
  if (st2.type === "newline") {
@@ -5086,7 +5086,7 @@ var require_resolve_flow_collection = __commonJS({
5086
5086
  else
5087
5087
  onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
5088
5088
  }
5089
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep8, null, valueProps, onError) : null;
5089
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep9, null, valueProps, onError) : null;
5090
5090
  if (valueNode) {
5091
5091
  if (isBlock(value))
5092
5092
  onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
@@ -5266,7 +5266,7 @@ var require_resolve_block_scalar = __commonJS({
5266
5266
  chompStart = i + 1;
5267
5267
  }
5268
5268
  let value = "";
5269
- let sep8 = "";
5269
+ let sep9 = "";
5270
5270
  let prevMoreIndented = false;
5271
5271
  for (let i = 0; i < contentStart; ++i)
5272
5272
  value += lines[i][0].slice(trimIndent) + "\n";
@@ -5283,24 +5283,24 @@ var require_resolve_block_scalar = __commonJS({
5283
5283
  indent = "";
5284
5284
  }
5285
5285
  if (type === Scalar.Scalar.BLOCK_LITERAL) {
5286
- value += sep8 + indent.slice(trimIndent) + content;
5287
- sep8 = "\n";
5286
+ value += sep9 + indent.slice(trimIndent) + content;
5287
+ sep9 = "\n";
5288
5288
  } else if (indent.length > trimIndent || content[0] === " ") {
5289
- if (sep8 === " ")
5290
- sep8 = "\n";
5291
- else if (!prevMoreIndented && sep8 === "\n")
5292
- sep8 = "\n\n";
5293
- value += sep8 + indent.slice(trimIndent) + content;
5294
- sep8 = "\n";
5289
+ if (sep9 === " ")
5290
+ sep9 = "\n";
5291
+ else if (!prevMoreIndented && sep9 === "\n")
5292
+ sep9 = "\n\n";
5293
+ value += sep9 + indent.slice(trimIndent) + content;
5294
+ sep9 = "\n";
5295
5295
  prevMoreIndented = true;
5296
5296
  } else if (content === "") {
5297
- if (sep8 === "\n")
5297
+ if (sep9 === "\n")
5298
5298
  value += "\n";
5299
5299
  else
5300
- sep8 = "\n";
5300
+ sep9 = "\n";
5301
5301
  } else {
5302
- value += sep8 + content;
5303
- sep8 = " ";
5302
+ value += sep9 + content;
5303
+ sep9 = " ";
5304
5304
  prevMoreIndented = false;
5305
5305
  }
5306
5306
  }
@@ -5482,25 +5482,25 @@ var require_resolve_flow_scalar = __commonJS({
5482
5482
  if (!match2)
5483
5483
  return source;
5484
5484
  let res = match2[1];
5485
- let sep8 = " ";
5485
+ let sep9 = " ";
5486
5486
  let pos = first.lastIndex;
5487
5487
  line.lastIndex = pos;
5488
5488
  while (match2 = line.exec(source)) {
5489
5489
  if (match2[1] === "") {
5490
- if (sep8 === "\n")
5491
- res += sep8;
5490
+ if (sep9 === "\n")
5491
+ res += sep9;
5492
5492
  else
5493
- sep8 = "\n";
5493
+ sep9 = "\n";
5494
5494
  } else {
5495
- res += sep8 + match2[1];
5496
- sep8 = " ";
5495
+ res += sep9 + match2[1];
5496
+ sep9 = " ";
5497
5497
  }
5498
5498
  pos = line.lastIndex;
5499
5499
  }
5500
5500
  const last = /[ \t]*(.*)/sy;
5501
5501
  last.lastIndex = pos;
5502
5502
  match2 = last.exec(source);
5503
- return res + sep8 + (match2?.[1] ?? "");
5503
+ return res + sep9 + (match2?.[1] ?? "");
5504
5504
  }
5505
5505
  function doubleQuotedValue(source, onError) {
5506
5506
  let res = "";
@@ -6310,14 +6310,14 @@ var require_cst_stringify = __commonJS({
6310
6310
  }
6311
6311
  }
6312
6312
  }
6313
- function stringifyItem({ start, key, sep: sep8, value }) {
6313
+ function stringifyItem({ start, key, sep: sep9, value }) {
6314
6314
  let res = "";
6315
6315
  for (const st2 of start)
6316
6316
  res += st2.source;
6317
6317
  if (key)
6318
6318
  res += stringifyToken(key);
6319
- if (sep8)
6320
- for (const st2 of sep8)
6319
+ if (sep9)
6320
+ for (const st2 of sep9)
6321
6321
  res += st2.source;
6322
6322
  if (value)
6323
6323
  res += stringifyToken(value);
@@ -7484,18 +7484,18 @@ var require_parser = __commonJS({
7484
7484
  if (this.type === "map-value-ind") {
7485
7485
  const prev = getPrevProps(this.peek(2));
7486
7486
  const start = getFirstKeyStartProps(prev);
7487
- let sep8;
7487
+ let sep9;
7488
7488
  if (scalar.end) {
7489
- sep8 = scalar.end;
7490
- sep8.push(this.sourceToken);
7489
+ sep9 = scalar.end;
7490
+ sep9.push(this.sourceToken);
7491
7491
  delete scalar.end;
7492
7492
  } else
7493
- sep8 = [this.sourceToken];
7493
+ sep9 = [this.sourceToken];
7494
7494
  const map = {
7495
7495
  type: "block-map",
7496
7496
  offset: scalar.offset,
7497
7497
  indent: scalar.indent,
7498
- items: [{ start, key: scalar, sep: sep8 }]
7498
+ items: [{ start, key: scalar, sep: sep9 }]
7499
7499
  };
7500
7500
  this.onKeyLine = true;
7501
7501
  this.stack[this.stack.length - 1] = map;
@@ -7648,15 +7648,15 @@ var require_parser = __commonJS({
7648
7648
  } else if (isFlowToken(it2.key) && !includesToken(it2.sep, "newline")) {
7649
7649
  const start2 = getFirstKeyStartProps(it2.start);
7650
7650
  const key = it2.key;
7651
- const sep8 = it2.sep;
7652
- sep8.push(this.sourceToken);
7651
+ const sep9 = it2.sep;
7652
+ sep9.push(this.sourceToken);
7653
7653
  delete it2.key;
7654
7654
  delete it2.sep;
7655
7655
  this.stack.push({
7656
7656
  type: "block-map",
7657
7657
  offset: this.offset,
7658
7658
  indent: this.indent,
7659
- items: [{ start: start2, key, sep: sep8 }]
7659
+ items: [{ start: start2, key, sep: sep9 }]
7660
7660
  });
7661
7661
  } else if (start.length > 0) {
7662
7662
  it2.sep = it2.sep.concat(start, this.sourceToken);
@@ -7850,13 +7850,13 @@ var require_parser = __commonJS({
7850
7850
  const prev = getPrevProps(parent);
7851
7851
  const start = getFirstKeyStartProps(prev);
7852
7852
  fixFlowSeqItems(fc2);
7853
- const sep8 = fc2.end.splice(1, fc2.end.length);
7854
- sep8.push(this.sourceToken);
7853
+ const sep9 = fc2.end.splice(1, fc2.end.length);
7854
+ sep9.push(this.sourceToken);
7855
7855
  const map = {
7856
7856
  type: "block-map",
7857
7857
  offset: fc2.offset,
7858
7858
  indent: fc2.indent,
7859
- items: [{ start, key: fc2, sep: sep8 }]
7859
+ items: [{ start, key: fc2, sep: sep9 }]
7860
7860
  };
7861
7861
  this.onKeyLine = true;
7862
7862
  this.stack[this.stack.length - 1] = map;
@@ -13593,8 +13593,8 @@ function createDrainableWorker(process2, options = {}) {
13593
13593
  },
13594
13594
  drain() {
13595
13595
  if (closed || queue.length === 0 && inFlight2 === 0) return Promise.resolve();
13596
- return new Promise((resolve16) => {
13597
- waiters.push(resolve16);
13596
+ return new Promise((resolve17) => {
13597
+ waiters.push(resolve17);
13598
13598
  });
13599
13599
  },
13600
13600
  outstanding: () => queue.length + inFlight2,
@@ -13844,11 +13844,11 @@ function shellWriteTargets(command) {
13844
13844
  for (const target of targets) {
13845
13845
  const path3 = target.text.trim();
13846
13846
  if (!path3 || isUnresolvable(path3)) continue;
13847
- const relative4 = !path3.startsWith("/") && !path3.startsWith("~");
13848
- if (relative4 && baseUnknown) continue;
13847
+ const relative5 = !path3.startsWith("/") && !path3.startsWith("~");
13848
+ if (relative5 && baseUnknown) continue;
13849
13849
  out.push({
13850
13850
  path: path3,
13851
- ...relative4 && base !== void 0 ? { base } : {},
13851
+ ...relative5 && base !== void 0 ? { base } : {},
13852
13852
  ...target.atEnd ? { atEnd: true } : {}
13853
13853
  });
13854
13854
  }
@@ -19871,7 +19871,7 @@ function createRetryableCleanup(run3) {
19871
19871
  }
19872
19872
  function withPhaseTimeout(name, promise, timeoutMs) {
19873
19873
  if (timeoutMs === void 0 || !Number.isFinite(timeoutMs) || timeoutMs <= 0) return promise;
19874
- return new Promise((resolve16, reject) => {
19874
+ return new Promise((resolve17, reject) => {
19875
19875
  let settled = false;
19876
19876
  const settle = (apply) => {
19877
19877
  if (settled) return;
@@ -19882,18 +19882,18 @@ function withPhaseTimeout(name, promise, timeoutMs) {
19882
19882
  const timer = setTimeout(() => settle(() => reject(new ShutdownPhaseTimeoutError(name, timeoutMs))), timeoutMs);
19883
19883
  timer.unref?.();
19884
19884
  promise.then(
19885
- () => settle(resolve16),
19885
+ () => settle(resolve17),
19886
19886
  (error) => settle(() => reject(error))
19887
19887
  );
19888
19888
  });
19889
19889
  }
19890
19890
  function defaultDeadline(drained, timeoutMs) {
19891
- return new Promise((resolve16, reject) => {
19891
+ return new Promise((resolve17, reject) => {
19892
19892
  const timer = setTimeout(() => reject(new ShutdownTimeoutError(timeoutMs)), timeoutMs);
19893
19893
  void drained.then(
19894
19894
  () => {
19895
19895
  clearTimeout(timer);
19896
- resolve16();
19896
+ resolve17();
19897
19897
  },
19898
19898
  (error) => {
19899
19899
  clearTimeout(timer);
@@ -20388,7 +20388,7 @@ function rejectWebSocketUpgrade(socket, status = 403, reason = "Forbidden") {
20388
20388
  }
20389
20389
  }
20390
20390
  }
20391
- var LOCAL_HOSTNAMES, FORWARDED_HEADERS;
20391
+ var LOCAL_HOSTNAMES, FORWARDED_HEADERS, FRAME_REFUSED_HEADERS;
20392
20392
  var init_local_origin = __esm({
20393
20393
  "packages/server/src/local-origin.ts"() {
20394
20394
  "use strict";
@@ -20400,6 +20400,10 @@ var init_local_origin = __esm({
20400
20400
  "x-forwarded-port",
20401
20401
  "x-forwarded-proto"
20402
20402
  ];
20403
+ FRAME_REFUSED_HEADERS = {
20404
+ "x-frame-options": "DENY",
20405
+ "content-security-policy": "frame-ancestors 'none'"
20406
+ };
20403
20407
  }
20404
20408
  });
20405
20409
 
@@ -20647,6 +20651,21 @@ var init_audit = __esm({
20647
20651
  }
20648
20652
  });
20649
20653
 
20654
+ // packages/server/src/remote-refusal.ts
20655
+ function remoteHostLabel(platform3 = process.platform) {
20656
+ return platform3 === "darwin" ? "the Mac" : "the computer running Frizz";
20657
+ }
20658
+ function remoteRefusedMessage() {
20659
+ return `This can only be done on ${remoteHostLabel()}.`;
20660
+ }
20661
+ var REMOTE_REFUSED_CODE;
20662
+ var init_remote_refusal = __esm({
20663
+ "packages/server/src/remote-refusal.ts"() {
20664
+ "use strict";
20665
+ REMOTE_REFUSED_CODE = "remote_refused";
20666
+ }
20667
+ });
20668
+
20650
20669
  // packages/server/src/bus.ts
20651
20670
  var Bus, Emitter;
20652
20671
  var init_bus = __esm({
@@ -26464,7 +26483,7 @@ function forkBroker(options) {
26464
26483
  child.unref();
26465
26484
  const deadline = Date.now() + (options.timeoutMs ?? 3e4);
26466
26485
  const recordedCause = () => readClaudeBrokerExit(options.stateDir, options.sessionId, generation);
26467
- return new Promise((resolve16, reject) => {
26486
+ return new Promise((resolve17, reject) => {
26468
26487
  let settled = false;
26469
26488
  let timer;
26470
26489
  const settle = (outcome) => {
@@ -26475,7 +26494,7 @@ function forkBroker(options) {
26475
26494
  };
26476
26495
  const poll = () => {
26477
26496
  const record = readBrokerRecord(recordPath2);
26478
- if (record && pidAlive(record.daemonPid)) return settle(() => resolve16(record));
26497
+ if (record && pidAlive(record.daemonPid)) return settle(() => resolve17(record));
26479
26498
  if (Date.now() > deadline) {
26480
26499
  const exit = recordedCause();
26481
26500
  return settle(() => reject(new Error(
@@ -31288,19 +31307,19 @@ function searchPath2(env) {
31288
31307
  function vendoredNativeBeside(launcherJs, arch, access) {
31289
31308
  const triple = WINDOWS_TRIPLE[arch];
31290
31309
  if (!triple) return void 0;
31291
- const { dirname: dirname33, join: join65 } = win322;
31310
+ const { dirname: dirname33, join: join66 } = win322;
31292
31311
  const pkgRoot = dirname33(dirname33(launcherJs));
31293
31312
  const platformPkg = `codex-win32-${arch}`;
31294
31313
  const vendorRoots = [
31295
- join65(pkgRoot, "node_modules", "@openai", platformPkg, "vendor"),
31314
+ join66(pkgRoot, "node_modules", "@openai", platformPkg, "vendor"),
31296
31315
  // nested under the package
31297
- join65(dirname33(pkgRoot), platformPkg, "vendor"),
31316
+ join66(dirname33(pkgRoot), platformPkg, "vendor"),
31298
31317
  // hoisted beside it: <prefix>\node_modules\@openai\<pkg>
31299
- join65(pkgRoot, "vendor")
31318
+ join66(pkgRoot, "vendor")
31300
31319
  // the pre-platform-package layout, binaries inside @openai/codex itself
31301
31320
  ];
31302
31321
  for (const root of vendorRoots) {
31303
- const exe2 = join65(root, triple, "bin", "codex.exe");
31322
+ const exe2 = join66(root, triple, "bin", "codex.exe");
31304
31323
  if (access(exe2, "exists")) return exe2;
31305
31324
  }
31306
31325
  return void 0;
@@ -31586,7 +31605,7 @@ async function writeShared(path3, value) {
31586
31605
  }
31587
31606
  }
31588
31607
  function delay(ms) {
31589
- return new Promise((resolve16) => setTimeout(resolve16, ms));
31608
+ return new Promise((resolve17) => setTimeout(resolve17, ms));
31590
31609
  }
31591
31610
  async function acquireLock(path3) {
31592
31611
  const deadline = Date.now() + LOCK_WAIT_MS;
@@ -32097,9 +32116,9 @@ function readCodexAccountId(codexHome = defaultCodexHome()) {
32097
32116
  return void 0;
32098
32117
  }
32099
32118
  }
32100
- async function readCodexBinaryState(codexBin = "codex", exec = execFileAsync3, resolve16 = resolveCodexExecutable) {
32119
+ async function readCodexBinaryState(codexBin = "codex", exec = execFileAsync3, resolve17 = resolveCodexExecutable) {
32101
32120
  try {
32102
- const codex = resolve16(codexBin);
32121
+ const codex = resolve17(codexBin);
32103
32122
  await exec(codex.file, [...codex.args, "--version"], { timeout: 5e3 });
32104
32123
  return "present";
32105
32124
  } catch (err) {
@@ -36115,21 +36134,21 @@ async function stopNativeListener(stateDir, projectId, timeoutMs = 1e4) {
36115
36134
  if (!record) return;
36116
36135
  const deadline = Date.now() + timeoutMs;
36117
36136
  while (pidAlive2(record.listenerPid) && Date.now() < deadline) {
36118
- await new Promise((resolve16) => setTimeout(resolve16, 25));
36137
+ await new Promise((resolve17) => setTimeout(resolve17, 25));
36119
36138
  }
36120
36139
  if (pidAlive2(record.listenerPid)) {
36121
36140
  signalListener(record, "SIGKILL");
36122
36141
  while (pidAlive2(record.listenerPid) && Date.now() < deadline + 2e3) {
36123
- await new Promise((resolve16) => setTimeout(resolve16, 25));
36142
+ await new Promise((resolve17) => setTimeout(resolve17, 25));
36124
36143
  }
36125
36144
  }
36126
36145
  }
36127
36146
  function socketAccepting(socketPath) {
36128
- return new Promise((resolve16) => {
36147
+ return new Promise((resolve17) => {
36129
36148
  const probe = connect(socketPath);
36130
36149
  const done = (value) => {
36131
36150
  probe.destroy();
36132
- resolve16(value);
36151
+ resolve17(value);
36133
36152
  };
36134
36153
  probe.once("connect", () => done(true));
36135
36154
  probe.once("error", () => done(false));
@@ -36146,7 +36165,7 @@ function ipcWebSocket(endpoint) {
36146
36165
  return new import_websocket.default("ws://localhost/", { agent: new PipeAgent(), perMessageDeflate: false });
36147
36166
  }
36148
36167
  function attach(record, timeoutMs) {
36149
- return new Promise((resolve16, reject) => {
36168
+ return new Promise((resolve17, reject) => {
36150
36169
  const socket = ipcWebSocket(record.socketPath);
36151
36170
  const stdout = new PassThrough();
36152
36171
  const stderr = new PassThrough();
@@ -36199,7 +36218,7 @@ function attach(record, timeoutMs) {
36199
36218
  if (settled) return;
36200
36219
  settled = true;
36201
36220
  clearTimeout(timer);
36202
- resolve16(handle);
36221
+ resolve17(handle);
36203
36222
  });
36204
36223
  socket.on("message", (data) => {
36205
36224
  const text2 = typeof data === "string" ? data : Buffer.isBuffer(data) ? data.toString("utf8") : Buffer.concat(data).toString("utf8");
@@ -36262,7 +36281,7 @@ async function startListener(options, launchPrefix) {
36262
36281
  if (existsSync9(socketPath) && await socketAccepting(socketPath)) return record;
36263
36282
  if (!pidAlive2(record.listenerPid)) throw new Error("codex app-server listener exited before it became ready");
36264
36283
  if (Date.now() > deadline) throw new Error("codex app-server listener did not become ready");
36265
- await new Promise((resolve16) => setTimeout(resolve16, 50));
36284
+ await new Promise((resolve17) => setTimeout(resolve17, 50));
36266
36285
  }
36267
36286
  }
36268
36287
  var PRESUMED_LOSSY_REJOIN, nativeListenCodexAppServerHost;
@@ -36416,12 +36435,12 @@ async function stopCodexAppServerDaemon(stateDir, projectId, timeoutMs = 1e4) {
36416
36435
  if (!record) return;
36417
36436
  const deadline = Date.now() + timeoutMs;
36418
36437
  while (pidAlive3(record.daemonPid) && Date.now() < deadline) {
36419
- await new Promise((resolve16) => setTimeout(resolve16, 25));
36438
+ await new Promise((resolve17) => setTimeout(resolve17, 25));
36420
36439
  }
36421
36440
  if (pidAlive3(record.daemonPid)) {
36422
36441
  endDaemonTree(record.daemonPid, "SIGKILL");
36423
36442
  while (pidAlive3(record.daemonPid) && Date.now() < deadline + 2e3) {
36424
- await new Promise((resolve16) => setTimeout(resolve16, 25));
36443
+ await new Promise((resolve17) => setTimeout(resolve17, 25));
36425
36444
  }
36426
36445
  }
36427
36446
  }
@@ -36469,10 +36488,10 @@ function forkDaemon(options, launchPrefix) {
36469
36488
  });
36470
36489
  child.unref();
36471
36490
  const deadline = Date.now() + (options.timeoutMs ?? 3e4);
36472
- return new Promise((resolve16, reject) => {
36491
+ return new Promise((resolve17, reject) => {
36473
36492
  const poll = () => {
36474
36493
  const found = readDaemonRecord(stateDir, projectId);
36475
- if (found && pidAlive3(found.daemonPid)) return resolve16(found);
36494
+ if (found && pidAlive3(found.daemonPid)) return resolve17(found);
36476
36495
  if (!pidAlive3(child.pid ?? -1) && !found) return reject(new Error("codex app-server daemon exited before it became ready"));
36477
36496
  if (Date.now() > deadline) return reject(new Error("codex app-server daemon did not become ready"));
36478
36497
  setTimeout(poll, 50);
@@ -36490,7 +36509,7 @@ function helloDropCount(line) {
36490
36509
  }
36491
36510
  }
36492
36511
  function attach2(record, timeoutMs) {
36493
- return new Promise((resolve16, reject) => {
36512
+ return new Promise((resolve17, reject) => {
36494
36513
  const socket = createConnection(record.socketPath);
36495
36514
  const stdout = new PassThrough2();
36496
36515
  const stderr = new PassThrough2();
@@ -36540,7 +36559,7 @@ function attach2(record, timeoutMs) {
36540
36559
  if (!settled) {
36541
36560
  settled = true;
36542
36561
  clearTimeout(timer);
36543
- resolve16({ process: handle, droppedWhileDetached: helloDropCount(trimmed) });
36562
+ resolve17({ process: handle, droppedWhileDetached: helloDropCount(trimmed) });
36544
36563
  }
36545
36564
  continue;
36546
36565
  }
@@ -36672,12 +36691,12 @@ var init_codex_shell_env = __esm({
36672
36691
  // packages/server/src/backend/codex-execution-health.ts
36673
36692
  import { execFile as execFile6 } from "node:child_process";
36674
36693
  function probeHostMacOSServices() {
36675
- return new Promise((resolve16) => {
36694
+ return new Promise((resolve17) => {
36676
36695
  execFile6(MACOS_SERVICE_PROBE[0], MACOS_SERVICE_PROBE.slice(1), {
36677
36696
  timeout: MACOS_SERVICE_PROBE_TIMEOUT_MS,
36678
36697
  killSignal: "SIGKILL",
36679
36698
  maxBuffer: 64 * 1024
36680
- }, (error) => resolve16(!error));
36699
+ }, (error) => resolve17(!error));
36681
36700
  });
36682
36701
  }
36683
36702
  var MACOS_SERVICE_PROBE, MACOS_SERVICE_PROBE_TIMEOUT_MS, CodexExecutionHealth;
@@ -37404,11 +37423,11 @@ var init_codex_app_server = __esm({
37404
37423
  init_project_registry();
37405
37424
  CODEX_APP_SERVER_PROVIDER = "codex-app-server";
37406
37425
  CODEX_NATIVE_LISTEN_FLAG = "FRIZZ_CODEX_NATIVE_LISTEN";
37407
- CODEX_APP_SERVER_SUPPORTED_VERSION = "0.166.0";
37426
+ CODEX_APP_SERVER_SUPPORTED_VERSION = "0.167.0";
37408
37427
  CODEX_APP_SERVER_PROTOCOL_REVISION = Object.freeze({
37409
37428
  packageVersion: CODEX_APP_SERVER_SUPPORTED_VERSION,
37410
- sourceTag: "rust-v0.166.0",
37411
- sourceCommit: "6ff1e1ca3b30fc8b914720681fcf5fe62e95f856"
37429
+ sourceTag: "rust-v0.167.0",
37430
+ sourceCommit: "086ccc833bc9cf01024ad2dd6af7dbd421b6bf9a"
37412
37431
  });
37413
37432
  PROTOCOL_FINGERPRINT = [
37414
37433
  CODEX_APP_SERVER_PROTOCOL_REVISION.sourceTag,
@@ -37697,12 +37716,12 @@ var init_codex_app_server = __esm({
37697
37716
  if (this.pending.size >= MAX_OUTBOUND_REQUESTS) throw new Error("Codex app-server outbound request queue is full");
37698
37717
  if (!Number.isSafeInteger(this.nextId)) throw new Error("Codex app-server request id space is exhausted");
37699
37718
  const id2 = this.nextId++;
37700
- const result = new Promise((resolve16, reject) => {
37719
+ const result = new Promise((resolve17, reject) => {
37701
37720
  const timer = setTimeout(() => {
37702
37721
  this.pending.delete(id2);
37703
37722
  reject(new Error(`Codex app-server request timed out: ${method}`));
37704
37723
  }, timeoutMs);
37705
- this.pending.set(id2, { resolve: resolve16, reject, timer });
37724
+ this.pending.set(id2, { resolve: resolve17, reject, timer });
37706
37725
  });
37707
37726
  try {
37708
37727
  await this.write({ id: id2, method, params });
@@ -37739,7 +37758,7 @@ var init_codex_app_server = __esm({
37739
37758
  }
37740
37759
  whenIdle() {
37741
37760
  if (!this.draining) return Promise.resolve();
37742
- return new Promise((resolve16) => this.idleWaiters.add(resolve16));
37761
+ return new Promise((resolve17) => this.idleWaiters.add(resolve17));
37743
37762
  }
37744
37763
  consume(chunk2) {
37745
37764
  if (this.closed) return;
@@ -37803,7 +37822,7 @@ var init_codex_app_server = __esm({
37803
37822
  queueMicrotask(() => void this.drain());
37804
37823
  }
37805
37824
  if (!this.draining) {
37806
- for (const resolve16 of this.idleWaiters) resolve16();
37825
+ for (const resolve17 of this.idleWaiters) resolve17();
37807
37826
  this.idleWaiters.clear();
37808
37827
  }
37809
37828
  }
@@ -37867,8 +37886,8 @@ var init_codex_app_server = __esm({
37867
37886
  if (Buffer.byteLength(line, "utf8") > MAX_JSONL_BYTES) {
37868
37887
  return Promise.reject(new Error("Codex app-server outbound message exceeded its limit"));
37869
37888
  }
37870
- return new Promise((resolve16, reject) => {
37871
- this.child.stdin.write(line, "utf8", (error) => error ? reject(error) : resolve16());
37889
+ return new Promise((resolve17, reject) => {
37890
+ this.child.stdin.write(line, "utf8", (error) => error ? reject(error) : resolve17());
37872
37891
  });
37873
37892
  }
37874
37893
  fail(reason, error) {
@@ -38564,7 +38583,7 @@ var init_codex_app_server = __esm({
38564
38583
  while (Date.now() - start < ms) {
38565
38584
  const row = this.bindingForScope(threadSlug, sessionId);
38566
38585
  if (!row || row.current_turn_id !== turnId) return;
38567
- await new Promise((resolve16) => setTimeout(resolve16, 50));
38586
+ await new Promise((resolve17) => setTimeout(resolve17, 50));
38568
38587
  }
38569
38588
  }
38570
38589
  async waitForTurnCleared(threadSlug, sessionId, ms) {
@@ -38572,7 +38591,7 @@ var init_codex_app_server = __esm({
38572
38591
  while (Date.now() - start < ms) {
38573
38592
  const row = this.bindingForScope(threadSlug, sessionId);
38574
38593
  if (!row || row.current_turn_id === null) return;
38575
- await new Promise((resolve16) => setTimeout(resolve16, 100));
38594
+ await new Promise((resolve17) => setTimeout(resolve17, 100));
38576
38595
  }
38577
38596
  }
38578
38597
  // Dispatch entry: create a PERSISTED (ephemeral:false, restart-resumable) session with the worker
@@ -38780,14 +38799,14 @@ var init_codex_app_server = __esm({
38780
38799
  released = true;
38781
38800
  this.activeOperations--;
38782
38801
  if (this.activeOperations === 0) {
38783
- for (const resolve16 of this.operationWaiters) resolve16();
38802
+ for (const resolve17 of this.operationWaiters) resolve17();
38784
38803
  this.operationWaiters.clear();
38785
38804
  }
38786
38805
  };
38787
38806
  }
38788
38807
  whenOperationsIdle() {
38789
38808
  if (this.activeOperations === 0) return Promise.resolve();
38790
- return new Promise((resolve16) => this.operationWaiters.add(resolve16));
38809
+ return new Promise((resolve17) => this.operationWaiters.add(resolve17));
38791
38810
  }
38792
38811
  /** The connection is shared with every other store (and every other project), so the bridge only
38793
38812
  * stops USING it — closing it is its owner's job. Every read after this returns nothing. */
@@ -38902,8 +38921,8 @@ var init_codex_app_server = __esm({
38902
38921
  * the project to go idle, so the caller should proceed rather than hang; a rejection propagates. */
38903
38922
  async awaitAuthReplacement(replacement2) {
38904
38923
  let timer;
38905
- const expired = new Promise((resolve16) => {
38906
- timer = setTimeout(() => resolve16(false), this.authReplacementWaitMs);
38924
+ const expired = new Promise((resolve17) => {
38925
+ timer = setTimeout(() => resolve17(false), this.authReplacementWaitMs);
38907
38926
  timer.unref?.();
38908
38927
  });
38909
38928
  const settled = replacement2.then(() => true);
@@ -38924,14 +38943,14 @@ var init_codex_app_server = __esm({
38924
38943
  }
38925
38944
  whenTurnsIdle() {
38926
38945
  if (!this.hasInFlightTurns()) return Promise.resolve();
38927
- return new Promise((resolve16) => {
38928
- this.turnIdleWaiters.add(resolve16);
38929
- if (!this.hasInFlightTurns() && this.turnIdleWaiters.delete(resolve16)) resolve16();
38946
+ return new Promise((resolve17) => {
38947
+ this.turnIdleWaiters.add(resolve17);
38948
+ if (!this.hasInFlightTurns() && this.turnIdleWaiters.delete(resolve17)) resolve17();
38930
38949
  });
38931
38950
  }
38932
38951
  notifyTurnIdleWaiters() {
38933
38952
  if (this.dbReleased || this.hasInFlightTurns()) return;
38934
- for (const resolve16 of this.turnIdleWaiters) resolve16();
38953
+ for (const resolve17 of this.turnIdleWaiters) resolve17();
38935
38954
  this.turnIdleWaiters.clear();
38936
38955
  }
38937
38956
  async replaceAppServerForAuthChange(event) {
@@ -39580,18 +39599,18 @@ var init_codex_app_server = __esm({
39580
39599
  if (set.size === 0) this.settingsWaiters.delete(threadId);
39581
39600
  }
39582
39601
  };
39583
- const promise = new Promise((resolve16) => {
39584
- settle = resolve16;
39602
+ const promise = new Promise((resolve17) => {
39603
+ settle = resolve17;
39585
39604
  listener = (observed) => {
39586
39605
  detach();
39587
- resolve16(observed);
39606
+ resolve17(observed);
39588
39607
  };
39589
39608
  const set = this.settingsWaiters.get(threadId) ?? /* @__PURE__ */ new Set();
39590
39609
  set.add(listener);
39591
39610
  this.settingsWaiters.set(threadId, set);
39592
39611
  timer = setTimeout(() => {
39593
39612
  detach();
39594
- resolve16(void 0);
39613
+ resolve17(void 0);
39595
39614
  }, timeoutMs);
39596
39615
  timer.unref?.();
39597
39616
  });
@@ -40413,7 +40432,7 @@ function parseCodexQuotaFromRateLimits(result, observedAt = Date.now()) {
40413
40432
  } };
40414
40433
  }
40415
40434
  function queryCodexRateLimits(codexHome = defaultCodexHome(), codexBin = "codex", timeoutMs = 12e3) {
40416
- return new Promise((resolve16) => {
40435
+ return new Promise((resolve17) => {
40417
40436
  const observedAt = Date.now();
40418
40437
  const accountId = readCodexAccountId(codexHome);
40419
40438
  let child;
@@ -40426,7 +40445,7 @@ function queryCodexRateLimits(codexHome = defaultCodexHome(), codexBin = "codex"
40426
40445
  windowsHide: true
40427
40446
  });
40428
40447
  } catch {
40429
- resolve16(void 0);
40448
+ resolve17(void 0);
40430
40449
  return;
40431
40450
  }
40432
40451
  let settled = false;
@@ -40438,7 +40457,7 @@ function queryCodexRateLimits(codexHome = defaultCodexHome(), codexBin = "codex"
40438
40457
  child.kill("SIGKILL");
40439
40458
  } catch {
40440
40459
  }
40441
- resolve16(quota);
40460
+ resolve17(quota);
40442
40461
  };
40443
40462
  const timer = setTimeout(() => finish(void 0), timeoutMs);
40444
40463
  const send = (msg) => {
@@ -40699,7 +40718,7 @@ function readQuestionFences(storage, input) {
40699
40718
  const reusable = atMs >= IDS_REUSABLE_FROM_MS;
40700
40719
  const assembled = assembleQuestionFences(questionFenceBlocks(sighting.text).map((b) => b.read));
40701
40720
  const fault = (id2, text2) => out.faults.push({ at: at2, id: id2, faults: [text2] });
40702
- const refuse = (spec, id2, text2) => {
40721
+ const refuse2 = (spec, id2, text2) => {
40703
40722
  fault(id2, text2);
40704
40723
  for (const h3 of questionHandles(spec)) if (h3 !== id2) fault(h3, followUpRiderFault(id2));
40705
40724
  };
@@ -40741,7 +40760,7 @@ function readQuestionFences(storage, input) {
40741
40760
  options: node.options.map((o) => {
40742
40761
  const kept = (o.followUps ?? []).filter((child) => {
40743
40762
  if (!child.handle || !taken(child.handle)) return true;
40744
- refuse(child, child.handle, usedFault(child.handle));
40763
+ refuse2(child, child.handle, usedFault(child.handle));
40745
40764
  return false;
40746
40765
  }).map(pruned);
40747
40766
  const { followUps: _followUps, ...rest } = o;
@@ -40753,7 +40772,7 @@ function readQuestionFences(storage, input) {
40753
40772
  const id2 = child.handle ?? "";
40754
40773
  const existing = option.followUps?.find((f) => f.handle === child.handle);
40755
40774
  if (existing) {
40756
- if (!sameNode(existing, child) && entry.row.asked_at !== atMs) return void refuse(child, id2, usedFault(id2));
40775
+ if (!sameNode(existing, child) && entry.row.asked_at !== atMs) return void refuse2(child, id2, usedFault(id2));
40757
40776
  heldAt.set(id2, Math.max(heldAt.get(id2) ?? 0, atMs));
40758
40777
  for (const o of child.options ?? []) {
40759
40778
  const under2 = existing.options?.find((x2) => x2.label === o.label);
@@ -40761,10 +40780,10 @@ function readQuestionFences(storage, input) {
40761
40780
  }
40762
40781
  return;
40763
40782
  }
40764
- if (taken(id2)) return void refuse(child, id2, usedFault(id2));
40783
+ if (taken(id2)) return void refuse2(child, id2, usedFault(id2));
40765
40784
  const subtree = pruned(child);
40766
40785
  if (level + askedQuestionDepth(subtree) > ASK_MAX_DEPTH) {
40767
- return void refuse(child, id2, `it would reach level ${level + askedQuestionDepth(subtree)} under \`${entry.row.handle ?? entry.row.id}\`, and follow-ups go ${ASK_MAX_DEPTH} levels deep at most \u2014 past that you are asking the human to fill in a form; ask it as its own question, without the \`when:\` line, or decide it yourself`);
40786
+ return void refuse2(child, id2, `it would reach level ${level + askedQuestionDepth(subtree)} under \`${entry.row.handle ?? entry.row.id}\`, and follow-ups go ${ASK_MAX_DEPTH} levels deep at most \u2014 past that you are asking the human to fill in a form; ask it as its own question, without the \`when:\` line, or decide it yourself`);
40768
40787
  }
40769
40788
  option.followUps = [...option.followUps ?? [], subtree];
40770
40789
  entry.added.push(...questionHandles(subtree));
@@ -40779,12 +40798,12 @@ function readQuestionFences(storage, input) {
40779
40798
  const entry = treeOf(rootRow);
40780
40799
  const same2 = rootRow.handle === ask.id && entry !== void 0 && (sameNode(entry.root, ask.spec) || rootRow.asked_at === atMs);
40781
40800
  if (!same2) {
40782
- refuse(ask.spec, ask.id, usedFault(ask.id));
40801
+ refuse2(ask.spec, ask.id, usedFault(ask.id));
40783
40802
  } else if (settledBefore(rootRow)) {
40784
40803
  fault(ask.id, `\`${ask.id}\` was already asked and ${SETTLED_WORD[rootRow.state]} \u2014 this fence was written before a settled question's id could be asked again; ask it again in a new message if you still need an answer`);
40785
40804
  for (const o of ask.spec.options ?? []) {
40786
40805
  for (const child of o.followUps ?? []) {
40787
- if (child.handle && !nodeByHandle(entry.root, child.handle)) refuse(child, child.handle, settledParentFault(ask.id, rootRow.state));
40806
+ if (child.handle && !nodeByHandle(entry.root, child.handle)) refuse2(child, child.handle, settledParentFault(ask.id, rootRow.state));
40788
40807
  }
40789
40808
  }
40790
40809
  } else {
@@ -40795,7 +40814,7 @@ function readQuestionFences(storage, input) {
40795
40814
  for (const child of o.followUps ?? []) {
40796
40815
  if (!under2) continue;
40797
40816
  if (rootRow.state === "open") {
40798
- if (autonomousFault && !nodeByHandle(entry.root, child.handle ?? "")) refuse(child, child.handle ?? "", autonomousFault);
40817
+ if (autonomousFault && !nodeByHandle(entry.root, child.handle ?? "")) refuse2(child, child.handle ?? "", autonomousFault);
40799
40818
  else grow(entry, under2, 1, child);
40800
40819
  } else if (child.handle && nodeByHandle(entry.root, child.handle)) heldAt.set(child.handle, Math.max(heldAt.get(child.handle) ?? 0, atMs));
40801
40820
  }
@@ -40807,7 +40826,7 @@ function readQuestionFences(storage, input) {
40807
40826
  ask.spec = pruned(ask.spec);
40808
40827
  }
40809
40828
  if (childFault && !ask.spec.secret) {
40810
- refuse(ask.spec, ask.id, childFault);
40829
+ refuse2(ask.spec, ask.id, childFault);
40811
40830
  continue;
40812
40831
  }
40813
40832
  if (autonomousFault && !ask.spec.secret) {
@@ -40853,7 +40872,7 @@ function readQuestionFences(storage, input) {
40853
40872
  }
40854
40873
  const row = index.get(f.parent);
40855
40874
  if (!row) {
40856
- refuse(f.spec, f.id, taken(f.id) ? usedFault(f.id) : `\`when: ${f.parent} = ${f.option}\` names \`${f.parent}\`, which is neither a question in this message nor an open question of this thread \u2014 a follow-up hangs off a question that is still waiting for its answer; to ask this on its own, drop the \`when:\` line`);
40875
+ refuse2(f.spec, f.id, taken(f.id) ? usedFault(f.id) : `\`when: ${f.parent} = ${f.option}\` names \`${f.parent}\`, which is neither a question in this message nor an open question of this thread \u2014 a follow-up hangs off a question that is still waiting for its answer; to ask this on its own, drop the \`when:\` line`);
40857
40876
  continue;
40858
40877
  }
40859
40878
  const entry = treeOf(row);
@@ -40862,8 +40881,8 @@ function readQuestionFences(storage, input) {
40862
40881
  const already = entry ? nodeByHandle(entry.root, f.id) : void 0;
40863
40882
  if (already) {
40864
40883
  const inPlace = option?.followUps?.some((x2) => x2 === already.node) && sameNode(already.node, f.spec);
40865
- if (!inPlace) refuse(f.spec, f.id, usedFault(f.id));
40866
- else if (settledBefore(row)) refuse(f.spec, f.id, `\`${f.id}\` was already asked and ${SETTLED_WORD[row.state]} with the question it follows, so there is no open question to hang it from \u2014 ask it as its own question, without the \`when:\` line, if you still need an answer`);
40884
+ if (!inPlace) refuse2(f.spec, f.id, usedFault(f.id));
40885
+ else if (settledBefore(row)) refuse2(f.spec, f.id, `\`${f.id}\` was already asked and ${SETTLED_WORD[row.state]} with the question it follows, so there is no open question to hang it from \u2014 ask it as its own question, without the \`when:\` line, if you still need an answer`);
40867
40886
  else {
40868
40887
  ref(row);
40869
40888
  if (row.state === "open" && entry && option && target) grow(entry, option, target.level, f.spec);
@@ -40872,27 +40891,27 @@ function readQuestionFences(storage, input) {
40872
40891
  continue;
40873
40892
  }
40874
40893
  if (taken(f.id)) {
40875
- refuse(f.spec, f.id, usedFault(f.id));
40894
+ refuse2(f.spec, f.id, usedFault(f.id));
40876
40895
  continue;
40877
40896
  }
40878
40897
  if (row.state !== "open") {
40879
- refuse(f.spec, f.id, settledParentFault(f.parent, row.state));
40898
+ refuse2(f.spec, f.id, settledParentFault(f.parent, row.state));
40880
40899
  continue;
40881
40900
  }
40882
40901
  if (!entry || !target) {
40883
- refuse(f.spec, f.id, `\`when: ${f.parent} = ${f.option}\` names \`${f.parent}\`, whose stored question could not be read \u2014 ask this as its own question, without the \`when:\` line`);
40902
+ refuse2(f.spec, f.id, `\`when: ${f.parent} = ${f.option}\` names \`${f.parent}\`, whose stored question could not be read \u2014 ask this as its own question, without the \`when:\` line`);
40884
40903
  continue;
40885
40904
  }
40886
40905
  if (autonomousFault ?? childFault) {
40887
- refuse(f.spec, f.id, autonomousFault ?? childFault);
40906
+ refuse2(f.spec, f.id, autonomousFault ?? childFault);
40888
40907
  continue;
40889
40908
  }
40890
40909
  if (target.node.kind === "multi") {
40891
- refuse(f.spec, f.id, followUpMultiFault(f.parent));
40910
+ refuse2(f.spec, f.id, followUpMultiFault(f.parent));
40892
40911
  continue;
40893
40912
  }
40894
40913
  if (!option) {
40895
- refuse(f.spec, f.id, followUpOptionFault(when, target.node));
40914
+ refuse2(f.spec, f.id, followUpOptionFault(when, target.node));
40896
40915
  continue;
40897
40916
  }
40898
40917
  const before = entry.added.length;
@@ -41084,7 +41103,7 @@ function outputTail(chunks, max = COMMAND_WATCH_OUTPUT_MAX_BYTES) {
41084
41103
  function runWatchCommand(spec) {
41085
41104
  const startedAtMs = Date.now();
41086
41105
  const timeoutMs = spec.timeoutMs ?? COMMAND_WATCH_RUN_TIMEOUT_MS;
41087
- return new Promise((resolve16) => {
41106
+ return new Promise((resolve17) => {
41088
41107
  const chunks = [];
41089
41108
  let held = 0;
41090
41109
  const keep = (chunk2) => {
@@ -41103,7 +41122,7 @@ function runWatchCommand(spec) {
41103
41122
  for (const t of timers) clearTimeout(t);
41104
41123
  spec.signal?.removeEventListener("abort", onAbort);
41105
41124
  const output = outputTail(extra ? [...chunks, Buffer.from(extra)] : chunks);
41106
- resolve16({ ...result, output, startedAtMs, finishedAtMs: Date.now() });
41125
+ resolve17({ ...result, output, startedAtMs, finishedAtMs: Date.now() });
41107
41126
  };
41108
41127
  let child;
41109
41128
  try {
@@ -41157,7 +41176,7 @@ function createRunLimiter(limit) {
41157
41176
  const waiting = [];
41158
41177
  return async (fn) => {
41159
41178
  if (active < limit) active++;
41160
- else await new Promise((resolve16) => waiting.push(resolve16));
41179
+ else await new Promise((resolve17) => waiting.push(resolve17));
41161
41180
  try {
41162
41181
  return await fn();
41163
41182
  } finally {
@@ -41234,26 +41253,26 @@ function claudeSandboxRefusal(where) {
41234
41253
  return void 0;
41235
41254
  }
41236
41255
  function commandWatchRefusal(row, opts) {
41237
- const refuse = (reason) => `${reason}. ${COMMAND_WATCH_FALLBACK}`;
41256
+ const refuse2 = (reason) => `${reason}. ${COMMAND_WATCH_FALLBACK}`;
41238
41257
  if ((opts.platform ?? process.platform) === "win32") {
41239
- return refuse("command watches run under `/bin/sh`, which this machine does not have");
41258
+ return refuse2("command watches run under `/bin/sh`, which this machine does not have");
41240
41259
  }
41241
41260
  const backend = row.backend ?? "claude";
41242
41261
  if (backend !== "claude") {
41243
- return refuse(
41262
+ return refuse2(
41244
41263
  `command watches are for Claude threads only, and this one runs on ${backend === "codex" ? "Codex" : "an ACP agent"}: Frizz cannot tell whether your thread's own sandbox would have let the command run`
41245
41264
  );
41246
41265
  }
41247
41266
  if (row.permission_mode !== "bypassPermissions") {
41248
- return refuse(
41267
+ return refuse2(
41249
41268
  `this thread runs in \`${row.permission_mode ?? "an unrecorded"}\` permission mode, and the server runs a watched command with no permission check at all \u2014 so Frizz runs one only for a thread in \`bypassPermissions\` mode`
41250
41269
  );
41251
41270
  }
41252
41271
  if (row.permission_pending && row.permission_pending !== "bypassPermissions") {
41253
- return refuse(`this thread's permission mode is being changed to \`${row.permission_pending}\``);
41272
+ return refuse2(`this thread's permission mode is being changed to \`${row.permission_pending}\``);
41254
41273
  }
41255
41274
  const sandbox = claudeSandboxRefusal({ cwd: opts.cwd, env: opts.env, home: opts.home, managedPaths: opts.managedPaths, managedPreferencePaths: opts.managedPreferencePaths, readPlistJson: opts.readPlistJson });
41256
- if (sandbox) return refuse(sandbox);
41275
+ if (sandbox) return refuse2(sandbox);
41257
41276
  return void 0;
41258
41277
  }
41259
41278
  function startMonitorProcess(spec) {
@@ -41318,8 +41337,8 @@ function startMonitorProcess(spec) {
41318
41337
  };
41319
41338
  let child;
41320
41339
  let resolveDone;
41321
- const done = new Promise((resolve16) => {
41322
- resolveDone = resolve16;
41340
+ const done = new Promise((resolve17) => {
41341
+ resolveDone = resolve17;
41323
41342
  });
41324
41343
  let settled = false;
41325
41344
  let stopping = false;
@@ -41537,6 +41556,10 @@ import { spawn as spawn6 } from "node:child_process";
41537
41556
  import { closeSync as closeSync13, existsSync as existsSync13, fstatSync as fstatSync2, openSync as openSync14, readFileSync as readFileSync23, readSync as readSync7, realpathSync as realpathSync7, statSync as statSync18 } from "node:fs";
41538
41557
  import { homedir as homedir14 } from "node:os";
41539
41558
  import { basename as basename5, dirname as dirname12, isAbsolute as isAbsolute7, join as join35, resolve as resolve6, sep as sep2 } from "node:path";
41559
+ function isUnderRoot(path3, root, real = true) {
41560
+ if (!real) return path3 === root || path3.startsWith(root.endsWith(sep2) ? root : root + sep2);
41561
+ return isUnder(path3, root);
41562
+ }
41540
41563
  function isUnder(real, root) {
41541
41564
  let rootReal;
41542
41565
  try {
@@ -41641,7 +41664,8 @@ function localFileHeaders(file) {
41641
41664
  "x-content-type-options": "nosniff",
41642
41665
  "cache-control": "private, no-store",
41643
41666
  // A CSP sandbox stops Chrome's PDF viewer from loading at all, so only the download carries one.
41644
- ...file.pdf ? {} : { "content-security-policy": "default-src 'none'; sandbox" }
41667
+ // The board's own reader frames a PDF, and nobody else may.
41668
+ ...file.pdf ? { "x-frame-options": "SAMEORIGIN" } : { "content-security-policy": "default-src 'none'; sandbox" }
41645
41669
  };
41646
41670
  }
41647
41671
  function readLocalMarkdown(rawPath, roots) {
@@ -41666,11 +41690,11 @@ function defaultSpawn(command, args, options) {
41666
41690
  }
41667
41691
  async function awaitOpenerStart(child, command) {
41668
41692
  child.unref();
41669
- await new Promise((resolve16, reject) => {
41693
+ await new Promise((resolve17, reject) => {
41670
41694
  child.once("error", (error) => reject(new Error(
41671
41695
  error.code === "ENOENT" ? `${command} is not installed or not on PATH` : `could not start ${command}: ${error.message}`
41672
41696
  )));
41673
- child.once("spawn", resolve16);
41697
+ child.once("spawn", resolve17);
41674
41698
  });
41675
41699
  }
41676
41700
  function localFileOpenCommand(path3, selected, options = {}) {
@@ -44157,7 +44181,7 @@ function connectClaudeBroker(socketPath, handlers, options = {}) {
44157
44181
  next.on("error", () => next.destroy());
44158
44182
  };
44159
44183
  connect2();
44160
- const mcpRequest = (t, fields, timeoutMs) => new Promise((resolve16, reject) => {
44184
+ const mcpRequest = (t, fields, timeoutMs) => new Promise((resolve17, reject) => {
44161
44185
  if (closed) {
44162
44186
  reject(new Error("the broker connection is closed"));
44163
44187
  return;
@@ -44168,12 +44192,12 @@ function connectClaudeBroker(socketPath, handlers, options = {}) {
44168
44192
  reject(new Error("the Claude session did not answer the MCP request"));
44169
44193
  }, timeoutMs);
44170
44194
  if (timer.unref) timer.unref();
44171
- pendingMcp.set(requestId, { settle: resolve16, fail: reject, timer });
44195
+ pendingMcp.set(requestId, { settle: resolve17, fail: reject, timer });
44172
44196
  send({ t, requestId, ...fields });
44173
44197
  });
44174
44198
  return {
44175
44199
  sendInput: (message) => send({ t: "input", message }),
44176
- deliverInput: (message, { acknowledged, timeoutMs = 3e4 }) => new Promise((resolve16, reject) => {
44200
+ deliverInput: (message, { acknowledged, timeoutMs = 3e4 }) => new Promise((resolve17, reject) => {
44177
44201
  if (closed) {
44178
44202
  reject(undelivered(false));
44179
44203
  return;
@@ -44186,7 +44210,7 @@ function connectClaudeBroker(socketPath, handlers, options = {}) {
44186
44210
  entry2.fail(undelivered(entry2.written));
44187
44211
  }), timeoutMs);
44188
44212
  if (timer.unref) timer.unref();
44189
- const entry = { settle: resolve16, fail: reject, timer, written: false };
44213
+ const entry = { settle: resolve17, fail: reject, timer, written: false };
44190
44214
  pendingInputs.set(requestId, entry);
44191
44215
  const onWritten = (error) => {
44192
44216
  if (error) return;
@@ -44194,7 +44218,7 @@ function connectClaudeBroker(socketPath, handlers, options = {}) {
44194
44218
  if (acknowledged || !pendingInputs.has(requestId)) return;
44195
44219
  pendingInputs.delete(requestId);
44196
44220
  clearTimeout(timer);
44197
- resolve16();
44221
+ resolve17();
44198
44222
  };
44199
44223
  try {
44200
44224
  send(acknowledged ? { t: "input", message, requestId } : { t: "input", message }, onWritten);
@@ -44206,7 +44230,7 @@ function connectClaudeBroker(socketPath, handlers, options = {}) {
44206
44230
  }),
44207
44231
  answerPermission: (requestId, decision2) => send({ t: "permission", requestId, decision: decision2 }),
44208
44232
  interrupt: (options2) => send({ t: "interrupt", ...options2?.sendNow ? { sendNow: options2.sendNow } : {} }),
44209
- cancelInput: (id2) => new Promise((resolve16, reject) => {
44233
+ cancelInput: (id2) => new Promise((resolve17, reject) => {
44210
44234
  if (closed) {
44211
44235
  reject(new Error("the broker connection is closed"));
44212
44236
  return;
@@ -44217,10 +44241,10 @@ function connectClaudeBroker(socketPath, handlers, options = {}) {
44217
44241
  reject(new Error("the Claude session did not answer the unqueue request"));
44218
44242
  }, cancelTimeoutMs);
44219
44243
  if (timer.unref) timer.unref();
44220
- pendingCancels.set(requestId, { settle: resolve16, fail: reject, timer });
44244
+ pendingCancels.set(requestId, { settle: resolve17, fail: reject, timer });
44221
44245
  send({ t: "cancel-input", requestId, id: id2 });
44222
44246
  }),
44223
- stopTask: (taskId) => new Promise((resolve16, reject) => {
44247
+ stopTask: (taskId) => new Promise((resolve17, reject) => {
44224
44248
  if (closed) {
44225
44249
  reject(new Error("the broker connection is closed"));
44226
44250
  return;
@@ -44231,12 +44255,12 @@ function connectClaudeBroker(socketPath, handlers, options = {}) {
44231
44255
  reject(new Error("the Claude session did not answer the stop request"));
44232
44256
  }, cancelTimeoutMs);
44233
44257
  if (timer.unref) timer.unref();
44234
- pendingStops.set(requestId, { settle: resolve16, fail: reject, timer });
44258
+ pendingStops.set(requestId, { settle: resolve17, fail: reject, timer });
44235
44259
  send({ t: "stop-task", requestId, taskId });
44236
44260
  }),
44237
44261
  // The skill list is answered from the SDK's own memory (captured at initialize), so it shares the
44238
44262
  // short cancel deadline rather than the rename one.
44239
- listSkills: () => new Promise((resolve16, reject) => {
44263
+ listSkills: () => new Promise((resolve17, reject) => {
44240
44264
  if (closed) {
44241
44265
  reject(new Error("the broker connection is closed"));
44242
44266
  return;
@@ -44247,7 +44271,7 @@ function connectClaudeBroker(socketPath, handlers, options = {}) {
44247
44271
  reject(new Error("the Claude session did not answer the skill listing"));
44248
44272
  }, cancelTimeoutMs);
44249
44273
  if (timer.unref) timer.unref();
44250
- pendingSkills.set(requestId, { settle: resolve16, fail: reject, timer });
44274
+ pendingSkills.set(requestId, { settle: resolve17, fail: reject, timer });
44251
44275
  send({ t: "list-skills", requestId });
44252
44276
  }),
44253
44277
  // A status read is local to the CLI; a reconnect waits on the server's handshake, so it takes the
@@ -44255,7 +44279,7 @@ function connectClaudeBroker(socketPath, handlers, options = {}) {
44255
44279
  mcpServerStatus: () => mcpRequest("mcp-status", {}, cancelTimeoutMs).then((frame) => (Array.isArray(frame.servers) ? frame.servers : []).filter((s) => typeof s?.name === "string" && typeof s?.status === "string")),
44256
44280
  reconnectMcpServer: (name) => mcpRequest("mcp-reconnect", { name }, renameTimeoutMs).then(() => void 0),
44257
44281
  // The longer deadline: a re-title is a provider round trip, not local bookkeeping.
44258
- renameSession: (description) => new Promise((resolve16, reject) => {
44282
+ renameSession: (description) => new Promise((resolve17, reject) => {
44259
44283
  if (closed) {
44260
44284
  reject(new Error("the broker connection is closed"));
44261
44285
  return;
@@ -44266,7 +44290,7 @@ function connectClaudeBroker(socketPath, handlers, options = {}) {
44266
44290
  reject(new Error("the Claude session did not answer the rename request"));
44267
44291
  }, renameTimeoutMs);
44268
44292
  if (timer.unref) timer.unref();
44269
- pendingRenames.set(requestId, { settle: resolve16, fail: reject, timer });
44293
+ pendingRenames.set(requestId, { settle: resolve17, fail: reject, timer });
44270
44294
  send({ t: "rename", requestId, description });
44271
44295
  }),
44272
44296
  setPermissionMode: (mode) => send({ t: "set-mode", mode }),
@@ -47269,7 +47293,7 @@ ${peer.name ?? ""}`;
47269
47293
  return projectId === receiverProjectId || !project ? thread : { ...thread, project };
47270
47294
  };
47271
47295
  }
47272
- function projectTranscriptSessionPeers(messages, resolve16) {
47296
+ function projectTranscriptSessionPeers(messages, resolve17) {
47273
47297
  const cache2 = /* @__PURE__ */ new Map();
47274
47298
  let changed = false;
47275
47299
  const out = messages.map((message) => {
@@ -47277,7 +47301,7 @@ function projectTranscriptSessionPeers(messages, resolve16) {
47277
47301
  if (!peer?.socket) return message;
47278
47302
  const key = `${peer.socket}
47279
47303
  ${peer.name ?? ""}`;
47280
- if (!cache2.has(key)) cache2.set(key, resolve16(peer));
47304
+ if (!cache2.has(key)) cache2.set(key, resolve17(peer));
47281
47305
  const thread = cache2.get(key);
47282
47306
  if (!thread) return message;
47283
47307
  changed = true;
@@ -48008,14 +48032,14 @@ function createGithubReviewFetcher(deps = {}) {
48008
48032
  pending = /* @__PURE__ */ new Map();
48009
48033
  if (batch.size === 0) return;
48010
48034
  if (now() < notBeforeMs) {
48011
- for (const entry of batch.values()) for (const resolve16 of entry.resolve) resolve16({ status: "deferred" });
48035
+ for (const entry of batch.values()) for (const resolve17 of entry.resolve) resolve17({ status: "deferred" });
48012
48036
  return;
48013
48037
  }
48014
48038
  const entries2 = [...batch.values()];
48015
48039
  for (let offset = 0; offset < entries2.length; offset += MAX_REFS_PER_REQUEST) {
48016
48040
  const chunk2 = entries2.slice(offset, offset + MAX_REFS_PER_REQUEST);
48017
48041
  if (offset > 0 && now() < rateLimitBlockedUntilMs) {
48018
- for (const entry of chunk2) for (const resolve16 of entry.resolve) resolve16({ status: "deferred" });
48042
+ for (const entry of chunk2) for (const resolve17 of entry.resolve) resolve17({ status: "deferred" });
48019
48043
  continue;
48020
48044
  }
48021
48045
  let results;
@@ -48035,15 +48059,15 @@ function createGithubReviewFetcher(deps = {}) {
48035
48059
  status: "error",
48036
48060
  failure: { kind: "shape", message: `No GitHub result for ${refKey(entry.ref)}` }
48037
48061
  };
48038
- for (const resolve16 of entry.resolve) resolve16(result);
48062
+ for (const resolve17 of entry.resolve) resolve17(result);
48039
48063
  }
48040
48064
  }
48041
48065
  };
48042
- return (ref) => new Promise((resolve16) => {
48066
+ return (ref) => new Promise((resolve17) => {
48043
48067
  const key = refKey(ref);
48044
48068
  const existing = pending.get(key);
48045
- if (existing) existing.resolve.push(resolve16);
48046
- else pending.set(key, { ref, resolve: [resolve16] });
48069
+ if (existing) existing.resolve.push(resolve17);
48070
+ else pending.set(key, { ref, resolve: [resolve17] });
48047
48071
  if (!flushScheduled) {
48048
48072
  flushScheduled = true;
48049
48073
  queueMicrotask(() => {
@@ -48503,7 +48527,7 @@ function concurrencyGate(limit) {
48503
48527
  const waiting = [];
48504
48528
  return async (fn) => {
48505
48529
  if (active < limit) active++;
48506
- else await new Promise((resolve16) => waiting.push(resolve16));
48530
+ else await new Promise((resolve17) => waiting.push(resolve17));
48507
48531
  try {
48508
48532
  return await fn();
48509
48533
  } finally {
@@ -50207,8 +50231,8 @@ ${clock}`;
50207
50231
  const live2 = launchMonitor(service, w, now(), { events: [] });
50208
50232
  if (typeof live2 === "string") return { running: false, events: [], refused: live2 };
50209
50233
  let timer2;
50210
- await Promise.race([live2.ended, new Promise((resolve16) => {
50211
- timer2 = setTimeout(resolve16, windowMs);
50234
+ await Promise.race([live2.ended, new Promise((resolve17) => {
50235
+ timer2 = setTimeout(resolve17, windowMs);
50212
50236
  })]);
50213
50237
  if (timer2) clearTimeout(timer2);
50214
50238
  const seen = live2.registration ?? { events: [] };
@@ -51415,8 +51439,8 @@ function shellWrittenPaths(tool, projectDir) {
51415
51439
  const base = expandHome(target.base ?? tool.cwd ?? projectDir, home);
51416
51440
  const absoluteBase = path.isAbsolute(base) ? base : path.resolve(projectDir, base);
51417
51441
  const resolved2 = path.resolve(absoluteBase, expandHome(target.path, home));
51418
- const relative4 = path.relative(projectDir, resolved2);
51419
- if (relative4 === "" || relative4.startsWith("..") || path.isAbsolute(relative4)) continue;
51442
+ const relative5 = path.relative(projectDir, resolved2);
51443
+ if (relative5 === "" || relative5.startsWith("..") || path.isAbsolute(relative5)) continue;
51420
51444
  out.push(resolved2);
51421
51445
  }
51422
51446
  return out;
@@ -51836,20 +51860,20 @@ function pushUserRecord(out, sourceId, text2, at2, dropCorrection, shareId = tru
51836
51860
  }
51837
51861
  function createCorrectionSink(out) {
51838
51862
  const marked = /* @__PURE__ */ new Set();
51839
- const refuse = (correction) => {
51863
+ const refuse2 = (correction) => {
51840
51864
  if (marked.has(correction)) return;
51841
51865
  marked.add(correction);
51842
51866
  markFenceRefused(out);
51843
51867
  };
51844
51868
  return (text2) => {
51845
51869
  if (isParkCorrection(text2)) {
51846
- refuse(text2);
51870
+ refuse2(text2);
51847
51871
  return true;
51848
51872
  }
51849
51873
  const merged2 = parseMergedWake(text2);
51850
51874
  if (!merged2) return false;
51851
51875
  const corrections = merged2.filter((part) => isParkCorrection(part.body));
51852
- for (const part of corrections) refuse(part.body);
51876
+ for (const part of corrections) refuse2(part.body);
51853
51877
  return corrections.length === merged2.length;
51854
51878
  };
51855
51879
  }
@@ -54665,14 +54689,14 @@ var init_acp_rpc = __esm({
54665
54689
  this.process = process2;
54666
54690
  this.options = options;
54667
54691
  const maxLine = options.maxLineBytes ?? DEFAULT_MAX_LINE_BYTES;
54668
- this.exitPromise = new Promise((resolve16) => {
54692
+ this.exitPromise = new Promise((resolve17) => {
54669
54693
  process2.on("exit", (code, signal) => {
54670
54694
  this.settleClosed(`exit ${signal ?? code ?? "?"}`);
54671
- resolve16({ code, signal });
54695
+ resolve17({ code, signal });
54672
54696
  });
54673
54697
  process2.on("error", (err) => {
54674
54698
  this.settleClosed(err.message);
54675
- resolve16({ code: null, signal: null });
54699
+ resolve17({ code: null, signal: null });
54676
54700
  });
54677
54701
  });
54678
54702
  process2.stdin?.on("error", (err) => this.settleClosed(`stdin: ${err.message}`));
@@ -54727,13 +54751,13 @@ var init_acp_rpc = __esm({
54727
54751
  if (this.closedReason !== void 0) return Promise.reject(new AcpConnectionClosed(method, this.closedReason));
54728
54752
  const id2 = this.nextId++;
54729
54753
  const timeoutMs = opts.timeoutMs ?? this.options.requestTimeoutMs ?? DEFAULT_TIMEOUT_MS;
54730
- return new Promise((resolve16, reject) => {
54754
+ return new Promise((resolve17, reject) => {
54731
54755
  const timer = timeoutMs > 0 ? setTimeout(() => {
54732
54756
  this.pending.delete(id2);
54733
54757
  reject(new AcpRequestTimeout(method, timeoutMs));
54734
54758
  }, timeoutMs) : void 0;
54735
54759
  timer?.unref?.();
54736
- this.pending.set(id2, { method, resolve: resolve16, reject, timer });
54760
+ this.pending.set(id2, { method, resolve: resolve17, reject, timer });
54737
54761
  if (!this.write({ jsonrpc: "2.0", id: id2, method, params })) {
54738
54762
  this.pending.delete(id2);
54739
54763
  if (timer) clearTimeout(timer);
@@ -54755,8 +54779,8 @@ var init_acp_rpc = __esm({
54755
54779
  adoptPending(method, onId) {
54756
54780
  if (this.closedReason !== void 0) return Promise.reject(new AcpConnectionClosed(method, this.closedReason));
54757
54781
  const id2 = this.nextId++;
54758
- return new Promise((resolve16, reject) => {
54759
- this.pending.set(id2, { method, resolve: resolve16, reject, timer: void 0 });
54782
+ return new Promise((resolve17, reject) => {
54783
+ this.pending.set(id2, { method, resolve: resolve17, reject, timer: void 0 });
54760
54784
  onId(id2);
54761
54785
  });
54762
54786
  }
@@ -54918,12 +54942,12 @@ async function stopAcpDaemon(stateDir, sessionId, timeoutMs = 1e4) {
54918
54942
  }
54919
54943
  const deadline = Date.now() + timeoutMs;
54920
54944
  while (pidAlive4(record.daemonPid) && Date.now() < deadline) {
54921
- await new Promise((resolve16) => setTimeout(resolve16, 25));
54945
+ await new Promise((resolve17) => setTimeout(resolve17, 25));
54922
54946
  }
54923
54947
  if (pidAlive4(record.daemonPid)) {
54924
54948
  endDaemonTree(record.daemonPid, "SIGKILL");
54925
54949
  while (pidAlive4(record.daemonPid) && Date.now() < deadline + 2e3) {
54926
- await new Promise((resolve16) => setTimeout(resolve16, 25));
54950
+ await new Promise((resolve17) => setTimeout(resolve17, 25));
54927
54951
  }
54928
54952
  }
54929
54953
  }
@@ -54963,10 +54987,10 @@ function forkDaemon2(options) {
54963
54987
  });
54964
54988
  child.unref();
54965
54989
  const deadline = Date.now() + (options.timeoutMs ?? 3e4);
54966
- return new Promise((resolve16, reject) => {
54990
+ return new Promise((resolve17, reject) => {
54967
54991
  const poll = () => {
54968
54992
  const found = readAcpDaemonRecord(stateDir, sessionId);
54969
- if (found && pidAlive4(found.daemonPid)) return resolve16(found);
54993
+ if (found && pidAlive4(found.daemonPid)) return resolve17(found);
54970
54994
  if (!pidAlive4(child.pid ?? -1) && !found) return reject(new Error("acp daemon exited before it became ready"));
54971
54995
  if (Date.now() > deadline) return reject(new Error("acp daemon did not become ready"));
54972
54996
  setTimeout(poll, 50);
@@ -54991,7 +55015,7 @@ function parseHello(line) {
54991
55015
  }
54992
55016
  }
54993
55017
  function attach3(record, timeoutMs) {
54994
- return new Promise((resolve16, reject) => {
55018
+ return new Promise((resolve17, reject) => {
54995
55019
  const socket = createConnection2(record.socketPath);
54996
55020
  const stdout = new PassThrough3();
54997
55021
  const stderr = new PassThrough3();
@@ -55054,7 +55078,7 @@ function attach3(record, timeoutMs) {
55054
55078
  if (!settled) {
55055
55079
  settled = true;
55056
55080
  clearTimeout(timer);
55057
- resolve16({ process: handle, hello: parseHello(trimmed), adopt });
55081
+ resolve17({ process: handle, hello: parseHello(trimmed), adopt });
55058
55082
  continue;
55059
55083
  }
55060
55084
  try {
@@ -55306,9 +55330,9 @@ var init_acp_bridge = __esm({
55306
55330
  const conn = new AcpConnection(proc, {
55307
55331
  onRequest: (method, params) => {
55308
55332
  if (isReady && live2) return this.handleRequest(live2, method, params);
55309
- return new Promise((resolve16, reject) => {
55333
+ return new Promise((resolve17, reject) => {
55310
55334
  held.push(() => {
55311
- this.handleRequest(live2, method, params).then(resolve16, reject);
55335
+ this.handleRequest(live2, method, params).then(resolve17, reject);
55312
55336
  });
55313
55337
  });
55314
55338
  },
@@ -55894,8 +55918,8 @@ ${sendText}`;
55894
55918
  this.diagnostic(live2.slug, "permission", `could not record the approval: ${err.message}`);
55895
55919
  return Promise.resolve(failClosed);
55896
55920
  }
55897
- return new Promise((resolve16) => {
55898
- live2.pendingPerms.set(id2, { resolve: resolve16, optionByDecision: built.optionByDecision, scope });
55921
+ return new Promise((resolve17) => {
55922
+ live2.pendingPerms.set(id2, { resolve: resolve17, optionByDecision: built.optionByDecision, scope });
55899
55923
  this.options.onStatusChange?.();
55900
55924
  });
55901
55925
  }
@@ -84683,13 +84707,13 @@ function canonicalFingerprint(value) {
84683
84707
  }
84684
84708
  function abortableCallback(promise, signal, label) {
84685
84709
  if (signal.aborted) return Promise.reject(new ClaudeAgentSdkProtocolError(`${label} aborted`));
84686
- return new Promise((resolve16, reject) => {
84710
+ return new Promise((resolve17, reject) => {
84687
84711
  const abort = () => reject(new ClaudeAgentSdkProtocolError(`${label} aborted`));
84688
84712
  signal.addEventListener("abort", abort, { once: true });
84689
84713
  promise.then(
84690
84714
  (value) => {
84691
84715
  signal.removeEventListener("abort", abort);
84692
- resolve16(value);
84716
+ resolve17(value);
84693
84717
  },
84694
84718
  (error) => {
84695
84719
  signal.removeEventListener("abort", abort);
@@ -84874,7 +84898,7 @@ var init_claude_agent_sdk = __esm({
84874
84898
  if (value !== void 0) return Promise.resolve({ done: false, value });
84875
84899
  if (this.failure) return Promise.reject(this.failure);
84876
84900
  if (this.ended) return Promise.resolve({ done: true, value: void 0 });
84877
- const parked = new Promise((resolve16, reject) => this.waiters.push({ resolve: resolve16, reject }));
84901
+ const parked = new Promise((resolve17, reject) => this.waiters.push({ resolve: resolve17, reject }));
84878
84902
  for (const settle of this.drainListeners.splice(0)) settle();
84879
84903
  return parked;
84880
84904
  }
@@ -84889,7 +84913,7 @@ var init_claude_agent_sdk = __esm({
84889
84913
  whenDrained() {
84890
84914
  if (this.ended || this.failure) return Promise.resolve();
84891
84915
  if (this.buffered.length === 0 && this.waiters.length > 0) return Promise.resolve();
84892
- return new Promise((resolve16) => this.drainListeners.push(resolve16));
84916
+ return new Promise((resolve17) => this.drainListeners.push(resolve17));
84893
84917
  }
84894
84918
  [Symbol.asyncIterator]() {
84895
84919
  return this;
@@ -84989,8 +85013,8 @@ var init_claude_agent_sdk = __esm({
84989
85013
  this.redactor = redactor;
84990
85014
  this.diagnostic = diagnostic;
84991
85015
  this.rateLimit = rateLimit;
84992
- this.readyPromise = new Promise((resolve16, reject) => {
84993
- this.resolveReady = resolve16;
85016
+ this.readyPromise = new Promise((resolve17, reject) => {
85017
+ this.resolveReady = resolve17;
84994
85018
  this.rejectReady = reject;
84995
85019
  });
84996
85020
  void this.readyPromise.catch(() => void 0);
@@ -86254,7 +86278,7 @@ function createClaudeMcpProbe(options) {
86254
86278
  for (; ; ) {
86255
86279
  const rows = await handle.mcpServerStatus();
86256
86280
  if (!rows.some((row) => row.status === "pending") || Date.now() >= deadline) return rows;
86257
- await new Promise((resolve16) => setTimeout(resolve16, SETTLE_POLL_MS));
86281
+ await new Promise((resolve17) => setTimeout(resolve17, SETTLE_POLL_MS));
86258
86282
  }
86259
86283
  };
86260
86284
  const stdioRow = (name, server) => {
@@ -86338,7 +86362,7 @@ function createMcpService(deps) {
86338
86362
  if (!await signedIn.answer) throw new McpUnavailable(CLAUDE_SIGNED_OUT);
86339
86363
  return deps.claudeProbe();
86340
86364
  };
86341
- const resolve16 = (target) => {
86365
+ const resolve17 = (target) => {
86342
86366
  if ("slug" in target) {
86343
86367
  const row = deps.getSession(target.slug);
86344
86368
  if (!row) throw new Error(`thread ${target.slug} has no session to read MCP servers from`);
@@ -86401,7 +86425,7 @@ function createMcpService(deps) {
86401
86425
  const view = (attempt) => ({ state: attempt.state, ...attempt.error ? { error: attempt.error } : {} });
86402
86426
  return {
86403
86427
  async status(target) {
86404
- const resolved2 = resolve16(target);
86428
+ const resolved2 = resolve17(target);
86405
86429
  if (resolved2.backend === "acp") return { backend: "acp", agent: resolved2.agent, supported: false, servers: [] };
86406
86430
  if (resolved2.backend === "codex") {
86407
86431
  if (!deps.codexAppServer) return { backend: "codex", agent: resolved2.agent, supported: true, servers: [], note: CODEX_UNAVAILABLE };
@@ -86417,7 +86441,7 @@ function createMcpService(deps) {
86417
86441
  },
86418
86442
  async signIn(target, server) {
86419
86443
  sweep();
86420
- const resolved2 = resolve16(target);
86444
+ const resolved2 = resolve17(target);
86421
86445
  if (resolved2.backend === "acp") throw new Error(`${resolved2.agent} doesn't support MCP sign-in from Frizz`);
86422
86446
  for (const attempt2 of attempts.values()) {
86423
86447
  if (attempt2.state === "waiting" && attempt2.server === server && attempt2.backend === resolved2.backend) {
@@ -89869,13 +89893,15 @@ function errorEnvelope(err) {
89869
89893
  ...err?.deliveryKept === true ? { kept: true } : {}
89870
89894
  };
89871
89895
  }
89872
- function mountRouter(app, prefix, router) {
89896
+ function mountRouter(app, prefix, router, guard) {
89873
89897
  const procMap = extractProcedureMap(router);
89874
- app.get(`${prefix}/__procedures`, (c) => c.json(procMap));
89898
+ app.get(`${prefix}/__procedures`, (c) => guard?.procedure(c, "__procedures") ?? c.json(procMap));
89875
89899
  for (const [name, proc] of Object.entries(router)) {
89876
89900
  const path3 = `${prefix}/${name}`;
89877
89901
  if (proc._tag === "query") {
89878
89902
  app.get(path3, async (c) => {
89903
+ const refused = guard?.procedure(c, name);
89904
+ if (refused) return refused;
89879
89905
  const rawInput = c.req.query("input");
89880
89906
  let input;
89881
89907
  if (rawInput) {
@@ -89892,6 +89918,8 @@ function mountRouter(app, prefix, router) {
89892
89918
  }
89893
89919
  input = parsed.data;
89894
89920
  }
89921
+ const refusedInput = guard?.input?.(c, name, input);
89922
+ if (refusedInput) return refusedInput;
89895
89923
  try {
89896
89924
  const result = await proc.handler(input !== void 0 ? { input } : {});
89897
89925
  return c.json({ result });
@@ -89901,6 +89929,8 @@ function mountRouter(app, prefix, router) {
89901
89929
  });
89902
89930
  } else if (proc._tag === "mutation") {
89903
89931
  app.post(path3, async (c) => {
89932
+ const refused = guard?.procedure(c, name);
89933
+ if (refused) return refused;
89904
89934
  let input;
89905
89935
  const contentType = c.req.header("content-type");
89906
89936
  if (contentType?.includes("application/json")) {
@@ -89913,6 +89943,8 @@ function mountRouter(app, prefix, router) {
89913
89943
  }
89914
89944
  input = parsed.data;
89915
89945
  }
89946
+ const refusedInput = guard?.input?.(c, name, input);
89947
+ if (refusedInput) return refusedInput;
89916
89948
  try {
89917
89949
  const result = await proc.handler({ input });
89918
89950
  return c.json({ result: result ?? null });
@@ -89922,6 +89954,8 @@ function mountRouter(app, prefix, router) {
89922
89954
  });
89923
89955
  } else if (proc._tag === "stream") {
89924
89956
  app.get(path3, async (c) => {
89957
+ const refused = guard?.procedure(c, name);
89958
+ if (refused) return refused;
89925
89959
  const rawInput = c.req.query("input");
89926
89960
  let input;
89927
89961
  if (rawInput) {
@@ -89938,6 +89972,8 @@ function mountRouter(app, prefix, router) {
89938
89972
  }
89939
89973
  input = parsed.data;
89940
89974
  }
89975
+ const refusedInput = guard?.input?.(c, name, input);
89976
+ if (refusedInput) return refusedInput;
89941
89977
  return streamSSE(c, async (sseStream) => {
89942
89978
  let id2 = 0;
89943
89979
  const gen = proc.handler(input !== void 0 ? { input } : {});
@@ -89951,7 +89987,7 @@ function mountRouter(app, prefix, router) {
89951
89987
  });
89952
89988
  }
89953
89989
  }
89954
- app.all(`${prefix}/:procedure`, (c) => c.json(
89990
+ app.all(`${prefix}/:procedure`, (c) => guard?.procedure(c, c.req.param("procedure")) ?? c.json(
89955
89991
  {
89956
89992
  error: `unknown RPC procedure \`${c.req.param("procedure")}\` \u2014 this server does not implement it. A caller built against a different version of frizz is the usual cause.`
89957
89993
  },
@@ -90514,6 +90550,80 @@ var init_github_hovercard = __esm({
90514
90550
  }
90515
90551
  });
90516
90552
 
90553
+ // packages/server/src/remote-reads.ts
90554
+ import { realpathSync as realpathSync15 } from "node:fs";
90555
+ import { isAbsolute as isAbsolute12, join as join53, relative as relative2, resolve as resolve13, sep as sep4 } from "node:path";
90556
+ function refusedSegment(segment) {
90557
+ if (segment === "" || segment === ".frizz") return false;
90558
+ return segment.startsWith(".") || SECRET_NAME2.test(segment);
90559
+ }
90560
+ function refusedBelow(root, path3) {
90561
+ return relative2(root, path3).split(sep4).some(refusedSegment);
90562
+ }
90563
+ function realOrNull(path3) {
90564
+ try {
90565
+ return realpathSync15(path3);
90566
+ } catch {
90567
+ return null;
90568
+ }
90569
+ }
90570
+ function readableUnderStateRoots(real) {
90571
+ const data = realOrNull(frizzRoots().data);
90572
+ if (!data) return void 0;
90573
+ const projects = join53(data, "projects");
90574
+ if (isUnderRoot(real, projects)) {
90575
+ const [id2, kept] = relative2(projects, real).split(sep4);
90576
+ return id2 && kept === "attachments" ? join53(projects, id2, "attachments") : void 0;
90577
+ }
90578
+ const scratch = realOrNull(join53(launchHostDir(), ".frizz", "threads"));
90579
+ return scratch && isUnderRoot(real, scratch) ? scratch : void 0;
90580
+ }
90581
+ function remoteProjectDirs(current2) {
90582
+ return [current2, ...listProjects().map((project) => project.path)];
90583
+ }
90584
+ function remoteReadablePath(rawPath, projectDirs) {
90585
+ const raw2 = normalizeLocalPath(rawPath);
90586
+ if (!isAbsolute12(raw2)) return null;
90587
+ const real = realOrNull(raw2);
90588
+ if (!real) return null;
90589
+ const roots = frizzRoots();
90590
+ const underStateRoot = [roots.data, roots.state, roots.cache].some((root2) => isUnderRoot(real, root2));
90591
+ const root = underStateRoot ? readableUnderStateRoots(real) : projectDirs.find((dir) => isUnderRoot(real, dir));
90592
+ if (!root) return null;
90593
+ const realRoot = realOrNull(root);
90594
+ if (!realRoot || refusedBelow(realRoot, real)) return null;
90595
+ const asked = resolve13(raw2);
90596
+ for (const base of [root, realRoot]) {
90597
+ if (isUnderRoot(asked, base, false) && refusedBelow(base, asked)) return null;
90598
+ }
90599
+ return real;
90600
+ }
90601
+ var SECRET_NAME2;
90602
+ var init_remote_reads = __esm({
90603
+ "packages/server/src/remote-reads.ts"() {
90604
+ "use strict";
90605
+ init_frizz_paths();
90606
+ init_local_file();
90607
+ init_local_path();
90608
+ init_project_registry();
90609
+ SECRET_NAME2 = new RegExp(
90610
+ "^(?:" + [
90611
+ "id_(?:rsa|dsa|ecdsa|ed25519)(?:_sk)?",
90612
+ "credentials(?:\\..*)?",
90613
+ "secrets?(?:\\..*)?",
90614
+ "token(?:\\..*)?",
90615
+ "session-key",
90616
+ "sessions\\.json",
90617
+ "identity\\.key",
90618
+ "auth\\.json",
90619
+ "service-account.*\\.json",
90620
+ ".*\\.(?:pem|key|p12|pfx|keystore|jks|ppk|kdbx|tfstate|asc|gpg|token)"
90621
+ ].join("|") + ")$",
90622
+ "i"
90623
+ );
90624
+ }
90625
+ });
90626
+
90517
90627
  // packages/server/src/backend/account-actions.ts
90518
90628
  import { execFile as execFile10 } from "node:child_process";
90519
90629
  import { promisify as promisify8 } from "node:util";
@@ -91183,9 +91293,9 @@ var init_raster = __esm({
91183
91293
  // packages/server/src/icon-renditions.ts
91184
91294
  import { mkdirSync as mkdirSync29, readdirSync as readdirSync15, readFileSync as readFileSync38, renameSync as renameSync15, rmSync as rmSync17, writeFileSync as writeFileSync22 } from "node:fs";
91185
91295
  import { homedir as homedir23 } from "node:os";
91186
- import { join as join53 } from "node:path";
91296
+ import { join as join54 } from "node:path";
91187
91297
  function iconRenditionDir(id2, home = homedir23()) {
91188
- return join53(frizzPaths({ home }).cache, "project-icons", id2);
91298
+ return join54(frizzPaths({ home }).cache, "project-icons", id2);
91189
91299
  }
91190
91300
  function renditionName(hash, size) {
91191
91301
  return `${hash}-${size}.v${RENDITION_VERSION}.png`;
@@ -91205,7 +91315,7 @@ function projectIconRendition(id2, bytes, hash, size, options = {}) {
91205
91315
  const dimensions = rasterDimensions(bytes);
91206
91316
  if (!dimensions || Math.max(dimensions.width, dimensions.height) <= size) return void 0;
91207
91317
  const dir = iconRenditionDir(id2, options.home);
91208
- const file = join53(dir, renditionName(hash, size));
91318
+ const file = join54(dir, renditionName(hash, size));
91209
91319
  try {
91210
91320
  return readFileSync38(file);
91211
91321
  } catch {
@@ -91215,7 +91325,7 @@ function projectIconRendition(id2, bytes, hash, size, options = {}) {
91215
91325
  const png2 = encodePng(resizeToFit(master, size));
91216
91326
  try {
91217
91327
  mkdirSync29(dir, { recursive: true });
91218
- for (const name of readdirSync15(dir)) if (!name.startsWith(`${hash}-`)) rmSync17(join53(dir, name), { force: true });
91328
+ for (const name of readdirSync15(dir)) if (!name.startsWith(`${hash}-`)) rmSync17(join54(dir, name), { force: true });
91219
91329
  const partial = `${file}.${process.pid}.tmp`;
91220
91330
  writeFileSync22(partial, png2);
91221
91331
  renameSync15(partial, file);
@@ -91238,9 +91348,9 @@ var init_icon_renditions = __esm({
91238
91348
  });
91239
91349
 
91240
91350
  // packages/server/src/project-icon.ts
91241
- import { readFileSync as readFileSync39, readdirSync as readdirSync16, realpathSync as realpathSync15, statSync as statSync26 } from "node:fs";
91351
+ import { readFileSync as readFileSync39, readdirSync as readdirSync16, realpathSync as realpathSync16, statSync as statSync26 } from "node:fs";
91242
91352
  import { homedir as homedir24 } from "node:os";
91243
- import { basename as basename11, dirname as dirname24, extname as extname3, join as join54, relative as relative2, sep as sep4 } from "node:path";
91353
+ import { basename as basename11, dirname as dirname24, extname as extname3, join as join55, relative as relative3, sep as sep5 } from "node:path";
91244
91354
  function normalizeStem(stem) {
91245
91355
  const sized = stem.toLowerCase().replace(/[@-]\d+(\.\d+)?x(\d+)?$/u, "").replace(/[-_]\d{2,4}$/u, "");
91246
91356
  const themed = sized.replace(VARIANT_SUFFIX, "");
@@ -91261,7 +91371,7 @@ function sizeScore(dimensions) {
91261
91371
  return Math.max(0, Math.min(40, Math.round(Math.log2(edge / 24) * 8)));
91262
91372
  }
91263
91373
  function under(root, relativeDirectory) {
91264
- return relativeDirectory ? join54(root, relativeDirectory) : root;
91374
+ return relativeDirectory ? join55(root, relativeDirectory) : root;
91265
91375
  }
91266
91376
  function listFiles(directory) {
91267
91377
  try {
@@ -91283,19 +91393,19 @@ function iconDirectories(root) {
91283
91393
  for (const asset of ASSET_DIRECTORIES) directories.push(under(root, asset));
91284
91394
  for (const host of HOST_DIRECTORIES) {
91285
91395
  if (!children2.has(host)) continue;
91286
- for (const asset of ASSET_DIRECTORIES) directories.push(under(join54(root, host), asset));
91396
+ for (const asset of ASSET_DIRECTORIES) directories.push(under(join55(root, host), asset));
91287
91397
  }
91288
91398
  for (const extra of EXTRA_DIRECTORIES) directories.push(under(root, extra));
91289
91399
  for (const container of WORKSPACE_CONTAINERS) {
91290
91400
  if (!children2.has(container)) continue;
91291
91401
  let members;
91292
91402
  try {
91293
- members = readdirSync16(join54(root, container), { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name);
91403
+ members = readdirSync16(join55(root, container), { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name);
91294
91404
  } catch {
91295
91405
  continue;
91296
91406
  }
91297
91407
  for (const member of members) {
91298
- for (const asset of ASSET_DIRECTORIES) directories.push(under(join54(root, container, member), asset));
91408
+ for (const asset of ASSET_DIRECTORIES) directories.push(under(join55(root, container, member), asset));
91299
91409
  }
91300
91410
  }
91301
91411
  return [...new Set(directories)];
@@ -91309,7 +91419,7 @@ function manifestIcons(manifestPath) {
91309
91419
  }
91310
91420
  if (!Array.isArray(parsed?.icons)) return [];
91311
91421
  const directory = dirname24(manifestPath);
91312
- return parsed.icons.map((icon) => typeof icon?.src === "string" ? icon.src : void 0).filter((src) => !!src && !/^(https?:)?\/\//u.test(src) && !src.startsWith("data:")).map((src) => join54(directory, src.replace(/[?#].*$/u, "").replace(/^\//u, "")));
91422
+ return parsed.icons.map((icon) => typeof icon?.src === "string" ? icon.src : void 0).filter((src) => !!src && !/^(https?:)?\/\//u.test(src) && !src.startsWith("data:")).map((src) => join55(directory, src.replace(/[?#].*$/u, "").replace(/^\//u, "")));
91313
91423
  }
91314
91424
  function projectIconCandidates(root) {
91315
91425
  const projectStem = normalizeStem(basename11(root)).normalized;
@@ -91328,7 +91438,7 @@ function projectIconCandidates(root) {
91328
91438
  for (const name of listFiles(directory)) {
91329
91439
  const extension2 = extname3(name).toLowerCase();
91330
91440
  if (MANIFEST_NAMES.includes(name.toLowerCase())) {
91331
- for (const icon of manifestIcons(join54(directory, name))) {
91441
+ for (const icon of manifestIcons(join55(directory, name))) {
91332
91442
  if (MEASURABLE_IMAGE_EXTENSIONS.has(extname3(icon).toLowerCase())) {
91333
91443
  fromManifest.add(icon);
91334
91444
  files.push({ path: icon, directory: dirname24(icon) });
@@ -91339,7 +91449,7 @@ function projectIconCandidates(root) {
91339
91449
  if (!MEASURABLE_IMAGE_EXTENSIONS.has(extension2)) continue;
91340
91450
  const stem = name.slice(0, name.length - extension2.length);
91341
91451
  if (normalizeStem(stem).normalized === "favicon") iconHomes.add(directory);
91342
- files.push({ path: join54(directory, name), directory });
91452
+ files.push({ path: join55(directory, name), directory });
91343
91453
  if (files.length >= MAX_CANDIDATES) break;
91344
91454
  }
91345
91455
  }
@@ -91361,10 +91471,10 @@ function projectIconCandidates(root) {
91361
91471
  const aspect = dimensions.width / dimensions.height;
91362
91472
  if (aspect < MIN_ASPECT || aspect > MAX_ASPECT) continue;
91363
91473
  const home = iconHomes.has(directory);
91364
- const segments = directory === root ? [] : relative2(root, directory).split(sep4);
91474
+ const segments = directory === root ? [] : relative3(root, directory).split(sep5);
91365
91475
  const generated = segments.some((segment) => GENERATED_DIRECTORIES.has(segment));
91366
91476
  const score = sizeScore(dimensions) + (FORMAT_SCORES[extension2] ?? 0) + (named?.score ?? 0) + (!square ? 0 : named || isProjectNamed ? 2 : squareCut ? 20 : 0) + (isProjectNamed ? 16 : 0) + (viaManifest ? 8 : 0) + (home ? 10 : 0) + (segments.length === 0 ? 8 : 0) + (svgDeclaresColour(path3) === false ? -COLOURLESS_SVG_PENALTY : 0) - (variant ? 3 : 0) - (generated ? 6 : 0) - Math.min(8, segments.length * 2);
91367
- const where = directory === root ? "the project root" : relative2(root, directory);
91477
+ const where = directory === root ? "the project root" : relative3(root, directory);
91368
91478
  const size = dimensions.scalable ? "scalable" : `${Math.round(dimensions.width)}\xD7${Math.round(dimensions.height)}`;
91369
91479
  const why = isProjectNamed && !named ? "named after the project" : named?.reason ?? (squareCut ? "the square logo" : "listed in the web manifest");
91370
91480
  const colourless = svgDeclaresColour(path3) === false ? ", no colour of its own" : "";
@@ -91391,19 +91501,19 @@ function resolveProjectIconResponse(id2, options = {}) {
91391
91501
  if (!contentType) return { status: 404 };
91392
91502
  let real;
91393
91503
  try {
91394
- real = realpathSync15(path3);
91504
+ real = realpathSync16(path3);
91395
91505
  if (!statSync26(real).isFile()) return { status: 404 };
91396
91506
  } catch {
91397
91507
  return { status: 404 };
91398
91508
  }
91399
91509
  const roots = [entry.path, projectStateDir(id2, home)].map((root) => {
91400
91510
  try {
91401
- return realpathSync15(root);
91511
+ return realpathSync16(root);
91402
91512
  } catch {
91403
91513
  return root;
91404
91514
  }
91405
91515
  });
91406
- if (!roots.some((root) => real === root || real.startsWith(root + sep4))) return { status: 404 };
91516
+ if (!roots.some((root) => real === root || real.startsWith(root + sep5))) return { status: 404 };
91407
91517
  let body;
91408
91518
  try {
91409
91519
  body = readFileSync39(real);
@@ -91544,8 +91654,8 @@ function openPanel(kind, command = panelCommand(kind)) {
91544
91654
  let reaped = false;
91545
91655
  let stderr = "";
91546
91656
  let settle;
91547
- const outcome = new Promise((resolve16) => {
91548
- settle = resolve16;
91657
+ const outcome = new Promise((resolve17) => {
91658
+ settle = resolve17;
91549
91659
  });
91550
91660
  createInterface({ input: child.stdout }).on("line", (line) => {
91551
91661
  let message;
@@ -91772,7 +91882,7 @@ function run(argv) {
91772
91882
 
91773
91883
  // packages/server/src/router.ts
91774
91884
  import { readFileSync as readFileSync40, statSync as statSync27 } from "node:fs";
91775
- import { join as join55, resolve as resolve13 } from "node:path";
91885
+ import { join as join56, resolve as resolve14 } from "node:path";
91776
91886
  import { randomUUID as randomUUID20 } from "node:crypto";
91777
91887
  import { basename as basename12, dirname as dirname25 } from "node:path";
91778
91888
  import { existsSync as existsSync22, mkdirSync as mkdirSync30, rmSync as rmSync18, writeFileSync as writeFileSync23 } from "node:fs";
@@ -91964,8 +92074,8 @@ function projectCard(entry, stale) {
91964
92074
  function addProjectAtPath(input, home = homedir25()) {
91965
92075
  const typed = input.trim();
91966
92076
  if (!typed) throw new Error("Enter a folder path.");
91967
- const expanded = typed === "~" || typed.startsWith("~/") ? join55(home, typed.slice(1)) : typed;
91968
- const absolute = resolve13(expanded);
92077
+ const expanded = typed === "~" || typed.startsWith("~/") ? join56(home, typed.slice(1)) : typed;
92078
+ const absolute = resolve14(expanded);
91969
92079
  let stats;
91970
92080
  try {
91971
92081
  stats = statSync27(absolute);
@@ -92051,7 +92161,7 @@ function mergeSubAgentSteers(messages, steers) {
92051
92161
  return merged2;
92052
92162
  }
92053
92163
  function createRouter(ctx) {
92054
- const frizzDir = join55(ctx.project.dir, ".frizz");
92164
+ const frizzDir = join56(ctx.project.dir, ".frizz");
92055
92165
  const openRoots = openableFileRoots(ctx.project);
92056
92166
  const thisProject = { id: ctx.project.id, dir: ctx.project.dir };
92057
92167
  const audit = (action, base, run3, onResult) => audited(ctx.audit, action, base, run3, { onResult, servedBy: ctx.project.id });
@@ -93230,7 +93340,7 @@ ${gapNote}` : input.message;
93230
93340
  detail: { prompt: textDigest(input.prompt), backend: input.backend ?? "claude", model: input.model ?? null, effort: input.effort ?? null }
93231
93341
  },
93232
93342
  () => ctx.dispatcher.dispatch(input, { backend: input.backend }),
93233
- (result) => ({ thread: result.slug, detail: { sessionId: result.sessionId } })
93343
+ (result) => ({ thread: result.slug, detail: { sessionId: result.sessionId, permissionMode: ctx.storage.getSession(result.slug)?.permission_mode ?? null } })
93234
93344
  )
93235
93345
  }),
93236
93346
  // Cold-adopt a pre-existing thread (no session row): spawn a fresh worker on its file.
@@ -94195,6 +94305,14 @@ ${gapNote}` : input.message;
94195
94305
  ...everyMs !== everyAsked ? { every: input.every } : {},
94196
94306
  ...forMs !== forAsked ? { for: input.for } : {}
94197
94307
  };
94308
+ recordAudit(ctx.audit, () => ({
94309
+ action: "commandWatchArm",
94310
+ outcome: "ok",
94311
+ project: thisProject,
94312
+ thread: input.slug,
94313
+ servedBy: ctx.project.id,
94314
+ detail: { command: textDigest(command), everyMs, forMs }
94315
+ }));
94198
94316
  const first = await service.probe(input.slug, command);
94199
94317
  const firstRun = first ? { at: new Date(first.finishedAtMs).toISOString(), outcome: first.outcome, exitCode: first.exitCode, output: first.output } : void 0;
94200
94318
  if (first?.outcome === "exit" && first.exitCode === 0) {
@@ -94272,7 +94390,7 @@ ${gapNote}` : input.message;
94272
94390
  if (!w || w.kind !== "monitor" || w.thread_slug !== input.slug) {
94273
94391
  return { command: null, description: null, output: "", truncated: false, state: "gone", ended: null, events: 0, startedAt: null, stoppable: false };
94274
94392
  }
94275
- const content = readBackgroundShellOutput(monitorOutputPath(join55(ctx.project.stateDir, "monitors"), w.id));
94393
+ const content = readBackgroundShellOutput(monitorOutputPath(join56(ctx.project.stateDir, "monitors"), w.id));
94276
94394
  const running = w.state === "armed";
94277
94395
  return {
94278
94396
  command: w.command,
@@ -94311,11 +94429,11 @@ ${gapNote}` : input.message;
94311
94429
  if (row.state === "archived" || row.archived === 1) {
94312
94430
  throw new Error("Reopen this thread before registering a monitor on it");
94313
94431
  }
94314
- const refuse = (refused) => ({ refused, alreadyArmed: false, running: false, events: [], watches: armedCommandWatchViews(input.slug) });
94432
+ const refuse2 = (refused) => ({ refused, alreadyArmed: false, running: false, events: [], watches: armedCommandWatchViews(input.slug) });
94315
94433
  const service = ctx.commandWatches;
94316
94434
  const gate = service ? service.refusal(row) : `this server cannot run monitors. ${MONITOR_FALLBACK}`;
94317
- if (gate) return refuse(`Frizz will not run a monitor for this thread: ${gate.replace(COMMAND_WATCH_FALLBACK, MONITOR_FALLBACK)}`);
94318
- if (!service?.startMonitor || !ctx.scheduler?.startMonitor) return refuse(`Frizz will not run a monitor for this thread: this server cannot run monitors. ${MONITOR_FALLBACK}`);
94435
+ if (gate) return refuse2(`Frizz will not run a monitor for this thread: ${gate.replace(COMMAND_WATCH_FALLBACK, MONITOR_FALLBACK)}`);
94436
+ if (!service?.startMonitor || !ctx.scheduler?.startMonitor) return refuse2(`Frizz will not run a monitor for this thread: this server cannot run monitors. ${MONITOR_FALLBACK}`);
94319
94437
  const command = input.command.trim();
94320
94438
  const description = input.description?.trim().replace(/\s+/g, " ") || void 0;
94321
94439
  const armed = ctx.storage.listCommandWatches(input.slug, { armedOnly: true });
@@ -94334,7 +94452,7 @@ ${gapNote}` : input.message;
94334
94452
  throw new Error(`this thread already has ${armed.length} command watches and monitors armed (the limit is ${COMMAND_WATCH_MAX_ARMED}) \u2014 drop one first`);
94335
94453
  }
94336
94454
  if ((service.monitorsRunning?.() ?? 0) >= MONITOR_SERVER_MAX_RUNNING) {
94337
- return refuse(`Frizz already runs ${MONITOR_SERVER_MAX_RUNNING} monitors across every project, its limit. ${MONITOR_FALLBACK}`);
94455
+ return refuse2(`Frizz already runs ${MONITOR_SERVER_MAX_RUNNING} monitors across every project, its limit. ${MONITOR_FALLBACK}`);
94338
94456
  }
94339
94457
  const forAsked = parseAwaitingDurationRaw(input.for);
94340
94458
  if (forAsked === null) throw new Error(`\`--for ${input.for}\` is not a duration \u2014 give one like \`2h\` or \`3d\` (max 7d)`);
@@ -94342,6 +94460,14 @@ ${gapNote}` : input.message;
94342
94460
  const now = Date.now();
94343
94461
  const id2 = `cmw_${randomUUID20().replace(/-/g, "").slice(0, 12)}`;
94344
94462
  ctx.storage.clearThreadDone(input.slug);
94463
+ recordAudit(ctx.audit, () => ({
94464
+ action: "monitorArm",
94465
+ outcome: "ok",
94466
+ project: thisProject,
94467
+ thread: input.slug,
94468
+ servedBy: ctx.project.id,
94469
+ detail: { id: id2, command: textDigest(command), forMs }
94470
+ }));
94345
94471
  ctx.storage.armMonitor({ id: id2, slug: input.slug, command, description, createdAtMs: now, expiresAtMs: now + forMs });
94346
94472
  const started = await ctx.scheduler.startMonitor(id2);
94347
94473
  ctx.board.refresh();
@@ -94349,7 +94475,7 @@ ${gapNote}` : input.message;
94349
94475
  if (started.refused) {
94350
94476
  ctx.storage.settleCommandWatch(id2, "cancelled", Date.now());
94351
94477
  ctx.board.refresh();
94352
- return refuse(`Frizz could not start your monitor: ${started.refused}. ${MONITOR_FALLBACK}`);
94478
+ return refuse2(`Frizz could not start your monitor: ${started.refused}. ${MONITOR_FALLBACK}`);
94353
94479
  }
94354
94480
  if (started.exited) {
94355
94481
  const notHere = started.exited.outcome === "error" || started.exited.outcome === "exit" && (started.exited.exitCode === 126 || started.exited.exitCode === 127);
@@ -94707,8 +94833,14 @@ Say which way you went and why in your write-up, so the human can course-correct
94707
94833
  output: external_exports.object({ resolved: external_exports.array(external_exports.object({ input: external_exports.string(), path: external_exports.string().nullable() })) }),
94708
94834
  handler: async ({ input }) => {
94709
94835
  const memo3 = /* @__PURE__ */ new Map();
94836
+ const via = currentRequestOrigin().via;
94837
+ const remote = via === "public" || via === "network";
94838
+ const dirs = remote ? remoteProjectDirs(ctx.project.dir) : [];
94710
94839
  const resolved2 = input.paths.map((raw2) => {
94711
- if (!memo3.has(raw2)) memo3.set(raw2, resolveOpenableFile(raw2, ctx.project.dir, openRoots));
94840
+ if (!memo3.has(raw2)) {
94841
+ const path3 = resolveOpenableFile(raw2, ctx.project.dir, openRoots);
94842
+ memo3.set(raw2, path3 && (!remote || remoteReadablePath(path3, dirs)) ? path3 : null);
94843
+ }
94712
94844
  return { input: raw2, path: memo3.get(raw2) ?? null };
94713
94845
  });
94714
94846
  return { resolved: resolved2 };
@@ -95421,6 +95553,7 @@ var init_router5 = __esm({
95421
95553
  init_claude_model_upgrade();
95422
95554
  init_logging();
95423
95555
  init_audit();
95556
+ init_remote_reads();
95424
95557
  init_codex();
95425
95558
  init_claude_broker_host();
95426
95559
  init_thread_hibernation();
@@ -95508,8 +95641,8 @@ var init_compression = __esm({
95508
95641
  });
95509
95642
 
95510
95643
  // packages/server/src/local-visualization.ts
95511
- import { readdirSync as readdirSync17, readFileSync as readFileSync41, realpathSync as realpathSync16, statSync as statSync28 } from "node:fs";
95512
- import { join as join56, sep as sep5 } from "node:path";
95644
+ import { readdirSync as readdirSync17, readFileSync as readFileSync41, realpathSync as realpathSync17, statSync as statSync28 } from "node:fs";
95645
+ import { join as join57, sep as sep6 } from "node:path";
95513
95646
  function children(path3, pattern) {
95514
95647
  try {
95515
95648
  return readdirSync17(path3, { withFileTypes: true }).filter((entry) => entry.isDirectory() && pattern.test(entry.name)).map((entry) => entry.name).sort().reverse();
@@ -95518,28 +95651,28 @@ function children(path3, pattern) {
95518
95651
  }
95519
95652
  }
95520
95653
  function isUnder2(path3, root) {
95521
- return path3 === root || path3.startsWith(root.endsWith(sep5) ? root : root + sep5);
95654
+ return path3 === root || path3.startsWith(root.endsWith(sep6) ? root : root + sep6);
95522
95655
  }
95523
95656
  function resolveFragment(projectDir, sessionId, file) {
95524
- const base = join56(projectDir, ".codex", "visualizations");
95657
+ const base = join57(projectDir, ".codex", "visualizations");
95525
95658
  let projectReal;
95526
95659
  let baseReal;
95527
95660
  try {
95528
- projectReal = realpathSync16(projectDir);
95529
- baseReal = realpathSync16(base);
95661
+ projectReal = realpathSync17(projectDir);
95662
+ baseReal = realpathSync17(base);
95530
95663
  } catch {
95531
95664
  return null;
95532
95665
  }
95533
95666
  if (!isUnder2(baseReal, projectReal)) return null;
95534
95667
  for (const year of children(base, YEAR_PART)) {
95535
- const yearDir = join56(base, year);
95668
+ const yearDir = join57(base, year);
95536
95669
  for (const month of children(yearDir, DATE_PART)) {
95537
- const monthDir = join56(yearDir, month);
95670
+ const monthDir = join57(yearDir, month);
95538
95671
  for (const day of children(monthDir, DATE_PART)) {
95539
- const sessionRoot = join56(baseReal, year, month, day, sessionId);
95540
- const candidate = join56(monthDir, day, sessionId, file);
95672
+ const sessionRoot = join57(baseReal, year, month, day, sessionId);
95673
+ const candidate = join57(monthDir, day, sessionId, file);
95541
95674
  try {
95542
- const real = realpathSync16(candidate);
95675
+ const real = realpathSync17(candidate);
95543
95676
  if (isUnder2(real, sessionRoot) && statSync28(real).isFile()) return real;
95544
95677
  } catch {
95545
95678
  }
@@ -95642,6 +95775,7 @@ function resolveLocalVisualization(projectDir, sessionId, file) {
95642
95775
  "frame-src 'none'",
95643
95776
  "base-uri 'none'",
95644
95777
  "form-action 'none'",
95778
+ "frame-ancestors 'self'",
95645
95779
  // Defense in depth for direct navigation to the route: keep the generated document opaque-origin
95646
95780
  // and capability-limited even when it is not inside the client's sandboxed iframe.
95647
95781
  "sandbox allow-scripts"
@@ -95668,12 +95802,246 @@ var init_local_visualization = __esm({
95668
95802
  }
95669
95803
  });
95670
95804
 
95805
+ // packages/server/src/remote-gate.ts
95806
+ function remoteRule(name) {
95807
+ return Object.hasOwn(REMOTE_ACCESS, name) ? REMOTE_ACCESS[name] : "deny";
95808
+ }
95809
+ function remoteAnswerRefusal(input, checks) {
95810
+ for (const answer of input.answers) {
95811
+ const stored = checks.questionSpec(input.slug, answer.questionId);
95812
+ const spec = stored && parseSpec2(stored.spec);
95813
+ if (!spec) return refusedCard("This question can't be read here");
95814
+ const refusal = refusalOfNode(spec, answer, answer.questionId, true);
95815
+ if (refusal) return refusal;
95816
+ }
95817
+ return null;
95818
+ }
95819
+ function parseSpec2(spec) {
95820
+ try {
95821
+ const parsed = AskedQuestionSchema.safeParse(JSON.parse(spec));
95822
+ return parsed.success ? parsed.data : void 0;
95823
+ } catch {
95824
+ return void 0;
95825
+ }
95826
+ }
95827
+ function refusalOfNode(node, said, rootId, root) {
95828
+ if (node.secret) return refusedCard("This question asks for a secret");
95829
+ if (node.danger) return refusedCard("This question is marked as dangerous");
95830
+ const options = node.options ?? [];
95831
+ if (options.length === 0) return refusedCard("This question takes typed text");
95832
+ if (said.questionId !== rootId || said.question !== node.question) return refusedCard("This answer doesn't match its question");
95833
+ if (said.text?.trim()) return refusedCard("This answer has typed text in it");
95834
+ const labels = new Set(options.map((option) => option.label));
95835
+ if (new Set(said.chosen).size !== said.chosen.length || said.chosen.some((label) => !labels.has(label))) {
95836
+ return refusedCard("This answer has something in it that isn't one of the options");
95837
+ }
95838
+ if (root && said.chosen.length === 0) return refusedCard("This answer doesn't pick an option");
95839
+ if (node.kind !== "multi" && said.chosen.length > 1) return refusedCard("This answer picks more than one option");
95840
+ const taken = node.kind === "multi" || said.chosen.length === 0 ? void 0 : options.find((option) => option.label === said.chosen[0]);
95841
+ const asked = taken?.followUps ?? [];
95842
+ const given = said.followUps ?? [];
95843
+ if (given.length !== asked.length) return refusedCard("This answer doesn't match its question");
95844
+ for (const [index, child] of asked.entries()) {
95845
+ const refusal = refusalOfNode(child, given[index], rootId, false);
95846
+ if (refusal) return refusal;
95847
+ }
95848
+ return null;
95849
+ }
95850
+ function isRemoteCaller(stamp) {
95851
+ const via = decodeCallerStamp(stamp)?.via;
95852
+ return via === "public" || via === "network";
95853
+ }
95854
+ function auditRemoteRefusal(audit, request, detail2, project) {
95855
+ const origin = requestOriginFrom({ caller: request.stamp, userAgent: request.userAgent, socketRemote: request.socketRemote });
95856
+ withRequestOrigin(origin, () => recordAudit(audit, () => ({ action: "remoteRefused", outcome: "refused", project, servedBy: project.id, detail: detail2 })));
95857
+ }
95858
+ function refuse(c, audit, project, detail2, message = remoteRefusedMessage()) {
95859
+ auditRemoteRefusal(audit, {
95860
+ stamp: c.req.header(CALLER_HEADER),
95861
+ userAgent: c.req.header("user-agent"),
95862
+ socketRemote: c.env?.remoteAddress
95863
+ }, detail2, project);
95864
+ return c.json({ error: message, code: REMOTE_REFUSED_CODE }, 403);
95865
+ }
95866
+ function remoteGate(options) {
95867
+ const isRemote2 = (c) => isRemoteCaller(c.req.header(CALLER_HEADER));
95868
+ return {
95869
+ procedure(c, name) {
95870
+ if (!isRemote2(c)) return void 0;
95871
+ if (remoteRule(name) !== "deny") return void 0;
95872
+ return refuse(c, options.audit, options.project, { procedure: name });
95873
+ },
95874
+ input(c, name, input) {
95875
+ if (!isRemote2(c)) return void 0;
95876
+ const rule = remoteRule(name);
95877
+ if (typeof rule !== "function") return void 0;
95878
+ const refusal = rule(input, options);
95879
+ return refusal ? refuse(c, options.audit, options.project, { procedure: name }, refusal) : void 0;
95880
+ }
95881
+ };
95882
+ }
95883
+ function remoteRouteAllowed(suffix) {
95884
+ return REMOTE_ROUTES.has(suffix) || suffix.startsWith("/rpc/");
95885
+ }
95886
+ function refuseRemoteRoute(c, options, route) {
95887
+ return refuse(c, options.audit, options.project, { route });
95888
+ }
95889
+ var onThisMachine, REMOTE_ACCESS, refusedCard, REMOTE_SOCKET_MESSAGES, REMOTE_ROUTES;
95890
+ var init_remote_gate = __esm({
95891
+ "packages/server/src/remote-gate.ts"() {
95892
+ "use strict";
95893
+ init_src();
95894
+ init_audit();
95895
+ init_remote_refusal();
95896
+ onThisMachine = (what) => `${what} can only be done on ${remoteHostLabel()}.`;
95897
+ REMOTE_ACCESS = {
95898
+ // Reading the board and its threads.
95899
+ board: "allow",
95900
+ boardState: "allow",
95901
+ boardDeltas: "allow",
95902
+ threadBody: "allow",
95903
+ threadTranscript: "allow",
95904
+ threadTranscriptEarlier: "allow",
95905
+ threadSettledQuestions: "allow",
95906
+ threadLocate: "allow",
95907
+ pendingInteractions: "allow",
95908
+ interactionGet: "allow",
95909
+ subAgentTranscript: "allow",
95910
+ backgroundShellOutput: "allow",
95911
+ backgroundShellActivity: "allow",
95912
+ monitorOutput: "allow",
95913
+ projectsList: "allow",
95914
+ projectsRailCounts: "allow",
95915
+ // What the page reads as it loads. None of these takes input that reaches a process.
95916
+ settingsGet: "allow",
95917
+ dispatchPreferencesGet: "allow",
95918
+ codexModels: "allow",
95919
+ acpAgents: "allow",
95920
+ quota: (input) => input?.force ? onThisMachine("Refreshing the quota") : null,
95921
+ authStatus: (input) => input?.fresh ? onThisMachine("Checking the sign-in again") : null,
95922
+ // Files, confined to what remote-reads.ts allows.
95923
+ localMarkdown: (input, checks) => checks.mayRead(input.path) ? null : remoteRefusedMessage(),
95924
+ localFile: (input, checks) => checks.mayRead(input.path) ? null : remoteRefusedMessage(),
95925
+ resolveLocalPaths: "allow",
95926
+ // Filters what it answers itself, since one batch mixes paths. See router.ts.
95927
+ // Bookkeeping: the reader's own place on the board. Nothing here starts or changes any work.
95928
+ markRead: "allow",
95929
+ threadSeen: "allow",
95930
+ snoozeAwaitingBackground: "allow",
95931
+ setThreadPinned: "allow",
95932
+ reorderPinnedThreads: "allow",
95933
+ setThreadConsolePinned: "allow",
95934
+ reorderConsolePinnedThreads: "allow",
95935
+ projectsReorder: "allow",
95936
+ // A snooze with a prompt is a message to the worker, sent later: the scheduler resumes the thread with
95937
+ // it when the snooze ends, in whatever permission mode that thread runs.
95938
+ setThreadSnooze: (input) => input.prompt != null ? onThisMachine("Scheduling a message") : null,
95939
+ // Picking a listed option on a question card.
95940
+ answerQuestions: (input, checks) => remoteAnswerRefusal(input, checks),
95941
+ // Everything else is the machine's.
95942
+ interactionResolve: "deny",
95943
+ interactionCancel: "deny",
95944
+ subAgentSteer: "deny",
95945
+ subAgentStop: "deny",
95946
+ stopBackgroundOp: "deny",
95947
+ dispatch: "deny",
95948
+ adoptThread: "deny",
95949
+ followUp: "deny",
95950
+ steerThread: "deny",
95951
+ spawnThread: "deny",
95952
+ spawnChild: "deny",
95953
+ dismissFailedFollowUp: "deny",
95954
+ unqueueFollowUp: "deny",
95955
+ deliverQueuedNow: "deny",
95956
+ compactThread: "deny",
95957
+ setThreadPermission: "deny",
95958
+ threadProfileOptions: "deny",
95959
+ threadSkills: "deny",
95960
+ mcpStatus: "deny",
95961
+ mcpSignIn: "deny",
95962
+ mcpSignInPoll: "deny",
95963
+ mcpSignInFinish: "deny",
95964
+ mcpSignInCancel: "deny",
95965
+ setThreadProfile: "deny",
95966
+ upgradeThreadModel: "deny",
95967
+ archiveThread: "deny",
95968
+ setThreadState: "deny",
95969
+ completeThread: "deny",
95970
+ setThreadRecurringPrompt: "deny",
95971
+ setOwnThreadRecurringPrompt: "deny",
95972
+ getOwnThreadRecurringPrompt: "deny",
95973
+ setOwnThreadTimer: "deny",
95974
+ cancelOwnThreadTimer: "deny",
95975
+ listOwnThreadTimers: "deny",
95976
+ listOwnThreadActivity: "deny",
95977
+ listThreads: "deny",
95978
+ upsertOwnLink: "deny",
95979
+ dropOwnLink: "deny",
95980
+ addOwnPrWatch: "deny",
95981
+ dropOwnPrWatch: "deny",
95982
+ addOwnCommandWatch: "deny",
95983
+ dropOwnCommandWatch: "deny",
95984
+ stopMonitor: "deny",
95985
+ addOwnMonitor: "deny",
95986
+ listOwnCommandWatches: "deny",
95987
+ addOwnWatch: "deny",
95988
+ dropOwnWatch: "deny",
95989
+ ask: "deny",
95990
+ unask: "deny",
95991
+ dismissQuestions: "deny",
95992
+ markOwnDone: "deny",
95993
+ listOwnPrWatches: "deny",
95994
+ setOwnThreadStopHook: "deny",
95995
+ setOwnThreadHeartbeat: "deny",
95996
+ setThreadHeartbeat: "deny",
95997
+ forgetThread: "deny",
95998
+ openExternal: "deny",
95999
+ openLocalFile: "deny",
96000
+ markComplete: "deny",
96001
+ setThreadStatus: "deny",
96002
+ repairThread: "deny",
96003
+ dismissThread: "deny",
96004
+ renameThread: "deny",
96005
+ setOwnThreadTitle: "deny",
96006
+ aiRenameThread: "deny",
96007
+ killAgent: "deny",
96008
+ claudeModels: "deny",
96009
+ acpAgentModels: "deny",
96010
+ accountLogout: "deny",
96011
+ projectRemove: "deny",
96012
+ projectIconPick: "deny",
96013
+ projectIconPickWarm: "deny",
96014
+ projectIconSet: "deny",
96015
+ projectIconClear: "deny",
96016
+ projectRename: "deny",
96017
+ projectPick: "deny",
96018
+ projectPickWarm: "deny",
96019
+ projectAdd: "deny",
96020
+ settingsSet: "deny",
96021
+ settingsReset: "deny",
96022
+ dispatchPreferenceSet: "deny",
96023
+ githubPromptDefaults: "deny",
96024
+ githubStatus: "deny",
96025
+ githubAccount: "deny",
96026
+ githubSignInStart: "deny",
96027
+ githubSignInCancel: "deny",
96028
+ githubSignOut: "deny",
96029
+ githubList: "deny",
96030
+ githubRefPreview: "deny",
96031
+ githubDispatchBatch: "deny"
96032
+ };
96033
+ refusedCard = (why) => `${why}, so it can only be answered on ${remoteHostLabel()}.`;
96034
+ REMOTE_SOCKET_MESSAGES = { board: true, sub: true, unsub: true };
96035
+ REMOTE_ROUTES = /* @__PURE__ */ new Set(["/events", "/project-icon", "/local-visualization", "/local-image", "/local-file"]);
96036
+ }
96037
+ });
96038
+
95671
96039
  // packages/server/src/launch-routing.ts
95672
- import { realpathSync as realpathSync17 } from "node:fs";
96040
+ import { realpathSync as realpathSync18 } from "node:fs";
95673
96041
  import { homedir as homedir26 } from "node:os";
95674
- import { isAbsolute as isAbsolute12 } from "node:path";
96042
+ import { isAbsolute as isAbsolute13 } from "node:path";
95675
96043
  function classifyLaunch(dir, home = homedir26()) {
95676
- const candidate = realpathSync17(discoverProjectRoot(dir, home));
96044
+ const candidate = realpathSync18(discoverProjectRoot(dir, home));
95677
96045
  const refused = isHomeDirectory(candidate, home);
95678
96046
  if (!refused && (isExistingProjectRoot(candidate) || findByPath(candidate, home) !== void 0)) {
95679
96047
  return { kind: "open", root: candidate };
@@ -95701,7 +96069,7 @@ function parseLaunchRouteRequest(body) {
95701
96069
  if (!body || typeof body !== "object" || Array.isArray(body)) return { error: "expected a JSON object" };
95702
96070
  const { protocol, dir, args } = body;
95703
96071
  if (protocol !== LAUNCH_ROUTE_PROTOCOL) return { error: `unsupported launch protocol ${String(protocol)}` };
95704
- if (typeof dir !== "string" || dir.length === 0 || dir.length > 4096 || !isAbsolute12(dir)) return { error: "dir must be an absolute path" };
96072
+ if (typeof dir !== "string" || dir.length === 0 || dir.length > 4096 || !isAbsolute13(dir)) return { error: "dir must be an absolute path" };
95705
96073
  if (args !== void 0 && !(Array.isArray(args) && args.length <= 64 && args.every((arg) => typeof arg === "string" && arg.length <= 4096)))
95706
96074
  return { error: "args must be a short list of strings" };
95707
96075
  return { protocol: LAUNCH_ROUTE_PROTOCOL, dir, ...args ? { args } : {} };
@@ -95720,12 +96088,12 @@ var init_launch_routing = __esm({
95720
96088
 
95721
96089
  // packages/server/src/project-serving.ts
95722
96090
  import { readFileSync as readFileSync42, renameSync as renameSync16, writeFileSync as writeFileSync24 } from "node:fs";
95723
- import { isAbsolute as isAbsolute13, join as join57 } from "node:path";
96091
+ import { isAbsolute as isAbsolute14, join as join58 } from "node:path";
95724
96092
  function parse3(value) {
95725
96093
  if (!value || typeof value !== "object") return null;
95726
96094
  const record = value;
95727
96095
  if (record.version !== 1 || typeof record.projectId !== "string" || typeof record.projectDir !== "string") return null;
95728
- if (!isAbsolute13(record.projectDir) || typeof record.updatedAt !== "string") return null;
96096
+ if (!isAbsolute14(record.projectDir) || typeof record.updatedAt !== "string") return null;
95729
96097
  const server = record.server;
95730
96098
  const generation = server && Number.isInteger(server.pid) && server.pid > 0 && typeof server.processStart === "string" && server.processStart.length > 0 && typeof server.openedAt === "string" ? { pid: server.pid, processStart: server.processStart, openedAt: server.openedAt } : void 0;
95731
96099
  return {
@@ -95738,13 +96106,13 @@ function parse3(value) {
95738
96106
  }
95739
96107
  function readProjectServing(stateDir) {
95740
96108
  try {
95741
- return parse3(JSON.parse(readFileSync42(join57(stateDir, PROJECT_SERVING_FILE), "utf8")));
96109
+ return parse3(JSON.parse(readFileSync42(join58(stateDir, PROJECT_SERVING_FILE), "utf8")));
95742
96110
  } catch {
95743
96111
  return null;
95744
96112
  }
95745
96113
  }
95746
96114
  function writeRecord(stateDir, record) {
95747
- const path3 = join57(stateDir, PROJECT_SERVING_FILE);
96115
+ const path3 = join58(stateDir, PROJECT_SERVING_FILE);
95748
96116
  const partial = `${path3}.${process.pid}.tmp`;
95749
96117
  writeFileSync24(partial, `${JSON.stringify(record)}
95750
96118
  `, { mode: 384 });
@@ -95818,7 +96186,7 @@ var init_project_serving = __esm({
95818
96186
  // packages/server/src/app.ts
95819
96187
  import { createReadStream as createReadStream2, mkdirSync as mkdirSync31, writeFileSync as writeFileSync25 } from "node:fs";
95820
96188
  import { Readable } from "node:stream";
95821
- import { join as join58 } from "node:path";
96189
+ import { join as join59 } from "node:path";
95822
96190
  import { randomUUID as randomUUID21 } from "node:crypto";
95823
96191
  function attachmentFileName(name) {
95824
96192
  let clean = (name.split(/[\\/]/).pop() ?? "").replace(/\s/g, " ").replace(/[\u0000-\u001f\u007f`]/g, "-").trim();
@@ -95848,6 +96216,16 @@ function createApp(ctx, options = {}) {
95848
96216
  }
95849
96217
  await next();
95850
96218
  });
96219
+ const gateProject = { id: ctx.project.id, dir: ctx.project.dir };
96220
+ const isRemote2 = (c) => isRemoteCaller(c.req.header(CALLER_HEADER));
96221
+ app.use("*", async (c, next) => {
96222
+ if (isRemote2(c)) {
96223
+ const suffix = c.req.path.startsWith(FRIZZ_ROUTE_PREFIX) ? c.req.path.slice(FRIZZ_ROUTE_PREFIX.length) : "";
96224
+ if (!remoteRouteAllowed(suffix)) return refuseRemoteRoute(c, { audit: ctx.audit, project: gateProject }, c.req.path.slice(0, 200));
96225
+ }
96226
+ await next();
96227
+ });
96228
+ const mayReadRemotely = (path3) => remoteReadablePath(path3, remoteProjectDirs(ctx.project.dir)) !== null;
95851
96229
  app.use(
95852
96230
  cors({
95853
96231
  origin: (origin) => allowedLocalCorsOrigin(origin, port2),
@@ -95923,6 +96301,7 @@ function createApp(ctx, options = {}) {
95923
96301
  }
95924
96302
  });
95925
96303
  app.get(frizzRoute("/local-image"), (c) => {
96304
+ if (isRemote2(c) && !mayReadRemotely(c.req.query("path") ?? "")) return c.text("404", 404);
95926
96305
  const r = resolveLocalImage(c.req.query("path"), c.req.header("range"));
95927
96306
  if (r.status === 416) return c.body(null, 416, { "content-range": `bytes */${r.size}`, "accept-ranges": "bytes" });
95928
96307
  if (r.status === 400 || r.status === 404) return c.text(String(r.status), r.status);
@@ -95933,6 +96312,7 @@ function createApp(ctx, options = {}) {
95933
96312
  app.get(frizzRoute("/local-file"), (c) => {
95934
96313
  let file;
95935
96314
  try {
96315
+ if (isRemote2(c) && !mayReadRemotely(c.req.query("path") ?? "")) return c.text("404", 404);
95936
96316
  file = resolveServedLocalFile(c.req.query("path") ?? "", openableFileRoots(ctx.project));
95937
96317
  } catch {
95938
96318
  return c.text("404", 404);
@@ -95970,7 +96350,9 @@ function createApp(ctx, options = {}) {
95970
96350
  return c.html(r.body, 200, {
95971
96351
  "cache-control": "private, no-store",
95972
96352
  "content-security-policy": r.contentSecurityPolicy,
95973
- "x-content-type-options": "nosniff"
96353
+ "x-content-type-options": "nosniff",
96354
+ // Shown in the board's own iframe, so its own origin is the one page that may frame it.
96355
+ "x-frame-options": "SAMEORIGIN"
95974
96356
  });
95975
96357
  });
95976
96358
  app.post(frizzRoute("/attach"), async (c) => {
@@ -95984,9 +96366,9 @@ function createApp(ctx, options = {}) {
95984
96366
  if (!isAllowedAttachmentName(name)) return c.json({ error: "unsupported file type" }, 400);
95985
96367
  if (typeof body.data !== "string" || body.data.length > ATTACHMENT_MAX_BASE64_CHARS) return c.json({ error: "bad payload" }, 400);
95986
96368
  const buf = Buffer.from(body.data, "base64");
95987
- const dir = join58(ctx.project.stateDir, "attachments", `${Date.now()}-${randomUUID21().slice(0, 8)}`);
96369
+ const dir = join59(ctx.project.stateDir, "attachments", `${Date.now()}-${randomUUID21().slice(0, 8)}`);
95988
96370
  mkdirSync31(dir, { recursive: true });
95989
- const path3 = join58(dir, attachmentFileName(name));
96371
+ const path3 = join59(dir, attachmentFileName(name));
95990
96372
  writeFileSync25(path3, buf);
95991
96373
  return c.json({ path: path3 });
95992
96374
  });
@@ -96014,15 +96396,23 @@ function createApp(ctx, options = {}) {
96014
96396
  const heartbeat = setInterval(() => void stream2.writeSSE({ event: "heartbeat", data: "" }).catch(() => {
96015
96397
  }), 1e4);
96016
96398
  await new Promise(
96017
- (resolve16) => stream2.onAbort(() => {
96399
+ (resolve17) => stream2.onAbort(() => {
96018
96400
  unsubscribe();
96019
96401
  clearInterval(heartbeat);
96020
- resolve16();
96402
+ resolve17();
96021
96403
  })
96022
96404
  );
96023
96405
  })
96024
96406
  );
96025
- mountRouter(app, frizzRoute("/rpc"), createRouter(ctx));
96407
+ mountRouter(app, frizzRoute("/rpc"), createRouter(ctx), remoteGate({
96408
+ audit: ctx.audit,
96409
+ project: gateProject,
96410
+ questionSpec: (slug, id2) => {
96411
+ const row = ctx.storage.getThreadQuestion(id2);
96412
+ return row && row.thread_slug === slug ? { spec: row.spec } : void 0;
96413
+ },
96414
+ mayRead: mayReadRemotely
96415
+ }));
96026
96416
  return app;
96027
96417
  }
96028
96418
  var init_app = __esm({
@@ -96041,6 +96431,8 @@ var init_app = __esm({
96041
96431
  init_project_icon();
96042
96432
  init_local_visualization();
96043
96433
  init_audit();
96434
+ init_remote_gate();
96435
+ init_remote_reads();
96044
96436
  init_launch_routing();
96045
96437
  init_project();
96046
96438
  init_project_serving();
@@ -96132,7 +96524,13 @@ function createAppSocketServer(deps) {
96132
96524
  const lastSig = /* @__PURE__ */ new Map();
96133
96525
  const fileWatches = /* @__PURE__ */ new WeakMap();
96134
96526
  let fileWatchCount = 0;
96527
+ const remoteSockets = /* @__PURE__ */ new WeakMap();
96135
96528
  function subscribeFile(ws, path3) {
96529
+ const remote = remoteSockets.get(ws);
96530
+ if (remote && !deps.mayReadRemotely?.(path3)) {
96531
+ deps.refusedRemotely?.(remote, { socket: "file" });
96532
+ return;
96533
+ }
96136
96534
  let held = fileWatches.get(ws);
96137
96535
  if (!held) {
96138
96536
  held = /* @__PURE__ */ new Map();
@@ -96660,6 +97058,11 @@ function createAppSocketServer(deps) {
96660
97058
  return;
96661
97059
  }
96662
97060
  const msg = parsed.data;
97061
+ if (remoteSockets.has(ws) && !REMOTE_SOCKET_MESSAGES[msg.t]) {
97062
+ deps.refusedRemotely?.(remoteSockets.get(ws), { socket: msg.t });
97063
+ closeSocket(ws, 1008, "not available remotely");
97064
+ return;
97065
+ }
96663
97066
  if (msg.t === "board") {
96664
97067
  resumeBoard(msg.bootId, msg.seq);
96665
97068
  return;
@@ -96751,6 +97154,11 @@ function createAppSocketServer(deps) {
96751
97154
  releaseReservation();
96752
97155
  const origin = req.headers.origin;
96753
97156
  if (typeof origin === "string") socketOrigins.set(ws, origin);
97157
+ const stamp = req.headers[CALLER_HEADER];
97158
+ if (typeof stamp === "string" && isRemoteCaller(stamp)) {
97159
+ const userAgent = req.headers["user-agent"];
97160
+ remoteSockets.set(ws, { stamp, userAgent });
97161
+ }
96754
97162
  wss.emit("connection", ws, req);
96755
97163
  });
96756
97164
  } catch {
@@ -96779,13 +97187,13 @@ function createAppSocketServer(deps) {
96779
97187
  clearTranscriptSnapshots();
96780
97188
  globalReadTimes.length = 0;
96781
97189
  originReadTimes.clear();
96782
- const socketDrains = [...wss.clients].map((ws) => new Promise((resolve16) => {
96783
- if (ws.readyState === ws.CLOSED) return resolve16();
96784
- ws.once("close", () => resolve16());
97190
+ const socketDrains = [...wss.clients].map((ws) => new Promise((resolve17) => {
97191
+ if (ws.readyState === ws.CLOSED) return resolve17();
97192
+ ws.once("close", () => resolve17());
96785
97193
  try {
96786
97194
  ws.terminate();
96787
97195
  } catch {
96788
- resolve16();
97196
+ resolve17();
96789
97197
  }
96790
97198
  }));
96791
97199
  lastSig.clear();
@@ -96828,6 +97236,8 @@ var init_app_socket = __esm({
96828
97236
  init_src();
96829
97237
  init_transcript();
96830
97238
  init_local_origin();
97239
+ init_audit();
97240
+ init_remote_gate();
96831
97241
  WS_PATH = frizzRoute("/ws");
96832
97242
  SubscriptionRegistry = class {
96833
97243
  bySlug = /* @__PURE__ */ new Map();
@@ -96986,9 +97396,9 @@ var init_local_file_watch = __esm({
96986
97396
 
96987
97397
  // packages/server/src/boot-progress.ts
96988
97398
  import { mkdirSync as mkdirSync32, readFileSync as readFileSync43, renameSync as renameSync17, rmSync as rmSync19, writeFileSync as writeFileSync26 } from "node:fs";
96989
- import { basename as basename14, dirname as dirname27, join as join59 } from "node:path";
97399
+ import { basename as basename14, dirname as dirname27, join as join60 } from "node:path";
96990
97400
  function bootProgressPath(stateDir) {
96991
- return join59(stateDir, BOOT_PROGRESS_NAME);
97401
+ return join60(stateDir, BOOT_PROGRESS_NAME);
96992
97402
  }
96993
97403
  function createBootProgressPublisher(stateDir, minIntervalMs = 200) {
96994
97404
  if (!stateDir) {
@@ -97009,7 +97419,7 @@ function createBootProgressPublisher(stateDir, minIntervalMs = 200) {
97009
97419
  step++;
97010
97420
  try {
97011
97421
  mkdirSync32(dirname27(path3), { recursive: true, mode: 448 });
97012
- const temp = join59(dirname27(path3), `.${basename14(path3)}.${process.pid}.tmp`);
97422
+ const temp = join60(dirname27(path3), `.${basename14(path3)}.${process.pid}.tmp`);
97013
97423
  writeFileSync26(temp, `${JSON.stringify({ pid: process.pid, step, phase, at: new Date(now).toISOString() })}
97014
97424
  `, "utf8");
97015
97425
  renameSync17(temp, path3);
@@ -97036,11 +97446,11 @@ var init_boot_progress = __esm({
97036
97446
 
97037
97447
  // packages/server/src/runtime-lease.ts
97038
97448
  import { existsSync as existsSync23, mkdirSync as mkdirSync33, readdirSync as readdirSync18, readFileSync as readFileSync44, unlinkSync as unlinkSync10, writeFileSync as writeFileSync27 } from "node:fs";
97039
- import { dirname as dirname28, join as join60 } from "node:path";
97449
+ import { dirname as dirname28, join as join61 } from "node:path";
97040
97450
  function runtimeVersionDir(bin) {
97041
97451
  let dir = dirname28(bin);
97042
97452
  for (let step = 0; step < MAX_ASCENT; step++) {
97043
- if (existsSync23(join60(dir, PROVISIONED_MARKER))) return dir;
97453
+ if (existsSync23(join61(dir, PROVISIONED_MARKER))) return dir;
97044
97454
  const parent = dirname28(dir);
97045
97455
  if (parent === dir) return void 0;
97046
97456
  dir = parent;
@@ -97059,7 +97469,7 @@ function leaseRuntime(bin, role) {
97059
97469
  const versionDir = runtimeVersionDir(bin);
97060
97470
  if (!versionDir) return () => {
97061
97471
  };
97062
- const path3 = join60(versionDir, LEASES_DIR, `${process.pid}.json`);
97472
+ const path3 = join61(versionDir, LEASES_DIR, `${process.pid}.json`);
97063
97473
  try {
97064
97474
  mkdirSync33(dirname28(path3), { recursive: true });
97065
97475
  const lease = { pid: process.pid, role, bin, at: (/* @__PURE__ */ new Date()).toISOString() };
@@ -97076,7 +97486,7 @@ function leaseRuntime(bin, role) {
97076
97486
  };
97077
97487
  }
97078
97488
  function liveRuntimeLeases(versionDir) {
97079
- const dir = join60(versionDir, LEASES_DIR);
97489
+ const dir = join61(versionDir, LEASES_DIR);
97080
97490
  let names;
97081
97491
  try {
97082
97492
  names = readdirSync18(dir);
@@ -97086,7 +97496,7 @@ function liveRuntimeLeases(versionDir) {
97086
97496
  const live2 = [];
97087
97497
  for (const name of names) {
97088
97498
  if (!name.endsWith(".json")) continue;
97089
- const path3 = join60(dir, name);
97499
+ const path3 = join61(dir, name);
97090
97500
  let lease;
97091
97501
  try {
97092
97502
  lease = JSON.parse(readFileSync44(path3, "utf8"));
@@ -97131,14 +97541,14 @@ import {
97131
97541
  writeFileSync as writeFileSync28,
97132
97542
  writeSync as writeSync3
97133
97543
  } from "node:fs";
97134
- import { dirname as dirname29, isAbsolute as isAbsolute14, join as join61, normalize, relative as relative3, sep as sep6 } from "node:path";
97544
+ import { dirname as dirname29, isAbsolute as isAbsolute15, join as join62, normalize, relative as relative4, sep as sep7 } from "node:path";
97135
97545
  import { Readable as Readable2, Transform, Writable as Writable4 } from "node:stream";
97136
97546
  import { pipeline } from "node:stream/promises";
97137
97547
  import { createGunzip } from "node:zlib";
97138
97548
  function runtimesRoot(env = process.env) {
97139
97549
  const override = env[RUNTIMES_DIR_ENV];
97140
- if (override && isAbsolute14(override)) return override;
97141
- return join61(frizzRoots().cache, "runtimes");
97550
+ if (override && isAbsolute15(override)) return override;
97551
+ return join62(frizzRoots().cache, "runtimes");
97142
97552
  }
97143
97553
  function isMusl() {
97144
97554
  if (process.platform !== "linux") return false;
@@ -97155,15 +97565,15 @@ function runtimeCoordinates(backend, platform3 = process.platform, arch = proces
97155
97565
  return { pkg: "@openai/codex", packageVersion: `${CODEX_VERSION}-${platform3}-${arch}`, label: CODEX_VERSION, binary: `codex${exe2}` };
97156
97566
  }
97157
97567
  function provisionedBinary(backend, root, label) {
97158
- const dir = join61(root, backend, label);
97568
+ const dir = join62(root, backend, label);
97159
97569
  let marker;
97160
97570
  try {
97161
- marker = JSON.parse(readFileSync45(join61(dir, MARKER), "utf8"));
97571
+ marker = JSON.parse(readFileSync45(join62(dir, MARKER), "utf8"));
97162
97572
  } catch {
97163
97573
  return void 0;
97164
97574
  }
97165
97575
  if (typeof marker.binary !== "string" || marker.label !== label) return void 0;
97166
- const bin = join61(dir, marker.binary);
97576
+ const bin = join62(dir, marker.binary);
97167
97577
  return existsSync24(bin) ? bin : void 0;
97168
97578
  }
97169
97579
  function octal(buffer, offset, length) {
@@ -97176,19 +97586,19 @@ function field(buffer, offset, length) {
97176
97586
  function safeEntryPath(dest, name) {
97177
97587
  const parts = name.split("/").filter((part) => part.length > 0);
97178
97588
  if (parts.length < 2) return void 0;
97179
- const rel = normalize(parts.slice(1).join(sep6));
97180
- if (isAbsolute14(rel) || rel === ".." || rel.startsWith(`..${sep6}`)) return void 0;
97181
- const full = join61(dest, rel);
97182
- const back = relative3(dest, full);
97183
- if (back.startsWith("..") || isAbsolute14(back)) return void 0;
97589
+ const rel = normalize(parts.slice(1).join(sep7));
97590
+ if (isAbsolute15(rel) || rel === ".." || rel.startsWith(`..${sep7}`)) return void 0;
97591
+ const full = join62(dest, rel);
97592
+ const back = relative4(dest, full);
97593
+ if (back.startsWith("..") || isAbsolute15(back)) return void 0;
97184
97594
  return full;
97185
97595
  }
97186
97596
  function locateBinary(dir, backend, binary) {
97187
97597
  if (backend === "claude") {
97188
- const direct = join61(dir, binary);
97598
+ const direct = join62(dir, binary);
97189
97599
  return existsSync24(direct) ? direct : void 0;
97190
97600
  }
97191
- const vendor = join61(dir, "vendor");
97601
+ const vendor = join62(dir, "vendor");
97192
97602
  let triples;
97193
97603
  try {
97194
97604
  triples = readdirSync19(vendor);
@@ -97196,7 +97606,7 @@ function locateBinary(dir, backend, binary) {
97196
97606
  return void 0;
97197
97607
  }
97198
97608
  for (const triple of triples) {
97199
- const candidate = join61(vendor, triple, "bin", binary);
97609
+ const candidate = join62(vendor, triple, "bin", binary);
97200
97610
  if (existsSync24(candidate)) return candidate;
97201
97611
  }
97202
97612
  return void 0;
@@ -97212,9 +97622,9 @@ async function provisionRuntime(backend, options) {
97212
97622
  const registry = options.registry ?? REGISTRY;
97213
97623
  const progress = options.onProgress ?? (() => {
97214
97624
  });
97215
- const backendDir = join61(root, backend);
97216
- const finalDir = join61(backendDir, coordinates.label);
97217
- const partial = join61(backendDir, `.partial-${coordinates.label}-${process.pid}`);
97625
+ const backendDir = join62(root, backend);
97626
+ const finalDir = join62(backendDir, coordinates.label);
97627
+ const partial = join62(backendDir, `.partial-${coordinates.label}-${process.pid}`);
97218
97628
  mkdirSync34(backendDir, { recursive: true });
97219
97629
  rmSync20(partial, { recursive: true, force: true });
97220
97630
  mkdirSync34(partial);
@@ -97258,10 +97668,10 @@ async function provisionRuntime(backend, options) {
97258
97668
  pkg: coordinates.pkg,
97259
97669
  packageVersion: coordinates.packageVersion,
97260
97670
  integrity,
97261
- binary: relative3(partial, bin),
97671
+ binary: relative4(partial, bin),
97262
97672
  at: (/* @__PURE__ */ new Date()).toISOString()
97263
97673
  };
97264
- writeFileSync28(join61(partial, MARKER), `${JSON.stringify(marker, null, 2)}
97674
+ writeFileSync28(join62(partial, MARKER), `${JSON.stringify(marker, null, 2)}
97265
97675
  `, "utf8");
97266
97676
  const rename3 = options.rename ?? renameSync18;
97267
97677
  try {
@@ -97271,7 +97681,7 @@ async function provisionRuntime(backend, options) {
97271
97681
  break;
97272
97682
  } catch (err) {
97273
97683
  if (attempt >= RENAME_ATTEMPTS || !TRANSIENT_HANDLE_CODES.has(errorCode4(err) ?? "") || existsSync24(finalDir)) throw err;
97274
- await new Promise((resolve16) => setTimeout(resolve16, options.retryDelayMs ?? RENAME_RETRY_DELAY_MS));
97684
+ await new Promise((resolve17) => setTimeout(resolve17, options.retryDelayMs ?? RENAME_RETRY_DELAY_MS));
97275
97685
  }
97276
97686
  }
97277
97687
  } catch (err) {
@@ -97281,7 +97691,7 @@ async function provisionRuntime(backend, options) {
97281
97691
  return { bin: theirs, label: coordinates.label, fetched: false };
97282
97692
  }
97283
97693
  progress("ready");
97284
- return { bin: join61(finalDir, marker.binary), label: coordinates.label, fetched: true };
97694
+ return { bin: join62(finalDir, marker.binary), label: coordinates.label, fetched: true };
97285
97695
  } catch (err) {
97286
97696
  rmSync20(partial, { recursive: true, force: true });
97287
97697
  throw err;
@@ -97289,7 +97699,7 @@ async function provisionRuntime(backend, options) {
97289
97699
  }
97290
97700
  function sweepRuntimes(backend, root, keepLabel, now = Date.now(), deps = {}) {
97291
97701
  const rm4 = deps.rm ?? defaultSweepRm;
97292
- const backendDir = join61(root, backend);
97702
+ const backendDir = join62(root, backend);
97293
97703
  let entries2;
97294
97704
  try {
97295
97705
  entries2 = readdirSync19(backendDir);
@@ -97299,7 +97709,7 @@ function sweepRuntimes(backend, root, keepLabel, now = Date.now(), deps = {}) {
97299
97709
  const sweep = { removed: [], kept: [] };
97300
97710
  for (const entry of entries2) {
97301
97711
  if (entry === keepLabel) continue;
97302
- const full = join61(backendDir, entry);
97712
+ const full = join62(backendDir, entry);
97303
97713
  if (entry.startsWith(".partial-")) {
97304
97714
  try {
97305
97715
  if (now - statSync30(full).mtimeMs < 24 * 60 * 60 * 1e3) continue;
@@ -98078,17 +98488,17 @@ var init_legacy_project_db = __esm({
98078
98488
 
98079
98489
  // packages/server/src/frizz-db.ts
98080
98490
  import { existsSync as existsSync25, mkdirSync as mkdirSync35, readdirSync as readdirSync20, renameSync as renameSync19, statSync as statSync31 } from "node:fs";
98081
- import { basename as basename15, dirname as dirname30, join as join62 } from "node:path";
98491
+ import { basename as basename15, dirname as dirname30, join as join63 } from "node:path";
98082
98492
  function frizzDatabaseLocation(options) {
98083
98493
  if (options.stateDir !== void 0) {
98084
98494
  const projectsDir = dirname30(options.stateDir);
98085
98495
  if (basename15(projectsDir) === "projects") {
98086
- return { path: options.path ?? join62(dirname30(projectsDir), "ui.db"), projectsDir };
98496
+ return { path: options.path ?? join63(dirname30(projectsDir), "ui.db"), projectsDir };
98087
98497
  }
98088
- return { path: options.path ?? join62(options.stateDir, "ui.db"), projectsDir: void 0 };
98498
+ return { path: options.path ?? join63(options.stateDir, "ui.db"), projectsDir: void 0 };
98089
98499
  }
98090
98500
  const data = options.home ? frizzPaths({ home: options.home }).data : frizzRoots().data;
98091
- return { path: options.path ?? join62(data, "ui.db"), projectsDir: join62(data, "projects") };
98501
+ return { path: options.path ?? join63(data, "ui.db"), projectsDir: join63(data, "projects") };
98092
98502
  }
98093
98503
  function ensureFrizzSchema(db2) {
98094
98504
  db2.exec(`
@@ -98119,10 +98529,10 @@ function openFrizzDatabase(options = {}) {
98119
98529
  );
98120
98530
  for (const projectId of retiredLegacyProjectIds(projectsDir)) {
98121
98531
  if (alreadyImported.has(projectId)) continue;
98122
- const dir = join62(projectsDir, projectId);
98532
+ const dir = join63(projectsDir, projectId);
98123
98533
  try {
98124
- renameSync19(join62(dir, "ui.db.imported"), join62(dir, "ui.db"));
98125
- db2.prepare("INSERT INTO imported_project (project_id, source, rows, imported_at) VALUES (?, ?, 0, ?)").run(projectId, join62(dir, "ui.db"), (/* @__PURE__ */ new Date()).toISOString());
98534
+ renameSync19(join63(dir, "ui.db.imported"), join63(dir, "ui.db"));
98535
+ db2.prepare("INSERT INTO imported_project (project_id, source, rows, imported_at) VALUES (?, ?, 0, ?)").run(projectId, join63(dir, "ui.db"), (/* @__PURE__ */ new Date()).toISOString());
98126
98536
  alreadyImported.add(projectId);
98127
98537
  log.info("frizz-db", `${projectId}: restored ui.db.imported to ui.db and recorded it as imported`);
98128
98538
  } catch (error) {
@@ -98132,7 +98542,7 @@ function openFrizzDatabase(options = {}) {
98132
98542
  }
98133
98543
  for (const projectId of legacyProjectIds(projectsDir)) {
98134
98544
  if (alreadyImported.has(projectId)) continue;
98135
- const legacyPath = join62(projectsDir, projectId, "ui.db");
98545
+ const legacyPath = join63(projectsDir, projectId, "ui.db");
98136
98546
  try {
98137
98547
  const rows = importLegacyProject(db2, projectId, legacyPath);
98138
98548
  imported.push({ projectId, rows });
@@ -98165,7 +98575,7 @@ function projectIdsWithFile(projectsDir, file) {
98165
98575
  if (!existsSync25(projectsDir)) return [];
98166
98576
  return readdirSync20(projectsDir).filter((name) => {
98167
98577
  try {
98168
- return statSync31(join62(projectsDir, name, file)).isFile();
98578
+ return statSync31(join63(projectsDir, name, file)).isFile();
98169
98579
  } catch {
98170
98580
  return false;
98171
98581
  }
@@ -98175,7 +98585,7 @@ function legacyProjectIds(projectsDir) {
98175
98585
  return projectIdsWithFile(projectsDir, "ui.db");
98176
98586
  }
98177
98587
  function retiredLegacyProjectIds(projectsDir) {
98178
- return projectIdsWithFile(projectsDir, "ui.db.imported").filter((id2) => !existsSync25(join62(projectsDir, id2, "ui.db")));
98588
+ return projectIdsWithFile(projectsDir, "ui.db.imported").filter((id2) => !existsSync25(join63(projectsDir, id2, "ui.db")));
98179
98589
  }
98180
98590
  function tableColumns(db2, schema, table) {
98181
98591
  return db2.prepare(`PRAGMA ${schema}.table_info(${table})`).all().map((c) => c.name);
@@ -98244,12 +98654,12 @@ function startTenantPrime(deps) {
98244
98654
  const log3 = deps.log ?? ((message) => log.info("tenants", message));
98245
98655
  let stopped = false;
98246
98656
  let interrupt;
98247
- const defaultDelay = (ms) => new Promise((resolve16) => {
98248
- if (stopped) return resolve16();
98657
+ const defaultDelay = (ms) => new Promise((resolve17) => {
98658
+ if (stopped) return resolve17();
98249
98659
  const finish = () => {
98250
98660
  clearTimeout(timer);
98251
98661
  interrupt = void 0;
98252
- resolve16();
98662
+ resolve17();
98253
98663
  };
98254
98664
  const timer = setTimeout(finish, ms);
98255
98665
  timer.unref?.();
@@ -98356,7 +98766,7 @@ var init_projects_changed = __esm({
98356
98766
  // packages/server/src/project-teardown.ts
98357
98767
  import { rmSync as rmSync21 } from "node:fs";
98358
98768
  import { homedir as homedir27 } from "node:os";
98359
- import { dirname as dirname31, resolve as resolve14 } from "node:path";
98769
+ import { dirname as dirname31, resolve as resolve15 } from "node:path";
98360
98770
  async function stopProjectWorkers(ctx) {
98361
98771
  let stopped = 0;
98362
98772
  for (const row of ctx.storage.allSessions()) {
@@ -98376,7 +98786,7 @@ function deleteProjectState(projectId, home = homedir27()) {
98376
98786
  if (!/^[\w.-]+$/u.test(projectId) || projectId === "." || projectId === "..") {
98377
98787
  throw new Error(`Refusing to delete state for a malformed project id: ${projectId}`);
98378
98788
  }
98379
- if (dirname31(resolve14(target)) !== resolve14(dirname31(projectStateDir("x", home)))) {
98789
+ if (dirname31(resolve15(target)) !== resolve15(dirname31(projectStateDir("x", home)))) {
98380
98790
  throw new Error(`Refusing to delete ${target} \u2014 it is not a project state directory`);
98381
98791
  }
98382
98792
  rmSync21(target, { recursive: true, force: true });
@@ -98406,7 +98816,7 @@ __export(index_exports, {
98406
98816
  });
98407
98817
  import { createServer } from "node:http";
98408
98818
  import { readFileSync as readFileSync46, existsSync as existsSync26, statSync as statSync32 } from "node:fs";
98409
- import { dirname as dirname32, join as join63, resolve as resolve15, extname as extname4, posix as posix2, sep as sep7 } from "node:path";
98819
+ import { dirname as dirname32, join as join64, resolve as resolve16, extname as extname4, posix as posix2, sep as sep8 } from "node:path";
98410
98820
  function readServerAddressHolder(path3) {
98411
98821
  try {
98412
98822
  const value = JSON.parse(readFileSync46(path3, "utf8"));
@@ -98537,12 +98947,12 @@ function staticIsFresh(req, etag, mtimeMs) {
98537
98947
  }
98538
98948
  function serveStatic(distDir, req, res) {
98539
98949
  const rel = posix2.normalize((req.url ?? "/").split("?")[0].replace(/\\/g, "/")).replace(/^(\.\.[/\\])+/, "");
98540
- let file = join63(distDir, rel === "/" ? "index.html" : rel);
98541
- if (!file.startsWith(distDir + sep7)) file = join63(distDir, "index.html");
98542
- if (!existsSync26(file)) file = join63(distDir, "index.html");
98950
+ let file = join64(distDir, rel === "/" ? "index.html" : rel);
98951
+ if (!file.startsWith(distDir + sep8)) file = join64(distDir, "index.html");
98952
+ if (!existsSync26(file)) file = join64(distDir, "index.html");
98543
98953
  try {
98544
98954
  const stats = statSync32(file);
98545
- const cacheControl = file.startsWith(join63(distDir, "assets") + sep7) ? STATIC_CACHE_IMMUTABLE : STATIC_CACHE_REVALIDATE;
98955
+ const cacheControl = file.startsWith(join64(distDir, "assets") + sep8) ? STATIC_CACHE_IMMUTABLE : STATIC_CACHE_REVALIDATE;
98546
98956
  const etag = `"${stats.size.toString(16)}-${Math.trunc(stats.mtimeMs).toString(16)}"`;
98547
98957
  const headers = {
98548
98958
  "content-type": MIME[extname4(file)] ?? "application/octet-stream",
@@ -98551,7 +98961,10 @@ function serveStatic(distDir, req, res) {
98551
98961
  "last-modified": stats.mtime.toUTCString(),
98552
98962
  // Sent on every static response, not just the compressed ones: a shared cache in front of a
98553
98963
  // tunnelled Frizz must not hand a brotli body to a client that asked for identity.
98554
- vary: "Accept-Encoding"
98964
+ vary: "Accept-Encoding",
98965
+ // Before the 304 below: a browser keeps the frame policy of the response it revalidated from, and
98966
+ // an older copy of the page has none.
98967
+ ...FRAME_REFUSED_HEADERS
98555
98968
  };
98556
98969
  if (staticIsFresh(req, etag, stats.mtimeMs)) {
98557
98970
  res.writeHead(304, headers);
@@ -98712,7 +99125,9 @@ async function startServer(opts = {}) {
98712
99125
  // A reader's live watch on the file it shows. Gated as the read is (one set of openable roots for
98713
99126
  // both readers, plus the Markdown reader's canonical-extension check) and watched by CANONICAL
98714
99127
  // path, so a symlinked `.md` and its target are one watch.
98715
- watchFile: (path3, onChange) => watchLocalFile(resolveWatchableLocalFile(path3, openableFileRoots(c.project)), onChange)
99128
+ watchFile: (path3, onChange) => watchLocalFile(resolveWatchableLocalFile(path3, openableFileRoots(c.project)), onChange),
99129
+ mayReadRemotely: (path3) => remoteReadablePath(path3, remoteProjectDirs(c.project.dir)) !== null,
99130
+ refusedRemotely: (request, detail2) => auditRemoteRefusal(c.audit, request, detail2, { id: c.project.id, dir: c.project.dir })
98716
99131
  });
98717
99132
  let githubInit;
98718
99133
  let appSocket;
@@ -98983,8 +99398,8 @@ async function startServer(opts = {}) {
98983
99398
  await phase("wake scheduler", () => void 0);
98984
99399
  }
98985
99400
  statusPath = serverLockPathFor(ctx.project);
98986
- const webRoot = resolve15(import.meta.dirname, "..", "..", "web");
98987
- const distDir = opts.webDistDir ? resolve15(opts.webDistDir) : join63(webRoot, "dist");
99401
+ const webRoot = resolve16(import.meta.dirname, "..", "..", "web");
99402
+ const distDir = opts.webDistDir ? resolve16(opts.webDistDir) : join64(webRoot, "dist");
98988
99403
  startupPhase = "Vite";
98989
99404
  if (opts.dev) {
98990
99405
  try {
@@ -99032,7 +99447,7 @@ async function startServer(opts = {}) {
99032
99447
  (segment) => findProjectBySegment(segment),
99033
99448
  (projectId) => tenants.get(projectId) !== void 0
99034
99449
  );
99035
- if (registered) {
99450
+ if (registered && !isRemoteCaller(firstValue(req.headers[CALLER_HEADER]))) {
99036
99451
  res.writeHead(200, { "content-type": "application/json" });
99037
99452
  res.end(JSON.stringify(registered));
99038
99453
  return;
@@ -99060,11 +99475,16 @@ async function startServer(opts = {}) {
99060
99475
  return;
99061
99476
  }
99062
99477
  if (vite) {
99478
+ if (isRemoteCaller(firstValue(req.headers[CALLER_HEADER]))) {
99479
+ res.writeHead(403, { "content-type": "text/plain; charset=UTF-8", ...FRAME_REFUSED_HEADERS });
99480
+ res.end(remoteRefusedMessage());
99481
+ return;
99482
+ }
99063
99483
  vite.middlewares(req, res, () => {
99064
99484
  try {
99065
- const html = readFileSync46(join63(webRoot, "index.html"), "utf8");
99485
+ const html = readFileSync46(join64(webRoot, "index.html"), "utf8");
99066
99486
  void vite.transformIndexHtml(url, html).then((out) => {
99067
- res.writeHead(200, { "content-type": "text/html" });
99487
+ res.writeHead(200, { "content-type": "text/html", ...FRAME_REFUSED_HEADERS });
99068
99488
  res.end(out);
99069
99489
  });
99070
99490
  } catch {
@@ -99207,7 +99627,7 @@ async function startServer(opts = {}) {
99207
99627
  });
99208
99628
  }
99209
99629
  }
99210
- var SERVER_SHUTDOWN_TIMEOUT_MS, SERVER_FORCE_EXIT_MS, defaultStartServerRuntime, ServerStartupError, isApiUrl, serverLockPathFor, MIME, STATIC_CACHE_IMMUTABLE, STATIC_CACHE_REVALIDATE, staticEncodedCache, STATIC_ENCODED_CACHE_MAX_BYTES, staticEncodedCacheBytes;
99630
+ var SERVER_SHUTDOWN_TIMEOUT_MS, SERVER_FORCE_EXIT_MS, defaultStartServerRuntime, ServerStartupError, firstValue, isApiUrl, serverLockPathFor, MIME, STATIC_CACHE_IMMUTABLE, STATIC_CACHE_REVALIDATE, staticEncodedCache, STATIC_ENCODED_CACHE_MAX_BYTES, staticEncodedCacheBytes;
99211
99631
  var init_index = __esm({
99212
99632
  "packages/server/src/index.ts"() {
99213
99633
  "use strict";
@@ -99222,6 +99642,11 @@ var init_index = __esm({
99222
99642
  init_local_file_watch();
99223
99643
  init_project_launch();
99224
99644
  init_frizz_paths();
99645
+ init_audit();
99646
+ init_local_origin();
99647
+ init_remote_gate();
99648
+ init_remote_refusal();
99649
+ init_remote_reads();
99225
99650
  init_project_identity();
99226
99651
  init_boot_progress();
99227
99652
  init_logging();
@@ -99272,8 +99697,9 @@ var init_index = __esm({
99272
99697
  this.fence = options.fence;
99273
99698
  }
99274
99699
  };
99700
+ firstValue = (value) => Array.isArray(value) ? value[0] : value;
99275
99701
  isApiUrl = (url) => url === FRIZZ_ROUTE_PREFIX || url.startsWith(`${FRIZZ_ROUTE_PREFIX}/`);
99276
- serverLockPathFor = (project) => join63(project.stateDir, "server.lock");
99702
+ serverLockPathFor = (project) => join64(project.stateDir, "server.lock");
99277
99703
  MIME = {
99278
99704
  ".html": "text/html",
99279
99705
  ".js": "text/javascript",
@@ -99298,7 +99724,7 @@ init_shutdown();
99298
99724
  init_logging();
99299
99725
  init_access_codes();
99300
99726
  import { existsSync as existsSync27 } from "node:fs";
99301
- import { join as join64 } from "node:path";
99727
+ import { join as join65 } from "node:path";
99302
99728
 
99303
99729
  // packages/server/src/session-epoch-child.ts
99304
99730
  init_access_codes();
@@ -99516,6 +99942,7 @@ var RECOVERY_SCRIPT = `
99516
99942
 
99517
99943
  // packages/server/src/restart-supervisor.ts
99518
99944
  init_audit();
99945
+ init_remote_refusal();
99519
99946
  init_src();
99520
99947
  var SUPERVISOR_CONTROL_PREFIX = "/_frizz/control";
99521
99948
  var SUPERVISOR_RESTART_PATH = `${SUPERVISOR_CONTROL_PREFIX}/restart`;
@@ -99618,7 +100045,7 @@ try {
99618
100045
  ];
99619
100046
  if (!existsSync27(stableWebDist)) throw new Error("stable artifact launch is missing its verified web directory");
99620
100047
  for (const [name, directory, requiredFile] of required) {
99621
- if (!directory || !existsSync27(join64(directory, requiredFile)))
100048
+ if (!directory || !existsSync27(join65(directory, requiredFile)))
99622
100049
  throw new Error(`stable artifact launch is missing verified ${name}`);
99623
100050
  }
99624
100051
  }