@reason-machines/cli-linux-x64 0.2.561 → 0.2.563

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 (129) hide show
  1. package/bin/reason +2 -2
  2. package/bin/vm-hands/agent-network-3stvmqsj.js +2 -0
  3. package/bin/vm-hands/api-9xm5e4g9.js +2 -0
  4. package/bin/vm-hands/api-credentials-3wwkpts2.js +2 -0
  5. package/bin/vm-hands/{ask-relay-xx0rzpch.js → ask-relay-5f92e4c5.js} +2 -2
  6. package/bin/vm-hands/connect-cli-d3dp0r1t.js +2 -0
  7. package/bin/vm-hands/credentials-sk4sag42.js +2 -0
  8. package/bin/vm-hands/custom-endpoint-device-3jscber1.js +2 -0
  9. package/bin/vm-hands/desktop-account-xma0330a.js +2 -0
  10. package/bin/vm-hands/desktop-components-p0zx6qxg.js +2 -0
  11. package/bin/vm-hands/desktop-delegate-tch2qzx0.js +2 -0
  12. package/bin/vm-hands/device-workspace-4bj43nxq.js +2 -0
  13. package/bin/vm-hands/{fsevents-vxv56sp5.js → fsevents-ezcg3e40.js} +1 -1
  14. package/bin/vm-hands/hands-worker-source-8pe7yv0m.js +2 -0
  15. package/bin/vm-hands/{index-03p9c17x.js → index-w92ys6ra.js} +16 -16
  16. package/bin/vm-hands/install-receipt-68xxg7hn.js +2 -0
  17. package/bin/vm-hands/local-automation-0a7enct8.js +2 -0
  18. package/bin/vm-hands/local-capabilities-d3ycjdyg.js +2 -0
  19. package/bin/vm-hands/local-desktop-users-jpf0resr.js +2 -0
  20. package/bin/vm-hands/local-display-mac-h5yz0ydd.js +2 -0
  21. package/bin/vm-hands/local-display-session-pc85z6mg.js +2 -0
  22. package/bin/vm-hands/local-display-video-40avbg94.js +2 -0
  23. package/bin/vm-hands/local-managed-process-ka331rcr.js +2 -0
  24. package/bin/vm-hands/local-pty-session-tqn2xmph.js +2 -0
  25. package/bin/vm-hands/managed-runtime-nwj7cn7c.js +2 -0
  26. package/bin/vm-hands/network-auto-update-tk104maa.js +3 -0
  27. package/bin/vm-hands/network-contract-nkwcf4r9.js +2 -0
  28. package/bin/vm-hands/{network-sign-in-61gmpmaa.js → network-sign-in-t9ng36rs.js} +2 -2
  29. package/bin/vm-hands/package-9w0mmxb5.js +2 -0
  30. package/bin/vm-hands/permissions-ywh8x4dq.js +2 -0
  31. package/bin/vm-hands/reason-hands-protocol-pck5har9.js +2 -0
  32. package/bin/vm-hands/serve-service-43kmwskj.js +2 -0
  33. package/bin/vm-hands/{status-khqk4cjw.js → status-ec366bs8.js} +7 -7
  34. package/bin/vm-hands/version-6ys9zwbj.js +2 -0
  35. package/bin/vm-hands/{vm-hands-entry-lite-ht6hzkgj.js → vm-hands-entry-lite-0jy8mv4a.js} +2 -2
  36. package/bin/vm-hands/{vm-hands-entry-lite-zawytz09.js → vm-hands-entry-lite-12ck5swp.js} +2 -2
  37. package/bin/vm-hands/{vm-hands-entry-lite-j10cw3d9.js → vm-hands-entry-lite-13nx02p7.js} +7 -7
  38. package/bin/vm-hands/{vm-hands-entry-lite-vdv4nm5f.js → vm-hands-entry-lite-1b21avcs.js} +2 -2
  39. package/bin/vm-hands/{vm-hands-entry-lite-bj3w2ven.js → vm-hands-entry-lite-1w39j6vz.js} +2 -2
  40. package/bin/vm-hands/{vm-hands-entry-lite-gxpw14jv.js → vm-hands-entry-lite-1wxwsb3f.js} +7 -7
  41. package/bin/vm-hands/{vm-hands-entry-lite-ms99mzp0.js → vm-hands-entry-lite-284z7ct8.js} +3 -3
  42. package/bin/vm-hands/{vm-hands-entry-lite-a7bf7xr7.js → vm-hands-entry-lite-2qfmabqn.js} +3 -3
  43. package/bin/vm-hands/{vm-hands-entry-lite-q9s1e2y1.js → vm-hands-entry-lite-33at6g06.js} +2 -2
  44. package/bin/vm-hands/{vm-hands-entry-lite-e3fn8ys2.js → vm-hands-entry-lite-3gc2bn5a.js} +2 -2
  45. package/bin/vm-hands/{vm-hands-entry-lite-hxfxs7r9.js → vm-hands-entry-lite-3q2ng4e9.js} +2 -2
  46. package/bin/vm-hands/vm-hands-entry-lite-41nn0vbf.js +150 -0
  47. package/bin/vm-hands/{vm-hands-entry-lite-5y4phfv1.js → vm-hands-entry-lite-43bv9hf0.js} +3 -3
  48. package/bin/vm-hands/{vm-hands-entry-lite-vkhacd00.js → vm-hands-entry-lite-61p78r72.js} +19 -19
  49. package/bin/vm-hands/{vm-hands-entry-lite-hs6sdn60.js → vm-hands-entry-lite-88dxn9b5.js} +2 -2
  50. package/bin/vm-hands/vm-hands-entry-lite-997y1m1r.js +3 -0
  51. package/bin/vm-hands/{vm-hands-entry-lite-zh6ncdjn.js → vm-hands-entry-lite-a3gq377t.js} +2 -2
  52. package/bin/vm-hands/{vm-hands-entry-lite-0wb1n769.js → vm-hands-entry-lite-b1vanmtv.js} +5 -5
  53. package/bin/vm-hands/{vm-hands-entry-lite-q9djb28r.js → vm-hands-entry-lite-cc8hwgxc.js} +3 -3
  54. package/bin/vm-hands/vm-hands-entry-lite-chq0qx9f.js +12 -0
  55. package/bin/vm-hands/{vm-hands-entry-lite-84mc1f7h.js → vm-hands-entry-lite-cmmb9k3g.js} +2 -2
  56. package/bin/vm-hands/{vm-hands-entry-lite-jgk5z8zc.js → vm-hands-entry-lite-d12hx1dk.js} +6 -6
  57. package/bin/vm-hands/{vm-hands-entry-lite-7pfhwxn5.js → vm-hands-entry-lite-d431ffz0.js} +1 -1
  58. package/bin/vm-hands/{vm-hands-entry-lite-ptycjmkc.js → vm-hands-entry-lite-fccn6s4j.js} +2 -2
  59. package/bin/vm-hands/{vm-hands-entry-lite-qf990rxw.js → vm-hands-entry-lite-fn2805g8.js} +2 -2
  60. package/bin/vm-hands/{vm-hands-entry-lite-y3nz20wb.js → vm-hands-entry-lite-frg1b1rg.js} +105 -105
  61. package/bin/vm-hands/{vm-hands-entry-lite-71ebge0c.js → vm-hands-entry-lite-fxptf351.js} +5 -5
  62. package/bin/vm-hands/{vm-hands-entry-lite-57ajjwmh.js → vm-hands-entry-lite-gxf2r5en.js} +1 -1
  63. package/bin/vm-hands/{vm-hands-entry-lite-h7nk2848.js → vm-hands-entry-lite-j8s2vqpf.js} +42 -42
  64. package/bin/vm-hands/{vm-hands-entry-lite-2dak7e1h.js → vm-hands-entry-lite-jgwjt10t.js} +3 -5
  65. package/bin/vm-hands/{vm-hands-entry-lite-hjjbjpd7.js → vm-hands-entry-lite-jj7873n8.js} +3 -3
  66. package/bin/vm-hands/{vm-hands-entry-lite-xvccy3z4.js → vm-hands-entry-lite-k4d5rhpw.js} +2 -2
  67. package/bin/vm-hands/{vm-hands-entry-lite-9g52kxyj.js → vm-hands-entry-lite-kbnxk71q.js} +2 -2
  68. package/bin/vm-hands/{vm-hands-entry-lite-m1we91g4.js → vm-hands-entry-lite-mn8rjpxq.js} +10 -10
  69. package/bin/vm-hands/{vm-hands-entry-lite-52qz0n30.js → vm-hands-entry-lite-ngry8nkq.js} +4 -4
  70. package/bin/vm-hands/vm-hands-entry-lite-pe374cn6.js +81 -0
  71. package/bin/vm-hands/{vm-hands-entry-lite-8xv6c0rm.js → vm-hands-entry-lite-pg7nnyc6.js} +2 -2
  72. package/bin/vm-hands/{vm-hands-entry-lite-tcmye5ny.js → vm-hands-entry-lite-q62g6sx0.js} +2 -2
  73. package/bin/vm-hands/{vm-hands-entry-lite-v4hr9x9h.js → vm-hands-entry-lite-qjrgvdbj.js} +34 -34
  74. package/bin/vm-hands/{vm-hands-entry-lite-krpqqx12.js → vm-hands-entry-lite-rxydyqke.js} +2 -2
  75. package/bin/vm-hands/{vm-hands-entry-lite-weqam12f.js → vm-hands-entry-lite-s93f3pbv.js} +3 -3
  76. package/bin/vm-hands/{vm-hands-entry-lite-z0ht62s4.js → vm-hands-entry-lite-sh4mqy93.js} +3 -3
  77. package/bin/vm-hands/vm-hands-entry-lite-srtqjjqb.js +48 -0
  78. package/bin/vm-hands/{vm-hands-entry-lite-6jxshhps.js → vm-hands-entry-lite-thstg177.js} +6 -6
  79. package/bin/vm-hands/vm-hands-entry-lite-vbqfmsd3.js +4 -0
  80. package/bin/vm-hands/vm-hands-entry-lite-wnqqjsew.js +3 -0
  81. package/bin/vm-hands/{vm-hands-entry-lite-pxtycfdv.js → vm-hands-entry-lite-xfak34av.js} +4 -4
  82. package/bin/vm-hands/{vm-hands-entry-lite-sy7dcccg.js → vm-hands-entry-lite-y0jtj8zz.js} +1 -1
  83. package/bin/vm-hands/{vm-hands-entry-lite-yvws5zpx.js → vm-hands-entry-lite-yg4dk99m.js} +1 -1
  84. package/bin/vm-hands/{vm-hands-entry-lite-2rgf8866.js → vm-hands-entry-lite-z65xva21.js} +2 -2
  85. package/bin/vm-hands/{vm-hands-entry-lite-wcgm41jq.js → vm-hands-entry-lite-zj9esd2g.js} +7 -7
  86. package/bin/vm-hands/{vm-hands-entry-lite-jpvmkce5.js → vm-hands-entry-lite-zp7chzcc.js} +1 -1
  87. package/bin/vm-hands/{vm-hands-entry-lite-k5ytpgzz.js → vm-hands-entry-lite-zpvr7wc6.js} +19 -19
  88. package/bin/vm-hands/vm-hands-entry-lite.js +2 -2
  89. package/bin/vm-hands/vm-hands-executor-2ngwj96m.js +12 -0
  90. package/bin/vm-hands/vm-hands-op-runner-te2ze1e7.js +2 -0
  91. package/bin/vm-hands/{vm-hands-runtime-1qxf96z7.js → vm-hands-runtime-09ehkm3c.js} +3 -3
  92. package/bin/vm-hands/worker-preview-readiness-h96yr4wf.js +2 -0
  93. package/bin/vm-hands/worker-sandbox-6kkhvryn.js +2 -0
  94. package/package.json +1 -1
  95. package/bin/vm-hands/agent-network-kk36zca7.js +0 -2
  96. package/bin/vm-hands/api-credentials-mtfdk175.js +0 -2
  97. package/bin/vm-hands/api-w6w7vfp3.js +0 -2
  98. package/bin/vm-hands/connect-cli-dmwph620.js +0 -2
  99. package/bin/vm-hands/credentials-s7ps7y6s.js +0 -2
  100. package/bin/vm-hands/custom-endpoint-device-3xnrp33e.js +0 -2
  101. package/bin/vm-hands/desktop-account-eg8thn79.js +0 -2
  102. package/bin/vm-hands/device-workspace-h5rsecq8.js +0 -2
  103. package/bin/vm-hands/hands-worker-source-vk664w8p.js +0 -2
  104. package/bin/vm-hands/install-receipt-j04hdw1k.js +0 -2
  105. package/bin/vm-hands/local-automation-vvt9d9xb.js +0 -2
  106. package/bin/vm-hands/local-capabilities-pwv76ns5.js +0 -2
  107. package/bin/vm-hands/local-desktop-users-sq4trh07.js +0 -2
  108. package/bin/vm-hands/local-display-mac-yxcxvg2z.js +0 -2
  109. package/bin/vm-hands/local-display-session-axh9mfdk.js +0 -2
  110. package/bin/vm-hands/local-display-video-pxhztqk7.js +0 -2
  111. package/bin/vm-hands/local-managed-process-4mgqn7tg.js +0 -2
  112. package/bin/vm-hands/local-pty-session-edd8ttf9.js +0 -2
  113. package/bin/vm-hands/managed-runtime-pcagtyfz.js +0 -2
  114. package/bin/vm-hands/network-auto-update-wkzb91qz.js +0 -3
  115. package/bin/vm-hands/network-contract-8mxtma3w.js +0 -2
  116. package/bin/vm-hands/package-vwvzjtn0.js +0 -2
  117. package/bin/vm-hands/permissions-348prrcx.js +0 -2
  118. package/bin/vm-hands/reason-hands-protocol-1nkpw1v3.js +0 -2
  119. package/bin/vm-hands/serve-service-3dkyznay.js +0 -2
  120. package/bin/vm-hands/version-c1hen0wn.js +0 -2
  121. package/bin/vm-hands/vm-hands-entry-lite-9yfmkd1f.js +0 -3
  122. package/bin/vm-hands/vm-hands-entry-lite-ab1pq3xg.js +0 -3
  123. package/bin/vm-hands/vm-hands-entry-lite-hn9pq7zj.js +0 -127
  124. package/bin/vm-hands/vm-hands-entry-lite-nn6zcvmp.js +0 -3
  125. package/bin/vm-hands/vm-hands-entry-lite-z213y4pj.js +0 -150
  126. package/bin/vm-hands/vm-hands-executor-csdtg7kj.js +0 -12
  127. package/bin/vm-hands/vm-hands-op-runner-z7tsd84c.js +0 -2
  128. package/bin/vm-hands/worker-preview-readiness-06tygyjs.js +0 -2
  129. package/bin/vm-hands/worker-sandbox-e1cpkzfz.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Fi,ji,Hi,Nn}from"./vm-hands-entry-lite-9g52kxyj.js";import{oc,sc,F,bi,vi,Mo,_r,Bo,Si,zt,gt,Fo,qt,He,Wt,_t,hn,Ei,ki,Ho}from"./vm-hands-entry-lite-jpvmkce5.js";import{Fn}from"./vm-hands-entry-lite-krpqqx12.js";import{dn}from"./vm-hands-entry-lite-zh6ncdjn.js";import{bt}from"./vm-hands-entry-lite-ptycjmkc.js";var r=["cgroup_membership_read_failed","cgroup_v2_membership_absent","cgroup_scope_invalid","cgroup_root_unavailable","cgroup_directory_unavailable","cgroup_limit_read_failed","cgroup_events_read_failed","cgroup_current_read_failed","cgroup_stat_read_failed","boot_id_read_failed","boot_id_invalid","guest_meminfo_read_failed","guest_vmstat_read_failed","memory_counter_invalid","memory_field_missing","memory_capacity_invalid"];var o=String.raw`(function(fs, path) {
2
+ import{Ui,zi,qi,Mn}from"./vm-hands-entry-lite-kbnxk71q.js";import{hc,fc,F,Ei,ki,jo,_r,Ho,xi,qt,_t,Uo,Wt,He,Vt,yt,yn,Ci,Ai,qo}from"./vm-hands-entry-lite-zp7chzcc.js";import{Un}from"./vm-hands-entry-lite-rxydyqke.js";import{gn}from"./vm-hands-entry-lite-a3gq377t.js";import{vt}from"./vm-hands-entry-lite-fccn6s4j.js";var r=["cgroup_membership_read_failed","cgroup_v2_membership_absent","cgroup_scope_invalid","cgroup_root_unavailable","cgroup_directory_unavailable","cgroup_limit_read_failed","cgroup_events_read_failed","cgroup_current_read_failed","cgroup_stat_read_failed","boot_id_read_failed","boot_id_invalid","guest_meminfo_read_failed","guest_vmstat_read_failed","memory_counter_invalid","memory_field_missing","memory_capacity_invalid"];var o=String.raw`(function(fs, path) {
3
3
  const fail = (message, reasonCode) => { throw Object.assign(Error(message), {reasonCode}); };
4
4
  const read = (p, reasonCode, trim=true) => { try { const text=fs.readFileSync(p, "utf8"); return trim?text.trim():text; }
5
5
  catch { fail("memory_read", reasonCode); } };
@@ -309,7 +309,7 @@ function fileOperation(request) {
309
309
  });
310
310
  return { promise, cancel() {} };
311
311
  }
312
- `;var s="a3e39eb55160acfc116fa9871ccc594c68be7a642d2331b24baa707c8f601ec0";import{createHash as O}from"crypto";var q=Object.freeze({"api.ara.so":"api.reasonmachines.com","api.reasonmachines.ai":"api.reasonmachines.com","api-staging.ara.so":"staging-api.reasonmachines.com","staging-api.reasonmachines.ai":"staging-api.reasonmachines.com"});var a=Object.freeze({trailingSlashPattern:/\/+$/.source,keyPrefix:"http.",keySuffix:"/.extraheader",valuePrefix:"Authorization: Bearer "});var l=Object.freeze({tokenEnv:"ARA_GIT_BROKER_TOKEN",reasonTokenEnv:"REASON_GIT_BROKER_TOKEN",urlEnv:"ARA_GIT_BROKER_URL",keyPrefix:"credential.",keySuffix:"/.helper",value:'!f(){ printf "username=%s\\npassword=%s\\n" "ara-run" "${REASON_GIT_BROKER_TOKEN:-$ARA_GIT_BROKER_TOKEN}"; };f'});var tn=/^[A-Za-z_][A-Za-z0-9_]*$/;var h=new Set(["ARA_INFERENCE_TOKEN","AI_GATEWAY_API_KEY","CLOUD_AGENT_AI_GATEWAY_API_KEY","INFERENCE_V2_GATEWAY_API_KEY","VERCEL_AI_GATEWAY_API_KEY","INFERENCE_V2_CONCENTRATE_API_KEY","INFERENCE_V2_OPENAI_API_KEY","INFERENCE_V2_ANTHROPIC_API_KEY","INFERENCE_V2_FINGERPRINT_SECRET","OPENAI_API_KEY","OPENROUTER_API_KEY","ANTHROPIC_API_KEY","CODEX_ACCESS_TOKEN","GITHUB_COPILOT_API_KEY","AZURE_OPENAI_API_KEY","AZURE_OPENAI_CLIENT_SECRET"]),m=new Set(["ARA_OPERATOR_KEY","BL_API_KEY","BLAXEL_API_KEY","NSC_TOKEN","NSC_TOKEN_FILE","NAMESPACE_API_KEY","NAMESPACE_ACCESS_TOKEN","NAMESPACE_TOKEN","NAMESPACE_TOKEN_JSON","NAMESPACE_SANDBOX_TOKEN_JSON","ARA_LOCAL_QA_NAMESPACE_WORKLOAD_TOKEN_FILE","NAMESPACE_SANDBOX_USE_LOCAL_USER_TOKEN","COMPUTE_SERVICE_TOKEN"]),g=["INFISICAL_","NSC_"],_=new Set(["ARA_JOB_ENV","ARA_DELIVERY_BASE_SHA","WORK_ROOT","REPO_DIR","ARA_CONTROL_DIR","ARA_PRESERVE_WORKSPACE","ARA_PINNED_CHECKOUT_REUSE","FOLLOWUP_BRANCH","REPO_URL","TOKENLESS_URL","REPOSITORY_IDENTITY_URL","DEFAULT_BRANCH","BRANCH","BRANCH_GENERATED","BASE_REF","REPO_EMPTY","REPO_WRITABLE","ARA_DELIVERY_BASE_BRANCH","ARA_SERVER_GIT_PUBLICATION","ARA_EMPTY_REPOSITORY_COMMIT","REASON_MODEL","REASON_DELIVERY_BASE_BRANCH","REASON_DELIVERY_BASE_SHA","REASON_EMPTY_REPOSITORY_COMMIT","REASON_SCRATCH_SESSION_ID","REASON_SERVER_GIT_PUBLICATION","REASON_ALLOW_INSTALL_SCRIPTS","SCM_TOKEN","SCM_TOKEN_USER","REASON_OIDC_TOKEN_URL","REASON_OIDC_REQUEST_TOKEN","AWS_CONTAINER_CREDENTIALS_FULL_URI","AWS_CONTAINER_AUTHORIZATION_TOKEN","AWS_CONTAINER_CREDENTIALS_RELATIVE_URI","AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE","BASH_ENV","ENV","BASHOPTS","SHELLOPTS","PS4","IFS","CDPATH","GLOBIGNORE","PROMPT_COMMAND","PATH","HOME","TMPDIR","TMP","TEMP","XDG_CONFIG_HOME","GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_COMMON_DIR","GIT_NAMESPACE","GIT_CEILING_DIRECTORIES","GIT_DISCOVERY_ACROSS_FILESYSTEM","GIT_SHALLOW_FILE","GIT_ALLOW_PROTOCOL","GIT_PROTOCOL_FROM_USER","GIT_REPLACE_REF_BASE","NODE_OPTIONS","NODE_PATH","NODE_REPL_EXTERNAL_MODULES","CLASSPATH","PYTHONPATH","PYTHONSTARTUP","PYTHONHOME","RUBYOPT","RUBYLIB","PERL5LIB","PERL5OPT","JAVA_TOOL_OPTIONS","_JAVA_OPTIONS","JDK_JAVA_OPTIONS","GEM_PATH","GEM_HOME","GIT_SSH","GIT_SSH_COMMAND","GIT_EXEC_PATH","GIT_TEMPLATE_DIR","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_PROXY_COMMAND","GIT_EXTERNAL_DIFF","GIT_PAGER","GIT_EDITOR","GIT_ASKPASS","SSH_ASKPASS","PAGER","EDITOR","TAR_OPTIONS","CURL_HOME","WGETRC","APT_CONFIG","PERLLIB","GIT_GRAFT_FILE","POSIXLY_CORRECT"]),y=["GIT_TRACE","CONTEXT_REPO_","ARA_CHECKPOINT_BOOTSTRAP_","_","ARA_HANDS_","ARA_DEVICE_","ARA_GIT_BROKER_","REASON_HANDS_","REASON_DEVICE_","REASON_GIT_BROKER_","LD_","DYLD_","GIT_CONFIG","BASH_FUNC_"];var t="^(?!(?:"+[...h,...m,..._].join("|")+")$)(?!(?:"+[...g,...y].join("|")+"))"+tn.source.slice(1),W=new RegExp(t);var v=["HOME","PWD","OLDPWD","TMPDIR","TMP","TEMP","SHELL","USER","LOGNAME","SCM_TOKEN","SCM_TOKEN_USER","GH_TOKEN","GITHUB_TOKEN","GH_ENTERPRISE_TOKEN","GITHUB_ENTERPRISE_TOKEN","GITLAB_TOKEN"],b=["ARA_HANDS_","ARA_DEVICE_","ARA_GIT_BROKER_","REASON_HANDS_","REASON_DEVICE_","REASON_GIT_BROKER_","BUN_"],E="^(?!(?:"+v.join("|")+")$)(?!(?:"+b.join("|")+"))"+t.slice(1),S="ARA_DELIVERY_BASE_SHA|WORK_ROOT|FOLLOWUP_BRANCH|ARA_PRESERVE_WORKSPACE|ARA_PINNED_CHECKOUT_REUSE|CONTEXT_REPO_[A-Z0-9_]+|REPO_URL|TOKENLESS_URL|REPOSITORY_IDENTITY_URL|DEFAULT_BRANCH|BRANCH|BRANCH_GENERATED|BASE_REF|REPO_EMPTY|REPO_WRITABLE|ARA_DELIVERY_BASE_BRANCH|ARA_SERVER_GIT_PUBLICATION|ARA_EMPTY_REPOSITORY_COMMIT|REASON_MODEL|REASON_DELIVERY_BASE_BRANCH|REASON_DELIVERY_BASE_SHA|REASON_EMPTY_REPOSITORY_COMMIT|REASON_SCRATCH_SESSION_ID|REASON_SERVER_GIT_PUBLICATION|REASON_ALLOW_INSTALL_SCRIPTS",n="^(?:"+S+"|"+E.slice(1,-1)+")$",w=new RegExp(n);function hi(u){return w.test(u)}var pr=Object.freeze({tokenPath:"/identity/token",awsPath:"/identity/aws",tokenPattern:/^[A-Za-z0-9_.~-]+$/.source}),Re=Object.freeze({variables:256,valueBytes:130816,snapshotBytes:1048576}),z=Object.freeze({valueChars:16384,snapshotBytes:65536});var c=["set -g history-limit 50000","set -g status off","set -g window-size smallest","set -gq fill-character ' '","set -g escape-time 10","set -g prefix None","set -g prefix2 None","set -g terminal-overrides ',*:smcup@:rmcup@'"];var U=2,H="ara-hands-worker.cjs",d=["/usr/local/go/bin","/opt/node/bin","/usr/local/bin","/usr/sbin","/usr/bin","/sbin","/bin","/usr/local/cargo/bin"],I=d.join(":"),A=["/opt/homebrew/bin",...d].join(":"),T='(platform, linuxPath, macosPath) => platform === "darwin" ? macosPath : linuxPath';var P=String.raw`(function(anchor, pid, native) {
312
+ `;var s="a3e39eb55160acfc116fa9871ccc594c68be7a642d2331b24baa707c8f601ec0";import{createHash as O}from"crypto";var q=Object.freeze({"api.ara.so":"api.reasonmachines.com","api.reasonmachines.ai":"api.reasonmachines.com","api-staging.ara.so":"staging-api.reasonmachines.com","staging-api.reasonmachines.ai":"staging-api.reasonmachines.com"});var a=Object.freeze({trailingSlashPattern:/\/+$/.source,keyPrefix:"http.",keySuffix:"/.extraheader",valuePrefix:"Authorization: Bearer "});var l=Object.freeze({tokenEnv:"ARA_GIT_BROKER_TOKEN",reasonTokenEnv:"REASON_GIT_BROKER_TOKEN",urlEnv:"ARA_GIT_BROKER_URL",keyPrefix:"credential.",keySuffix:"/.helper",value:'!f(){ printf "username=%s\\npassword=%s\\n" "ara-run" "${REASON_GIT_BROKER_TOKEN:-$ARA_GIT_BROKER_TOKEN}"; };f'});var an=/^[A-Za-z_][A-Za-z0-9_]*$/;var h=new Set(["ARA_INFERENCE_TOKEN","AI_GATEWAY_API_KEY","CLOUD_AGENT_AI_GATEWAY_API_KEY","INFERENCE_V2_GATEWAY_API_KEY","VERCEL_AI_GATEWAY_API_KEY","INFERENCE_V2_CONCENTRATE_API_KEY","INFERENCE_V2_OPENAI_API_KEY","INFERENCE_V2_ANTHROPIC_API_KEY","INFERENCE_V2_FINGERPRINT_SECRET","OPENAI_API_KEY","OPENROUTER_API_KEY","ANTHROPIC_API_KEY","CODEX_ACCESS_TOKEN","GITHUB_COPILOT_API_KEY","AZURE_OPENAI_API_KEY","AZURE_OPENAI_CLIENT_SECRET"]),m=new Set(["ARA_OPERATOR_KEY","BL_API_KEY","BLAXEL_API_KEY","NSC_TOKEN","NSC_TOKEN_FILE","NAMESPACE_API_KEY","NAMESPACE_ACCESS_TOKEN","NAMESPACE_TOKEN","NAMESPACE_TOKEN_JSON","NAMESPACE_SANDBOX_TOKEN_JSON","ARA_LOCAL_QA_NAMESPACE_WORKLOAD_TOKEN_FILE","NAMESPACE_SANDBOX_USE_LOCAL_USER_TOKEN","COMPUTE_SERVICE_TOKEN"]),g=["INFISICAL_","NSC_"],_=new Set(["ARA_JOB_ENV","ARA_DELIVERY_BASE_SHA","WORK_ROOT","REPO_DIR","ARA_CONTROL_DIR","ARA_PRESERVE_WORKSPACE","ARA_PINNED_CHECKOUT_REUSE","FOLLOWUP_BRANCH","REPO_URL","TOKENLESS_URL","REPOSITORY_IDENTITY_URL","DEFAULT_BRANCH","BRANCH","BRANCH_GENERATED","BASE_REF","REPO_EMPTY","REPO_WRITABLE","ARA_DELIVERY_BASE_BRANCH","ARA_SERVER_GIT_PUBLICATION","ARA_EMPTY_REPOSITORY_COMMIT","REASON_MODEL","REASON_DELIVERY_BASE_BRANCH","REASON_DELIVERY_BASE_SHA","REASON_EMPTY_REPOSITORY_COMMIT","REASON_SCRATCH_SESSION_ID","REASON_SERVER_GIT_PUBLICATION","REASON_ALLOW_INSTALL_SCRIPTS","SCM_TOKEN","SCM_TOKEN_USER","REASON_OIDC_TOKEN_URL","REASON_OIDC_REQUEST_TOKEN","AWS_CONTAINER_CREDENTIALS_FULL_URI","AWS_CONTAINER_AUTHORIZATION_TOKEN","AWS_CONTAINER_CREDENTIALS_RELATIVE_URI","AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE","BASH_ENV","ENV","BASHOPTS","SHELLOPTS","PS4","IFS","CDPATH","GLOBIGNORE","PROMPT_COMMAND","PATH","HOME","TMPDIR","TMP","TEMP","XDG_CONFIG_HOME","GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_COMMON_DIR","GIT_NAMESPACE","GIT_CEILING_DIRECTORIES","GIT_DISCOVERY_ACROSS_FILESYSTEM","GIT_SHALLOW_FILE","GIT_ALLOW_PROTOCOL","GIT_PROTOCOL_FROM_USER","GIT_REPLACE_REF_BASE","NODE_OPTIONS","NODE_PATH","NODE_REPL_EXTERNAL_MODULES","CLASSPATH","PYTHONPATH","PYTHONSTARTUP","PYTHONHOME","RUBYOPT","RUBYLIB","PERL5LIB","PERL5OPT","JAVA_TOOL_OPTIONS","_JAVA_OPTIONS","JDK_JAVA_OPTIONS","GEM_PATH","GEM_HOME","GIT_SSH","GIT_SSH_COMMAND","GIT_EXEC_PATH","GIT_TEMPLATE_DIR","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_PROXY_COMMAND","GIT_EXTERNAL_DIFF","GIT_PAGER","GIT_EDITOR","GIT_ASKPASS","SSH_ASKPASS","PAGER","EDITOR","TAR_OPTIONS","CURL_HOME","WGETRC","APT_CONFIG","PERLLIB","GIT_GRAFT_FILE","POSIXLY_CORRECT"]),y=["GIT_TRACE","CONTEXT_REPO_","ARA_CHECKPOINT_BOOTSTRAP_","_","ARA_HANDS_","ARA_DEVICE_","ARA_GIT_BROKER_","REASON_HANDS_","REASON_DEVICE_","REASON_GIT_BROKER_","LD_","DYLD_","GIT_CONFIG","BASH_FUNC_"];var t="^(?!(?:"+[...h,...m,..._].join("|")+")$)(?!(?:"+[...g,...y].join("|")+"))"+an.source.slice(1),W=new RegExp(t);var v=["HOME","PWD","OLDPWD","TMPDIR","TMP","TEMP","SHELL","USER","LOGNAME","SCM_TOKEN","SCM_TOKEN_USER","GH_TOKEN","GITHUB_TOKEN","GH_ENTERPRISE_TOKEN","GITHUB_ENTERPRISE_TOKEN","GITLAB_TOKEN"],b=["ARA_HANDS_","ARA_DEVICE_","ARA_GIT_BROKER_","REASON_HANDS_","REASON_DEVICE_","REASON_GIT_BROKER_","BUN_"],E="^(?!(?:"+v.join("|")+")$)(?!(?:"+b.join("|")+"))"+t.slice(1),S="ARA_DELIVERY_BASE_SHA|WORK_ROOT|FOLLOWUP_BRANCH|ARA_PRESERVE_WORKSPACE|ARA_PINNED_CHECKOUT_REUSE|CONTEXT_REPO_[A-Z0-9_]+|REPO_URL|TOKENLESS_URL|REPOSITORY_IDENTITY_URL|DEFAULT_BRANCH|BRANCH|BRANCH_GENERATED|BASE_REF|REPO_EMPTY|REPO_WRITABLE|ARA_DELIVERY_BASE_BRANCH|ARA_SERVER_GIT_PUBLICATION|ARA_EMPTY_REPOSITORY_COMMIT|REASON_MODEL|REASON_DELIVERY_BASE_BRANCH|REASON_DELIVERY_BASE_SHA|REASON_EMPTY_REPOSITORY_COMMIT|REASON_SCRATCH_SESSION_ID|REASON_SERVER_GIT_PUBLICATION|REASON_ALLOW_INSTALL_SCRIPTS",n="^(?:"+S+"|"+E.slice(1,-1)+")$",w=new RegExp(n);function fi(u){return w.test(u)}var dr=Object.freeze({tokenPath:"/identity/token",awsPath:"/identity/aws",tokenPattern:/^[A-Za-z0-9_.~-]+$/.source}),Re=Object.freeze({variables:256,valueBytes:130816,snapshotBytes:1048576}),z=Object.freeze({valueChars:16384,snapshotBytes:65536});var c=["set -g history-limit 50000","set -g status off","set -g window-size smallest","set -gq fill-character ' '","set -g escape-time 10","set -g prefix None","set -g prefix2 None","set -g terminal-overrides ',*:smcup@:rmcup@'"];var U=2,H="ara-hands-worker.cjs",d=["/usr/local/go/bin","/opt/node/bin","/usr/local/bin","/usr/sbin","/usr/bin","/sbin","/bin","/usr/local/cargo/bin"],R=d.join(":"),I=["/opt/homebrew/bin",...d].join(":"),A='(platform, linuxPath, macosPath) => platform === "darwin" ? macosPath : linuxPath';var P=String.raw`(function(anchor, pid, native) {
313
313
  const token = native.identity(pid);
314
314
  const session = native.session(pid);
315
315
  if (!native.same(anchor)) throw new Error("pty_session_identity_lost");
@@ -348,7 +348,7 @@ function fileOperation(request) {
348
348
  require("node:fs").writeSync(3, "subreaper\n");
349
349
  api.execve(ptr(args[0]), ptr(argv), ptr(envp));
350
350
  throw new Error("pty_exec_failed");
351
- })`,Xc=String.raw`
351
+ })`,nl=String.raw`
352
352
  "use strict";
353
353
  const crypto = require("node:crypto");
354
354
  const fs = require("node:fs");
@@ -359,7 +359,7 @@ const { StringDecoder } = require("node:string_decoder");
359
359
  const GIT_BROKER_HTTP_HEADER_POLICY = ${JSON.stringify(a)};
360
360
  const GIT_BROKER_CREDENTIAL_HELPER_POLICY = ${JSON.stringify(l)};
361
361
  const DEVICE_ENVIRONMENT_NAME_RE = new RegExp(${JSON.stringify(n)});
362
- const DEVICE_CLOUD_ACCESS_POLICY = ${JSON.stringify(pr)};
362
+ const DEVICE_CLOUD_ACCESS_POLICY = ${JSON.stringify(dr)};
363
363
  const DEVICE_ENVIRONMENT_LIMITS = ${JSON.stringify(Re)};
364
364
 
365
365
  const VERSION = ${F};
@@ -369,33 +369,33 @@ const GUEST_MEMORY_UNAVAILABLE_REASONS = ${JSON.stringify(r)};
369
369
  const sampleGuestMemory = ${o};
370
370
  const inspectMacPtyMember = ${P};
371
371
  const probeLinuxPtyLibrary = ${k};
372
- const windowsPtyApi = ${dn};
372
+ const windowsPtyApi = ${gn};
373
373
  const LINUX_PTY_EXEC_SOURCE = ${JSON.stringify(N)};
374
- const CLOSE_CODES = ${JSON.stringify(ki)};
374
+ const CLOSE_CODES = ${JSON.stringify(Ai)};
375
375
  const SHA256_RE = /^[0-9a-f]{64}$/;
376
- const MAX_FRAME_BYTES = ${bi};
377
- const MAX_INPUT_CHARS = ${vi};
378
- const MAX_STRUCTURED_INPUT_CHARS = ${Mo};
376
+ const MAX_FRAME_BYTES = ${Ei};
377
+ const MAX_INPUT_CHARS = ${ki};
378
+ const MAX_STRUCTURED_INPUT_CHARS = ${jo};
379
379
  const MAX_OUTPUT_CHARS = ${_r};
380
- const WORKSPACE_BEFORE_MAX_OUTPUT_CHARS = ${Ho};
381
- const MAX_ERROR_CHARS = ${Bo};
380
+ const WORKSPACE_BEFORE_MAX_OUTPUT_CHARS = ${qo};
381
+ const MAX_ERROR_CHARS = ${Ho};
382
382
  const MAX_LEDGER_IDS = 16384;
383
383
  const MAX_CACHED_RESULTS = 256;
384
- const MAX_JOB_INPUT_CHARS = ${Si};
385
- const MAX_JOB_OUTPUT_CHARS = ${zt};
386
- const MAX_JOB_OUTPUT_CHUNKS = ${gt};
387
- const MAX_JOBS = ${Fo};
384
+ const MAX_JOB_INPUT_CHARS = ${xi};
385
+ const MAX_JOB_OUTPUT_CHARS = ${qt};
386
+ const MAX_JOB_OUTPUT_CHUNKS = ${_t};
387
+ const MAX_JOBS = ${Uo};
388
388
  const MAX_JOB_RECORD_BYTES = 262144;
389
389
  const MAX_JOB_JOURNAL_BYTES = MAX_JOBS * MAX_JOB_RECORD_BYTES;
390
- const MAX_JOB_CONTROL_FRAME_BYTES = ${qt};
390
+ const MAX_JOB_CONTROL_FRAME_BYTES = ${Wt};
391
391
  const MAX_PTY_INPUT_BYTES = ${He};
392
- const MAX_PTY_OUTPUT_BYTES = ${Wt};
393
- const MAX_PTY_DIMENSION = ${_t};
392
+ const MAX_PTY_OUTPUT_BYTES = ${Vt};
393
+ const MAX_PTY_DIMENSION = ${yt};
394
394
  const ID_RE = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,199}$/;
395
395
  const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
396
396
  const WINDOWS = process.platform === "win32";
397
397
  // Each Bash leader's tree on Windows, children that outlive it included (shared/windows-job-object.ts).
398
- const windowsJobs = WINDOWS ? ${Fn}(require) : null;
398
+ const windowsJobs = WINDOWS ? ${Un}(require) : null;
399
399
  /** Windows has no POSIX owner or mode bits: the user's own profile folders are
400
400
  * private by their ACLs, and the worker runs as that ordinary user. */
401
401
  function ownedPrivately(stat, mask = 0o077) {
@@ -492,9 +492,9 @@ function jobsUserPrefix(model) {
492
492
  return user ? ["/usr/bin/setpriv", "--reuid=" + user.uid, "--regid=" + gid, "--clear-groups", "--no-new-privs", "--",
493
493
  "/usr/bin/env", "HOME=" + user.home, "USER=" + user.username, "LOGNAME=" + user.username] : [];
494
494
  }
495
- const FIXED_CLOUD_CHILD_PATH = ${JSON.stringify(I)};
496
- const FIXED_MACOS_CLOUD_CHILD_PATH = ${JSON.stringify(A)};
497
- const selectCloudChildPath = ${T};
495
+ const FIXED_CLOUD_CHILD_PATH = ${JSON.stringify(R)};
496
+ const FIXED_MACOS_CLOUD_CHILD_PATH = ${JSON.stringify(I)};
497
+ const selectCloudChildPath = ${A};
498
498
  const config = JSON.parse(fs.readFileSync(process.argv[2], "utf8"));
499
499
  const FIXED_BASH = WINDOWS ? config.bashExecutable : "/bin/bash";
500
500
  const allowedTools = config.allowedTools === undefined
@@ -577,12 +577,12 @@ function validJobEnvSourcePath() {
577
577
  if (config.jobEnvSourcePath === undefined || config.jobEnvSourcePath === path.join(config.workRoot, "job.env")) return true;
578
578
  // A cloud workspace's job.env is in its Session's root-only control
579
579
  // directory (shared/device-workspace.ts), derived from the root alone.
580
- const cloud = new RegExp(${JSON.stringify(Nn.source)}).exec(config.workRoot);
580
+ const cloud = new RegExp(${JSON.stringify(Mn.source)}).exec(config.workRoot);
581
581
  if (process.platform === "linux" && cloud) {
582
582
  const workspaceId = cloud[3];
583
- const owner = (new RegExp(${JSON.stringify(ji.source)}).exec(workspaceId) || [])[1]
584
- ?? (new RegExp(${JSON.stringify(Hi.source)}).exec(workspaceId) || [])[1] ?? workspaceId;
585
- return config.jobEnvSourcePath === ${JSON.stringify(Fi)} + "/" + owner + "/job.env";
583
+ const owner = (new RegExp(${JSON.stringify(zi.source)}).exec(workspaceId) || [])[1]
584
+ ?? (new RegExp(${JSON.stringify(qi.source)}).exec(workspaceId) || [])[1] ?? workspaceId;
585
+ return config.jobEnvSourcePath === ${JSON.stringify(Ui)} + "/" + owner + "/job.env";
586
586
  }
587
587
  // Personal Cloud controls are root-owned and outside the writable grant.
588
588
  // Admit only the same canonical session, never a caller-selected private path.
@@ -1027,7 +1027,7 @@ function initializeJobs() {
1027
1027
  // (shared/local-protected-paths.ts) that the file tools and every confinement
1028
1028
  // refuse. A home-folder worker keeps it in ~/.config/reason, so its Session may
1029
1029
  // work in the home folder itself, as a Mac's home grant does.
1030
- const PROTECTED_STATE_DIRECTORIES = ${JSON.stringify(bt)};
1030
+ const PROTECTED_STATE_DIRECTORIES = ${JSON.stringify(vt)};
1031
1031
  function stateOverlapsWorkspace(state, root) {
1032
1032
  if (pathWithin(root, state)) return true;
1033
1033
  if (!pathWithin(state, root)) return false;
@@ -2347,7 +2347,7 @@ function windowsPtyOperation(request, managed) {
2347
2347
  try {
2348
2348
  if (pty.activeProcesses() > 0) pty.terminate();
2349
2349
  for (const startedAt = Date.now(); pty.activeProcesses() > 0;) {
2350
- if (Date.now() - startedAt > ${hn}) throw new Error("pty_cleanup_timeout");
2350
+ if (Date.now() - startedAt > ${yn}) throw new Error("pty_cleanup_timeout");
2351
2351
  await new Promise((resolve) => setTimeout(resolve, 20));
2352
2352
  }
2353
2353
  pty.close();
@@ -2795,7 +2795,7 @@ function ptyOperation(request, managed, program = TERMINAL_SHELL) {
2795
2795
  const { members, empty } = native.session(anchor, device);
2796
2796
  try {
2797
2797
  if (empty && exitCode !== null && subreaper) break;
2798
- if (Date.now() - startedAt > ${hn}) throw new Error("pty_cleanup_timeout");
2798
+ if (Date.now() - startedAt > ${yn}) throw new Error("pty_cleanup_timeout");
2799
2799
  for (const token of members) {
2800
2800
  if (!native.same(anchor)) throw new Error("pty_session_identity_lost");
2801
2801
  const id = native.identityKey(token);
@@ -2811,7 +2811,7 @@ function ptyOperation(request, managed, program = TERMINAL_SHELL) {
2811
2811
  controlReleased = true;
2812
2812
  let exitTimer;
2813
2813
  try { await Promise.race([child.exited, new Promise((_, reject) => {
2814
- exitTimer = setTimeout(() => reject(new Error("pty_anchor_exit_unconfirmed")), ${Ei});
2814
+ exitTimer = setTimeout(() => reject(new Error("pty_anchor_exit_unconfirmed")), ${Ci});
2815
2815
  })]); } finally { clearTimeout(exitTimer); }
2816
2816
  if (timedOut) finish("timeout", 124);
2817
2817
  else if (cancelled) finish("cancelled", 130);
@@ -3362,10 +3362,10 @@ const PI_EXIT_STDIO_GRACE_MS = 100;
3362
3362
  // the token once under quoteDepth layers of single quoting, so the confined
3363
3363
  // script is byte-identical to what the Brain's confineBashPayload gives the
3364
3364
  // bash tool: srt/bwrap, the payload uid, the network allowlist and allowWrite.
3365
- const PI_TOOL_CONFINEMENT_TOKEN = "${oc}";
3365
+ const PI_TOOL_CONFINEMENT_TOKEN = "${hc}";
3366
3366
  function validPiToolConfinement(value) {
3367
3367
  return hasOnlyKeys(value, ["template", "quoteDepth"]) && typeof value.template === "string"
3368
- && value.template.length <= ${sc} && !value.template.includes("\0")
3368
+ && value.template.length <= ${fc} && !value.template.includes("\0")
3369
3369
  && value.template.split(PI_TOOL_CONFINEMENT_TOKEN).length === 2 && [1, 2, 3].includes(value.quoteDepth);
3370
3370
  }
3371
3371
  // The script T when this command is exactly this policy's confineBashPayload(T)
@@ -4176,5 +4176,5 @@ void startJobControl().then(() => {
4176
4176
  try { loadJobs(); prepareRequestJournal(); } catch { process.exit(44); }
4177
4177
  if (validPrivateJob) markReady(); else connect();
4178
4178
  }, () => process.exit(45));
4179
- `.trimStart();var R=O("sha256").update(Xc,"utf8").digest("hex"),Ro={42:"worker_config_invalid",43:"workspace_alias_failed",44:"job_journal_unavailable",45:"job_control_failed",46:"job_journal_owned"};
4180
- export{tn,hi,pr,Re,U,H,Xc,R,Ro};
4179
+ `.trimStart();var T=O("sha256").update(nl,"utf8").digest("hex"),Ro={42:"worker_config_invalid",43:"workspace_alias_failed",44:"job_journal_unavailable",45:"job_control_failed",46:"job_journal_owned"};
4180
+ export{an,fi,dr,Re,U,H,nl,T,Ro};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- var Fn=String.raw`(function(require) {
2
+ var Un=String.raw`(function(require) {
3
3
  if (process.platform !== "win32") return null;
4
4
  let ffi, kernel32;
5
5
  try {
@@ -64,4 +64,4 @@ var Fn=String.raw`(function(require) {
64
64
  },
65
65
  };
66
66
  })`;
67
- export{Fn};
67
+ export{Un};
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{L}from"./vm-hands-entry-lite-ptycjmkc.js";import{Y,Rt,Me,It,Be}from"./vm-hands-entry-lite-8xv6c0rm.js";import{spawn as y}from"child_process";import{existsSync as p,mkdirSync as T,readFileSync as _,writeFileSync as A}from"fs";import{homedir as g}from"os";import{basename as H,delimiter as E,join as f,win32 as u}from"path";var Bt=process.platform==="win32"?Rt("win32"):"/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",P=Bt.split(E),R=5000,S=65536,O=new Set(["zsh","bash"]),b=[[".local","bin"],[".bun","bin"],[".cargo","bin"],["go","bin"]],x=(t,e)=>new Promise((n,r)=>{let o;try{o=y(t,[...e],{...Me(),stdio:["ignore","pipe","ignore"]}),It(o)}catch(c){r(c);return}let i=[],s=0,a=null,d=(c)=>{a??=Error(c);try{if(o.pid!==void 0)Be(o.pid,"SIGKILL")}catch{}},m=setTimeout(()=>d("login_shell_timeout"),R);o.stdout?.on("data",(c)=>{if(s+=c.length,s>S)d("login_shell_output_too_large");else i.push(c)}),o.once("error",(c)=>{clearTimeout(m),r(c)}),o.once("close",(c)=>{if(clearTimeout(m),a)r(a);else if(c!==0)r(Error("login_shell_exit_nonzero"));else n(Buffer.concat(i).toString("utf8"))})});function w(t){return typeof t==="string"&&t.startsWith("/")&&!t.includes("\x00")&&O.has(H(t))}function h(t){let e=new Set,n=[];for(let r of t){if(e.has(r))continue;e.add(r),n.push(r)}return n}function pi(t,e=process.platform){let n=e==="win32",r=t.split(`
3
- `).at(-1)??"",o=[];for(let i of r.split(n?";":":")){let s=i.trim();if(n?!u.isAbsolute(s):!s.startsWith("/"))continue;if(s.includes("\x00"))continue;if(L(s))continue;o.push(s)}return h(o)}function Ao(t){let e=t?.home??g(),n=t?.directoryExists??p,r=b.map((o)=>f(e,...o)).filter((o)=>{try{return n(o)}catch{return!1}});return h([...r,...process.platform==="win32"?pi(process.env.PATH??process.env.Path??""):[],...P]).join(E)}async function C(t){let e=t?.shell??process.env.SHELL,n=()=>({path:Ao({home:t?.home,directoryExists:t?.directoryExists}),source:"fallback"});if(process.platform==="win32"||!w(e))return n();let r;try{r=await(t?.runLoginShell??x)(e,["-lic",'printf %s "$PATH"'])}catch{return n()}if(Buffer.byteLength(r,"utf8")>S)return n();let o=pi(r);if(o.length===0)return n();return{path:h([...o,...P]).join(":"),source:"login_shell"}}function tc(t){let e=null;return()=>(e??=C(t),e)}function l(t){if(t===void 0||t.includes("\x00")||Buffer.byteLength(t,"utf8")>32768)return;return t}function je(t){let e=t.source??process.env,n={HOME:t.home,PATH:t.path??Bt,TMPDIR:t.temporaryDirectory,SHELL:l(e.SHELL)??"/bin/zsh",LANG:l(e.LANG)??"C.UTF-8",LC_ALL:l(e.LC_ALL)??l(e.LANG)??"C.UTF-8"},r=l(e.LC_CTYPE),o=l(e.TERM),i=l(e.COLORTERM);if(r)n.LC_CTYPE=r;if(o)n.TERM=o;if(i)n.COLORTERM=i;if(process.platform==="win32"){for(let s of I){let a=l(e[s]);if(a)n[s]=a}n.TEMP=n.TMP=t.temporaryDirectory,n.SHELL=Y()??n.SHELL,n.PATH=Po(n.PATH)}return n}function Po(t,e=f(g(),".reason","python3")){let n=(i)=>t.split(u.delimiter).filter((s)=>s&&!/[\\/]WindowsApps[\\/]?$/i.test(s)).map((s)=>u.join(s,i)).find((s)=>p(s)),r=n("python.exe");if(n("python3.exe")||!r)return t;let o=`#!/bin/sh
2
+ import{L}from"./vm-hands-entry-lite-fccn6s4j.js";import{Y,Tt,Me,Dt,Be}from"./vm-hands-entry-lite-pg7nnyc6.js";import{spawn as y}from"child_process";import{existsSync as p,mkdirSync as T,readFileSync as _,writeFileSync as A}from"fs";import{homedir as g}from"os";import{basename as H,delimiter as E,join as f,win32 as u}from"path";var Ft=process.platform==="win32"?Tt("win32"):"/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",P=Ft.split(E),R=5000,S=65536,O=new Set(["zsh","bash"]),b=[[".local","bin"],[".bun","bin"],[".cargo","bin"],["go","bin"]],x=(t,e)=>new Promise((n,r)=>{let o;try{o=y(t,[...e],{...Me(),stdio:["ignore","pipe","ignore"]}),Dt(o)}catch(c){r(c);return}let i=[],s=0,a=null,d=(c)=>{a??=Error(c);try{if(o.pid!==void 0)Be(o.pid,"SIGKILL")}catch{}},m=setTimeout(()=>d("login_shell_timeout"),R);o.stdout?.on("data",(c)=>{if(s+=c.length,s>S)d("login_shell_output_too_large");else i.push(c)}),o.once("error",(c)=>{clearTimeout(m),r(c)}),o.once("close",(c)=>{if(clearTimeout(m),a)r(a);else if(c!==0)r(Error("login_shell_exit_nonzero"));else n(Buffer.concat(i).toString("utf8"))})});function w(t){return typeof t==="string"&&t.startsWith("/")&&!t.includes("\x00")&&O.has(H(t))}function h(t){let e=new Set,n=[];for(let r of t){if(e.has(r))continue;e.add(r),n.push(r)}return n}function gi(t,e=process.platform){let n=e==="win32",r=t.split(`
3
+ `).at(-1)??"",o=[];for(let i of r.split(n?";":":")){let s=i.trim();if(n?!u.isAbsolute(s):!s.startsWith("/"))continue;if(s.includes("\x00"))continue;if(L(s))continue;o.push(s)}return h(o)}function Io(t){let e=t?.home??g(),n=t?.directoryExists??p,r=b.map((o)=>f(e,...o)).filter((o)=>{try{return n(o)}catch{return!1}});return h([...r,...process.platform==="win32"?gi(process.env.PATH??process.env.Path??""):[],...P]).join(E)}async function C(t){let e=t?.shell??process.env.SHELL,n=()=>({path:Io({home:t?.home,directoryExists:t?.directoryExists}),source:"fallback"});if(process.platform==="win32"||!w(e))return n();let r;try{r=await(t?.runLoginShell??x)(e,["-lic",'printf %s "$PATH"'])}catch{return n()}if(Buffer.byteLength(r,"utf8")>S)return n();let o=gi(r);if(o.length===0)return n();return{path:h([...o,...P]).join(":"),source:"login_shell"}}function lc(t){let e=null;return()=>(e??=C(t),e)}function l(t){if(t===void 0||t.includes("\x00")||Buffer.byteLength(t,"utf8")>32768)return;return t}function je(t){let e=t.source??process.env,n={HOME:t.home,PATH:t.path??Ft,TMPDIR:t.temporaryDirectory,SHELL:l(e.SHELL)??"/bin/zsh",LANG:l(e.LANG)??"C.UTF-8",LC_ALL:l(e.LC_ALL)??l(e.LANG)??"C.UTF-8"},r=l(e.LC_CTYPE),o=l(e.TERM),i=l(e.COLORTERM);if(r)n.LC_CTYPE=r;if(o)n.TERM=o;if(i)n.COLORTERM=i;if(process.platform==="win32"){for(let s of I){let a=l(e[s]);if(a)n[s]=a}n.TEMP=n.TMP=t.temporaryDirectory,n.SHELL=Y()??n.SHELL,n.PATH=Do(n.PATH)}return n}function Do(t,e=f(g(),".reason","python3")){let n=(i)=>t.split(u.delimiter).filter((s)=>s&&!/[\\/]WindowsApps[\\/]?$/i.test(s)).map((s)=>u.join(s,i)).find((s)=>p(s)),r=n("python.exe");if(n("python3.exe")||!r)return t;let o=`#!/bin/sh
4
4
  exec "${r.replaceAll("\\","/")}" "$@"
5
5
  `;try{let i=f(e,"python3");if(!p(i)||_(i,"utf8")!==o)T(e,{recursive:!0}),A(i,o)}catch{return t}return[e,t].join(u.delimiter)}var I=["SystemRoot","SystemDrive","windir","ComSpec","PATHEXT","USERPROFILE","USERNAME","USERDOMAIN","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","CommonProgramFiles","NUMBER_OF_PROCESSORS","PROCESSOR_ARCHITECTURE","OS"];
6
- export{Bt,pi,Ao,tc,je,Po};
6
+ export{Ft,gi,Io,lc,je,Do};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{B}from"./vm-hands-entry-lite-8xv6c0rm.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFileSync as h}from"child_process";import{mkdirSync as k,readdirSync as D,readFileSync as w,rmSync as g,statSync as x,writeFileSync as L}from"fs";import{join as p,sep as y}from"path";import{setTimeout as _}from"timers/promises";var P=3000,u=null;function S(e){return p(e,"users")}function Br(e){if(u?.root===e.root)return;let o=S(e.root);k(o,{recursive:!0,mode:448}),L(p(o,String(process.pid)),"",{mode:384}),u=e}function kl(){if(!u)return;g(p(S(u.root),String(process.pid)),{force:!0}),u=null}function m(e){try{return process.kill(e,0),!0}catch(o){return o instanceof Error&&"code"in o&&o.code==="EPERM"}}function E(){let e=process.getuid?.();if(process.platform==="linux")return D("/proc").flatMap((n)=>{if(!/^\d+$/.test(n))return[];try{if(x(`/proc/${n}`).uid!==e)return[];let s=w(`/proc/${n}/cmdline`).toString("utf8").split("\x00").join(" ").trim();return s?[{pid:Number(n),command:s}]:[]}catch{return[]}});if(process.platform==="win32")return h(B("powershell.exe"),["-NoLogo","-NoProfile","-NonInteractive","-Command",'Get-CimInstance Win32_Process | ForEach-Object { "$($_.ProcessId) $($_.CommandLine)" }'],{encoding:"utf8",maxBuffer:16777216,windowsHide:!0}).split(/\r?\n/).flatMap((s)=>{let l=/^(\d+) (.+)$/.exec(s.trim());return l?[{pid:Number(l[1]),command:l[2]}]:[]});return h("/bin/ps",["-axww","-o","pid=,uid=,command="],{encoding:"utf8",maxBuffer:16777216}).split(`
3
- `).flatMap((n)=>{let s=/^\s*(\d+)\s+(\d+)\s+(.+)$/.exec(n);return s&&Number(s[2])===e?[{pid:Number(s[1]),command:s[3]}]:[]})}async function ua(){let e=u;if(!e)return{released:"unused",stopped:0};let o=S(e.root);g(p(o,String(process.pid)),{force:!0}),u=null;let n=!1;for(let t of D(o)){let c=Number(t);if(Number.isSafeInteger(c)&&c>0&&m(c))n=!0;else g(p(o,t),{force:!0})}if(n)return{released:"shared",stopped:0};let s=E().filter((t)=>t.pid!==process.pid&&(t.command.includes(`${e.root}${y}`)||t.command.includes(`${e.automation}${y}`)||t.command.includes(e.extensionDir))),l=(t,c)=>{try{process.kill(t,c)}catch{}};for(let t of s)l(t.pid,"SIGTERM");for(let t=Date.now()+P;Date.now()<t&&s.some((c)=>m(c.pid));)await new Promise((c)=>setTimeout(c,100));for(let t of s)if(m(t.pid))l(t.pid,"SIGKILL");return{released:"stopped",stopped:s.length}}var M=20000,N=30000,O=100,a=new Map,i=null,b=0,f=[];function da(e){a.set(e,(a.get(e)??0)+1);let o=!1;return()=>{if(o)return;o=!0;let n=(a.get(e)??1)-1;if(n>0){a.set(e,n);return}if(a.delete(e),i?.run===e)i.idleUntil=0}}function T(){return new r("automation_desktop_busy","Another Session, or another agent of this Session, is using this worker's desktop. Retry after it finishes.")}function U(e,o){return i!==null&&i.run!==e&&(i.calls>0||o<i.idleUntil)}async function pa(e,o,n=Date.now,s="run"){let l=Symbol(e);f.push(l);try{let d=n()+N;for(;;){if(b===0&&!U(e,n())&&(i?.run===e||f[0]===l))break;if(n()>=d)throw T();await _(O,void 0,{signal:o}).catch(()=>o.throwIfAborted())}}finally{f.splice(f.indexOf(l),1)}if(s==="call"&&!(i?.run===e&&(i.calls>0||n()<i.idleUntil))){b+=1;let d=!1;return()=>{if(d)return;d=!0,b-=1}}if(i?.run!==e)i={run:e,calls:0,idleUntil:0};let t=i;t.calls+=1;let c=!1;return()=>{if(c)return;c=!0,t.calls-=1,t.idleUntil=n()+M}}
4
- export{Br,kl,ua,da,pa};
2
+ import{B}from"./vm-hands-entry-lite-pg7nnyc6.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFileSync as h}from"child_process";import{mkdirSync as k,readdirSync as D,readFileSync as w,rmSync as g,statSync as x,writeFileSync as L}from"fs";import{join as p,sep as y}from"path";import{setTimeout as _}from"timers/promises";var P=3000,u=null;function S(e){return p(e,"users")}function qr(e){if(u?.root===e.root)return;let o=S(e.root);k(o,{recursive:!0,mode:448}),L(p(o,String(process.pid)),"",{mode:384}),u=e}function Dl(){if(!u)return;g(p(S(u.root),String(process.pid)),{force:!0}),u=null}function m(e){try{return process.kill(e,0),!0}catch(o){return o instanceof Error&&"code"in o&&o.code==="EPERM"}}function E(){let e=process.getuid?.();if(process.platform==="linux")return D("/proc").flatMap((n)=>{if(!/^\d+$/.test(n))return[];try{if(x(`/proc/${n}`).uid!==e)return[];let s=w(`/proc/${n}/cmdline`).toString("utf8").split("\x00").join(" ").trim();return s?[{pid:Number(n),command:s}]:[]}catch{return[]}});if(process.platform==="win32")return h(B("powershell.exe"),["-NoLogo","-NoProfile","-NonInteractive","-Command",'Get-CimInstance Win32_Process | ForEach-Object { "$($_.ProcessId) $($_.CommandLine)" }'],{encoding:"utf8",maxBuffer:16777216,windowsHide:!0}).split(/\r?\n/).flatMap((s)=>{let l=/^(\d+) (.+)$/.exec(s.trim());return l?[{pid:Number(l[1]),command:l[2]}]:[]});return h("/bin/ps",["-axww","-o","pid=,uid=,command="],{encoding:"utf8",maxBuffer:16777216}).split(`
3
+ `).flatMap((n)=>{let s=/^\s*(\d+)\s+(\d+)\s+(.+)$/.exec(n);return s&&Number(s[2])===e?[{pid:Number(s[1]),command:s[3]}]:[]})}async function ya(){let e=u;if(!e)return{released:"unused",stopped:0};let o=S(e.root);g(p(o,String(process.pid)),{force:!0}),u=null;let n=!1;for(let t of D(o)){let c=Number(t);if(Number.isSafeInteger(c)&&c>0&&m(c))n=!0;else g(p(o,t),{force:!0})}if(n)return{released:"shared",stopped:0};let s=E().filter((t)=>t.pid!==process.pid&&(t.command.includes(`${e.root}${y}`)||t.command.includes(`${e.automation}${y}`)||t.command.includes(e.extensionDir))),l=(t,c)=>{try{process.kill(t,c)}catch{}};for(let t of s)l(t.pid,"SIGTERM");for(let t=Date.now()+P;Date.now()<t&&s.some((c)=>m(c.pid));)await new Promise((c)=>setTimeout(c,100));for(let t of s)if(m(t.pid))l(t.pid,"SIGKILL");return{released:"stopped",stopped:s.length}}var M=20000,N=30000,O=100,a=new Map,i=null,b=0,f=[];function wa(e){a.set(e,(a.get(e)??0)+1);let o=!1;return()=>{if(o)return;o=!0;let n=(a.get(e)??1)-1;if(n>0){a.set(e,n);return}if(a.delete(e),i?.run===e)i.idleUntil=0}}function T(){return new r("automation_desktop_busy","Another Session, or another agent of this Session, is using this worker's desktop. Retry after it finishes.")}function U(e,o){return i!==null&&i.run!==e&&(i.calls>0||o<i.idleUntil)}async function ba(e,o,n=Date.now,s="run"){let l=Symbol(e);f.push(l);try{let d=n()+N;for(;;){if(b===0&&!U(e,n())&&(i?.run===e||f[0]===l))break;if(n()>=d)throw T();await _(O,void 0,{signal:o}).catch(()=>o.throwIfAborted())}}finally{f.splice(f.indexOf(l),1)}if(s==="call"&&!(i?.run===e&&(i.calls>0||n()<i.idleUntil))){b+=1;let d=!1;return()=>{if(d)return;d=!0,b-=1}}if(i?.run!==e)i={run:e,calls:0,idleUntil:0};let t=i;t.calls+=1;let c=!1;return()=>{if(c)return;c=!0,t.calls-=1,t.idleUntil=n()+M}}
4
+ export{qr,Dl,ya,wa,ba};
@@ -0,0 +1,48 @@
1
+ // @bun
2
+ import{D,Dn,ds,Pr,ps,hs}from"./vm-hands-entry-lite-13nx02p7.js";import{wc,bc,A,Zo}from"./vm-hands-entry-lite-pe374cn6.js";import{Ue}from"./vm-hands-entry-lite-chq0qx9f.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFile as xt,spawn as _e}from"child_process";import{existsSync as vt}from"fs";import{connect as Et}from"net";function dt(){let e=new Set,t=null,s=(n)=>({holder:t?.viewer??null,you:t===n,same_user:Boolean(t?.viewer&&n.viewer&&t.viewer.user_id===n.viewer.user_id)}),i=()=>{for(let n of e)n.notify(s(n))};return{join(n){return e.add(n),n.notify(s(n)),()=>{if(!e.delete(n))return;if(t!==n)return;t=null,i()}},claim(n){if(t===n||!e.has(n))return;t=n,i()}}}var Ce=dt();import{spawn as pt}from"child_process";import{existsSync as ft}from"fs";import{connect as mt}from"net";import{join as j}from"path";var ze="reason_desktop",N={sampleRate:48000,channels:2,codec:"opus"},ht=5000,yt=107,gt=262144,Vo=(e)=>j(e,"native"),Kt=(e)=>`unix:${e}`;function he(e,t=1000){if(!ft(e))return Promise.resolve(!1);return new Promise((s)=>{let i=mt({path:e}),n=(l)=>{i.destroy(),s(l)};i.setTimeout(t,()=>n(!1)),i.once("error",()=>n(!1)),i.once("close",()=>n(!1)),i.once("connect",()=>n(!0))})}async function _c(e,t){if(!t)return null;let s=Vo(e);if(Buffer.byteLength(s)>yt||/["'\\\s]/.test(s))return null;try{if(await he(s))return s;let i=pt(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:${j(e,"pulseaudio.log")}`,"-n",`--load=module-native-protocol-unix socket="${s}" auth-anonymous=1 auth-cookie-enabled=0`,`--load=module-null-sink sink_name=${ze} rate=${N.sampleRate} channels=${N.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:j(e,"runtime"),PULSE_STATE_PATH:j(e,"state")}});Ue(i.pid);let n=!1;i.once("error",()=>{n=!0}),i.once("exit",()=>{n=!0}),i.unref();let l=Date.now()+ht;while(Date.now()<l){if(await he(s))return s;if(n)return await he(s)?s:null;await new Promise((c)=>setTimeout(c,50))}if(!n)i.kill("SIGKILL");return null}catch{return null}}function Oe(){let{sampleRate:e,channels:t}=N;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",`${ze}.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 bt=[79,103,103,83],wt=Buffer.from("OpusHead"),_t=Buffer.from("OpusTags"),Be=(e,t)=>e.byteLength>=t.byteLength&&t.every((s,i)=>e[i]===s);class ye extends Error{constructor(e){super(e);this.name="OggProtocolError"}}class ge{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 s=[],i=0;while(t.byteLength-i>=27){if(bt.some((b,f)=>t[i+f]!==b)||t[i+4]!==0)throw new ye("invalid_page");let n=(t[i+5]&1)!==0,l=t[i+26];if(t.byteLength-i<27+l)break;let c=t.subarray(i+27,i+27+l),h=c.reduce((b,f)=>b+f,0),g=27+l+h;if(t.byteLength-i<g)break;if(!n&&this.partialBytes>0)this.resetPartial();let m=n&&this.partialBytes===0,p=i+27+l,w=p;for(let b of c){if(p+=b,b===255)continue;if(this.appendPartial(t.subarray(w,p),m),w=p,!m){let f=this.takePartial();if(f.byteLength>0&&!Be(f,wt)&&!Be(f,_t))s.push(f)}m=!1,this.resetPartial()}if(w<p)this.appendPartial(t.subarray(w,p),m);i+=g}return this.buffer=t.slice(i),s}appendPartial(e,t){if(t||e.byteLength===0)return;if(this.partialBytes+=e.byteLength,this.partialBytes>gt)throw new ye("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 s of this.partial)e.set(s,t),t+=s.byteLength;return e}resetPartial(){this.partial=[],this.partialBytes=0}}import{spawn as kt}from"child_process";var Ve=1048576,St=String.raw`
3
+ import gi, json, os, sys
4
+ gi.require_version("Gtk", "3.0")
5
+ from gi.repository import Gtk, Gdk, GLib
6
+ if not Gtk.init_check()[0]:
7
+ sys.exit(1)
8
+ clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
9
+ pending = b""
10
+ generation = 0
11
+ def send(value):
12
+ print(json.dumps(value, ensure_ascii=True), flush=True)
13
+ def changed(clipboard, event):
14
+ global generation
15
+ generation += 1
16
+ current = generation
17
+ def received(clipboard, text, unused):
18
+ if current == generation and text is not None and len(text.encode("utf-8")) <= ${D}:
19
+ send({"text": text})
20
+ clipboard.request_text(received, None)
21
+ # No request_text on startup: never share the pre-existing clipboard.
22
+ clipboard.connect("owner-change", changed)
23
+ def input_ready(fd, condition):
24
+ global pending
25
+ chunk = os.read(fd, 65536)
26
+ if not chunk:
27
+ Gtk.main_quit()
28
+ return False
29
+ pending += chunk
30
+ while b"\n" in pending:
31
+ line, pending = pending.split(b"\n", 1)
32
+ text = json.loads(line)
33
+ if not isinstance(text, str) or len(text.encode("utf-8")) > ${D} or "\x00" in text:
34
+ sys.exit(1)
35
+ clipboard.set_text(text, -1)
36
+ send("ack")
37
+ if len(pending) > ${D*6+2}:
38
+ sys.exit(1)
39
+ return True
40
+ GLib.io_add_watch(0, GLib.IO_IN | GLib.IO_HUP, input_ready)
41
+ send("ready")
42
+ Gtk.main()
43
+ `;function Ne(e,t){let s=kt("/usr/bin/python3",["-I","-u","-c",St],{env:{DISPLAY:e.display,XAUTHORITY:e.xauthority},stdio:["pipe","pipe","ignore"]}),i=!1,n=!0,l="",c=0,h=[],g=setTimeout(()=>p(),5000),m=()=>{i=!0,clearTimeout(g),h.length=0,s.kill("SIGKILL")},p=()=>{if(i)return;m(),t.end({error:new r("display_unavailable","Reason could not start this Linux desktop's UTF-8 clipboard.")})},w=(b,f=32)=>{if(i)return;if(!n){b();return}if(c+=f,c>Ve)m(),t.end({reason:"input_backpressure"});else h.push({apply:b,bytes:f})};return s.stdout.on("data",(b)=>{if(i)return;l+=b.toString("ascii");for(let f=l.indexOf(`
44
+ `);f>=0;f=l.indexOf(`
45
+ `)){let T=l.slice(0,f);l=l.slice(f+1);let x;try{x=JSON.parse(T)}catch{p();return}if(x==="ready"||x==="ack"){clearTimeout(g),n=!1;while(!n&&!i&&h.length){let d=h.shift();c-=d.bytes,d.apply()}}else if(x&&typeof x==="object"&&"text"in x&&typeof x.text==="string"&&Buffer.byteLength(x.text)<=D)t.clipboard(x.text);else{p();return}if(i)return}if(l.length>D*6+32)p()}),s.stdin.on("error",p),s.once("error",p),s.once("exit",p),{apply:w,write(b){if(Buffer.byteLength(b)>D||b.includes("\x00")){p();return}let f=`${JSON.stringify(b)}
46
+ `;w(()=>{if(n=!0,g=setTimeout(()=>p(),5000),s.stdin.write(f),s.stdin.writableLength>Ve)m(),t.end({reason:"input_backpressure"})},Buffer.byteLength(f))},close:m}}var z={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}},Dt="avc1.4D002A",Ge={width:1920,height:1080},Mt=262144,Pt=0.2,It=250,Lt=1e4,At=1024,be=1e4,Rt=500,Tt=60,Ct=1e4,Bt=1000,Fe=1048576,Ut=-223,zt=-308,Go={kind:"mac_screen",sound:null},Ko={kind:"windows_screen",sound:null},Ot,He=()=>Ot??=A()?.ffmpeg??null,Z=(e,t,s)=>_e(e,t,{env:s,stdio:["ignore","pipe","ignore"],windowsHide:!0}),Vt,ke=()=>Vt??=Zo(A()),$e=(e,t,s)=>{let[i,...n]=[...ke(),e];return Z(i,[...n,...t],s)},Ke=()=>nt?.videotoolbox?"h264_videotoolbox":"libx264",Nt=()=>Math.round(performance.now()*1000),we=new Set,qe=!1;function Je(e){if(we.add(e),e.once("exit",()=>we.delete(e)),qe)return;qe=!0,process.once("exit",()=>{for(let t of we)try{t.kill("SIGKILL")}catch{}})}function Ze(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{}},Rt);e.once("exit",()=>clearTimeout(t))}function Gt(e,t,s){return{args:["-f","x11grab","-draw_mouse","1","-framerate",String(e),"-video_size",`${t.width}x${t.height}`,"-i",s],size:t}}function Ft(e){return{args:["-f","avfoundation","-capture_cursor","1","-pixel_format","nv12","-framerate",String(e),"-i","Capture screen 0:none"],size:null}}function Ht(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 $t(e){return{args:["-probesize","32","-analyzeduration","0","-f","image2pipe","-c:v","mjpeg","-framerate",String(e),"-i","pipe:0"],size:null}}var Qe=1700000;function et(e){return Math.min(1,Math.round(Math.sqrt(Qe/(e.width*e.height))*100)/100)}function qt(e,t,s){let i=_e(s.axe,["stream-video","--udid",s.udid,"--format","ffmpeg","--fps","30","--quality","85","--scale",String(Math.min(0.99,et(s.size)))],{stdio:["ignore","pipe","ignore"]}),n=_e(e,t,{env:{},stdio:["pipe","pipe","ignore"]});i.stdout.pipe(n.stdin),n.stdin.on("error",()=>{});let l=()=>{if(i.exitCode===null&&i.signalCode===null)i.kill("SIGTERM")};return n.once("exit",l),n.once("error",l),i.once("exit",()=>{if(n.exitCode===null&&n.signalCode===null)n.kill("SIGTERM")}),i.once("error",()=>{if(n.exitCode===null&&n.signalCode===null)n.kill("SIGTERM")}),n}function We(e){let t=Math.min(1,Ge.width/e.width,Ge.height/e.height);return{width:Math.round(e.width*t),height:Math.round(e.height*t)}}function J(e,t,s,i="libx264"){let n=z[e],l=(w)=>Math.max(2,Math.floor(w/2)*2),c={width:l(s.width*n.scale),height:l(s.height*n.scale)},h=c.width!==t.size?.width||c.height!==t.size.height,g=Math.max(1,Math.round(n.kbps*2/n.fps)),m=["-g",String(n.fps*Tt)],p=i==="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",...m,"-b:v",`${n.kbps}k`,"-maxrate",`${n.kbps}k`,"-bufsize",`${g}k`,"-bsf:v","h264_metadata=aud=insert"]:["-c:v","libx264","-preset",n.x264Preset,"-tune","zerolatency","-profile:v","main","-level","4.2","-bf","0","-pix_fmt","yuv420p",...n.threads?["-threads",String(n.threads)]:[],"-x264-params","aud=1:repeat-headers=1",...m,"-crf",String(n.crf),"-maxrate",`${n.kbps}k`,"-bufsize",`${g}k`];return["-hide_banner","-loglevel","error","-nostdin","-fflags","nobuffer",...t.args,"-an",...h?["-vf",`scale=${c.width}:${c.height}:flags=fast_bilinear`]:[],...p,"-flush_packets","1","-f","h264","pipe:1"]}class tt{buffer=new Uint8Array(0);scanned=0;key=!1;micros=0;push(e,t){if(this.buffer.byteLength===0)this.micros=t;let s=new Uint8Array(this.buffer.byteLength+e.byteLength);s.set(this.buffer),s.set(e,this.buffer.byteLength),this.buffer=s;let i=[],n=this.scanned;while(n+3<this.buffer.byteLength){if(this.buffer[n]!==0||this.buffer[n+1]!==0||this.buffer[n+2]!==1){n++;continue}let l=this.buffer[n+3]&31,c=n>0&&this.buffer[n-1]===0?n-1:n;if(l===9&&c>0)i.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,n-=c;if(l===5)this.key=!0;n+=3}return this.scanned=n,i}}function Wt(e,t){let s=Et({path:e}),i=Buffer.alloc(0),n="version",l=0,c=!1,h=[],g=0,m=!1,p=(d)=>{if(m)return;m=!0,s.destroy(),t.end(d)},w=()=>p({reason:"display_protocol"}),b=(d)=>{if(m)return;if(!c){if(g+=d.byteLength,g>Fe)p({reason:"input_backpressure"});else h.push(d);return}if(s.write(d),s.writableLength>Fe)p({reason:"input_backpressure"})},f=(d)=>{i=i.subarray(d)},T=()=>{switch(n){case"version":{if(i.byteLength<12)return!1;let d=/^RFB (\d{3})\.(\d{3})\n$/.exec(i.subarray(0,12).toString("latin1"));if(!d||Number(d[1])*1000+Number(d[2])<3007)return w(),!1;return f(12),s.write(`RFB 003.007
47
+ `),n="security",!0}case"security":{if(i.byteLength<1)return!1;let d=i[0];if(d===0)return w(),!1;if(i.byteLength<1+d)return!1;if(!i.subarray(1,1+d).includes(1))return w(),!1;return f(1+d),s.write(Buffer.from([1,1])),n="init",!0}case"init":{if(i.byteLength<24)return!1;let d=i.readUInt32BE(20);if(d>65536)return w(),!1;if(i.byteLength<24+d)return!1;let S={width:i.readUInt16BE(0),height:i.readUInt16BE(2)};if(f(24+d),S.width===0||S.height===0)return w(),!1;n="messages";let _=Buffer.alloc(12);_.writeUInt8(2,0),_.writeUInt16BE(2,2),_.writeInt32BE(zt,4),_.writeInt32BE(Ut,8),s.write(_),c=!0;for(let v of h)s.write(v);return h=[],g=0,t.ready(S),!m}case"skip":{let d=Math.min(l,i.byteLength);if(f(d),l-=d,l>0)return!1;return n="messages",!0}case"messages":{if(i.byteLength<1)return!1;switch(i[0]){case 1:{if(i.byteLength<6)return!1;let d=6+i.readUInt16BE(4)*6;if(i.byteLength<d)return!1;return f(d),!0}case 2:return f(1),!0;case 3:{if(i.byteLength<8)return!1;let d=i.readUInt32BE(4);if(d>D/2)return f(8),n="skip",l=d,!0;if(i.byteLength<8+d)return!1;let S=i.subarray(8,8+d).toString("latin1");return f(8+d),t.clipboard(S),!m}default:return w(),!1}}}},x=!1;return s.once("connect",()=>{x=!0}),s.on("data",(d)=>{if(m)return;i=i.byteLength?Buffer.concat([i,d]):d;while(!m&&T());}),s.once("error",()=>{if(!x)p({error:new r("display_unavailable","Reason could not reach this machine's desktop server.")})}),s.once("close",()=>p({reason:"display_closed"})),{pointer(d,S,_){let v=Buffer.alloc(6);v.writeUInt8(5,0),v.writeUInt8(_&255,1),v.writeUInt16BE(d,2),v.writeUInt16BE(S,4),b(v)},key(d,S){let _=Buffer.alloc(8);_.writeUInt8(4,0),_.writeUInt8(d?1:0,1),_.writeUInt32BE(S>>>0,4),b(_)},clipboard(d){if(Array.from(d).some((v)=>v.codePointAt(0)>255)){p({reason:"clipboard_unicode_unsupported"});return}let S=Buffer.from(d,"latin1"),_=Buffer.alloc(8);_.writeUInt8(6,0),_.writeUInt32BE(S.byteLength,4),b(Buffer.concat([_,S]))},close(){m=!0,s.destroy()}}}class Se{run=null;viewers=new Set;get running(){return this.run!==null}start(e,t,s,i){this.viewers.add(e),this.stop();let n;try{n=s()}catch{this.fail();return}Je(n);let l={child:n,splitter:new tt};this.run=l;for(let h of[...this.viewers])h.started(t);n.stdout?.on("data",(h)=>{if(this.run!==l)return;for(let g of l.splitter.push(h,i()))for(let m of[...this.viewers])m.unit(g)});let c=()=>{if(this.run!==l)return;this.run=null,this.fail()};n.once("exit",c),n.once("error",c)}leave(e){if(!this.viewers.delete(e))return;if(this.viewers.size===0)this.stop()}stop(){if(!this.run)return;Ze(this.run.child),this.run=null}fail(){for(let e of[...this.viewers])e.failed()}}var Xe=new WeakMap;function Xt(e){let t=Xe.get(e);if(!t)Xe.set(e,t=new Se);return t}var G=new Map;function Jo(e,t,s={}){let i=s.micros??Nt,n=new ds,l=t.request.preset,c=null,h=null,g=null,m=!1,p=null,w=!1,b=!1,f=null,T=0,x=0,d=!1,S=null,_=null,v=0,Q=null,I=[],F=0,L=[],xe=new Uint32Array(be+1),ee=0,te=null,ne=0,O=0,re=0,ve=0,Ee=0,H=null,ie=0,C={frames:0,bytes:0,since:i()},B=[],V=0,se,oe=!1,it=i(),M={},U=()=>Math.round((i()-it)/1000),De=s.control??Ce,ae=null,le=null,Me=0,ue=!1,Pe={pause(){if(!p?.running)return;p.stop(),ue=!0},adopt(o){let a=o!==null&&(o.width!==h?.width||o.height!==h?.height);if(a)h=o;if(!a&&!ue)return;if(ue=!1,p)Y();else pe()}},st=(o)=>{if(!s.resizeDesktop||!c||"kind"in c||e.done)return;let a=c.display,u=()=>[...G.get(a)??[]];Me++,s.resizeDesktop(c,o,()=>{for(let y of u())y.pause()}).then((y)=>{for(let k of u())k.adopt(y)})},P=(o)=>{let a=Dn(o);return e.send(a),ve+=a.byteLength,a.byteLength},K=(o)=>{if(e.done)return;if(e.open)P({type:"error",code:o});e.end({reason:o})},q=()=>Math.max(Mt,z[l].kbps*1000/8*Pt),W=()=>i()/1000,ot=()=>{while(L.length>1&&L[0].atMs<W()-Lt)L.shift();return L[0]?.rttMs??null},Ie=(o)=>{let a=ot();if(a===null||I.length===0)return!1;let u=(a+It)*o;return W()-I[0].sentMs>u||F>u/1000*z[l].kbps*1000/8},at=(o)=>{if(v===0)return;let a=Math.min(o,v-1);if(Q!==null&&a<=Q)return;Q=a;let u=W();while(I.length&&I[0].seq<=a){let y=I.shift();if(F-=y.bytes,y.seq!==a)continue;let k=Math.max(0,u-y.sentMs);while(L.length&&L.at(-1).rttMs>=k)L.pop();L.push({atMs:u,rttMs:k}),xe[Math.min(be,Math.round(k))]++,ee++,te=Math.min(te??k,k)}},lt=()=>{let o=0;for(let a=0;a<=be;a++)if(o+=xe[a],o*2>=ee)return a;return 0},ut=()=>e.bufferedAmount<=q()/2&&!Ie(0.5),Le=()=>{oe=!0,B=[],V=0,p?.leave(ce),p=null},Ae=(o)=>{if(e.done)return;if(o.key)M.first_key_ms??=U();if(!m){if(!p||B.length===0&&!o.key)return;if(B.push(o),V+=o.data.byteLength,V>q())Le();return}if(d){O++;return}if(e.bufferedAmount>q()||Ie(1)){d=!0,O++,S=setInterval(()=>{if(e.done||!ut())return;if(S)clearInterval(S);S=null,d=!1,Y()},s.drainPollMs??25);return}if(!w){if(!o.key){O++;return}if(P({type:"hello",width:h.width,height:h.height,fps:z[l].fps,preset:l,codec:Dt}),w=!0,M.first_frame_ms??=U(),!b&&c?.sound)P({type:"audioHello",...N}),b=!0}let a=P({type:"frame",key:o.key,seq:v,captureMicros:o.micros,data:o.data});if(I.push({seq:v,sentMs:W(),bytes:a}),F+=a,I.length>At)F-=I.shift().bytes;v++,ne++,H??=o.micros,ie=o.micros,C.frames++,C.bytes+=a},ce={started(o){l=o,w=!1,B=[],V=0},unit:Ae,failed:()=>K("encoder_failed")},de=()=>{let o=(s.ffmpeg??He)();if(!c||!h){K("encoder_failed");return}let[a,u]=[c,h],y="kind"in a&&a.kind==="simulator"?a.stream:null;if(!o&&!y){K("encoder_failed");return}if(p??="kind"in a&&a.kind==="mac_screen"?Xt(s.spawn??$e):new Se,M.encoder_ms===void 0)M.encoder_ms=U(),M.encoder_shared=p.running;p.start(ce,l,()=>{let k=z[l].fps;if(y)return y(k,z[l].kbps,Qe);if("kind"in a&&a.kind==="simulator"){let E=Math.min(0.99,et(a.size)),R={width:a.size.width*E,height:a.size.height*E};return qt(o,J(l,$t(Math.min(k,30)),R,(s.macEncoder??Ke)()),a)}if("kind"in a&&a.kind==="windows_screen")return(s.spawn??Z)(o,J(l,Ht(k,u),We(u)),{SystemRoot:process.env.SystemRoot??"C:\\Windows"});return"kind"in a?(s.spawn??$e)(o,J(l,Ft(k),We(u),(s.macEncoder??Ke)()),{}):(s.spawn??Z)(o,J(l,Gt(k,u,a.display),u),{DISPLAY:a.display,XAUTHORITY:a.xauthority})},i)},X=()=>{if(!f)return;Ze(f.child),f=null},ct=()=>{let o=(s.ffmpeg??He)();if(f||e.done||!b||!c?.sound||!o)return;let a;try{a=(s.spawn??Z)(o,Oe(),{PULSE_SERVER:Kt(c.sound)})}catch{return}Je(a);let u={child:a,reader:new ge};f=u,a.stdout?.on("data",(k)=>{if(f!==u||e.done)return;let E;try{E=u.reader.push(k)}catch{X();return}let R=i();for(let me of E){if(e.bufferedAmount>q()){x++;continue}P({type:"audio",captureMicros:R,data:me}),T++}});let y=()=>{if(f===u)X()};a.once("exit",y),a.once("error",y)},Y=()=>{if(!p||e.done)return;re++,de()},pe=()=>{if(e.done||!h)return;if(!m){if(p||oe)return;de(),se=setTimeout(()=>{if(!m)Le()},Ct);return}if(clearTimeout(se),M.encoder_early===void 0){if(M.encoder_early=p!==null,oe)M.hold_lapsed=!0}if(!p)de();let o=B;B=[],V=0;for(let a of o)Ae(a);_??=setInterval(()=>{let a=i(),u=Math.max(0.001,(a-C.since)/1e6);P({type:"stats",stats:{fps:Math.round(C.frames/u*10)/10,kbps:Math.round(C.bytes*8/1000/u),dropped:O,restarts:re,queued_bytes:e.bufferedAmount}}),C={frames:0,bytes:0,since:a}},Bt)};t.desktop.then((o)=>{if(e.done)return;c=o;let a={ready(u){h=u,M.desktop_ms??=U(),pe()},clipboard(u){if(e.open&&Buffer.byteLength(u)<=D)P({type:"serverClipboard",text:u})},end(u){if("reason"in u&&e.open)P({type:"error",code:u.reason});e.end(u)}};if("kind"in o&&o.kind==="simulator")g=o.input,a.ready(o.points);else if("kind"in o&&o.kind==="windows_screen")g=(s.windowsInput??bc)(a);else if("kind"in o)g=(s.macInput??((u)=>hs(u,ke())))(a);else{let u=G.get(o.display);if(!u)G.set(o.display,u=new Set);u.add(Pe);let y=(s.linuxClipboard??Ne)(o,a),k=Wt(o.rfbSocket,{...a,clipboard:(E)=>{if(!y)a.clipboard(E)}});g=y?{pointer:(E,R,me)=>y.apply(()=>k.pointer(E,R,me)),key:(E,R)=>y.apply(()=>k.key(E,R)),clipboard:(E)=>y.write(E),close(){y.close(),k.close()}}:k}Re()},(o)=>e.end({error:o}));function Re(){if(le||!t.viewerSameNetwork||!m||e.done||!c||!("kind"in c)||c.kind!=="mac_screen")return;le=(s.macWindows??ps)((o)=>{if(e.open)P({type:"windows",bounds:o})})}let Te={viewer:t.viewer??null,notify(o){if(e.open)P({type:"control",control:o})}},fe=(o)=>{if(!g)return;if(!c||!("kind"in c)||c.kind!=="simulator")De.claim(Te);o(g)};return{opened(){M.relay_ms??=U()},received(o){Ee+=o.byteLength;let a;try{a=n.push(o)}catch{K("viewer_protocol");return}for(let u of a){if(e.done)return;switch(u.type){case"ping":P({type:"pong",token:u.token});break;case"pointer":fe((y)=>y.pointer(u.x,u.y,u.buttons));break;case"key":fe((y)=>y.key(u.down,u.keysym));break;case"clientClipboard":fe((y)=>y.clipboard(u.text));break;case"config":if(u.preset!==l)l=u.preset,Y();break;case"keyframeRequest":if(w&&!d)Y();break;case"ack":at(u.seq);break;case"audioEnable":if(u.on)ct();else X();break;case"resize":st({width:u.width,height:u.height});break;default:break}}if(!m&&!e.done){if(m=!0,M.viewer_ms=U(),t.viewer)ae=De.join(Te);pe(),Re()}},close(){if(c&&!("kind"in c)){let o=G.get(c.display);if(o?.delete(Pe),o?.size===0)G.delete(c.display)}if(ae?.(),ae=null,le?.close(),S)clearInterval(S);if(_)clearInterval(_);clearTimeout(se),p?.leave(ce),X(),g?.close()},summary:()=>({output_bytes:ve,input_bytes:Ee,video:{preset:l,frames:ne,dropped:O,restarts:re,avg_fps:H!==null&&ie>H?Math.round((ne-1)/((ie-H)/1e6)*10)/10:0,min_rtt_ms:Math.round(te??0),p50_rtt_ms:ee?lt():0,audio_packets:T,audio_dropped:x,resizes:Me,connect:M}})}}var Ye=null,nt=null,Yt=null,jt=null;function Zt(){let e=A();return e?.features.display?e.ffmpeg:null}function rt(e){return Ye??=new Promise((t)=>{xt(e,["-hide_banner","-encoders"],{env:{},timeout:5000,killSignal:"SIGKILL",maxBuffer:1048576,encoding:"utf8"},(s,i)=>{let n=(l)=>!s&&new RegExp(`^\\s*V\\S*\\s+${l}\\s`,"m").test(i);t(nt={x264:n("libx264"),videotoolbox:n("h264_videotoolbox")})})}),Ye}var je=null;function Xo(){return je??=(async()=>{let e=[A()?.ffmpeg,"/opt/homebrew/bin/ffmpeg","/usr/local/bin/ffmpeg"].find((s)=>Boolean(s&&vt(s)));if(!e)return null;let t=await rt(e);return t.videotoolbox||t.x264?e:null})(),je}function Jt(e=process.platform,t={}){if(e!=="linux"&&e!=="darwin"&&e!=="win32")return Promise.resolve(!1);let s=(t.ffmpeg??Zt)();if(!s)return Promise.resolve(!1);let i=(t.encoders??rt)(s);if(e==="linux")return i.then((l)=>l.x264);if(e==="win32"){let l=t.windowsScreen?t.windowsScreen():jt??=wc();return Promise.all([i,l]).then(([c,h])=>c.x264&&(h?.session??0)>0)}let n=t.macScreen?t.macScreen():Yt??=Pr(ke());return Promise.all([i,n]).then(([l,c])=>(l.x264||l.videotoolbox)&&c?.screen===!0&&c.accessibility)}
48
+ export{Vo,Kt,_c,Go,Ko,Jo,Xo,Jt};
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{g}from"./vm-hands-entry-lite-bj3w2ven.js";import{s}from"./vm-hands-entry-lite-zawytz09.js";import{randomUUID as P}from"crypto";import{spawnSync as b}from"child_process";import{chmodSync as z,cpSync as Z,existsSync as x,lstatSync as A,mkdirSync as L,readdirSync as ee,readFileSync as C,readlinkSync as te,realpathSync as T,renameSync as _,rmdirSync as ne,rmSync as y,symlinkSync as D,writeFileSync as re}from"fs";import{dirname as h,join as u,relative as ie,resolve as oe}from"path";var ss="so.ara.cli",w=[ss,"com.reasonmachines.cli"],$i="5LJFSBRY2F";function Mi(e){return`(${e.map((t)=>`identifier "${t}"`).join(" or ")}) and anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] exists and certificate leaf[field.1.2.840.113635.100.6.1.13] exists and certificate leaf[subject.OU] = "${$i}"`}var Y="ReasonBackgroundIdentity",Ic="Contents/Helpers/ReasonPermissionTile",se="so.ara.cli.permission-tile",be=Mi([se,"com.reasonmachines.cli.permission-tile"]),k="AraBackgroundIdentity",ce="Reason",Ae=Mi(w),ae=`anchor apple generic and (${w.map((e)=>`identifier "${e}"`).join(" or ")}) and certificate leaf[subject.OU] = "${$i}"`;class vt extends Error{code;constructor(e,t){super(t);this.code=e;this.name="MacOSBackgroundIdentityError"}}var Tn="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";function ot(e=s()){return u(e,"Library","Application Support","Reason","Background","Reason.app")}function O(e=s()){return u(e,"Library","Application Support","Ara","Background","Ara.app")}function ue(e){try{return A(e).isFile()}catch{return!1}}function v(e){return[Y,k].map((t)=>u(e,"Contents","MacOS",t)).find(ue)??null}function d(e){try{if(!A(e).isDirectory())return!1;let t=C(u(e,"Contents","Info.plist"),"utf8");return w.some((n)=>t.includes(`<string>${n}</string>`))&&(t.includes(`<string>${ce}</string>`)||t.includes("<string>Ara</string>"))&&v(e)!==null}catch{return!1}}function Yt(e=s()){let t=ot(e);if(!d(t))return null;try{let n=C(u(t,"Contents","Info.plist"),"utf8");return/<key>CFBundleVersion<\/key>\s*<string>(\d+\.\d+\.\d+)<\/string>/.exec(n)?.[1]??null}catch{return null}}function as(e,t=s()){let n=Yt(t);return n===null||V(R(n.split(".")),R(e.split(/[.-]/).slice(0,3)))}var le=1e4;function F(e,t){return b(e,[...t],{stdio:"ignore",timeout:le}).status??1}var G=new Set;function K(e){if(process.env.REASON_TEST_REFUSE_REAL_IDENTITY!=="1")return;let t=(n)=>{try{return T(n)}catch{return oe(n)}};if(e!==void 0&&t(e)!==t(s()))return;throw Error("A test tried to change this computer's real Reason background identity; pass a temporary home. Refused by scripts/test-env.ts.")}var W=/\/(?:runtime|CLI)\/versions\/(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$|\/\.(?:ara|reason)(?:-staging)?-worker-(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$/,H=new Set(["ara","ara.exe","reason","reason.exe"]);function R(e){return e.map((t)=>Number(t))}function V(e,t){for(let n=0;n<3;n+=1)if(e[n]!==t[n])return e[n]<t[n];return!1}var de=[0,2,161];function fe(e){if(e===null)return!0;let t=de,n=null;try{n=T(process.execPath)}catch{}return e.some((r)=>{let i=W.exec(r);if(i){let f=i[1]===void 0?i.slice(4,7):i.slice(1,4);return V(R(f),t)}let o=r.slice(r.lastIndexOf("/")+1);return H.has(o)&&r!==n&&r!==process.execPath})}function pe(){let e=b("/bin/ps",["-xo","pid=,comm="],{encoding:"utf8",timeout:5000});if(e.status!==0)return null;let t=[];for(let n of e.stdout.split(`
2
+ import{g}from"./vm-hands-entry-lite-1w39j6vz.js";import{s}from"./vm-hands-entry-lite-12ck5swp.js";import{randomUUID as P}from"crypto";import{spawnSync as b}from"child_process";import{chmodSync as z,cpSync as Z,existsSync as x,lstatSync as A,mkdirSync as L,readdirSync as ee,readFileSync as C,readlinkSync as te,realpathSync as T,renameSync as _,rmdirSync as ne,rmSync as y,symlinkSync as D,writeFileSync as re}from"fs";import{dirname as h,join as u,relative as ie,resolve as oe}from"path";var fs="so.ara.cli",w=[fs,"com.reasonmachines.cli"],Fi="5LJFSBRY2F";function ji(e){return`(${e.map((t)=>`identifier "${t}"`).join(" or ")}) and anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] exists and certificate leaf[field.1.2.840.113635.100.6.1.13] exists and certificate leaf[subject.OU] = "${Fi}"`}var Y="ReasonBackgroundIdentity",Bc="Contents/Helpers/ReasonPermissionTile",se="so.ara.cli.permission-tile",be=ji([se,"com.reasonmachines.cli.permission-tile"]),k="AraBackgroundIdentity",ce="Reason",Ae=ji(w),ae=`anchor apple generic and (${w.map((e)=>`identifier "${e}"`).join(" or ")}) and certificate leaf[subject.OU] = "${Fi}"`;class St extends Error{code;constructor(e,t){super(t);this.code=e;this.name="MacOSBackgroundIdentityError"}}var On="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";function st(e=s()){return u(e,"Library","Application Support","Reason","Background","Reason.app")}function O(e=s()){return u(e,"Library","Application Support","Ara","Background","Ara.app")}function ue(e){try{return A(e).isFile()}catch{return!1}}function v(e){return[Y,k].map((t)=>u(e,"Contents","MacOS",t)).find(ue)??null}function d(e){try{if(!A(e).isDirectory())return!1;let t=C(u(e,"Contents","Info.plist"),"utf8");return w.some((n)=>t.includes(`<string>${n}</string>`))&&(t.includes(`<string>${ce}</string>`)||t.includes("<string>Ara</string>"))&&v(e)!==null}catch{return!1}}function Yt(e=s()){let t=st(e);if(!d(t))return null;try{let n=C(u(t,"Contents","Info.plist"),"utf8");return/<key>CFBundleVersion<\/key>\s*<string>(\d+\.\d+\.\d+)<\/string>/.exec(n)?.[1]??null}catch{return null}}function ms(e,t=s()){let n=Yt(t);return n===null||V(R(n.split(".")),R(e.split(/[.-]/).slice(0,3)))}var le=1e4;function F(e,t){return b(e,[...t],{stdio:"ignore",timeout:le}).status??1}var G=new Set;function K(e){if(process.env.REASON_TEST_REFUSE_REAL_IDENTITY!=="1")return;let t=(n)=>{try{return T(n)}catch{return oe(n)}};if(e!==void 0&&t(e)!==t(s()))return;throw Error("A test tried to change this computer's real Reason background identity; pass a temporary home. Refused by scripts/test-env.ts.")}var W=/\/(?:runtime|CLI)\/versions\/(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$|\/\.(?:ara|reason)(?:-staging)?-worker-(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$/,H=new Set(["ara","ara.exe","reason","reason.exe"]);function R(e){return e.map((t)=>Number(t))}function V(e,t){for(let n=0;n<3;n+=1)if(e[n]!==t[n])return e[n]<t[n];return!1}var de=[0,2,161];function fe(e){if(e===null)return!0;let t=de,n=null;try{n=T(process.execPath)}catch{}return e.some((r)=>{let i=W.exec(r);if(i){let f=i[1]===void 0?i.slice(4,7):i.slice(1,4);return V(R(f),t)}let o=r.slice(r.lastIndexOf("/")+1);return H.has(o)&&r!==n&&r!==process.execPath})}function pe(){let e=b("/bin/ps",["-xo","pid=,comm="],{encoding:"utf8",timeout:5000});if(e.status!==0)return null;let t=[];for(let n of e.stdout.split(`
3
3
  `)){let r=/^\s*(\d+)\s+(\S.*)$/.exec(n);if(!r||Number(r[1])===process.pid)continue;let i=r[2].trimEnd(),o=i.slice(i.lastIndexOf("/")+1);if(!W.test(i)&&H.has(o)){let a=b("/usr/sbin/lsof",["-a","-p",r[1],"-d","txt","-Fn"],{encoding:"utf8",timeout:5000}).stdout?.split(`
4
- `).find((l)=>l.startsWith("n/"));if(a)i=a.slice(1)}t.push(i)}return t}function cs(e){if(K(e.home),!d(e.sourceApp))throw new vt("identity_invalid","The packaged Reason background identity is missing or invalid.");let t=e.command??F,n=ot(e.home),r=h(n);L(r,{recursive:!0,mode:448}),z(r,448);let i=T(e.sourceApp),o=null;try{o=T(n)}catch{}if(i!==o){let f=`${process.pid}.${P()}`,a=u(r,`.Reason.app.${f}.tmp`),l=u(r,`.Reason.app.${f}.old`),m=!1;try{if(Z(i,a,{recursive:!0,errorOnExist:!0,preserveTimestamps:!0}),!d(a))throw new vt("identity_invalid","The copied Reason background identity is invalid.");let S=e.releaseSigned?["--test-requirement",`=${ae}`]:[];if(t("/usr/bin/codesign",["--verify","--strict",...S,a])!==0)throw new vt("identity_invalid_signature","The installed Reason background identity has an invalid signature.");let I=!1;for(let p=0;p<4;p+=1){let E=!1;try{_(n,l),E=!0,m=!0}catch(c){if(c.code!=="ENOENT")throw c}if(p===0)e.beforePublish?.();try{_(a,n),I=!0}catch(c){let Q=c.code;if(!["EEXIST","ENOTEMPTY"].includes(Q??""))throw c;if(E)y(l,{recursive:!0,force:!0}),m=!1;if(p===3)throw c;continue}if(E)y(l,{recursive:!0,force:!0}),m=!1;break}if(!I)throw Error("Could not publish Reason's background identity.")}catch(S){if(m&&!x(n)&&x(l))_(l,n);throw S}finally{y(a,{recursive:!0,force:!0}),y(l,{recursive:!0,force:!0})}}return q(n,e,{verified:i!==o}),n}function J(e){return u(h(e),".Reason.app.registered")}function j(e){try{let t=A(e);return t.isDirectory()?`${t.ino}:${t.birthtimeMs}`:null}catch{return null}}function N(e){let t=j(e);try{return t!==null&&C(J(e),"utf8")===t}catch{return!1}}function X(e){if(d(e))return"bundle";try{if(A(u(e,"Contents","Info.plist"),{throwIfNoEntry:!1}))return null;return A(u(e,"Contents","MacOS",k)).isSymbolicLink()?"retired":null}catch{return null}}function q(e,t,n={}){let r=t.command??F;if(!n.verified&&r("/usr/bin/codesign",["--verify","--strict",e])!==0)throw new vt("identity_invalid_signature","The installed Reason background identity has an invalid signature.");if(r(Tn,["-f",e])!==0)throw new vt("identity_register_failed","Could not register Reason's macOS background identity.");let i=j(e);try{if(i)re(J(e),i,{mode:384})}catch{}try{ge(e,t.home,r,t.runningExecutables??pe)}catch(o){let f=o.code??"unknown";process.stderr.write(`Reason background identity: legacy_identity_retire_failed (${f})
5
- `)}}function ge(e,t,n,r){let i=v(e);if(!i)return;let o=O(t),f=h(o),a=(c)=>u(c,"Contents","MacOS",k),l=ie(h(a(o)),i),m=`${process.pid}.${P()}`,S=X(o);if(S===null)return;let I=S==="bundle";if(I)n(Tn,["-u",o]);let p=u(f,`.Ara.app.${m}.old`);if(!G.has(o)&&!fe(r())){if(!I)n(Tn,["-u",o]);try{_(o,p)}catch(c){if(c.code==="ENOENT")return;throw c}y(p,{recursive:!0,force:!0}),ye(f);return}if(!I){if(te(a(o))===l)return;let c=`${a(o)}.${m}`;D(l,c);try{_(c,a(o))}finally{y(c,{force:!0})}return}let E=u(f,`.Ara.app.${m}.shim`);L(h(a(E)),{recursive:!0}),D(l,a(E));try{try{_(o,p)}catch(c){if(c.code==="ENOENT")return;throw c}try{_(E,o)}catch(c){if(x(o))return;throw _(p,o),c}}finally{y(E,{recursive:!0,force:!0}),y(p,{recursive:!0,force:!0})}}function ye(e){try{if(ee(e).some((n)=>n!==".DS_Store"))return;y(u(e,".DS_Store"),{force:!0}),ne(e)}catch{}}var M=new Map;function ls(e=s()){let t=M.get(e);if(t)return t;if(process.platform!=="darwin")return[];let n=B(e);if(n===null&&x(h(ot(e))))Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,100),n=B(e);if(n===null)return[];return M.set(e,n),n}function B(e){let t=ot(e),n=O(e);if(!d(t)||!N(t))try{Bi({home:e,skipWhenSettled:!0})}catch{}let r=d(t)&&(N(t)||!d(n))?t:d(n)?n:null,i=r?v(r):null;if(!i)return null;if(r===n)G.add(n);let o=b(i,["--can-spawn"],{env:{},timeout:2000,encoding:"utf8"});return o.status===0&&o.stdout===`spawn
6
- `?[i,"--spawn"]:[]}var U=new Map;function kr(e=s()){let t=ls(e),n=t[0];if(!n)return[];let r=U.get(n);if(r===void 0){let i=b(n,["--can-spawn-computer-use"],{env:{},timeout:2000,encoding:"utf8"});r=i.status===0&&i.stdout===`spawn
7
- `,U.set(n,r)}return r?t:[]}function In(e=kr(),t=s()){if(e.length>0)return null;if(Yt(t)===null)return"computer_use_identity_missing";return as(g,t)?"computer_use_identity_outdated":"computer_use_identity_unavailable"}function Bi(e={}){K(e.home);let t=ot(e.home);if(e.skipWhenSettled&&d(t)&&N(t)&&X(O(e.home))===null)return!0;if(!d(t)){let n=O(e.home);if(!d(n))return!1;try{return cs({...e,sourceApp:n}),!0}catch(r){if(!d(t))throw r}}return q(t,e),!0}var Dn="REASON_WORKER_IDENTITY_APP";function Dc(e,t=process.env,n=s()){let r=t[Dn];return r&&r===ot(n)?r:e}function Oc(e,t){if(process.platform!=="darwin")return null;let n=ot(e),r=u(n,"Contents","MacOS",Y),i=b(r,["--can-run-worker",t],{env:{},timeout:2000,encoding:"utf8"});return i.status===0&&i.stdout===`run-worker
4
+ `).find((l)=>l.startsWith("n/"));if(a)i=a.slice(1)}t.push(i)}return t}function gs(e){if(K(e.home),!d(e.sourceApp))throw new St("identity_invalid","The packaged Reason background identity is missing or invalid.");let t=e.command??F,n=st(e.home),r=h(n);L(r,{recursive:!0,mode:448}),z(r,448);let i=T(e.sourceApp),o=null;try{o=T(n)}catch{}if(i!==o){let f=`${process.pid}.${P()}`,a=u(r,`.Reason.app.${f}.tmp`),l=u(r,`.Reason.app.${f}.old`),m=!1;try{if(Z(i,a,{recursive:!0,errorOnExist:!0,preserveTimestamps:!0}),!d(a))throw new St("identity_invalid","The copied Reason background identity is invalid.");let S=e.releaseSigned?["--test-requirement",`=${ae}`]:[];if(t("/usr/bin/codesign",["--verify","--strict",...S,a])!==0)throw new St("identity_invalid_signature","The installed Reason background identity has an invalid signature.");let I=!1;for(let p=0;p<4;p+=1){let E=!1;try{_(n,l),E=!0,m=!0}catch(c){if(c.code!=="ENOENT")throw c}if(p===0)e.beforePublish?.();try{_(a,n),I=!0}catch(c){let Q=c.code;if(!["EEXIST","ENOTEMPTY"].includes(Q??""))throw c;if(E)y(l,{recursive:!0,force:!0}),m=!1;if(p===3)throw c;continue}if(E)y(l,{recursive:!0,force:!0}),m=!1;break}if(!I)throw Error("Could not publish Reason's background identity.")}catch(S){if(m&&!x(n)&&x(l))_(l,n);throw S}finally{y(a,{recursive:!0,force:!0}),y(l,{recursive:!0,force:!0})}}return q(n,e,{verified:i!==o}),n}function J(e){return u(h(e),".Reason.app.registered")}function j(e){try{let t=A(e);return t.isDirectory()?`${t.ino}:${t.birthtimeMs}`:null}catch{return null}}function N(e){let t=j(e);try{return t!==null&&C(J(e),"utf8")===t}catch{return!1}}function X(e){if(d(e))return"bundle";try{if(A(u(e,"Contents","Info.plist"),{throwIfNoEntry:!1}))return null;return A(u(e,"Contents","MacOS",k)).isSymbolicLink()?"retired":null}catch{return null}}function q(e,t,n={}){let r=t.command??F;if(!n.verified&&r("/usr/bin/codesign",["--verify","--strict",e])!==0)throw new St("identity_invalid_signature","The installed Reason background identity has an invalid signature.");if(r(On,["-f",e])!==0)throw new St("identity_register_failed","Could not register Reason's macOS background identity.");let i=j(e);try{if(i)re(J(e),i,{mode:384})}catch{}try{ge(e,t.home,r,t.runningExecutables??pe)}catch(o){let f=o.code??"unknown";process.stderr.write(`Reason background identity: legacy_identity_retire_failed (${f})
5
+ `)}}function ge(e,t,n,r){let i=v(e);if(!i)return;let o=O(t),f=h(o),a=(c)=>u(c,"Contents","MacOS",k),l=ie(h(a(o)),i),m=`${process.pid}.${P()}`,S=X(o);if(S===null)return;let I=S==="bundle";if(I)n(On,["-u",o]);let p=u(f,`.Ara.app.${m}.old`);if(!G.has(o)&&!fe(r())){if(!I)n(On,["-u",o]);try{_(o,p)}catch(c){if(c.code==="ENOENT")return;throw c}y(p,{recursive:!0,force:!0}),ye(f);return}if(!I){if(te(a(o))===l)return;let c=`${a(o)}.${m}`;D(l,c);try{_(c,a(o))}finally{y(c,{force:!0})}return}let E=u(f,`.Ara.app.${m}.shim`);L(h(a(E)),{recursive:!0}),D(l,a(E));try{try{_(o,p)}catch(c){if(c.code==="ENOENT")return;throw c}try{_(E,o)}catch(c){if(x(o))return;throw _(p,o),c}}finally{y(E,{recursive:!0,force:!0}),y(p,{recursive:!0,force:!0})}}function ye(e){try{if(ee(e).some((n)=>n!==".DS_Store"))return;y(u(e,".DS_Store"),{force:!0}),ne(e)}catch{}}var M=new Map;function _s(e=s()){let t=M.get(e);if(t)return t;if(process.platform!=="darwin")return[];let n=B(e);if(n===null&&x(h(st(e))))Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,100),n=B(e);if(n===null)return[];return M.set(e,n),n}function B(e){let t=st(e),n=O(e);if(!d(t)||!N(t))try{Hi({home:e,skipWhenSettled:!0})}catch{}let r=d(t)&&(N(t)||!d(n))?t:d(n)?n:null,i=r?v(r):null;if(!i)return null;if(r===n)G.add(n);let o=b(i,["--can-spawn"],{env:{},timeout:2000,encoding:"utf8"});return o.status===0&&o.stdout===`spawn
6
+ `?[i,"--spawn"]:[]}var U=new Map;function Tr(e=s()){let t=_s(e),n=t[0];if(!n)return[];let r=U.get(n);if(r===void 0){let i=b(n,["--can-spawn-computer-use"],{env:{},timeout:2000,encoding:"utf8"});r=i.status===0&&i.stdout===`spawn
7
+ `,U.set(n,r)}return r?t:[]}function Nn(e=Tr(),t=s()){if(e.length>0)return null;if(Yt(t)===null)return"computer_use_identity_missing";return ms(g,t)?"computer_use_identity_outdated":"computer_use_identity_unavailable"}function Hi(e={}){K(e.home);let t=st(e.home);if(e.skipWhenSettled&&d(t)&&N(t)&&X(O(e.home))===null)return!0;if(!d(t)){let n=O(e.home);if(!d(n))return!1;try{return gs({...e,sourceApp:n}),!0}catch(r){if(!d(t))throw r}}return q(t,e),!0}var Ln="REASON_WORKER_IDENTITY_APP";function Fc(e,t=process.env,n=s()){let r=t[Ln];return r&&r===st(n)?r:e}function jc(e,t){if(process.platform!=="darwin")return null;let n=st(e),r=u(n,"Contents","MacOS",Y),i=b(r,["--can-run-worker",t],{env:{},timeout:2000,encoding:"utf8"});return i.status===0&&i.stdout===`run-worker
8
8
  `?{app:n,executable:r}:null}
9
- export{ss,$i,Mi,Ic,vt,Tn,ot,Yt,as,cs,ls,kr,In,Bi,Dn,Dc,Oc};
9
+ export{fs,Fi,ji,Bc,St,On,st,Yt,ms,gs,_s,Tr,Nn,Hi,Ln,Fc,jc};
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{mkdirSync as R,readdirSync as A,readFileSync as k,realpathSync as x}from"fs";import{userInfo as E}from"os";var zn="--vm-hands-op-runner-kind=person",qn="--vm-hands-op-runner-kind=surface",Wr="--vm-hands-surface-uid=",Vr="--vm-hands-surface-dir=",C="/sys/fs/cgroup/reason-person/desktop",Gr=new Set(["automation.call.v1","display.stream.v1","preview.serve.v1"]);function D(t){let a=new Set([t]),l=[];try{l=A("/proc")}catch{}for(let n of l){if(!/^\d+$/.test(n))continue;try{let o=k(`/proc/${n}/stat`,"utf8");if(Number(o.slice(o.lastIndexOf(")")+2).split(" ")[3])===t)a.add(Number(n))}catch{}}for(let n of a)try{process.kill(n,"SIGKILL")}catch{}}var H=(t)=>{let a=globalThis.Bun;if(!a)throw new r("pty_unavailable","Reason terminals require the Bun runtime.");let l=a.spawn({cmd:[t.shell,...t.args],cwd:t.cwd,env:{...t.environment,TERM:"xterm-256color"},terminal:{cols:t.cols,rows:t.rows,data:(c,d)=>t.onData(d)}}),n=l.terminal,o=()=>{D(l.pid);try{n?.close()}catch{}};if(!n)throw o(),new r("pty_unavailable","Reason could not allocate a pseudo-terminal.");return{write:(c)=>n.write(c),resize:(c,d)=>n.resize(c,d),kill:o,exited:l.exited.then((c)=>typeof c==="number"?c:null,()=>null)}};function O(){let t=(()=>{try{return E().username}catch{return}})();return{PATH:process.env.PATH,HOME:process.env.HOME,SHELL:process.env.SHELL,LANG:"C.UTF-8",...t?{USER:t,LOGNAME:t}:{}}}async function L(t){let[{localAutomationAvailable:a},{localDisplayReady:l},{localDisplayVideoAvailable:n},{probeWorkerPreview:o},m]=await Promise.all([import("./local-automation-0a7enct8.js"),import("./local-display-session-pc85z6mg.js"),import("./local-display-video-40avbg94.js"),import("./worker-preview-readiness-h96yr4wf.js"),import("fs")]),c=AbortSignal.timeout(15000),d=null;try{m.mkdirSync(t,{recursive:!0,mode:448}),d=m.mkdtempSync(`${t}/probe-`);let[w,u,v]=await Promise.all([Promise.resolve().then(()=>a()).catch(()=>!1),l().catch(()=>!1),o(d,c).catch(()=>!1)]);return{t:"readiness",display_video:u&&await n().catch(()=>!1),lanes:{"automation.call.v1":w,"display.stream.v1":u,"preview.serve.v1":v,"tunnel.open":v,"tunnel.close":v}}}finally{if(d)m.rmSync(d,{recursive:!0,force:!0})}}function N(t){let a="";try{a=k("/proc/self/cgroup","utf8").split(`
3
+ `).find((o)=>o.startsWith("0::"))?.slice(3)??""}catch{return null}if(!/^\/reason-person\/vm-hands\/[A-Za-z0-9._-]+$/.test(a))return null;if(!t)return null;let l=[t.xvnc,t.xvfb,t.openbox,t.x11vnc,t.pulseaudio,t.browser,"/usr/bin/dbus-daemon","/bin/dbus-daemon"].flatMap((o)=>{try{return o?[x(o)]:[]}catch{return[]}}),n={join:`/sys/fs/cgroup${a}/desktop`,keep:C,programs:[...new Set(l)]};for(let o of[n.join,n.keep])try{R(o,{mode:493})}catch(m){if(m.code!=="EEXIST")return null}return n}async function hl(){let[{executeLocalOperation:t,spawnCaptured:a},{runLocalPtySession:l},{configureDesktopAccount:n,desktopAccount:o},{configureWorkerSandbox:m},{configureDesktopPlacement:c},{readDesktopComponents:d}]=await Promise.all([import("./local-capabilities-d3ycjdyg.js"),import("./local-pty-session-tqn2xmph.js"),import("./desktop-account-xma0330a.js"),import("./worker-sandbox-6kkhvryn.js"),import("./desktop-delegate-tch2qzx0.js"),import("./desktop-components-p0zx6qxg.js")]);m();let w=process.argv.includes(zn),u=process.argv.includes(qn),v=(i,e,p)=>a(i,e[0]==="-lic"?["-lc",...e.slice(1)]:e,p),y=(process.geteuid?.()??0)!==0;if(u){y=!1;let i=process.argv.find((e)=>e.startsWith(Wr))?.slice(Wr.length);if((process.geteuid?.()??-1)===0&&i)try{y=n({value:i})!==null&&o()!==null}catch{y=!1}}let S=new Map,_=new Map,f=(i)=>{try{process.send?.(i)}catch{}};if(u&&y){let i=o()?.home,e=i?N(d({home:i})):null;c(e&&{...e,log:(p,g)=>f({t:"log",event:p,fields:g})})}if(process.on("message",(i)=>{let e=i;if(e?.t==="cancel"){S.get(e.id)?.abort();return}if(e?.t==="control"){let s=_.get(e.id);if(u&&s&&e.control&&typeof e.control.kind==="string")import("./local-managed-process-ka331rcr.js").then(({controlManagedDeviceProcess:h})=>h(s,{kind:e.control.kind,payload:e.control.payload??{}})).catch(()=>!1);return}if(e?.t==="retire"){if(u&&typeof e.operation_id==="string"&&typeof e.status==="string")import("./local-managed-process-ka331rcr.js").then(({retireManagedDeviceProcess:s})=>s(e.operation_id,e.status)).catch(()=>!1);return}if(e?.t!=="op")return;if(!y){f({t:"done",id:e.id,completion:{status:"failed",error_code:"vm_hands_payload_account_unavailable"}});return}let p=e.claim.capability;if(p==="pty.start"&&!w){f({t:"done",id:e.id,completion:{status:"failed",error_code:"capability_not_granted"}});return}if(Gr.has(p)!==u){f({t:"done",id:e.id,completion:{status:"failed",error_code:"capability_not_granted"}});return}let g=new AbortController;S.set(e.id,g),_.set(e.id,e.claim);let b=p==="pty.start"?{runPtySession:(s)=>l(s,{spawnPty:H,environment:O(),loadProxy:()=>null})}:{worker:e.worker,...p==="exec.full"?{spawnFullControl:v}:{}};t(e.state,e.claim,{...b,signal:g.signal,emit:(s)=>{let{deliverySignal:h,...P}=s;f({t:"event",id:e.id,event:P})}}).then((s)=>f({t:"done",id:e.id,completion:s}),(s)=>f({t:"done",id:e.id,completion:{status:"failed",error_code:s&&typeof s==="object"&&"code"in s&&typeof s.code==="string"?s.code:"vm_hands_op_failed"}})).finally(()=>{S.delete(e.id),_.delete(e.id)})}),process.on("disconnect",()=>process.exit(0)),u){let i=process.argv.find((p)=>p.startsWith(Vr))?.slice(Vr.length),e={t:"readiness",display_video:!1,lanes:{}};f(y&&i?await L(i).catch(()=>e):e)}await new Promise(()=>{})}
4
+ export{zn,qn,Wr,Vr,Gr,hl};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ function Ot(n){return Function("return ("+n+")")()}
3
+ export{Ot};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{w,En}from"./vm-hands-entry-lite-q9s1e2y1.js";import{_n}from"./vm-hands-entry-lite-vdv4nm5f.js";import{Ni,De,yt}from"./vm-hands-entry-lite-hs6sdn60.js";import{s}from"./vm-hands-entry-lite-zawytz09.js";import{t,n,c,i}from"./vm-hands-entry-lite-k5ytpgzz.js";import{createHmac as Le,createPublicKey as we,randomBytes as Ae,randomUUID as G,verify as Pe}from"crypto";import{chmodSync as P,existsSync as H,mkdirSync as Ee,readFileSync as Re,realpathSync as xe,renameSync as Ne,statSync as Oe,unlinkSync as Ke,writeFileSync as Ce}from"fs";import{basename as Te,dirname as R,isAbsolute as J,join as h,resolve as Ue}from"path";var We=[Object.freeze({family:"ara",channel:"stable",applicationId:"so.ara.desktop"}),Object.freeze({family:"ara",channel:"staging",applicationId:"so.ara.desktop.staging"}),Object.freeze({family:"reason",channel:"stable",applicationId:"com.reasonmachines.desktop"}),Object.freeze({family:"reason",channel:"staging",applicationId:"com.reasonmachines.desktop.staging"})];var te="REASON_DESKTOP_RUNTIME",ne="REASON_DESKTOP_RUNTIME_CHANNEL",ie="REASON_DESKTOP_RUNTIME_INSTANCE_ID",re="REASON_DESKTOP_RUNTIME_WORKSPACE_SCOPE",rt={[te]:"ARA_DESKTOP_RUNTIME",[ne]:"ARA_DESKTOP_RUNTIME_CHANNEL",[ie]:"ARA_DESKTOP_RUNTIME_INSTANCE_ID",[re]:"ARA_DESKTOP_RUNTIME_WORKSPACE_SCOPE"};function K(e){if(e===void 0)return;if(!/^[a-f0-9]{64}$/.test(e))throw Error("Invalid desktop workspace scope.");return e}import{chmodSync as S,existsSync as y,mkdirSync as I,readFileSync as C,realpathSync as oe,renameSync as se,unlinkSync as k,writeFileSync as D}from"fs";import{createPrivateKey as ce,createPublicKey as le,generateKeyPairSync as de,randomUUID as ue,sign as pe}from"crypto";import{createRequire as ge}from"module";import{homedir as fe,platform as M}from"os";import{dirname as ye,join as v}from"path";var T=1,ve=16384,_=65536,_e=128,be=128,j=65536;class a extends Error{code;nativeStatus;constructor(e,r){super(`Reason Device proof boundary failed (${e}).${r===void 0?"":` Native status: ${r}.`}`);this.code=e;this.nativeStatus=r;this.name="LocalCredentialBoundaryError"}}function V(e){if(e.code==="proof_key_read_failed"&&e.nativeStatus===-25300)return"proof_key_missing";switch(e.nativeStatus){case-25308:return"keychain_interaction_required";case-25293:return"keychain_access_denied";case-25291:return"keychain_unavailable";default:return e.code}}var L=null;function B(){if(!L)try{L=ge(import.meta.url)("bun:ffi")}catch{throw new a("native_boundary_unavailable")}return L}function me(e){if(typeof e!=="string")return null;try{let r=new URL(e);if(r.protocol!=="https:"&&r.hostname!=="127.0.0.1"&&r.hostname!=="localhost"&&r.hostname!=="[::1]"&&r.hostname!=="::1")return null;return r.origin}catch{return null}}function he(e){if(!e||typeof e!=="object"||Array.isArray(e))throw new a("invalid_credential_record");let r=e,o=me(r.apiOrigin);if(r.version!==T||!o||typeof r.orgId!=="string"||r.orgId.length<1||r.orgId.length>160||typeof r.deviceId!=="string"||r.deviceId.length<1||r.deviceId.length>160||typeof r.credential!=="string"||!/^(?:reason|ara)_dev_/.test(r.credential)||r.credential.length>4096)throw new a("invalid_credential_record");return{version:T,apiOrigin:o,orgId:r.orgId,deviceId:r.deviceId,credential:r.credential}}function cn(e=process.execPath){let r=e;try{r=oe(e)}catch{}return _n(ye(r))}function p(e){return B().ptr(e)}function Ie(e){if(!y(e))throw new a("native_boundary_unavailable");let{dlopen:r,FFIType:o}=B();try{return r(e,{ara_device_configure_scope:{args:[o.ptr,o.u64],returns:o.i32},ara_device_key_load_public:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_create_fresh_public:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_sign:{args:[o.ptr,o.u64,o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_is_non_extractable:{args:[o.ptr],returns:o.i32},ara_device_key_delete:{args:[o.ptr],returns:o.i32},ara_device_binding_read:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_binding_create:{args:[o.ptr,o.u64],returns:o.i32},ara_device_binding_update:{args:[o.ptr,o.u64],returns:o.i32},ara_device_binding_delete:{args:[o.ptr],returns:o.i32},ara_device_keychain_read:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_keychain_delete:{args:[o.ptr],returns:o.i32}})}catch(l){if(l instanceof a)throw l;throw new a("native_boundary_unavailable")}}function U(e){return Buffer.from(e).toString("base64url")}function jt(e){if(typeof e!=="string"||!/^[A-Za-z0-9_-]{87}$/.test(e))return!1;try{let r=Buffer.from(e,"base64url");return r.byteLength===65&&r[0]===4}catch{return!1}}function yi(e){if(e.byteLength<8||e.byteLength>72||e[0]!==48)return!1;let r=e[1];return r!==void 0&&r<128&&r+2===e.byteLength}class ft{libraryPath;runtimePlatform;workspaceScope;library=null;constructor(e=cn(),r=M(),o){this.libraryPath=e;this.runtimePlatform=r;this.workspaceScope=o;K(o)}symbols(){if(this.runtimePlatform!=="darwin")throw new a("unsupported_platform");this.library??=Ie(this.libraryPath);let e=new TextEncoder().encode(this.workspaceScope??""),r=this.library.symbols.ara_device_configure_scope(p(e.length?e:new Uint8Array(1)),BigInt(e.length));if(r!==0)throw new a("native_boundary_unavailable",r);return this.library.symbols}publicKey(e){let r=new Uint8Array(_e),o=new BigUint64Array(1),l=e==="load"?this.symbols().ara_device_key_load_public(p(r),BigInt(r.byteLength),p(o)):this.symbols().ara_device_key_create_fresh_public(p(r),BigInt(r.byteLength),p(o));if(l!==0)throw new a(e==="load"?"proof_key_read_failed":"proof_key_generation_failed",l);let d=Number(o[0]);if(!Number.isSafeInteger(d)||d!==65)throw new a("invalid_public_key");let u=U(r.subarray(0,d));if(!jt(u))throw new a("invalid_public_key");return u}loadPublicKey(){return this.publicKey("load")}createFreshPublicKey(){return this.publicKey("create_fresh")}sign(e){if(e.byteLength<1||e.byteLength>j)throw new a("proof_sign_failed");let r=new Uint8Array(be),o=new BigUint64Array(1),l=this.symbols().ara_device_key_sign(p(e),BigInt(e.byteLength),p(r),BigInt(r.byteLength),p(o));if(l!==0)throw new a("proof_sign_failed",l);let d=Number(o[0]);if(!Number.isSafeInteger(d)||d<1||d>r.byteLength)throw new a("invalid_signature");let u=r.subarray(0,d);if(!yi(u))throw new a("invalid_signature");return U(u)}privateKeyIsNonExtractable(){let e=new Uint8Array(1),r=this.symbols().ara_device_key_is_non_extractable(p(e));if(r!==0||e[0]!==1)throw new a("proof_key_read_failed",r);return!0}deleteKey(){let e=new Uint8Array(1),r=this.symbols().ara_device_key_delete(p(e));if(r!==0)throw new a("proof_key_delete_failed",r);return e[0]===1}loadBinding(){let e=new Uint8Array(_),r=new BigUint64Array(1),o=this.symbols().ara_device_binding_read(p(e),BigInt(e.byteLength),p(r));if(o===1)return null;if(o!==0)throw new a("binding_read_failed",o);let l=Number(r[0]);if(!Number.isSafeInteger(l)||l<1||l>e.byteLength)throw new a("invalid_binding");return e.slice(0,l)}createBinding(e){if(e.byteLength<1||e.byteLength>_)throw new a("invalid_binding");let r=this.symbols().ara_device_binding_create(p(e),BigInt(e.byteLength));if(r!==0)throw new a("binding_create_failed",r)}updateBinding(e){if(e.byteLength<1||e.byteLength>_)throw new a("invalid_binding");let r=this.symbols().ara_device_binding_update(p(e),BigInt(e.byteLength));if(r!==0)throw new a("binding_update_failed",r)}deleteBinding(){let e=new Uint8Array(1),r=this.symbols().ara_device_binding_delete(p(e));if(r!==0)throw new a("binding_delete_failed",r);return e[0]===1}loadLegacyCredential(){let e=new Uint8Array(ve),r=new BigUint64Array(1),o=this.symbols().ara_device_keychain_read(p(e),BigInt(e.byteLength),p(r));if(o===1)return null;if(o!==0)throw new a("legacy_credential_read_failed",o);let l=Number(r[0]);if(!Number.isSafeInteger(l)||l<1||l>e.byteLength)throw new a("invalid_credential_record");try{let d=new TextDecoder("utf-8",{fatal:!0}).decode(e.subarray(0,l));return he(JSON.parse(d))}catch(d){if(d instanceof a)throw d;throw new a("invalid_credential_record")}}deleteLegacyCredential(){let e=new Uint8Array(1),r=this.symbols().ara_device_keychain_delete(p(e));if(r!==0)throw new a("legacy_credential_delete_failed",r);return e[0]===1}}function F(e){let r=e.export({format:"jwk"});if(r.crv!=="P-256"||typeof r.x!=="string"||typeof r.y!=="string")throw new a("invalid_public_key");let o=Buffer.from(r.x,"base64url"),l=Buffer.from(r.y,"base64url");if(o.byteLength!==32||l.byteLength!==32)throw new a("invalid_public_key");let d=Buffer.concat([Buffer.of(4),o,l]).toString("base64url");if(!jt(d))throw new a("invalid_public_key");return d}function ke(){let e=process.env.XDG_CONFIG_HOME?.trim()||v(fe(),".config");De(e);let r=v(e,"ara");return Ni(r)?r:v(e,"reason")}class ln{directory;constructor(e=ke()){this.directory=e}keyPath(){return v(this.directory,"local-device.key")}bindingPath(){return v(this.directory,"local-device.binding")}loadPrivateKeyObject(){let e=this.keyPath();if(!y(e))throw new a("proof_key_read_failed");try{let r=C(e,"utf8");return ce({key:r,format:"pem"})}catch{throw new a("proof_key_read_failed")}}loadPublicKey(){let e=this.loadPrivateKeyObject(),r=le(e);return F(r)}createFreshPublicKey(){I(this.directory,{recursive:!0,mode:448});let{privateKey:e,publicKey:r}=de("ec",{namedCurve:"P-256"}),o=e.export({type:"pkcs8",format:"pem"}),l=this.keyPath();return D(l,o,{mode:384}),S(l,384),F(r)}sign(e){if(e.byteLength<1||e.byteLength>j)throw new a("proof_sign_failed");let r=this.loadPrivateKeyObject(),o;try{o=pe("sha256",e,r)}catch{throw new a("proof_sign_failed")}if(!yi(o))throw new a("invalid_signature");return o.toString("base64url")}privateKeyIsNonExtractable(){return!1}deleteKey(){let e=this.keyPath();if(!y(e))return!1;return k(e),!0}loadBinding(){let e=this.bindingPath();if(!y(e))return null;try{return new Uint8Array(C(e))}catch{return null}}createBinding(e){if(e.byteLength<1||e.byteLength>_)throw new a("invalid_binding");I(this.directory,{recursive:!0,mode:448});let r=this.bindingPath();if(y(r))throw new a("binding_create_failed");D(r,e,{mode:384}),S(r,384)}updateBinding(e){if(e.byteLength<1||e.byteLength>_)throw new a("invalid_binding");I(this.directory,{recursive:!0,mode:448});let r=this.bindingPath();if(!y(r))throw new a("binding_update_failed");let o=`${r}.${ue()}`;try{D(o,e,{mode:384,flag:"wx"}),S(o,384),se(o,r)}finally{if(y(o))k(o)}}deleteBinding(){let e=this.bindingPath();if(!y(e))return!1;return k(e),!0}loadLegacyCredential(){return null}deleteLegacyCredential(){return!1}}function A(){return M()==="darwin"?new ft:new ln}var b=t().min(1).max(160).regex(/^[A-Za-z0-9._:-]+$/),z=n({id:b,kind:i("permission_denied"),operation:c(["bash","read","write","edit"]),provenance:c(["sandbox_policy","os_permission_unknown"]),occurredAt:t().datetime(),expiresAt:t().datetime(),sessionId:b,deviceId:b,organizationId:b}).strict();var x=4;var m="macos-keychain-p256-v1",Y=1,Fe=`ARA-DEVICE-BINDING-V1
3
- `;function Me(e){return e===void 0||typeof e==="number"&&Number.isInteger(e)&&e>=1&&e<=4}function fr(e,r=Date.now()){let o=z.safeParse(e);if(!o.success)return!1;let l=o.data,d=typeof l.occurredAt==="string"?Date.parse(l.occurredAt):NaN,u=typeof l.expiresAt==="string"?Date.parse(l.expiresAt):NaN;return l.kind==="permission_denied"&&["bash","read","write","edit"].includes(l.operation)&&["sandbox_policy","os_permission_unknown"].includes(l.provenance)&&Number.isFinite(d)&&d<=r&&u>r&&u>d&&u-d<=600000}function un(e,r,o=Date.now()){if(!e||!r||e.state!=="connected"||e.deviceId!==r.deviceId)return null;let l=Date.parse(e.lastHeartbeatAt??""),d=e.permissionRecovery;if(!(o-l>=0&&o-l<30000)||!fr(d,o)||d.deviceId!==r.deviceId||d.organizationId!==r.orgId)return null;try{process.kill(e.pid,0)}catch{return null}return d}function X(e={},r=s()){let o=w({env:{...process.env,...e}}),l=e.XDG_CONFIG_HOME?.trim()||h(r,".config");return yt(l,...o==="staging"?["staging"]:[])}function mt(e={},r=s()){return h(X(e,r),"local-device.json")}function mr(e={},r=s()){return h(X(e,r),"local-daemon.json")}function N(e,r){Ee(R(e),{recursive:!0,mode:448}),P(R(e),448);let o=`${e}.${process.pid}.${G()}.tmp`;try{Ce(o,`${JSON.stringify(r,null,2)}
4
- `,{mode:384,flag:"wx"}),P(o,384),Ne(o,e),P(e,384)}finally{if(H(o))Ke(o)}return e}function O(e){if(!H(e))return null;try{return JSON.parse(Re(e,"utf8"))}catch{return null}}function E(e,r,o){try{e.onCredentialLifecycle?.({event:r,...o?{reasonCode:o}:{}})}catch{}}function je(e){if(!Array.isArray(e))return null;let r=[];for(let o of e){if(!o||typeof o!=="object")return null;let l=o;if(typeof l.id!=="string"||typeof l.label!=="string"||typeof l.path!=="string"||typeof l.pathFingerprint!=="string"||!l.permissions||typeof l.permissions.read!=="boolean"||typeof l.permissions.write!=="boolean"||typeof l.permissions.execute!=="boolean"||typeof l.permissions.discover_environment!=="boolean"||typeof l.permissions.expose_mcp!=="boolean")return null;r.push({id:l.id,label:l.label,path:l.path,pathFingerprint:l.pathFingerprint,permissions:l.permissions})}return r}function W(e,r,o=[]){let l=Object.keys(e);return r.every((d)=>Object.hasOwn(e,d))&&l.every((d)=>r.includes(d)||o.includes(d))}function Ve(e){if(typeof e!=="string")return null;try{let r=new URL(e);if(r.protocol!=="https:"&&r.hostname!=="127.0.0.1"&&r.hostname!=="localhost")return null;return r.origin}catch{return null}}function Z(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let r=e,o=je(r.roots),l=Ve(r.apiOrigin);if(!l||typeof r.orgId!=="string"||typeof r.deviceId!=="string"||typeof r.displayName!=="string"||typeof r.registeredAt!=="string"||!Me(r.handsSlots)||r.worker!==void 0&&(!r.worker||!/^[a-f0-9]{64}$/.test(r.worker.configDigest)||!["persistent","ephemeral"].includes(r.worker.lifetime)||!Number.isFinite(Date.parse(r.worker.expiresAt)))||!o)return null;return{apiOrigin:l,orgId:r.orgId,deviceId:r.deviceId,displayName:r.displayName,registeredAt:r.registeredAt,...r.handsSlots!==void 0?{handsSlots:r.handsSlots}:{},...r.worker!==void 0?{worker:r.worker}:{},roots:o}}function Be(e){return{...e,credentialStorage:m}}function $e(e){return{version:x,apiOrigin:e.apiOrigin,orgId:e.orgId,deviceId:e.deviceId,devicePublicKey:e.devicePublicKey,displayName:e.displayName,registeredAt:e.registeredAt,...e.handsSlots!==void 0?{handsSlots:e.handsSlots}:{},...e.worker!==void 0?{worker:e.worker}:{},roots:e.roots.map((r)=>({id:r.id,label:r.label,path:r.path,pathFingerprint:r.pathFingerprint,permissions:{read:r.permissions.read,write:r.permissions.write,execute:r.permissions.execute,discover_environment:r.permissions.discover_environment,expose_mcp:r.permissions.expose_mcp}})),credentialStorage:m}}function q(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let r=e;if(!W(r,["version","apiOrigin","orgId","deviceId","devicePublicKey","displayName","registeredAt","roots","credentialStorage"],["handsSlots","worker"]))return null;let o=Z(r);if(!o||r.version!==x||r.credentialStorage!==m||!jt(r.devicePublicKey))return null;return{version:x,...o,devicePublicKey:r.devicePublicKey,credentialStorage:m}}function Q(e){return new TextEncoder().encode(`${Fe}${JSON.stringify($e(e))}`)}function ze(e){let r=Buffer.from(e,"base64url");return we({format:"jwk",key:{kty:"EC",crv:"P-256",x:r.subarray(1,33).toString("base64url"),y:r.subarray(33,65).toString("base64url")}})}function Ge(e,r){let o={version:Y,state:e,signature:r.sign(Q(e))};return new TextEncoder().encode(JSON.stringify(o))}function ee(e){let r;try{r=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e))}catch{throw new a("invalid_binding")}if(!r||typeof r!=="object"||Array.isArray(r))throw new a("invalid_binding");let o=r;if(!W(o,["version","state","signature"])||o.version!==Y||typeof o.signature!=="string"||!/^[A-Za-z0-9_-]{10,128}$/.test(o.signature))throw new a("invalid_binding");let l=q(o.state);if(!l)throw new a("invalid_binding");let d=!1;try{d=Pe("sha256",Q(l),ze(l.devicePublicKey),Buffer.from(o.signature,"base64url"))}catch{d=!1}if(!d)throw new a("invalid_binding");return l}function He(e){let{credentialStorage:r,...o}=e;return o}function Je(e){return e instanceof a?V(e):"credential_boundary_failed"}function Ht(e=mt(),r={}){let o=O(e),l=r.proofStore??r.credentialStore??A(),d=l.loadBinding();if(!d){if(o&&typeof o==="object"&&!Array.isArray(o)&&Ye(o))return null;if(o!==null)throw new a("invalid_binding");return null}let u=ee(d),g=l.loadPublicKey();if(l.privateKeyIsNonExtractable(),g!==u.devicePublicKey)throw new a("invalid_public_key");let f=q(o);if(r.repair!==!1&&(!f||JSON.stringify(f)!==JSON.stringify(u)))N(e,u);return He(u)}function Ye(e){let r=e,o=Z(e);if(!o)return null;if(r.version===2){if(typeof r.deviceCredential!=="string"||!/^(?:reason|ara)_dev_/.test(r.deviceCredential)||r.deviceCredential.length>4096)return null;return{state:o,credentialSource:"plaintext-v2"}}if(r.version!==3||r.credentialStorage!=="macos-keychain-v1"||"deviceCredential"in r)return null;return{state:o,credentialSource:"keychain-v3"}}function ae(e,r=mt(),o={}){let l=o.proofStore??o.credentialStore??A();E(o,"credential.store_started");try{if(!jt(e.devicePublicKey)||l.loadPublicKey()!==e.devicePublicKey)throw new a("invalid_public_key");l.privateKeyIsNonExtractable();let d=Be(e),u=l.loadBinding();if(u){let f=ee(u);if(f.devicePublicKey!==e.devicePublicKey||f.orgId!==e.orgId||f.deviceId!==e.deviceId||f.apiOrigin!==e.apiOrigin&&!En(f.apiOrigin,e.apiOrigin))throw new a("invalid_binding")}let g=Ge(d,l);if(u)l.updateBinding(g);else l.createBinding(g);return N(r,d),E(o,"credential.store_completed"),r}catch(d){throw E(o,"credential.store_failed",Je(d)),d}}function tt(e=mr()){let r=O(e);if(!r||typeof r!=="object")return null;let o=r;if(o.version!==1||typeof o.pid!=="number"||!Number.isInteger(o.pid)||!["starting","connected","stopped","error"].includes(o.state??"")||typeof o.startedAt!=="string"||o.lastHeartbeatAt!==void 0&&typeof o.lastHeartbeatAt!=="string"||o.lastUsedAt!==void 0&&typeof o.lastUsedAt!=="string"||o.organizationId!==void 0&&typeof o.organizationId!=="string"||o.organizationName!==void 0&&typeof o.organizationName!=="string"||o.organizationSlug!==void 0&&typeof o.organizationSlug!=="string"||o.error!==void 0&&typeof o.error!=="string"||o.reconnectingSince!==void 0&&typeof o.reconnectingSince!=="string"||o.workspace!==void 0&&typeof o.workspace!=="string")return null;if(o.permissionRecovery!==void 0&&!fr(o.permissionRecovery))delete o.permissionRecovery;return o}function wi(e,r=mr()){return N(r,e)}var gr=1;function Xe(e=mt()){return h(R(e),"local-device.proxy.json")}function Se(e=Xe()){let r=O(e);if(!r||typeof r!=="object"||Array.isArray(r))return null;let o=r;if(o.version!==gr||typeof o.url!=="string"||o.url.length===0||o.caFile!==void 0&&(typeof o.caFile!=="string"||!J(o.caFile)))return null;return{version:gr,url:o.url,...o.caFile?{caFile:o.caFile}:{}}}function Ut(e,r={read:!0,write:!1,execute:!1,discover_environment:!1,expose_mcp:!1},o=Ae(32)){let l=new Set,d=[];for(let u of e){let g=xe(J(u)?u:Ue(u));if(!Oe(g).isDirectory())throw Error(`Local execution root is not a directory: ${u}`);if(l.has(g))continue;l.add(g),d.push({id:G(),label:Te(g)||g,path:g,pathFingerprint:Le("sha256",o).update(g).digest("hex"),permissions:{...r}})}if(d.length===0)throw Error("At least one explicit local execution root is required.");return d}
5
- export{a,cn,jt,yi,ft,ln,fr,un,mt,mr,Ht,ae,tt,wi,gr,Se,Ut};
2
+ import{w,Cn}from"./vm-hands-entry-lite-33at6g06.js";import{Sn}from"./vm-hands-entry-lite-1b21avcs.js";import{Mi,De,wt}from"./vm-hands-entry-lite-88dxn9b5.js";import{s}from"./vm-hands-entry-lite-12ck5swp.js";import{t,n,c,i}from"./vm-hands-entry-lite-zpvr7wc6.js";import{createHmac as Le,createPublicKey as we,randomBytes as Ae,randomUUID as G,verify as Pe}from"crypto";import{chmodSync as P,existsSync as H,mkdirSync as Ee,readFileSync as Re,realpathSync as xe,renameSync as Ne,statSync as Oe,unlinkSync as Ke,writeFileSync as Ce}from"fs";import{basename as Te,dirname as R,isAbsolute as J,join as h,resolve as Ue}from"path";var We=[Object.freeze({family:"ara",channel:"stable",applicationId:"so.ara.desktop"}),Object.freeze({family:"ara",channel:"staging",applicationId:"so.ara.desktop.staging"}),Object.freeze({family:"reason",channel:"stable",applicationId:"com.reasonmachines.desktop"}),Object.freeze({family:"reason",channel:"staging",applicationId:"com.reasonmachines.desktop.staging"})];var te="REASON_DESKTOP_RUNTIME",ne="REASON_DESKTOP_RUNTIME_CHANNEL",ie="REASON_DESKTOP_RUNTIME_INSTANCE_ID",re="REASON_DESKTOP_RUNTIME_WORKSPACE_SCOPE",it={[te]:"ARA_DESKTOP_RUNTIME",[ne]:"ARA_DESKTOP_RUNTIME_CHANNEL",[ie]:"ARA_DESKTOP_RUNTIME_INSTANCE_ID",[re]:"ARA_DESKTOP_RUNTIME_WORKSPACE_SCOPE"};function K(e){if(e===void 0)return;if(!/^[a-f0-9]{64}$/.test(e))throw Error("Invalid desktop workspace scope.");return e}import{chmodSync as S,existsSync as y,mkdirSync as I,readFileSync as C,realpathSync as oe,renameSync as se,unlinkSync as k,writeFileSync as D}from"fs";import{createPrivateKey as ce,createPublicKey as le,generateKeyPairSync as de,randomUUID as ue,sign as pe}from"crypto";import{createRequire as ge}from"module";import{homedir as fe,platform as M}from"os";import{dirname as ye,join as v}from"path";var T=1,ve=16384,_=65536,_e=128,be=128,j=65536;class a extends Error{code;nativeStatus;constructor(e,r){super(`Reason Device proof boundary failed (${e}).${r===void 0?"":` Native status: ${r}.`}`);this.code=e;this.nativeStatus=r;this.name="LocalCredentialBoundaryError"}}function V(e){if(e.code==="proof_key_read_failed"&&e.nativeStatus===-25300)return"proof_key_missing";switch(e.nativeStatus){case-25308:return"keychain_interaction_required";case-25293:return"keychain_access_denied";case-25291:return"keychain_unavailable";default:return e.code}}var L=null;function B(){if(!L)try{L=ge(import.meta.url)("bun:ffi")}catch{throw new a("native_boundary_unavailable")}return L}function me(e){if(typeof e!=="string")return null;try{let r=new URL(e);if(r.protocol!=="https:"&&r.hostname!=="127.0.0.1"&&r.hostname!=="localhost"&&r.hostname!=="[::1]"&&r.hostname!=="::1")return null;return r.origin}catch{return null}}function he(e){if(!e||typeof e!=="object"||Array.isArray(e))throw new a("invalid_credential_record");let r=e,o=me(r.apiOrigin);if(r.version!==T||!o||typeof r.orgId!=="string"||r.orgId.length<1||r.orgId.length>160||typeof r.deviceId!=="string"||r.deviceId.length<1||r.deviceId.length>160||typeof r.credential!=="string"||!/^(?:reason|ara)_dev_/.test(r.credential)||r.credential.length>4096)throw new a("invalid_credential_record");return{version:T,apiOrigin:o,orgId:r.orgId,deviceId:r.deviceId,credential:r.credential}}function hn(e=process.execPath){let r=e;try{r=oe(e)}catch{}return Sn(ye(r))}function p(e){return B().ptr(e)}function Ie(e){if(!y(e))throw new a("native_boundary_unavailable");let{dlopen:r,FFIType:o}=B();try{return r(e,{ara_device_configure_scope:{args:[o.ptr,o.u64],returns:o.i32},ara_device_key_load_public:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_create_fresh_public:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_sign:{args:[o.ptr,o.u64,o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_is_non_extractable:{args:[o.ptr],returns:o.i32},ara_device_key_delete:{args:[o.ptr],returns:o.i32},ara_device_binding_read:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_binding_create:{args:[o.ptr,o.u64],returns:o.i32},ara_device_binding_update:{args:[o.ptr,o.u64],returns:o.i32},ara_device_binding_delete:{args:[o.ptr],returns:o.i32},ara_device_keychain_read:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_keychain_delete:{args:[o.ptr],returns:o.i32}})}catch(l){if(l instanceof a)throw l;throw new a("native_boundary_unavailable")}}function U(e){return Buffer.from(e).toString("base64url")}function Ht(e){if(typeof e!=="string"||!/^[A-Za-z0-9_-]{87}$/.test(e))return!1;try{let r=Buffer.from(e,"base64url");return r.byteLength===65&&r[0]===4}catch{return!1}}function vi(e){if(e.byteLength<8||e.byteLength>72||e[0]!==48)return!1;let r=e[1];return r!==void 0&&r<128&&r+2===e.byteLength}class mt{libraryPath;runtimePlatform;workspaceScope;library=null;constructor(e=hn(),r=M(),o){this.libraryPath=e;this.runtimePlatform=r;this.workspaceScope=o;K(o)}symbols(){if(this.runtimePlatform!=="darwin")throw new a("unsupported_platform");this.library??=Ie(this.libraryPath);let e=new TextEncoder().encode(this.workspaceScope??""),r=this.library.symbols.ara_device_configure_scope(p(e.length?e:new Uint8Array(1)),BigInt(e.length));if(r!==0)throw new a("native_boundary_unavailable",r);return this.library.symbols}publicKey(e){let r=new Uint8Array(_e),o=new BigUint64Array(1),l=e==="load"?this.symbols().ara_device_key_load_public(p(r),BigInt(r.byteLength),p(o)):this.symbols().ara_device_key_create_fresh_public(p(r),BigInt(r.byteLength),p(o));if(l!==0)throw new a(e==="load"?"proof_key_read_failed":"proof_key_generation_failed",l);let d=Number(o[0]);if(!Number.isSafeInteger(d)||d!==65)throw new a("invalid_public_key");let u=U(r.subarray(0,d));if(!Ht(u))throw new a("invalid_public_key");return u}loadPublicKey(){return this.publicKey("load")}createFreshPublicKey(){return this.publicKey("create_fresh")}sign(e){if(e.byteLength<1||e.byteLength>j)throw new a("proof_sign_failed");let r=new Uint8Array(be),o=new BigUint64Array(1),l=this.symbols().ara_device_key_sign(p(e),BigInt(e.byteLength),p(r),BigInt(r.byteLength),p(o));if(l!==0)throw new a("proof_sign_failed",l);let d=Number(o[0]);if(!Number.isSafeInteger(d)||d<1||d>r.byteLength)throw new a("invalid_signature");let u=r.subarray(0,d);if(!vi(u))throw new a("invalid_signature");return U(u)}privateKeyIsNonExtractable(){let e=new Uint8Array(1),r=this.symbols().ara_device_key_is_non_extractable(p(e));if(r!==0||e[0]!==1)throw new a("proof_key_read_failed",r);return!0}deleteKey(){let e=new Uint8Array(1),r=this.symbols().ara_device_key_delete(p(e));if(r!==0)throw new a("proof_key_delete_failed",r);return e[0]===1}loadBinding(){let e=new Uint8Array(_),r=new BigUint64Array(1),o=this.symbols().ara_device_binding_read(p(e),BigInt(e.byteLength),p(r));if(o===1)return null;if(o!==0)throw new a("binding_read_failed",o);let l=Number(r[0]);if(!Number.isSafeInteger(l)||l<1||l>e.byteLength)throw new a("invalid_binding");return e.slice(0,l)}createBinding(e){if(e.byteLength<1||e.byteLength>_)throw new a("invalid_binding");let r=this.symbols().ara_device_binding_create(p(e),BigInt(e.byteLength));if(r!==0)throw new a("binding_create_failed",r)}updateBinding(e){if(e.byteLength<1||e.byteLength>_)throw new a("invalid_binding");let r=this.symbols().ara_device_binding_update(p(e),BigInt(e.byteLength));if(r!==0)throw new a("binding_update_failed",r)}deleteBinding(){let e=new Uint8Array(1),r=this.symbols().ara_device_binding_delete(p(e));if(r!==0)throw new a("binding_delete_failed",r);return e[0]===1}loadLegacyCredential(){let e=new Uint8Array(ve),r=new BigUint64Array(1),o=this.symbols().ara_device_keychain_read(p(e),BigInt(e.byteLength),p(r));if(o===1)return null;if(o!==0)throw new a("legacy_credential_read_failed",o);let l=Number(r[0]);if(!Number.isSafeInteger(l)||l<1||l>e.byteLength)throw new a("invalid_credential_record");try{let d=new TextDecoder("utf-8",{fatal:!0}).decode(e.subarray(0,l));return he(JSON.parse(d))}catch(d){if(d instanceof a)throw d;throw new a("invalid_credential_record")}}deleteLegacyCredential(){let e=new Uint8Array(1),r=this.symbols().ara_device_keychain_delete(p(e));if(r!==0)throw new a("legacy_credential_delete_failed",r);return e[0]===1}}function F(e){let r=e.export({format:"jwk"});if(r.crv!=="P-256"||typeof r.x!=="string"||typeof r.y!=="string")throw new a("invalid_public_key");let o=Buffer.from(r.x,"base64url"),l=Buffer.from(r.y,"base64url");if(o.byteLength!==32||l.byteLength!==32)throw new a("invalid_public_key");let d=Buffer.concat([Buffer.of(4),o,l]).toString("base64url");if(!Ht(d))throw new a("invalid_public_key");return d}function ke(){let e=process.env.XDG_CONFIG_HOME?.trim()||v(fe(),".config");De(e);let r=v(e,"ara");return Mi(r)?r:v(e,"reason")}class fn{directory;constructor(e=ke()){this.directory=e}keyPath(){return v(this.directory,"local-device.key")}bindingPath(){return v(this.directory,"local-device.binding")}loadPrivateKeyObject(){let e=this.keyPath();if(!y(e))throw new a("proof_key_read_failed");try{let r=C(e,"utf8");return ce({key:r,format:"pem"})}catch{throw new a("proof_key_read_failed")}}loadPublicKey(){let e=this.loadPrivateKeyObject(),r=le(e);return F(r)}createFreshPublicKey(){I(this.directory,{recursive:!0,mode:448});let{privateKey:e,publicKey:r}=de("ec",{namedCurve:"P-256"}),o=e.export({type:"pkcs8",format:"pem"}),l=this.keyPath();return D(l,o,{mode:384}),S(l,384),F(r)}sign(e){if(e.byteLength<1||e.byteLength>j)throw new a("proof_sign_failed");let r=this.loadPrivateKeyObject(),o;try{o=pe("sha256",e,r)}catch{throw new a("proof_sign_failed")}if(!vi(o))throw new a("invalid_signature");return o.toString("base64url")}privateKeyIsNonExtractable(){return!1}deleteKey(){let e=this.keyPath();if(!y(e))return!1;return k(e),!0}loadBinding(){let e=this.bindingPath();if(!y(e))return null;try{return new Uint8Array(C(e))}catch{return null}}createBinding(e){if(e.byteLength<1||e.byteLength>_)throw new a("invalid_binding");I(this.directory,{recursive:!0,mode:448});let r=this.bindingPath();if(y(r))throw new a("binding_create_failed");D(r,e,{mode:384}),S(r,384)}updateBinding(e){if(e.byteLength<1||e.byteLength>_)throw new a("invalid_binding");I(this.directory,{recursive:!0,mode:448});let r=this.bindingPath();if(!y(r))throw new a("binding_update_failed");let o=`${r}.${ue()}`;try{D(o,e,{mode:384,flag:"wx"}),S(o,384),se(o,r)}finally{if(y(o))k(o)}}deleteBinding(){let e=this.bindingPath();if(!y(e))return!1;return k(e),!0}loadLegacyCredential(){return null}deleteLegacyCredential(){return!1}}function A(){return M()==="darwin"?new mt:new fn}var b=t().min(1).max(160).regex(/^[A-Za-z0-9._:-]+$/),z=n({id:b,kind:i("permission_denied"),operation:c(["bash","read","write","edit"]),provenance:c(["sandbox_policy","os_permission_unknown"]),occurredAt:t().datetime(),expiresAt:t().datetime(),sessionId:b,deviceId:b,organizationId:b}).strict();var x=4;var m="macos-keychain-p256-v1",Y=1,Fe=`ARA-DEVICE-BINDING-V1
3
+ `;function Me(e){return e===void 0||typeof e==="number"&&Number.isInteger(e)&&e>=1&&e<=4}function fr(e,r=Date.now()){let o=z.safeParse(e);if(!o.success)return!1;let l=o.data,d=typeof l.occurredAt==="string"?Date.parse(l.occurredAt):NaN,u=typeof l.expiresAt==="string"?Date.parse(l.expiresAt):NaN;return l.kind==="permission_denied"&&["bash","read","write","edit"].includes(l.operation)&&["sandbox_policy","os_permission_unknown"].includes(l.provenance)&&Number.isFinite(d)&&d<=r&&u>r&&u>d&&u-d<=600000}function mn(e,r,o=Date.now()){if(!e||!r||e.state!=="connected"||e.deviceId!==r.deviceId)return null;let l=Date.parse(e.lastHeartbeatAt??""),d=e.permissionRecovery;if(!(o-l>=0&&o-l<30000)||!fr(d,o)||d.deviceId!==r.deviceId||d.organizationId!==r.orgId)return null;try{process.kill(e.pid,0)}catch{return null}return d}function X(e={},r=s()){let o=w({env:{...process.env,...e}}),l=e.XDG_CONFIG_HOME?.trim()||h(r,".config");return wt(l,...o==="staging"?["staging"]:[])}function gt(e={},r=s()){return h(X(e,r),"local-device.json")}function mr(e={},r=s()){return h(X(e,r),"local-daemon.json")}function N(e,r){Ee(R(e),{recursive:!0,mode:448}),P(R(e),448);let o=`${e}.${process.pid}.${G()}.tmp`;try{Ce(o,`${JSON.stringify(r,null,2)}
4
+ `,{mode:384,flag:"wx"}),P(o,384),Ne(o,e),P(e,384)}finally{if(H(o))Ke(o)}return e}function O(e){if(!H(e))return null;try{return JSON.parse(Re(e,"utf8"))}catch{return null}}function E(e,r,o){try{e.onCredentialLifecycle?.({event:r,...o?{reasonCode:o}:{}})}catch{}}function je(e){if(!Array.isArray(e))return null;let r=[];for(let o of e){if(!o||typeof o!=="object")return null;let l=o;if(typeof l.id!=="string"||typeof l.label!=="string"||typeof l.path!=="string"||typeof l.pathFingerprint!=="string"||!l.permissions||typeof l.permissions.read!=="boolean"||typeof l.permissions.write!=="boolean"||typeof l.permissions.execute!=="boolean"||typeof l.permissions.discover_environment!=="boolean"||typeof l.permissions.expose_mcp!=="boolean")return null;r.push({id:l.id,label:l.label,path:l.path,pathFingerprint:l.pathFingerprint,permissions:l.permissions})}return r}function W(e,r,o=[]){let l=Object.keys(e);return r.every((d)=>Object.hasOwn(e,d))&&l.every((d)=>r.includes(d)||o.includes(d))}function Ve(e){if(typeof e!=="string")return null;try{let r=new URL(e);if(r.protocol!=="https:"&&r.hostname!=="127.0.0.1"&&r.hostname!=="localhost")return null;return r.origin}catch{return null}}function Z(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let r=e,o=je(r.roots),l=Ve(r.apiOrigin);if(!l||typeof r.orgId!=="string"||typeof r.deviceId!=="string"||typeof r.displayName!=="string"||typeof r.registeredAt!=="string"||!Me(r.handsSlots)||r.worker!==void 0&&(!r.worker||!/^[a-f0-9]{64}$/.test(r.worker.configDigest)||!["persistent","ephemeral"].includes(r.worker.lifetime)||!Number.isFinite(Date.parse(r.worker.expiresAt)))||!o)return null;return{apiOrigin:l,orgId:r.orgId,deviceId:r.deviceId,displayName:r.displayName,registeredAt:r.registeredAt,...r.handsSlots!==void 0?{handsSlots:r.handsSlots}:{},...r.worker!==void 0?{worker:r.worker}:{},roots:o}}function Be(e){return{...e,credentialStorage:m}}function $e(e){return{version:x,apiOrigin:e.apiOrigin,orgId:e.orgId,deviceId:e.deviceId,devicePublicKey:e.devicePublicKey,displayName:e.displayName,registeredAt:e.registeredAt,...e.handsSlots!==void 0?{handsSlots:e.handsSlots}:{},...e.worker!==void 0?{worker:e.worker}:{},roots:e.roots.map((r)=>({id:r.id,label:r.label,path:r.path,pathFingerprint:r.pathFingerprint,permissions:{read:r.permissions.read,write:r.permissions.write,execute:r.permissions.execute,discover_environment:r.permissions.discover_environment,expose_mcp:r.permissions.expose_mcp}})),credentialStorage:m}}function q(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let r=e;if(!W(r,["version","apiOrigin","orgId","deviceId","devicePublicKey","displayName","registeredAt","roots","credentialStorage"],["handsSlots","worker"]))return null;let o=Z(r);if(!o||r.version!==x||r.credentialStorage!==m||!Ht(r.devicePublicKey))return null;return{version:x,...o,devicePublicKey:r.devicePublicKey,credentialStorage:m}}function Q(e){return new TextEncoder().encode(`${Fe}${JSON.stringify($e(e))}`)}function ze(e){let r=Buffer.from(e,"base64url");return we({format:"jwk",key:{kty:"EC",crv:"P-256",x:r.subarray(1,33).toString("base64url"),y:r.subarray(33,65).toString("base64url")}})}function Ge(e,r){let o={version:Y,state:e,signature:r.sign(Q(e))};return new TextEncoder().encode(JSON.stringify(o))}function ee(e){let r;try{r=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e))}catch{throw new a("invalid_binding")}if(!r||typeof r!=="object"||Array.isArray(r))throw new a("invalid_binding");let o=r;if(!W(o,["version","state","signature"])||o.version!==Y||typeof o.signature!=="string"||!/^[A-Za-z0-9_-]{10,128}$/.test(o.signature))throw new a("invalid_binding");let l=q(o.state);if(!l)throw new a("invalid_binding");let d=!1;try{d=Pe("sha256",Q(l),ze(l.devicePublicKey),Buffer.from(o.signature,"base64url"))}catch{d=!1}if(!d)throw new a("invalid_binding");return l}function He(e){let{credentialStorage:r,...o}=e;return o}function Je(e){return e instanceof a?V(e):"credential_boundary_failed"}function Ut(e=gt(),r={}){let o=O(e),l=r.proofStore??r.credentialStore??A(),d=l.loadBinding();if(!d){if(o&&typeof o==="object"&&!Array.isArray(o)&&Ye(o))return null;if(o!==null)throw new a("invalid_binding");return null}let u=ee(d),g=l.loadPublicKey();if(l.privateKeyIsNonExtractable(),g!==u.devicePublicKey)throw new a("invalid_public_key");let f=q(o);if(r.repair!==!1&&(!f||JSON.stringify(f)!==JSON.stringify(u)))N(e,u);return He(u)}function Ye(e){let r=e,o=Z(e);if(!o)return null;if(r.version===2){if(typeof r.deviceCredential!=="string"||!/^(?:reason|ara)_dev_/.test(r.deviceCredential)||r.deviceCredential.length>4096)return null;return{state:o,credentialSource:"plaintext-v2"}}if(r.version!==3||r.credentialStorage!=="macos-keychain-v1"||"deviceCredential"in r)return null;return{state:o,credentialSource:"keychain-v3"}}function ae(e,r=gt(),o={}){let l=o.proofStore??o.credentialStore??A();E(o,"credential.store_started");try{if(!Ht(e.devicePublicKey)||l.loadPublicKey()!==e.devicePublicKey)throw new a("invalid_public_key");l.privateKeyIsNonExtractable();let d=Be(e),u=l.loadBinding();if(u){let f=ee(u);if(f.devicePublicKey!==e.devicePublicKey||f.orgId!==e.orgId||f.deviceId!==e.deviceId||f.apiOrigin!==e.apiOrigin&&!Cn(f.apiOrigin,e.apiOrigin))throw new a("invalid_binding")}let g=Ge(d,l);if(u)l.updateBinding(g);else l.createBinding(g);return N(r,d),E(o,"credential.store_completed"),r}catch(d){throw E(o,"credential.store_failed",Je(d)),d}}function rt(e=mr()){let r=O(e);if(!r||typeof r!=="object")return null;let o=r;if(o.version!==1||typeof o.pid!=="number"||!Number.isInteger(o.pid)||!["starting","connected","stopped","error"].includes(o.state??"")||typeof o.startedAt!=="string"||o.lastHeartbeatAt!==void 0&&typeof o.lastHeartbeatAt!=="string"||o.lastUsedAt!==void 0&&typeof o.lastUsedAt!=="string"||o.organizationId!==void 0&&typeof o.organizationId!=="string"||o.organizationName!==void 0&&typeof o.organizationName!=="string"||o.organizationSlug!==void 0&&typeof o.organizationSlug!=="string"||o.error!==void 0&&typeof o.error!=="string"||o.reconnectingSince!==void 0&&typeof o.reconnectingSince!=="string"||o.workspace!==void 0&&typeof o.workspace!=="string")return null;if(o.permissionRecovery!==void 0&&!fr(o.permissionRecovery))delete o.permissionRecovery;return o}function Si(e,r=mr()){return N(r,e)}var gr=1;function Xe(e=gt()){return h(R(e),"local-device.proxy.json")}function Se(e=Xe()){let r=O(e);if(!r||typeof r!=="object"||Array.isArray(r))return null;let o=r;if(o.version!==gr||typeof o.url!=="string"||o.url.length===0||o.caFile!==void 0&&(typeof o.caFile!=="string"||!J(o.caFile)))return null;return{version:gr,url:o.url,...o.caFile?{caFile:o.caFile}:{}}}function zt(e,r={read:!0,write:!1,execute:!1,discover_environment:!1,expose_mcp:!1},o=Ae(32)){let l=new Set,d=[];for(let u of e){let g=xe(J(u)?u:Ue(u));if(!Oe(g).isDirectory())throw Error(`Local execution root is not a directory: ${u}`);if(l.has(g))continue;l.add(g),d.push({id:G(),label:Te(g)||g,path:g,pathFingerprint:Le("sha256",o).update(g).digest("hex"),permissions:{...r}})}if(d.length===0)throw Error("At least one explicit local execution root is required.");return d}
5
+ export{a,hn,Ht,vi,mt,fn,fr,mn,gt,mr,Ut,ae,rt,Si,gr,Se,zt};