@reason-machines/cli-linux-x64 0.2.558 → 0.2.560

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 (154) hide show
  1. package/bin/reason +2 -2
  2. package/bin/vm-hands/agent-network-j5f603sy.js +2 -0
  3. package/bin/vm-hands/api-credentials-7rhpwe7n.js +2 -0
  4. package/bin/vm-hands/api-vkgf7wma.js +2 -0
  5. package/bin/vm-hands/ask-relay-2vf6fa2t.js +5 -0
  6. package/bin/vm-hands/connect-cli-06x1wfgv.js +2 -0
  7. package/bin/vm-hands/credentials-s7ps7y6s.js +2 -0
  8. package/bin/vm-hands/custom-endpoint-device-3xnrp33e.js +2 -0
  9. package/bin/vm-hands/desktop-account-eg8thn79.js +2 -0
  10. package/bin/vm-hands/device-workspace-h5rsecq8.js +2 -0
  11. package/bin/vm-hands/{fsevents-fev1pxw2.js → fsevents-vxv56sp5.js} +1 -1
  12. package/bin/vm-hands/hands-worker-source-vk664w8p.js +2 -0
  13. package/bin/vm-hands/{index-j6wffzfd.js → index-03p9c17x.js} +106 -106
  14. package/bin/vm-hands/install-receipt-j04hdw1k.js +2 -0
  15. package/bin/vm-hands/local-automation-8b1znx0p.js +2 -0
  16. package/bin/vm-hands/local-capabilities-m6pzcc94.js +2 -0
  17. package/bin/vm-hands/local-desktop-users-sq4trh07.js +2 -0
  18. package/bin/vm-hands/local-display-mac-yxcxvg2z.js +2 -0
  19. package/bin/vm-hands/local-display-session-zyd8s6n6.js +2 -0
  20. package/bin/vm-hands/local-display-video-rk680vwg.js +2 -0
  21. package/bin/vm-hands/local-managed-process-w26jhyfg.js +2 -0
  22. package/bin/vm-hands/local-pty-session-edd8ttf9.js +2 -0
  23. package/bin/vm-hands/managed-runtime-ykv5nyva.js +2 -0
  24. package/bin/vm-hands/network-auto-update-mrjz964a.js +3 -0
  25. package/bin/vm-hands/network-contract-8mxtma3w.js +2 -0
  26. package/bin/vm-hands/network-sign-in-8yvdx5rm.js +3 -0
  27. package/bin/vm-hands/package-vwvzjtn0.js +2 -0
  28. package/bin/vm-hands/permissions-nmxr8238.js +2 -0
  29. package/bin/vm-hands/reason-hands-protocol-1nkpw1v3.js +2 -0
  30. package/bin/vm-hands/serve-service-det934tz.js +2 -0
  31. package/bin/vm-hands/status-fr7192eh.js +96 -0
  32. package/bin/vm-hands/version-5d6gbmrd.js +2 -0
  33. package/bin/vm-hands/vm-hands-entry-lite-0as6nsks.js +3 -0
  34. package/bin/vm-hands/vm-hands-entry-lite-0ex2twm5.js +4 -0
  35. package/bin/vm-hands/vm-hands-entry-lite-0wb1n769.js +9 -0
  36. package/bin/vm-hands/{vm-hands-entry-lite-a3p6xz53.js → vm-hands-entry-lite-2rgf8866.js} +2 -2
  37. package/bin/vm-hands/vm-hands-entry-lite-4jgykvd3.js +2 -0
  38. package/bin/vm-hands/vm-hands-entry-lite-52qz0n30.js +7 -0
  39. package/bin/vm-hands/vm-hands-entry-lite-57ajjwmh.js +2 -0
  40. package/bin/vm-hands/vm-hands-entry-lite-71ebge0c.js +42 -0
  41. package/bin/vm-hands/vm-hands-entry-lite-84mc1f7h.js +3 -0
  42. package/bin/vm-hands/vm-hands-entry-lite-8pcs85ak.js +105 -0
  43. package/bin/vm-hands/vm-hands-entry-lite-8w0ah5j9.js +11 -0
  44. package/bin/vm-hands/vm-hands-entry-lite-8xv6c0rm.js +3 -0
  45. package/bin/vm-hands/vm-hands-entry-lite-9g52kxyj.js +3 -0
  46. package/bin/vm-hands/vm-hands-entry-lite-a6ss0ges.js +3 -0
  47. package/bin/vm-hands/vm-hands-entry-lite-a7bf7xr7.js +5 -0
  48. package/bin/vm-hands/vm-hands-entry-lite-ab1pq3xg.js +3 -0
  49. package/bin/vm-hands/vm-hands-entry-lite-bnpdn6fw.js +127 -0
  50. package/bin/vm-hands/vm-hands-entry-lite-cspd38hc.js +539 -0
  51. package/bin/vm-hands/{vm-hands-entry-lite-q1yvw4xz.js → vm-hands-entry-lite-e3fn8ys2.js} +2 -2
  52. package/bin/vm-hands/vm-hands-entry-lite-f8p11q6h.js +452 -0
  53. package/bin/vm-hands/{vm-hands-entry-lite-qzkxtymm.js → vm-hands-entry-lite-f95mg81d.js} +2 -2
  54. package/bin/vm-hands/vm-hands-entry-lite-fhx46jny.js +10 -0
  55. package/bin/vm-hands/{vm-hands-entry-lite-wptbvtg0.js → vm-hands-entry-lite-fk2s50nc.js} +5 -5
  56. package/bin/vm-hands/vm-hands-entry-lite-hjjbjpd7.js +4 -0
  57. package/bin/vm-hands/vm-hands-entry-lite-hs6sdn60.js +3 -0
  58. package/bin/vm-hands/vm-hands-entry-lite-hxfxs7r9.js +3 -0
  59. package/bin/vm-hands/{vm-hands-entry-lite-2v4zh9ze.js → vm-hands-entry-lite-j10cw3d9.js} +9 -9
  60. package/bin/vm-hands/{vm-hands-entry-lite-rdnm87zp.js → vm-hands-entry-lite-jhsa4av7.js} +2 -2
  61. package/bin/vm-hands/vm-hands-entry-lite-jpvmkce5.js +2 -0
  62. package/bin/vm-hands/vm-hands-entry-lite-k5ytpgzz.js +65 -0
  63. package/bin/vm-hands/{vm-hands-entry-lite-s85p7tqp.js → vm-hands-entry-lite-krpqqx12.js} +2 -2
  64. package/bin/vm-hands/{vm-hands-entry-lite-q2h781jg.js → vm-hands-entry-lite-ms99mzp0.js} +3 -3
  65. package/bin/vm-hands/vm-hands-entry-lite-nn6zcvmp.js +3 -0
  66. package/bin/vm-hands/{vm-hands-entry-lite-46pwqvpf.js → vm-hands-entry-lite-ptycjmkc.js} +2 -2
  67. package/bin/vm-hands/vm-hands-entry-lite-pxtycfdv.js +5 -0
  68. package/bin/vm-hands/vm-hands-entry-lite-q3er9m6y.js +9 -0
  69. package/bin/vm-hands/vm-hands-entry-lite-q9djb28r.js +4 -0
  70. package/bin/vm-hands/vm-hands-entry-lite-q9s1e2y1.js +3 -0
  71. package/bin/vm-hands/vm-hands-entry-lite-qegwyvyz.js +3 -0
  72. package/bin/vm-hands/{vm-hands-entry-lite-pzj5s203.js → vm-hands-entry-lite-qf990rxw.js} +2 -2
  73. package/bin/vm-hands/vm-hands-entry-lite-rhx6adbr.js +52 -0
  74. package/bin/vm-hands/vm-hands-entry-lite-sy7dcccg.js +2 -0
  75. package/bin/vm-hands/vm-hands-entry-lite-tcmye5ny.js +3 -0
  76. package/bin/vm-hands/vm-hands-entry-lite-tvnfm4xg.js +150 -0
  77. package/bin/vm-hands/{vm-hands-entry-lite-1yv5qqew.js → vm-hands-entry-lite-v4hr9x9h.js} +45 -45
  78. package/bin/vm-hands/vm-hands-entry-lite-vdv4nm5f.js +3 -0
  79. package/bin/vm-hands/vm-hands-entry-lite-weqam12f.js +6 -0
  80. package/bin/vm-hands/vm-hands-entry-lite-y4df9n3f.js +345 -0
  81. package/bin/vm-hands/vm-hands-entry-lite-yvws5zpx.js +4 -0
  82. package/bin/vm-hands/{vm-hands-entry-lite-qd46yhvz.js → vm-hands-entry-lite-z0ht62s4.js} +3 -3
  83. package/bin/vm-hands/vm-hands-entry-lite-zawytz09.js +3 -0
  84. package/bin/vm-hands/{vm-hands-entry-lite-h2rq71rj.js → vm-hands-entry-lite-zh6ncdjn.js} +2 -2
  85. package/bin/vm-hands/vm-hands-entry-lite.js +2 -2
  86. package/bin/vm-hands/{vm-hands-executor-a6c1j3gp.js → vm-hands-executor-qny3mx8f.js} +8 -8
  87. package/bin/vm-hands/vm-hands-op-runner-5q01rhkc.js +2 -0
  88. package/bin/vm-hands/{vm-hands-runtime-t5e8a0mn.js → vm-hands-runtime-gjjm5fzd.js} +3 -3
  89. package/bin/vm-hands/worker-preview-readiness-06tygyjs.js +2 -0
  90. package/bin/vm-hands/worker-sandbox-e1cpkzfz.js +2 -0
  91. package/package.json +1 -1
  92. package/bin/vm-hands/api-credentials-ds01769g.js +0 -2
  93. package/bin/vm-hands/api-tfq16a08.js +0 -2
  94. package/bin/vm-hands/connect-cli-ha9vbajx.js +0 -2
  95. package/bin/vm-hands/credentials-sbza33ac.js +0 -2
  96. package/bin/vm-hands/custom-endpoint-device-mydksbg8.js +0 -2
  97. package/bin/vm-hands/desktop-account-t0afsge2.js +0 -2
  98. package/bin/vm-hands/device-workspace-b534qy2c.js +0 -2
  99. package/bin/vm-hands/hands-worker-source-qj7s9dk5.js +0 -2
  100. package/bin/vm-hands/install-receipt-zv1bjbgh.js +0 -2
  101. package/bin/vm-hands/local-automation-29f2yk7r.js +0 -2
  102. package/bin/vm-hands/local-capabilities-1x36d69w.js +0 -2
  103. package/bin/vm-hands/local-desktop-users-5scb9930.js +0 -2
  104. package/bin/vm-hands/local-display-mac-pft73te9.js +0 -2
  105. package/bin/vm-hands/local-display-session-0sbtewn9.js +0 -2
  106. package/bin/vm-hands/local-display-video-vtd5xa7h.js +0 -2
  107. package/bin/vm-hands/local-managed-process-jz8h33nx.js +0 -2
  108. package/bin/vm-hands/local-pty-session-njd0tprg.js +0 -2
  109. package/bin/vm-hands/managed-runtime-c843ftzx.js +0 -2
  110. package/bin/vm-hands/network-contract-kx0hz3wt.js +0 -2
  111. package/bin/vm-hands/package-way7qesn.js +0 -2
  112. package/bin/vm-hands/permissions-qyfv0m6a.js +0 -2
  113. package/bin/vm-hands/reason-hands-protocol-g54rtrhd.js +0 -2
  114. package/bin/vm-hands/serve-service-fjr8vj0t.js +0 -2
  115. package/bin/vm-hands/status-yfp1ayay.js +0 -10
  116. package/bin/vm-hands/version-f3kptj80.js +0 -2
  117. package/bin/vm-hands/vm-hands-entry-lite-04x5xjt6.js +0 -5
  118. package/bin/vm-hands/vm-hands-entry-lite-07apxfh8.js +0 -42
  119. package/bin/vm-hands/vm-hands-entry-lite-0wsr8edk.js +0 -3
  120. package/bin/vm-hands/vm-hands-entry-lite-1bbt37sr.js +0 -452
  121. package/bin/vm-hands/vm-hands-entry-lite-3gbf905c.js +0 -3
  122. package/bin/vm-hands/vm-hands-entry-lite-46zcjqas.js +0 -2
  123. package/bin/vm-hands/vm-hands-entry-lite-48rphbjm.js +0 -3
  124. package/bin/vm-hands/vm-hands-entry-lite-4anjdcth.js +0 -3
  125. package/bin/vm-hands/vm-hands-entry-lite-4rystkgj.js +0 -14
  126. package/bin/vm-hands/vm-hands-entry-lite-6dk00ch5.js +0 -150
  127. package/bin/vm-hands/vm-hands-entry-lite-73f4cgkf.js +0 -3
  128. package/bin/vm-hands/vm-hands-entry-lite-7cmf6428.js +0 -3
  129. package/bin/vm-hands/vm-hands-entry-lite-8dfw96ym.js +0 -3
  130. package/bin/vm-hands/vm-hands-entry-lite-97agw762.js +0 -5
  131. package/bin/vm-hands/vm-hands-entry-lite-ak0hd94p.js +0 -7
  132. package/bin/vm-hands/vm-hands-entry-lite-bpamn7ny.js +0 -9
  133. package/bin/vm-hands/vm-hands-entry-lite-cmfzxk3d.js +0 -126
  134. package/bin/vm-hands/vm-hands-entry-lite-dgfx0rbn.js +0 -5
  135. package/bin/vm-hands/vm-hands-entry-lite-efsp2wfz.js +0 -539
  136. package/bin/vm-hands/vm-hands-entry-lite-fs0bsr5q.js +0 -52
  137. package/bin/vm-hands/vm-hands-entry-lite-fxzadxz4.js +0 -2
  138. package/bin/vm-hands/vm-hands-entry-lite-gje7xvy9.js +0 -6
  139. package/bin/vm-hands/vm-hands-entry-lite-h1qjggz0.js +0 -4
  140. package/bin/vm-hands/vm-hands-entry-lite-n7bd44rm.js +0 -2
  141. package/bin/vm-hands/vm-hands-entry-lite-ny6w4vgq.js +0 -4
  142. package/bin/vm-hands/vm-hands-entry-lite-ravxhygk.js +0 -3
  143. package/bin/vm-hands/vm-hands-entry-lite-tf0qzc0a.js +0 -9
  144. package/bin/vm-hands/vm-hands-entry-lite-tyem93c1.js +0 -3
  145. package/bin/vm-hands/vm-hands-entry-lite-vj7xzb3y.js +0 -2
  146. package/bin/vm-hands/vm-hands-entry-lite-wf26hjeh.js +0 -105
  147. package/bin/vm-hands/vm-hands-entry-lite-wghmyfba.js +0 -4
  148. package/bin/vm-hands/vm-hands-entry-lite-wzv13c8k.js +0 -65
  149. package/bin/vm-hands/vm-hands-entry-lite-yptpy066.js +0 -3
  150. package/bin/vm-hands/vm-hands-entry-lite-yretc2th.js +0 -3
  151. package/bin/vm-hands/vm-hands-entry-lite-z6znx10m.js +0 -2
  152. package/bin/vm-hands/vm-hands-op-runner-g81p656v.js +0 -2
  153. package/bin/vm-hands/worker-preview-readiness-gy36ejp9.js +0 -2
  154. package/bin/vm-hands/worker-sandbox-f1tfb3y0.js +0 -2
@@ -0,0 +1,127 @@
1
+ // @bun
2
+ import{O,Rn,ns,Xt,is,os}from"./vm-hands-entry-lite-j10cw3d9.js";import{ls}from"./vm-hands-entry-lite-q3er9m6y.js";import{Ko}from"./vm-hands-entry-lite-q9djb28r.js";import{s}from"./vm-hands-entry-lite-zawytz09.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFile as _s,spawn as qe}from"child_process";import{existsSync as ks}from"fs";import{connect as vs}from"net";function gn(){let e=new Set,t=null,n=(i)=>({holder:t?.viewer??null,you:t===i,same_user:Boolean(t?.viewer&&i.viewer&&t.viewer.user_id===i.viewer.user_id)}),o=()=>{for(let i of e)i.notify(n(i))};return{join(i){return e.add(i),i.notify(n(i)),()=>{if(!e.delete(i))return;if(t!==i)return;t=null,o()}},claim(i){if(t===i||!e.has(i))return;t=i,o()}}}var ut=gn();import{createHash as vt}from"crypto";import{once as Pn}from"events";import{createWriteStream as Cn,existsSync as Mn,mkdirSync as Tn,mkdtempSync as hr,readFileSync as de,readdirSync as br,renameSync as On,realpathSync as An,rmSync as $n,statSync as Ue,writeFileSync as Ln}from"fs";import{delimiter as wr,dirname as Be,join as y}from"path";import{finished as Nn}from"stream/promises";var Gt="omljlfpmafedpplnpkkahegadhkimdje",lc="https://chromewebstore.google.com/detail/reason/omljlfpmafedpplnpkkahegadhkimdje";var A={ocu:{repository:"https://github.com/iFurySt/open-codex-computer-use.git",revision:"386a260d1ab8b690adbbb27f7471595cf0c2b752",version:"0.3.5"},obu:{repository:"https://github.com/iFurySt/open-browser-use.git",revision:"ac015846df75928fbcf0f3a0f3ba3a210ce1a507",version:"0.1.42"}},F={version:"155.0.8059.84",macArm64Sha256:"13b9e98ce56f5ce18e100a009f455c9285f399e7c9dc8a76fdf2f3a9755bb5f2",linux64Sha256:"cf0f049892dea22e6a6db26d47ed0d7776b7158edcbec4634086633df8bafcbc",win64Sha256:"507f2a031441d10c62b5e3d4e863f09ac1198a571c1419976cbd8387f639afde"};var J={ocu:{url:`https://registry.npmjs.org/open-computer-use/-/open-computer-use-${A.ocu.version}.tgz`,sha256:"7c16a87c8cd357787b02c0ebd040dd5f93880c1fb51c1901caa2e0c05d063130",size_bytes:5844280},obu:{url:`https://registry.npmjs.org/open-browser-use/-/open-browser-use-${A.obu.version}.tgz`,sha256:"9386d8ce0a147b3f55e1807b68edf736836378807541c457c9b5f6ca2cabaa4e",size_bytes:21372018},extension:{url:`https://github.com/iFurySt/open-browser-use/releases/download/v${A.obu.version}/open-browser-use-chrome-extension-${A.obu.version}.zip`,sha256:"c9c07bec1175e12ea6985b0e7784a5ef01fd03f014b958224a1e17dcd838a241",size_bytes:31070}},le="pnbmoicbkopffjjgfgfglopechaiemkp";import{spawn as Te}from"child_process";import{createRequire as hn}from"module";import{join as bn}from"path";var xn=30000,_n=1048576;function Oe(){return process.env.SystemRoot??"C:\\Windows"}function kn(){return bn(Oe(),"System32","WindowsPowerShell","v1.0","powershell.exe")}var vn=String.raw`
3
+ $ErrorActionPreference = "Stop"
4
+ Add-Type -TypeDefinition @"
5
+ using System;
6
+ using System.Runtime.InteropServices;
7
+ public static class ReasonInput {
8
+ [StructLayout(LayoutKind.Sequential)] public struct MOUSEINPUT { public int dx; public int dy; public int mouseData; public uint dwFlags; public uint time; public IntPtr dwExtraInfo; }
9
+ [StructLayout(LayoutKind.Sequential)] public struct KEYBDINPUT { public ushort wVk; public ushort wScan; public uint dwFlags; public uint time; public IntPtr dwExtraInfo; }
10
+ [StructLayout(LayoutKind.Explicit)] public struct UNION { [FieldOffset(0)] public MOUSEINPUT mi; [FieldOffset(0)] public KEYBDINPUT ki; }
11
+ [StructLayout(LayoutKind.Sequential)] public struct INPUT { public uint type; public UNION u; }
12
+ [DllImport("user32.dll")] static extern uint SendInput(uint count, INPUT[] inputs, int size);
13
+ [DllImport("user32.dll")] public static extern bool SetProcessDPIAware();
14
+ [DllImport("user32.dll")] public static extern int GetSystemMetrics(int index);
15
+ [DllImport("user32.dll")] static extern uint MapVirtualKey(uint code, uint type);
16
+ [DllImport("user32.dll")] public static extern uint GetClipboardSequenceNumber();
17
+ static void Send(INPUT input) { SendInput(1, new INPUT[] { input }, Marshal.SizeOf(typeof(INPUT))); }
18
+ public static void Mouse(uint flags, int x, int y, int data) {
19
+ INPUT input = new INPUT(); input.type = 0;
20
+ input.u.mi.dx = x; input.u.mi.dy = y; input.u.mi.mouseData = data; input.u.mi.dwFlags = flags; Send(input);
21
+ }
22
+ public static void Key(ushort vk, ushort unit, uint flags) {
23
+ INPUT input = new INPUT(); input.type = 1;
24
+ input.u.ki.wVk = vk; input.u.ki.wScan = vk != 0 ? (ushort)MapVirtualKey(vk, 0) : unit; input.u.ki.dwFlags = flags; Send(input);
25
+ }
26
+ }
27
+ "@
28
+ [void][ReasonInput]::SetProcessDPIAware()
29
+ $width = [ReasonInput]::GetSystemMetrics(0)
30
+ $height = [ReasonInput]::GetSystemMetrics(1)
31
+ $session = [Diagnostics.Process]::GetCurrentProcess().SessionId
32
+ [Console]::Out.WriteLine('{"session":' + $session + ',"width":' + $width + ',"height":' + $height + '}')
33
+ [Console]::Out.Flush()
34
+ $mode = "__MODE__"
35
+ if ($mode -eq "probe") { exit 0 }
36
+ if ($mode -eq "clipboard") {
37
+ # Only changes made during this pairing: never export the initial clipboard.
38
+ $parent = Get-Process -Id __PARENT__
39
+ $last = [ReasonInput]::GetClipboardSequenceNumber()
40
+ while (-not $parent.HasExited) {
41
+ Start-Sleep -Milliseconds 100
42
+ $count = [ReasonInput]::GetClipboardSequenceNumber()
43
+ if ($count -eq $last) { continue }
44
+ $last = $count
45
+ try { $text = Get-Clipboard -Raw } catch { continue }
46
+ if (-not $text) { continue }
47
+ $bytes = [Text.Encoding]::UTF8.GetBytes($text)
48
+ if ($bytes.Length -gt __MAX_TEXT_BYTES__) { continue }
49
+ [Console]::Out.WriteLine("c " + [Convert]::ToBase64String($bytes))
50
+ [Console]::Out.Flush()
51
+ }
52
+ exit 0
53
+ }
54
+ $scaleX = 65535.0 / [Math]::Max(1, $width - 1)
55
+ $scaleY = 65535.0 / [Math]::Max(1, $height - 1)
56
+ while ($null -ne ($line = [Console]::In.ReadLine())) {
57
+ $n = $line.Split(" ")
58
+ try {
59
+ switch ($n[0]) {
60
+ "p" { [ReasonInput]::Mouse(0x8001, [int]([int]$n[1] * $scaleX), [int]([int]$n[2] * $scaleY), 0) }
61
+ "b" { [ReasonInput]::Mouse([uint32]$n[1], 0, 0, [int]$n[2]) }
62
+ "k" { [ReasonInput]::Key([uint16]$n[1], [uint16]$n[2], [uint32]$n[3]) }
63
+ "c" { Set-Clipboard -Value ([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($n[1]))) }
64
+ }
65
+ } catch { [Console]::Error.WriteLine("input: $_") }
66
+ }
67
+ `;function Ae(e){let t=vn.replace("__MODE__",e).replace("__PARENT__",String(process.pid)).replace("__MAX_TEXT_BYTES__",String(O));return[kn(),["-NoLogo","-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",Buffer.from(t,"utf16le").toString("base64")]]}var Sn=["USERPROFILE","LOCALAPPDATA","APPDATA","TEMP","TMP","PSModuleAnalysisCachePath"];function $e(){let e=Sn.flatMap((t)=>process.env[t]?[[t,process.env[t]]]:[]);return{...Object.fromEntries(e),SystemRoot:Oe(),windir:Oe()}}function ht(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=="object")return null;let n=t,o=(i,a)=>typeof i==="number"&&Number.isSafeInteger(i)&&i>=a;return o(n.session,0)&&o(n.width,1)&&o(n.height,1)?{session:n.session,width:n.width,height:n.height}:null}function bt(){return new Promise((e)=>{let t=Te(...Ae("probe"),{env:$e(),stdio:["ignore","pipe","ignore"],windowsHide:!0}),n="",o=setTimeout(()=>{t.kill("SIGKILL"),e(null)},xn);t.stdout.setEncoding("utf8").on("data",(i)=>{n+=i}),t.once("error",()=>{clearTimeout(o),e(null)}),t.once("close",()=>{clearTimeout(o),e(ht(n.split(/\r?\n/)[0]??""))})})}var Z;function yt(){if(Z!==void 0)return Z;if(process.platform!=="win32")return Z=!1;try{let e=hn(import.meta.url)("bun:ffi"),{symbols:t}=e.dlopen("kernel32.dll",{GetCurrentProcessId:{args:[],returns:e.FFIType.u32},ProcessIdToSessionId:{args:[e.FFIType.u32,e.FFIType.ptr],returns:e.FFIType.i32}}),n=new Uint32Array(1);return Z=t.ProcessIdToSessionId(t.GetCurrentProcessId(),n)!==0&&n[0]>0}catch{return Z=!1}}var lt=[{bit:1,down:2,up:4},{bit:2,down:32,up:64},{bit:4,down:8,up:16}],dt=2048,pt=4096,En=[[8,dt,120],[16,dt,-120],[32,pt,-120],[64,pt,120]],ft=1,Me=2,Dn=4,In=new Set([65505,65506]),mt=new Set([65507,65508,65511,65512,65513,65514,65027,65515,65516]),gt=new Map([[65505,[160,!1]],[65506,[161,!1]],[65507,[162,!1]],[65508,[163,!0]],[65511,[164,!1]],[65512,[165,!0]],[65513,[164,!1]],[65514,[165,!0]],[65027,[165,!0]],[65515,[91,!0]],[65516,[92,!0]],[65288,[8,!1]],[65289,[9,!1]],[65056,[9,!1]],[65293,[13,!1]],[65307,[27,!1]],[65535,[46,!0]],[65379,[45,!0]],[65360,[36,!0]],[65367,[35,!0]],[65365,[33,!0]],[65366,[34,!0]],[65361,[37,!0]],[65362,[38,!0]],[65363,[39,!0]],[65364,[40,!0]],[65383,[93,!0]],[65509,[20,!1]],[65299,[19,!1]],[65300,[145,!1]],[65377,[44,!0]],[65407,[144,!0]],[32,[32,!1]],[65421,[13,!0]],[65408,[32,!1]],[65450,[106,!1]],[65451,[107,!1]],[65452,[108,!1]],[65453,[109,!1]],[65454,[110,!1]],[65455,[111,!0]],[65429,[36,!1]],[65430,[37,!1]],[65431,[38,!1]],[65432,[39,!1]],[65433,[40,!1]],[65434,[33,!1]],[65435,[34,!1]],[65436,[35,!1]],[65438,[45,!1]],[65439,[46,!1]],...Array.from({length:10},(e,t)=>[65456+t,[96+t,!1]]),...Array.from({length:24},(e,t)=>[65470+t,[112+t,!1]])]);class wt{x=-1;y=-1;mask=0;held=new Set;pressed=new Set;pointer(e,t,n){let o=[];if(e!==this.x||t!==this.y)this.x=e,this.y=t,o.push(`p ${e} ${t}`);for(let i of lt){let a=(this.mask&i.bit)!==0,c=(n&i.bit)!==0;if(a!==c)o.push(`b ${c?i.down:i.up} 0`)}for(let[i,a,c]of En)if(!(this.mask&i)&&n&i)o.push(`b ${a} ${c}`);return this.mask=n,o}key(e,t){let n=e?0:Me;if(In.has(t)||mt.has(t))if(e)this.held.add(t);else this.held.delete(t);let o=gt.get(t);if(o)return[`k ${o[0]} 0 ${n|(o[1]?ft:0)}`];let i=t<256?t:(t&4278190080)===16777216?t&16777215:0,a=String.fromCharCode(i),c=[...this.held].some((w)=>mt.has(w)),p=/^[A-Za-z0-9]$/.test(a)?a.toUpperCase().charCodeAt(0):0;if(p&&(e?c:this.pressed.has(p))){if(e)this.pressed.add(p);else this.pressed.delete(p);return[`k ${p} 0 ${n}`]}if(i<33||i>=127&&i<160||i>65535||i>=55296&&i<57344)return[];return[`k 0 ${i} ${n|Dn}`]}release(){let e=lt.filter((t)=>this.mask&t.bit).map((t)=>`b ${t.up} 0`);for(let t of this.pressed)e.push(`k ${t} 0 ${Me}`);for(let t of this.held){let[n,o]=gt.get(t);e.push(`k ${n} 0 ${Me|(o?ft:0)}`)}return this.mask=0,this.pressed.clear(),this.held.clear(),e}}function xt(e){let t=Te(...Ae("input"),{env:$e(),stdio:["pipe","pipe","ignore"],windowsHide:!0}),n=new wt,o="",i=!1,a=null,c=()=>{if(a?.kill("SIGKILL"),t.exitCode!==null||t.signalCode!==null)return;t.stdin.end(n.release().map((f)=>`${f}
68
+ `).join("")),setTimeout(()=>t.kill("SIGKILL"),2000).unref()},p=(f)=>{if(i)return;i=!0,c(),e.end(f)},w=(f)=>p({error:new r("display_unavailable",f)}),b=(f)=>{if(i||f.length===0)return;if(t.stdin.write(f.map((x)=>`${x}
69
+ `).join("")),t.stdin.writableLength>_n)p({reason:"input_backpressure"})},h=()=>{a=Te(...Ae("clipboard"),{env:$e(),stdio:["ignore","pipe","ignore"],windowsHide:!0});let f="";a.stdout?.on("data",(x)=>{if(i)return;f+=x.toString("ascii");for(let m=f.indexOf(`
70
+ `);m>=0;m=f.indexOf(`
71
+ `)){let R=f.slice(0,m).replace(/\r$/,"");if(f=f.slice(m+1),!R.startsWith("c "))continue;let S=R.slice(2);if(S.length>Math.ceil(O/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(S)){p({reason:"display_protocol"});return}let u=Buffer.from(S,"base64");if(u.byteLength<=O)e.clipboard(u.toString("utf8"));if(i)return}if(f.length>Math.ceil(O/3)*4+4)p({reason:"display_protocol"})}),a.once("error",()=>w("Reason could not watch this computer's desktop clipboard.")),a.once("exit",()=>{if(!i)w("Reason could not watch this computer's desktop clipboard.")})};return t.stdout.on("data",(f)=>{if(i||o===null)return;o+=f.toString("utf8");let x=o.indexOf(`
72
+ `);if(x<0){if(o.length>4096)p({reason:"display_protocol"});return}let m=ht(o.slice(0,x).trim());if(o=null,!m)p({reason:"display_protocol"});else if(m.session===0)w("This Windows worker runs as a service, which has no desktop: run it in the signed-in desktop session.");else h(),e.ready({width:m.width,height:m.height})}),t.stdin.on("error",()=>{return}),t.once("error",()=>w("Reason could not start this computer's desktop input.")),t.once("exit",()=>{if(o!==null)w("Reason could not start this computer's desktop input.");else p({reason:"display_closed"})}),{pointer:(f,x,m)=>b(n.pointer(f,x,m)),key:(f,x)=>b(n.key(f,x)),clipboard:(f)=>b([`c ${Buffer.from(f,"utf8").toString("base64")}`]),close(){i=!0,c()}}}var Un=["none","standard","all"],ue="22.23.4",Bn={"linux-x64":"b8492284c76a54baf58d61668dd0e41ee0fc98adabf9503d30f05d08f55b4406","linux-arm64":"f7a1e486dbc8b286847815b477d4fb5e9fb963ed4489c3e1588853d685f589f9","darwin-arm64":"c9e1dbc748b33ed2d14f42445191ecaf14c56259c7a9a26d0042c49ec2b66428","win32-x64":"cbc74b5e0982c9dbb41525fd8fb5dcd32fbee237863f7829072f4639a1ce5f20","win32-arm64":"a8b8cd79cbbb3062435f449591d98dd63730bbbf30ce2d7cc3a6376c236cb111"},Le={"linux-x64":{ocu:"dist/linux/amd64/open-computer-use",obu:"native/linux-amd64/open-browser-use"},"linux-arm64":{ocu:"dist/linux/arm64/open-computer-use",obu:"native/linux-arm64/open-browser-use"},"darwin-arm64":{ocu:"dist/Open Computer Use.app/Contents/MacOS/OpenComputerUse",obu:"native/darwin-arm64/open-browser-use"},"win32-x64":{ocu:"dist/windows/amd64/open-computer-use.exe",obu:"native/windows-amd64/open-browser-use.exe"},"win32-arm64":{ocu:"dist/windows/arm64/open-computer-use.exe",obu:"native/windows-arm64/open-browser-use.exe"}},St="chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing",Et="chrome-win64/chrome.exe",W={version:"9.0.2",url:"https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffmpeg.zip",sha256:"c8ed4c4e6978a03c485edbfe4e0a5dc2380f8a30bba5150531b31b094492d924"},Hn={version:W.version,url:"https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffprobe.zip",sha256:"fcbe839537485eaee7a7a8bc5cbc0f90d53617e80943e8a5b2e31cb851197ea6"},Ne={version:W.version,url:`https://github.com/GyanD/codexffmpeg/releases/download/${W.version}/ffmpeg-${W.version}-essentials_build.zip`,sha256:"60f467265b1e312373dbcd92200c2618a74850f98d3d078e94296bb3fa2047ba"},_t=`ffmpeg-${Ne.version}-essentials_build/bin`,z="com.ifuryst.open_browser_use.extension",Dt="com.reasonmachines.browser_use.extension",yn="/tmp/reason-browser-use",He=["tint2","picom","xterm","pcmanfm"],It=["fonts-droid-fallback"],Pt=["pulseaudio"],Ct=["tigervnc-standalone-server"],Fn=["xvfb","openbox","x11vnc","x11-utils","x11-xserver-utils","xdotool","dbus-x11","at-spi2-core","python3","python3-gi","gir1.2-atspi-2.0","gir1.2-gtk-3.0","fonts-dejavu-core",...It,"galculator","chromium","ffmpeg","tmux",...Pt,...Ct,...He],zn=new Set([...He,...It,...Pt,...Ct]),kt=Fn.filter((e)=>e!=="chromium"&&!zn.has(e)),jn=["Xvfb","openbox","x11vnc","xdotool","dbus-launch","python3","ffmpeg","tmux"],ce="/usr/bin/chromium",Vn=["/usr/local/bin","/usr/bin","/bin","/opt/homebrew/bin"];function Rt(e=process.platform,t=process.arch){let n=`${e}-${t}`;return n==="linux-x64"||n==="linux-arm64"||n==="darwin-arm64"||n==="win32-x64"||n==="win32-arm64"?n:null}function K(e){return e==="win32-x64"||e==="win32-arm64"}function Fe(e){return K(e)?`node-v${ue}-${e.replace("win32","win")}`:`node-v${ue}-${e}`}function pe(e){return{node:{version:ue,url:`https://nodejs.org/dist/v${ue}/${Fe(e)}${K(e)?".zip":".tar.gz"}`,sha256:Bn[e]},open_computer_use:{version:A.ocu.version,url:J.ocu.url,sha256:J.ocu.sha256},open_browser_use:{version:A.obu.version,url:J.obu.url,sha256:J.obu.sha256},...e==="darwin-arm64"?{chrome_for_testing:{version:F.version,url:`https://storage.googleapis.com/chrome-for-testing-public/${F.version}/mac-arm64/chrome-mac-arm64.zip`,sha256:F.macArm64Sha256}}:K(e)?{chrome_for_testing:{version:F.version,url:`https://storage.googleapis.com/chrome-for-testing-public/${F.version}/win64/chrome-win64.zip`,sha256:F.win64Sha256}}:{}}}function Gn(e){let t={extension:le};for(let[n,o]of Object.entries(pe(e)))t[n]=`${o.version}@${o.sha256}`;return t}function Mt(e){return y(e,".local","share","reason","desktop")}function wn(e,t=Ko()){let n=Mt(t),o=(f)=>y(n,f,pe(e)[f]?.version??""),i=o("open_computer_use"),a=o("open_browser_use"),c=e==="darwin-arm64",p=K(e),w=y(t,"Library","Application Support"),b=y(process.platform==="win32"&&process.env.LOCALAPPDATA?process.env.LOCALAPPDATA:y(t,"AppData","Local"),"OpenBrowserUse"),h=c?y(w,"Google","Chrome","NativeMessagingHosts",`${z}.json`):p?y(b,"NativeMessagingHosts",`${z}.json`):y(t,".config","google-chrome","NativeMessagingHosts",`${z}.json`);return{root:n,automation:y(Be(n),"automation"),receipt:y(n,"receipt.json"),minimal:je(t),node:p?y(o("node"),Fe(e),"node.exe"):y(o("node"),"bin","node"),ocuDir:i,ocu:y(i,Le[e].ocu),ocuApp:c?y(i,"dist","Open Computer Use.app"):null,obuDir:a,obu:y(a,"cli","open-browser-use.js"),nativeHost:y(a,Le[e].obu),extensionDir:c?y(w,"OpenBrowserUse","chrome-extension","release"):p?y(b,"chrome-extension","release"):y(t,".local","share","open-browser-use","chrome-extension","release"),setupNativeHostManifest:h,nativeHostManifests:c?[h,y(w,"Google","ChromeForTesting","NativeMessagingHosts",`${z}.json`)]:p?[h]:[y(t,".config","chromium","NativeMessagingHosts",`${z}.json`),y(t,".config","google-chrome-for-testing","NativeMessagingHosts",`${z}.json`)],browser:c?y(o("chrome_for_testing"),St):p?y(o("chrome_for_testing"),Et):ce,userChromeHost:c?y(n,"user-chrome","reason-browser-use"):null,userChromeRegistration:c?y(w,"Google","Chrome","NativeMessagingHosts",`${Dt}.json`):null,ffmpegDir:y(n,"ffmpeg"),ffmpeg:c?y(n,"ffmpeg",W.version,"ffmpeg"):p?y(n,"ffmpeg",Ne.version,_t,"ffmpeg.exe"):null,ffprobe:c?y(n,"ffprobe",Hn.version,"ffprobe"):p?y(n,"ffmpeg",Ne.version,_t,"ffprobe.exe"):null}}function Tt(e){try{let t=JSON.parse(de(e,"utf8"));if(typeof t!=="object"||t===null)return null;let n=t,o=n.pins;if(n.schema_version!==1||typeof n.platform!=="string"||typeof o!=="object"||o===null||!Object.values(o).every((i)=>typeof i==="string")||!Un.includes(n.permissions)||!Array.isArray(n.missing_system_packages)||!n.missing_system_packages.every((i)=>typeof i==="string")||typeof n.updated_at!=="string")return null;return{schema_version:1,platform:n.platform,pins:o,permissions:n.permissions,missing_system_packages:n.missing_system_packages,updated_at:n.updated_at}}catch{return null}}function Wn(e,t,n=384){Tn(Be(e),{recursive:!0,mode:448});let o=`${e}.pending.${process.pid}`;Ln(o,t,{mode:n}),On(o,e)}function L(e){try{return Ue(e).isFile()}catch{return!1}}function Ot(e){try{let t=Ue(e);return t.isFile()&&(t.mode&73)!==0}catch{return!1}}function Kn(e){try{return de(e,"utf8")}catch{return null}}function B(e){for(let t of Vn){let n=y(t,e);try{let o=Ue(n);if(o.isFile()&&(o.mode&73)!==0)return n}catch{}}return null}function Xn(e){try{let t=JSON.parse(de(y(e,"package.json"),"utf8"));return typeof t==="object"&&t!==null&&typeof t.version==="string"?t.version:null}catch{return null}}function qn(e,t,n){let o=pe(n)[e];if(!o)return!1;let i=K(n);if(e==="node")return L(i?y(t,Fe(n),"node.exe"):y(t,"bin","node"));if(e==="chrome_for_testing")return L(y(t,i?Et:St));let a=Le[n][e==="open_computer_use"?"ocu":"obu"];return Xn(t)===o.version&&L(y(t,a))&&(e==="open_computer_use"||L(y(t,"cli","open-browser-use.js")))}function Yn(e){return vt("sha256").update(Buffer.from(e,"base64")).digest("hex").slice(0,32).replace(/./g,(t)=>String.fromCharCode(97+Number.parseInt(t,16)))}function ze(e){try{let t=JSON.parse(de(e,"utf8"));return typeof t==="object"&&t!==null&&!Array.isArray(t)?t:null}catch{return null}}function Jn(e){let t=ze(y(e.extensionDir,"manifest.json"));return t!==null&&t.version===A.obu.version&&typeof t.key==="string"&&Yn(t.key)===le}function Zn(e,t){let n=e?.allowed_origins;return e!==null&&e.name===z&&Array.isArray(n)&&n.length===1&&n[0]===`chrome-extension://${le}/`&&(t===void 0||e.path===t)}function Qn(e){return Jn(e)&&L(e.nativeHost)&&e.nativeHostManifests.every((t)=>Zn(ze(t),e.nativeHost))}function es(e){return`#!/bin/sh
73
+ # Reason's Chrome extension host (reason desktop install): Open Browser Use on Reason's socket directory.
74
+ obu=${`'${e.replaceAll("'","'\\''")}'`}
75
+ case "$1" in
76
+ chrome-extension://*) exec "$obu" host --socket-dir ${yn} ;;
77
+ mcp) shift; exec "$obu" mcp --socket-dir ${yn} "$@" ;;
78
+ esac
79
+ exec "$obu" "$@"
80
+ `}function ts(e){let t=ze(e),n=t?.allowed_origins;return t!==null&&t.name===Dt&&t.type==="stdio"&&Array.isArray(n)&&n.includes(`chrome-extension://${Gt}/`)&&typeof t.path==="string"&&Ot(t.path)}function ss(e,t){if(!e.userChromeHost||!e.userChromeRegistration)return null;if(!t||Kn(e.userChromeHost)!==es(e.nativeHost)||!Ot(e.userChromeHost))return{code:"user_chrome_browser_use_missing"};return ts(e.userChromeRegistration)?{host:e.userChromeHost}:{code:"user_chrome_native_host_unregistered"}}var rs={display:["display","desktop_session","desktop_video"],computer:["display","desktop_session","system_packages","node","open_computer_use"],browser:["display","desktop_session","system_packages","node","open_computer_use","open_browser_use","browser_extension","browser","chrome_for_testing"]};function T(e={}){let t=e.platform===void 0?Rt():e.platform;if(!t)return null;let n=wn(t,e.home),o=Tt(n.receipt),i=Gn(t),a=o!==null&&o.platform===t&&JSON.stringify(Object.entries(o.pins).sort())===JSON.stringify(Object.entries(i).sort()),c=[],p=pe(t);for(let u of["node","open_computer_use","open_browser_use","chrome_for_testing"]){let _=p[u];if(!_)continue;let v=qn(u,y(n.root,u,_.version),t),E=o?.pins[u],N=v&&E===i[u]?"ready":E!==void 0&&E!==i[u]?"outdated":"missing";c.push({name:u,state:N,detail:_.version})}let w=o?.pins.extension===le&&Qn(n);c.push({name:"browser_extension",state:w?"ready":"missing",detail:le});let b=B("Xvfb"),h=B("x11vnc"),f=B("openbox");if(K(t))c.push(yt()?{name:"desktop_session",state:"ready",detail:"signed-in desktop session"}:{name:"desktop_session",state:"missing",detail:"run the worker in the signed-in desktop session, not as a service"}),c.push(n.ffmpeg&&L(n.ffmpeg)?{name:"desktop_video",state:"ready",detail:n.ffmpeg}:{name:"desktop_video",state:"missing",detail:"run `reason desktop install` for desktop video"});else if(t!=="darwin-arm64"){c.push(L(ce)?{name:"browser",state:"ready",detail:ce}:{name:"browser",state:"missing",detail:`non-snap Chromium at ${ce}`});let u=b!==null&&h!==null&&f!==null;c.push({name:"display",state:u?"ready":"missing",detail:"Xvfb + openbox + x11vnc"});let _=jn.filter((I)=>B(I)===null),v=(o?.missing_system_packages??kt).filter((I)=>kt.includes(I)),E=_.length===0&&v.length===0;c.push(E?{name:"system_packages",state:"ready"}:{name:"system_packages",state:"missing",detail:[...new Set([...v,..._])].join(" ")});let N=He.filter((I)=>B(I)===null);c.push(N.length===0?{name:"desktop_look",state:"ready"}:{name:"desktop_look",state:"missing",detail:N.join(" ")})}let x=n.ffmpeg&&L(n.ffmpeg)?n.ffmpeg:B("ffmpeg"),m=!x?null:x===n.ffmpeg?n.ffprobe:y(Be(An(x)),"ffprobe"),R=a&&c.every((u)=>u.state==="ready"),S=(u)=>a&&c.every((_)=>!rs[u].includes(_.name)||_.state==="ready");return{platform:t,root:n.root,automation:n.automation,ready:R,features:{display:S("display"),computer:S("computer"),browser:S("browser")},node:n.node,ocu:n.ocu,obu:n.obu,nativeHost:n.nativeHost,extensionDir:n.extensionDir,browser:n.browser,ffmpeg:x,ffprobe:m&&L(m)?m:null,userChrome:ss(n,a&&["node","open_browser_use"].every((u)=>c.find((_)=>_.name===u)?.state==="ready")),pulseaudio:B("pulseaudio"),xvnc:B("Xvnc"),xvfb:b,x11vnc:h,openbox:f,components:c}}function At(e){return as(e)?ls():[]}function as(e){return e?.platform==="darwin-arm64"&&e.ffmpeg===y(e.root,"ffmpeg",W.version,"ffmpeg")}async function dc(e,t,n,o=fetch){try{let i=await o(e,{redirect:"follow"});if(!i.ok||!i.body)throw Error(`download failed (HTTP ${i.status}): ${e}`);let a=vt("sha256"),c=Cn(n,{mode:384});try{let w=i.body.getReader();for(let b=await w.read();!b.done;b=await w.read())if(a.update(b.value),!c.write(b.value))await Pn(c,"drain")}finally{c.end(),await Nn(c)}let p=a.digest("hex");if(p!==t)throw Error(`digest mismatch for ${e}: expected ${t}, got ${p}`)}catch(i){throw $n(n,{force:!0}),i}}function je(e){return y(Mt(e),"minimal.json")}function cs(e=s()){return Mn(je(e))}function pc(e={}){Wn(je(e.home??s()),`${JSON.stringify({version:1,minimal_at:(e.now?.()??new Date).toISOString()})}
81
+ `)}function hc(e={}){let t=e.platform===void 0?Rt():e.platform;if(t===null)return null;let n=e.home??s();if(Tt(wn(t,n).receipt)!==null)return"refresh";return cs(n)?null:"install"}import{spawn as us}from"child_process";import{existsSync as ds}from"fs";import{connect as ps}from"net";import{join as fe}from"path";var Lt="reason_desktop",Q={sampleRate:48000,channels:2,codec:"opus"},fs=5000,ms=107,gs=262144,zo=(e)=>fe(e,"native"),Kt=(e)=>`unix:${e}`;function Ve(e,t=1000){if(!ds(e))return Promise.resolve(!1);return new Promise((n)=>{let o=ps({path:e}),i=(a)=>{o.destroy(),n(a)};o.setTimeout(t,()=>i(!1)),o.once("error",()=>i(!1)),o.once("close",()=>i(!1)),o.once("connect",()=>i(!0))})}async function uc(e,t){if(!t)return null;let n=zo(e);if(Buffer.byteLength(n)>ms||/["'\\\s]/.test(n))return null;try{if(await Ve(n))return n;let o=us(t,["--daemonize=no","--system=no","--use-pid-file=no","--exit-idle-time=-1","--disallow-exit=yes","--realtime=no","--high-priority=no","--disallow-module-loading=yes","--log-level=warning",`--log-target=file:${fe(e,"pulseaudio.log")}`,"-n",`--load=module-native-protocol-unix socket="${n}" auth-anonymous=1 auth-cookie-enabled=0`,`--load=module-null-sink sink_name=${Lt} rate=${Q.sampleRate} channels=${Q.channels} sink_properties=device.description=Reason_desktop`],{detached:!0,stdio:"ignore",env:{HOME:e,PATH:"/usr/bin:/bin",XDG_RUNTIME_DIR:e,PULSE_RUNTIME_PATH:fe(e,"runtime"),PULSE_STATE_PATH:fe(e,"state")}}),i=!1;o.once("error",()=>{i=!0}),o.once("exit",()=>{i=!0}),o.unref();let a=Date.now()+fs;while(Date.now()<a){if(await Ve(n))return n;if(i)return await Ve(n)?n:null;await new Promise((c)=>setTimeout(c,50))}if(!i)o.kill("SIGKILL");return null}catch{return null}}function Nt(){let{sampleRate:e,channels:t}=Q;return["-hide_banner","-loglevel","error","-nostdin","-fflags","nobuffer","-f","pulse","-sample_rate",String(e),"-channels",String(t),"-fragment_size",String(e*t*2/50),"-i",`${Lt}.monitor`,"-vn","-ac",String(t),"-ar",String(e),"-c:a","libopus","-b:a","64k","-application","lowdelay","-frame_duration","20","-flush_packets","1","-page_duration","20000","-f","ogg","pipe:1"]}var hs=[79,103,103,83],bs=Buffer.from("OpusHead"),ys=Buffer.from("OpusTags"),$t=(e,t)=>e.byteLength>=t.byteLength&&t.every((n,o)=>e[o]===n);class Ge extends Error{constructor(e){super(e);this.name="OggProtocolError"}}class We{buffer=new Uint8Array(0);partial=[];partialBytes=0;push(e){let t=new Uint8Array(this.buffer.byteLength+e.byteLength);t.set(this.buffer),t.set(e,this.buffer.byteLength);let n=[],o=0;while(t.byteLength-o>=27){if(hs.some((x,m)=>t[o+m]!==x)||t[o+4]!==0)throw new Ge("invalid_page");let i=(t[o+5]&1)!==0,a=t[o+26];if(t.byteLength-o<27+a)break;let c=t.subarray(o+27,o+27+a),p=c.reduce((x,m)=>x+m,0),w=27+a+p;if(t.byteLength-o<w)break;if(!i&&this.partialBytes>0)this.resetPartial();let b=i&&this.partialBytes===0,h=o+27+a,f=h;for(let x of c){if(h+=x,x===255)continue;if(this.appendPartial(t.subarray(f,h),b),f=h,!b){let m=this.takePartial();if(m.byteLength>0&&!$t(m,bs)&&!$t(m,ys))n.push(m)}b=!1,this.resetPartial()}if(f<h)this.appendPartial(t.subarray(f,h),b);o+=w}return this.buffer=t.slice(o),n}appendPartial(e,t){if(t||e.byteLength===0)return;if(this.partialBytes+=e.byteLength,this.partialBytes>gs)throw new Ge("packet_too_large");this.partial.push(e.slice())}takePartial(){if(this.partial.length===1)return this.partial[0];let e=new Uint8Array(this.partialBytes),t=0;for(let n of this.partial)e.set(n,t),t+=n.byteLength;return e}resetPartial(){this.partial=[],this.partialBytes=0}}import{spawn as ws}from"child_process";var Ut=1048576,xs=String.raw`
82
+ import gi, json, os, sys
83
+ gi.require_version("Gtk", "3.0")
84
+ from gi.repository import Gtk, Gdk, GLib
85
+ if not Gtk.init_check()[0]:
86
+ sys.exit(1)
87
+ clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
88
+ pending = b""
89
+ generation = 0
90
+ def send(value):
91
+ print(json.dumps(value, ensure_ascii=True), flush=True)
92
+ def changed(clipboard, event):
93
+ global generation
94
+ generation += 1
95
+ current = generation
96
+ def received(clipboard, text, unused):
97
+ if current == generation and text is not None and len(text.encode("utf-8")) <= ${O}:
98
+ send({"text": text})
99
+ clipboard.request_text(received, None)
100
+ # No request_text on startup: never share the pre-existing clipboard.
101
+ clipboard.connect("owner-change", changed)
102
+ def input_ready(fd, condition):
103
+ global pending
104
+ chunk = os.read(fd, 65536)
105
+ if not chunk:
106
+ Gtk.main_quit()
107
+ return False
108
+ pending += chunk
109
+ while b"\n" in pending:
110
+ line, pending = pending.split(b"\n", 1)
111
+ text = json.loads(line)
112
+ if not isinstance(text, str) or len(text.encode("utf-8")) > ${O} or "\x00" in text:
113
+ sys.exit(1)
114
+ clipboard.set_text(text, -1)
115
+ send("ack")
116
+ if len(pending) > ${O*6+2}:
117
+ sys.exit(1)
118
+ return True
119
+ GLib.io_add_watch(0, GLib.IO_IN | GLib.IO_HUP, input_ready)
120
+ send("ready")
121
+ Gtk.main()
122
+ `;function Bt(e,t){let n=ws("/usr/bin/python3",["-I","-u","-c",xs],{env:{DISPLAY:e.display,XAUTHORITY:e.xauthority},stdio:["pipe","pipe","ignore"]}),o=!1,i=!0,a="",c=0,p=[],w=setTimeout(()=>h(),5000),b=()=>{o=!0,clearTimeout(w),p.length=0,n.kill("SIGKILL")},h=()=>{if(o)return;b(),t.end({error:new r("display_unavailable","Reason could not start this Linux desktop's UTF-8 clipboard.")})},f=(x,m=32)=>{if(o)return;if(!i){x();return}if(c+=m,c>Ut)b(),t.end({reason:"input_backpressure"});else p.push({apply:x,bytes:m})};return n.stdout.on("data",(x)=>{if(o)return;a+=x.toString("ascii");for(let m=a.indexOf(`
123
+ `);m>=0;m=a.indexOf(`
124
+ `)){let R=a.slice(0,m);a=a.slice(m+1);let S;try{S=JSON.parse(R)}catch{h();return}if(S==="ready"||S==="ack"){clearTimeout(w),i=!1;while(!i&&!o&&p.length){let u=p.shift();c-=u.bytes,u.apply()}}else if(S&&typeof S==="object"&&"text"in S&&typeof S.text==="string"&&Buffer.byteLength(S.text)<=O)t.clipboard(S.text);else{h();return}if(o)return}if(a.length>O*6+32)h()}),n.stdin.on("error",h),n.once("error",h),n.once("exit",h),{apply:f,write(x){if(Buffer.byteLength(x)>O||x.includes("\x00")){h();return}let m=`${JSON.stringify(x)}
125
+ `;f(()=>{if(i=!0,w=setTimeout(()=>h(),5000),n.stdin.write(m),n.stdin.writableLength>Ut)b(),t.end({reason:"input_backpressure"})},Buffer.byteLength(m))},close:b}}var X={smooth:{fps:60,crf:23,kbps:8000,x264Preset:"ultrafast",threads:2,scale:1},sharp:{fps:30,crf:19,kbps:1e4,x264Preset:"superfast",scale:1},data_saver:{fps:20,crf:28,kbps:2000,x264Preset:"ultrafast",scale:0.75},balanced:{fps:30,crf:23,kbps:4000,x264Preset:"ultrafast",threads:2,scale:1}},Ss="avc1.4D002A",Ht={width:1920,height:1080},Es=262144,Ds=0.2,Is=250,Ps=1e4,Cs=1024,Ke=1e4,Rs=500,Ms=60,Ts=1e4,Os=1000,Ft=1048576,As=-223,$s=-308,qo={kind:"mac_screen",sound:null},Wo={kind:"windows_screen",sound:null},Ls,zt=()=>Ls??=T()?.ffmpeg??null,ge=(e,t,n)=>qe(e,t,{env:n,stdio:["ignore","pipe","ignore"],windowsHide:!0}),Ns,Ye=()=>Ns??=At(T()),jt=(e,t,n)=>{let[o,...i]=[...Ye(),e];return ge(o,[...i,...t],n)},Vt=()=>on?.videotoolbox?"h264_videotoolbox":"libx264",Us=()=>Math.round(performance.now()*1000),Xe=new Set,Wt=!1;function en(e){if(Xe.add(e),e.once("exit",()=>Xe.delete(e)),Wt)return;Wt=!0,process.once("exit",()=>{for(let t of Xe)try{t.kill("SIGKILL")}catch{}})}function tn(e){try{e.stdout?.destroy()}catch{}if(e.exitCode!==null||e.signalCode!==null)return;try{e.kill("SIGTERM")}catch{return}let t=setTimeout(()=>{if(e.exitCode===null&&e.signalCode===null)try{e.kill("SIGKILL")}catch{}},Rs);e.once("exit",()=>clearTimeout(t))}function Bs(e,t,n){return{args:["-f","x11grab","-draw_mouse","1","-framerate",String(e),"-video_size",`${t.width}x${t.height}`,"-i",n],size:t}}function Hs(e){return{args:["-f","avfoundation","-capture_cursor","1","-pixel_format","nv12","-framerate",String(e),"-i","Capture screen 0:none"],size:null}}function Fs(e,t){return{args:["-f","gdigrab","-draw_mouse","1","-framerate",String(e),"-offset_x","0","-offset_y","0","-video_size",`${t.width}x${t.height}`,"-i","desktop"],size:t}}function zs(e){return{args:["-probesize","32","-analyzeduration","0","-f","image2pipe","-c:v","mjpeg","-framerate",String(e),"-i","pipe:0"],size:null}}var nn=1700000;function sn(e){return Math.min(1,Math.round(Math.sqrt(nn/(e.width*e.height))*100)/100)}function js(e,t,n){let o=qe(n.axe,["stream-video","--udid",n.udid,"--format","ffmpeg","--fps","30","--quality","85","--scale",String(Math.min(0.99,sn(n.size)))],{stdio:["ignore","pipe","ignore"]}),i=qe(e,t,{env:{},stdio:["pipe","pipe","ignore"]});o.stdout.pipe(i.stdin),i.stdin.on("error",()=>{});let a=()=>{if(o.exitCode===null&&o.signalCode===null)o.kill("SIGTERM")};return i.once("exit",a),i.once("error",a),o.once("exit",()=>{if(i.exitCode===null&&i.signalCode===null)i.kill("SIGTERM")}),o.once("error",()=>{if(i.exitCode===null&&i.signalCode===null)i.kill("SIGTERM")}),i}function qt(e){let t=Math.min(1,Ht.width/e.width,Ht.height/e.height);return{width:Math.round(e.width*t),height:Math.round(e.height*t)}}function me(e,t,n,o="libx264"){let i=X[e],a=(f)=>Math.max(2,Math.floor(f/2)*2),c={width:a(n.width*i.scale),height:a(n.height*i.scale)},p=c.width!==t.size?.width||c.height!==t.size.height,w=Math.max(1,Math.round(i.kbps*2/i.fps)),b=["-g",String(i.fps*Ms)],h=o==="h264_videotoolbox"?["-c:v","h264_videotoolbox","-realtime","1","-prio_speed","1","-allow_sw","1","-profile:v","main","-level","4.2","-bf","0","-pix_fmt","nv12",...b,"-b:v",`${i.kbps}k`,"-maxrate",`${i.kbps}k`,"-bufsize",`${w}k`,"-bsf:v","h264_metadata=aud=insert"]:["-c:v","libx264","-preset",i.x264Preset,"-tune","zerolatency","-profile:v","main","-level","4.2","-bf","0","-pix_fmt","yuv420p",...i.threads?["-threads",String(i.threads)]:[],"-x264-params","aud=1:repeat-headers=1",...b,"-crf",String(i.crf),"-maxrate",`${i.kbps}k`,"-bufsize",`${w}k`];return["-hide_banner","-loglevel","error","-nostdin","-fflags","nobuffer",...t.args,"-an",...p?["-vf",`scale=${c.width}:${c.height}:flags=fast_bilinear`]:[],...h,"-flush_packets","1","-f","h264","pipe:1"]}class rn{buffer=new Uint8Array(0);scanned=0;key=!1;micros=0;push(e,t){if(this.buffer.byteLength===0)this.micros=t;let n=new Uint8Array(this.buffer.byteLength+e.byteLength);n.set(this.buffer),n.set(e,this.buffer.byteLength),this.buffer=n;let o=[],i=this.scanned;while(i+3<this.buffer.byteLength){if(this.buffer[i]!==0||this.buffer[i+1]!==0||this.buffer[i+2]!==1){i++;continue}let a=this.buffer[i+3]&31,c=i>0&&this.buffer[i-1]===0?i-1:i;if(a===9&&c>0)o.push({data:this.buffer.slice(0,c),key:this.key,micros:this.micros}),this.buffer=this.buffer.subarray(c),this.key=!1,this.micros=t,i-=c;if(a===5)this.key=!0;i+=3}return this.scanned=i,o}}function Vs(e,t){let n=vs({path:e}),o=Buffer.alloc(0),i="version",a=0,c=!1,p=[],w=0,b=!1,h=(u)=>{if(b)return;b=!0,n.destroy(),t.end(u)},f=()=>h({reason:"display_protocol"}),x=(u)=>{if(b)return;if(!c){if(w+=u.byteLength,w>Ft)h({reason:"input_backpressure"});else p.push(u);return}if(n.write(u),n.writableLength>Ft)h({reason:"input_backpressure"})},m=(u)=>{o=o.subarray(u)},R=()=>{switch(i){case"version":{if(o.byteLength<12)return!1;let u=/^RFB (\d{3})\.(\d{3})\n$/.exec(o.subarray(0,12).toString("latin1"));if(!u||Number(u[1])*1000+Number(u[2])<3007)return f(),!1;return m(12),n.write(`RFB 003.007
126
+ `),i="security",!0}case"security":{if(o.byteLength<1)return!1;let u=o[0];if(u===0)return f(),!1;if(o.byteLength<1+u)return!1;if(!o.subarray(1,1+u).includes(1))return f(),!1;return m(1+u),n.write(Buffer.from([1,1])),i="init",!0}case"init":{if(o.byteLength<24)return!1;let u=o.readUInt32BE(20);if(u>65536)return f(),!1;if(o.byteLength<24+u)return!1;let _={width:o.readUInt16BE(0),height:o.readUInt16BE(2)};if(m(24+u),_.width===0||_.height===0)return f(),!1;i="messages";let v=Buffer.alloc(12);v.writeUInt8(2,0),v.writeUInt16BE(2,2),v.writeInt32BE($s,4),v.writeInt32BE(As,8),n.write(v),c=!0;for(let E of p)n.write(E);return p=[],w=0,t.ready(_),!b}case"skip":{let u=Math.min(a,o.byteLength);if(m(u),a-=u,a>0)return!1;return i="messages",!0}case"messages":{if(o.byteLength<1)return!1;switch(o[0]){case 1:{if(o.byteLength<6)return!1;let u=6+o.readUInt16BE(4)*6;if(o.byteLength<u)return!1;return m(u),!0}case 2:return m(1),!0;case 3:{if(o.byteLength<8)return!1;let u=o.readUInt32BE(4);if(u>O/2)return m(8),i="skip",a=u,!0;if(o.byteLength<8+u)return!1;let _=o.subarray(8,8+u).toString("latin1");return m(8+u),t.clipboard(_),!b}default:return f(),!1}}}},S=!1;return n.once("connect",()=>{S=!0}),n.on("data",(u)=>{if(b)return;o=o.byteLength?Buffer.concat([o,u]):u;while(!b&&R());}),n.once("error",()=>{if(!S)h({error:new r("display_unavailable","Reason could not reach this machine's desktop server.")})}),n.once("close",()=>h({reason:"display_closed"})),{pointer(u,_,v){let E=Buffer.alloc(6);E.writeUInt8(5,0),E.writeUInt8(v&255,1),E.writeUInt16BE(u,2),E.writeUInt16BE(_,4),x(E)},key(u,_){let v=Buffer.alloc(8);v.writeUInt8(4,0),v.writeUInt8(u?1:0,1),v.writeUInt32BE(_>>>0,4),x(v)},clipboard(u){if(Array.from(u).some((E)=>E.codePointAt(0)>255)){h({reason:"clipboard_unicode_unsupported"});return}let _=Buffer.from(u,"latin1"),v=Buffer.alloc(8);v.writeUInt8(6,0),v.writeUInt32BE(_.byteLength,4),x(Buffer.concat([v,_]))},close(){b=!0,n.destroy()}}}class Je{run=null;viewers=new Set;get running(){return this.run!==null}start(e,t,n,o){this.viewers.add(e),this.stop();let i;try{i=n()}catch{this.fail();return}en(i);let a={child:i,splitter:new rn};this.run=a;for(let p of[...this.viewers])p.started(t);i.stdout?.on("data",(p)=>{if(this.run!==a)return;for(let w of a.splitter.push(p,o()))for(let b of[...this.viewers])b.unit(w)});let c=()=>{if(this.run!==a)return;this.run=null,this.fail()};i.once("exit",c),i.once("error",c)}leave(e){if(!this.viewers.delete(e))return;if(this.viewers.size===0)this.stop()}stop(){if(!this.run)return;tn(this.run.child),this.run=null}fail(){for(let e of[...this.viewers])e.failed()}}var Yt=new WeakMap;function Gs(e){let t=Yt.get(e);if(!t)Yt.set(e,t=new Je);return t}var ee=new Map;function Vo(e,t,n={}){let o=n.micros??Us,i=new ns,a=t.request.preset,c=null,p=null,w=null,b=!1,h=null,f=!1,x=!1,m=null,R=0,S=0,u=!1,_=null,v=null,E=0,N=null,I=[],te=0,U=[],Ze=new Uint32Array(Ke+1),he=0,be=null,ye=0,q=0,we=0,Qe=0,et=0,ne=null,xe=0,j={frames:0,bytes:0,since:o()},V=[],Y=0,_e,ke=!1,cn=o(),C={},G=()=>Math.round((o()-cn)/1000),tt=n.control??ut,ve=null,Se=null,nt=0,Ee=!1,st={pause(){if(!h?.running)return;h.stop(),Ee=!0},adopt(l){let d=l!==null&&(l.width!==p?.width||l.height!==p?.height);if(d)p=l;if(!d&&!Ee)return;if(Ee=!1,h)ae();else Pe()}},un=(l)=>{if(!n.resizeDesktop||!c||"kind"in c||e.done)return;let d=c.display,g=()=>[...ee.get(d)??[]];nt++,n.resizeDesktop(c,l,()=>{for(let k of g())k.pause()}).then((k)=>{for(let D of g())D.adopt(k)})},M=(l)=>{let d=Rn(l);return e.send(d),Qe+=d.byteLength,d.byteLength},se=(l)=>{if(e.done)return;if(e.open)M({type:"error",code:l});e.end({reason:l})},re=()=>Math.max(Es,X[a].kbps*1000/8*Ds),oe=()=>o()/1000,ln=()=>{while(U.length>1&&U[0].atMs<oe()-Ps)U.shift();return U[0]?.rttMs??null},rt=(l)=>{let d=ln();if(d===null||I.length===0)return!1;let g=(d+Is)*l;return oe()-I[0].sentMs>g||te>g/1000*X[a].kbps*1000/8},dn=(l)=>{if(E===0)return;let d=Math.min(l,E-1);if(N!==null&&d<=N)return;N=d;let g=oe();while(I.length&&I[0].seq<=d){let k=I.shift();if(te-=k.bytes,k.seq!==d)continue;let D=Math.max(0,g-k.sentMs);while(U.length&&U.at(-1).rttMs>=D)U.pop();U.push({atMs:g,rttMs:D}),Ze[Math.min(Ke,Math.round(D))]++,he++,be=Math.min(be??D,D)}},pn=()=>{let l=0;for(let d=0;d<=Ke;d++)if(l+=Ze[d],l*2>=he)return d;return 0},fn=()=>e.bufferedAmount<=re()/2&&!rt(0.5),ot=()=>{ke=!0,V=[],Y=0,h?.leave(De),h=null},it=(l)=>{if(e.done)return;if(l.key)C.first_key_ms??=G();if(!b){if(!h||V.length===0&&!l.key)return;if(V.push(l),Y+=l.data.byteLength,Y>re())ot();return}if(u){q++;return}if(e.bufferedAmount>re()||rt(1)){u=!0,q++,_=setInterval(()=>{if(e.done||!fn())return;if(_)clearInterval(_);_=null,u=!1,ae()},n.drainPollMs??25);return}if(!f){if(!l.key){q++;return}if(M({type:"hello",width:p.width,height:p.height,fps:X[a].fps,preset:a,codec:Ss}),f=!0,C.first_frame_ms??=G(),!x&&c?.sound)M({type:"audioHello",...Q}),x=!0}let d=M({type:"frame",key:l.key,seq:E,captureMicros:l.micros,data:l.data});if(I.push({seq:E,sentMs:oe(),bytes:d}),te+=d,I.length>Cs)te-=I.shift().bytes;E++,ye++,ne??=l.micros,xe=l.micros,j.frames++,j.bytes+=d},De={started(l){a=l,f=!1,V=[],Y=0},unit:it,failed:()=>se("encoder_failed")},Ie=()=>{let l=(n.ffmpeg??zt)();if(!c||!p){se("encoder_failed");return}let[d,g]=[c,p],k="kind"in d&&d.kind==="simulator"?d.stream:null;if(!l&&!k){se("encoder_failed");return}if(h??="kind"in d&&d.kind==="mac_screen"?Gs(n.spawn??jt):new Je,C.encoder_ms===void 0)C.encoder_ms=G(),C.encoder_shared=h.running;h.start(De,a,()=>{let D=X[a].fps;if(k)return k(D,X[a].kbps,nn);if("kind"in d&&d.kind==="simulator"){let P=Math.min(0.99,sn(d.size)),H={width:d.size.width*P,height:d.size.height*P};return js(l,me(a,zs(Math.min(D,30)),H,(n.macEncoder??Vt)()),d)}if("kind"in d&&d.kind==="windows_screen")return(n.spawn??ge)(l,me(a,Fs(D,g),qt(g)),{SystemRoot:process.env.SystemRoot??"C:\\Windows"});return"kind"in d?(n.spawn??jt)(l,me(a,Hs(D),qt(g),(n.macEncoder??Vt)()),{}):(n.spawn??ge)(l,me(a,Bs(D,g,d.display),g),{DISPLAY:d.display,XAUTHORITY:d.xauthority})},o)},ie=()=>{if(!m)return;tn(m.child),m=null},mn=()=>{let l=(n.ffmpeg??zt)();if(m||e.done||!x||!c?.sound||!l)return;let d;try{d=(n.spawn??ge)(l,Nt(),{PULSE_SERVER:Kt(c.sound)})}catch{return}en(d);let g={child:d,reader:new We};m=g,d.stdout?.on("data",(D)=>{if(m!==g||e.done)return;let P;try{P=g.reader.push(D)}catch{ie();return}let H=o();for(let Re of P){if(e.bufferedAmount>re()){S++;continue}M({type:"audio",captureMicros:H,data:Re}),R++}});let k=()=>{if(m===g)ie()};d.once("exit",k),d.once("error",k)},ae=()=>{if(!h||e.done)return;we++,Ie()},Pe=()=>{if(e.done||!p)return;if(!b){if(h||ke)return;Ie(),_e=setTimeout(()=>{if(!b)ot()},Ts);return}if(clearTimeout(_e),C.encoder_early===void 0){if(C.encoder_early=h!==null,ke)C.hold_lapsed=!0}if(!h)Ie();let l=V;V=[],Y=0;for(let d of l)it(d);v??=setInterval(()=>{let d=o(),g=Math.max(0.001,(d-j.since)/1e6);M({type:"stats",stats:{fps:Math.round(j.frames/g*10)/10,kbps:Math.round(j.bytes*8/1000/g),dropped:q,restarts:we,queued_bytes:e.bufferedAmount}}),j={frames:0,bytes:0,since:d}},Os)};t.desktop.then((l)=>{if(e.done)return;c=l;let d={ready(g){p=g,C.desktop_ms??=G(),Pe()},clipboard(g){if(e.open&&Buffer.byteLength(g)<=O)M({type:"serverClipboard",text:g})},end(g){if("reason"in g&&e.open)M({type:"error",code:g.reason});e.end(g)}};if("kind"in l&&l.kind==="simulator")w=l.input,d.ready(l.points);else if("kind"in l&&l.kind==="windows_screen")w=(n.windowsInput??xt)(d);else if("kind"in l)w=(n.macInput??((g)=>os(g,Ye())))(d);else{let g=ee.get(l.display);if(!g)ee.set(l.display,g=new Set);g.add(st);let k=(n.linuxClipboard??Bt)(l,d),D=Vs(l.rfbSocket,{...d,clipboard:(P)=>{if(!k)d.clipboard(P)}});w=k?{pointer:(P,H,Re)=>k.apply(()=>D.pointer(P,H,Re)),key:(P,H)=>k.apply(()=>D.key(P,H)),clipboard:(P)=>k.write(P),close(){k.close(),D.close()}}:D}at()},(l)=>e.end({error:l}));function at(){if(Se||!t.viewerSameNetwork||!b||e.done||!c||!("kind"in c)||c.kind!=="mac_screen")return;Se=(n.macWindows??is)((l)=>{if(e.open)M({type:"windows",bounds:l})})}let ct={viewer:t.viewer??null,notify(l){if(e.open)M({type:"control",control:l})}},Ce=(l)=>{if(!w)return;if(!c||!("kind"in c)||c.kind!=="simulator")tt.claim(ct);l(w)};return{opened(){C.relay_ms??=G()},received(l){et+=l.byteLength;let d;try{d=i.push(l)}catch{se("viewer_protocol");return}for(let g of d){if(e.done)return;switch(g.type){case"ping":M({type:"pong",token:g.token});break;case"pointer":Ce((k)=>k.pointer(g.x,g.y,g.buttons));break;case"key":Ce((k)=>k.key(g.down,g.keysym));break;case"clientClipboard":Ce((k)=>k.clipboard(g.text));break;case"config":if(g.preset!==a)a=g.preset,ae();break;case"keyframeRequest":if(f&&!u)ae();break;case"ack":dn(g.seq);break;case"audioEnable":if(g.on)mn();else ie();break;case"resize":un({width:g.width,height:g.height});break;default:break}}if(!b&&!e.done){if(b=!0,C.viewer_ms=G(),t.viewer)ve=tt.join(ct);Pe(),at()}},close(){if(c&&!("kind"in c)){let l=ee.get(c.display);if(l?.delete(st),l?.size===0)ee.delete(c.display)}if(ve?.(),ve=null,Se?.close(),_)clearInterval(_);if(v)clearInterval(v);clearTimeout(_e),h?.leave(De),ie(),w?.close()},summary:()=>({output_bytes:Qe,input_bytes:et,video:{preset:a,frames:ye,dropped:q,restarts:we,avg_fps:ne!==null&&xe>ne?Math.round((ye-1)/((xe-ne)/1e6)*10)/10:0,min_rtt_ms:Math.round(be??0),p50_rtt_ms:he?pn():0,audio_packets:R,audio_dropped:S,resizes:nt,connect:C}})}}var Zt=null,on=null,Ws=null,Ks=null;function Xs(){let e=T();return e?.features.display?e.ffmpeg:null}function an(e){return Zt??=new Promise((t)=>{_s(e,["-hide_banner","-encoders"],{env:{},timeout:5000,killSignal:"SIGKILL",maxBuffer:1048576,encoding:"utf8"},(n,o)=>{let i=(a)=>!n&&new RegExp(`^\\s*V\\S*\\s+${a}\\s`,"m").test(o);t(on={x264:i("libx264"),videotoolbox:i("h264_videotoolbox")})})}),Zt}var Qt=null;function Go(){return Qt??=(async()=>{let e=[T()?.ffmpeg,"/opt/homebrew/bin/ffmpeg","/usr/local/bin/ffmpeg"].find((n)=>Boolean(n&&ks(n)));if(!e)return null;let t=await an(e);return t.videotoolbox||t.x264?e:null})(),Qt}function Jt(e=process.platform,t={}){if(e!=="linux"&&e!=="darwin"&&e!=="win32")return Promise.resolve(!1);let n=(t.ffmpeg??Xs)();if(!n)return Promise.resolve(!1);let o=(t.encoders??an)(n);if(e==="linux")return o.then((a)=>a.x264);if(e==="win32"){let a=t.windowsScreen?t.windowsScreen():Ks??=bt();return Promise.all([o,a]).then(([c,p])=>c.x264&&(p?.session??0)>0)}let i=t.macScreen?t.macScreen():Ws??=Xt(Ye());return Promise.all([o,i]).then(([a,c])=>(a.x264||a.videotoolbox)&&c?.screen===!0&&c.accessibility)}
127
+ export{Gt,lc,le,zo,Kt,uc,qo,Wo,Vo,Go,Jt,yn,wn,T,dc,pc,hc};