@openartifactsai/cli 0.23.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/SKILL.md +7 -2
  2. package/package.json +1 -1
  3. package/vendor/CHANGELOG.md +1082 -0
  4. package/vendor/artifact-types/page/SKILL.md +3 -1
  5. package/vendor/artifact-types/page/artifact-type/reference/capabilities.d.ts +0 -1
  6. package/vendor/artifact-types/page/artifact-type/reference/capabilities.md +1 -1
  7. package/vendor/frame-host/client/comments.js +20 -19
  8. package/vendor/frame-host/client/page.js +1352 -0
  9. package/vendor/frame-host/client/review.js +279 -0
  10. package/vendor/frame-host/client/runtime.js +8 -6
  11. package/vendor/frame-host/client/sample.js +1 -1
  12. package/vendor/frame-host/client/shell.css +1 -0
  13. package/vendor/frame-host/client/shell.js +206 -6
  14. package/vendor/frame-host/client/translate.js +375 -0
  15. package/vendor/frame-host/frame-host.mjs +91 -30
  16. package/vendor/home/assets/{browser-models-DWkPVHmp.js → browser-models-Ceon9UIN.js} +4 -4
  17. package/vendor/home/assets/library-RBaguEV9.js +397 -0
  18. package/vendor/home/assets/main-BKHYngAm.js +2 -0
  19. package/vendor/home/assets/main-Cw3mY0u9.css +1 -0
  20. package/vendor/home/assets/node.browser-BFrmG6rb.js +1 -0
  21. package/vendor/home/assets/node.browser-CPQVYRMD.js +1 -0
  22. package/vendor/home/assets/react-DQymU5Da.js +47 -0
  23. package/vendor/home/index.html +3 -3
  24. package/vendor/home/library/index.html +2 -2
  25. package/vendor/open-artifacts.mjs +2516 -1072
  26. package/vendor/runtime.json +1 -1
  27. package/vendor/shell/assets/{browser-models-BzwWAVuE.js → browser-models-CiXqE7b9.js} +4 -4
  28. package/vendor/shell/assets/index-BhxD6amu.js +53 -0
  29. package/vendor/shell/assets/index-Cw3mY0u9.css +1 -0
  30. package/vendor/shell/assets/{node.browser-BgqLTfql.js → node.browser-ByUkO9oN.js} +1 -1
  31. package/vendor/shell/assets/{node.browser-BvryIsl7.js → node.browser-CSEwiusG.js} +1 -1
  32. package/vendor/shell/index.html +2 -2
  33. package/vendor/type-server/cli.mjs +87 -26
  34. package/vendor/type-server/editors/data/assets/{index-CX_sn7ZZ.js → index-B0E35R1E.js} +5 -4
  35. package/vendor/type-server/editors/data/index.html +1 -1
  36. package/vendor/type-server/editors/design/assets/{index-BpNUmTVD.js → index-BOc3kd6N.js} +78 -77
  37. package/vendor/type-server/editors/design/index.html +1 -1
  38. package/vendor/type-server/editors/design-system/assets/{index-CP6AEO1P.js → index-B7MtPrtk.js} +5 -4
  39. package/vendor/type-server/editors/design-system/index.html +1 -1
  40. package/vendor/type-server/editors/docs/assets/{abnfDiagram-WEYOIA3C-Do25i7oS.js → abnfDiagram-WEYOIA3C-DcfGbMC9.js} +1 -1
  41. package/vendor/type-server/editors/docs/assets/{architectureDiagram-ZHVYKT53-BLlpboc2.js → architectureDiagram-ZHVYKT53-CfcGFZjM.js} +1 -1
  42. package/vendor/type-server/editors/docs/assets/{blockDiagram-RJAE7QA3-D0rO5p7M.js → blockDiagram-RJAE7QA3-C5s3aXD2.js} +1 -1
  43. package/vendor/type-server/editors/docs/assets/{c4Diagram-XDPPPE54-OoTiysJI.js → c4Diagram-XDPPPE54-BJgchX97.js} +1 -1
  44. package/vendor/type-server/editors/docs/assets/channel-B2TtMfsN.js +1 -0
  45. package/vendor/type-server/editors/docs/assets/{chunk-2E7WHVMD-yBl5BEaI.js → chunk-2E7WHVMD-BgQ4xapY.js} +1 -1
  46. package/vendor/type-server/editors/docs/assets/{chunk-2Q5K7J3B-DHKM5gd6.js → chunk-2Q5K7J3B-B1ktgQTo.js} +1 -1
  47. package/vendor/type-server/editors/docs/assets/{chunk-4EMNKR2T-B-f8WPM6.js → chunk-4EMNKR2T-Co-2oGfa.js} +1 -1
  48. package/vendor/type-server/editors/docs/assets/{chunk-55XCU76K-n8RDJr36.js → chunk-55XCU76K-BqpDaZgl.js} +1 -1
  49. package/vendor/type-server/editors/docs/assets/{chunk-5VM5RSS4-DzLzcqXE.js → chunk-5VM5RSS4-BJPvauTV.js} +1 -1
  50. package/vendor/type-server/editors/docs/assets/{chunk-JWPE2WC7-BLXkUVcK.js → chunk-JWPE2WC7-NCBAl-SW.js} +1 -1
  51. package/vendor/type-server/editors/docs/assets/{chunk-VQ5W62QI-DAGNVD29.js → chunk-VQ5W62QI-DPzloG3R.js} +1 -1
  52. package/vendor/type-server/editors/docs/assets/{chunk-XXDRQBXY-fgVyAbWV.js → chunk-XXDRQBXY-D08KAfXl.js} +1 -1
  53. package/vendor/type-server/editors/docs/assets/{chunk-ZCHMQSOR-D90xHR9n.js → chunk-ZCHMQSOR-CLWESu07.js} +2 -2
  54. package/vendor/type-server/editors/docs/assets/{classDiagram-v2-4MYWR3UA-uk1mPogR.js → classDiagram-v2-4MYWR3UA-BSPsabsn.js} +1 -1
  55. package/vendor/type-server/editors/docs/assets/{core-BMv5rGOd.js → core-Cqu2ilBr.js} +1 -1
  56. package/vendor/type-server/editors/docs/assets/{cose-bilkent-JH36ORCC-BJdqW8l3.js → cose-bilkent-JH36ORCC-D6at9M78.js} +1 -1
  57. package/vendor/type-server/editors/docs/assets/{cynefin-EF2NZ3EQ-BCce_ZhK.js → cynefin-EF2NZ3EQ-BTylb97F.js} +1 -1
  58. package/vendor/type-server/editors/docs/assets/{cynefinDiagram-WF24UDRP-DxD-4yjR.js → cynefinDiagram-WF24UDRP-Din3pKvL.js} +1 -1
  59. package/vendor/type-server/editors/docs/assets/{dagre-NK4GIZVX-B3VAS51Y.js → dagre-NK4GIZVX-5qfRwQnt.js} +1 -1
  60. package/vendor/type-server/editors/docs/assets/{diagram-CBK3MWTC-B0kHeUdr.js → diagram-CBK3MWTC-BnrAjIhJ.js} +1 -1
  61. package/vendor/type-server/editors/docs/assets/{diagram-I5XIIV2D-BCRvsLAu.js → diagram-I5XIIV2D-CH_xkoKv.js} +1 -1
  62. package/vendor/type-server/editors/docs/assets/{diagram-ODIL2UCW-DFOTsSuA.js → diagram-ODIL2UCW-D5dns2KC.js} +1 -1
  63. package/vendor/type-server/editors/docs/assets/{diagram-PFBEJUXE-_DT3jk0i.js → diagram-PFBEJUXE-D-3cnWXB.js} +1 -1
  64. package/vendor/type-server/editors/docs/assets/{diagram-RJA3I4VV-UFrdnTgs.js → diagram-RJA3I4VV-DImejfKM.js} +1 -1
  65. package/vendor/type-server/editors/docs/assets/{diagram-TYUNFSNR-DrbWyZOX.js → diagram-TYUNFSNR-DscxSG0M.js} +1 -1
  66. package/vendor/type-server/editors/docs/assets/{ebnfDiagram-V4P3TTPT-M-DCWgZM.js → ebnfDiagram-V4P3TTPT-C4wwb0NC.js} +1 -1
  67. package/vendor/type-server/editors/docs/assets/{elk-QONTBCTQ-l6XmbRQj.js → elk-QONTBCTQ-O05tgWzI.js} +1 -1
  68. package/vendor/type-server/editors/docs/assets/{erDiagram-KYQIGQAA-CHqbnmEE.js → erDiagram-KYQIGQAA-D171V8gY.js} +1 -1
  69. package/vendor/type-server/editors/docs/assets/{flowDiagram-IUGLLWBU-BzkFyGCL.js → flowDiagram-IUGLLWBU-DcvtJsgJ.js} +1 -1
  70. package/vendor/type-server/editors/docs/assets/{ganttDiagram-R7GPNTJY-BcNaSXNv.js → ganttDiagram-R7GPNTJY-DcuQ9a5m.js} +1 -1
  71. package/vendor/type-server/editors/docs/assets/{gitGraphDiagram-PDYL7XHY-JaNdSZbv.js → gitGraphDiagram-PDYL7XHY-iQoh6Yen.js} +1 -1
  72. package/vendor/type-server/editors/docs/assets/{index-BMNUnwXE.js → index-BNk_Jpgl.js} +49 -48
  73. package/vendor/type-server/editors/docs/assets/{infoDiagram-MVDRKAX5-Cl2Q_Ylf.js → infoDiagram-MVDRKAX5-DECkmgI6.js} +1 -1
  74. package/vendor/type-server/editors/docs/assets/{ishikawaDiagram-HPEHV2GE-umirqIpN.js → ishikawaDiagram-HPEHV2GE-CK0mATvD.js} +1 -1
  75. package/vendor/type-server/editors/docs/assets/{journeyDiagram-BOSHW7O7-HMtvkXvq.js → journeyDiagram-BOSHW7O7-Dz1u7rfA.js} +1 -1
  76. package/vendor/type-server/editors/docs/assets/{kanban-definition-FNSA4HC5-CYouTBUM.js → kanban-definition-FNSA4HC5-B1-0Mp0R.js} +1 -1
  77. package/vendor/type-server/editors/docs/assets/{mermaid.core-BEcbgpI8.js → mermaid.core-DhXbeevr.js} +4 -4
  78. package/vendor/type-server/editors/docs/assets/{mindmap-definition-6OY57UG3-BnwugHtV.js → mindmap-definition-6OY57UG3-Czy5C8sa.js} +1 -1
  79. package/vendor/type-server/editors/docs/assets/{pegDiagram-ECIUJNBX-DqT6jxo7.js → pegDiagram-ECIUJNBX-C97juwaO.js} +1 -1
  80. package/vendor/type-server/editors/docs/assets/{pieDiagram-GNMPY74T-CBKjnr1W.js → pieDiagram-GNMPY74T-rrh7flvh.js} +1 -1
  81. package/vendor/type-server/editors/docs/assets/{quadrantDiagram-D57K4MC3-CdTG11Ff.js → quadrantDiagram-D57K4MC3-D3xBy1ZX.js} +1 -1
  82. package/vendor/type-server/editors/docs/assets/{railroadDiagram-Y72NRBL7-BZgG8r2y.js → railroadDiagram-Y72NRBL7-B3r2jnFu.js} +1 -1
  83. package/vendor/type-server/editors/docs/assets/{requirementDiagram-EQYSW5RA-CutdnAmY.js → requirementDiagram-EQYSW5RA-BQ47C1Ra.js} +1 -1
  84. package/vendor/type-server/editors/docs/assets/{sankeyDiagram-SY24JHO5-DBaoPDhR.js → sankeyDiagram-SY24JHO5-CzPG7mjJ.js} +1 -1
  85. package/vendor/type-server/editors/docs/assets/{sequenceDiagram-BLEHNHQU-B6YZp-Wu.js → sequenceDiagram-BLEHNHQU-Bg7XKU4E.js} +1 -1
  86. package/vendor/type-server/editors/docs/assets/{sizeCapture-INFHLROL-xATlK6Zl.js → sizeCapture-INFHLROL-CKrHufer.js} +1 -1
  87. package/vendor/type-server/editors/docs/assets/{stateDiagram-v2-A6IESKWZ-C7BND5vv.js → stateDiagram-v2-A6IESKWZ-CW9zsuBs.js} +1 -1
  88. package/vendor/type-server/editors/docs/assets/{swimlanes-B3ENRKFQ-WYLzM6hb.js → swimlanes-B3ENRKFQ-ucM-4idg.js} +1 -1
  89. package/vendor/type-server/editors/docs/assets/swimlanesDiagram-AYQRV4AK-DuNOy5jj.js +8 -0
  90. package/vendor/type-server/editors/docs/assets/{timeline-definition-JXYKGLGB-BXC0F4xE.js → timeline-definition-JXYKGLGB-D__Vd4zC.js} +1 -1
  91. package/vendor/type-server/editors/docs/assets/{usecaseDiagram-WPOLBNNX-Cx58jkEj.js → usecaseDiagram-WPOLBNNX-MvJGETnL.js} +1 -1
  92. package/vendor/type-server/editors/docs/assets/{vennDiagram-Q3Y3IDCW-DhdwpApW.js → vennDiagram-Q3Y3IDCW-DqUtQLGR.js} +1 -1
  93. package/vendor/type-server/editors/docs/assets/{wardleyDiagram-IVAIDKWA-CBdbPWVr.js → wardleyDiagram-IVAIDKWA-usWt7-Hk.js} +1 -1
  94. package/vendor/type-server/editors/docs/assets/{xychartDiagram-4URNHDU4-Cb0tcPqs.js → xychartDiagram-4URNHDU4-D2RJz2yB.js} +1 -1
  95. package/vendor/type-server/editors/docs/index.html +1 -1
  96. package/vendor/type-server/editors/motion/assets/{gif-jobs-Bq4rwLBV.js → gif-jobs-Bn-j8izW.js} +1 -1
  97. package/vendor/type-server/editors/motion/assets/{index-BDOqtmcc.js → index-C6NXgLix.js} +7 -6
  98. package/vendor/type-server/editors/motion/assets/{src-8SKXU1IY.js → src-C0eDPv3h.js} +1 -1
  99. package/vendor/type-server/editors/motion/index.html +1 -1
  100. package/vendor/type-server/editors/sheets/assets/{index-BY38EAff.js → index-BzbNSKJF.js} +7 -6
  101. package/vendor/type-server/editors/sheets/assets/{workbook-worker-CRtLrZhP.js → workbook-worker-3zEBX9ep.js} +3 -2
  102. package/vendor/type-server/editors/sheets/index.html +1 -1
  103. package/vendor/type-server/editors/slides/assets/{index-B51oMclO.js → index-BfTA-zoQ.js} +7 -6
  104. package/vendor/type-server/editors/slides/assets/{src-CdsEFSuC.js → src-DPkvzCL6.js} +1 -1
  105. package/vendor/type-server/editors/slides/index.html +1 -1
  106. package/vendor/type-server/editors/whiteboard/assets/{drawing-look-worker-Dd2iYbXC.js → drawing-look-worker-CYqIJdVf.js} +4 -3
  107. package/vendor/type-server/editors/whiteboard/assets/{gif-jobs-DmIqT6gk.js → gif-jobs-CPyG3MAt.js} +1 -1
  108. package/vendor/type-server/editors/whiteboard/assets/{index-B3oRKavi.js → index-BBgN0Gcr.js} +2 -2
  109. package/vendor/type-server/editors/whiteboard/assets/{index-CTf9pd4S.js → index-BKFgBbwk.js} +8 -7
  110. package/vendor/type-server/editors/whiteboard/index.html +1 -1
  111. package/vendor/type-server/shell/assets/{browser-models-BzwWAVuE.js → browser-models-CiXqE7b9.js} +4 -4
  112. package/vendor/type-server/shell/assets/index-BhxD6amu.js +53 -0
  113. package/vendor/type-server/shell/assets/index-Cw3mY0u9.css +1 -0
  114. package/vendor/type-server/shell/assets/{node.browser-BgqLTfql.js → node.browser-ByUkO9oN.js} +1 -1
  115. package/vendor/type-server/shell/assets/{node.browser-BvryIsl7.js → node.browser-CSEwiusG.js} +1 -1
  116. package/vendor/type-server/shell/index.html +2 -2
  117. package/vendor/home/assets/RuntimeUpdate-BwvJ9sYp.js +0 -43
  118. package/vendor/home/assets/library-CyeaNaQo.js +0 -226
  119. package/vendor/home/assets/main-DUyobyFI.js +0 -5
  120. package/vendor/home/assets/main-DXpv3z2x.css +0 -1
  121. package/vendor/home/assets/node.browser-Cy4GM7Yl.js +0 -1
  122. package/vendor/home/assets/node.browser-nUfHL25Z.js +0 -1
  123. package/vendor/shell/assets/index-BIHLxOO6.js +0 -52
  124. package/vendor/shell/assets/index-DXpv3z2x.css +0 -1
  125. package/vendor/type-server/editors/docs/assets/channel-Cgat34ii.js +0 -1
  126. package/vendor/type-server/editors/docs/assets/swimlanesDiagram-AYQRV4AK-Bwh1tnzE.js +0 -8
  127. package/vendor/type-server/shell/assets/index-BIHLxOO6.js +0 -52
  128. package/vendor/type-server/shell/assets/index-DXpv3z2x.css +0 -1
@@ -0,0 +1,279 @@
1
+ "use strict";
2
+ (() => {
3
+ // packages/server-sdk/src/frame/client/review.ts
4
+ (() => {
5
+ "use strict";
6
+ const w = window;
7
+ const MAX_EVENTS = 50;
8
+ const MAX_ERRORS = 10;
9
+ const MAX_OUTLINE_CHARS = 9e3;
10
+ const VIEW_LINES = 16;
11
+ const PART_LINES = 45;
12
+ const MAX_CLIPPED_ELEMENTS = 6;
13
+ const MEASURE_MS = 150;
14
+ const MAX_CUTS = 40;
15
+ const CUT_OFF = "text is cut off in ";
16
+ const INTO_MARGIN = "text runs into the bottom margin of ";
17
+ const LANDMARKS = "header,nav,main,section,article,aside,footer,h1,h2,h3,table,form,canvas,svg,img,button";
18
+ const TEXT_HOLDERS = "h1,h2,h3,h4,p,a,button,li,td,th,label";
19
+ const EDITABLE = "textarea,[contenteditable]";
20
+ const NOT_MEASURED = "svg,script,style,textarea,select,[role=img],[aria-hidden=true],[inert],[contenteditable]:not([contenteditable=false])";
21
+ const MOVES = /transform|translate|rotate|scale|height|width|top|left|right|bottom|margin|inset|grid|font/i;
22
+ const squash = (text) => (text ?? "").replace(/\s+/g, " ").trim();
23
+ const clip = (text, max) => {
24
+ const flat = squash(text);
25
+ return flat.length > max ? `${flat.slice(0, max - 1)}…` : flat;
26
+ };
27
+ const shown = (el) => el.getClientRects().length > 0;
28
+ const px = (value) => parseFloat(value) || 0;
29
+ const isSet = (value) => !!value && value !== "none";
30
+ const hides = (overflow) => overflow === "hidden" || overflow === "clip";
31
+ const scrolls = (overflow) => overflow === "auto" || overflow === "scroll";
32
+ function pathOf(start) {
33
+ const steps = [];
34
+ for (let el = start; el && el !== document.documentElement && steps.length < 12; el = el.parentElement) {
35
+ if (el.id && /^[A-Za-z][\w-]*$/.test(el.id)) {
36
+ steps.unshift(`#${el.id}`);
37
+ break;
38
+ }
39
+ let nth = 1;
40
+ for (let sib = el.previousElementSibling; sib; sib = sib.previousElementSibling) if (sib.tagName === el.tagName) nth++;
41
+ steps.unshift(`${el.tagName.toLowerCase()}:nth-of-type(${nth})`);
42
+ }
43
+ return steps.join(" > ") || "html";
44
+ }
45
+ function wordsOf(el) {
46
+ if (el.ownerDocument.designMode === "on" || el.closest(EDITABLE) || el.querySelector(EDITABLE)) return "";
47
+ return el instanceof HTMLElement ? el.innerText : el.textContent ?? "";
48
+ }
49
+ const labelOf = (el) => clip(el.getAttribute("aria-label") || el.getAttribute("alt") || wordsOf(el), 48) || el.tagName.toLowerCase();
50
+ function first(selector) {
51
+ if (typeof selector !== "string" || !selector) return null;
52
+ try {
53
+ return [...document.querySelectorAll(selector)].find(shown) ?? null;
54
+ } catch {
55
+ return null;
56
+ }
57
+ }
58
+ function overflowsHidden(el) {
59
+ const style = getComputedStyle(el);
60
+ if (el.clientWidth <= 4 || style.textOverflow === "ellipsis" || !squash(el.textContent)) return false;
61
+ return hides(style.overflowX) && el.scrollWidth > el.clientWidth + 2 || hides(style.overflowY) && el.scrollHeight > el.clientHeight + 2;
62
+ }
63
+ function describe(el) {
64
+ const box = el.getBoundingClientRect();
65
+ const style = getComputedStyle(el);
66
+ const classes = el.classList.length ? ` .${clip(el.classList.value, 40)}` : "";
67
+ const at = `@${Math.round(box.left)},${Math.round(box.top + scrollY)} ${Math.round(box.width)}x${Math.round(box.height)}`;
68
+ const type = `${style.display} ${style.fontWeight} ${style.fontSize} ${style.color} on ${style.backgroundColor}`;
69
+ return `${pathOf(el)}${classes} ${at} ${type}${overflowsHidden(el) ? " CLIPPED" : ""} "${labelOf(el)}"`;
70
+ }
71
+ function outline(part) {
72
+ const inView = (el) => {
73
+ const box = el.getBoundingClientRect();
74
+ return box.bottom > 0 && box.top < innerHeight;
75
+ };
76
+ const els = part ? [part, ...part.querySelectorAll(":not(svg *)")].filter(shown).slice(0, PART_LINES) : [...document.querySelectorAll(LANDMARKS)].filter((el) => shown(el) && inView(el)).slice(0, VIEW_LINES);
77
+ const head = `Scrolled to ${Math.round(scrollY)} of ${document.documentElement.scrollHeight}`;
78
+ return [head, ...els.map(describe)].join("\n").slice(0, MAX_OUTLINE_CHARS);
79
+ }
80
+ function clippersOf(el, moving, known) {
81
+ if (known.has(el)) return known.get(el);
82
+ const root = document.documentElement;
83
+ const rootStyle = getComputedStyle(root);
84
+ const bodyIsViewport = rootStyle.overflowX === "visible" && rootStyle.overflowY === "visible";
85
+ const out = [];
86
+ let opacity = 1;
87
+ let freeX = true;
88
+ let freeY = true;
89
+ let placed = false;
90
+ let result = out;
91
+ for (let at = el; at; at = at.parentElement) {
92
+ const style = getComputedStyle(at);
93
+ opacity *= Number(style.opacity || 1);
94
+ if (moving.has(at) || style.display === "none" || opacity < 0.35) {
95
+ result = null;
96
+ break;
97
+ }
98
+ const transformed = isSet(style.transform) || isSet(style.translate) || isSet(style.rotate);
99
+ const containing = style.position !== "static" || transformed;
100
+ if (at === root) {
101
+ const x = freeX && hides(bodyIsViewport && document.body ? getComputedStyle(document.body).overflowX : rootStyle.overflowX);
102
+ if (x) out.push({ el: at, box: new DOMRect(-scrollX, -scrollY, root.clientWidth, innerHeight), room: innerHeight, padBottom: 0, x, y: false, trims: scrollX !== 0, capped: true });
103
+ } else if (!(placed && !containing) && !(at === document.body && bodyIsViewport)) {
104
+ const box = at.getBoundingClientRect();
105
+ const scale = box.height / (at.offsetHeight || box.height || 1) || 1;
106
+ const padBottom = px(style.paddingBottom) * scale;
107
+ const x = freeX && hides(style.overflowX);
108
+ const y = freeY && hides(style.overflowY);
109
+ if (x || y) {
110
+ const masked = isSet(style.maskImage) || isSet(style.scrollSnapType);
111
+ out.push({
112
+ el: at,
113
+ box,
114
+ room: box.height - px(style.paddingTop) * scale - padBottom,
115
+ padBottom,
116
+ x,
117
+ y,
118
+ trims: masked || at.scrollLeft !== 0 || style.textOverflow === "ellipsis",
119
+ capped: masked || at.scrollTop > 0 || isSet(style.maxHeight) || isSet(style.webkitLineClamp)
120
+ });
121
+ }
122
+ if (scrolls(style.overflowX) && at.scrollWidth > at.clientWidth) freeX = false;
123
+ if (scrolls(style.overflowY) && at.scrollHeight > at.clientHeight) freeY = false;
124
+ }
125
+ if (containing) placed = false;
126
+ if (style.position === "absolute") placed = true;
127
+ if (style.position === "fixed" || transformed) break;
128
+ }
129
+ known.set(el, result);
130
+ return result;
131
+ }
132
+ function cutBy(line, clippers) {
133
+ const slack = line.height * 0.3;
134
+ for (const c of clippers) {
135
+ const { box } = c;
136
+ const pastX = c.x && (line.right - slack > box.right || line.left + slack < box.left);
137
+ const pastY = c.y && (line.bottom - slack > box.bottom || line.top + slack < box.top);
138
+ const besideX = box.width < line.height || line.right <= box.left + slack || line.left >= box.right - slack;
139
+ const besideY = line.top >= box.bottom - slack || line.bottom <= box.top + slack;
140
+ const roomy = c.room > line.height * 3;
141
+ if (pastY && !c.capped && !besideX && (besideY ? roomy : c.room > line.height / 2)) return [c.el, CUT_OFF];
142
+ if (pastX && !besideX && !besideY && !c.trims) return [c.el, CUT_OFF];
143
+ if (pastX || pastY) return null;
144
+ if (c.y && !c.capped && roomy && c.padBottom >= 24 && line.bottom > box.bottom - c.padBottom * 0.6) return [c.el, INTO_MARGIN];
145
+ }
146
+ return null;
147
+ }
148
+ function cutText() {
149
+ const until = performance.now() + MEASURE_MS;
150
+ const moving = /* @__PURE__ */ new Set();
151
+ for (const animation of document.getAnimations()) {
152
+ const effect = animation.effect;
153
+ if (!(effect instanceof KeyframeEffect) || effect.pseudoElement || animation.playState === "finished") continue;
154
+ if (MOVES.test(Object.keys(effect.getKeyframes()[0] ?? {}).join())) moving.add(effect.target);
155
+ }
156
+ const found = /* @__PURE__ */ new Map();
157
+ const known = /* @__PURE__ */ new Map();
158
+ const range = document.createRange();
159
+ const texts = document.createTreeWalker(document.body ?? document.documentElement, NodeFilter.SHOW_TEXT);
160
+ for (let node = texts.nextNode(); node && found.size < MAX_CUTS; node = texts.nextNode()) {
161
+ if (performance.now() > until) return null;
162
+ const text = node.nodeValue ?? "";
163
+ const holder = node.parentElement;
164
+ if (!holder || text.length > 2e4 || !/[\p{L}\p{N}]/u.test(text) || holder.closest(NOT_MEASURED)) continue;
165
+ if (holder.checkVisibility?.({ visibilityProperty: true, contentVisibilityAuto: true }) === false) continue;
166
+ const clippers = clippersOf(holder, moving, known);
167
+ if (!clippers?.length) continue;
168
+ range.setStart(node, 0);
169
+ range.setEnd(node, text.trimEnd().length);
170
+ for (const line of range.getClientRects()) {
171
+ const cut = line.width > 0 ? cutBy(line, clippers) : null;
172
+ if (cut && found.get(cut[0]) !== CUT_OFF) found.set(cut[0], cut[1]);
173
+ }
174
+ }
175
+ if (found.size >= MAX_CUTS || document.fonts?.status === "loading") return null;
176
+ return [...found].map(([el, what]) => what + pathOf(el));
177
+ }
178
+ w.__openArtifactsReview?.(({ send, errors: early }) => {
179
+ const errors = early.map((e) => clip(e, 200)).slice(-MAX_ERRORS);
180
+ const events = [];
181
+ const noteError = (error) => {
182
+ errors.push(clip(error instanceof Error ? error.message : String(error), 200));
183
+ errors.splice(0, errors.length - MAX_ERRORS);
184
+ };
185
+ const note = (kind, what) => {
186
+ const last = events[events.length - 1];
187
+ if (last?.kind === kind && (kind === "scroll" || last.what === what)) events.pop();
188
+ events.push({ at: Date.now(), kind, what });
189
+ events.splice(0, events.length - MAX_EVENTS);
190
+ };
191
+ addEventListener("error", (ev) => noteError(ev.message));
192
+ addEventListener("unhandledrejection", (ev) => noteError(ev.reason));
193
+ addEventListener("scrollend", () => note("scroll", `to ${Math.round(scrollY)}px`), { passive: true });
194
+ addEventListener(
195
+ "click",
196
+ (ev) => {
197
+ const at = ev.composedPath()[0];
198
+ if (ev.isTrusted && at instanceof Element) note("click", `${pathOf(at)} "${labelOf(at)}"`);
199
+ },
200
+ true
201
+ );
202
+ addEventListener(
203
+ "change",
204
+ (ev) => {
205
+ const t = ev.target;
206
+ if (!ev.isTrusted || !(t instanceof Element)) return;
207
+ let value;
208
+ if (t instanceof HTMLSelectElement) value = t.selectedOptions[0]?.text;
209
+ else if (t instanceof HTMLInputElement) value = /^(checkbox|radio)$/.test(t.type) ? String(t.checked) : t.type === "range" ? t.value : void 0;
210
+ note("change", `${pathOf(t)}${value === void 0 ? "" : ` to ${clip(value, 60)}`}`);
211
+ },
212
+ true
213
+ );
214
+ function problems(measure) {
215
+ const out = [];
216
+ const width = document.documentElement.clientWidth;
217
+ if (document.documentElement.scrollWidth > width + 1) {
218
+ const wide = [...document.body?.querySelectorAll(":not(svg *)") ?? []].find((el) => el.getBoundingClientRect().right > width + 1);
219
+ out.push(`the page scrolls sideways at ${width}px wide${wide ? `, because of ${pathOf(wide)}` : ""}`);
220
+ }
221
+ let clipped = 0;
222
+ for (const el of document.body?.querySelectorAll(TEXT_HOLDERS) ?? []) {
223
+ if (clipped >= MAX_CLIPPED_ELEMENTS) break;
224
+ if (overflowsHidden(el)) {
225
+ clipped++;
226
+ out.push(CUT_OFF + pathOf(el));
227
+ }
228
+ }
229
+ if (measure) out.push(...cutText() ?? []);
230
+ return [...new Set(out)];
231
+ }
232
+ let before = null;
233
+ return (command) => {
234
+ const answer = (value) => send({ __fr: { op: "answer", n: command.n, value } });
235
+ const baseline = before ??= problems(false);
236
+ switch (command.op) {
237
+ case "on":
238
+ send({ __fr: { op: "ready" } });
239
+ break;
240
+ case "stale":
241
+ if (command.leaving !== true) send({ __fr: { op: "ready" } });
242
+ break;
243
+ case "view": {
244
+ const theme = document.documentElement.dataset.theme ?? (matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "");
245
+ const now = Date.now();
246
+ answer({
247
+ w: innerWidth,
248
+ h: innerHeight,
249
+ dark: theme === "dark",
250
+ outline: outline(null),
251
+ events: events.splice(0).map((e) => ({ t: Math.round((now - e.at) / 1e3), kind: e.kind, what: e.what })),
252
+ errors: [...errors]
253
+ });
254
+ break;
255
+ }
256
+ case "look": {
257
+ const part = first(command.path);
258
+ answer({
259
+ outline: command.path && !part ? "Nothing visible matches." : outline(part),
260
+ overflow: problems(true),
261
+ errors: [...errors]
262
+ });
263
+ break;
264
+ }
265
+ case "check": {
266
+ const known = Array.isArray(command.known) ? command.known.map(String) : baseline;
267
+ answer({ problems: [...errors.splice(0).map((e) => `script error: ${e}`), ...problems(true).filter((p) => !known.includes(p))] });
268
+ break;
269
+ }
270
+ case "problems":
271
+ answer([...errors.map((e) => `script error: ${e}`), ...problems(true)]);
272
+ break;
273
+ default:
274
+ break;
275
+ }
276
+ };
277
+ });
278
+ })();
279
+ })();
@@ -13,6 +13,7 @@
13
13
  const parentWin = window.parent;
14
14
  const framed = !!SHELL && !!parentWin && parentWin !== window;
15
15
  const INIT_TIMEOUT_MS = 1e4;
16
+ const INIT_PARSING_LIMIT_MS = 35e3;
16
17
  const WANT_TIMEOUT_MS = 1e4;
17
18
  const ACKED_MS = 9e5;
18
19
  const BUDGET_MAX_MS = 6e5;
@@ -74,6 +75,7 @@
74
75
  initDone = true;
75
76
  if (packet) {
76
77
  if (typeof packet.brokerGen === "number") brokerGen = packet.brokerGen;
78
+ w.__openArtifactsShellInit = { hostKeys: packet.hostKeys, hostVisible: packet.hostVisible };
77
79
  const grants2 = /* @__PURE__ */ new Set();
78
80
  if (isRecord(packet.capabilities)) {
79
81
  for (const [name, grant] of Object.entries(packet.capabilities)) {
@@ -137,9 +139,10 @@
137
139
  if (cap === "assets") msg.holds = true;
138
140
  const activation = cap === "comments" || ACTIVATED[`${cap}.${method}`] === true;
139
141
  try {
140
- if (transfer && transfer.length) parentWin.postMessage(msg, { targetOrigin: SHELL, transfer });
141
- else if (activation) parentWin.postMessage(msg, { targetOrigin: SHELL, includeUserActivation: true });
142
- else parentWin.postMessage(msg, SHELL);
142
+ const options = { targetOrigin: SHELL };
143
+ if (transfer && transfer.length) options.transfer = transfer;
144
+ if (activation) options.includeUserActivation = true;
145
+ parentWin.postMessage(msg, options);
143
146
  } catch (e) {
144
147
  pending.delete(id);
145
148
  p.reject({ code: "invalid_argument", message: String(e?.message || e) });
@@ -229,6 +232,7 @@
229
232
  const tick = () => {
230
233
  if (initDone) return;
231
234
  post({ __frame_connect: true, contract: boot.contract, key: boot.key });
235
+ if (document.readyState === "loading" && !initWaiters.length && performance.now() < INIT_PARSING_LIMIT_MS) tries = 0;
232
236
  if (++tries * 400 < INIT_TIMEOUT_MS) setTimeout(tick, 400);
233
237
  else finishInit(null);
234
238
  };
@@ -790,7 +794,6 @@
790
794
  }
791
795
  async function answerCommentSend(ticket, payload) {
792
796
  let reply;
793
- let handoffNote;
794
797
  for (const listener of [...sendListeners]) {
795
798
  if (!sendListeners.has(listener)) continue;
796
799
  try {
@@ -800,11 +803,10 @@
800
803
  return;
801
804
  }
802
805
  reply ??= commentResponseText(result?.reply, 500);
803
- handoffNote ??= commentResponseText(result?.handoffNote, 2e3);
804
806
  } catch {
805
807
  }
806
808
  }
807
- post({ __open_artifacts_comments_sent: true, ticket, handled: false, reply, handoffNote });
809
+ post({ __open_artifacts_comments_sent: true, ticket, handled: false, reply });
808
810
  }
809
811
  let fallbackOn = false;
810
812
  const COMMENT_CURSOR = 'url("data:image/svg+xml,%3Csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20width=%2728%27%20height=%2728%27%20viewBox=%270%200%2028%2028%27%3E%3Cpath%20d=%27M%202%2026%20L%202%2014%20A%2012%2012%200%201%201%2014%2026%20Z%27%20fill=%27%23000%27%20stroke=%27%23fff%27%20stroke-width=%272%27/%3E%3C/svg%3E") 2 26, crosshair';
@@ -535,7 +535,7 @@
535
535
  return bytes > SAMPLE_MAX_TOOL_RESULT_BYTES ? tooLarge(bytes) : { content: text };
536
536
  }
537
537
  function thrownResult(name, error) {
538
- console.warn(`openArtifacts.sample: tool ${name} threw:`, error);
538
+ console.warn(`openArtifacts: page tool ${name} threw:`, error);
539
539
  const message = isRecord2(error) && typeof error.message === "string" ? error.message : String(error);
540
540
  let content = `Error: ${message}`;
541
541
  while (bytesOf(content) > SAMPLE_MAX_TOOL_RESULT_BYTES) content = content.slice(0, Math.floor(content.length * 0.9));
@@ -23,6 +23,7 @@
23
23
  html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg); }
24
24
  #stage { position: fixed; inset: 0; }
25
25
  #stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: transparent; }
26
+ #stage iframe[data-page-ring] { outline: 2px solid var(--accent); outline-offset: -2px; }
26
27
  .problem-card .row { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }
27
28
  .problem-card button {
28
29
  font: inherit; color: inherit; background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px;
@@ -29,6 +29,9 @@
29
29
  const ACKED = /* @__PURE__ */ new Set(["assets.upload", "comments.sendToAgent", "room.sendToAgentSession", "artifact.publish"]);
30
30
  const SNAPSHOT_READY_S = 8;
31
31
  const SNAPSHOT_HOLD_MS = 5e3;
32
+ const RELOAD_CAPTURE_MS = 250;
33
+ const BLOCKED_NOTICE_MS = 5e3;
34
+ const COMMENT_SHORTCUT = { id: "toggle_comment_mode", key: "KeyC", alt: true, skipInEditable: true };
32
35
  let session = null;
33
36
  let frame = null;
34
37
  let pageWin = null;
@@ -44,6 +47,18 @@
44
47
  const subs = /* @__PURE__ */ new Map();
45
48
  const rerun = /* @__PURE__ */ new Set();
46
49
  let rerunTimer = null;
50
+ const pageTab = (() => {
51
+ const key = "open-artifacts:tab";
52
+ try {
53
+ const have = sessionStorage.getItem(key);
54
+ if (have && /^[0-9a-z]{1,32}$/.test(have)) return have;
55
+ const made = randomId(10).toLowerCase();
56
+ sessionStorage.setItem(key, made);
57
+ return made;
58
+ } catch {
59
+ return randomId(10).toLowerCase();
60
+ }
61
+ })();
47
62
  function randomId(n) {
48
63
  const a = new Uint8Array(n);
49
64
  crypto.getRandomValues(a);
@@ -182,9 +197,10 @@
182
197
  const f = document.createElement("iframe");
183
198
  frame = f;
184
199
  f.title = session?.title || "Artifact";
185
- f.allow = "clipboard-read *; clipboard-write *; fullscreen *; autoplay *";
200
+ f.allow = "clipboard-read *; clipboard-write *; fullscreen *; autoplay *; translator *; language-detector *";
186
201
  f.referrerPolicy = "origin";
187
202
  if (session?.sandbox) f.setAttribute("sandbox", session.sandbox);
203
+ f.name = JSON.stringify({ tab: pageTab });
188
204
  f.src = pageUrl(ver);
189
205
  f.addEventListener("load", () => {
190
206
  dropSamples();
@@ -192,13 +208,32 @@
192
208
  chrome.answered = 0;
193
209
  chrome.sent = 0;
194
210
  if (activity.known) toPage({ __frame_agent_activity: true, working: activity.working });
211
+ toOuter({ openArtifacts: "translate_status", status: { state: "idle", lang: null, usable: false }, fresh: true });
195
212
  });
196
213
  $("stage").append(f);
197
214
  armReadyTimer();
198
215
  }
216
+ let reloads = 0;
217
+ const captures = /* @__PURE__ */ new Map();
199
218
  function reloadPage(nextVer) {
200
219
  if (!frame) return;
201
220
  ver = nextVer;
221
+ const n = ++reloads;
222
+ if (!ready || !pageWin) return loadPageAgain(n);
223
+ let went = false;
224
+ const go = () => {
225
+ if (went) return;
226
+ went = true;
227
+ captures.delete(n);
228
+ loadPageAgain(n);
229
+ };
230
+ captures.set(n, go);
231
+ toPage({ __frame_hot_capture: true, gen: n });
232
+ setTimeout(go, RELOAD_CAPTURE_MS);
233
+ }
234
+ function loadPageAgain(n) {
235
+ if (!frame || n !== reloads) return;
236
+ const nextVer = ver;
202
237
  ready = false;
203
238
  revealed = false;
204
239
  revealHeld = false;
@@ -214,6 +249,7 @@
214
249
  views?.setMovable(false);
215
250
  chrome.snapshot = null;
216
251
  lastSnapshotText = "";
252
+ endPrint(false, "failed");
217
253
  chrome.pendingExport = null;
218
254
  frame.src = pageUrl(nextVer);
219
255
  armReadyTimer();
@@ -254,8 +290,8 @@
254
290
  hostVisible: hostVisible(),
255
291
  hostOverlays: [],
256
292
  hostSides: {},
257
- // Here: no host keys (the outer Shell takes its own shortcuts in its own frame).
258
- hostKeys: [],
293
+ // Alt+C for comment mode, also while the page has focus.
294
+ hostKeys: s.comments?.available ? [COMMENT_SHORTCUT] : [],
259
295
  hot: { gen: 0, phase: "final", from: null },
260
296
  capBudgets: DEFAULT_CAP_BUDGETS,
261
297
  capWants: true,
@@ -297,6 +333,10 @@
297
333
  }
298
334
  if (m.__frame_cap === true && typeof m.id === "string") return answerCap(m);
299
335
  if (m.__frame_cap_want === true) return answerWant(m);
336
+ if (m.__frame_hot_state === true) {
337
+ if (typeof m.gen === "number") captures.get(m.gen)?.();
338
+ return;
339
+ }
300
340
  if (m.__frame_ready === true) {
301
341
  if (!ready) {
302
342
  ready = true;
@@ -327,7 +367,15 @@
327
367
  }
328
368
  if (m.__frame_chrome_hello === true) return chromeHello();
329
369
  if (m.__frame_chrome_report === true) return chromeReport(m.snapshot);
330
- if (m.__frame_chrome_decline === true) return exportEnded(m.request, "declined");
370
+ if (m.__frame_chrome_decline === true) return printing?.request === m.request ? endPrint(false, "declined") : exportEnded(m.request, "declined");
371
+ if (m.__frame_print_ready === true) return printReady(m);
372
+ if (isObj(m.__fr)) return reviewHeard(m.__fr);
373
+ if (isObj(m.__ft_status)) return toOuter({ openArtifacts: "translate_status", status: m.__ft_status });
374
+ if (isObj(m.__ft_xl)) {
375
+ const { id, texts } = m.__ft_xl;
376
+ if (typeof id === "number" && Array.isArray(texts)) toOuter({ openArtifacts: "translate_text", id, texts });
377
+ return;
378
+ }
331
379
  if (m.__open_artifacts_export_done === true) return exportEnded(m.request, "done");
332
380
  if (m.__frame_title_from_content === true && typeof m.title === "string") {
333
381
  const out = await post("title", { title: m.title, ifUnnamed: m.ifUnnamed !== false }).catch(() => null);
@@ -361,6 +409,77 @@
361
409
  return;
362
410
  }
363
411
  if (m.__open_artifacts_comments_moved === true) return void onMoved(m);
412
+ if (m.__frame_nav === true && typeof m.url === "string") return openFromPage(m);
413
+ if (m.__frame_blocked === true) return tellBlocked(m.kind);
414
+ if (m.__frame_host_key === true) return hostKey(m.id);
415
+ if (typeof m.__frame_page_ring === "boolean") {
416
+ frame?.toggleAttribute("data-page-ring", m.__frame_page_ring);
417
+ return;
418
+ }
419
+ }
420
+ const BLOCKED_TEXT = {
421
+ link: "This link can’t be opened here.",
422
+ form: "This form can’t be sent from here.",
423
+ file: "This file can’t be opened here."
424
+ };
425
+ let lastBlockedNotice = 0;
426
+ function tellBlocked(kind) {
427
+ const text = typeof kind === "string" ? BLOCKED_TEXT[kind] : void 0;
428
+ const now = Date.now();
429
+ if (!text || now - lastBlockedNotice < BLOCKED_NOTICE_MS) return;
430
+ lastBlockedNotice = now;
431
+ toast(text);
432
+ }
433
+ let lastHostKey = 0;
434
+ function hostKey(id) {
435
+ if (id !== COMMENT_SHORTCUT.id || !frame || document.activeElement !== frame || !document.hasFocus() || document.fullscreenElement) return;
436
+ const now = performance.now();
437
+ if (now - lastHostKey < 50) return;
438
+ lastHostKey = now;
439
+ toggleCommentsByKey(true);
440
+ }
441
+ function toggleCommentsByKey(fromPage2) {
442
+ if (!session?.comments?.available) return;
443
+ const on = !comments.on;
444
+ setMode(on);
445
+ if (on && fromPage2) toPage({ __frame_leave_field: true });
446
+ }
447
+ function isCommentShortcut(ev) {
448
+ if (!ev.altKey || ev.metaKey || ev.ctrlKey || ev.shiftKey || ev.isComposing || ev.keyCode === 229) return false;
449
+ const letter = /^[ -~]$/.test(ev.key) ? ev.key.toUpperCase() : ev.keyCode >= 65 && ev.keyCode <= 90 ? String.fromCharCode(ev.keyCode) : ev.code.slice(3);
450
+ if (letter !== "C") return false;
451
+ const at = ev.target instanceof Element ? ev.target : null;
452
+ return !at?.closest("input,textarea,select,[contenteditable]:not([contenteditable=false]),[role=dialog],[role=alertdialog],[role=menu],[role=listbox],[role=combobox]");
453
+ }
454
+ let lastOpened = 0;
455
+ function openFromPage(m) {
456
+ const activation = navigator.userActivation;
457
+ if (comments.on || activation?.isActive === false) return;
458
+ let url;
459
+ try {
460
+ url = new URL(m.url);
461
+ } catch {
462
+ return;
463
+ }
464
+ const inApp = /^(mailto|tel|sms):$/.test(url.protocol);
465
+ if (!inApp && url.protocol !== "http:" && url.protocol !== "https:") return;
466
+ if (typeof m.rawHref === "string" && m.rawHref[0] === "#" && url.origin === contentOrigin) {
467
+ if (m.newTab === true) followLink(`${location.origin}${location.pathname}${location.search}${url.hash}`, true);
468
+ return;
469
+ }
470
+ const now = performance.now();
471
+ if (now - lastOpened < 50) return;
472
+ lastOpened = now;
473
+ url.username = "";
474
+ url.password = "";
475
+ followLink(url.href, !inApp);
476
+ }
477
+ function followLink(href, newTab) {
478
+ const a = document.createElement("a");
479
+ a.href = href;
480
+ if (newTab) a.target = "_blank";
481
+ a.rel = "noopener noreferrer";
482
+ a.click();
364
483
  }
365
484
  async function answerCap(m) {
366
485
  const reply = (body) => toPage({ __frame_cap_r: true, id: m.id, ...body });
@@ -944,6 +1063,7 @@
944
1063
  }
945
1064
  const REQUEST = /^[A-Za-z0-9_-]{16,64}$/;
946
1065
  function startExport(format, variant, request, fromOuter2) {
1066
+ if (format === SHELL_PRINT && variant === void 0 && shellPrints()) return startPrint(request, fromOuter2);
947
1067
  const x = chrome.snapshot?.exports?.find((e) => e.format === format);
948
1068
  if (!x || x.disabled) return "unsupported";
949
1069
  if (variant !== void 0 && !(x.variants ?? []).some((v) => v.id === variant && !v.disabled)) return "unsupported";
@@ -972,6 +1092,80 @@
972
1092
  chrome.pendingExport = null;
973
1093
  if (pending.outer) toOuter({ openArtifacts: "chrome_export", request: pending.request, state });
974
1094
  }
1095
+ const SHELL_PRINT = "print";
1096
+ const PRINT_READY_MS = 6e4;
1097
+ const PRINT_MAX_HEIGHT = 5e5;
1098
+ const shellPrints = () => !!frame && !chrome.snapshot?.exports?.length;
1099
+ let printing = null;
1100
+ function startPrint(request, fromOuter2) {
1101
+ const now = Date.now();
1102
+ if (now - chrome.lastExportAt < 250) return "busy";
1103
+ if (printing?.sheet) endPrint(false, "done");
1104
+ if (printing || chrome.pendingExport && now - chrome.pendingExport.at < 5e3) return "busy";
1105
+ chrome.lastExportAt = now;
1106
+ chrome.pendingExport = { request, at: now, outer: fromOuter2 };
1107
+ printing = { request, timer: setTimeout(() => endPrint(false, "failed"), PRINT_READY_MS), sheet: null };
1108
+ toPageCmd({ cmd: "export", format: SHELL_PRINT, request, sender: "viewer" });
1109
+ return "started";
1110
+ }
1111
+ const printNumber = (v) => typeof v === "number" && Number.isFinite(v) ? v : 0;
1112
+ function printReady(m) {
1113
+ const job = printing;
1114
+ if (!job || job.sheet || m.request !== job.request || !frame) return;
1115
+ if (job.timer) clearTimeout(job.timer);
1116
+ job.timer = null;
1117
+ const height = Math.min(Math.ceil(printNumber(m.h)), PRINT_MAX_HEIGHT);
1118
+ const sheet = Math.min(Math.max(printNumber(m.page), height / 500), height);
1119
+ const width = Math.ceil(frame.getBoundingClientRect().width);
1120
+ if (!(width > 0) || !(sheet > 0)) return endPrint(false, "failed");
1121
+ frame.dataset.printing = "";
1122
+ const style = document.createElement("style");
1123
+ style.textContent = `@page{size:${width + 64}px ${Math.ceil(sheet) + 64}px;margin:32px}@media print{html,body{height:auto;overflow:visible;background:none}body>:not(#stage){display:none!important}#stage{position:static}#stage iframe:not([data-printing]){display:none}#stage iframe[data-printing]{position:static;display:block;outline:none;height:${height - 1}px!important}}`;
1124
+ document.head.append(style);
1125
+ job.sheet = style;
1126
+ addEventListener("afterprint", () => endPrint(true, "done"), { once: true });
1127
+ window.print();
1128
+ }
1129
+ function endPrint(printed, state) {
1130
+ const job = printing;
1131
+ if (!job) return;
1132
+ printing = null;
1133
+ if (job.timer) clearTimeout(job.timer);
1134
+ job.sheet?.remove();
1135
+ if (frame) delete frame.dataset.printing;
1136
+ toPage({ __frame_print_done: true, printed });
1137
+ exportEnded(job.request, state);
1138
+ }
1139
+ const REVIEW_ANSWER_MS = 5e3;
1140
+ let reviewSeq = 0;
1141
+ const reviewWaiting = /* @__PURE__ */ new Map();
1142
+ function askPage(op, fields = {}) {
1143
+ const n = ++reviewSeq;
1144
+ return new Promise((resolve) => {
1145
+ const timer = setTimeout(() => {
1146
+ reviewWaiting.delete(n);
1147
+ resolve(void 0);
1148
+ }, REVIEW_ANSWER_MS);
1149
+ reviewWaiting.set(n, (value) => {
1150
+ clearTimeout(timer);
1151
+ reviewWaiting.delete(n);
1152
+ resolve(value);
1153
+ });
1154
+ toPage({ __fr_cmd: { ...fields, op, n } });
1155
+ });
1156
+ }
1157
+ function reviewHeard(m) {
1158
+ if (m.op === "answer" && typeof m.n === "number") reviewWaiting.get(m.n)?.(m.value);
1159
+ }
1160
+ async function lookAtPage() {
1161
+ const [view, problems] = await Promise.all([askPage("view"), askPage("problems")]);
1162
+ if (!isObj(view)) return null;
1163
+ return {
1164
+ outline: typeof view.outline === "string" ? view.outline : "",
1165
+ problems: Array.isArray(problems) ? problems.filter((p) => typeof p === "string").slice(0, 40) : []
1166
+ };
1167
+ }
1168
+ Object.defineProperty(window, "__openArtifactsLook", { value: () => session?.snapshot ? lookAtPage() : Promise.resolve(null) });
975
1169
  function runAction(id) {
976
1170
  if (typeof id !== "string") return;
977
1171
  const action = chrome.snapshot?.actions?.find((a) => a.id === id);
@@ -1025,6 +1219,7 @@
1025
1219
  exports: exportItems().length > 0,
1026
1220
  ...snapshotChrome(snap)
1027
1221
  };
1222
+ if (shellPrints()) report.formats = [{ format: SHELL_PRINT }];
1028
1223
  toOuter({ openArtifacts: "chrome_report", protocol: CHROME_PROTOCOL, report });
1029
1224
  }
1030
1225
  function fromOuter(m) {
@@ -1044,6 +1239,8 @@
1044
1239
  return permissionAsks.get(String(m.id))?.(state);
1045
1240
  }
1046
1241
  if (m.openArtifacts === "sample_ev") return shellAnswers.get(String(m.id))?.(m.ev);
1242
+ if (m.openArtifacts === "translate") return toPage({ __ft_cmd: { action: m.action, target: m.target, engineHost: m.engineHost === true } });
1243
+ if (m.openArtifacts === "translate_text_r") return toPage({ __ft_xlr: { id: m.id, texts: m.texts, error: m.error } });
1047
1244
  if (m.openArtifacts !== "chrome_cmd") return;
1048
1245
  const c = m;
1049
1246
  if (c.cmd === "comments_mode") setMode(c.on ?? !comments.on);
@@ -1312,8 +1509,7 @@
1312
1509
  const r = await asked;
1313
1510
  const reply = boundedCommentText(r?.reply, 500);
1314
1511
  if (r?.handled === true) return { status: "handled", ...reply && { reply } };
1315
- const handoffNote = boundedCommentText(r?.handoffNote, 2e3);
1316
- const out = await cap("comments", "sendToAgent", { ...a, handoffNote }, own);
1512
+ const out = await cap("comments", "sendToAgent", a, own);
1317
1513
  void refreshThreads();
1318
1514
  return reply ? { ...out, reply } : out;
1319
1515
  }
@@ -1375,6 +1571,10 @@
1375
1571
  };
1376
1572
  document.addEventListener("keydown", (ev) => {
1377
1573
  if (ev.key === "Escape") onEscape();
1574
+ else if (session?.comments?.available && !document.fullscreenElement && isCommentShortcut(ev)) {
1575
+ ev.preventDefault();
1576
+ if (!ev.repeat) toggleCommentsByKey(false);
1577
+ }
1378
1578
  });
1379
1579
  document.addEventListener("visibilitychange", () => toPage({ __frame_host_visible: { visible: hostVisible() } }));
1380
1580
  matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => toPage({ __frame_theme: { theme: theme() } }));