@reason-machines/cli-linux-x64 0.2.408 → 0.2.411

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 (100) hide show
  1. package/bin/reason +2 -2
  2. package/bin/vm-hands/api-cjv8m2zy.js +2 -0
  3. package/bin/vm-hands/api-credentials-m5akr9fv.js +2 -0
  4. package/bin/vm-hands/connect-cli-kwxy8nva.js +2 -0
  5. package/bin/vm-hands/custom-endpoint-device-dkqb4rqy.js +2 -0
  6. package/bin/vm-hands/desktop-account-5v7x0ajx.js +2 -0
  7. package/bin/vm-hands/device-workspace-p9q9dckg.js +2 -0
  8. package/bin/vm-hands/{fsevents-vgg0dny6.js → fsevents-ekt70rcc.js} +1 -1
  9. package/bin/vm-hands/hands-worker-source-cgrpm21b.js +2 -0
  10. package/bin/vm-hands/{index-kx10kwyx.js → index-k8kcz8a3.js} +11 -11
  11. package/bin/vm-hands/install-receipt-7vt2y2vh.js +2 -0
  12. package/bin/vm-hands/local-automation-kqhprz6k.js +2 -0
  13. package/bin/vm-hands/local-capabilities-ptwd0rk9.js +2 -0
  14. package/bin/vm-hands/local-desktop-users-q886k0mm.js +2 -0
  15. package/bin/vm-hands/local-display-mac-w85956f1.js +2 -0
  16. package/bin/vm-hands/local-display-session-ycce0gqg.js +2 -0
  17. package/bin/vm-hands/local-pty-session-5f50sqq0.js +2 -0
  18. package/bin/vm-hands/managed-runtime-14qgbkr0.js +2 -0
  19. package/bin/vm-hands/network-contract-9x9kc5vv.js +2 -0
  20. package/bin/vm-hands/package-78fkast4.js +2 -0
  21. package/bin/vm-hands/permissions-v1120728.js +2 -0
  22. package/bin/vm-hands/reason-hands-protocol-2tnghj3b.js +2 -0
  23. package/bin/vm-hands/serve-service-cc42p3rv.js +2 -0
  24. package/bin/vm-hands/status-4chy5g03.js +10 -0
  25. package/bin/vm-hands/version-12b5jg7q.js +2 -0
  26. package/bin/vm-hands/{vm-hands-entry-lite-wyh6dp1t.js → vm-hands-entry-lite-09m2cdkw.js} +2 -2
  27. package/bin/vm-hands/{vm-hands-entry-lite-4aejamqr.js → vm-hands-entry-lite-0xrsph3r.js} +2 -2
  28. package/bin/vm-hands/{vm-hands-entry-lite-fyjzrvj5.js → vm-hands-entry-lite-1cwqa4jr.js} +2 -2
  29. package/bin/vm-hands/{vm-hands-entry-lite-snmxxhza.js → vm-hands-entry-lite-1ksme5sc.js} +2 -2
  30. package/bin/vm-hands/{vm-hands-entry-lite-ppytc9k7.js → vm-hands-entry-lite-1rrb66r9.js} +2 -2
  31. package/bin/vm-hands/{vm-hands-entry-lite-pn92kh7b.js → vm-hands-entry-lite-1rtkf2xm.js} +2 -2
  32. package/bin/vm-hands/{vm-hands-entry-lite-wf7ksh4e.js → vm-hands-entry-lite-1xtpeh3x.js} +5 -5
  33. package/bin/vm-hands/{vm-hands-entry-lite-g3ja0c3y.js → vm-hands-entry-lite-22kfyvnk.js} +1 -1
  34. package/bin/vm-hands/{vm-hands-entry-lite-saqdrc2w.js → vm-hands-entry-lite-3zdxefjh.js} +2 -2
  35. package/bin/vm-hands/{vm-hands-entry-lite-et2bh990.js → vm-hands-entry-lite-4fpjdnbk.js} +22 -22
  36. package/bin/vm-hands/{vm-hands-entry-lite-hzn1hf0p.js → vm-hands-entry-lite-6aeea05q.js} +2 -2
  37. package/bin/vm-hands/{vm-hands-entry-lite-mw0gzbds.js → vm-hands-entry-lite-88swf2qr.js} +3 -3
  38. package/bin/vm-hands/{vm-hands-entry-lite-dkcm3hyn.js → vm-hands-entry-lite-89z488gz.js} +2 -2
  39. package/bin/vm-hands/vm-hands-entry-lite-8ns59paz.js +3 -0
  40. package/bin/vm-hands/{vm-hands-entry-lite-mvx29q2q.js → vm-hands-entry-lite-8t9xssf9.js} +2 -2
  41. package/bin/vm-hands/{vm-hands-entry-lite-zn0v259d.js → vm-hands-entry-lite-907pa7f9.js} +4 -4
  42. package/bin/vm-hands/{vm-hands-entry-lite-zg3b0c08.js → vm-hands-entry-lite-9ay6f56v.js} +2 -2
  43. package/bin/vm-hands/{vm-hands-entry-lite-wd576mgy.js → vm-hands-entry-lite-9c95p6n9.js} +29 -29
  44. package/bin/vm-hands/{vm-hands-entry-lite-9ym3sx81.js → vm-hands-entry-lite-ab2m9erf.js} +1 -1
  45. package/bin/vm-hands/{vm-hands-entry-lite-79s23abx.js → vm-hands-entry-lite-b885gwfh.js} +4 -4
  46. package/bin/vm-hands/{vm-hands-entry-lite-51qvfk93.js → vm-hands-entry-lite-bdhjpv7g.js} +2 -2
  47. package/bin/vm-hands/{vm-hands-entry-lite-5p5h1eng.js → vm-hands-entry-lite-ckv17tn8.js} +2 -2
  48. package/bin/vm-hands/{vm-hands-entry-lite-8evzzh7v.js → vm-hands-entry-lite-eqgj4acy.js} +5 -5
  49. package/bin/vm-hands/{vm-hands-entry-lite-v3xznxcw.js → vm-hands-entry-lite-f5e3dbgk.js} +3 -3
  50. package/bin/vm-hands/vm-hands-entry-lite-ggj69hbj.js +2 -0
  51. package/bin/vm-hands/{vm-hands-entry-lite-8gtgr399.js → vm-hands-entry-lite-gvwdy3rf.js} +3 -3
  52. package/bin/vm-hands/{vm-hands-entry-lite-6p9c8nhf.js → vm-hands-entry-lite-hj8n59y9.js} +2 -2
  53. package/bin/vm-hands/{vm-hands-entry-lite-4geps3jz.js → vm-hands-entry-lite-j7k3e5w0.js} +3 -3
  54. package/bin/vm-hands/{vm-hands-entry-lite-ym1djztp.js → vm-hands-entry-lite-k278g9kj.js} +5 -5
  55. package/bin/vm-hands/{vm-hands-entry-lite-hcw5tk5d.js → vm-hands-entry-lite-m11j0f9q.js} +2 -2
  56. package/bin/vm-hands/{vm-hands-entry-lite-hfmydph9.js → vm-hands-entry-lite-mkmebj51.js} +4 -4
  57. package/bin/vm-hands/{vm-hands-entry-lite-0n2f3kx7.js → vm-hands-entry-lite-pgb514h0.js} +2 -2
  58. package/bin/vm-hands/{vm-hands-entry-lite-dq1m5ykp.js → vm-hands-entry-lite-q0k6kx6d.js} +4 -4
  59. package/bin/vm-hands/{vm-hands-entry-lite-gc7c22pq.js → vm-hands-entry-lite-qysyf65v.js} +1 -1
  60. package/bin/vm-hands/{vm-hands-entry-lite-762fbns7.js → vm-hands-entry-lite-rhhqbwmr.js} +2 -2
  61. package/bin/vm-hands/{vm-hands-entry-lite-hee1h411.js → vm-hands-entry-lite-t07pdqxb.js} +10 -10
  62. package/bin/vm-hands/{vm-hands-entry-lite-6whxyzz2.js → vm-hands-entry-lite-t9nz0ty7.js} +5 -5
  63. package/bin/vm-hands/vm-hands-entry-lite-vrqzr15t.js +3 -0
  64. package/bin/vm-hands/{vm-hands-entry-lite-e5hbehqn.js → vm-hands-entry-lite-ydg5av4g.js} +16 -16
  65. package/bin/vm-hands/vm-hands-entry-lite-zcd0e9fx.js +540 -0
  66. package/bin/vm-hands/{vm-hands-entry-lite-w9ckj5k4.js → vm-hands-entry-lite-zg36myyf.js} +4 -4
  67. package/bin/vm-hands/vm-hands-entry-lite.js +2 -2
  68. package/bin/vm-hands/{vm-hands-executor-79av9nam.js → vm-hands-executor-xcyzs4av.js} +6 -6
  69. package/bin/vm-hands/vm-hands-op-runner-117jfr8y.js +2 -0
  70. package/bin/vm-hands/{vm-hands-runtime-yacvv937.js → vm-hands-runtime-1qtn08n0.js} +3 -3
  71. package/bin/vm-hands/worker-sandbox-smqj3mbe.js +2 -0
  72. package/package.json +1 -1
  73. package/bin/vm-hands/api-8d760ppa.js +0 -2
  74. package/bin/vm-hands/api-credentials-eea1g4aw.js +0 -2
  75. package/bin/vm-hands/connect-cli-m8xafyn5.js +0 -2
  76. package/bin/vm-hands/custom-endpoint-device-nfjhs9fv.js +0 -2
  77. package/bin/vm-hands/desktop-account-rx4ajy2j.js +0 -2
  78. package/bin/vm-hands/device-workspace-n9tn4bzw.js +0 -2
  79. package/bin/vm-hands/hands-worker-source-yxsap3qk.js +0 -2
  80. package/bin/vm-hands/install-receipt-rmsjtfqy.js +0 -2
  81. package/bin/vm-hands/local-automation-7qcnytj6.js +0 -2
  82. package/bin/vm-hands/local-capabilities-hchsc804.js +0 -2
  83. package/bin/vm-hands/local-desktop-users-c6858avg.js +0 -2
  84. package/bin/vm-hands/local-display-mac-zmbp9z4c.js +0 -2
  85. package/bin/vm-hands/local-display-session-7bgp7gvf.js +0 -2
  86. package/bin/vm-hands/local-pty-session-8m175hqx.js +0 -2
  87. package/bin/vm-hands/managed-runtime-nkmg5s5h.js +0 -2
  88. package/bin/vm-hands/network-contract-qt2s82ap.js +0 -2
  89. package/bin/vm-hands/package-11mkdcmn.js +0 -2
  90. package/bin/vm-hands/permissions-67xv16a5.js +0 -2
  91. package/bin/vm-hands/reason-hands-protocol-r356wr4t.js +0 -2
  92. package/bin/vm-hands/serve-service-4n7e0b08.js +0 -2
  93. package/bin/vm-hands/status-e7r62q4e.js +0 -10
  94. package/bin/vm-hands/version-vdev7tyq.js +0 -2
  95. package/bin/vm-hands/vm-hands-entry-lite-8bzqc4xa.js +0 -2
  96. package/bin/vm-hands/vm-hands-entry-lite-qffs74x1.js +0 -540
  97. package/bin/vm-hands/vm-hands-entry-lite-rwr09j4w.js +0 -3
  98. package/bin/vm-hands/vm-hands-entry-lite-w8kc4jtb.js +0 -3
  99. package/bin/vm-hands/vm-hands-op-runner-kh1myd15.js +0 -2
  100. package/bin/vm-hands/worker-sandbox-x8dsz324.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{jr,Ur,Hr,qt}from"./vm-hands-entry-lite-mvx29q2q.js";import{Ui,Hi,k,Er,xr,_n,et,yn,kr,Fe,ye,wn,je,te,Ue,we,Dt,Cr,Ar,vn}from"./vm-hands-entry-lite-g3ja0c3y.js";import{Kt}from"./vm-hands-entry-lite-hcw5tk5d.js";import{Ot}from"./vm-hands-entry-lite-51qvfk93.js";import{Se}from"./vm-hands-entry-lite-0n2f3kx7.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{Hr,qr,zr,Wt}from"./vm-hands-entry-lite-8t9xssf9.js";import{qi,zi,k,kr,Cr,wn,tt,bn,Ar,je,ye,vn,Ue,te,He,we,Lt,Pr,Tr,En}from"./vm-hands-entry-lite-22kfyvnk.js";import{Zt}from"./vm-hands-entry-lite-m11j0f9q.js";import{Dt}from"./vm-hands-entry-lite-bdhjpv7g.js";import{Se}from"./vm-hands-entry-lite-pgb514h0.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 I}from"crypto";var H=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 c=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 bt=/^[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("|")+"))"+bt.source.slice(1),V=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),w="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="^(?:"+w+"|"+E.slice(1,-1)+")$",R=new RegExp(n);function ur(u){return R.test(u)}var Ze=Object.freeze({tokenPath:"/identity/token",awsPath:"/identity/aws",tokenPattern:/^[A-Za-z0-9_.~-]+$/.source}),W=Object.freeze({variables:256,valueBytes:130816,snapshotBytes:1048576}),Z=Object.freeze({valueChars:16384,snapshotBytes:65536});var l=["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 D=2,O="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"],A=d.join(":"),T=["/opt/homebrew/bin",...d].join(":"),P='(platform, linuxPath, macosPath) => platform === "darwin" ? macosPath : linuxPath';var N=String.raw`(function(anchor, pid, native) {
312
+ `;var s="a3e39eb55160acfc116fa9871ccc594c68be7a642d2331b24baa707c8f601ec0";import{createHash as I}from"crypto";var H=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 c=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 St=/^[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("|")+"))"+St.source.slice(1),V=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),w="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="^(?:"+w+"|"+E.slice(1,-1)+")$",R=new RegExp(n);function pr(u){return R.test(u)}var Xe=Object.freeze({tokenPath:"/identity/token",awsPath:"/identity/aws",tokenPattern:/^[A-Za-z0-9_.~-]+$/.source}),W=Object.freeze({variables:256,valueBytes:130816,snapshotBytes:1048576}),Z=Object.freeze({valueChars:16384,snapshotBytes:65536});var l=["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 D=2,O="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"],A=d.join(":"),T=["/opt/homebrew/bin",...d].join(":"),P='(platform, linuxPath, macosPath) => platform === "darwin" ? macosPath : linuxPath';var N=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
- })`,Ao=String.raw`
351
+ })`,To=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(c)};
361
361
  const DEVICE_ENVIRONMENT_NAME_RE = new RegExp(${JSON.stringify(n)});
362
- const DEVICE_CLOUD_ACCESS_POLICY = ${JSON.stringify(Ze)};
362
+ const DEVICE_CLOUD_ACCESS_POLICY = ${JSON.stringify(Xe)};
363
363
  const DEVICE_ENVIRONMENT_LIMITS = ${JSON.stringify(W)};
364
364
 
365
365
  const VERSION = ${k};
@@ -369,33 +369,33 @@ const GUEST_MEMORY_UNAVAILABLE_REASONS = ${JSON.stringify(r)};
369
369
  const sampleGuestMemory = ${o};
370
370
  const inspectMacPtyMember = ${N};
371
371
  const probeLinuxPtyLibrary = ${C};
372
- const windowsPtyApi = ${Ot};
372
+ const windowsPtyApi = ${Dt};
373
373
  const LINUX_PTY_EXEC_SOURCE = ${JSON.stringify(x)};
374
- const CLOSE_CODES = ${JSON.stringify(Ar)};
374
+ const CLOSE_CODES = ${JSON.stringify(Tr)};
375
375
  const SHA256_RE = /^[0-9a-f]{64}$/;
376
- const MAX_FRAME_BYTES = ${Er};
377
- const MAX_INPUT_CHARS = ${xr};
378
- const MAX_STRUCTURED_INPUT_CHARS = ${_n};
379
- const MAX_OUTPUT_CHARS = ${et};
380
- const WORKSPACE_BEFORE_MAX_OUTPUT_CHARS = ${vn};
381
- const MAX_ERROR_CHARS = ${yn};
376
+ const MAX_FRAME_BYTES = ${kr};
377
+ const MAX_INPUT_CHARS = ${Cr};
378
+ const MAX_STRUCTURED_INPUT_CHARS = ${wn};
379
+ const MAX_OUTPUT_CHARS = ${tt};
380
+ const WORKSPACE_BEFORE_MAX_OUTPUT_CHARS = ${En};
381
+ const MAX_ERROR_CHARS = ${bn};
382
382
  const MAX_LEDGER_IDS = 16384;
383
383
  const MAX_CACHED_RESULTS = 256;
384
- const MAX_JOB_INPUT_CHARS = ${kr};
385
- const MAX_JOB_OUTPUT_CHARS = ${Fe};
384
+ const MAX_JOB_INPUT_CHARS = ${Ar};
385
+ const MAX_JOB_OUTPUT_CHARS = ${je};
386
386
  const MAX_JOB_OUTPUT_CHUNKS = ${ye};
387
- const MAX_JOBS = ${wn};
387
+ const MAX_JOBS = ${vn};
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 = ${je};
390
+ const MAX_JOB_CONTROL_FRAME_BYTES = ${Ue};
391
391
  const MAX_PTY_INPUT_BYTES = ${te};
392
- const MAX_PTY_OUTPUT_BYTES = ${Ue};
392
+ const MAX_PTY_OUTPUT_BYTES = ${He};
393
393
  const MAX_PTY_DIMENSION = ${we};
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 ? ${Kt}(require) : null;
398
+ const windowsJobs = WINDOWS ? ${Zt}(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) {
@@ -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(qt.source)}).exec(config.workRoot);
580
+ const cloud = new RegExp(${JSON.stringify(Wt.source)}).exec(config.workRoot);
581
581
  if (process.platform === "linux" && cloud) {
582
582
  const workspaceId = cloud[3];
583
- const owner = (new RegExp(${JSON.stringify(Ur.source)}).exec(workspaceId) || [])[1]
584
- ?? (new RegExp(${JSON.stringify(Hr.source)}).exec(workspaceId) || [])[1] ?? workspaceId;
585
- return config.jobEnvSourcePath === ${JSON.stringify(jr)} + "/" + owner + "/job.env";
583
+ const owner = (new RegExp(${JSON.stringify(qr.source)}).exec(workspaceId) || [])[1]
584
+ ?? (new RegExp(${JSON.stringify(zr.source)}).exec(workspaceId) || [])[1] ?? workspaceId;
585
+ return config.jobEnvSourcePath === ${JSON.stringify(Hr)} + "/" + 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.
@@ -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 > ${Dt}) throw new Error("pty_cleanup_timeout");
2350
+ if (Date.now() - startedAt > ${Lt}) 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 > ${Dt}) throw new Error("pty_cleanup_timeout");
2798
+ if (Date.now() - startedAt > ${Lt}) 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")), ${Cr});
2814
+ exitTimer = setTimeout(() => reject(new Error("pty_anchor_exit_unconfirmed")), ${Pr});
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 = "${Ui}";
3365
+ const PI_TOOL_CONFINEMENT_TOKEN = "${qi}";
3366
3366
  function validPiToolConfinement(value) {
3367
3367
  return hasOnlyKeys(value, ["template", "quoteDepth"]) && typeof value.template === "string"
3368
- && value.template.length <= ${Hi} && !value.template.includes("\0")
3368
+ && value.template.length <= ${zi} && !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 S=I("sha256").update(Ao,"utf8").digest("hex");
4180
- export{bt,ur,Ze,W,D,O,Ao,S};
4179
+ `.trimStart();var S=I("sha256").update(To,"utf8").digest("hex");
4180
+ export{St,pr,Xe,W,D,O,To,S};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{t,o,i,Q,oe,s,n}from"./vm-hands-entry-lite-zn0v259d.js";var Xe=32768,St=67108864,fr=16384,E=204800,ln=600000,_=["content-type","anthropic-version","user-agent"],m=s(["openai-completions","openai-responses","anthropic-messages"]),f=new Set(_),C=oe(t(),t().max(2048)).refine((e)=>Object.keys(e).every((r)=>f.has(r))&&Object.values(e).every((r)=>!/[\r\n\0]/.test(r)),"Only non-secret custom endpoint request headers are permitted");function u(e){try{let r=new URL(e);return["http:","https:"].includes(r.protocol)&&!r.username&&!r.password&&!r.search&&!r.hash?r:null}catch{return null}}function mr(e,r){let c=u(e.baseUrl),l=u(r.baseUrl),a=u(e.url);if(!c||!l||!a||e.method!=="POST"||r.execution!=="device")return!1;let d=(p)=>p.origin+p.pathname.replace(/\/+$/,"");if(d(c)!==d(l)||a.origin!==c.origin)return!1;let h=r.api==="openai-completions"?"/chat/completions":r.api==="openai-responses"?"/responses":"/v1/messages";return a.pathname===c.pathname.replace(/\/+$/,"")+h}var un=i({baseUrl:t().max(2048),url:t().max(4096),method:n("POST"),body:t().refine((e)=>new TextEncoder().encode(e).byteLength<=E).optional(),headers:C,credentialOrganizationId:t().uuid(),accountKey:t().min(1).max(256).optional()}).strict().refine((e)=>m.options.some((r)=>mr(e,{baseUrl:e.baseUrl,api:r,execution:"device"})),"Invalid custom endpoint inference URL"),x=i({status:o().int().min(200).max(599),statusText:t().max(256).refine((e)=>!/[\r\n\0]/.test(e)),headers:oe(t(),t().max(4096)).refine((e)=>Object.keys(e).every((r)=>["content-type","retry-after","x-request-id","request-id"].includes(r))&&Object.values(e).every((r)=>!/[\r\n\0]/.test(r)))}).strict(),D=Q([i({eof:n(!0)}).strict(),i({eof:n(!1),data:t().max(Math.ceil(Xe/3)*4).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/).refine((e)=>e.length>0&&e.length*3/4-(e.endsWith("==")?2:e.endsWith("=")?1:0)<=Xe)}).strict()]),y=i({bytes:o().int().min(0).max(St),chunks:o().int().min(0).max(fr)}).strict(),dn=i({apiKey:t().min(1).max(16384).refine((e)=>!/[\r\n\0]/.test(e)),api:m}).strict(),S=["custom_endpoint_host_not_found","custom_endpoint_connection_failed","custom_endpoint_tls_failed"];function pn(e){return typeof e==="string"&&S.includes(e)}var g="Ollama listens only on 127.0.0.1 unless it is started with OLLAMA_HOST=0.0.0.0.",T={custom_endpoint_host_not_found:"Your computer couldn't resolve your model server's hostname. Check the hostname in the Base URL, and that this computer is on the network or tailnet that resolves it.",custom_endpoint_connection_failed:`Your computer's connection to your model server was refused or timed out. Check that the server is running and listening on the Base URL's address and port. ${g}`,custom_endpoint_tls_failed:"Your computer couldn't make a secure (TLS) connection to your model server. Check the server's https certificate, or use an http:// Base URL for a server on your computer or private network.",401:"Your model server refused the request (HTTP 401). Check the API key saved for it in Models.",403:"Your model server refused the request (HTTP 403). Ollama refuses requests addressed to a hostname other than localhost, such as a *.ts.net name from tailscale serve or funnel: restart it with OLLAMA_HOST=0.0.0.0, or use http://localhost:11434/v1 when it runs on the session's computer. For another server, check the API key and its access rules.",404:"Your model server answered HTTP 404 (not found). Check that the Base URL is the API root (for Ollama, http://localhost:11434/v1) and that each model ID is one the server lists."};var I=new Set(Object.values(T));export{Xe,St,fr,ln,mr,un,dn,pn};
2
+ import{t,o,i,Q,oe,s,n}from"./vm-hands-entry-lite-907pa7f9.js";var Ye=32768,xt=67108864,gr=16384,E=204800,dn=600000,_=["content-type","anthropic-version","user-agent"],m=s(["openai-completions","openai-responses","anthropic-messages"]),f=new Set(_),C=oe(t(),t().max(2048)).refine((e)=>Object.keys(e).every((r)=>f.has(r))&&Object.values(e).every((r)=>!/[\r\n\0]/.test(r)),"Only non-secret custom endpoint request headers are permitted");function u(e){try{let r=new URL(e);return["http:","https:"].includes(r.protocol)&&!r.username&&!r.password&&!r.search&&!r.hash?r:null}catch{return null}}function _r(e,r){let c=u(e.baseUrl),l=u(r.baseUrl),a=u(e.url);if(!c||!l||!a||e.method!=="POST"||r.execution!=="device")return!1;let d=(p)=>p.origin+p.pathname.replace(/\/+$/,"");if(d(c)!==d(l)||a.origin!==c.origin)return!1;let h=r.api==="openai-completions"?"/chat/completions":r.api==="openai-responses"?"/responses":"/v1/messages";return a.pathname===c.pathname.replace(/\/+$/,"")+h}var pn=i({baseUrl:t().max(2048),url:t().max(4096),method:n("POST"),body:t().refine((e)=>new TextEncoder().encode(e).byteLength<=E).optional(),headers:C,credentialOrganizationId:t().uuid(),accountKey:t().min(1).max(256).optional()}).strict().refine((e)=>m.options.some((r)=>_r(e,{baseUrl:e.baseUrl,api:r,execution:"device"})),"Invalid custom endpoint inference URL"),x=i({status:o().int().min(200).max(599),statusText:t().max(256).refine((e)=>!/[\r\n\0]/.test(e)),headers:oe(t(),t().max(4096)).refine((e)=>Object.keys(e).every((r)=>["content-type","retry-after","x-request-id","request-id"].includes(r))&&Object.values(e).every((r)=>!/[\r\n\0]/.test(r)))}).strict(),D=Q([i({eof:n(!0)}).strict(),i({eof:n(!1),data:t().max(Math.ceil(Ye/3)*4).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/).refine((e)=>e.length>0&&e.length*3/4-(e.endsWith("==")?2:e.endsWith("=")?1:0)<=Ye)}).strict()]),y=i({bytes:o().int().min(0).max(xt),chunks:o().int().min(0).max(gr)}).strict(),hn=i({apiKey:t().min(1).max(16384).refine((e)=>!/[\r\n\0]/.test(e)),api:m}).strict(),S=["custom_endpoint_host_not_found","custom_endpoint_connection_failed","custom_endpoint_tls_failed"];function fn(e){return typeof e==="string"&&S.includes(e)}var g="Ollama listens only on 127.0.0.1 unless it is started with OLLAMA_HOST=0.0.0.0.",T={custom_endpoint_host_not_found:"Your computer couldn't resolve your model server's hostname. Check the hostname in the Base URL, and that this computer is on the network or tailnet that resolves it.",custom_endpoint_connection_failed:`Your computer's connection to your model server was refused or timed out. Check that the server is running and listening on the Base URL's address and port. ${g}`,custom_endpoint_tls_failed:"Your computer couldn't make a secure (TLS) connection to your model server. Check the server's https certificate, or use an http:// Base URL for a server on your computer or private network.",401:"Your model server refused the request (HTTP 401). Check the API key saved for it in Models.",403:"Your model server refused the request (HTTP 403). Ollama refuses requests addressed to a hostname other than localhost, such as a *.ts.net name from tailscale serve or funnel: restart it with OLLAMA_HOST=0.0.0.0, or use http://localhost:11434/v1 when it runs on the session's computer. For another server, check the API key and its access rules.",404:"Your model server answered HTTP 404 (not found). Check that the Base URL is the API root (for Ollama, http://localhost:11434/v1) and that each model ID is one the server lists."};var I=new Set(Object.values(T));export{Ye,xt,gr,dn,_r,pn,hn,fn};
@@ -1,7 +1,7 @@
1
1
  // @bun
2
- import{vt}from"./vm-hands-entry-lite-6p9c8nhf.js";import{fe,se,x}from"./vm-hands-entry-lite-zg3b0c08.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{spawn as J,spawnSync as ee}from"child_process";import{existsSync as y,mkdtempSync as ne,readFileSync as K,readdirSync as te,realpathSync as re,rmSync as oe,statSync as G}from"fs";import{platform as T,tmpdir as ie}from"os";import{dirname as M,join as c,win32 as w}from"path";import{fileURLToPath as ae,pathToFileURL as W}from"url";var le=["bwrap","socat","rg"],de=2000;var ce=3,L=4000,ue=new Set([".git",".hg",".svn","node_modules"]),me=["runAsHostUid","sysrq-trigger"],X=c(M(M(ae(import.meta.url))),"packages","sandbox-runtime"),pe=c(X,"src","index.ts"),z=!1;function Ii(){z=!0}function j(){return z?c(M(re(process.execPath)),"runtime","srt"):void 0}function P(){let e=c(j()??X,"vendor","srt-win");return c(e,process.arch,"srt-win.exe")}async function Y(){let e=j();if(e&&process.platform==="linux"&&!y(c(e,"vendor","seccomp",process.arch,"apply-seccomp")))throw Error("packaged_sandbox_runtime_vendor_missing");if(e&&process.platform==="win32"&&!y(P()))throw Error("packaged_sandbox_runtime_vendor_missing");if(e){let i=K(c(e,"sandbox-runtime.mjs"),"utf8");for(let s of me)if(!i.includes(s))throw Error(`packaged_sandbox_runtime_fork_missing:${s}`)}let n=(await import(e?W(c(e,"sandbox-runtime.mjs")).href:W(pe).href)).SandboxManager;if(!n||typeof n.initialize!=="function"||typeof n.wrapWithSandboxArgv!=="function")throw Error("sandbox-runtime does not expose the expected SandboxManager API.");return{SandboxManager:n}}function ge(e={}){if((e.platformName??T())!=="linux")return!1;let o=e.fileExists??y,n=e.readFile??((i)=>K(i,"utf8"));for(let i of["/.dockerenv","/run/.containerenv"])try{if(o(i))return!0}catch{}try{return/docker|containerd|kubepods|lxc|libpod/.test(n("/proc/1/cgroup"))}catch{return!1}}function we(e){return["/bin/true","/usr/bin/true"].find((t)=>e(t))??null}function Se(e,t){return e==="strict"?["--ro-bind","/","/","--unshare-pid","--unshare-user","--cap-drop","ALL","--proc","/proc","--",t]:["--ro-bind","/","/","--unshare-pid","--unshare-user","--bind","/proc","/proc","--",t]}function be(e,t){try{let o=ee("bwrap",Se(e,t),{stdio:"ignore",timeout:de});return!o.error&&o.status===0}catch{return!1}}function xe(e){let t=e.platformName??T(),o=e.fileExists??y;if(t==="win32")return(e.bash??fe)()&&o(P())?m??"strict":null;if(t!=="linux")return null;let n=e.hasExecutable??vt;if(!le.every((l)=>n(l)))return null;let i=we(o);if(!i)return null;let s=m??(e.containerized??ge({platformName:t})?"weak":"strict");return(e.probeNamespaces??((l)=>be(l,i)))(s)?s:null}var S=null,C=!1,p=null,F=null;var m=null,E=null,A=null,R=null,v=[],g=new Map;function D(){throw b("sandbox_mode_conflict"),new r("sandbox_unavailable","Sandbox process policy conflicts with an existing probe or session. Restart the worker.")}function Di(e){if(m!==null&&m!==e||C&&S!==null&&S!==e||E!==null&&E!==e)D();m=e}function b(e){if(!p)process.stderr.write(`Reason worker: confined commands are off (${e})
3
- `);p=e}function dr(e){if(p)return!1;if(!C){if(S=xe(e??{}),C=!0,S&&!e)Ce()}return S!==null}function he(){return dr()?S:null}var _=null,h=0;function I(e,t){if(p)throw new r("sandbox_unavailable","Confined execution is unavailable in this worker process.");if(m&&e.sandboxMode&&m!==e.sandboxMode)D();let o=m??e.sandboxMode??he();if(!o)throw new r("sandbox_unavailable","Confined command execution is unavailable on this operating system.");if(E&&E!==o)D();return E=o,_??=(async()=>{let{SandboxManager:n}=await(e.loadSandboxRuntime??Y)();return await n.initialize(Ne(o,t)),n})().catch((n)=>{if(_=null,t)A=null,process.stderr.write(`Reason worker: the Windows sandbox did not start for this folder (${String(n).slice(0,500)})
2
+ import{Et}from"./vm-hands-entry-lite-hj8n59y9.js";import{fe,se,x}from"./vm-hands-entry-lite-9ay6f56v.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{spawn as J,spawnSync as ee}from"child_process";import{existsSync as y,mkdtempSync as ne,readFileSync as K,readdirSync as te,realpathSync as re,rmSync as oe,statSync as G}from"fs";import{platform as T,tmpdir as ie}from"os";import{dirname as M,join as c,win32 as w}from"path";import{fileURLToPath as ae,pathToFileURL as W}from"url";var le=["bwrap","socat","rg"],de=2000;var ce=3,L=4000,ue=new Set([".git",".hg",".svn","node_modules"]),me=["runAsHostUid","sysrq-trigger"],X=c(M(M(ae(import.meta.url))),"packages","sandbox-runtime"),pe=c(X,"src","index.ts"),z=!1;function Ni(){z=!0}function j(){return z?c(M(re(process.execPath)),"runtime","srt"):void 0}function P(){let e=c(j()??X,"vendor","srt-win");return c(e,process.arch,"srt-win.exe")}async function Y(){let e=j();if(e&&process.platform==="linux"&&!y(c(e,"vendor","seccomp",process.arch,"apply-seccomp")))throw Error("packaged_sandbox_runtime_vendor_missing");if(e&&process.platform==="win32"&&!y(P()))throw Error("packaged_sandbox_runtime_vendor_missing");if(e){let i=K(c(e,"sandbox-runtime.mjs"),"utf8");for(let s of me)if(!i.includes(s))throw Error(`packaged_sandbox_runtime_fork_missing:${s}`)}let n=(await import(e?W(c(e,"sandbox-runtime.mjs")).href:W(pe).href)).SandboxManager;if(!n||typeof n.initialize!=="function"||typeof n.wrapWithSandboxArgv!=="function")throw Error("sandbox-runtime does not expose the expected SandboxManager API.");return{SandboxManager:n}}function ge(e={}){if((e.platformName??T())!=="linux")return!1;let o=e.fileExists??y,n=e.readFile??((i)=>K(i,"utf8"));for(let i of["/.dockerenv","/run/.containerenv"])try{if(o(i))return!0}catch{}try{return/docker|containerd|kubepods|lxc|libpod/.test(n("/proc/1/cgroup"))}catch{return!1}}function we(e){return["/bin/true","/usr/bin/true"].find((t)=>e(t))??null}function Se(e,t){return e==="strict"?["--ro-bind","/","/","--unshare-pid","--unshare-user","--cap-drop","ALL","--proc","/proc","--",t]:["--ro-bind","/","/","--unshare-pid","--unshare-user","--bind","/proc","/proc","--",t]}function be(e,t){try{let o=ee("bwrap",Se(e,t),{stdio:"ignore",timeout:de});return!o.error&&o.status===0}catch{return!1}}function xe(e){let t=e.platformName??T(),o=e.fileExists??y;if(t==="win32")return(e.bash??fe)()&&o(P())?m??"strict":null;if(t!=="linux")return null;let n=e.hasExecutable??Et;if(!le.every((l)=>n(l)))return null;let i=we(o);if(!i)return null;let s=m??(e.containerized??ge({platformName:t})?"weak":"strict");return(e.probeNamespaces??((l)=>be(l,i)))(s)?s:null}var S=null,C=!1,p=null,F=null;var m=null,E=null,A=null,R=null,v=[],g=new Map;function D(){throw b("sandbox_mode_conflict"),new r("sandbox_unavailable","Sandbox process policy conflicts with an existing probe or session. Restart the worker.")}function Li(e){if(m!==null&&m!==e||C&&S!==null&&S!==e||E!==null&&E!==e)D();m=e}function b(e){if(!p)process.stderr.write(`Reason worker: confined commands are off (${e})
3
+ `);p=e}function hr(e){if(p)return!1;if(!C){if(S=xe(e??{}),C=!0,S&&!e)Ce()}return S!==null}function he(){return hr()?S:null}var _=null,h=0;function I(e,t){if(p)throw new r("sandbox_unavailable","Confined execution is unavailable in this worker process.");if(m&&e.sandboxMode&&m!==e.sandboxMode)D();let o=m??e.sandboxMode??he();if(!o)throw new r("sandbox_unavailable","Confined command execution is unavailable on this operating system.");if(E&&E!==o)D();return E=o,_??=(async()=>{let{SandboxManager:n}=await(e.loadSandboxRuntime??Y)();return await n.initialize(Ne(o,t)),n})().catch((n)=>{if(_=null,t)A=null,process.stderr.write(`Reason worker: the Windows sandbox did not start for this folder (${String(n).slice(0,500)})
4
4
  `);else b(`initialize_failed: ${String(n)}`);throw n instanceof r?n:new r("sandbox_unavailable","The confined execution sandbox failed to start.")}),_.then((n)=>{if(p)throw new r("sandbox_unavailable","Confined execution became unavailable during sandbox initialization.");return n})}function O(){if(h-=1,h===0)for(let e of v.splice(0))e()}async function ye(e,t=!0,o,n){let i=n===void 0?1/0:Date.now()+n;await Q();let s=_e();if(t)await s;let a=JSON.stringify(e),l=!1,u=()=>{if(!l)return;l=!1;let d=(g.get(a)??1)-1;if(d>0)g.set(a,d);else g.delete(a)};try{for(;;){if(o?.aborted)throw new r("cancelled","Operation was cancelled.");if(Date.now()>=i)return!1;if(R){await R;continue}let d=g.keys().next().value;if(A??=d??a,A===a&&(d===void 0||d===a))break;if(!l){l=!0,g.set(a,(g.get(a)??0)+1);continue}if(h===0&&d===a){Pe();continue}await new Promise((f)=>{if(v.push(f),o?.addEventListener("abort",()=>f(),{once:!0}),i!==1/0)setTimeout(f,Math.max(0,i-Date.now())).unref?.()})}return h+=1,!0}finally{if(l&&h===0)for(let d of v.splice(0))d();u()}}function Pe(){return R??=Me().finally(()=>{R=null}),R}function Ee(e,t,o=process.env){let n=o.USERPROFILE?w.resolve(o.USERPROFILE).toLowerCase():null,i=w.resolve(e).toLowerCase(),s=n!==null&&i.startsWith(`${n}\\`),a=t?q(o).filter((l)=>l.toLowerCase()===i||l.toLowerCase().startsWith(`${i}\\`)):[];return{denyRead:[],allowRead:[e],allowWrite:t?[e]:[],denyWrite:t?a:s?[]:[e]}}function q(e,t=process.execPath){let o=new Map;for(let n of[...(e.PATH??e.Path??"").split(";"),w.dirname(t)]){if(!n||!w.isAbsolute(n))continue;let i=w.resolve(n);if(!o.has(i.toLowerCase()))o.set(i.toLowerCase(),i)}return[...o.values()]}function Re(e=process.env,t=process.execPath){let o=[e.SystemRoot,e.ProgramFiles,e["ProgramFiles(x86)"],e.ProgramW6432,e.ProgramData,e.USERPROFILE].filter((n)=>!!n).map((n)=>w.resolve(n).toLowerCase());return q(e,t).filter((n)=>{let i=n.toLowerCase();return!o.some((s)=>i===s||i.startsWith(`${s}\\`))})}var U=null,H=null;function Q(e=P()){return H??=(async()=>{let t;try{t=JSON.parse((await V(e,["status"])).stdout).user?.user?.sid}catch{return null}if(typeof t!=="string"||!/^S-1-[0-9-]+$/.test(t))return null;if(!await new Promise((n)=>{let i=J(x("icacls"),[e,"/grant",`*${t}:(RX)`],{stdio:"ignore",windowsHide:!0,timeout:30000});i.on("error",()=>n(!1)),i.on("close",(s)=>n(s===0))}))process.stderr.write(`Reason worker: could not let the Windows sandbox user run srt-win.exe
5
5
  `);return t})(),H}function V(e,t,o){return new Promise((n)=>{let i=J(e,t,{stdio:["pipe","pipe","ignore"],windowsHide:!0,timeout:120000}),s="";i.stdout?.setEncoding("utf8").on("data",(a)=>{s+=a}),i.on("error",()=>n({status:null,stdout:s})),i.on("close",(a)=>n({status:a,stdout:s})),i.stdin?.end(o??"")})}function _e(e=P()){return U??=(async()=>{let t=Re();if(t.length===0)return;let o=await Q(e),n=o?await V(e,["acl","stamp","--holder-pid",String(process.ppid),"--sandbox-user-sid",o],JSON.stringify({denyRead:[],denyWrite:t})):null;if(!n||n.status!==0&&n.status!==2)b(`program_folder_deny_failed: ${n?`exit ${n.status}`:"no sandbox user"}`),process.stderr.write(`Reason worker: could not deny the Windows sandbox writes to PATH folders (${n?`exit ${n.status}`:"no sandbox user"}); confined commands are off
6
- `)})(),U}var Ae=`h=$(mktemp -d) || exit 125; trap 'rm -rf "$h"' EXIT; mkdir -p "$h/AppData/Roaming" "$h/AppData/Local"; w=$(cygpath -w "$h"); export HOME="$h" USERPROFILE="$w" APPDATA="$w\\AppData\\Roaming" LOCALAPPDATA="$w\\AppData\\Local" TEMP="$w" TMP="$w"; `;async function Me(){let e=_;if(_=null,A=null,!e)return;try{await(await e).reset()}catch{}}async function Ce(e={}){if(p)return!1;if(e.loadSandboxRuntime)return B(e.loadSandboxRuntime);if(!dr())return!1;return F??=B(Y),F}async function B(e){try{let{SandboxManager:t}=await e();if(process.platform==="win32"){if(!y(P()))b("dependencies_missing: srt-win.exe");return!p}let o=t.checkDependencies().errors;if(o.length>0)return b(`dependencies_missing: ${o.join(", ")}`),!1;return!p}catch(t){return b(`load_failed: ${String(t)}`),!1}}function sn(e=y,t=T()){if(t==="win32")return se("win32");return["/bin/bash","/bin/sh"].find((o)=>e(o))??"/bin/sh"}function ve(e){return e.map((t)=>`'${t.replaceAll("'","'\\''")}'`).join(" ")}function De(e,t,o=(n)=>te(n,{withFileTypes:!0}).filter((i)=>i.isDirectory()||i.isFile()).map((i)=>i.name)){let n=[],i=[{path:e,depth:0}],s=0;while(i.length>0&&s<L){let a=i.pop(),l;try{l=o(a.path)}catch{continue}for(let u of l){if(s+=1,s>L)break;let d=c(a.path,u);if(t(d)){n.push(d);continue}if(a.depth+1<ce&&!ue.has(u))i.push({path:d,depth:a.depth+1})}}return n}function Te(e){let t=c(e.root,".git"),o=[];try{if(G(t).isDirectory())o=[c(t,"config"),c(t,"hooks")]}catch{}return{denyRead:["/home","/root","/tmp","/tmp/.X11-unix",...e.protectedPaths],allowRead:[e.root,e.temporaryDirectory],allowWrite:[...e.allowWrite?[e.root]:[],e.temporaryDirectory],denyWrite:[...e.protectedPaths,...o]}}function ke(e,t){let o=c(t,".git"),n=[];try{if(G(o).isDirectory())n=[c(o,"config"),c(o,"hooks")]}catch{}return{denyRead:[...e],allowRead:[],allowWrite:[],denyWrite:[...e,...n]}}function Ne(e,t){if(t)return{network:{allowedDomains:[],deniedDomains:[]},filesystem:t,windows:{srtWin:{path:P()}}};return{network:{allowedDomains:[],deniedDomains:[]},filesystem:{denyRead:[],allowRead:[],allowWrite:[],denyWrite:[]},...e==="weak"?{enableWeakerNestedSandbox:!0}:{}}}function Ni(e){let t=e.createTemporaryDirectory??(()=>ne(c(ie(),"reason-device-"))),o=e.removeTemporaryDirectory??((n)=>oe(n,{recursive:!0,force:!0}));return async(n,i,s)=>{let a=process.platform==="win32",l;if(a){let d=Ee(s.root,s.allowWrite);if(!await ye(d,!s.workerProbe,s.signal,s.timeoutMs))return{exitCode:null,signal:null,stdout:"",stderr:"",timedOut:!0,truncated:!1};try{l=await I(e,d)}catch(f){throw O(),f}}else l=await I(e),h+=1;let u;try{u=t();let d=De(s.root,e.isProtectedPath),f;try{f=await l.wrapWithSandboxArgv((a?Ae:"")+ve([n,...i]),e.shell??sn(),{filesystem:a?ke(d,s.root):Te({root:s.root,allowWrite:s.allowWrite,temporaryDirectory:u,protectedPaths:d})},s.signal,s.cwd)}catch(N){throw N instanceof r?N:new r("sandbox_unavailable","The confined execution sandbox could not wrap the command.")}let[k,...Z]=f.argv;if(!k)throw new r("sandbox_unavailable","The confined execution sandbox produced no command.");return await e.spawnCaptured(k,Z,{cwd:s.cwd,timeoutMs:s.timeoutMs,signal:s.signal,env:a?f.env:e.scrubEnvironment(s.root,u)})}finally{O();try{l.cleanupAfterCommand()}catch{}if(u!==void 0)o(u)}}}
7
- export{Ii,Di,dr,sn,Ni};
6
+ `)})(),U}var Ae=`h=$(mktemp -d) || exit 125; trap 'rm -rf "$h"' EXIT; mkdir -p "$h/AppData/Roaming" "$h/AppData/Local"; w=$(cygpath -w "$h"); export HOME="$h" USERPROFILE="$w" APPDATA="$w\\AppData\\Roaming" LOCALAPPDATA="$w\\AppData\\Local" TEMP="$w" TMP="$w"; `;async function Me(){let e=_;if(_=null,A=null,!e)return;try{await(await e).reset()}catch{}}async function Ce(e={}){if(p)return!1;if(e.loadSandboxRuntime)return B(e.loadSandboxRuntime);if(!hr())return!1;return F??=B(Y),F}async function B(e){try{let{SandboxManager:t}=await e();if(process.platform==="win32"){if(!y(P()))b("dependencies_missing: srt-win.exe");return!p}let o=t.checkDependencies().errors;if(o.length>0)return b(`dependencies_missing: ${o.join(", ")}`),!1;return!p}catch(t){return b(`load_failed: ${String(t)}`),!1}}function cn(e=y,t=T()){if(t==="win32")return se("win32");return["/bin/bash","/bin/sh"].find((o)=>e(o))??"/bin/sh"}function ve(e){return e.map((t)=>`'${t.replaceAll("'","'\\''")}'`).join(" ")}function De(e,t,o=(n)=>te(n,{withFileTypes:!0}).filter((i)=>i.isDirectory()||i.isFile()).map((i)=>i.name)){let n=[],i=[{path:e,depth:0}],s=0;while(i.length>0&&s<L){let a=i.pop(),l;try{l=o(a.path)}catch{continue}for(let u of l){if(s+=1,s>L)break;let d=c(a.path,u);if(t(d)){n.push(d);continue}if(a.depth+1<ce&&!ue.has(u))i.push({path:d,depth:a.depth+1})}}return n}function Te(e){let t=c(e.root,".git"),o=[];try{if(G(t).isDirectory())o=[c(t,"config"),c(t,"hooks")]}catch{}return{denyRead:["/home","/root","/tmp","/tmp/.X11-unix",...e.protectedPaths],allowRead:[e.root,e.temporaryDirectory],allowWrite:[...e.allowWrite?[e.root]:[],e.temporaryDirectory],denyWrite:[...e.protectedPaths,...o]}}function ke(e,t){let o=c(t,".git"),n=[];try{if(G(o).isDirectory())n=[c(o,"config"),c(o,"hooks")]}catch{}return{denyRead:[...e],allowRead:[],allowWrite:[],denyWrite:[...e,...n]}}function Ne(e,t){if(t)return{network:{allowedDomains:[],deniedDomains:[]},filesystem:t,windows:{srtWin:{path:P()}}};return{network:{allowedDomains:[],deniedDomains:[]},filesystem:{denyRead:[],allowRead:[],allowWrite:[],denyWrite:[]},...e==="weak"?{enableWeakerNestedSandbox:!0}:{}}}function Mi(e){let t=e.createTemporaryDirectory??(()=>ne(c(ie(),"reason-device-"))),o=e.removeTemporaryDirectory??((n)=>oe(n,{recursive:!0,force:!0}));return async(n,i,s)=>{let a=process.platform==="win32",l;if(a){let d=Ee(s.root,s.allowWrite);if(!await ye(d,!s.workerProbe,s.signal,s.timeoutMs))return{exitCode:null,signal:null,stdout:"",stderr:"",timedOut:!0,truncated:!1};try{l=await I(e,d)}catch(f){throw O(),f}}else l=await I(e),h+=1;let u;try{u=t();let d=De(s.root,e.isProtectedPath),f;try{f=await l.wrapWithSandboxArgv((a?Ae:"")+ve([n,...i]),e.shell??cn(),{filesystem:a?ke(d,s.root):Te({root:s.root,allowWrite:s.allowWrite,temporaryDirectory:u,protectedPaths:d})},s.signal,s.cwd)}catch(N){throw N instanceof r?N:new r("sandbox_unavailable","The confined execution sandbox could not wrap the command.")}let[k,...Z]=f.argv;if(!k)throw new r("sandbox_unavailable","The confined execution sandbox produced no command.");return await e.spawnCaptured(k,Z,{cwd:s.cwd,timeoutMs:s.timeoutMs,signal:s.signal,env:a?f.env:e.scrubEnvironment(s.root,u)})}finally{O();try{l.cleanupAfterCommand()}catch{}if(u!==void 0)o(u)}}}
7
+ export{Ni,Li,hr,cn,Mi};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- var Ot=String.raw`(function(loadFfi, existsSync) {
2
+ var Dt=String.raw`(function(loadFfi, existsSync) {
3
3
  const STARTF_USESTDHANDLES = 0x100;
4
4
  const CREATE_SUSPENDED = 0x4;
5
5
  const CREATE_UNICODE_ENVIRONMENT = 0x400;
@@ -242,4 +242,4 @@ var Ot=String.raw`(function(loadFfi, existsSync) {
242
242
  }
243
243
  return { available, unavailableReason, defaultShell, shellArgs, quoteArg, environmentBlock, spawn };
244
244
  })`;
245
- export{Ot};
245
+ export{Dt};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{C}from"./vm-hands-entry-lite-t7an5zg2.js";import{basename as ln}from"path";var rt=["production","staging"],un="https://api.reasonmachines.com",fn="https://staging-api.reasonmachines.com";var A={production:{api:"https://api.reasonmachines.ai",app:"https://reasonmachines.ai"},staging:{api:"https://staging-api.reasonmachines.ai",app:"https://staging.reasonmachines.ai"}},gn=new Set(["ara-staging","ara-staging.exe","reason-staging","reason-staging.exe"]);function g(n={}){let e=C(n.env??process.env,"REASON_CLI_CHANNEL")?.trim().toLowerCase();if(e){if(rt.includes(e))return e;throw Error(`Unknown Reason CLI channel: ${e}`)}let r=ln(n.executablePath??process.execPath).toLowerCase();return gn.has(r)?"staging":"production"}function Lt(n){return n==="staging"?fn:un}var U={production:["https://api.ara.so",A.production.api],staging:["https://api-staging.ara.so",A.staging.api]};function Nr(n){let e;try{e=new URL(n).origin}catch{return n}let r=rt.find((t)=>U[t].includes(e));return r?Lt(r):e}function Wi(n,e){return n===e||Nr(n)===Nr(e)}function Vi(n,e){return rt.some((r)=>U[r].includes(n)&&e===Lt(r))}function Gi(n,e){try{let r=new URL(e);return!r.username&&!r.password&&(r.origin===Lt(n)||r.origin===A[n].api)}catch{return!1}}function Pn(n){try{let e=new URL(n).hostname.replace(/^\[|\]$/g,"").toLowerCase();return e==="localhost"||e==="127.0.0.1"||e==="::1"}catch{return!1}}import{randomBytes as J}from"crypto";import{chmodSync as q,closeSync as B,constants as bn,linkSync as V,lstatSync as I,mkdirSync as z,openSync as En,readdirSync as T,readFileSync as Kn,readlinkSync as R,renameSync as k,rmdirSync as Q,symlinkSync as S,unlinkSync as y}from"fs";import{createRequire as Nn}from"module";import{constants as Sn}from"os";import{basename as w,join as l,sep as kn}from"path";import{existsSync as D,lstatSync as j,readdirSync as pn,readFileSync as mn,readlinkSync as dn,realpathSync as yn}from"fs";import{join as d,sep as hn}from"path";function G(n,...e){let r=d(n,"ara"),t=d(n,"reason");if(!Lr(r))return d(t,...e);if(!D(t))return d(r,...e);return D(d(r,...e))&&!D(d(t,...e))?d(r,...e):d(t,...e)}function Lr(n){try{let e=j(n);if(!e.isSymbolicLink())return e.isDirectory();return dn(n)!=="reason"&&D(n)}catch{return!1}}function X(n,e=[]){if(!Lr(n))return!1;let r;try{r=[n,...pn(n,{withFileTypes:!0}).filter((t)=>t.isDirectory()).map((t)=>d(n,t.name))]}catch{return!1}return r.some((t)=>["connect","connect-once"].filter((i)=>!e.includes(d(t,i))).some((i)=>{let s=d(t,i,"worker.json");try{j(s)}catch{return!1}try{let a=JSON.parse(mn(s,"utf8"))?.stateDirectory;if(typeof a!=="string")return!0;let c=(o,u)=>o===u||o.startsWith(u+hn);return c(a,n)||c(M(a),M(n))}catch{return!0}}))}function M(n){try{return yn(n)}catch{return n}}var P=new Set(["credentials.json","local-device.json","local-device.revoked.json","local-device.auth-migration.json","local-device.json.registration-pending.json","local-daemon.json","local-daemon.json.workspaces.json","local-root-fingerprint-key.json","instances","workspaces"]),Z=new Set(["local-device.proxy.json"]),Cn=new Set(["local-device.key","local-device.binding"]),W=new Map;function nt(n,e,r){let t=l(n,"ara");if(process.platform==="win32"||/[/\\]\.reason-ssh[/\\][^/\\]+[/\\]installer-home[/\\]\.config$/.test(n))return{state:m(t)?.isDirectory()?"kept":"absent"};return vn(t,l(n,"reason"),{linkAlways:!0,kept:(i)=>X(i,r??[]),native:e===void 0?An:()=>e},r!==void 0)}function ve(n,...e){return nt(n),G(n,...e)}var nn="config_rename_unavailable:busy";function vn(n,e,r,t=!1){let i=t?void 0:W.get(n);if(i)return i;let s;try{s=_n(n,e,r)}catch(a){let c=`config_rename_unavailable:${E(a)??"failed"}`;try{return{state:m(n)?.isDirectory()?"kept":"absent",problem:c}}catch{return{state:"kept",problem:c}}}if(!(s.state==="absent"&&r.linkAlways)&&s.problem!==nn&&!(s.state==="kept"&&!s.problem))W.set(n,s);return s}function _n(n,e,r){wn(e,r.native);let t=!1;for(let i=0;i<8;i+=1){let s=m(n);if(s?.isSymbolicLink())return R(n)===w(e)?{state:t?"renamed":"linked"}:{state:"kept"};if(!s){if(L(e))f(()=>y(e),"ENOENT");if(!(t||r.linkAlways)||!x(e))return{state:"absent"};let o=_(e,"link");S(w(e),o);try{f(()=>k(o,n),"EISDIR","ENOTEMPTY","EEXIST","ENOTDIR")}finally{f(()=>y(o),"ENOENT")}continue}if(!s.isDirectory())return{state:"absent"};if(r.kept(n))return K(e),{state:"kept"};let a=r.native();if(!a)return K(e),{state:"kept",problem:"config_rename_unavailable:no_native"};let c=In(a,n);if(!c)return{state:"kept",problem:nn};try{if(I(n).isSymbolicLink())continue;let o=Rn(a,n,e);if(o)return{state:"kept",problem:o};t=!0}finally{c()}}throw Object.assign(Error("legacy directory rename did not settle"),{code:"unsettled"})}function Rn(n,e,r){let t=m(r);if(!t||L(r)){if(!t)S(w(r),r);try{n.exchange(e,r)}catch(o){if(L(r))f(()=>y(r),"ENOENT");return`config_rename_unavailable:${E(o)??"exchange_failed"}`}return null}if(!t.isDirectory())return"config_rename_unavailable:ENOTDIR";if(t.dev!==I(e).dev)return"config_rename_unavailable:EXDEV";let i=[_(r,"probe"),_(r,"probe")];try{S("a",i[0]),S("b",i[1]),n.exchange(i[0],i[1])}catch(o){return`config_rename_unavailable:${E(o)??"exchange_failed"}`}finally{for(let o of i)f(()=>y(o),"ENOENT")}let s=cn(r);for(let o of Cn){let u=m(l(r,o)),p=m(l(e,o));if(u&&p&&u.ino!==p.ino)z(`${s}-replaced`,{mode:448,recursive:!0}),k(l(r,o),l(`${s}-replaced`,o))}let a={linked:new Map,unitsKept:new Set};rn(e,r,"",a);let c=_(r,"rename");S(w(r),c);try{n.exchange(e,c)}catch(o){return f(()=>y(c),"ENOENT"),`config_rename_unavailable:${E(o)??"exchange_failed"}`}return tn(c,r,a,s),null}function en(n){return n===""||!n.includes(kn)}function rn(n,e,r,t){let i=en(r)&&sn(l(e,r),l(n,r));if(i)t.unitsKept.add(r);for(let s of T(l(n,r))){if(i&&(P.has(s)||Z.has(s)))continue;let a=l(r,s),c=l(n,a),o=l(e,a),u=m(c);if(!u)continue;let p=m(o);if(u.isDirectory()){if(!p)f(()=>z(o,{mode:u.mode&4095}),"EEXIST"),q(o,u.mode&4095);if(x(o))rn(n,e,a,t)}else if(!p){if(u.isSymbolicLink())f(()=>S(R(c),o),"EEXIST");else if(f(()=>V(c,o),"EEXIST","ENOENT"))t.linked.set(a,u.ino)}}}function wn(n,e){let r;try{if(!x(n))return;r=T(n)}catch{return}for(let t of r){let i=/^\.(rename|link|probe|claim)-(\d+)-[0-9a-f]+$/.exec(t);if(!i)continue;let s=l(n,t),a=m(s);if(!a)continue;if(!a.isDirectory()){if(!Y(Number(i[2])))f(()=>y(s),"ENOENT");continue}let c=e(),o=null;if(c){try{o=c.lock(s)}catch{continue}if(!o)continue}else if(Y(Number(i[2])))continue;try{let u=_(n,"claim");if(f(()=>k(s,u),"ENOENT"))tn(u,n,null,cn(n))}finally{o?.()}}}function tn(n,e,r,t){for(let[i,s]of r?.linked??[])if(!m(l(n,i))&&m(l(e,i))?.ino===s)f(()=>y(l(e,i)),"ENOENT");if(on(n,e,"",r),f(()=>Q(n),"ENOTEMPTY","EEXIST"))return;k(n,t),q(t,448)}function on(n,e,r,t){let i=en(r)&&(t?t.unitsKept.has(r):sn(l(e,r),l(n,r)));for(let s of T(l(n,r))){let a=l(r,s),c=l(n,a),o=l(e,a),u=I(c),p=m(o);if(p&&u.ino===p.ino&&u.dev===p.dev){y(c);continue}if(u.isFile()&&p?.isFile()&&t?.linked.get(a)===p.ino){k(c,o);continue}if(i&&(P.has(s)||Z.has(s)))continue;if(!p){if(u.isFile()){if(f(()=>V(c,o),"EEXIST"))y(c)}else f(()=>k(c,o),"EEXIST","ENOTEMPTY");continue}if(u.isDirectory()&&p.isDirectory())on(n,e,a,t),f(()=>Q(c),"ENOTEMPTY","EEXIST")}}function sn(n,e){for(let r of P)if(an(l(n,r),l(e,r)))return!0;return!1}function an(n,e){let r=m(n);if(!r)return!1;let t=m(e);if(!t)return!0;if(r.isDirectory()){if(!t.isDirectory())return!0;return T(n).some((i)=>an(l(n,i),l(e,i)))}if(r.isSymbolicLink())return!t.isSymbolicLink()||R(n)!==R(e);return r.ino!==t.ino||r.dev!==t.dev}function K(n){if(L(n))f(()=>y(n),"ENOENT")}function cn(n){return l(n,`.pre-rename-${new Date().toISOString().replace(/[:.]/g,"-")}-${J(3).toString("hex")}`)}function L(n){try{return I(n).isSymbolicLink()&&R(n)===w(n)}catch{return!1}}function x(n){let e=m(n);return e!==null&&e.isDirectory()}function In(n,e){for(let r=0;r<40;r+=1){let t=n.lock(e);if(t)return t;Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,50)}return null}function _(n,e){return l(n,`.${e}-${process.pid}-${J(6).toString("hex")}`)}function Y(n){if(n===process.pid)return!1;try{return process.kill(n,0),!0}catch(e){return E(e)==="EPERM"}}function m(n){try{return I(n)}catch(e){if(E(e)==="ENOENT"||E(e)==="ENOTDIR")return null;throw e}}function f(n,...e){try{return n(),!0}catch(r){if(e.includes(E(r)??""))return!1;throw r}}function E(n){return n instanceof Error&&"code"in n&&typeof n.code==="string"?n.code:void 0}var v,On=2,Dn=4,Ln=2,Tn=2,H=-100;function An(){if(v!==void 0)return v;if(v=null,process.platform!=="linux"&&process.platform!=="darwin")return null;let n;try{n=Nn(import.meta.url)("bun:ffi")}catch{return null}let e=process.platform==="darwin",r=e?"__error":"__errno_location",t=e?["/usr/lib/libSystem.B.dylib"]:["libc.so.6",`libc.musl-${process.arch==="arm64"?"aarch64":"x86_64"}.so.1`],{FFIType:i}=n;for(let s of t)try{let a=e?"renamex_np":"renameat2",o=n.dlopen(s,{flock:{args:[i.i32,i.i32],returns:i.i32},[r]:{args:[],returns:i.ptr},[a]:e?{args:[i.ptr,i.ptr,i.u32],returns:i.i32}:{args:[i.i32,i.ptr,i.i32,i.ptr,i.u32],returns:i.i32}}).symbols,u=o[r]();if(u===null)continue;let p=(N)=>{let b=n.read.i32(u),h=Object.entries(Sn.errno).find(([,O])=>O===b)?.[0]??`errno_${b}`;return Object.assign(Error(`${N} failed: ${h}`),{code:h})},F=(N)=>Buffer.from(`${N}\x00`,"utf8");return v={exchange(N,b){let h=F(N),O=F(b);if((e?o[a](n.ptr(h),n.ptr(O),Ln):o[a](H,n.ptr(h),H,n.ptr(O),Tn))!==0)throw p("exchange")},lock(N){let b=En(N,bn.O_RDONLY);if(o.flock(b,On|Dn)===0)return()=>B(b);let h=p("lock");if(B(b),h.code==="EWOULDBLOCK"||h.code==="EAGAIN")return null;throw h}},v}catch{}return null}
3
- export{rt,g,Lt,Nr,Wi,Vi,Gi,Pn,Lr,nt,ve};
2
+ import{C}from"./vm-hands-entry-lite-t7an5zg2.js";import{basename as ln}from"path";var nt=["production","staging"],un="https://api.reasonmachines.com",fn="https://staging-api.reasonmachines.com";var A={production:{api:"https://api.reasonmachines.ai",app:"https://reasonmachines.ai"},staging:{api:"https://staging-api.reasonmachines.ai",app:"https://staging.reasonmachines.ai"}},gn=new Set(["ara-staging","ara-staging.exe","reason-staging","reason-staging.exe"]);function g(n={}){let e=C(n.env??process.env,"REASON_CLI_CHANNEL")?.trim().toLowerCase();if(e){if(nt.includes(e))return e;throw Error(`Unknown Reason CLI channel: ${e}`)}let r=ln(n.executablePath??process.execPath).toLowerCase();return gn.has(r)?"staging":"production"}function $t(n){return n==="staging"?fn:un}var U={production:["https://api.ara.so",A.production.api],staging:["https://api-staging.ara.so",A.staging.api]};function Mr(n){let e;try{e=new URL(n).origin}catch{return n}let r=nt.find((t)=>U[t].includes(e));return r?$t(r):e}function Gi(n,e){return n===e||Mr(n)===Mr(e)}function Ki(n,e){return nt.some((r)=>U[r].includes(n)&&e===$t(r))}function Ji(n,e){try{let r=new URL(e);return!r.username&&!r.password&&(r.origin===$t(n)||r.origin===A[n].api)}catch{return!1}}function Rn(n){try{let e=new URL(n).hostname.replace(/^\[|\]$/g,"").toLowerCase();return e==="localhost"||e==="127.0.0.1"||e==="::1"}catch{return!1}}import{randomBytes as J}from"crypto";import{chmodSync as q,closeSync as B,constants as bn,linkSync as V,lstatSync as I,mkdirSync as z,openSync as En,readdirSync as T,readFileSync as Kn,readlinkSync as R,renameSync as k,rmdirSync as Q,symlinkSync as S,unlinkSync as y}from"fs";import{createRequire as Nn}from"module";import{constants as Sn}from"os";import{basename as w,join as l,sep as kn}from"path";import{existsSync as D,lstatSync as j,readdirSync as pn,readFileSync as mn,readlinkSync as dn,realpathSync as yn}from"fs";import{join as d,sep as hn}from"path";function G(n,...e){let r=d(n,"ara"),t=d(n,"reason");if(!$r(r))return d(t,...e);if(!D(t))return d(r,...e);return D(d(r,...e))&&!D(d(t,...e))?d(r,...e):d(t,...e)}function $r(n){try{let e=j(n);if(!e.isSymbolicLink())return e.isDirectory();return dn(n)!=="reason"&&D(n)}catch{return!1}}function X(n,e=[]){if(!$r(n))return!1;let r;try{r=[n,...pn(n,{withFileTypes:!0}).filter((t)=>t.isDirectory()).map((t)=>d(n,t.name))]}catch{return!1}return r.some((t)=>["connect","connect-once"].filter((i)=>!e.includes(d(t,i))).some((i)=>{let s=d(t,i,"worker.json");try{j(s)}catch{return!1}try{let a=JSON.parse(mn(s,"utf8"))?.stateDirectory;if(typeof a!=="string")return!0;let c=(o,u)=>o===u||o.startsWith(u+hn);return c(a,n)||c(M(a),M(n))}catch{return!0}}))}function M(n){try{return yn(n)}catch{return n}}var P=new Set(["credentials.json","local-device.json","local-device.revoked.json","local-device.auth-migration.json","local-device.json.registration-pending.json","local-daemon.json","local-daemon.json.workspaces.json","local-root-fingerprint-key.json","instances","workspaces"]),Z=new Set(["local-device.proxy.json"]),Cn=new Set(["local-device.key","local-device.binding"]),W=new Map;function it(n,e,r){let t=l(n,"ara");if(process.platform==="win32"||/[/\\]\.reason-ssh[/\\][^/\\]+[/\\]installer-home[/\\]\.config$/.test(n))return{state:m(t)?.isDirectory()?"kept":"absent"};return vn(t,l(n,"reason"),{linkAlways:!0,kept:(i)=>X(i,r??[]),native:e===void 0?Pn:()=>e},r!==void 0)}function ve(n,...e){return it(n),G(n,...e)}var nn="config_rename_unavailable:busy";function vn(n,e,r,t=!1){let i=t?void 0:W.get(n);if(i)return i;let s;try{s=_n(n,e,r)}catch(a){let c=`config_rename_unavailable:${E(a)??"failed"}`;try{return{state:m(n)?.isDirectory()?"kept":"absent",problem:c}}catch{return{state:"kept",problem:c}}}if(!(s.state==="absent"&&r.linkAlways)&&s.problem!==nn&&!(s.state==="kept"&&!s.problem))W.set(n,s);return s}function _n(n,e,r){In(e,r.native);let t=!1;for(let i=0;i<8;i+=1){let s=m(n);if(s?.isSymbolicLink())return R(n)===w(e)?{state:t?"renamed":"linked"}:{state:"kept"};if(!s){if(L(e))f(()=>y(e),"ENOENT");if(!(t||r.linkAlways)||!x(e))return{state:"absent"};let o=_(e,"link");S(w(e),o);try{f(()=>k(o,n),"EISDIR","ENOTEMPTY","EEXIST","ENOTDIR")}finally{f(()=>y(o),"ENOENT")}continue}if(!s.isDirectory())return{state:"absent"};if(r.kept(n))return K(e),{state:"kept"};let a=r.native();if(!a)return K(e),{state:"kept",problem:"config_rename_unavailable:no_native"};let c=On(a,n);if(!c)return{state:"kept",problem:nn};try{if(I(n).isSymbolicLink())continue;let o=wn(a,n,e);if(o)return{state:"kept",problem:o};t=!0}finally{c()}}throw Object.assign(Error("legacy directory rename did not settle"),{code:"unsettled"})}function wn(n,e,r){let t=m(r);if(!t||L(r)){if(!t)S(w(r),r);try{n.exchange(e,r)}catch(o){if(L(r))f(()=>y(r),"ENOENT");return`config_rename_unavailable:${E(o)??"exchange_failed"}`}return null}if(!t.isDirectory())return"config_rename_unavailable:ENOTDIR";if(t.dev!==I(e).dev)return"config_rename_unavailable:EXDEV";let i=[_(r,"probe"),_(r,"probe")];try{S("a",i[0]),S("b",i[1]),n.exchange(i[0],i[1])}catch(o){return`config_rename_unavailable:${E(o)??"exchange_failed"}`}finally{for(let o of i)f(()=>y(o),"ENOENT")}let s=cn(r);for(let o of Cn){let u=m(l(r,o)),p=m(l(e,o));if(u&&p&&u.ino!==p.ino)z(`${s}-replaced`,{mode:448,recursive:!0}),k(l(r,o),l(`${s}-replaced`,o))}let a={linked:new Map,unitsKept:new Set};rn(e,r,"",a);let c=_(r,"rename");S(w(r),c);try{n.exchange(e,c)}catch(o){return f(()=>y(c),"ENOENT"),`config_rename_unavailable:${E(o)??"exchange_failed"}`}return tn(c,r,a,s),null}function en(n){return n===""||!n.includes(kn)}function rn(n,e,r,t){let i=en(r)&&sn(l(e,r),l(n,r));if(i)t.unitsKept.add(r);for(let s of T(l(n,r))){if(i&&(P.has(s)||Z.has(s)))continue;let a=l(r,s),c=l(n,a),o=l(e,a),u=m(c);if(!u)continue;let p=m(o);if(u.isDirectory()){if(!p)f(()=>z(o,{mode:u.mode&4095}),"EEXIST"),q(o,u.mode&4095);if(x(o))rn(n,e,a,t)}else if(!p){if(u.isSymbolicLink())f(()=>S(R(c),o),"EEXIST");else if(f(()=>V(c,o),"EEXIST","ENOENT"))t.linked.set(a,u.ino)}}}function In(n,e){let r;try{if(!x(n))return;r=T(n)}catch{return}for(let t of r){let i=/^\.(rename|link|probe|claim)-(\d+)-[0-9a-f]+$/.exec(t);if(!i)continue;let s=l(n,t),a=m(s);if(!a)continue;if(!a.isDirectory()){if(!Y(Number(i[2])))f(()=>y(s),"ENOENT");continue}let c=e(),o=null;if(c){try{o=c.lock(s)}catch{continue}if(!o)continue}else if(Y(Number(i[2])))continue;try{let u=_(n,"claim");if(f(()=>k(s,u),"ENOENT"))tn(u,n,null,cn(n))}finally{o?.()}}}function tn(n,e,r,t){for(let[i,s]of r?.linked??[])if(!m(l(n,i))&&m(l(e,i))?.ino===s)f(()=>y(l(e,i)),"ENOENT");if(on(n,e,"",r),f(()=>Q(n),"ENOTEMPTY","EEXIST"))return;k(n,t),q(t,448)}function on(n,e,r,t){let i=en(r)&&(t?t.unitsKept.has(r):sn(l(e,r),l(n,r)));for(let s of T(l(n,r))){let a=l(r,s),c=l(n,a),o=l(e,a),u=I(c),p=m(o);if(p&&u.ino===p.ino&&u.dev===p.dev){y(c);continue}if(u.isFile()&&p?.isFile()&&t?.linked.get(a)===p.ino){k(c,o);continue}if(i&&(P.has(s)||Z.has(s)))continue;if(!p){if(u.isFile()){if(f(()=>V(c,o),"EEXIST"))y(c)}else f(()=>k(c,o),"EEXIST","ENOTEMPTY");continue}if(u.isDirectory()&&p.isDirectory())on(n,e,a,t),f(()=>Q(c),"ENOTEMPTY","EEXIST")}}function sn(n,e){for(let r of P)if(an(l(n,r),l(e,r)))return!0;return!1}function an(n,e){let r=m(n);if(!r)return!1;let t=m(e);if(!t)return!0;if(r.isDirectory()){if(!t.isDirectory())return!0;return T(n).some((i)=>an(l(n,i),l(e,i)))}if(r.isSymbolicLink())return!t.isSymbolicLink()||R(n)!==R(e);return r.ino!==t.ino||r.dev!==t.dev}function K(n){if(L(n))f(()=>y(n),"ENOENT")}function cn(n){return l(n,`.pre-rename-${new Date().toISOString().replace(/[:.]/g,"-")}-${J(3).toString("hex")}`)}function L(n){try{return I(n).isSymbolicLink()&&R(n)===w(n)}catch{return!1}}function x(n){let e=m(n);return e!==null&&e.isDirectory()}function On(n,e){for(let r=0;r<40;r+=1){let t=n.lock(e);if(t)return t;Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,50)}return null}function _(n,e){return l(n,`.${e}-${process.pid}-${J(6).toString("hex")}`)}function Y(n){if(n===process.pid)return!1;try{return process.kill(n,0),!0}catch(e){return E(e)==="EPERM"}}function m(n){try{return I(n)}catch(e){if(E(e)==="ENOENT"||E(e)==="ENOTDIR")return null;throw e}}function f(n,...e){try{return n(),!0}catch(r){if(e.includes(E(r)??""))return!1;throw r}}function E(n){return n instanceof Error&&"code"in n&&typeof n.code==="string"?n.code:void 0}var v,Dn=2,Ln=4,Tn=2,An=2,H=-100;function Pn(){if(v!==void 0)return v;if(v=null,process.platform!=="linux"&&process.platform!=="darwin")return null;let n;try{n=Nn(import.meta.url)("bun:ffi")}catch{return null}let e=process.platform==="darwin",r=e?"__error":"__errno_location",t=e?["/usr/lib/libSystem.B.dylib"]:["libc.so.6",`libc.musl-${process.arch==="arm64"?"aarch64":"x86_64"}.so.1`],{FFIType:i}=n;for(let s of t)try{let a=e?"renamex_np":"renameat2",o=n.dlopen(s,{flock:{args:[i.i32,i.i32],returns:i.i32},[r]:{args:[],returns:i.ptr},[a]:e?{args:[i.ptr,i.ptr,i.u32],returns:i.i32}:{args:[i.i32,i.ptr,i.i32,i.ptr,i.u32],returns:i.i32}}).symbols,u=o[r]();if(u===null)continue;let p=(N)=>{let b=n.read.i32(u),h=Object.entries(Sn.errno).find(([,O])=>O===b)?.[0]??`errno_${b}`;return Object.assign(Error(`${N} failed: ${h}`),{code:h})},F=(N)=>Buffer.from(`${N}\x00`,"utf8");return v={exchange(N,b){let h=F(N),O=F(b);if((e?o[a](n.ptr(h),n.ptr(O),Tn):o[a](H,n.ptr(h),H,n.ptr(O),An))!==0)throw p("exchange")},lock(N){let b=En(N,bn.O_RDONLY);if(o.flock(b,Dn|Ln)===0)return()=>B(b);let h=p("lock");if(B(b),h.code==="EWOULDBLOCK"||h.code==="EAGAIN")return null;throw h}},v}catch{}return null}
3
+ export{nt,g,$t,Mr,Gi,Ki,Ji,Rn,$r,it,ve};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFile as ie,spawn as E}from"child_process";var Zi="h264_ws_v1",Xi="video",it=["smooth","sharp","data_saver","balanced"];var Yi="video_presets";var L=8388608,v=65536,Qi="control",eo="v1",J=200;function Tn(t){if(!t||typeof t!=="object"||Array.isArray(t))return null;let e=t,n=(i)=>typeof i==="string"&&i.length>0&&i.length<=J;if(Object.keys(e).length!==2||!n(e.user_id)||!n(e.name))return null;return{user_id:e.user_id,name:e.name}}var to="windows",ro="v1",m=200,z=(t)=>typeof t==="string"&&it.includes(t);function no(t){if(!t||typeof t!=="object"||Array.isArray(t))return null;let e=t;if(Object.keys(e).length!==2||e.format!=="h264_ws_v1"||!z(e.preset))return null;return{format:"h264_ws_v1",preset:e.preset}}var o={hello:1,frame:2,stats:3,pong:4,serverClipboard:5,error:6,audioHello:7,audio:8,control:9,windows:10,pointer:16,key:17,config:18,ping:19,clientClipboard:20,keyframeRequest:21,ack:22,audioEnable:23};class l extends Error{constructor(t){super(t);this.name="DisplayVideoProtocolError"}}var Z=new TextEncoder,Q=new TextDecoder("utf-8",{fatal:!0});function p(t,e){if(e.byteLength+1>L)throw new l("message_too_large");let n=new Uint8Array(5+e.byteLength),i=new DataView(n.buffer);return i.setUint32(0,e.byteLength+1),i.setUint8(4,t),n.set(e,5),n}function y(t){let e=Z.encode(t);if(e.byteLength>v)throw new l("text_too_large");return e}function O(t,e){if(!Number.isInteger(t)||t<0||t>65535)throw new l(`invalid_${e}`);return t}function ee(t){if(!Number.isFinite(t))throw new l("invalid_window");return Math.max(-2147483648,Math.min(2147483647,Math.round(t)))}function $r(t){switch(t.type){case"hello":{let e=y(t.codec),n=new Uint8Array(6+e.byteLength),i=new DataView(n.buffer);return i.setUint16(0,O(t.width,"width")),i.setUint16(2,O(t.height,"height")),i.setUint8(4,Math.max(1,Math.min(240,Math.round(t.fps)))),i.setUint8(5,it.indexOf(t.preset)),n.set(e,6),p(o.hello,n)}case"frame":{let e=new Uint8Array(13+t.data.byteLength),n=new DataView(e.buffer);return n.setUint8(0,t.key?1:0),n.setUint32(1,t.seq>>>0),n.setBigUint64(5,BigInt(Math.max(0,Math.floor(t.captureMicros)))),e.set(t.data,13),p(o.frame,e)}case"stats":return p(o.stats,y(JSON.stringify(t.stats)));case"pong":case"ping":{let e=new Uint8Array(8);return new DataView(e.buffer).setFloat64(0,t.token),p(t.type==="ping"?o.ping:o.pong,e)}case"serverClipboard":return p(o.serverClipboard,y(t.text));case"clientClipboard":return p(o.clientClipboard,y(t.text));case"error":return p(o.error,y(t.code));case"pointer":{let e=new Uint8Array(5),n=new DataView(e.buffer);return n.setUint16(0,O(t.x,"x")),n.setUint16(2,O(t.y,"y")),n.setUint8(4,t.buttons&255),p(o.pointer,e)}case"key":{let e=new Uint8Array(5),n=new DataView(e.buffer);return n.setUint8(0,t.down?1:0),n.setUint32(1,t.keysym>>>0),p(o.key,e)}case"config":return p(o.config,Uint8Array.of(it.indexOf(t.preset)));case"keyframeRequest":return p(o.keyframeRequest,new Uint8Array(0));case"audioHello":{let e=y(t.codec),n=new Uint8Array(5+e.byteLength),i=new DataView(n.buffer);return i.setUint32(0,t.sampleRate>>>0),i.setUint8(4,t.channels&255),n.set(e,5),p(o.audioHello,n)}case"audio":{let e=new Uint8Array(8+t.data.byteLength);return new DataView(e.buffer).setBigUint64(0,BigInt(Math.max(0,Math.floor(t.captureMicros)))),e.set(t.data,8),p(o.audio,e)}case"control":return p(o.control,y(JSON.stringify(t.control)));case"windows":{let e=t.bounds.slice(0,m),n=new Uint8Array(e.length*16),i=new DataView(n.buffer);return e.forEach((s,a)=>{[s.x,s.y,s.width,s.height].forEach((c,d)=>i.setInt32(a*16+d*4,ee(c)))}),p(o.windows,n)}case"audioEnable":return p(o.audioEnable,Uint8Array.of(t.on?1:0));case"ack":{let e=new Uint8Array(4);return new DataView(e.buffer).setUint32(0,t.seq>>>0),p(o.ack,e)}}}function M(t){let e=it[t];if(!e)throw new l("invalid_preset");return e}function w(t,e){if(t.byteLength!==e)throw new l("invalid_length")}function S(t){if(t.byteLength>v)throw new l("text_too_large");try{return Q.decode(t)}catch{throw new l("invalid_text")}}function te(t){let e;try{e=JSON.parse(S(t))}catch{throw new l("invalid_stats")}let n=e;if(!n||typeof n!=="object"||["fps","kbps","dropped","restarts","queued_bytes"].some((s)=>typeof n[s]!=="number"||!Number.isFinite(n[s])))throw new l("invalid_stats");return{fps:n.fps,kbps:n.kbps,dropped:n.dropped,restarts:n.restarts,queued_bytes:n.queued_bytes}}function ne(t){let e;try{e=JSON.parse(S(t))}catch{throw new l("invalid_control")}let n=e;if(!n||typeof n!=="object"||typeof n.you!=="boolean"||typeof n.same_user!=="boolean")throw new l("invalid_control");let i=n.holder===null?null:Tn(n.holder);if(i===null&&n.holder!==null)throw new l("invalid_control");return{holder:i,you:n.you,same_user:n.same_user}}function re(t,e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(t){case o.hello:if(e.byteLength<6)throw new l("invalid_length");return{type:"hello",width:n.getUint16(0),height:n.getUint16(2),fps:n.getUint8(4),preset:M(n.getUint8(5)),codec:S(e.subarray(6))};case o.frame:if(e.byteLength<14)throw new l("invalid_length");if(n.getUint8(0)>1)throw new l("invalid_frame_flags");return{type:"frame",key:n.getUint8(0)===1,seq:n.getUint32(1),captureMicros:Number(n.getBigUint64(5)),data:e.subarray(13)};case o.stats:return{type:"stats",stats:te(e)};case o.ping:case o.pong:return w(e,8),{type:t===o.ping?"ping":"pong",token:n.getFloat64(0)};case o.serverClipboard:return{type:"serverClipboard",text:S(e)};case o.clientClipboard:return{type:"clientClipboard",text:S(e)};case o.error:return{type:"error",code:S(e)};case o.pointer:return w(e,5),{type:"pointer",x:n.getUint16(0),y:n.getUint16(2),buttons:n.getUint8(4)};case o.key:if(w(e,5),n.getUint8(0)>1)throw new l("invalid_key_flags");return{type:"key",down:n.getUint8(0)===1,keysym:n.getUint32(1)};case o.config:return w(e,1),{type:"config",preset:M(n.getUint8(0))};case o.keyframeRequest:return w(e,0),{type:"keyframeRequest"};case o.audioHello:if(e.byteLength<5)throw new l("invalid_length");return{type:"audioHello",sampleRate:n.getUint32(0),channels:n.getUint8(4),codec:S(e.subarray(5))};case o.audio:if(e.byteLength<9)throw new l("invalid_length");return{type:"audio",captureMicros:Number(n.getBigUint64(0)),data:e.subarray(8)};case o.audioEnable:if(w(e,1),n.getUint8(0)>1)throw new l("invalid_audio_flags");return{type:"audioEnable",on:n.getUint8(0)===1};case o.control:return{type:"control",control:ne(e)};case o.windows:{if(e.byteLength%16!==0||e.byteLength>m*16)throw new l("invalid_length");let i=[];for(let s=0;s<e.byteLength;s+=16)i.push({x:n.getInt32(s),y:n.getInt32(s+4),width:n.getInt32(s+8),height:n.getInt32(s+12)});return{type:"windows",bounds:i}}case o.ack:return w(e,4),{type:"ack",seq:n.getUint32(0)};default:return null}}class Rn{buffer=new Uint8Array(0);push(t){let e=new Uint8Array(this.buffer.byteLength+t.byteLength);e.set(this.buffer),e.set(t,this.buffer.byteLength);let n=[],i=0;while(e.byteLength-i>=4){let s=new DataView(e.buffer,e.byteOffset+i,4).getUint32(0);if(s<1||s>L)throw new l("invalid_message_length");if(e.byteLength-i-4<s)break;let a=e[i+4],c=e.slice(i+5,i+4+s),d=re(a,c);if(d)n.push(d);i+=4+s}return this.buffer=e.slice(i),n}}var Y="/usr/bin/osascript",se=5000,oe=1048576,ae=String.raw`
2
+ import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFile as ie,spawn as E}from"child_process";var Yi="h264_ws_v1",Qi="video",ot=["smooth","sharp","data_saver","balanced"];var eo="video_presets";var L=8388608,v=65536,to="control",ro="v1",J=200;function On(t){if(!t||typeof t!=="object"||Array.isArray(t))return null;let e=t,n=(i)=>typeof i==="string"&&i.length>0&&i.length<=J;if(Object.keys(e).length!==2||!n(e.user_id)||!n(e.name))return null;return{user_id:e.user_id,name:e.name}}var no="windows",io="v1",m=200,z=(t)=>typeof t==="string"&&ot.includes(t);function oo(t){if(!t||typeof t!=="object"||Array.isArray(t))return null;let e=t;if(Object.keys(e).length!==2||e.format!=="h264_ws_v1"||!z(e.preset))return null;return{format:"h264_ws_v1",preset:e.preset}}var o={hello:1,frame:2,stats:3,pong:4,serverClipboard:5,error:6,audioHello:7,audio:8,control:9,windows:10,pointer:16,key:17,config:18,ping:19,clientClipboard:20,keyframeRequest:21,ack:22,audioEnable:23};class l extends Error{constructor(t){super(t);this.name="DisplayVideoProtocolError"}}var Z=new TextEncoder,Q=new TextDecoder("utf-8",{fatal:!0});function p(t,e){if(e.byteLength+1>L)throw new l("message_too_large");let n=new Uint8Array(5+e.byteLength),i=new DataView(n.buffer);return i.setUint32(0,e.byteLength+1),i.setUint8(4,t),n.set(e,5),n}function y(t){let e=Z.encode(t);if(e.byteLength>v)throw new l("text_too_large");return e}function O(t,e){if(!Number.isInteger(t)||t<0||t>65535)throw new l(`invalid_${e}`);return t}function ee(t){if(!Number.isFinite(t))throw new l("invalid_window");return Math.max(-2147483648,Math.min(2147483647,Math.round(t)))}function Fr(t){switch(t.type){case"hello":{let e=y(t.codec),n=new Uint8Array(6+e.byteLength),i=new DataView(n.buffer);return i.setUint16(0,O(t.width,"width")),i.setUint16(2,O(t.height,"height")),i.setUint8(4,Math.max(1,Math.min(240,Math.round(t.fps)))),i.setUint8(5,ot.indexOf(t.preset)),n.set(e,6),p(o.hello,n)}case"frame":{let e=new Uint8Array(13+t.data.byteLength),n=new DataView(e.buffer);return n.setUint8(0,t.key?1:0),n.setUint32(1,t.seq>>>0),n.setBigUint64(5,BigInt(Math.max(0,Math.floor(t.captureMicros)))),e.set(t.data,13),p(o.frame,e)}case"stats":return p(o.stats,y(JSON.stringify(t.stats)));case"pong":case"ping":{let e=new Uint8Array(8);return new DataView(e.buffer).setFloat64(0,t.token),p(t.type==="ping"?o.ping:o.pong,e)}case"serverClipboard":return p(o.serverClipboard,y(t.text));case"clientClipboard":return p(o.clientClipboard,y(t.text));case"error":return p(o.error,y(t.code));case"pointer":{let e=new Uint8Array(5),n=new DataView(e.buffer);return n.setUint16(0,O(t.x,"x")),n.setUint16(2,O(t.y,"y")),n.setUint8(4,t.buttons&255),p(o.pointer,e)}case"key":{let e=new Uint8Array(5),n=new DataView(e.buffer);return n.setUint8(0,t.down?1:0),n.setUint32(1,t.keysym>>>0),p(o.key,e)}case"config":return p(o.config,Uint8Array.of(ot.indexOf(t.preset)));case"keyframeRequest":return p(o.keyframeRequest,new Uint8Array(0));case"audioHello":{let e=y(t.codec),n=new Uint8Array(5+e.byteLength),i=new DataView(n.buffer);return i.setUint32(0,t.sampleRate>>>0),i.setUint8(4,t.channels&255),n.set(e,5),p(o.audioHello,n)}case"audio":{let e=new Uint8Array(8+t.data.byteLength);return new DataView(e.buffer).setBigUint64(0,BigInt(Math.max(0,Math.floor(t.captureMicros)))),e.set(t.data,8),p(o.audio,e)}case"control":return p(o.control,y(JSON.stringify(t.control)));case"windows":{let e=t.bounds.slice(0,m),n=new Uint8Array(e.length*16),i=new DataView(n.buffer);return e.forEach((s,a)=>{[s.x,s.y,s.width,s.height].forEach((c,d)=>i.setInt32(a*16+d*4,ee(c)))}),p(o.windows,n)}case"audioEnable":return p(o.audioEnable,Uint8Array.of(t.on?1:0));case"ack":{let e=new Uint8Array(4);return new DataView(e.buffer).setUint32(0,t.seq>>>0),p(o.ack,e)}}}function M(t){let e=ot[t];if(!e)throw new l("invalid_preset");return e}function w(t,e){if(t.byteLength!==e)throw new l("invalid_length")}function S(t){if(t.byteLength>v)throw new l("text_too_large");try{return Q.decode(t)}catch{throw new l("invalid_text")}}function te(t){let e;try{e=JSON.parse(S(t))}catch{throw new l("invalid_stats")}let n=e;if(!n||typeof n!=="object"||["fps","kbps","dropped","restarts","queued_bytes"].some((s)=>typeof n[s]!=="number"||!Number.isFinite(n[s])))throw new l("invalid_stats");return{fps:n.fps,kbps:n.kbps,dropped:n.dropped,restarts:n.restarts,queued_bytes:n.queued_bytes}}function ne(t){let e;try{e=JSON.parse(S(t))}catch{throw new l("invalid_control")}let n=e;if(!n||typeof n!=="object"||typeof n.you!=="boolean"||typeof n.same_user!=="boolean")throw new l("invalid_control");let i=n.holder===null?null:On(n.holder);if(i===null&&n.holder!==null)throw new l("invalid_control");return{holder:i,you:n.you,same_user:n.same_user}}function re(t,e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(t){case o.hello:if(e.byteLength<6)throw new l("invalid_length");return{type:"hello",width:n.getUint16(0),height:n.getUint16(2),fps:n.getUint8(4),preset:M(n.getUint8(5)),codec:S(e.subarray(6))};case o.frame:if(e.byteLength<14)throw new l("invalid_length");if(n.getUint8(0)>1)throw new l("invalid_frame_flags");return{type:"frame",key:n.getUint8(0)===1,seq:n.getUint32(1),captureMicros:Number(n.getBigUint64(5)),data:e.subarray(13)};case o.stats:return{type:"stats",stats:te(e)};case o.ping:case o.pong:return w(e,8),{type:t===o.ping?"ping":"pong",token:n.getFloat64(0)};case o.serverClipboard:return{type:"serverClipboard",text:S(e)};case o.clientClipboard:return{type:"clientClipboard",text:S(e)};case o.error:return{type:"error",code:S(e)};case o.pointer:return w(e,5),{type:"pointer",x:n.getUint16(0),y:n.getUint16(2),buttons:n.getUint8(4)};case o.key:if(w(e,5),n.getUint8(0)>1)throw new l("invalid_key_flags");return{type:"key",down:n.getUint8(0)===1,keysym:n.getUint32(1)};case o.config:return w(e,1),{type:"config",preset:M(n.getUint8(0))};case o.keyframeRequest:return w(e,0),{type:"keyframeRequest"};case o.audioHello:if(e.byteLength<5)throw new l("invalid_length");return{type:"audioHello",sampleRate:n.getUint32(0),channels:n.getUint8(4),codec:S(e.subarray(5))};case o.audio:if(e.byteLength<9)throw new l("invalid_length");return{type:"audio",captureMicros:Number(n.getBigUint64(0)),data:e.subarray(8)};case o.audioEnable:if(w(e,1),n.getUint8(0)>1)throw new l("invalid_audio_flags");return{type:"audioEnable",on:n.getUint8(0)===1};case o.control:return{type:"control",control:ne(e)};case o.windows:{if(e.byteLength%16!==0||e.byteLength>m*16)throw new l("invalid_length");let i=[];for(let s=0;s<e.byteLength;s+=16)i.push({x:n.getInt32(s),y:n.getInt32(s+4),width:n.getInt32(s+8),height:n.getInt32(s+12)});return{type:"windows",bounds:i}}case o.ack:return w(e,4),{type:"ack",seq:n.getUint32(0)};default:return null}}class In{buffer=new Uint8Array(0);push(t){let e=new Uint8Array(this.buffer.byteLength+t.byteLength);e.set(this.buffer),e.set(t,this.buffer.byteLength);let n=[],i=0;while(e.byteLength-i>=4){let s=new DataView(e.buffer,e.byteOffset+i,4).getUint32(0);if(s<1||s>L)throw new l("invalid_message_length");if(e.byteLength-i-4<s)break;let a=e[i+4],c=e.slice(i+5,i+4+s),d=re(a,c);if(d)n.push(d);i+=4+s}return this.buffer=e.slice(i),n}}var Y="/usr/bin/osascript",se=5000,oe=1048576,ae=String.raw`
3
3
  ObjC.import("CoreGraphics");
4
4
  ObjC.import("ApplicationServices");
5
5
  ObjC.import("AppKit");
@@ -70,7 +70,7 @@ function run(argv) {
70
70
  }
71
71
  }
72
72
  `;function q(t){let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!=="object")return null;let n=e,i=(c)=>typeof c==="number"&&Number.isFinite(c)?Math.min(65535,Math.round(c)):0;if(typeof n.screen!=="boolean"||typeof n.accessibility!=="boolean")return null;let s=i(n.width),a=i(n.height);return s>0&&a>0?{screen:n.screen,accessibility:n.accessibility,width:s,height:a}:null}function k(t,...e){let[n,...i]=[...t,Y,"-l","JavaScript","-e",ae,...e];return[n,i]}function H(t,...e){return new Promise((n)=>{ie(...k(t,...e),{env:{},timeout:se,killSignal:"SIGKILL",maxBuffer:65536,encoding:"utf8"},(i,s)=>n(i?null:q(s.split(`
73
- `)[0]??"")))})}function qe(t=[]){return H(t,"probe")}function ot(t,e){return H(t,"request",...e?[e]:[])}var N=2,ce=8,ue=String.raw`
73
+ `)[0]??"")))})}function ze(t=[]){return H(t,"probe")}function st(t,e){return H(t,"request",...e?[e]:[])}var N=2,ce=8,ue=String.raw`
74
74
  ObjC.import("CoreGraphics");
75
75
  ObjC.import("Foundation");
76
76
  ObjC.bindFunction("getppid", ["int", []]);
@@ -101,12 +101,12 @@ function run() {
101
101
  $.NSThread.sleepForTimeInterval(wait);
102
102
  }
103
103
  }
104
- `;function le(t){let e;try{e=JSON.parse(t)}catch{return null}if(!Array.isArray(e))return null;let n=[];for(let i of e.slice(0,m)){if(!Array.isArray(i)||i.length!==4||!i.every((u)=>typeof u==="number"&&Number.isFinite(u)))return null;let[s,a,c,d]=i.map(Math.round);if(c>0&&d>0)n.push({x:s,y:a,width:c,height:d})}return n}function On(t){let e=Date.now(),n=0,i=!1,s=(u,b={})=>{try{process.stderr.write(`${JSON.stringify({event:"display.windows_helper",state:u,...b})}
104
+ `;function le(t){let e;try{e=JSON.parse(t)}catch{return null}if(!Array.isArray(e))return null;let n=[];for(let i of e.slice(0,m)){if(!Array.isArray(i)||i.length!==4||!i.every((u)=>typeof u==="number"&&Number.isFinite(u)))return null;let[s,a,c,d]=i.map(Math.round);if(c>0&&d>0)n.push({x:s,y:a,width:c,height:d})}return n}function Dn(t){let e=Date.now(),n=0,i=!1,s=(u,b={})=>{try{process.stderr.write(`${JSON.stringify({event:"display.windows_helper",state:u,...b})}
105
105
  `)}catch{}},a=(u,b={})=>{if(i)return;i=!0,s(u,{updates:n,duration_ms:Date.now()-e,...b})},c=E(Y,["-l","JavaScript","-e",ue],{env:{},stdio:["ignore","pipe","ignore"]});s("started");let d="";return c.stdout.on("data",(u)=>{if(i)return;d+=u.toString("utf8");for(let b=d.indexOf(`
106
106
  `);b>=0;b=d.indexOf(`
107
- `)){let x=le(d.slice(0,b));if(d=d.slice(b+1),x)n++,t(x)}if(d.length>65536)d=""}),c.once("error",(u)=>a("failed",{code:u.code??"spawn_failed"})),c.once("exit",(u,b)=>a("failed",{code:"exited",exit_code:u,signal:b})),{close(){a("stopped"),c.kill("SIGKILL")}}}var T=5,R=[{bit:1,button:0,down:1,up:2,drag:6},{bit:4,button:1,down:3,up:4,drag:7},{bit:2,button:2,down:25,up:26,drag:27}],de=[[8,1,0],[16,-1,0],[32,0,1],[64,0,-1]],P=50,fe=500,V=4,I=131072,W=262144,_=524288,F=1048576,B=new Map([[65505,[56,I]],[65506,[60,I]],[65507,[59,W]],[65508,[62,W]],[65511,[58,_]],[65512,[61,_]],[65513,[58,_]],[65514,[61,_]],[65027,[61,_]],[65515,[55,F]],[65516,[54,F]]]),pe=new Map([[65288,51],[65289,48],[65056,48],[65293,36],[65307,53],[65535,117],[65509,57],[65360,115],[65361,123],[65362,126],[65363,124],[65364,125],[65365,116],[65366,121],[65367,119],[65379,114],[65386,114],[65291,71],[65408,49],[65421,76],[65429,115],[65430,123],[65431,126],[65432,124],[65433,125],[65434,116],[65435,121],[65436,119],[65437,71],[65438,114],[65439,117],[65450,67],[65451,69],[65452,65],[65453,78],[65454,65],[65455,75],[65469,81],...[82,83,84,85,86,87,88,89,91,92].map((t,e)=>[65456+e,t]),...[122,120,99,118,96,97,98,100,101,109,103,111,105,107,113,106,64,79,80,90].map((t,e)=>[65470+e,t])]),G="asdfhgzxcv\x00bqweryt123465=97-80]ou[ip\x00lj'k;\\,/nm.\x00 `",j='~!@#$%^&*()_+{}|:"<>?',be="`1234567890-=[]\\;',./",D=new Map;for(let t=0;t<G.length;t++){let e=G[t];if(e==="\x00")continue;if(D.set(e.charCodeAt(0),[t,!1]),e>="a"&&e<="z")D.set(e.toUpperCase().charCodeAt(0),[t,!0])}for(let t=0;t<j.length;t++)D.set(j.charCodeAt(t),[D.get(be.charCodeAt(t))[0],!0]);class K{now;x=-1;y=-1;mask=0;clicks=0;lastDown=null;held=new Set;constructor(t=()=>performance.now()){this.now=t}flags(){let t=0;for(let e of this.held)t|=B.get(e)[1];return t}mouse(t,e){return`m ${t} ${this.x} ${this.y} ${e} ${t===T?0:this.clicks} ${this.flags()}`}pointer(t,e,n){let i=[];if(t!==this.x||e!==this.y){this.x=t,this.y=e;let s=R.find((a)=>this.mask&a.bit);i.push(s?this.mouse(s.drag,s.button):this.mouse(T,0))}for(let s of R){let a=(this.mask&s.bit)!==0,c=(n&s.bit)!==0;if(!a&&c){let d=this.now(),u=this.lastDown;this.clicks=u&&u.button===s.button&&d-u.at<=fe&&Math.abs(t-u.x)<=V&&Math.abs(e-u.y)<=V?this.clicks+1:1,this.lastDown={button:s.button,at:d,x:t,y:e},i.push(this.mouse(s.down,s.button))}else if(a&&!c)i.push(this.mouse(s.up,s.button))}for(let[s,a,c]of de)if(!(this.mask&s)&&n&s)i.push(`w ${a*P} ${c*P} ${this.flags()}`);return this.mask=n,i}key(t,e){let n=t?1:0,i=B.get(e);if(i){if(t)this.held.add(e);else this.held.delete(e);return[`k ${i[0]} ${n} ${this.flags()}`]}let s=pe.get(e);if(s!==void 0)return[`k ${s} ${n} ${this.flags()}`];let a=e<256?e:(e&4278190080)===16777216?e&16777215:0,c=D.get(a);if(c)return[`k ${c[0]} ${n} ${this.flags()|(c[1]?I:0)}`];if(a<160||a>65535||a>=55296&&a<57344)return[];return[`u ${n} ${a} ${this.flags()}`]}}function In(t,e=[]){let n=E(...k(e),{env:{},stdio:["pipe","pipe","ignore"]}),i=new K,s="",a=!1,c=null,d=()=>{n.kill("SIGKILL"),c?.kill("SIGKILL")},u=(f)=>{if(a)return;a=!0,d(),t.end(f)},b=(f)=>u({error:new r("display_unavailable",f)}),x=(f)=>{if(a||f.length===0)return;if(n.stdin.write(f.map((g)=>`${g}
107
+ `)){let x=le(d.slice(0,b));if(d=d.slice(b+1),x)n++,t(x)}if(d.length>65536)d=""}),c.once("error",(u)=>a("failed",{code:u.code??"spawn_failed"})),c.once("exit",(u,b)=>a("failed",{code:"exited",exit_code:u,signal:b})),{close(){a("stopped"),c.kill("SIGKILL")}}}var T=5,R=[{bit:1,button:0,down:1,up:2,drag:6},{bit:4,button:1,down:3,up:4,drag:7},{bit:2,button:2,down:25,up:26,drag:27}],de=[[8,1,0],[16,-1,0],[32,0,1],[64,0,-1]],P=50,fe=500,V=4,I=131072,W=262144,_=524288,F=1048576,B=new Map([[65505,[56,I]],[65506,[60,I]],[65507,[59,W]],[65508,[62,W]],[65511,[58,_]],[65512,[61,_]],[65513,[58,_]],[65514,[61,_]],[65027,[61,_]],[65515,[55,F]],[65516,[54,F]]]),pe=new Map([[65288,51],[65289,48],[65056,48],[65293,36],[65307,53],[65535,117],[65509,57],[65360,115],[65361,123],[65362,126],[65363,124],[65364,125],[65365,116],[65366,121],[65367,119],[65379,114],[65386,114],[65291,71],[65408,49],[65421,76],[65429,115],[65430,123],[65431,126],[65432,124],[65433,125],[65434,116],[65435,121],[65436,119],[65437,71],[65438,114],[65439,117],[65450,67],[65451,69],[65452,65],[65453,78],[65454,65],[65455,75],[65469,81],...[82,83,84,85,86,87,88,89,91,92].map((t,e)=>[65456+e,t]),...[122,120,99,118,96,97,98,100,101,109,103,111,105,107,113,106,64,79,80,90].map((t,e)=>[65470+e,t])]),G="asdfhgzxcv\x00bqweryt123465=97-80]ou[ip\x00lj'k;\\,/nm.\x00 `",j='~!@#$%^&*()_+{}|:"<>?',be="`1234567890-=[]\\;',./",D=new Map;for(let t=0;t<G.length;t++){let e=G[t];if(e==="\x00")continue;if(D.set(e.charCodeAt(0),[t,!1]),e>="a"&&e<="z")D.set(e.toUpperCase().charCodeAt(0),[t,!0])}for(let t=0;t<j.length;t++)D.set(j.charCodeAt(t),[D.get(be.charCodeAt(t))[0],!0]);class K{now;x=-1;y=-1;mask=0;clicks=0;lastDown=null;held=new Set;constructor(t=()=>performance.now()){this.now=t}flags(){let t=0;for(let e of this.held)t|=B.get(e)[1];return t}mouse(t,e){return`m ${t} ${this.x} ${this.y} ${e} ${t===T?0:this.clicks} ${this.flags()}`}pointer(t,e,n){let i=[];if(t!==this.x||e!==this.y){this.x=t,this.y=e;let s=R.find((a)=>this.mask&a.bit);i.push(s?this.mouse(s.drag,s.button):this.mouse(T,0))}for(let s of R){let a=(this.mask&s.bit)!==0,c=(n&s.bit)!==0;if(!a&&c){let d=this.now(),u=this.lastDown;this.clicks=u&&u.button===s.button&&d-u.at<=fe&&Math.abs(t-u.x)<=V&&Math.abs(e-u.y)<=V?this.clicks+1:1,this.lastDown={button:s.button,at:d,x:t,y:e},i.push(this.mouse(s.down,s.button))}else if(a&&!c)i.push(this.mouse(s.up,s.button))}for(let[s,a,c]of de)if(!(this.mask&s)&&n&s)i.push(`w ${a*P} ${c*P} ${this.flags()}`);return this.mask=n,i}key(t,e){let n=t?1:0,i=B.get(e);if(i){if(t)this.held.add(e);else this.held.delete(e);return[`k ${i[0]} ${n} ${this.flags()}`]}let s=pe.get(e);if(s!==void 0)return[`k ${s} ${n} ${this.flags()}`];let a=e<256?e:(e&4278190080)===16777216?e&16777215:0,c=D.get(a);if(c)return[`k ${c[0]} ${n} ${this.flags()|(c[1]?I:0)}`];if(a<160||a>65535||a>=55296&&a<57344)return[];return[`u ${n} ${a} ${this.flags()}`]}}function Nn(t,e=[]){let n=E(...k(e),{env:{},stdio:["pipe","pipe","ignore"]}),i=new K,s="",a=!1,c=null,d=()=>{n.kill("SIGKILL"),c?.kill("SIGKILL")},u=(f)=>{if(a)return;a=!0,d(),t.end(f)},b=(f)=>u({error:new r("display_unavailable",f)}),x=(f)=>{if(a||f.length===0)return;if(n.stdin.write(f.map((g)=>`${g}
108
108
  `).join("")),n.stdin.writableLength>oe)u({reason:"input_backpressure"})},X=()=>{c=E(...k(e,"clipboard"),{env:{},stdio:["ignore","pipe","ignore"]});let f="";c.stdout?.on("data",(g)=>{if(a)return;f+=g.toString("ascii");for(let h=f.indexOf(`
109
109
  `);h>=0;h=f.indexOf(`
110
110
  `)){let C=f.slice(0,h);if(f=f.slice(h+1),!C.startsWith("c "))continue;let A=C.slice(2);if(A.length>Math.ceil(v/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(A)){u({reason:"display_protocol"});return}let U=Buffer.from(A,"base64");if(U.byteLength<=v)t.clipboard(U.toString("utf8"));if(a)return}if(f.length>Math.ceil(v/3)*4+2)u({reason:"display_protocol"})}),c.once("error",()=>b("Reason could not watch this Mac's desktop clipboard.")),c.once("exit",()=>{if(!a)b("Reason could not watch this Mac's desktop clipboard.")})};return n.stdout.on("data",(f)=>{if(a||s===null)return;s+=f.toString("utf8");let g=s.indexOf(`
111
111
  `);if(g<0){if(s.length>4096)u({reason:"display_protocol"});return}let h=q(s.slice(0,g));if(s=null,!h)u({reason:"display_protocol"});else if(!h.screen||!h.accessibility)b(e.length>0?"Reason's background worker needs Screen Recording and Accessibility on this Mac (its own Reason entry in System Settings > Privacy & Security, not the Reason app's): run `reason permissions allow` on this Mac.":"Allow Screen Recording and Accessibility for this Mac's Reason worker, then restart it.");else X(),t.ready({width:h.width,height:h.height})}),n.stdin.on("error",()=>{return}),n.once("error",()=>b("Reason could not start this Mac's desktop input.")),n.once("exit",()=>{if(s!==null)b("Reason could not start this Mac's desktop input.");else u({reason:"display_closed"})}),{pointer:(f,g,h)=>x(i.pointer(f,g,h)),key:(f,g)=>x(i.key(f,g)),clipboard:(f)=>x([`c ${Buffer.from(f,"utf8").toString("base64")}`]),close(){a=!0,d()}}}
112
- export{Zi,Xi,it,Yi,v,Qi,eo,Tn,to,ro,no,$r,Rn,qe,ot,On,In};
112
+ export{Yi,Qi,ot,eo,v,to,ro,On,no,io,oo,Fr,In,ze,st,Dn,Nn};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{a}from"./vm-hands-entry-lite-dkcm3hyn.js";import{readFileSync as c}from"fs";import{isAbsolute as l,normalize as i}from"path";var m="REASON_WORKER_DESKTOP_USER",u=null;function p(t,o){for(let s of o.split(`
3
- `)){let e=s.split(":");if(e.length<7||Number(e[2])!==t||!/^\d+$/.test(e[2])||!/^\d+$/.test(e[3]))continue;let n=e[5];if(!/^[a-z_][a-z0-9_-]*$/i.test(e[0])||!l(n)||i(n)!==n||n==="/")return null;return{username:e[0],uid:t,gid:Number(e[3]),home:n}}return null}function as(t={}){let o="value"in t?t.value:process.env[m];if(u=null,o===void 0||o==="")return null;let s=t.platform??process.platform,e="euid"in t?t.euid:process.geteuid?.(),n=/^[1-9]\d{0,9}$/.test(o)?Number(o):NaN,r=s==="linux"&&e===0&&Number.isSafeInteger(n)?p(n,(t.passwd??(()=>c("/etc/passwd","utf8")))()):null;if(!r||r.gid===0)throw Error("worker_desktop_user_invalid");return u=r,r}function G(){return u}function En(){return u?.home??a()}
4
- export{as,G,En};
2
+ import{a}from"./vm-hands-entry-lite-89z488gz.js";import{readFileSync as c}from"fs";import{isAbsolute as l,normalize as i}from"path";var m="REASON_WORKER_DESKTOP_USER",u=null;function p(t,o){for(let s of o.split(`
3
+ `)){let e=s.split(":");if(e.length<7||Number(e[2])!==t||!/^\d+$/.test(e[2])||!/^\d+$/.test(e[3]))continue;let n=e[5];if(!/^[a-z_][a-z0-9_-]*$/i.test(e[0])||!l(n)||i(n)!==n||n==="/")return null;return{username:e[0],uid:t,gid:Number(e[3]),home:n}}return null}function ds(t={}){let o="value"in t?t.value:process.env[m];if(u=null,o===void 0||o==="")return null;let s=t.platform??process.platform,e="euid"in t?t.euid:process.geteuid?.(),n=/^[1-9]\d{0,9}$/.test(o)?Number(o):NaN,r=s==="linux"&&e===0&&Number.isSafeInteger(n)?p(n,(t.passwd??(()=>c("/etc/passwd","utf8")))()):null;if(!r||r.gid===0)throw Error("worker_desktop_user_invalid");return u=r,r}function G(){return u}function kn(){return u?.home??a()}
4
+ export{ds,G,kn};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ht}from"./vm-hands-entry-lite-1ksme5sc.js";var ct=Ht.version;export{ct};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{x}from"./vm-hands-entry-lite-zg3b0c08.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFileSync as b}from"child_process";import{mkdirSync as y,readdirSync as h,readFileSync as D,rmSync as f,statSync as k,writeFileSync as w}from"fs";import{join as p,sep as S}from"path";import{setTimeout as L}from"timers/promises";var _=3000,u=null;function g(e){return p(e,"users")}function ft(e){if(u?.root===e.root)return;let t=g(e.root);y(t,{recursive:!0,mode:448}),w(p(t,String(process.pid)),"",{mode:384}),u=e}function $s(){if(!u)return;f(p(g(u.root),String(process.pid)),{force:!0}),u=null}function m(e){try{return process.kill(e,0),!0}catch(t){return t instanceof Error&&"code"in t&&t.code==="EPERM"}}function P(){let e=process.getuid?.();if(process.platform==="linux")return h("/proc").flatMap((n)=>{if(!/^\d+$/.test(n))return[];try{if(k(`/proc/${n}`).uid!==e)return[];let s=D(`/proc/${n}/cmdline`).toString("utf8").split("\x00").join(" ").trim();return s?[{pid:Number(n),command:s}]:[]}catch{return[]}});if(process.platform==="win32")return b(x("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 c=/^(\d+) (.+)$/.exec(s.trim());return c?[{pid:Number(c[1]),command:c[2]}]:[]});return b("/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 Bs(){let e=u;if(!e)return{released:"unused",stopped:0};let t=g(e.root);f(p(t,String(process.pid)),{force:!0}),u=null;let n=!1;for(let o of h(t)){let i=Number(o);if(Number.isSafeInteger(i)&&i>0&&m(i))n=!0;else f(p(t,o),{force:!0})}if(n)return{released:"shared",stopped:0};let s=P().filter((o)=>o.pid!==process.pid&&(o.command.includes(`${e.root}${S}`)||o.command.includes(`${e.automation}${S}`)||o.command.includes(e.extensionDir))),c=(o,i)=>{try{process.kill(o,i)}catch{}};for(let o of s)c(o.pid,"SIGTERM");for(let o=Date.now()+_;Date.now()<o&&s.some((i)=>m(i.pid));)await new Promise((i)=>setTimeout(i,100));for(let o of s)if(m(o.pid))c(o.pid,"SIGKILL");return{released:"stopped",stopped:s.length}}var E=20000,M=30000,N=100,a=new Map,l=null,d=[];function fi(e){a.set(e,(a.get(e)??0)+1);let t=!1;return()=>{if(t)return;t=!0;let n=(a.get(e)??1)-1;if(n>0){a.set(e,n);return}if(a.delete(e),l?.run===e)l.idleUntil=0}}function O(){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 T(e,t){return l!==null&&l.run!==e&&(l.calls>0||t<l.idleUntil)}async function mi(e,t,n=Date.now){let s=Symbol(e);d.push(s);try{let i=n()+M;for(;;){if(!T(e,n())&&(l?.run===e||d[0]===s))break;if(n()>=i)throw O();await L(N,void 0,{signal:t}).catch(()=>t.throwIfAborted())}}finally{d.splice(d.indexOf(s),1)}if(l?.run!==e)l={run:e,calls:0,idleUntil:0};let c=l;c.calls+=1;let o=!1;return()=>{if(o)return;o=!0,c.calls-=1,c.idleUntil=n()+E}}
4
- export{ft,$s,Bs,fi,mi};
2
+ import{x}from"./vm-hands-entry-lite-9ay6f56v.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFileSync as b}from"child_process";import{mkdirSync as y,readdirSync as h,readFileSync as D,rmSync as f,statSync as k,writeFileSync as w}from"fs";import{join as p,sep as S}from"path";import{setTimeout as L}from"timers/promises";var _=3000,u=null;function g(e){return p(e,"users")}function gt(e){if(u?.root===e.root)return;let t=g(e.root);y(t,{recursive:!0,mode:448}),w(p(t,String(process.pid)),"",{mode:384}),u=e}function Us(){if(!u)return;f(p(g(u.root),String(process.pid)),{force:!0}),u=null}function m(e){try{return process.kill(e,0),!0}catch(t){return t instanceof Error&&"code"in t&&t.code==="EPERM"}}function P(){let e=process.getuid?.();if(process.platform==="linux")return h("/proc").flatMap((n)=>{if(!/^\d+$/.test(n))return[];try{if(k(`/proc/${n}`).uid!==e)return[];let s=D(`/proc/${n}/cmdline`).toString("utf8").split("\x00").join(" ").trim();return s?[{pid:Number(n),command:s}]:[]}catch{return[]}});if(process.platform==="win32")return b(x("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 c=/^(\d+) (.+)$/.exec(s.trim());return c?[{pid:Number(c[1]),command:c[2]}]:[]});return b("/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 Hs(){let e=u;if(!e)return{released:"unused",stopped:0};let t=g(e.root);f(p(t,String(process.pid)),{force:!0}),u=null;let n=!1;for(let o of h(t)){let i=Number(o);if(Number.isSafeInteger(i)&&i>0&&m(i))n=!0;else f(p(t,o),{force:!0})}if(n)return{released:"shared",stopped:0};let s=P().filter((o)=>o.pid!==process.pid&&(o.command.includes(`${e.root}${S}`)||o.command.includes(`${e.automation}${S}`)||o.command.includes(e.extensionDir))),c=(o,i)=>{try{process.kill(o,i)}catch{}};for(let o of s)c(o.pid,"SIGTERM");for(let o=Date.now()+_;Date.now()<o&&s.some((i)=>m(i.pid));)await new Promise((i)=>setTimeout(i,100));for(let o of s)if(m(o.pid))c(o.pid,"SIGKILL");return{released:"stopped",stopped:s.length}}var E=20000,M=30000,N=100,a=new Map,l=null,d=[];function gi(e){a.set(e,(a.get(e)??0)+1);let t=!1;return()=>{if(t)return;t=!0;let n=(a.get(e)??1)-1;if(n>0){a.set(e,n);return}if(a.delete(e),l?.run===e)l.idleUntil=0}}function O(){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 T(e,t){return l!==null&&l.run!==e&&(l.calls>0||t<l.idleUntil)}async function _i(e,t,n=Date.now){let s=Symbol(e);d.push(s);try{let i=n()+M;for(;;){if(!T(e,n())&&(l?.run===e||d[0]===s))break;if(n()>=i)throw O();await L(N,void 0,{signal:t}).catch(()=>t.throwIfAborted())}}finally{d.splice(d.indexOf(s),1)}if(l?.run!==e)l={run:e,calls:0,idleUntil:0};let c=l;c.calls+=1;let o=!1;return()=>{if(o)return;o=!0,c.calls-=1,c.idleUntil=n()+E}}
4
+ export{gt,Us,Hs,gi,_i};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{statSync as f}from"fs";import{delimiter as l,join as d}from"path";function vt(e,o=process.env.PATH??"",i=process.env,u=process.platform){let r=u==="win32",a=e.includes("/")||r&&e.includes("\\");if(!e||a||e.includes("\x00"))return!1;let c=r?["",...(i.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";")]:[""];return o.split(l).some((t)=>{if(!t)return!1;return c.some((n)=>{if(n===void 0)return!1;try{let s=f(d(t,`${e}${n}`));if(!s.isFile())return!1;return r||(s.mode&73)!==0}catch{return!1}})})}
3
- export{vt};
2
+ import{statSync as f}from"fs";import{delimiter as l,join as d}from"path";function Et(e,o=process.env.PATH??"",i=process.env,u=process.platform){let r=u==="win32",a=e.includes("/")||r&&e.includes("\\");if(!e||a||e.includes("\x00"))return!1;let c=r?["",...(i.PATHEXT??".EXE;.CMD;.BAT;.COM").split(";")]:[""];return o.split(l).some((t)=>{if(!t)return!1;return c.some((n)=>{if(n===void 0)return!1;try{let s=f(d(t,`${e}${n}`));if(!s.isFile())return!1;return r||(s.mode&73)!==0}catch{return!1}})})}
3
+ export{Et};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{C}from"./vm-hands-entry-lite-t7an5zg2.js";import{Br}from"./vm-hands-entry-lite-wf7ksh4e.js";import{tt}from"./vm-hands-entry-lite-ppytc9k7.js";import{a}from"./vm-hands-entry-lite-dkcm3hyn.js";import{I}from"./vm-hands-entry-lite-zg3b0c08.js";import{randomUUID as f}from"crypto";import{chmodSync as U,closeSync as h,constants as g,existsSync as me,fstatSync as F,lstatSync as R,mkdirSync as B,openSync as G,readFileSync as Y,readdirSync as z,readlinkSync as J,realpathSync as x,renameSync as _,rmSync as p,statSync as K,symlinkSync as _t,unlinkSync as M,writeFileSync as L}from"fs";import{basename as vt,dirname as N,isAbsolute as fe,join as c,relative as ge,resolve as b,sep as _e}from"path";import{createRequire as H}from"module";var q=1,j=1,ye=128,ve=65536;var he=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;var P=/^[a-z0-9_.-]{1,80}$/,be=64,Ee="so.ara.device-broker",Me=[Ee,"com.reasonmachines.device-broker"],Pt=Br(Me);var we=["service.install_started","service.install_completed","service.install_failed","service.launcher_adopted","service.launcher_conflict","service.started","service.reconnecting","service.reconnected","service.idle_sleep_held","service.idle_sleep_released","service.idle_sleep_failed","service.start_failed","service.stopped","service.exit_failed","service.singleton_rejected","credential.migration_started","credential.migration_completed","credential.migration_failed","credential.store_started","credential.store_completed","credential.store_failed","credential.delete_started","credential.delete_completed","credential.delete_failed","update.check_started","update.not_available","update.download_started","update.downloaded","update.verified","update.activated","update.rollback","update.failed","executor.update.check_started","executor.update.not_available","executor.update.download_started","executor.update.downloaded","executor.update.verified","executor.update.activated","executor.update.rollback","executor.update.failed","identity.refresh_completed","identity.refresh_failed","update.device_moved","update.components_installed","update.deferred","update.deferral_expired","worker.previous_exit","worker.capabilities_withheld","identity.computer_use_unavailable"];function X(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function W(e,t,n=[]){let r=new Set([...t,...n]);return t.every((i)=>(i in e))&&Object.keys(e).every((i)=>r.has(i))}function E(e){return typeof e==="string"&&he.test(e)}function Z(e){return typeof e==="string"&&!Number.isNaN(Date.parse(e))&&new Date(e).toISOString()===e}function S(e){B(e,{recursive:!0,mode:448}),U(e,448)}function Re(e,t){S(N(e));let n=`${e}.${process.pid}.${f()}.tmp`;try{L(n,t,{mode:384,flag:"wx"}),U(n,384),_(n,e)}finally{if(me(n))M(n)}}function Wo(e={}){if((e.platform??process.platform)!=="darwin")throw new tt("unsupported_platform","The managed Reason runtime is currently available only on macOS.");let n=e.environment??process.env,r=C(n,"REASON_CLI_CHANNEL")==="staging",i=r?C(n,"REASON_MANAGED_RUNTIME_ROOT")?.trim():void 0,o=e.root!==void 0||Boolean(i&&fe(i))?null:c(e.home??a(),"Library","Application Support"),d=e.root??(o?c(o,r?"Reason Staging":"Reason","CLI"):i);return{executableName:"reason",root:d,...o?{legacyRoot:c(o,"Ara",...r?["staging","runtime"]:["runtime"])}:{},versions:c(d,"versions"),current:c(d,"current"),previous:c(d,"previous"),brokerLock:c(d,"broker.lock"),transitionLock:c(d,"transition.lock"),lifecycleEvents:c(d,"lifecycle-events")}}function Vo(e){let t=e.legacyRoot;if(!t)return null;return{root:t,versions:c(t,"versions"),current:c(t,"current"),previous:c(t,"previous"),brokerLock:c(t,"broker.lock"),transitionLock:c(t,"transition.lock"),lifecycleEvents:c(t,"lifecycle-events")}}function pe(e,t){let n;try{if(!R(e).isSymbolicLink())return null;n=J(e)}catch{return null}let r=n.match(/^versions\/(\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?)\/(ara|Reason|reason)$/);return r&&(r[2]==="ara"||r[2]===t)?r[1]:null}function Go(e){return pe(e.current,e.executableName)}function D(e,t,n){let i=ge(t,e).split(_e);return i.length===2&&E(i[0])&&(i[1]==="ara"||n!==void 0&&i[1]===n)?i[0]:null}function Le(e,t){try{return R(t).isSymbolicLink()&&b(N(t),J(t))===b(e.current)}catch{return!1}}function Ko(e,t=process.execPath){try{return D(x(t),x(e.versions),e.executableName)!==null}catch{let n=b(t);return n===b(e.current)||Le(e,n)||D(n,b(e.versions),e.executableName)!==null}}function Ae(e){return X(e)&&W(e,["schema_version","pid","nonce","started_at","runtime_version"])&&e.schema_version===q&&typeof e.pid==="number"&&Number.isSafeInteger(e.pid)&&e.pid>0&&typeof e.nonce==="string"&&/^[0-9a-f-]{36}$/.test(e.nonce)&&Z(e.started_at)&&E(e.runtime_version)}function Q(e,t){try{let n=R(e);if(!n.isDirectory()||!I(n))return null;let r=G(c(e,t),g.O_RDONLY|g.O_NOFOLLOW|g.O_NONBLOCK);try{let i=F(r);if(!i.isFile()||i.nlink!==1||!I(i)||i.size>4096)return null;return Y(r,"utf8")}finally{h(r)}}catch{return null}}function A(e){try{let t=JSON.parse(Q(e,"owner.json")??"null");return Ae(t)?t:null}catch{return null}}function ee(e){try{return process.kill(e,0),!0}catch(t){return!(t instanceof Error&&("code"in t)&&t.code==="ESRCH")}}var O="lease",Ne=2,Se=4,y;function ke(){if(y!==void 0)return y;if(y=null,process.platform!=="linux"&&process.platform!=="darwin")return null;let e;try{e=H(import.meta.url)("bun:ffi")}catch{return null}let t=process.platform==="darwin"?"__error":"__errno_location",n=process.platform==="darwin"?["/usr/lib/libSystem.B.dylib"]:["libc.so.6",`libc.musl-${process.arch==="arm64"?"aarch64":"x86_64"}.so.1`];for(let r of n)try{let i=e.dlopen(r,{flock:{args:[e.FFIType.i32,e.FFIType.i32],returns:e.FFIType.i32},[t]:{args:[],returns:e.FFIType.ptr}}),s=i.symbols[t]();if(s===null)continue;return y={flock:(o,d)=>i.symbols.flock(o,d),errno:()=>e.read.i32(s),wouldBlock:process.platform==="darwin"?35:11},y}catch{}return null}var v,Ie=3221225472,Te=4,xe=128,Pe=32;function De(e){if(v===void 0){v=null;try{let s=H(import.meta.url)("bun:ffi"),{FFIType:o}=s;v={kernel:s.dlopen("kernel32.dll",{CreateFileW:{args:[o.ptr,o.u32,o.u32,o.ptr,o.u32,o.u32,o.ptr],returns:o.i64_fast},CloseHandle:{args:[o.i64_fast],returns:o.i32},GetLastError:{args:[],returns:o.u32}}).symbols,ptr:(l)=>s.ptr(l)}}catch{return null}}if(!v)return null;let{kernel:t,ptr:n}=v,r=Buffer.from(`${e}\x00`,"utf16le"),i=t.CreateFileW(n(r),Ie,0,null,Te,xe,null);if(Number(i)===-1)return t.GetLastError()===Pe?"busy":null;return{release:()=>{t.CloseHandle(i)}}}function Oe(e){if(process.platform==="win32")return De(`${e}.lease`);let t=ke();if(!t)return null;let n=G(`${e}.lease`,g.O_RDWR|g.O_CREAT|g.O_NOFOLLOW,384);try{let r=F(n);if(!r.isFile()||r.nlink!==1||!I(r))return h(n),"busy";if(t.flock(n,Ne|Se)===0)return{release:()=>h(n)};let i=t.errno();return h(n),i===t.wouldBlock?"busy":null}catch(r){throw h(n),r}}function Jo(e){S(N(e.path));let t=Oe(e.path);if(t==="busy")return{acquired:!1,owner:A(e.path),recoveredStaleOwner:!1};let n=t!==null;try{let r=Ce(e,t);if(r.acquired)n=!1;return r}finally{if(n)t.release()}}function Ce(e,t){let n=e.alive??ee,r=!1;for(let i=0;i<4;i+=1){let s={schema_version:q,pid:e.pid??process.pid,nonce:e.nonce?.()??f(),started_at:(e.now?.()??new Date).toISOString(),runtime_version:e.runtimeVersion},o=`${e.path}.init-${process.pid}-${f()}`,d=!1;try{if(B(o,{mode:448}),L(c(o,"owner.json"),`${JSON.stringify(s)}
2
+ import{C}from"./vm-hands-entry-lite-t7an5zg2.js";import{jr}from"./vm-hands-entry-lite-1xtpeh3x.js";import{rt}from"./vm-hands-entry-lite-1rrb66r9.js";import{a}from"./vm-hands-entry-lite-89z488gz.js";import{I}from"./vm-hands-entry-lite-9ay6f56v.js";import{randomUUID as f}from"crypto";import{chmodSync as U,closeSync as h,constants as g,existsSync as me,fstatSync as F,lstatSync as R,mkdirSync as B,openSync as G,readFileSync as Y,readdirSync as z,readlinkSync as J,realpathSync as x,renameSync as _,rmSync as p,statSync as K,symlinkSync as _t,unlinkSync as M,writeFileSync as L}from"fs";import{basename as vt,dirname as N,isAbsolute as fe,join as c,relative as ge,resolve as b,sep as _e}from"path";import{createRequire as H}from"module";var q=1,j=1,ye=128,ve=65536;var he=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;var P=/^[a-z0-9_.-]{1,80}$/,be=64,Ee="so.ara.device-broker",Me=[Ee,"com.reasonmachines.device-broker"],Pt=jr(Me);var we=["service.install_started","service.install_completed","service.install_failed","service.launcher_adopted","service.launcher_conflict","service.started","service.reconnecting","service.reconnected","service.idle_sleep_held","service.idle_sleep_released","service.idle_sleep_failed","service.start_failed","service.stopped","service.exit_failed","service.singleton_rejected","credential.migration_started","credential.migration_completed","credential.migration_failed","credential.store_started","credential.store_completed","credential.store_failed","credential.delete_started","credential.delete_completed","credential.delete_failed","update.check_started","update.not_available","update.download_started","update.downloaded","update.verified","update.activated","update.rollback","update.failed","executor.update.check_started","executor.update.not_available","executor.update.download_started","executor.update.downloaded","executor.update.verified","executor.update.activated","executor.update.rollback","executor.update.failed","identity.refresh_completed","identity.refresh_failed","update.device_moved","update.components_installed","update.deferred","update.deferral_expired","worker.previous_exit","worker.capabilities_withheld","identity.computer_use_unavailable"];function X(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function W(e,t,n=[]){let r=new Set([...t,...n]);return t.every((i)=>(i in e))&&Object.keys(e).every((i)=>r.has(i))}function E(e){return typeof e==="string"&&he.test(e)}function Z(e){return typeof e==="string"&&!Number.isNaN(Date.parse(e))&&new Date(e).toISOString()===e}function S(e){B(e,{recursive:!0,mode:448}),U(e,448)}function Re(e,t){S(N(e));let n=`${e}.${process.pid}.${f()}.tmp`;try{L(n,t,{mode:384,flag:"wx"}),U(n,384),_(n,e)}finally{if(me(n))M(n)}}function Go(e={}){if((e.platform??process.platform)!=="darwin")throw new rt("unsupported_platform","The managed Reason runtime is currently available only on macOS.");let n=e.environment??process.env,r=C(n,"REASON_CLI_CHANNEL")==="staging",i=r?C(n,"REASON_MANAGED_RUNTIME_ROOT")?.trim():void 0,o=e.root!==void 0||Boolean(i&&fe(i))?null:c(e.home??a(),"Library","Application Support"),d=e.root??(o?c(o,r?"Reason Staging":"Reason","CLI"):i);return{executableName:"reason",root:d,...o?{legacyRoot:c(o,"Ara",...r?["staging","runtime"]:["runtime"])}:{},versions:c(d,"versions"),current:c(d,"current"),previous:c(d,"previous"),brokerLock:c(d,"broker.lock"),transitionLock:c(d,"transition.lock"),lifecycleEvents:c(d,"lifecycle-events")}}function Ko(e){let t=e.legacyRoot;if(!t)return null;return{root:t,versions:c(t,"versions"),current:c(t,"current"),previous:c(t,"previous"),brokerLock:c(t,"broker.lock"),transitionLock:c(t,"transition.lock"),lifecycleEvents:c(t,"lifecycle-events")}}function pe(e,t){let n;try{if(!R(e).isSymbolicLink())return null;n=J(e)}catch{return null}let r=n.match(/^versions\/(\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?)\/(ara|Reason|reason)$/);return r&&(r[2]==="ara"||r[2]===t)?r[1]:null}function Jo(e){return pe(e.current,e.executableName)}function D(e,t,n){let i=ge(t,e).split(_e);return i.length===2&&E(i[0])&&(i[1]==="ara"||n!==void 0&&i[1]===n)?i[0]:null}function Le(e,t){try{return R(t).isSymbolicLink()&&b(N(t),J(t))===b(e.current)}catch{return!1}}function Zo(e,t=process.execPath){try{return D(x(t),x(e.versions),e.executableName)!==null}catch{let n=b(t);return n===b(e.current)||Le(e,n)||D(n,b(e.versions),e.executableName)!==null}}function Ae(e){return X(e)&&W(e,["schema_version","pid","nonce","started_at","runtime_version"])&&e.schema_version===q&&typeof e.pid==="number"&&Number.isSafeInteger(e.pid)&&e.pid>0&&typeof e.nonce==="string"&&/^[0-9a-f-]{36}$/.test(e.nonce)&&Z(e.started_at)&&E(e.runtime_version)}function Q(e,t){try{let n=R(e);if(!n.isDirectory()||!I(n))return null;let r=G(c(e,t),g.O_RDONLY|g.O_NOFOLLOW|g.O_NONBLOCK);try{let i=F(r);if(!i.isFile()||i.nlink!==1||!I(i)||i.size>4096)return null;return Y(r,"utf8")}finally{h(r)}}catch{return null}}function A(e){try{let t=JSON.parse(Q(e,"owner.json")??"null");return Ae(t)?t:null}catch{return null}}function ee(e){try{return process.kill(e,0),!0}catch(t){return!(t instanceof Error&&("code"in t)&&t.code==="ESRCH")}}var O="lease",Ne=2,Se=4,y;function ke(){if(y!==void 0)return y;if(y=null,process.platform!=="linux"&&process.platform!=="darwin")return null;let e;try{e=H(import.meta.url)("bun:ffi")}catch{return null}let t=process.platform==="darwin"?"__error":"__errno_location",n=process.platform==="darwin"?["/usr/lib/libSystem.B.dylib"]:["libc.so.6",`libc.musl-${process.arch==="arm64"?"aarch64":"x86_64"}.so.1`];for(let r of n)try{let i=e.dlopen(r,{flock:{args:[e.FFIType.i32,e.FFIType.i32],returns:e.FFIType.i32},[t]:{args:[],returns:e.FFIType.ptr}}),s=i.symbols[t]();if(s===null)continue;return y={flock:(o,d)=>i.symbols.flock(o,d),errno:()=>e.read.i32(s),wouldBlock:process.platform==="darwin"?35:11},y}catch{}return null}var v,Ie=3221225472,Te=4,xe=128,Pe=32;function De(e){if(v===void 0){v=null;try{let s=H(import.meta.url)("bun:ffi"),{FFIType:o}=s;v={kernel:s.dlopen("kernel32.dll",{CreateFileW:{args:[o.ptr,o.u32,o.u32,o.ptr,o.u32,o.u32,o.ptr],returns:o.i64_fast},CloseHandle:{args:[o.i64_fast],returns:o.i32},GetLastError:{args:[],returns:o.u32}}).symbols,ptr:(l)=>s.ptr(l)}}catch{return null}}if(!v)return null;let{kernel:t,ptr:n}=v,r=Buffer.from(`${e}\x00`,"utf16le"),i=t.CreateFileW(n(r),Ie,0,null,Te,xe,null);if(Number(i)===-1)return t.GetLastError()===Pe?"busy":null;return{release:()=>{t.CloseHandle(i)}}}function Oe(e){if(process.platform==="win32")return De(`${e}.lease`);let t=ke();if(!t)return null;let n=G(`${e}.lease`,g.O_RDWR|g.O_CREAT|g.O_NOFOLLOW,384);try{let r=F(n);if(!r.isFile()||r.nlink!==1||!I(r))return h(n),"busy";if(t.flock(n,Ne|Se)===0)return{release:()=>h(n)};let i=t.errno();return h(n),i===t.wouldBlock?"busy":null}catch(r){throw h(n),r}}function Xo(e){S(N(e.path));let t=Oe(e.path);if(t==="busy")return{acquired:!1,owner:A(e.path),recoveredStaleOwner:!1};let n=t!==null;try{let r=Ce(e,t);if(r.acquired)n=!1;return r}finally{if(n)t.release()}}function Ce(e,t){let n=e.alive??ee,r=!1;for(let i=0;i<4;i+=1){let s={schema_version:q,pid:e.pid??process.pid,nonce:e.nonce?.()??f(),started_at:(e.now?.()??new Date).toISOString(),runtime_version:e.runtimeVersion},o=`${e.path}.init-${process.pid}-${f()}`,d=!1;try{if(B(o,{mode:448}),L(c(o,"owner.json"),`${JSON.stringify(s)}
3
3
  `,{mode:384,flag:"wx"}),t!==null)L(c(o,O),`flock
4
- `,{mode:384,flag:"wx"});e.beforePublish?.();try{throw R(e.path),Object.assign(Error("Managed runtime lock exists."),{code:"EEXIST"})}catch(m){if(m.code!=="ENOENT")throw m}_(o,e.path),d=!0;let l=!1;return{acquired:!0,owner:s,recoveredStaleOwner:r,release(){if(l)return;if(l=!0,A(e.path)?.nonce===s.nonce)p(e.path,{recursive:!0,force:!0});t?.release()}}}catch(l){let m=l.code;if(!["EEXIST","ENOTEMPTY"].includes(m??""))throw l;let u=A(e.path),re=(e.now?.()??new Date).getTime(),ie=u&&e.staleAfterMs!==void 0?re-Date.parse(u.started_at)<e.staleAfterMs:!1,ae=u!==null&&!(t!==null&&Q(e.path,O)!==null)&&n(u.pid);if(!u||ae||ie)return{acquired:!1,owner:u,recoveredStaleOwner:!1};let k=`${e.path}.stale-${process.pid}-${f()}`;try{_(e.path,k),p(k,{recursive:!0,force:!0}),r=!0}catch(T){let oe=T.code;if(!["ENOENT","EEXIST"].includes(oe??""))throw T}}finally{if(!d)p(o,{recursive:!0,force:!0})}}throw new tt("lock_unavailable","Could not acquire the managed Reason runtime lock.")}function te(e){return X(e)&&W(e,["schema_version","event_id","occurred_at","event","runtime_version"],["from_version","to_version","reason_code","duration_ms","attempt_count","retry_in_ms","capabilities"])&&e.schema_version===j&&typeof e.event_id==="string"&&/^[0-9a-f-]{36}$/.test(e.event_id)&&Z(e.occurred_at)&&typeof e.event==="string"&&we.includes(e.event)&&E(e.runtime_version)&&(e.from_version===void 0||E(e.from_version))&&(e.to_version===void 0||E(e.to_version))&&(e.reason_code===void 0||typeof e.reason_code==="string"&&P.test(e.reason_code))&&(e.duration_ms===void 0||typeof e.duration_ms==="number"&&Number.isSafeInteger(e.duration_ms)&&e.duration_ms>=0&&e.duration_ms<=86400000)&&(e.attempt_count===void 0||typeof e.attempt_count==="number"&&Number.isSafeInteger(e.attempt_count)&&e.attempt_count>=1&&e.attempt_count<=1e5)&&(e.retry_in_ms===void 0||typeof e.retry_in_ms==="number"&&Number.isSafeInteger(e.retry_in_ms)&&e.retry_in_ms>=0&&e.retry_in_ms<=30000)&&(e.capabilities===void 0||Array.isArray(e.capabilities)&&e.capabilities.length<=be&&e.capabilities.every((t)=>typeof t==="string"&&P.test(t)))}var Ve=/^(\d{22}-[0-9a-f-]{36}\.json)$/,Ue=/^(\d{22}-[0-9a-f-]{36}\.json)\.sending-(\d+)-[0-9a-f-]{36}$/,Fe=300000,w=0n;function Be(e){let t=BigInt(new Date(e.occurred_at).getTime())*1000000n;return w=t>w?t:w+1n,`${String(w).padStart(22,"0")}-${e.event_id}.json`}function ne(e){try{return z(e.lifecycleEvents).filter((t)=>Ve.test(t)).sort()}catch{return[]}}function V(e){try{let t=JSON.parse(Y(e,"utf8"));return te(t)?t:null}catch{return null}}function $e(e,t=ee,n=Date.now()){let r;try{r=z(e.lifecycleEvents)}catch{return}for(let i of r){let s=i.match(Ue);if(!s)continue;let o=c(e.lifecycleEvents,i),d=c(e.lifecycleEvents,s[1]),l=!t(Number(s[2]));if(!l)try{l=n-K(o).mtimeMs>=Fe}catch{continue}if(!l)continue;try{_(o,d)}catch(m){let u=m.code;if(u==="EEXIST")M(o);else if(u!=="ENOENT")throw m}}}function Ge(e){let n=ne(e).flatMap((i)=>{try{return[{name:i,size:K(c(e.lifecycleEvents,i)).size}]}catch{return[]}}),r=n.reduce((i,s)=>i+s.size,0);while(n.length>ye||r>ve){let i=n.shift();if(!i)break;try{M(c(e.lifecycleEvents,i.name)),r-=i.size}catch(s){if(s.code!=="ENOENT")throw s}}}function Zo(e,t,n={}){let r={schema_version:j,event_id:n.eventId?.()??f(),occurred_at:(n.now?.()??new Date).toISOString(),...t};if(!te(r))throw new tt("invalid_lifecycle_event","Managed runtime lifecycle event is invalid.");return S(e.lifecycleEvents),Re(c(e.lifecycleEvents,Be(r)),`${JSON.stringify(r)}
5
- `),Ge(e),r}async function Xo(e,t,n){$e(e);let r=0;for(let i of ne(e)){let s=c(e.lifecycleEvents,i);if(n){let l=V(s);if(!l||!n(l))continue}let o=`${s}.sending-${process.pid}-${f()}`;try{_(s,o)}catch(l){if(l.code==="ENOENT")continue;throw l}let d=V(o);if(!d){M(o);continue}try{await t(d),M(o),r+=1}catch{try{_(o,s)}catch(l){if(l.code!=="ENOENT")throw l}break}}return r}export{Wo,Vo,Go,Ko,Jo,Zo,Xo};
4
+ `,{mode:384,flag:"wx"});e.beforePublish?.();try{throw R(e.path),Object.assign(Error("Managed runtime lock exists."),{code:"EEXIST"})}catch(m){if(m.code!=="ENOENT")throw m}_(o,e.path),d=!0;let l=!1;return{acquired:!0,owner:s,recoveredStaleOwner:r,release(){if(l)return;if(l=!0,A(e.path)?.nonce===s.nonce)p(e.path,{recursive:!0,force:!0});t?.release()}}}catch(l){let m=l.code;if(!["EEXIST","ENOTEMPTY"].includes(m??""))throw l;let u=A(e.path),re=(e.now?.()??new Date).getTime(),ie=u&&e.staleAfterMs!==void 0?re-Date.parse(u.started_at)<e.staleAfterMs:!1,ae=u!==null&&!(t!==null&&Q(e.path,O)!==null)&&n(u.pid);if(!u||ae||ie)return{acquired:!1,owner:u,recoveredStaleOwner:!1};let k=`${e.path}.stale-${process.pid}-${f()}`;try{_(e.path,k),p(k,{recursive:!0,force:!0}),r=!0}catch(T){let oe=T.code;if(!["ENOENT","EEXIST"].includes(oe??""))throw T}}finally{if(!d)p(o,{recursive:!0,force:!0})}}throw new rt("lock_unavailable","Could not acquire the managed Reason runtime lock.")}function te(e){return X(e)&&W(e,["schema_version","event_id","occurred_at","event","runtime_version"],["from_version","to_version","reason_code","duration_ms","attempt_count","retry_in_ms","capabilities"])&&e.schema_version===j&&typeof e.event_id==="string"&&/^[0-9a-f-]{36}$/.test(e.event_id)&&Z(e.occurred_at)&&typeof e.event==="string"&&we.includes(e.event)&&E(e.runtime_version)&&(e.from_version===void 0||E(e.from_version))&&(e.to_version===void 0||E(e.to_version))&&(e.reason_code===void 0||typeof e.reason_code==="string"&&P.test(e.reason_code))&&(e.duration_ms===void 0||typeof e.duration_ms==="number"&&Number.isSafeInteger(e.duration_ms)&&e.duration_ms>=0&&e.duration_ms<=86400000)&&(e.attempt_count===void 0||typeof e.attempt_count==="number"&&Number.isSafeInteger(e.attempt_count)&&e.attempt_count>=1&&e.attempt_count<=1e5)&&(e.retry_in_ms===void 0||typeof e.retry_in_ms==="number"&&Number.isSafeInteger(e.retry_in_ms)&&e.retry_in_ms>=0&&e.retry_in_ms<=30000)&&(e.capabilities===void 0||Array.isArray(e.capabilities)&&e.capabilities.length<=be&&e.capabilities.every((t)=>typeof t==="string"&&P.test(t)))}var Ve=/^(\d{22}-[0-9a-f-]{36}\.json)$/,Ue=/^(\d{22}-[0-9a-f-]{36}\.json)\.sending-(\d+)-[0-9a-f-]{36}$/,Fe=300000,w=0n;function Be(e){let t=BigInt(new Date(e.occurred_at).getTime())*1000000n;return w=t>w?t:w+1n,`${String(w).padStart(22,"0")}-${e.event_id}.json`}function ne(e){try{return z(e.lifecycleEvents).filter((t)=>Ve.test(t)).sort()}catch{return[]}}function V(e){try{let t=JSON.parse(Y(e,"utf8"));return te(t)?t:null}catch{return null}}function $e(e,t=ee,n=Date.now()){let r;try{r=z(e.lifecycleEvents)}catch{return}for(let i of r){let s=i.match(Ue);if(!s)continue;let o=c(e.lifecycleEvents,i),d=c(e.lifecycleEvents,s[1]),l=!t(Number(s[2]));if(!l)try{l=n-K(o).mtimeMs>=Fe}catch{continue}if(!l)continue;try{_(o,d)}catch(m){let u=m.code;if(u==="EEXIST")M(o);else if(u!=="ENOENT")throw m}}}function Ge(e){let n=ne(e).flatMap((i)=>{try{return[{name:i,size:K(c(e.lifecycleEvents,i)).size}]}catch{return[]}}),r=n.reduce((i,s)=>i+s.size,0);while(n.length>ye||r>ve){let i=n.shift();if(!i)break;try{M(c(e.lifecycleEvents,i.name)),r-=i.size}catch(s){if(s.code!=="ENOENT")throw s}}}function Yo(e,t,n={}){let r={schema_version:j,event_id:n.eventId?.()??f(),occurred_at:(n.now?.()??new Date).toISOString(),...t};if(!te(r))throw new rt("invalid_lifecycle_event","Managed runtime lifecycle event is invalid.");return S(e.lifecycleEvents),Re(c(e.lifecycleEvents,Be(r)),`${JSON.stringify(r)}
5
+ `),Ge(e),r}async function Qo(e,t,n){$e(e);let r=0;for(let i of ne(e)){let s=c(e.lifecycleEvents,i);if(n){let l=V(s);if(!l||!n(l))continue}let o=`${s}.sending-${process.pid}-${f()}`;try{_(s,o)}catch(l){if(l.code==="ENOENT")continue;throw l}let d=V(o);if(!d){M(o);continue}try{await t(d),M(o),r+=1}catch{try{_(o,s)}catch(l){if(l.code!=="ENOENT")throw l}break}}return r}export{Go,Ko,Jo,Zo,Xo,Yo,Qo};