@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{t,pt,A,o,d,u,c,_,oe,s,n}from"./vm-hands-entry-lite-zn0v259d.js";var T=t().max(201).regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/).refine((e)=>e.split("/").every((r)=>r!=="."&&r!=="..")),y=t().min(1).max(255).regex(/^[A-Za-z0-9_][A-Za-z0-9_./-]*$/).refine((e)=>!e.includes("..")&&!e.includes("//")&&!e.endsWith("/")&&!e.endsWith(".lock")),x=t().regex(/^[a-f0-9]{40}$/),E=o().int().positive(),k=t().min(1).max(256),D=t().max(60000),L={version:n(1),repoFullName:T},v=u(t().max(1024).regex(/^(?:Co-authored-by: [^<>\r\n\x00]+ <[^<>\s]+@[^<>\s]+>|Reason-Contributor-ID: rc_[a-f0-9]{32})$/)).max(1000),G=c({expectedTrailers:v,missingFromHead:v}),z=_("action",[c({action:n("edit"),title:k.optional(),body:D.optional(),base:y.optional()}),c({action:s(["ready","draft","close"])}),c({action:n("metadata"),field:s(["reviewer","assignee","label"]),change:s(["add","remove"]),value:t().min(1).max(100).refine((e)=>!/[\r\n\0]/.test(e))})]),ke=_("kind",[c({...L,kind:n("read"),path:t().min(1).max(2048),accept:s(["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"]).optional()}),c({...L,kind:n("pr_review_context"),number:E,after:t().min(1).max(1024).optional()}),c({...L,kind:n("prepare"),branch:y,baseSha:x,defaultBranch:y,diagnosticsVersion:n(1).optional()}),c({...L,kind:n("publish"),branch:y,defaultBranch:y,baseSha:x,remoteHeadSha:x.nullable(),contributorTrailers:v.optional()}),c({...L,kind:n("pr_create"),head:y,base:y,title:k,body:D,draft:d()}),c({...L,kind:n("pr_mutation"),number:E,mutation:z}),c({...L,kind:n("pr_merge"),number:E,expectedHeadSha:x,expectedBaseRef:y,method:s(["merge","squash","rebase"]),commitBody:t().max(65536).optional()})]),V=["local_device_gh_prepare_setup","local_device_gh_prepare_metadata","local_device_gh_prepare_private_init","local_device_gh_prepare_fetch","local_device_gh_prepare_base_mismatch","local_device_gh_prepare_checkout_validation","local_device_gh_prepare_checkout_init","local_device_gh_prepare_materialization"];function F(e){return V.some((r)=>r===e)}class zt extends Error{code;constructor(e){super(e);this.code=e}}function Ln(e,r,i){let l=ke.safeParse(e);return r==="failed"&&l.success&&l.data.kind==="prepare"&&l.data.diagnosticsVersion===1&&F(i)}var ct=245760,uo=_("kind",[c({kind:n("pr_review_context"),body:t().max(ct)}),c({kind:n("prepare"),headSha:x}),c({kind:n("read"),status:o().int().min(200).max(599),headers:oe(t(),t().max(8192)).refine((e)=>Object.keys(e).every((r)=>r==="link"||r==="content-type")),body:t().max(ct)}),c({kind:n("publish"),headSha:x,scannedObjectCount:o().int().min(0).max(5000),attribution:G.optional()}),c({kind:n("pr_create"),url:t().max(1024).regex(/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/pull\/[1-9][0-9]*$/)}),c({kind:n("pr_mutation"),number:E,applied:n(!0)}),c({kind:n("pr_merge"),number:E,merged:n(!0)})]).refine((e)=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=ct,"local_device_gh_result_too_large"),B=c({source:s(["agent","human"]),operationId:A()}),ie=c({version:n(1),userId:pt(),deviceId:pt(),rootId:pt(),runId:pt(),merge:B.optional(),contributorRefresh:pt().optional(),repoFullName:T.nullable(),rootRevision:t().regex(/^[1-9][0-9]*$/),readOnly:d(),generation:o().int().positive().nullable(),fenceId:pt().nullable()}).refine((e)=>e.generation===null===(e.fenceId===null));function I(e){return/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(e)&&e.split("/").every((r)=>r!=="."&&r!=="..")}function po(e,r,i={},l="read"){if(I(e)&&(r==="/search/issues"||r.startsWith("/search/issues?")))return J(e,r,i);if(!I(e)||!r.startsWith(`/repos/${e}/`)&&r!==`/repos/${e}`)throw Error("local_device_gh_repository_mismatch");if(/[\\#\u0000-\u001f]/.test(r)||/%(?:2e|5c|00)/i.test(r))throw Error("local_device_gh_path_denied");let g=new URL(r,"https://api.github.com");if(g.pathname!==r.split("?")[0]||g.username||g.password)throw Error("local_device_gh_path_denied");let h;try{h=decodeURIComponent(g.pathname.slice(`/repos/${e}`.length))}catch{throw Error("local_device_gh_path_denied")}if(h.includes("%")||h.split("/").some((p)=>p==="."||p===".."))throw Error("local_device_gh_path_denied");if((i.method??"GET").toUpperCase()!=="GET"||i.body!=null)throw Error("local_device_gh_mutation_not_admitted");if(![/^$/,/^\/commits$/,/^\/pulls$/,/^\/pulls\/[1-9][0-9]*(?:\/(?:commits|files|reviews|comments))?$/,/^\/issues\/[1-9][0-9]*(?:\/comments)?$/,/^\/issues\/comments\/[1-9][0-9]*\/reactions$/,/^\/commits\/[A-Za-z0-9_./-]+(?:\/(?:check-runs|status))?$/,/^\/check-runs\/[1-9][0-9]*(?:\/annotations)?$/,/^\/branches\/[A-Za-z0-9_./-]+$/,/^\/git\/ref\/heads\/[A-Za-z0-9_./-]+$/,/^\/compare\/[A-Za-z0-9_./-]+\.\.\.[A-Za-z0-9_./-]+$/].some((p)=>p.test(h)))throw Error("local_device_gh_path_denied");if(g.searchParams.forEach((p,b)=>{if(b==="per_page"&&/^[1-9][0-9]*$/.test(p)&&Number(p)<=100)return;if(b==="page"&&/^[1-9][0-9]*$/.test(p)&&Number(p)<=100)return;if(h==="/pulls"&&b==="state"&&["open","closed","all"].includes(p))return;if(h==="/pulls"&&b==="sort"&&p==="updated")return;if(h==="/pulls"&&b==="direction"&&p==="desc")return;if(h==="/pulls"&&["head","base"].includes(b)&&/^[A-Za-z0-9_./:-]{1,255}$/.test(p))return;throw Error("local_device_gh_query_denied")}),i.headers)new Headers(i.headers).forEach((b,j)=>{if(j!=="accept"||!["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"].includes(b))throw Error("local_device_gh_header_denied")})}function J(e,r,i){if(/[\\#\u0000-\u001f]/.test(r))throw Error("local_device_gh_path_denied");let l=new URL(r,"https://api.github.com");if(l.pathname!=="/search/issues"||l.username||l.password)throw Error("local_device_gh_path_denied");if((i.method??"GET").toUpperCase()!=="GET"||i.body!=null)throw Error("local_device_gh_mutation_not_admitted");let g=null;l.searchParams.forEach((f,p)=>{if(p==="q"&&g===null){g=f;return}if(p==="per_page"&&/^[1-9][0-9]*$/.test(f)&&Number(f)<=100)return;if(p==="page"&&/^[1-9][0-9]*$/.test(f)&&Number(f)<=100)return;throw Error("local_device_gh_query_denied")});let h=`repo:${e.toLowerCase()} `,S=g?.toLowerCase()??"";if(S.length>512||!(S+" ").startsWith(h)||/(?:^|\s)(?:repo|org|user):/.test(S.slice(h.length)))throw Error("local_device_gh_query_denied");if(i.headers)new Headers(i.headers).forEach((f,p)=>{if(p!=="accept"||f!=="application/vnd.github+json")throw Error("local_device_gh_header_denied")})}var ho=`query PullRequestReviewContext($owner: String!, $repo: String!, $number: Int!, $after: String) {
2
+ import{t,ft,A,o,d,u,c,_,oe,s,n}from"./vm-hands-entry-lite-907pa7f9.js";var T=t().max(201).regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/).refine((e)=>e.split("/").every((r)=>r!=="."&&r!=="..")),y=t().min(1).max(255).regex(/^[A-Za-z0-9_][A-Za-z0-9_./-]*$/).refine((e)=>!e.includes("..")&&!e.includes("//")&&!e.endsWith("/")&&!e.endsWith(".lock")),x=t().regex(/^[a-f0-9]{40}$/),O=o().int().positive(),k=t().min(1).max(256),D=t().max(60000),L={version:n(1),repoFullName:T},N=u(t().max(1024).regex(/^(?:Co-authored-by: [^<>\r\n\x00]+ <[^<>\s]+@[^<>\s]+>|Reason-Contributor-ID: rc_[a-f0-9]{32})$/)).max(1000),j=c({expectedTrailers:N,missingFromHead:N}),z=_("action",[c({action:n("edit"),title:k.optional(),body:D.optional(),base:y.optional()}),c({action:s(["ready","draft","close"])}),c({action:n("metadata"),field:s(["reviewer","assignee","label"]),change:s(["add","remove"]),value:t().min(1).max(100).refine((e)=>!/[\r\n\0]/.test(e))})]),ke=_("kind",[c({...L,kind:n("read"),path:t().min(1).max(2048),accept:s(["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"]).optional()}),c({...L,kind:n("pr_review_context"),number:O,after:t().min(1).max(1024).optional()}),c({...L,kind:n("prepare"),branch:y,baseSha:x,defaultBranch:y,diagnosticsVersion:n(1).optional()}),c({...L,kind:n("publish"),branch:y,defaultBranch:y,baseSha:x,remoteHeadSha:x.nullable(),contributorTrailers:N.optional()}),c({...L,kind:n("pr_create"),head:y,base:y,title:k,body:D,draft:d()}),c({...L,kind:n("pr_mutation"),number:O,mutation:z}),c({...L,kind:n("pr_merge"),number:O,expectedHeadSha:x,expectedBaseRef:y,method:s(["merge","squash","rebase"]),commitBody:t().max(65536).optional()})]),V=["local_device_gh_prepare_setup","local_device_gh_prepare_metadata","local_device_gh_prepare_private_init","local_device_gh_prepare_fetch","local_device_gh_prepare_base_mismatch","local_device_gh_prepare_checkout_validation","local_device_gh_prepare_checkout_init","local_device_gh_prepare_materialization"];function F(e){return V.some((r)=>r===e)}class Vt extends Error{code;constructor(e){super(e);this.code=e}}function $n(e,r,i){let l=ke.safeParse(e);return r==="failed"&&l.success&&l.data.kind==="prepare"&&l.data.diagnosticsVersion===1&&F(i)}var lt=245760,ho=_("kind",[c({kind:n("pr_review_context"),body:t().max(lt)}),c({kind:n("prepare"),headSha:x}),c({kind:n("read"),status:o().int().min(200).max(599),headers:oe(t(),t().max(8192)).refine((e)=>Object.keys(e).every((r)=>r==="link"||r==="content-type")),body:t().max(lt)}),c({kind:n("publish"),headSha:x,scannedObjectCount:o().int().min(0).max(5000),attribution:j.optional()}),c({kind:n("pr_create"),url:t().max(1024).regex(/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/pull\/[1-9][0-9]*$/)}),c({kind:n("pr_mutation"),number:O,applied:n(!0)}),c({kind:n("pr_merge"),number:O,merged:n(!0)})]).refine((e)=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=lt,"local_device_gh_result_too_large"),B=c({source:s(["agent","human"]),operationId:A()}),ie=c({version:n(1),userId:ft(),deviceId:ft(),rootId:ft(),runId:ft(),merge:B.optional(),contributorRefresh:ft().optional(),repoFullName:T.nullable(),rootRevision:t().regex(/^[1-9][0-9]*$/),readOnly:d(),generation:o().int().positive().nullable(),fenceId:ft().nullable()}).refine((e)=>e.generation===null===(e.fenceId===null));function I(e){return/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(e)&&e.split("/").every((r)=>r!=="."&&r!=="..")}function fo(e,r,i={},l="read"){if(I(e)&&(r==="/search/issues"||r.startsWith("/search/issues?")))return W(e,r,i);if(!I(e)||!r.startsWith(`/repos/${e}/`)&&r!==`/repos/${e}`)throw Error("local_device_gh_repository_mismatch");if(/[\\#\u0000-\u001f]/.test(r)||/%(?:2e|5c|00)/i.test(r))throw Error("local_device_gh_path_denied");let g=new URL(r,"https://api.github.com");if(g.pathname!==r.split("?")[0]||g.username||g.password)throw Error("local_device_gh_path_denied");let h;try{h=decodeURIComponent(g.pathname.slice(`/repos/${e}`.length))}catch{throw Error("local_device_gh_path_denied")}if(h.includes("%")||h.split("/").some((p)=>p==="."||p===".."))throw Error("local_device_gh_path_denied");if((i.method??"GET").toUpperCase()!=="GET"||i.body!=null)throw Error("local_device_gh_mutation_not_admitted");if(![/^$/,/^\/commits$/,/^\/pulls$/,/^\/pulls\/[1-9][0-9]*(?:\/(?:commits|files|reviews|comments))?$/,/^\/issues\/[1-9][0-9]*(?:\/comments)?$/,/^\/issues\/comments\/[1-9][0-9]*\/reactions$/,/^\/commits\/[A-Za-z0-9_./-]+(?:\/(?:check-runs|status))?$/,/^\/check-runs\/[1-9][0-9]*(?:\/annotations)?$/,/^\/branches\/[A-Za-z0-9_./-]+$/,/^\/git\/ref\/heads\/[A-Za-z0-9_./-]+$/,/^\/compare\/[A-Za-z0-9_./-]+\.\.\.[A-Za-z0-9_./-]+$/].some((p)=>p.test(h)))throw Error("local_device_gh_path_denied");if(g.searchParams.forEach((p,b)=>{if(b==="per_page"&&/^[1-9][0-9]*$/.test(p)&&Number(p)<=100)return;if(b==="page"&&/^[1-9][0-9]*$/.test(p)&&Number(p)<=100)return;if(h==="/pulls"&&b==="state"&&["open","closed","all"].includes(p))return;if(h==="/pulls"&&b==="sort"&&p==="updated")return;if(h==="/pulls"&&b==="direction"&&p==="desc")return;if(h==="/pulls"&&["head","base"].includes(b)&&/^[A-Za-z0-9_./:-]{1,255}$/.test(p))return;throw Error("local_device_gh_query_denied")}),i.headers)new Headers(i.headers).forEach((b,G)=>{if(G!=="accept"||!["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"].includes(b))throw Error("local_device_gh_header_denied")})}function W(e,r,i){if(/[\\#\u0000-\u001f]/.test(r))throw Error("local_device_gh_path_denied");let l=new URL(r,"https://api.github.com");if(l.pathname!=="/search/issues"||l.username||l.password)throw Error("local_device_gh_path_denied");if((i.method??"GET").toUpperCase()!=="GET"||i.body!=null)throw Error("local_device_gh_mutation_not_admitted");let g=null;l.searchParams.forEach((f,p)=>{if(p==="q"&&g===null){g=f;return}if(p==="per_page"&&/^[1-9][0-9]*$/.test(f)&&Number(f)<=100)return;if(p==="page"&&/^[1-9][0-9]*$/.test(f)&&Number(f)<=100)return;throw Error("local_device_gh_query_denied")});let h=`repo:${e.toLowerCase()} `,S=g?.toLowerCase()??"";if(S.length>512||!(S+" ").startsWith(h)||/(?:^|\s)(?:repo|org|user):/.test(S.slice(h.length)))throw Error("local_device_gh_query_denied");if(i.headers)new Headers(i.headers).forEach((f,p)=>{if(p!=="accept"||f!=="application/vnd.github+json")throw Error("local_device_gh_header_denied")})}var mo=`query PullRequestReviewContext($owner: String!, $repo: String!, $number: Int!, $after: String) {
3
3
  repository(owner: $owner, name: $repo) {
4
4
  nameWithOwner
5
5
  pullRequest(number: $number) {
@@ -34,9 +34,9 @@ import{t,pt,A,o,d,u,c,_,oe,s,n}from"./vm-hands-entry-lite-zn0v259d.js";var T=t()
34
34
  }
35
35
  }
36
36
  }
37
- }`;function We(e){return e.kind==="read"||e.kind==="pr_review_context"}var lt=["inspect_project","fs.read","fs.write","fs.search","fs.watch","fs.upload","fs.export","fs.import","fs.download","exec.run","exec.full","process.run.v1","process.full.v1","pty.start","pty.input","pty.resize","pty.close","git.run","process.list","process.signal","ports.list","tunnel.open","tunnel.close","env.discover","setup.run","mcp.discover","mcp.start","mcp.proxy","browser.snapshot","browser.navigate","browser.act","computer.snapshot","computer.act","computer.use","browser.use","browser.recording.v1","browser.pr-proof.v1","hands.connect","jobs.control","environment.install","github.local.v1","inference.ollama.v1","inference.custom.v1","delegate.devin.copy.v1","delegate.cursor.copy.v1","display.stream.v1","automation.call.v1","preview.serve.v1","workspace.setup.v1","simulator.call.v1","simulator.stream.v1"];var Ve=2,w="/app/local-runtime",Ce=262144,gs="x-reason-relay-host-alias",_s="v1";function m(e,r){return{path:`${w}${e}`,routerPath:e,auth:r}}function O(e,r){return{...m(e,"device_proof"),forOperation(i){return m(`/operations/${encodeURIComponent(i)}${r}`,"device_proof")}}}var ys={register:m("/register","registration_bearer"),enroll:m("/enroll","none"),authChallenge:m("/auth/challenge","none"),identity:m("/identity","device_proof"),heartbeat:m("/heartbeat","device_proof"),rootsSync:m("/roots/sync","device_proof"),disconnect:m("/disconnect","device_proof"),lifecycle:m("/lifecycle","device_proof"),localSubscription:m("/local-subscription","device_proof"),ownerWorkspaces:m("/owner-workspaces","device_proof"),ownerWorkspaceEnrollment:m("/owner-workspaces/enrollment","device_proof"),sessionWorktrees:m("/session-worktrees","device_proof"),operationClaim:m("/operations/claim","device_proof"),operationHeartbeat:O("/operations/:operationId/heartbeat","/heartbeat"),operationEvents:O("/operations/:operationId/events","/events"),operationComplete:O("/operations/:operationId/complete","/complete"),operationEnvironment:O("/operations/:operationId/environment","/environment"),operationEnvironmentAck:O("/operations/:operationId/environment-ack","/environment-ack"),operationCustomEndpointCredential:O("/operations/:operationId/custom-endpoint-credential","/custom-endpoint-credential")},Mn=`${w}/session`;var W=[/^\/app\/local-runtime\/heartbeat$/,/^\/app\/local-runtime\/operations\/claim$/,/^\/app\/local-runtime\/operations\/[0-9a-fA-F-]{36}\/(?:heartbeat|events|complete|environment|environment-ack)$/];function bs(e){return W.some((r)=>r.test(e))}var zr=60000;var $n="hands_control_v1",ut="environment.deliver",Bn="vm_hands_workspace_deferred",Fn="vm_hands.workspace_grant",jn="hands.unbind_unverified",Un="claim_v1",Hn="environment_at_claim",qn="ready_v1",zn="workspace_check",Wn="rebind_v1",Vn="resident_rebind",Gn="hands.rebind",Kn="snapshot_v1",Jn="cloud_access",Zn="playwright_v1",Xn="headless_browser",Yn="v1",Qn="job_env_large_values",pe="srt_root_v1",X="hands_confinement",Ae="gid_v1",q="model_jobs_egress",ei="setpriv_v1",ti="jobs_user",ri="spawning_attempt_v1",Y="hands_session_group";var ni="session_cap",ii="none",oi="same_launch_v1",si="exit_v1",ai="start_wait",dt="user_chrome",ci="cloud_sessions";function N(e){if(!a(e)||Object.keys(e).length!==5||e.version!==1)return!1;let r=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return["boot_generation","recording_operation_id","recording_attempt_id"].every((i)=>typeof e[i]==="string"&&r.test(e[i]))&&typeof e.root_version==="string"&&/^[0-9]{1,20}(?:\.[0-9]{1,6})?$/.test(e.root_version)}function C(e){if(!a(e)||Object.keys(e).length!==6)return!1;let r=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return typeof e.device_id==="string"&&r.test(e.device_id)&&(e.binding==="workspace_source"||e.binding==="mcp_control")&&Number.isSafeInteger(e.target_revision)&&Number(e.target_revision)>=0&&Number.isSafeInteger(e.root_grant_revision)&&Number(e.root_grant_revision)>0&&Number.isSafeInteger(e.target_generation)&&Number(e.target_generation)>0&&typeof e.target_fence_id==="string"&&r.test(e.target_fence_id)}var vs=["lock_acquired","enrollment_started","enrollment_completed","readiness_started","readiness_completed","inventory_completed","control_ready"],Wt=86400000;var K=["production","staging"];function P(e){if(!a(e)||Object.keys(e).length!==3)return!1;let r=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return["organization_id","user_id","device_id"].every((i)=>Object.hasOwn(e,i)&&typeof e[i]==="string"&&r.test(e[i])&&e[i]!=="00000000-0000-0000-0000-000000000000")}var Z="DEVICE-PROOF-V2";function li(e,r=Z){let i=e.method.toUpperCase();if(!/^[A-Z]+$/.test(i)||!e.pathAndQuery.startsWith(`${w}/`)||e.pathAndQuery.includes(`
37
+ }`;function Ve(e){return e.kind==="read"||e.kind==="pr_review_context"}var ut=["inspect_project","fs.read","fs.write","fs.search","fs.watch","fs.upload","fs.export","fs.import","fs.download","exec.run","exec.full","process.run.v1","process.full.v1","pty.start","pty.input","pty.resize","pty.close","git.run","process.list","process.signal","ports.list","tunnel.open","tunnel.close","env.discover","setup.run","mcp.discover","mcp.start","mcp.proxy","browser.snapshot","browser.navigate","browser.act","computer.snapshot","computer.act","computer.use","browser.use","browser.recording.v1","browser.pr-proof.v1","hands.connect","jobs.control","environment.install","github.local.v1","inference.ollama.v1","inference.custom.v1","delegate.devin.copy.v1","delegate.cursor.copy.v1","display.stream.v1","automation.call.v1","preview.serve.v1","workspace.setup.v1","simulator.call.v1","simulator.stream.v1"];var Ge=2,w="/app/local-runtime",Ce=262144,vs="x-reason-relay-host-alias",Ss="v1";function m(e,r){return{path:`${w}${e}`,routerPath:e,auth:r}}function E(e,r){return{...m(e,"device_proof"),forOperation(i){return m(`/operations/${encodeURIComponent(i)}${r}`,"device_proof")}}}var Es={register:m("/register","registration_bearer"),enroll:m("/enroll","none"),authChallenge:m("/auth/challenge","none"),identity:m("/identity","device_proof"),heartbeat:m("/heartbeat","device_proof"),rootsSync:m("/roots/sync","device_proof"),disconnect:m("/disconnect","device_proof"),lifecycle:m("/lifecycle","device_proof"),localSubscription:m("/local-subscription","device_proof"),ownerWorkspaces:m("/owner-workspaces","device_proof"),ownerWorkspaceEnrollment:m("/owner-workspaces/enrollment","device_proof"),sessionWorktrees:m("/session-worktrees","device_proof"),operationClaim:m("/operations/claim","device_proof"),operationHeartbeat:E("/operations/:operationId/heartbeat","/heartbeat"),operationEvents:E("/operations/:operationId/events","/events"),operationComplete:E("/operations/:operationId/complete","/complete"),operationEnvironment:E("/operations/:operationId/environment","/environment"),operationEnvironmentAck:E("/operations/:operationId/environment-ack","/environment-ack"),operationCustomEndpointCredential:E("/operations/:operationId/custom-endpoint-credential","/custom-endpoint-credential")},Bn=`${w}/session`;var J=[/^\/app\/local-runtime\/heartbeat$/,/^\/app\/local-runtime\/operations\/claim$/,/^\/app\/local-runtime\/operations\/[0-9a-fA-F-]{36}\/(?:heartbeat|events|complete|environment|environment-ack)$/];function xs(e){return J.some((r)=>r.test(e))}var Vr=60000;var Fn="hands_control_v1",dt="environment.deliver",Ae="vm_hands_workspace_deferred",pt="vm_hands.workspace_grant",jn="hands.unbind_unverified",Un="claim_v1",Hn="environment_at_claim",qn="ready_v1",zn="workspace_check",Wn="rebind_v1",Vn="grant_v1",Gn="workspace_grant",Kn="resident_rebind",Jn="hands.rebind",Zn="snapshot_v1",Xn="cloud_access",Yn="playwright_v1",Qn="headless_browser",ei="v1",ti="job_env_large_values",pe="srt_root_v1",X="hands_confinement",Pe="gid_v1",q="model_jobs_egress",ri="setpriv_v1",ni="jobs_user",ii="spawning_attempt_v1",Y="hands_session_group";var oi="session_cap",si="none",ai="same_launch_v1",ci="exit_v1",li="start_wait",ht="user_chrome",ui="cloud_sessions";function v(e){if(!a(e)||Object.keys(e).length!==5||e.version!==1)return!1;let r=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return["boot_generation","recording_operation_id","recording_attempt_id"].every((i)=>typeof e[i]==="string"&&r.test(e[i]))&&typeof e.root_version==="string"&&/^[0-9]{1,20}(?:\.[0-9]{1,6})?$/.test(e.root_version)}function C(e){if(!a(e)||Object.keys(e).length!==6)return!1;let r=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return typeof e.device_id==="string"&&r.test(e.device_id)&&(e.binding==="workspace_source"||e.binding==="mcp_control")&&Number.isSafeInteger(e.target_revision)&&Number(e.target_revision)>=0&&Number.isSafeInteger(e.root_grant_revision)&&Number(e.root_grant_revision)>0&&Number.isSafeInteger(e.target_generation)&&Number(e.target_generation)>0&&typeof e.target_fence_id==="string"&&r.test(e.target_fence_id)}var ks=["lock_acquired","enrollment_started","enrollment_completed","readiness_started","readiness_completed","inventory_completed","control_ready"],Gt=86400000;var K=["production","staging"];function P(e){if(!a(e)||Object.keys(e).length!==3)return!1;let r=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return["organization_id","user_id","device_id"].every((i)=>Object.hasOwn(e,i)&&typeof e[i]==="string"&&r.test(e[i])&&e[i]!=="00000000-0000-0000-0000-000000000000")}var Z="DEVICE-PROOF-V2";function di(e,r=Z){let i=e.method.toUpperCase();if(!/^[A-Z]+$/.test(i)||!e.pathAndQuery.startsWith(`${w}/`)||e.pathAndQuery.includes(`
38
38
  `)||!/^[0-9]{1,20}$/.test(e.timestamp)||!/^[A-Za-z0-9_-]{22,43}$/.test(e.nonce)||e.challenge.length<16||e.challenge.length>1024||e.challenge.includes(`
39
39
  `)||!/^[a-f0-9]{64}$/.test(e.bodySha256))throw Error("Invalid Reason Device proof input.");return Buffer.from([r,i,e.pathAndQuery,e.timestamp,e.nonce,e.challenge,e.bodySha256].join(`
40
- `),"utf8")}function a(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function Q(e,r){return typeof e==="string"&&r.some((i)=>i===e)}function H(e){return a(e)&&typeof e.id==="string"&&typeof e.label==="string"&&typeof e.path_fingerprint==="string"}function ee(e){return a(e)&&Number.isInteger(e.seq)&&Number(e.seq)>=0&&typeof e.kind==="string"&&/^[A-Za-z0-9._:-]{1,64}$/.test(e.kind)&&a(e.payload)}function R(e){throw Error(e)}function Ss(e,r){let i=a(e)?e:{},l=typeof i.error==="string"?i.error:`http_${r}`,g=typeof i.detail==="string"?i.detail:typeof i.message==="string"?i.message:`Reason Device request failed (${r})`;return{code:l,message:g}}function Io(e){if(!a(e)||typeof e.challenge!=="string"||e.challenge.length<16||e.challenge.length>1024||e.challenge.includes(`
41
- `)||typeof e.expires_at!=="string"||!Number.isFinite(Date.parse(e.expires_at)))R("Reason returned an invalid Device proof challenge.");return{challenge:e.challenge,expires_at:e.expires_at}}function M(e,r){if(!a(e)||typeof e.device_id!=="string"||e.auth_scheme!=="p256"||e.organization_id!==void 0&&typeof e.organization_id!=="string"||e.protocol_version!==Ve||!Array.isArray(e.roots)||!e.roots.every(H)||r&&typeof e.organization_id!=="string"||e.device_credential!==void 0)R(r?"Reason returned an invalid Device enrollment.":"Reason returned an invalid Device registration.");return{...{device_id:e.device_id,...typeof e.organization_id==="string"?{organization_id:e.organization_id}:{},protocol_version:Ve,roots:e.roots},auth_scheme:"p256"}}function Es(e){return M(e,!1)}function xs(e){let r=M(e,!0);if(typeof r.organization_id!=="string")return R("Reason returned an invalid Device enrollment.");return{...r,organization_id:r.organization_id}}function ks(e){if(!a(e)||typeof e.server_time!=="string"||typeof e.drain!=="boolean")return R("Reason returned an invalid Device heartbeat.");return{server_time:e.server_time,drain:e.drain,...U(e),...typeof e.update_policy==="string"||e.update_policy===null?{update_policy:e.update_policy}:{},...typeof e.supported_protocol_version==="number"?{supported_protocol_version:e.supported_protocol_version}:{},...ne(e.latest_cli_versions),...e.hands_prespawn===!0?{hands_prespawn:!0}:{}}}var te=["account_root_metadata_supported","workspace_root_metadata_supported","account_root_path_supported","home_contained_roots_supported","root_paths_supported","startup_supported"];function U(e){return Object.fromEntries(te.filter((r)=>e[r]===!0).map((r)=>[r,!0]))}function Cs(e){if(!a(e))return;try{return{...Io(e),...U(e)}}catch{return}}function ne(e){if(!a(e))return{};let r={};for(let i of K){let l=e[i];if(typeof l==="string"&&/^(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})$/.test(l))r[i]=l}return Object.keys(r).length>0?{latest_cli_versions:r}:{}}function As(e){if(!a(e)||!Array.isArray(e.roots)||!e.roots.every(H))return R("Reason returned an invalid Device root sync.");return{roots:e.roots}}function Ps(e){if(!a(e)||e.user_id!==void 0&&typeof e.user_id!=="string"||typeof e.organization_id!=="string"||typeof e.organization_name!=="string"||typeof e.organization_slug!=="string")return R("Reason returned an invalid Device identity.");return{...typeof e.user_id==="string"?{user_id:e.user_id}:{},organization_id:e.organization_id,organization_name:e.organization_name,organization_slug:e.organization_slug}}function Ts(e){if(!a(e)||e.disconnected!==!0)return R("Reason did not disconnect this Device.");let r=e.sessions_moved;return typeof r==="number"&&Number.isSafeInteger(r)&&r>=0?{disconnected:!0,sessions_moved:r}:{disconnected:!0}}function Rs(e){if(a(e)&&e.ok===!0&&typeof e.expires==="number")return{ok:!0,expires:e.expires};if(a(e)&&e.ok===!1&&typeof e.error==="string")return{ok:!1,error:e.error};return R("Reason did not answer the local login hand-over.")}function Os(e){if(!a(e)||e.accepted!==!0)return R("Reason did not accept the Device lifecycle event.");return{accepted:!0}}function re(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function Is(e,r=lt){if(!a(e)||typeof e.operation_id!=="string"||typeof e.attempt_id!=="string"||typeof e.attempt_token!=="string"||!/^(?:reason|ara)_attempt_/.test(e.attempt_token)||typeof e.lease_until!=="string"||typeof e.run_id!=="string"||typeof e.root_id!=="string"||e.owner!==void 0&&!P(e.owner)||!Q(e.capability,r)||!a(e.payload)||e.protocol_version!==Ve||re(e.payload)>Ce||e.authority!==void 0&&!C(e.authority)||e.local_github_authority!==void 0&&!ie.safeParse(e.local_github_authority).success||e.capability==="github.local.v1"&&!ie.safeParse(e.local_github_authority).success||e.recording_authority!==void 0&&!N(e.recording_authority)||e.capability==="browser.recording.v1"&&(!N(e.recording_authority)||!P(e.owner))||e.capability!=="browser.recording.v1"&&e.recording_authority!==void 0)return R("Reason returned an invalid Device operation claim.");let i={operation_id:e.operation_id,attempt_id:e.attempt_id,attempt_token:e.attempt_token,lease_until:e.lease_until,run_id:e.run_id,root_id:e.root_id,capability:e.capability,payload:e.payload,...C(e.authority)?{authority:e.authority}:{},...N(e.recording_authority)?{recording_authority:Object.freeze({...e.recording_authority})}:{},...e.local_github_authority!==void 0?{local_github_authority:ie.parse(e.local_github_authority)}:{},...e.capability==="hands.connect"&&a(e.environment)&&a(e.environment.payload)&&C(e.environment.authority)?{environment:{payload:e.environment.payload,authority:e.environment.authority}}:{},protocol_version:Ve};if(e.owner!==void 0)i.owner=Object.freeze({...e.owner});return i}function Ds(e){if(!a(e)||typeof e.lease_until!=="string"||!Array.isArray(e.controls)||!e.controls.every(ee)||!Number.isInteger(e.next_control_seq)||Number(e.next_control_seq)<0)return R("Reason returned an invalid Device operation heartbeat.");return{lease_until:e.lease_until,controls:e.controls,next_control_seq:Number(e.next_control_seq)}}function Ns(e){if(!a(e)||!Number.isInteger(e.next_event_seq)||Number(e.next_event_seq)<0||typeof e.duplicate!=="boolean"||!Number.isInteger(e.accepted_count)||Number(e.accepted_count)<0)return R("Reason returned an invalid Device operation event result.");return{next_event_seq:Number(e.next_event_seq),duplicate:e.duplicate,accepted_count:Number(e.accepted_count)}}function Ls(e){if(!a(e)||!a(e.payload)||!C(e.authority))return R("Reason returned an invalid Device environment delivery.");return{payload:e.payload,authority:e.authority}}function ae(e){return e==="succeeded"||e==="failed"||e==="cancelled"||e==="expired"}function Ms(e){if(!a(e)||!ae(e.status)||typeof e.idempotent!=="boolean")return R("Reason returned an invalid Device operation completion.");return{status:e.status,idempotent:e.idempotent}}
42
- export{ke,zt,Ln,ct,uo,ie,po,ho,We,lt,Ve,Ce,gs,_s,ys,Mn,bs,zr,$n,ut,Bn,Fn,jn,Un,Hn,qn,zn,Wn,Vn,Gn,Kn,Jn,Zn,Xn,Yn,Qn,pe,X,Ae,q,ei,ti,ri,Y,ni,ii,oi,si,ai,dt,ci,vs,Wt,li,Ss,Io,Es,xs,ks,Cs,As,Ps,Ts,Rs,Os,Is,Ds,Ns,Ls,Ms};
40
+ `),"utf8")}function a(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function Q(e,r){return typeof e==="string"&&r.some((i)=>i===e)}function H(e){return a(e)&&typeof e.id==="string"&&typeof e.label==="string"&&typeof e.path_fingerprint==="string"}function ee(e){return a(e)&&Number.isInteger(e.seq)&&Number(e.seq)>=0&&typeof e.kind==="string"&&/^[A-Za-z0-9._:-]{1,64}$/.test(e.kind)&&a(e.payload)}function R(e){throw Error(e)}function Cs(e,r){let i=a(e)?e:{},l=typeof i.error==="string"?i.error:`http_${r}`,g=typeof i.detail==="string"?i.detail:typeof i.message==="string"?i.message:`Reason Device request failed (${r})`;return{code:l,message:g}}function No(e){if(!a(e)||typeof e.challenge!=="string"||e.challenge.length<16||e.challenge.length>1024||e.challenge.includes(`
41
+ `)||typeof e.expires_at!=="string"||!Number.isFinite(Date.parse(e.expires_at)))R("Reason returned an invalid Device proof challenge.");return{challenge:e.challenge,expires_at:e.expires_at}}function M(e,r){if(!a(e)||typeof e.device_id!=="string"||e.auth_scheme!=="p256"||e.organization_id!==void 0&&typeof e.organization_id!=="string"||e.protocol_version!==Ge||!Array.isArray(e.roots)||!e.roots.every(H)||r&&typeof e.organization_id!=="string"||e.device_credential!==void 0)R(r?"Reason returned an invalid Device enrollment.":"Reason returned an invalid Device registration.");return{...{device_id:e.device_id,...typeof e.organization_id==="string"?{organization_id:e.organization_id}:{},protocol_version:Ge,roots:e.roots},auth_scheme:"p256"}}function As(e){return M(e,!1)}function Ps(e){let r=M(e,!0);if(typeof r.organization_id!=="string")return R("Reason returned an invalid Device enrollment.");return{...r,organization_id:r.organization_id}}function Ts(e){if(!a(e)||typeof e.server_time!=="string"||typeof e.drain!=="boolean")return R("Reason returned an invalid Device heartbeat.");return{server_time:e.server_time,drain:e.drain,...U(e),...typeof e.update_policy==="string"||e.update_policy===null?{update_policy:e.update_policy}:{},...typeof e.supported_protocol_version==="number"?{supported_protocol_version:e.supported_protocol_version}:{},...ne(e.latest_cli_versions),...e.hands_prespawn===!0?{hands_prespawn:!0}:{}}}var te=["account_root_metadata_supported","workspace_root_metadata_supported","account_root_path_supported","home_contained_roots_supported","root_paths_supported","startup_supported"];function U(e){return Object.fromEntries(te.filter((r)=>e[r]===!0).map((r)=>[r,!0]))}function Rs(e){if(!a(e))return;try{return{...No(e),...U(e)}}catch{return}}function ne(e){if(!a(e))return{};let r={};for(let i of K){let l=e[i];if(typeof l==="string"&&/^(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})$/.test(l))r[i]=l}return Object.keys(r).length>0?{latest_cli_versions:r}:{}}function Os(e){if(!a(e)||!Array.isArray(e.roots)||!e.roots.every(H))return R("Reason returned an invalid Device root sync.");return{roots:e.roots}}function Is(e){if(!a(e)||e.user_id!==void 0&&typeof e.user_id!=="string"||typeof e.organization_id!=="string"||typeof e.organization_name!=="string"||typeof e.organization_slug!=="string")return R("Reason returned an invalid Device identity.");return{...typeof e.user_id==="string"?{user_id:e.user_id}:{},organization_id:e.organization_id,organization_name:e.organization_name,organization_slug:e.organization_slug}}function Ds(e){if(!a(e)||e.disconnected!==!0)return R("Reason did not disconnect this Device.");let r=e.sessions_moved;return typeof r==="number"&&Number.isSafeInteger(r)&&r>=0?{disconnected:!0,sessions_moved:r}:{disconnected:!0}}function Ns(e){if(a(e)&&e.ok===!0&&typeof e.expires==="number")return{ok:!0,expires:e.expires};if(a(e)&&e.ok===!1&&typeof e.error==="string")return{ok:!1,error:e.error};return R("Reason did not answer the local login hand-over.")}function Ls(e){if(!a(e)||e.accepted!==!0)return R("Reason did not accept the Device lifecycle event.");return{accepted:!0}}function re(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function Ms(e,r=ut){if(!a(e)||typeof e.operation_id!=="string"||typeof e.attempt_id!=="string"||typeof e.attempt_token!=="string"||!/^(?:reason|ara)_attempt_/.test(e.attempt_token)||typeof e.lease_until!=="string"||typeof e.run_id!=="string"||typeof e.root_id!=="string"||e.owner!==void 0&&!P(e.owner)||!Q(e.capability,r)||!a(e.payload)||e.protocol_version!==Ge||re(e.payload)>Ce||e.authority!==void 0&&!C(e.authority)||e.local_github_authority!==void 0&&!ie.safeParse(e.local_github_authority).success||e.capability==="github.local.v1"&&!ie.safeParse(e.local_github_authority).success||e.recording_authority!==void 0&&!v(e.recording_authority)||e.capability==="browser.recording.v1"&&(!v(e.recording_authority)||!P(e.owner))||e.capability!=="browser.recording.v1"&&e.recording_authority!==void 0)return R("Reason returned an invalid Device operation claim.");let i={operation_id:e.operation_id,attempt_id:e.attempt_id,attempt_token:e.attempt_token,lease_until:e.lease_until,run_id:e.run_id,root_id:e.root_id,capability:e.capability,payload:e.payload,...C(e.authority)?{authority:e.authority}:{},...v(e.recording_authority)?{recording_authority:Object.freeze({...e.recording_authority})}:{},...e.local_github_authority!==void 0?{local_github_authority:ie.parse(e.local_github_authority)}:{},...e.capability==="hands.connect"&&a(e.environment)&&a(e.environment.payload)&&C(e.environment.authority)?{environment:{payload:e.environment.payload,authority:e.environment.authority}}:{},protocol_version:Ge};if(e.owner!==void 0)i.owner=Object.freeze({...e.owner});return i}function $s(e){if(!a(e)||typeof e.lease_until!=="string"||!Array.isArray(e.controls)||!e.controls.every(ee)||!Number.isInteger(e.next_control_seq)||Number(e.next_control_seq)<0)return R("Reason returned an invalid Device operation heartbeat.");return{lease_until:e.lease_until,controls:e.controls,next_control_seq:Number(e.next_control_seq)}}function Bs(e){if(!a(e)||!Number.isInteger(e.next_event_seq)||Number(e.next_event_seq)<0||typeof e.duplicate!=="boolean"||!Number.isInteger(e.accepted_count)||Number(e.accepted_count)<0)return R("Reason returned an invalid Device operation event result.");return{next_event_seq:Number(e.next_event_seq),duplicate:e.duplicate,accepted_count:Number(e.accepted_count)}}function Fs(e){if(!a(e)||!a(e.payload)||!C(e.authority))return R("Reason returned an invalid Device environment delivery.");return{payload:e.payload,authority:e.authority}}function ae(e){return e==="succeeded"||e==="failed"||e==="cancelled"||e==="expired"}function js(e){if(!a(e)||!ae(e.status)||typeof e.idempotent!=="boolean")return R("Reason returned an invalid Device operation completion.");return{status:e.status,idempotent:e.idempotent}}
42
+ export{ke,Vt,$n,lt,ho,ie,fo,mo,Ve,ut,Ge,Ce,vs,Ss,Es,Bn,xs,Vr,Fn,dt,Ae,pt,jn,Un,Hn,qn,zn,Wn,Vn,Gn,Kn,Jn,Zn,Xn,Yn,Qn,ei,ti,pe,X,Pe,q,ri,ni,ii,Y,oi,si,ai,ci,li,ht,ui,ks,Gt,di,Cs,No,As,Ps,Ts,Rs,Os,Is,Ds,Ns,Ls,Ms,$s,Bs,Fs,js};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- var Kt=String.raw`(function(require) {
2
+ var Zt=String.raw`(function(require) {
3
3
  if (process.platform !== "win32") return null;
4
4
  let ffi, kernel32;
5
5
  try {
@@ -64,4 +64,4 @@ var Kt=String.raw`(function(require) {
64
64
  },
65
65
  };
66
66
  })`;
67
- export{Kt};
67
+ export{Zt};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Me,$i,F,Ye,xt,gr,P,V,$e}from"./vm-hands-entry-lite-e5hbehqn.js";import{G}from"./vm-hands-entry-lite-v3xznxcw.js";import{ot}from"./vm-hands-entry-lite-8evzzh7v.js";import{st}from"./vm-hands-entry-lite-wf7ksh4e.js";import{Mr}from"./vm-hands-entry-lite-762fbns7.js";import{ft,mi}from"./vm-hands-entry-lite-8gtgr399.js";import{be,xn}from"./vm-hands-entry-lite-hee1h411.js";import{dt}from"./vm-hands-entry-lite-ym1djztp.js";import{a}from"./vm-hands-entry-lite-dkcm3hyn.js";import{x}from"./vm-hands-entry-lite-zg3b0c08.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{spawn as R,spawnSync as tt}from"child_process";import{createHash as rt,randomUUID as me}from"crypto";import{closeSync as nt,copyFileSync as se,existsSync as M,fstatSync as it,mkdirSync as ie,openSync as at,readdirSync as U,readFileSync as K,readlinkSync as ct,renameSync as fe,rmSync as lt,statSync as ut,writeFileSync as pt}from"fs";import{connect as mt}from"net";import{tmpdir as L,userInfo as ge}from"os";import{basename as ae,delimiter as gt,dirname as B,join as f}from"path";var Y=`import { spawn, execFileSync } from "node:child_process";
2
+ import{$e,Fi,F,Qe,Ct,yr,P,V,Be}from"./vm-hands-entry-lite-ydg5av4g.js";import{G}from"./vm-hands-entry-lite-f5e3dbgk.js";import{st}from"./vm-hands-entry-lite-eqgj4acy.js";import{at}from"./vm-hands-entry-lite-1xtpeh3x.js";import{Br}from"./vm-hands-entry-lite-rhhqbwmr.js";import{gt,_i}from"./vm-hands-entry-lite-gvwdy3rf.js";import{be,Cn}from"./vm-hands-entry-lite-t07pdqxb.js";import{ht}from"./vm-hands-entry-lite-k278g9kj.js";import{a}from"./vm-hands-entry-lite-89z488gz.js";import{x}from"./vm-hands-entry-lite-9ay6f56v.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{spawn as R,spawnSync as tt}from"child_process";import{createHash as ot,randomUUID as me}from"crypto";import{closeSync as rt,copyFileSync as se,existsSync as M,fstatSync as nt,mkdirSync as ie,openSync as it,readdirSync as U,readFileSync as K,readlinkSync as ct,renameSync as fe,rmSync as lt,statSync as ut,writeFileSync as dt}from"fs";import{connect as pt}from"net";import{tmpdir as L,userInfo as ge}from"os";import{basename as ae,delimiter as mt,dirname as B,join as f}from"path";var Y=`import { spawn, execFileSync } from "node:child_process";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import { readFileSync, readlinkSync, lstatSync, realpathSync, statSync, mkdtempSync, mkdirSync, chmodSync, writeFileSync, readdirSync, rmSync, openSync, readSync, closeSync, renameSync } from "node:fs";
5
5
  import { tmpdir } from "node:os";
@@ -849,7 +849,7 @@ if(process.env.REASON_CLOUD_GATEWAY_EXEC === "1") {
849
849
  process.stdout.write(JSON.stringify(cloudAutomationFailure(error))+"\\n");process.exitCode=1;
850
850
  }
851
851
  }
852
- `;import{spawn as Ee}from"child_process";import{basename as Ce}from"path";var Te="__desktop-call",Ne="/usr/bin/setpriv",Pe=27262976,De=8192,Ue=2000;function q(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function Le(e){try{return JSON.parse(e)}catch{return null}}function Be(){return[process.execPath,...Ce(process.execPath).startsWith("bun")&&process.argv[1]?[process.argv[1]]:[],Te]}function Et(e,o,t,n={}){t.throwIfAborted();let s=n.command??Be();return new Promise((i,u)=>{let c=(n.spawnProcess??Ee)(Ne,[`--reuid=${e.uid}`,`--regid=${e.gid}`,"--clear-groups","--no-new-privs","--",...s],{cwd:e.home,detached:!0,stdio:["pipe","pipe","pipe"],env:{HOME:e.home,USER:e.username,LOGNAME:e.username,PATH:"/usr/local/bin:/usr/bin:/bin"}}),d=[],m=0,l="",p=null,g=!1,h,y=(_)=>{try{process.kill(-c.pid,_)}catch{c.kill(_)}},I=(_)=>{p??=_,y("SIGTERM"),h??=setTimeout(()=>y("SIGKILL"),Ue)},S=()=>I(new r("cancelled","Reason cancelled the desktop operation."));t.addEventListener("abort",S,{once:!0});let w=(_)=>{if(g)return;g=!0,clearTimeout(h),t.removeEventListener("abort",S),_()};if(c.stdout.on("data",(_)=>{if(m+=_.byteLength,m>Pe)I(new r("desktop_delegate_failed","Reason's desktop reply is too large."));else d.push(_)}),c.stderr.setEncoding("utf8").on("data",(_)=>{l=(l+_).slice(-De)}),c.stdin.on("error",()=>{}),c.once("error",()=>w(()=>u(p??new r("desktop_delegate_unavailable","Reason could not start its desktop as the desktop account.")))),c.once("close",(_,Oe)=>w(()=>{if(p)return u(p);let b=Le(Buffer.concat(d).toString("utf8"));if(q(b)&&b.ok===!0&&q(b.result))return i(b.result);let O=q(b)&&b.ok===!1&&typeof b.code==="string"&&typeof b.message==="string"?new r(b.code.slice(0,120),b.message.slice(0,2000)):null,X=`exited ${_??Oe}${O?"":" with no reply"}`,J=l.trim().split(`
852
+ `;import{spawn as Ee}from"child_process";import{basename as Ce}from"path";var Te="__desktop-call",Ne="/usr/bin/setpriv",Pe=27262976,De=8192,Me=2000;function q(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function Ue(e){try{return JSON.parse(e)}catch{return null}}function Le(){return[process.execPath,...Ce(process.execPath).startsWith("bun")&&process.argv[1]?[process.argv[1]]:[],Te]}function kt(e,o,t,n={}){t.throwIfAborted();let s=n.command??Le();return new Promise((i,u)=>{let c=(n.spawnProcess??Ee)(Ne,[`--reuid=${e.uid}`,`--regid=${e.gid}`,"--clear-groups","--no-new-privs","--",...s],{cwd:e.home,detached:!0,stdio:["pipe","pipe","pipe"],env:{HOME:e.home,USER:e.username,LOGNAME:e.username,PATH:"/usr/local/bin:/usr/bin:/bin"}}),d=[],m=0,l="",p=null,g=!1,h,y=(_)=>{try{process.kill(-c.pid,_)}catch{c.kill(_)}},I=(_)=>{p??=_,y("SIGTERM"),h??=setTimeout(()=>y("SIGKILL"),Me)},S=()=>I(new r("cancelled","Reason cancelled the desktop operation."));t.addEventListener("abort",S,{once:!0});let w=(_)=>{if(g)return;g=!0,clearTimeout(h),t.removeEventListener("abort",S),_()};if(c.stdout.on("data",(_)=>{if(m+=_.byteLength,m>Pe)I(new r("desktop_delegate_failed","Reason's desktop reply is too large."));else d.push(_)}),c.stderr.setEncoding("utf8").on("data",(_)=>{l=(l+_).slice(-De)}),c.stdin.on("error",()=>{}),c.once("error",()=>w(()=>u(p??new r("desktop_delegate_unavailable","Reason could not start its desktop as the desktop account.")))),c.once("close",(_,Oe)=>w(()=>{if(p)return u(p);let b=Ue(Buffer.concat(d).toString("utf8"));if(q(b)&&b.ok===!0&&q(b.result))return i(b.result);let O=q(b)&&b.ok===!1&&typeof b.code==="string"&&typeof b.message==="string"?new r(b.code.slice(0,120),b.message.slice(0,2000)):null,X=`exited ${_??Oe}${O?"":" with no reply"}`,J=l.trim().split(`
853
853
  `).at(-1)?.slice(-300)??"";if(!O||O.code==="desktop_delegate_failed")process.stderr.write(`Reason worker: desktop call ${X}${l?`: ${l.trim().slice(-500)}`:""}
854
- `);if(O)return u(O);u(new r("desktop_delegate_failed",`Reason's desktop operation failed (${X}${J?`: ${J}`:""}).`))})),t.aborted)S();c.stdin.end(JSON.stringify(o))})}async function z(e,o,t,n={}){let s=await Et(e,{op:"automation",call:o},t,n);if(!Number.isSafeInteger(s.code)||typeof s.stdout!=="string"||typeof s.stderr!=="string")throw new r("desktop_delegate_failed","Reason's desktop reply is malformed.");return{code:s.code,stdout:Buffer.from(s.stdout,"base64"),stderr:s.stderr}}import{execFile as qe,spawn as We}from"child_process";import{closeSync as Fe,mkdirSync as Ge,openSync as He}from"fs";import{dirname as E,join as je}from"path";import{promisify as Ke}from"util";var Xe=Ke(qe),Z="x-apple.systempreferences:com.apple.preference.security",Je={accessibility:`${Z}?Privacy_Accessibility`,screen:`${Z}?Privacy_ScreenCapture`},ze=64,A=new Map;function C(e,o){let t=A.get(e);if(t?.has(o))return!1;if(!t){if(A.size>=ze)A.delete(A.keys().next().value);t=new Set,A.set(e,t)}return t.add(o),!0}function Ve(){let e=a(),o=xn(be(e),process.env),t=je(e,".local","share","reason","desktop-install.log");Ge(E(t),{recursive:!0,mode:448});let n=He(t,"a",384);try{let s=We(o,["desktop","install"],{detached:!0,stdio:["ignore",n,n],env:{...process.env,REASON_DESKTOP_BACKGROUND:"1"}});s.on("error",()=>{return}),s.unref()}finally{Fe(n)}}var T={open:async(e,o)=>{await Xe("/usr/bin/open",e,{signal:o,timeout:1e4,maxBuffer:8192})},request:(e,o)=>ot(e,o),tile:Mr,installDesktop:Ve},Q=!1;async function ee(e,o,t){try{await o.open(["-a","Google Chrome",e],t)}catch{t.throwIfAborted(),await o.open([e],t)}}async function oe(e,o,t,n){if(await t.open([Je[o]],n).catch(()=>{}),e[0]&&!n.aborted)t.tile(E(E(E(e[0]))),o)}async function Ze(e,o,t,n,s){for(let i of t){if(!C(e,`grant:${i}`))continue;s.throwIfAborted(),await n.request(o,i).catch(()=>null),await oe(o,i,n,s)}}var Qe={name:"open_tab",description:"Open a web page in the user's own Chrome on this Mac. Reason cannot read, screenshot or click in that tab, and no tab_id is returned: browser control needs Reason's Chrome extension. An actual browser call opens its setup page.",inputSchema:{type:"object",properties:{url:{type:"string",description:"An http or https URL."}},required:["url"],additionalProperties:!1}};function te(e){return{code:0,stderr:"",stdout:Buffer.from(JSON.stringify({ok:!0,...e}))}}function et(e){if(typeof e!=="string")return null;try{let o=new URL(e);return o.protocol==="https:"||o.protocol==="http:"?o.href:null}catch{return null}}async function re(e,o=T){let{call:t,runId:n,signal:s}=e;if(t.kind==="browser"){if(t.operation==="discover")return te({result:{tools:[Qe]}});if(t.operation!=="call")throw new r("automation_browser_setup_required","Browser control is not set up on this Mac yet. Request a browser operation or connect Chrome from Reason to set it up.")}if(e.desktopMissing&&!Q){Q=!0;try{o.installDesktop()}catch{}}if(t.kind==="computer"){if(e.identity.length>0&&C(n,"grant:probe")){let c=await o.request(e.identity).catch(()=>null),d=c?[...c.accessibility?[]:["accessibility"],...c.screen?[]:["screen"]]:[];for(let m of d)C(n,`grant:${m}`);for(let m of d)await oe(e.identity,m,o,s)}throw new r("automation_computer_setup_required","Computer use is not set up on this Mac yet; Reason asked macOS for any missing permission.")}if(C(n,"page:chrome-extension"))await ee($i,o,s).catch(()=>{});let i=t.arguments,u=t.operation==="call"&&t.tool==="open_tab"&&i&&typeof i==="object"&&!Array.isArray(i)?et(i.url):null;if(!u)throw new r("automation_browser_setup_required","Browser control is not set up on this Mac yet; Reason opened its Chrome Web Store page. open_tab still opens pages.");return await ee(u,o,s),te({result:{content:[{type:"text",text:JSON.stringify({opened:u,browser:"the user's Chrome",controllable:!1,note:"Opened for the user to see. Reason cannot read or act in this tab until Reason's Chrome extension is added (its Chrome Web Store page is open)."})}]}})}async function ne(e,o=T){if(e.call.kind!=="computer"||e.call.operation!=="permission_status"||e.output.code!==0||e.identity.length===0)return e.output;let t;try{t=JSON.parse(e.output.stdout.toString("utf8"))}catch{return e.output}if(!t||typeof t!=="object"||Array.isArray(t))return e.output;let n=t.permissions;if(!n||typeof n!=="object")return e.output;let s=n,i=[...s.accessibility==="missing"?["accessibility"]:[],...s.screenRecording==="missing"?["screen"]:[]];if(i.length===0)return e.output;return await Ze(e.runId,e.identity,i,o,e.signal),{...e.output,stdout:Buffer.from(JSON.stringify({...t,requested:i}))}}var j=172032,ht=18874368,wt=8192,_t=65536,yt=55000,bt=60000,St=4,kt=40000,Rt=/^[0-9a-f-]{36}$/,ce=Y,It=me();function N(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function D(){throw new r("invalid_automation_request","Reason automation request is malformed.")}function he(e){let o=Object.keys(e).sort().join(",");if(o==="call"||o==="browser,call"){let t=e.call,n=o==="browser,call";if(!N(t)||t.version!==1||t.kind!=="computer"&&t.kind!=="browser"||n&&(e.browser!==dt||t.kind!=="browser")||JSON.stringify(t).length>_t)D();return{call:t,userChrome:n}}if(o==="offset,output_id"){if(typeof e.output_id!=="string"||!Rt.test(e.output_id)||!Number.isSafeInteger(e.offset)||e.offset<0)D();return{output_id:e.output_id,offset:e.offset}}return D()}function hn(e=process.platform,o=P){if(e==="darwin")return!0;return(e==="linux"||e==="win32")&&o()?.features.computer===!0}var vt="__computer-use";function rs(e=P){return e()?.userChrome??{code:"user_chrome_browser_use_missing"}}function we(e,o,t,n){return new Promise((s)=>{let i=R(e,o,{env:t,stdio:"ignore",windowsHide:!0}),u=setTimeout(()=>{i.kill("SIGKILL"),s(-1)},n);i.once("error",()=>{clearTimeout(u),s(-1)}),i.once("exit",(c)=>{clearTimeout(u),s(c??-1)})})}function Ot(e,o,t,n){return new Promise((s)=>{let i=R(e,o,{env:t,stdio:["ignore","pipe","ignore"],windowsHide:!0}),u="";i.stdout.setEncoding("utf8").on("data",(d)=>{u+=d});let c=setTimeout(()=>{i.kill("SIGKILL"),s(null)},n);i.once("error",()=>{clearTimeout(c),s(null)}),i.once("close",(d)=>{clearTimeout(c),s(d===0?u:null)})})}function At(e){return v(e)?f(L(),"open-browser-use"):"/tmp/open-browser-use"}function v(e){return e.platform==="win32-x64"||e.platform==="win32-arm64"}var Ct=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,Tt=33554432;function Nt(e,o){let t;try{t=e===null?null:JSON.parse(e)}catch{return null}let n=N(t)&&N(t.result)?t.result.metadata:null;if(!N(n)||n.extensionId!==o)return null;return typeof n.extensionInstanceId==="string"&&Ct.test(n.extensionInstanceId)?n.extensionInstanceId:null}async function _e(e,o,t){let n=t.storages.map((c)=>{try{return U(c).filter((d)=>d.endsWith(".log")||d.endsWith(".ldb")).map((d)=>f(c,d))}catch{return[]}}),s;try{s=n.some((c)=>c.length>0)?U(t.socketDir).filter((c)=>c.endsWith(".sock")):[]}catch{return[]}let i=[];for(let c of s){let d=f(t.socketDir,c),m=Nt(await Ot(e,["info","--socket",d,"--timeout","2s"],o,5000),t.extensionId);if(m)i.push({instance:m,socket:d})}let u=[];for(let[c,d]of(i.length>0?n:[]).entries())for(let m of d)try{if(ut(m).size>Tt)continue;let l=K(m),p=i.find((g)=>l.includes(g.instance));if(p){u.push({storage:t.storages[c],...p});break}}catch{}return u}async function Pt(e,o,t){return(await _e(e,o,t))[0]?.instance??null}function ye(e,o,t){return Pt(e.nativeHost,o,{socketDir:At(e),extensionId:F,storages:[f(t,"browser-profile","Default","Local Extension Settings",F)]})}var le=/^(Default|Profile ([0-9]+))$/;async function Dt(e,o,t=a(),n=xt){let s=f(t,"Library","Application Support","Google","Chrome"),i=[];try{i=U(s)}catch(l){if(l.code==="EPERM")throw new r("browser_use_chrome_access_denied","macOS blocked Reason from reading Chrome's profiles. Allow Full Disk Access for Reason on this Mac and try again.")}let u=(l)=>Number(le.exec(l)?.[2]??-1),c=i.filter((l)=>le.test(l)&&M(f(s,l,"Extensions",Me))).sort((l,p)=>u(l)-u(p)),d=(l)=>f(s,l,"Local Extension Settings",Me);return(await _e(e,o,{socketDir:n,extensionId:Me,storages:c.map(d)})).map(({storage:l,instance:p,socket:g})=>({profile:c.find((h)=>d(h)===l),instance:p,socket:g}))}async function Mt(e,o,t=a(),n=xt){let s=(await Dt(e,o,t,n))[0]?.instance;if(!s)throw new r("automation_user_chrome_not_connected","No Chrome profile on this Mac is connected to Reason. Open Chrome with the Reason extension, then try again.");return s}function ue(e){return new Promise((o)=>{let t=mt({path:e}),n=(s)=>{t.destroy(),o(s)};t.setTimeout(1000,()=>n(!1)),t.once("error",()=>n(!1)),t.once("connect",()=>n(!0))})}async function Se(e,o){let t=Date.now()+o;while(Date.now()<t){if(await e())return!0;await new Promise((n)=>setTimeout(n,200))}return!1}var W=new Map;function H(e,o){let t=W.get(e);if(!t)t=o().finally(()=>W.delete(e)),W.set(e,t);return t}async function Ut(e,o){if(await ue(e))return;if(lt(e,{force:!0}),await we("dbus-daemon",["--session",`--address=unix:path=${e}`,"--fork"],o,1e4)!==0||!await Se(()=>ue(e),5000))throw new r("automation_unavailable","Reason could not start the desktop session bus.")}async function de(e,o,t){let n=e.platform==="darwin-arm64"||v(e)?async()=>await ye(e,o,t)!==null:async()=>await we(e.nativeHost,["info"],o,5000)===0;if(await n())return;let s=["--profile-directory=Default",`--load-extension=${e.extensionDir}`,"--no-first-run","--no-default-browser-check","--window-size=1280,800","about:blank"],i,u=null,c=0;if(e.platform==="darwin-arm64"){let l=f(t,"browser-profile");V(l);let p=f(l,"NativeMessagingHosts");ie(p,{recursive:!0,mode:448});let g=gr(e.platform).nativeHostManifests[0];se(g,f(p,ae(g)));let h=e.browser.slice(0,e.browser.indexOf(".app/")+4),y=s.filter((I)=>I!=="about:blank").concat("--no-startup-window","--use-mock-keychain");i=R("/usr/bin/open",["-g","-n","-a",h,"--args",`--user-data-dir=${l}`,...y],{env:o,stdio:"ignore"})}else if(v(e)){let l=f(t,"browser-profile");V(l),tt(x("icacls"),[B(e.browser),"/grant","*S-1-15-2-1:(OI)(CI)(RX)","*S-1-15-2-2:(OI)(CI)(RX)"],{stdio:"ignore",windowsHide:!0,timeout:60000});let p=s.filter((g)=>g!=="about:blank").concat("--no-startup-window","--keep-alive-for-test");i=R(e.browser,[`--user-data-dir=${l}`,...p],{detached:!0,stdio:"ignore",env:o})}else{let l=f(o.HOME,".config","google-chrome"),p=f(l,"NativeMessagingHosts");ie(p,{recursive:!0,mode:448});let g=gr(e.platform).nativeHostManifests[0];se(g,f(p,ae(g)));let h=process.geteuid?.()===0?["--no-sandbox"]:[];u=f(t,"browser.log");let y=at(u,"a",384);c=it(y).size,i=R(e.browser,[`--user-data-dir=${l}`,...s,...h,"--force-renderer-accessibility"],{detached:!0,stdio:["ignore",y,y],env:{...o,ACCESSIBILITY_ENABLED:"1"}}),nt(y)}let d=!1;i.once("error",()=>{d=!0}),i.once("exit",(l)=>{d||=l!==0}),i.unref();let m=!1;if(await Se(async()=>d||(m=await n()),kt),!m){if(u&&K(u).subarray(c).toString("utf8").includes("No usable sandbox"))throw new r("automation_browser_sandbox_unavailable","Chromium found no usable sandbox on this machine. Run the worker as a non-root user with unprivileged user namespaces enabled, or in a container with seccomp unconfined.");throw new r("automation_browser_unavailable","Reason could not connect the desktop browser.")}}async function ns(e){await Re(e,!0)}function is(e){return xe(e,ke(e))}function xe(e,o){return e.platform==="darwin-arm64"||v(e)?f(o,"browser-profile"):f(o,"home",".config","google-chrome")}function ke(e){let o=f(e.root,"automation");if(!M(o)||!Lt(e.automation))return e.automation;if(!$t(xe(e,o)))try{fe(o,e.automation)}catch{}return M(o)?o:e.automation}function Lt(e){try{return U(e).length===0}catch(o){return o.code==="ENOENT"}}function $t(e){let o;try{o=ct(f(e,"SingletonLock"))}catch{return!1}let t=Number(o.slice(o.lastIndexOf("-")+1));if(!Number.isSafeInteger(t)||t<=0)return!0;try{return process.kill(t,0),!0}catch(n){return n.code==="EPERM"}}async function Re(e,o){ft({root:e.root,automation:e.automation,extensionDir:e.extensionDir});let t=ke(e);V(t);let n=ge().username,s={USER:n,LOGNAME:n,REASON_AUTOMATION_OCU:e.ocu,REASON_AUTOMATION_OBU:e.nativeHost};if(e.platform==="darwin-arm64"||v(e)){let l=v(e)?{...s,...Bt(),HOME:a()}:{...s,HOME:a(),PATH:`${B(e.node)}:/usr/bin:/bin:/usr/sbin:/sbin`,REASON_AUTOMATION_OCU:process.execPath,REASON_AUTOMATION_OCU_SUBCOMMAND:vt};if(!o)return l;await H("browser",()=>de(e,l,t));let p=await ye(e,l,t);if(!p)throw new r("automation_browser_unavailable","Reason could not connect the desktop browser.");return{...l,REASON_AUTOMATION_OBU_INSTANCE:p,REASON_AUTOMATION_BACKGROUND_TABS:"1"}}let i=await $e(),u=f(t,"home"),c=f(t,"runtime");V(u),V(c);let d=f(t,"bus"),m={...s,HOME:u,PATH:`${B(e.node)}:/usr/bin:/bin`,DISPLAY:i.display,XAUTHORITY:i.xauthority,XDG_RUNTIME_DIR:c,DBUS_SESSION_BUS_ADDRESS:`unix:path=${d}`,...i.sound?{PULSE_SERVER:Ye(i.sound)}:{}};if(await H("bus",()=>Ut(d,m)),o)await H("browser",()=>de(e,m,t));return m}function Bt(){let e=process.env.SystemRoot??"C:\\Windows",o=Object.fromEntries(["SystemDrive","USERPROFILE","LOCALAPPDATA","APPDATA","ProgramData","ProgramFiles","PATHEXT","ComSpec","USERNAME","USERDOMAIN","COMPUTERNAME","NUMBER_OF_PROCESSORS","PROCESSOR_ARCHITECTURE","PSModuleAnalysisCachePath"].flatMap((n)=>process.env[n]?[[n,process.env[n]]]:[])),t=f(e,"System32");return{...o,SystemRoot:e,windir:e,TEMP:L(),TMP:L(),PATH:[t,f(t,"WindowsPowerShell","v1.0"),e].join(gt)}}async function qt(e,o,t){let n=ge().username,s={USER:n,LOGNAME:n,HOME:a(),PATH:`${B(e.node)}:/usr/bin:/bin:/usr/sbin:/sbin`,REASON_AUTOMATION_OBU:o,REASON_AUTOMATION_BACKGROUND_TABS:"1"},i=await Mt(o,s);return t.throwIfAborted(),{...s,REASON_AUTOMATION_OBU_INSTANCE:i}}function Wt(e){if(process.platform!=="win32")return["--input-type=module","--eval",e];let o=f(L(),`reason-automation-${rt("sha256").update(e).digest("hex").slice(0,16)}.mjs`);if(!M(o)||K(o,"utf8")!==e){let t=`${o}.${process.pid}.tmp`;pt(t,e,{mode:384}),fe(t,o)}return[o]}function Ie(e,o,t,n){if(typeof ce!=="string")return Promise.reject(new r("automation_unavailable","This Reason build has no automation runtime."));let s=ce;return new Promise((i,u)=>{let c=R(e,Wt(s),{env:{...o,REASON_CLOUD_GATEWAY_EXEC:"1",REASON_AUTOMATION_INLINE_RESULT:"1"},stdio:["pipe","pipe","pipe"],detached:process.platform!=="win32",windowsHide:!0}),d=[],m=0,l="",p=null,g=!1,h=(w)=>{if(p??=w,process.platform==="win32"&&c.pid){R(f(process.env.SystemRoot??"C:\\Windows","System32","taskkill.exe"),["/pid",String(c.pid),"/t","/f"],{stdio:"ignore",windowsHide:!0}).once("error",()=>c.kill("SIGKILL"));return}try{process.kill(-c.pid,"SIGKILL")}catch{c.kill("SIGKILL")}},y=(w)=>{if(g)return;g=!0,clearTimeout(I),n.removeEventListener("abort",S),w()},I=setTimeout(()=>h(new r("automation_timed_out","Reason automation did not finish in time.")),yt),S=()=>h(new r("cancelled","Reason cancelled the automation call."));if(n.addEventListener("abort",S,{once:!0}),c.stdout.on("data",(w)=>{if(m+=w.byteLength,m>ht)h(new r("automation_output_too_large","Reason automation output is too large."));else d.push(w)}),c.stderr.setEncoding("utf8").on("data",(w)=>{l=(l+w).slice(-wt)}),c.stdin.on("error",()=>{}),c.once("error",()=>y(()=>u(p??new r("automation_unavailable","Reason could not start the automation runtime.")))),c.once("close",(w)=>y(()=>{if(p)u(p);else i({code:w??1,stdout:Buffer.concat(d),stderr:l})})),n.aborted)S();c.stdin.end(t)})}var k=new Map;function Ft(e,o,t){for(let[s,i]of k)if(i.expiresAt<=t)k.delete(s);while(k.size>=St)k.delete(k.keys().next().value);let n=me();return k.set(n,{runId:e,bytes:o,expiresAt:t+bt}),n}async function ve(e,o,t,n={}){let s=await(n.environment??Re)(e,o.kind==="browser");return t.throwIfAborted(),await(n.runtime??Ie)(e.node,s,JSON.stringify(o),t)}async function os(e,o){let t=he({call:e});if(!("call"in t))D();let n=P();if(!n?.features.computer||t.call.kind==="browser"&&!n.features.browser)throw new r("automation_unavailable","Run `reason desktop install` on this machine to enable computer and browser use.");return await ve(n,t.call,o)}function pe(e,o,t){let n=e.stdout.byteLength>j?Ft(o,e.stdout,t):void 0;return{code:e.code,stderr:e.stderr,instance_id:It,output_bytes:e.stdout.byteLength,chunk:e.stdout.subarray(0,j).toString("base64"),...n?{output_id:n}:{}}}async function fn(e,o={}){let t=he(e.payload),n=(o.now??Date.now)();if("output_id"in t){let h=k.get(t.output_id);if(!h||h.runId!==e.runId||h.expiresAt<=n||t.offset>h.bytes.byteLength)throw new r("automation_output_unavailable","Reason automation output expired.");return{chunk:h.bytes.subarray(t.offset,t.offset+j).toString("base64")}}let s=(o.components??P)(),i=(o.platform??process.platform)==="darwin",u=i?(o.macIdentity??st)():[],c=o.macSetup??T,d=!s?.features.computer||t.call.kind==="browser"&&!t.userChrome&&!s.features.browser;if(i&&(d||u.length===0||t.call.kind==="browser"&&t.userChrome&&!e.userChrome))return pe(await re({runId:e.runId,call:t.call,identity:u,desktopMissing:d,signal:e.signal},c),e.runId,n);if(!s?.features.computer)throw new r("automation_unavailable","Run `reason desktop install` on this machine to enable computer and browser use.");let m=t.userChrome?e.userChrome:void 0;if(t.userChrome&&!m)throw new r("automation_user_chrome_unavailable","Your own Chrome is not enabled on this computer: run `reason desktop install` on this Mac (and `reason connect --user-chrome on` if you turned it off).");if(t.call.kind==="browser"&&!m&&!s.features.browser)throw new r("automation_browser_not_installed",!s.platform.startsWith("linux")?"Browser use is unavailable on this machine: re-run `reason desktop install`.":"Browser use is unavailable on this machine: install a non-snap Chromium at /usr/bin/chromium, then re-run `reason desktop install`.");e.signal.throwIfAborted();let l=await mi(e.runId,e.signal,o.now),p="account"in o?o.account??null:G(),g;try{if(m){let h=await(o.userChromeEnvironment??qt)(s,m,e.signal);e.signal.throwIfAborted(),g=await(o.runtime??Ie)(s.node,h,JSON.stringify(t.call),e.signal)}else if(p)g=await(o.delegate??z)(p,t.call,e.signal);else g=await ve(s,t.call,e.signal,o)}finally{l()}if(i)g=await ne({runId:e.runId,call:t.call,identity:u,output:g,signal:e.signal},c);return pe(g,e.runId,n)}
855
- export{Et,hn,rs,ns,is,os,fn};
854
+ `);if(O)return u(O);u(new r("desktop_delegate_failed",`Reason's desktop operation failed (${X}${J?`: ${J}`:""}).`))})),t.aborted)S();c.stdin.end(JSON.stringify(o))})}async function z(e,o,t,n={}){let s=await kt(e,{op:"automation",call:o},t,n);if(!Number.isSafeInteger(s.code)||typeof s.stdout!=="string"||typeof s.stderr!=="string")throw new r("desktop_delegate_failed","Reason's desktop reply is malformed.");return{code:s.code,stdout:Buffer.from(s.stdout,"base64"),stderr:s.stderr}}import{execFile as qe,spawn as We}from"child_process";import{closeSync as Fe,mkdirSync as Ge,openSync as He}from"fs";import{dirname as E,join as je}from"path";import{promisify as Ke}from"util";var Xe=Ke(qe),Z="x-apple.systempreferences:com.apple.preference.security",Je={accessibility:`${Z}?Privacy_Accessibility`,screen:`${Z}?Privacy_ScreenCapture`},Ye=64,A=new Map;function C(e,o){let t=A.get(e);if(t?.has(o))return!1;if(!t){if(A.size>=Ye)A.delete(A.keys().next().value);t=new Set,A.set(e,t)}return t.add(o),!0}function ze(){let e=a(),o=Cn(be(e),process.env),t=je(e,".local","share","reason","desktop-install.log");Ge(E(t),{recursive:!0,mode:448});let n=He(t,"a",384);try{let s=We(o,["desktop","install"],{detached:!0,stdio:["ignore",n,n],env:{...process.env,REASON_DESKTOP_BACKGROUND:"1"}});s.on("error",()=>{return}),s.unref()}finally{Fe(n)}}var T={open:async(e,o)=>{await Xe("/usr/bin/open",e,{signal:o,timeout:1e4,maxBuffer:8192})},request:(e,o)=>st(e,o),tile:Br,installDesktop:ze},Q=!1;async function ee(e,o,t){try{await o.open(["-a","Google Chrome",e],t)}catch{t.throwIfAborted(),await o.open([e],t)}}async function oe(e,o,t,n){if(await t.open([Je[o]],n).catch(()=>{}),e[0]&&!n.aborted)t.tile(E(E(E(e[0]))),o)}async function Ve(e,o,t,n,s){for(let i of t){if(!C(e,`grant:${i}`))continue;s.throwIfAborted(),await n.request(o,i).catch(()=>null),await oe(o,i,n,s)}}var Ze={name:"open_tab",description:"Open a web page in the user's own Chrome on this Mac. Reason cannot read, screenshot or click in that tab, and no tab_id is returned: browser control needs Reason's Chrome extension. An actual browser call opens its setup page.",inputSchema:{type:"object",properties:{url:{type:"string",description:"An http or https URL."}},required:["url"],additionalProperties:!1}};function te(e){return{code:0,stderr:"",stdout:Buffer.from(JSON.stringify({ok:!0,...e}))}}function et(e){if(typeof e!=="string")return null;try{let o=new URL(e);return o.protocol==="https:"||o.protocol==="http:"?o.href:null}catch{return null}}async function re(e,o=T){let{call:t,runId:n,signal:s}=e;if(t.kind==="browser"){if(t.operation==="discover")return te({result:{tools:[Ze]}});if(t.operation!=="call")throw new r("automation_browser_setup_required","Browser control is not set up on this Mac yet. Request a browser operation or connect Chrome from Reason to set it up.")}if(e.desktopMissing&&!Q){Q=!0;try{o.installDesktop()}catch{}}if(t.kind==="computer"){if(e.identity.length>0&&C(n,"grant:probe")){let c=await o.request(e.identity).catch(()=>null),d=c?[...c.accessibility?[]:["accessibility"],...c.screen?[]:["screen"]]:[];for(let m of d)C(n,`grant:${m}`);for(let m of d)await oe(e.identity,m,o,s)}throw new r("automation_computer_setup_required","Computer use is not set up on this Mac yet; Reason asked macOS for any missing permission.")}if(C(n,"page:chrome-extension"))await ee(Fi,o,s).catch(()=>{});let i=t.arguments,u=t.operation==="call"&&t.tool==="open_tab"&&i&&typeof i==="object"&&!Array.isArray(i)?et(i.url):null;if(!u)throw new r("automation_browser_setup_required","Browser control is not set up on this Mac yet; Reason opened its Chrome Web Store page. open_tab still opens pages.");return await ee(u,o,s),te({result:{content:[{type:"text",text:JSON.stringify({opened:u,browser:"the user's Chrome",controllable:!1,note:"Opened for the user to see. Reason cannot read or act in this tab until Reason's Chrome extension is added (its Chrome Web Store page is open)."})}]}})}async function ne(e,o=T){if(e.call.kind!=="computer"||e.call.operation!=="permission_status"||e.output.code!==0||e.identity.length===0)return e.output;let t;try{t=JSON.parse(e.output.stdout.toString("utf8"))}catch{return e.output}if(!t||typeof t!=="object"||Array.isArray(t))return e.output;let n=t.permissions;if(!n||typeof n!=="object")return e.output;let s=n,i=[...s.accessibility==="missing"?["accessibility"]:[],...s.screenRecording==="missing"?["screen"]:[]];if(i.length===0)return e.output;return await Ve(e.runId,e.identity,i,o,e.signal),{...e.output,stdout:Buffer.from(JSON.stringify({...t,requested:i}))}}var j=172032,ft=18874368,wt=8192,_t=65536,yt=55000,bt=60000,St=4,xt=40000,Rt=/^[0-9a-f-]{36}$/,ce=Y,It=me();function N(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function D(){throw new r("invalid_automation_request","Reason automation request is malformed.")}function he(e){let o=Object.keys(e).sort().join(",");if(o==="call"||o==="browser,call"){let t=e.call,n=o==="browser,call";if(!N(t)||t.version!==1||t.kind!=="computer"&&t.kind!=="browser"||n&&(e.browser!==ht||t.kind!=="browser")||JSON.stringify(t).length>_t)D();return{call:t,userChrome:n}}if(o==="offset,output_id"){if(typeof e.output_id!=="string"||!Rt.test(e.output_id)||!Number.isSafeInteger(e.offset)||e.offset<0)D();return{output_id:e.output_id,offset:e.offset}}return D()}function mn(e=process.platform,o=P){if(e==="darwin")return!0;return(e==="linux"||e==="win32")&&o()?.features.computer===!0}var vt="__computer-use";function ss(e=P){return e()?.userChrome??{code:"user_chrome_browser_use_missing"}}function we(e,o,t,n){return new Promise((s)=>{let i=R(e,o,{env:t,stdio:"ignore",windowsHide:!0}),u=setTimeout(()=>{i.kill("SIGKILL"),s(-1)},n);i.once("error",()=>{clearTimeout(u),s(-1)}),i.once("exit",(c)=>{clearTimeout(u),s(c??-1)})})}function Ot(e,o,t,n){return new Promise((s)=>{let i=R(e,o,{env:t,stdio:["ignore","pipe","ignore"],windowsHide:!0}),u="";i.stdout.setEncoding("utf8").on("data",(d)=>{u+=d});let c=setTimeout(()=>{i.kill("SIGKILL"),s(null)},n);i.once("error",()=>{clearTimeout(c),s(null)}),i.once("close",(d)=>{clearTimeout(c),s(d===0?u:null)})})}function At(e){return v(e)?f(L(),"open-browser-use"):"/tmp/open-browser-use"}function v(e){return e.platform==="win32-x64"||e.platform==="win32-arm64"}var Et=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,Tt=33554432;function Nt(e,o){let t;try{t=e===null?null:JSON.parse(e)}catch{return null}let n=N(t)&&N(t.result)?t.result.metadata:null;if(!N(n)||n.extensionId!==o)return null;return typeof n.extensionInstanceId==="string"&&Et.test(n.extensionInstanceId)?n.extensionInstanceId:null}async function _e(e,o,t){let n=t.storages.map((c)=>{try{return U(c).filter((d)=>d.endsWith(".log")||d.endsWith(".ldb")).map((d)=>f(c,d))}catch{return[]}}),s;try{s=n.some((c)=>c.length>0)?U(t.socketDir).filter((c)=>c.endsWith(".sock")):[]}catch{return[]}let i=[];for(let c of s){let d=f(t.socketDir,c),m=Nt(await Ot(e,["info","--socket",d,"--timeout","2s"],o,5000),t.extensionId);if(m)i.push({instance:m,socket:d})}let u=[];for(let[c,d]of(i.length>0?n:[]).entries())for(let m of d)try{if(ut(m).size>Tt)continue;let l=K(m),p=i.find((g)=>l.includes(g.instance));if(p){u.push({storage:t.storages[c],...p});break}}catch{}return u}async function Pt(e,o,t){return(await _e(e,o,t))[0]?.instance??null}function ye(e,o,t){return Pt(e.nativeHost,o,{socketDir:At(e),extensionId:F,storages:[f(t,"browser-profile","Default","Local Extension Settings",F)]})}var le=/^(Default|Profile ([0-9]+))$/;async function Dt(e,o,t=a(),n=Ct){let s=f(t,"Library","Application Support","Google","Chrome"),i=[];try{i=U(s)}catch(l){if(l.code==="EPERM")throw new r("browser_use_chrome_access_denied","macOS blocked Reason from reading Chrome's profiles. Allow Full Disk Access for Reason on this Mac and try again.")}let u=(l)=>Number(le.exec(l)?.[2]??-1),c=i.filter((l)=>le.test(l)&&M(f(s,l,"Extensions",$e))).sort((l,p)=>u(l)-u(p)),d=(l)=>f(s,l,"Local Extension Settings",$e);return(await _e(e,o,{socketDir:n,extensionId:$e,storages:c.map(d)})).map(({storage:l,instance:p,socket:g})=>({profile:c.find((h)=>d(h)===l),instance:p,socket:g}))}async function Mt(e,o,t=a(),n=Ct){let s=(await Dt(e,o,t,n))[0]?.instance;if(!s)throw new r("automation_user_chrome_not_connected","No Chrome profile on this Mac is connected to Reason. Open Chrome with the Reason extension, then try again.");return s}function ue(e){return new Promise((o)=>{let t=pt({path:e}),n=(s)=>{t.destroy(),o(s)};t.setTimeout(1000,()=>n(!1)),t.once("error",()=>n(!1)),t.once("connect",()=>n(!0))})}async function Se(e,o){let t=Date.now()+o;while(Date.now()<t){if(await e())return!0;await new Promise((n)=>setTimeout(n,200))}return!1}var W=new Map;function H(e,o){let t=W.get(e);if(!t)t=o().finally(()=>W.delete(e)),W.set(e,t);return t}async function Ut(e,o){if(await ue(e))return;if(lt(e,{force:!0}),await we("dbus-daemon",["--session",`--address=unix:path=${e}`,"--fork"],o,1e4)!==0||!await Se(()=>ue(e),5000))throw new r("automation_unavailable","Reason could not start the desktop session bus.")}async function de(e,o,t){let n=e.platform==="darwin-arm64"||v(e)?async()=>await ye(e,o,t)!==null:async()=>await we(e.nativeHost,["info"],o,5000)===0;if(await n())return;let s=["--profile-directory=Default",`--load-extension=${e.extensionDir}`,"--no-first-run","--no-default-browser-check","--window-size=1280,800","about:blank"],i,u=null,c=0;if(e.platform==="darwin-arm64"){let l=f(t,"browser-profile");V(l);let p=f(l,"NativeMessagingHosts");ie(p,{recursive:!0,mode:448});let g=yr(e.platform).nativeHostManifests[0];se(g,f(p,ae(g)));let h=e.browser.slice(0,e.browser.indexOf(".app/")+4),y=s.filter((I)=>I!=="about:blank").concat("--no-startup-window","--use-mock-keychain");i=R("/usr/bin/open",["-g","-n","-a",h,"--args",`--user-data-dir=${l}`,...y],{env:o,stdio:"ignore"})}else if(v(e)){let l=f(t,"browser-profile");V(l),tt(x("icacls"),[B(e.browser),"/grant","*S-1-15-2-1:(OI)(CI)(RX)","*S-1-15-2-2:(OI)(CI)(RX)"],{stdio:"ignore",windowsHide:!0,timeout:60000});let p=s.filter((g)=>g!=="about:blank").concat("--no-startup-window","--keep-alive-for-test");i=R(e.browser,[`--user-data-dir=${l}`,...p],{detached:!0,stdio:"ignore",env:o})}else{let l=f(o.HOME,".config","google-chrome"),p=f(l,"NativeMessagingHosts");ie(p,{recursive:!0,mode:448});let g=yr(e.platform).nativeHostManifests[0];se(g,f(p,ae(g)));let h=process.geteuid?.()===0?["--no-sandbox"]:[];u=f(t,"browser.log");let y=it(u,"a",384);c=nt(y).size,i=R(e.browser,[`--user-data-dir=${l}`,...s,...h,"--force-renderer-accessibility"],{detached:!0,stdio:["ignore",y,y],env:{...o,ACCESSIBILITY_ENABLED:"1"}}),rt(y)}let d=!1;i.once("error",()=>{d=!0}),i.once("exit",(l)=>{d||=l!==0}),i.unref();let m=!1;if(await Se(async()=>d||(m=await n()),xt),!m){if(u&&K(u).subarray(c).toString("utf8").includes("No usable sandbox"))throw new r("automation_browser_sandbox_unavailable","Chromium found no usable sandbox on this machine. Run the worker as a non-root user with unprivileged user namespaces enabled, or in a container with seccomp unconfined.");throw new r("automation_browser_unavailable","Reason could not connect the desktop browser.")}}async function as(e){await Re(e,!0)}function cs(e){return xe(e,ke(e))}function xe(e,o){return e.platform==="darwin-arm64"||v(e)?f(o,"browser-profile"):f(o,"home",".config","google-chrome")}function ke(e){let o=f(e.root,"automation");if(!M(o)||!Lt(e.automation))return e.automation;if(!$t(xe(e,o)))try{fe(o,e.automation)}catch{}return M(o)?o:e.automation}function Lt(e){try{return U(e).length===0}catch(o){return o.code==="ENOENT"}}function $t(e){let o;try{o=ct(f(e,"SingletonLock"))}catch{return!1}let t=Number(o.slice(o.lastIndexOf("-")+1));if(!Number.isSafeInteger(t)||t<=0)return!0;try{return process.kill(t,0),!0}catch(n){return n.code==="EPERM"}}async function Re(e,o){gt({root:e.root,automation:e.automation,extensionDir:e.extensionDir});let t=ke(e);V(t);let n=ge().username,s={USER:n,LOGNAME:n,REASON_AUTOMATION_OCU:e.ocu,REASON_AUTOMATION_OBU:e.nativeHost};if(e.platform==="darwin-arm64"||v(e)){let l=v(e)?{...s,...Bt(),HOME:a()}:{...s,HOME:a(),PATH:`${B(e.node)}:/usr/bin:/bin:/usr/sbin:/sbin`,REASON_AUTOMATION_OCU:process.execPath,REASON_AUTOMATION_OCU_SUBCOMMAND:vt};if(!o)return l;await H("browser",()=>de(e,l,t));let p=await ye(e,l,t);if(!p)throw new r("automation_browser_unavailable","Reason could not connect the desktop browser.");return{...l,REASON_AUTOMATION_OBU_INSTANCE:p,REASON_AUTOMATION_BACKGROUND_TABS:"1"}}let i=await Be(),u=f(t,"home"),c=f(t,"runtime");V(u),V(c);let d=f(t,"bus"),m={...s,HOME:u,PATH:`${B(e.node)}:/usr/bin:/bin`,DISPLAY:i.display,XAUTHORITY:i.xauthority,XDG_RUNTIME_DIR:c,DBUS_SESSION_BUS_ADDRESS:`unix:path=${d}`,...i.sound?{PULSE_SERVER:Qe(i.sound)}:{}};if(await H("bus",()=>Ut(d,m)),o)await H("browser",()=>de(e,m,t));return m}function Bt(){let e=process.env.SystemRoot??"C:\\Windows",o=Object.fromEntries(["SystemDrive","USERPROFILE","LOCALAPPDATA","APPDATA","ProgramData","ProgramFiles","PATHEXT","ComSpec","USERNAME","USERDOMAIN","COMPUTERNAME","NUMBER_OF_PROCESSORS","PROCESSOR_ARCHITECTURE","PSModuleAnalysisCachePath"].flatMap((n)=>process.env[n]?[[n,process.env[n]]]:[])),t=f(e,"System32");return{...o,SystemRoot:e,windir:e,TEMP:L(),TMP:L(),PATH:[t,f(t,"WindowsPowerShell","v1.0"),e].join(mt)}}async function qt(e,o,t){let n=ge().username,s={USER:n,LOGNAME:n,HOME:a(),PATH:`${B(e.node)}:/usr/bin:/bin:/usr/sbin:/sbin`,REASON_AUTOMATION_OBU:o,REASON_AUTOMATION_BACKGROUND_TABS:"1"},i=await Mt(o,s);return t.throwIfAborted(),{...s,REASON_AUTOMATION_OBU_INSTANCE:i}}function Wt(e){if(process.platform!=="win32")return["--input-type=module","--eval",e];let o=f(L(),`reason-automation-${ot("sha256").update(e).digest("hex").slice(0,16)}.mjs`);if(!M(o)||K(o,"utf8")!==e){let t=`${o}.${process.pid}.tmp`;dt(t,e,{mode:384}),fe(t,o)}return[o]}function Ie(e,o,t,n){if(typeof ce!=="string")return Promise.reject(new r("automation_unavailable","This Reason build has no automation runtime."));let s=ce;return new Promise((i,u)=>{let c=R(e,Wt(s),{env:{...o,REASON_CLOUD_GATEWAY_EXEC:"1",REASON_AUTOMATION_INLINE_RESULT:"1"},stdio:["pipe","pipe","pipe"],detached:process.platform!=="win32",windowsHide:!0}),d=[],m=0,l="",p=null,g=!1,h=(w)=>{if(p??=w,process.platform==="win32"&&c.pid){R(f(process.env.SystemRoot??"C:\\Windows","System32","taskkill.exe"),["/pid",String(c.pid),"/t","/f"],{stdio:"ignore",windowsHide:!0}).once("error",()=>c.kill("SIGKILL"));return}try{process.kill(-c.pid,"SIGKILL")}catch{c.kill("SIGKILL")}},y=(w)=>{if(g)return;g=!0,clearTimeout(I),n.removeEventListener("abort",S),w()},I=setTimeout(()=>h(new r("automation_timed_out","Reason automation did not finish in time.")),yt),S=()=>h(new r("cancelled","Reason cancelled the automation call."));if(n.addEventListener("abort",S,{once:!0}),c.stdout.on("data",(w)=>{if(m+=w.byteLength,m>ft)h(new r("automation_output_too_large","Reason automation output is too large."));else d.push(w)}),c.stderr.setEncoding("utf8").on("data",(w)=>{l=(l+w).slice(-wt)}),c.stdin.on("error",()=>{}),c.once("error",()=>y(()=>u(p??new r("automation_unavailable","Reason could not start the automation runtime.")))),c.once("close",(w)=>y(()=>{if(p)u(p);else i({code:w??1,stdout:Buffer.concat(d),stderr:l})})),n.aborted)S();c.stdin.end(t)})}var k=new Map;function Ft(e,o,t){for(let[s,i]of k)if(i.expiresAt<=t)k.delete(s);while(k.size>=St)k.delete(k.keys().next().value);let n=me();return k.set(n,{runId:e,bytes:o,expiresAt:t+bt}),n}async function ve(e,o,t,n={}){let s=await(n.environment??Re)(e,o.kind==="browser");return t.throwIfAborted(),await(n.runtime??Ie)(e.node,s,JSON.stringify(o),t)}async function ls(e,o){let t=he({call:e});if(!("call"in t))D();let n=P();if(!n?.features.computer||t.call.kind==="browser"&&!n.features.browser)throw new r("automation_unavailable","Run `reason desktop install` on this machine to enable computer and browser use.");return await ve(n,t.call,o)}function pe(e,o,t){let n=e.stdout.byteLength>j?Ft(o,e.stdout,t):void 0;return{code:e.code,stderr:e.stderr,instance_id:It,output_bytes:e.stdout.byteLength,chunk:e.stdout.subarray(0,j).toString("base64"),...n?{output_id:n}:{}}}async function gn(e,o={}){let t=he(e.payload),n=(o.now??Date.now)();if("output_id"in t){let h=k.get(t.output_id);if(!h||h.runId!==e.runId||h.expiresAt<=n||t.offset>h.bytes.byteLength)throw new r("automation_output_unavailable","Reason automation output expired.");return{chunk:h.bytes.subarray(t.offset,t.offset+j).toString("base64")}}let s=(o.components??P)(),i=(o.platform??process.platform)==="darwin",u=i?(o.macIdentity??at)():[],c=o.macSetup??T,d=!s?.features.computer||t.call.kind==="browser"&&!t.userChrome&&!s.features.browser;if(i&&(d||u.length===0||t.call.kind==="browser"&&t.userChrome&&!e.userChrome))return pe(await re({runId:e.runId,call:t.call,identity:u,desktopMissing:d,signal:e.signal},c),e.runId,n);if(!s?.features.computer)throw new r("automation_unavailable","Run `reason desktop install` on this machine to enable computer and browser use.");let m=t.userChrome?e.userChrome:void 0;if(t.userChrome&&!m)throw new r("automation_user_chrome_unavailable","Your own Chrome is not enabled on this computer: run `reason desktop install` on this Mac (and `reason connect --user-chrome on` if you turned it off).");if(t.call.kind==="browser"&&!m&&!s.features.browser)throw new r("automation_browser_not_installed",!s.platform.startsWith("linux")?"Browser use is unavailable on this machine: re-run `reason desktop install`.":"Browser use is unavailable on this machine: install a non-snap Chromium at /usr/bin/chromium, then re-run `reason desktop install`.");e.signal.throwIfAborted();let l=await _i(e.runId,e.signal,o.now),p="account"in o?o.account??null:G(),g;try{if(m){let h=await(o.userChromeEnvironment??qt)(s,m,e.signal);e.signal.throwIfAborted(),g=await(o.runtime??Ie)(s.node,h,JSON.stringify(t.call),e.signal)}else if(p)g=await(o.delegate??z)(p,t.call,e.signal);else g=await ve(s,t.call,e.signal,o)}finally{l()}if(i)g=await ne({runId:e.runId,call:t.call,identity:u,output:g,signal:e.signal},c);return pe(g,e.runId,n)}
855
+ export{kt,mn,ss,as,cs,ls,gn};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{resolve as s,sep as i}from"path";var Se=[[".ssh"],[".gnupg"],[".aws"],[".azure"],[".kube"],[".docker"],[".infisical"],[".password-store"],[".terraform.d"],[".config","ara"],[".config","reason"],[".config","gh"],[".config","gcloud"],[".config","infisical"],[".config","op"],[".config","1password"],[".config","pass"],[".local","share","keyrings"],["library","keychains"],["library","application support","so.ara.desktop"],["appdata","roaming","github cli"],["appdata","roaming","gcloud"],["appdata","roaming","microsoft","credentials"],["appdata","local","microsoft","credentials"],["appdata","roaming","microsoft","protect"],["appdata","roaming","1password"],["appdata","local","1password"],["appdata","roaming","microsoft","windows","start menu","programs","startup"],["documents","windowspowershell"],["documents","powershell"],["appdata","local","reason"]],Mt=[[".codex","config.toml"],[".cursor","mcp.json"],[".claude","settings.json"],[".claude","settings.local.json"],[".cargo","credentials"],[".cargo","credentials.toml"],[".gem","credentials"],[".config","git","config"],[".config","git","credentials"],[".config","pip","pip.conf"]],$t=new Set([".bash_login",".bash_profile",".bashrc",".bunfig.toml",".claude.json",".env",".envrc",".git-credentials",".gitconfig",".mcp.json",".netrc",".npmrc",".profile",".pypirc",".terraformrc",".yarnrc",".yarnrc.yml",".zlogin",".zlogout",".zprofile",".zshenv",".zshrc","auth.json","credentials.json","credentials.tfrc.json","local-daemon.json","local-device.json","mcp.json"]),Bt=[".key",".p12",".pfx",".pem"];function t(n,a){if(n.length<a.length)return!1;for(let r=0;r<=n.length-a.length;r+=1)if(a.every((o,e)=>n[r+e]===o))return!0;return!1}function E(n){let a=s(n).split(i).filter(Boolean).map((o)=>o.toLowerCase());if(Se.some((o)=>t(a,o)))return!0;if(Mt.some((o)=>t(a,o)))return!0;let r=a.at(-1)??"";return $t.has(r)||r.startsWith(".env.")||Bt.some((o)=>r.endsWith(o))}
3
- export{Se,Mt,$t,Bt,E};
2
+ import{resolve as s,sep as i}from"path";var Se=[[".ssh"],[".gnupg"],[".aws"],[".azure"],[".kube"],[".docker"],[".infisical"],[".password-store"],[".terraform.d"],[".config","ara"],[".config","reason"],[".config","gh"],[".config","gcloud"],[".config","infisical"],[".config","op"],[".config","1password"],[".config","pass"],[".local","share","keyrings"],["library","keychains"],["library","application support","so.ara.desktop"],["appdata","roaming","github cli"],["appdata","roaming","gcloud"],["appdata","roaming","microsoft","credentials"],["appdata","local","microsoft","credentials"],["appdata","roaming","microsoft","protect"],["appdata","roaming","1password"],["appdata","local","1password"],["appdata","roaming","microsoft","windows","start menu","programs","startup"],["documents","windowspowershell"],["documents","powershell"],["appdata","local","reason"]],Bt=[[".codex","config.toml"],[".cursor","mcp.json"],[".claude","settings.json"],[".claude","settings.local.json"],[".cargo","credentials"],[".cargo","credentials.toml"],[".gem","credentials"],[".config","git","config"],[".config","git","credentials"],[".config","pip","pip.conf"]],Ft=new Set([".bash_login",".bash_profile",".bashrc",".bunfig.toml",".claude.json",".env",".envrc",".git-credentials",".gitconfig",".mcp.json",".netrc",".npmrc",".profile",".pypirc",".terraformrc",".yarnrc",".yarnrc.yml",".zlogin",".zlogout",".zprofile",".zshenv",".zshrc","auth.json","credentials.json","credentials.tfrc.json","local-daemon.json","local-device.json","mcp.json"]),jt=[".key",".p12",".pfx",".pem"];function t(n,a){if(n.length<a.length)return!1;for(let r=0;r<=n.length-a.length;r+=1)if(a.every((o,e)=>n[r+e]===o))return!0;return!1}function E(n){let a=s(n).split(i).filter(Boolean).map((o)=>o.toLowerCase());if(Se.some((o)=>t(a,o)))return!0;if(Bt.some((o)=>t(a,o)))return!0;let r=a.at(-1)??"";return Ft.has(r)||r.startsWith(".env.")||jt.some((o)=>r.endsWith(o))}
3
+ export{Se,Bt,Ft,jt,E};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{g,Lr,nt,ve}from"./vm-hands-entry-lite-5p5h1eng.js";import{zi}from"./vm-hands-entry-lite-ppytc9k7.js";import{a}from"./vm-hands-entry-lite-dkcm3hyn.js";import{t,i,s,n}from"./vm-hands-entry-lite-zn0v259d.js";import{createHmac as bt,createPublicKey as me,randomBytes as mt,randomUUID as he,verify as Se}from"crypto";import{chmodSync as L,existsSync as z,mkdirSync as Ie,readFileSync as ke,realpathSync as St,renameSync as De,statSync as It,unlinkSync as Le,writeFileSync as we}from"fs";import{basename as Dt,dirname as w,isAbsolute as Ae,join as m,resolve as Lt}from"path";var $e=[Object.freeze({family:"ara",channel:"stable",applicationId:"so.ara.desktop"}),Object.freeze({family:"ara",channel:"staging",applicationId:"so.ara.desktop.staging"}),Object.freeze({family:"reason",channel:"stable",applicationId:"com.reasonmachines.desktop"}),Object.freeze({family:"reason",channel:"staging",applicationId:"com.reasonmachines.desktop.staging"})];var Z="REASON_DESKTOP_RUNTIME",q="REASON_DESKTOP_RUNTIME_CHANNEL",Q="REASON_DESKTOP_RUNTIME_INSTANCE_ID",ee="REASON_DESKTOP_RUNTIME_WORKSPACE_SCOPE",We={[Z]:"ARA_DESKTOP_RUNTIME",[q]:"ARA_DESKTOP_RUNTIME_CHANNEL",[Q]:"ARA_DESKTOP_RUNTIME_INSTANCE_ID",[ee]:"ARA_DESKTOP_RUNTIME_WORKSPACE_SCOPE"};function x(r){if(r===void 0)return;if(!/^[a-f0-9]{64}$/.test(r))throw Error("Invalid desktop workspace scope.");return r}import{chmodSync as h,existsSync as f,mkdirSync as S,readFileSync as N,realpathSync as te,renameSync as ne,unlinkSync as I,writeFileSync as k}from"fs";import{createPrivateKey as ie,createPublicKey as re,generateKeyPairSync as oe,randomUUID as ae,sign as se}from"crypto";import{createRequire as ce}from"module";import{homedir as le,platform as T}from"os";import{dirname as de,join as y}from"path";var O=1,ue=16384,v=65536,pe=128,ge=128,U=65536;class l extends Error{code;nativeStatus;constructor(r,e){super(`Reason Device proof boundary failed (${r}).${e===void 0?"":` Native status: ${e}.`}`);this.code=r;this.nativeStatus=e;this.name="LocalCredentialBoundaryError"}}var D=null;function F(){if(!D)try{D=ce(import.meta.url)("bun:ffi")}catch{throw new l("native_boundary_unavailable")}return D}function fe(r){if(typeof r!=="string")return null;try{let e=new URL(r);if(e.protocol!=="https:"&&e.hostname!=="127.0.0.1"&&e.hostname!=="localhost"&&e.hostname!=="[::1]"&&e.hostname!=="::1")return null;return e.origin}catch{return null}}function ye(r){if(!r||typeof r!=="object"||Array.isArray(r))throw new l("invalid_credential_record");let e=r,o=fe(e.apiOrigin);if(e.version!==O||!o||typeof e.orgId!=="string"||e.orgId.length<1||e.orgId.length>160||typeof e.deviceId!=="string"||e.deviceId.length<1||e.deviceId.length>160||typeof e.credential!=="string"||!/^(?:reason|ara)_dev_/.test(e.credential)||e.credential.length>4096)throw new l("invalid_credential_record");return{version:O,apiOrigin:o,orgId:e.orgId,deviceId:e.deviceId,credential:e.credential}}function Pt(r=process.execPath){let e=r;try{e=te(r)}catch{}return zi(de(e))}function u(r){return F().ptr(r)}function _e(r){if(!f(r))throw new l("native_boundary_unavailable");let{dlopen:e,FFIType:o}=F();try{return e(r,{ara_device_configure_scope:{args:[o.ptr,o.u64],returns:o.i32},ara_device_key_load_public:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_create_fresh_public:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_sign:{args:[o.ptr,o.u64,o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_is_non_extractable:{args:[o.ptr],returns:o.i32},ara_device_key_delete:{args:[o.ptr],returns:o.i32},ara_device_binding_read:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_binding_create:{args:[o.ptr,o.u64],returns:o.i32},ara_device_binding_update:{args:[o.ptr,o.u64],returns:o.i32},ara_device_binding_delete:{args:[o.ptr],returns:o.i32},ara_device_keychain_read:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_keychain_delete:{args:[o.ptr],returns:o.i32}})}catch(c){if(c instanceof l)throw c;throw new l("native_boundary_unavailable")}}function K(r){return Buffer.from(r).toString("base64url")}function _(r){if(typeof r!=="string"||!/^[A-Za-z0-9_-]{87}$/.test(r))return!1;try{let e=Buffer.from(r,"base64url");return e.byteLength===65&&e[0]===4}catch{return!1}}function M(r){if(r.byteLength<8||r.byteLength>72||r[0]!==48)return!1;let e=r[1];return e!==void 0&&e<128&&e+2===r.byteLength}class Be{libraryPath;runtimePlatform;workspaceScope;library=null;constructor(r=Pt(),e=T(),o){this.libraryPath=r;this.runtimePlatform=e;this.workspaceScope=o;x(o)}symbols(){if(this.runtimePlatform!=="darwin")throw new l("unsupported_platform");this.library??=_e(this.libraryPath);let r=new TextEncoder().encode(this.workspaceScope??""),e=this.library.symbols.ara_device_configure_scope(u(r.length?r:new Uint8Array(1)),BigInt(r.length));if(e!==0)throw new l("native_boundary_unavailable",e);return this.library.symbols}publicKey(r){let e=new Uint8Array(pe),o=new BigUint64Array(1),c=r==="load"?this.symbols().ara_device_key_load_public(u(e),BigInt(e.byteLength),u(o)):this.symbols().ara_device_key_create_fresh_public(u(e),BigInt(e.byteLength),u(o));if(c!==0)throw new l(r==="load"?"proof_key_read_failed":"proof_key_generation_failed",c);let d=Number(o[0]);if(!Number.isSafeInteger(d)||d!==65)throw new l("invalid_public_key");let p=K(e.subarray(0,d));if(!_(p))throw new l("invalid_public_key");return p}loadPublicKey(){return this.publicKey("load")}createFreshPublicKey(){return this.publicKey("create_fresh")}sign(r){if(r.byteLength<1||r.byteLength>U)throw new l("proof_sign_failed");let e=new Uint8Array(ge),o=new BigUint64Array(1),c=this.symbols().ara_device_key_sign(u(r),BigInt(r.byteLength),u(e),BigInt(e.byteLength),u(o));if(c!==0)throw new l("proof_sign_failed",c);let d=Number(o[0]);if(!Number.isSafeInteger(d)||d<1||d>e.byteLength)throw new l("invalid_signature");let p=e.subarray(0,d);if(!M(p))throw new l("invalid_signature");return K(p)}privateKeyIsNonExtractable(){let r=new Uint8Array(1),e=this.symbols().ara_device_key_is_non_extractable(u(r));if(e!==0||r[0]!==1)throw new l("proof_key_read_failed",e);return!0}deleteKey(){let r=new Uint8Array(1),e=this.symbols().ara_device_key_delete(u(r));if(e!==0)throw new l("proof_key_delete_failed",e);return r[0]===1}loadBinding(){let r=new Uint8Array(v),e=new BigUint64Array(1),o=this.symbols().ara_device_binding_read(u(r),BigInt(r.byteLength),u(e));if(o===1)return null;if(o!==0)throw new l("binding_read_failed",o);let c=Number(e[0]);if(!Number.isSafeInteger(c)||c<1||c>r.byteLength)throw new l("invalid_binding");return r.slice(0,c)}createBinding(r){if(r.byteLength<1||r.byteLength>v)throw new l("invalid_binding");let e=this.symbols().ara_device_binding_create(u(r),BigInt(r.byteLength));if(e!==0)throw new l("binding_create_failed",e)}updateBinding(r){if(r.byteLength<1||r.byteLength>v)throw new l("invalid_binding");let e=this.symbols().ara_device_binding_update(u(r),BigInt(r.byteLength));if(e!==0)throw new l("binding_update_failed",e)}deleteBinding(){let r=new Uint8Array(1),e=this.symbols().ara_device_binding_delete(u(r));if(e!==0)throw new l("binding_delete_failed",e);return r[0]===1}loadLegacyCredential(){let r=new Uint8Array(ue),e=new BigUint64Array(1),o=this.symbols().ara_device_keychain_read(u(r),BigInt(r.byteLength),u(e));if(o===1)return null;if(o!==0)throw new l("legacy_credential_read_failed",o);let c=Number(e[0]);if(!Number.isSafeInteger(c)||c<1||c>r.byteLength)throw new l("invalid_credential_record");try{let d=new TextDecoder("utf-8",{fatal:!0}).decode(r.subarray(0,c));return ye(JSON.parse(d))}catch(d){if(d instanceof l)throw d;throw new l("invalid_credential_record")}}deleteLegacyCredential(){let r=new Uint8Array(1),e=this.symbols().ara_device_keychain_delete(u(r));if(e!==0)throw new l("legacy_credential_delete_failed",e);return r[0]===1}}function C(r){let e=r.export({format:"jwk"});if(e.crv!=="P-256"||typeof e.x!=="string"||typeof e.y!=="string")throw new l("invalid_public_key");let o=Buffer.from(e.x,"base64url"),c=Buffer.from(e.y,"base64url");if(o.byteLength!==32||c.byteLength!==32)throw new l("invalid_public_key");let d=Buffer.concat([Buffer.of(4),o,c]).toString("base64url");if(!_(d))throw new l("invalid_public_key");return d}function be(){let r=process.env.XDG_CONFIG_HOME?.trim()||y(le(),".config");nt(r);let e=y(r,"ara");return Lr(e)?e:y(r,"reason")}class br{directory;constructor(r=be()){this.directory=r}keyPath(){return y(this.directory,"local-device.key")}bindingPath(){return y(this.directory,"local-device.binding")}loadPrivateKeyObject(){let r=this.keyPath();if(!f(r))throw new l("proof_key_read_failed");try{let e=N(r,"utf8");return ie({key:e,format:"pem"})}catch{throw new l("proof_key_read_failed")}}loadPublicKey(){let r=this.loadPrivateKeyObject(),e=re(r);return C(e)}createFreshPublicKey(){S(this.directory,{recursive:!0,mode:448});let{privateKey:r,publicKey:e}=oe("ec",{namedCurve:"P-256"}),o=r.export({type:"pkcs8",format:"pem"}),c=this.keyPath();return k(c,o,{mode:384}),h(c,384),C(e)}sign(r){if(r.byteLength<1||r.byteLength>U)throw new l("proof_sign_failed");let e=this.loadPrivateKeyObject(),o;try{o=se("sha256",r,e)}catch{throw new l("proof_sign_failed")}if(!M(o))throw new l("invalid_signature");return o.toString("base64url")}privateKeyIsNonExtractable(){return!1}deleteKey(){let r=this.keyPath();if(!f(r))return!1;return I(r),!0}loadBinding(){let r=this.bindingPath();if(!f(r))return null;try{return new Uint8Array(N(r))}catch{return null}}createBinding(r){if(r.byteLength<1||r.byteLength>v)throw new l("invalid_binding");S(this.directory,{recursive:!0,mode:448});let e=this.bindingPath();if(f(e))throw new l("binding_create_failed");k(e,r,{mode:384}),h(e,384)}updateBinding(r){if(r.byteLength<1||r.byteLength>v)throw new l("invalid_binding");S(this.directory,{recursive:!0,mode:448});let e=this.bindingPath();if(!f(e))throw new l("binding_update_failed");let o=`${e}.${ae()}`;try{k(o,r,{mode:384,flag:"wx"}),h(o,384),ne(o,e)}finally{if(f(o))I(o)}}deleteBinding(){let r=this.bindingPath();if(!f(r))return!1;return I(r),!0}loadLegacyCredential(){return null}deleteLegacyCredential(){return!1}}function V(){return T()==="darwin"?new Be:new br}var b=t().min(1).max(160).regex(/^[A-Za-z0-9._:-]+$/),B=i({id:b,kind:n("permission_denied"),operation:s(["bash","read","write","edit"]),provenance:s(["sandbox_policy","os_permission_unknown"]),occurredAt:t().datetime(),expiresAt:t().datetime(),sessionId:b,deviceId:b,organizationId:b}).strict();var A=4;var P="macos-keychain-p256-v1",Pe=1,Ee=`ARA-DEVICE-BINDING-V1
3
- `;function Re(r){return r===void 0||typeof r==="number"&&Number.isInteger(r)&&r>=1&&r<=4}function G(r,e=Date.now()){let o=B.safeParse(r);if(!o.success)return!1;let c=o.data,d=typeof c.occurredAt==="string"?Date.parse(c.occurredAt):NaN,p=typeof c.expiresAt==="string"?Date.parse(c.expiresAt):NaN;return c.kind==="permission_denied"&&["bash","read","write","edit"].includes(c.operation)&&["sandbox_policy","os_permission_unknown"].includes(c.provenance)&&Number.isFinite(d)&&d<=e&&p>e&&p>d&&p-d<=600000}function Tt(r,e,o=Date.now()){if(!r||!e||r.state!=="connected"||r.deviceId!==e.deviceId)return null;let c=Date.parse(r.lastHeartbeatAt??""),d=r.permissionRecovery;if(!(o-c>=0&&o-c<30000)||!G(d,o)||d.deviceId!==e.deviceId||d.organizationId!==e.orgId)return null;try{process.kill(r.pid,0)}catch{return null}return d}function H(r={},e=a()){let o=g({env:{...process.env,...r}}),c=r.XDG_CONFIG_HOME?.trim()||m(e,".config");return ve(c,...o==="staging"?["staging"]:[])}function vr(r={},e=a()){return m(H(r,e),"local-device.json")}function xe(r={},e=a()){return m(H(r,e),"local-daemon.json")}function Ne(r,e){Ie(w(r),{recursive:!0,mode:448}),L(w(r),448);let o=`${r}.${process.pid}.${he()}.tmp`;try{we(o,`${JSON.stringify(e,null,2)}
4
- `,{mode:384,flag:"wx"}),L(o,384),De(o,r),L(r,384)}finally{if(z(o))Le(o)}return r}function E(r){if(!z(r))return null;try{return JSON.parse(ke(r,"utf8"))}catch{return null}}function Oe(r){if(!Array.isArray(r))return null;let e=[];for(let o of r){if(!o||typeof o!=="object")return null;let c=o;if(typeof c.id!=="string"||typeof c.label!=="string"||typeof c.path!=="string"||typeof c.pathFingerprint!=="string"||!c.permissions||typeof c.permissions.read!=="boolean"||typeof c.permissions.write!=="boolean"||typeof c.permissions.execute!=="boolean"||typeof c.permissions.discover_environment!=="boolean"||typeof c.permissions.expose_mcp!=="boolean")return null;e.push({id:c.id,label:c.label,path:c.path,pathFingerprint:c.pathFingerprint,permissions:c.permissions})}return e}function J(r,e,o=[]){let c=Object.keys(r);return e.every((d)=>Object.hasOwn(r,d))&&c.every((d)=>e.includes(d)||o.includes(d))}function Ke(r){if(typeof r!=="string")return null;try{let e=new URL(r);if(e.protocol!=="https:"&&e.hostname!=="127.0.0.1"&&e.hostname!=="localhost")return null;return e.origin}catch{return null}}function Y(r){if(!r||typeof r!=="object"||Array.isArray(r))return null;let e=r,o=Oe(e.roots),c=Ke(e.apiOrigin);if(!c||typeof e.orgId!=="string"||typeof e.deviceId!=="string"||typeof e.displayName!=="string"||typeof e.registeredAt!=="string"||!Re(e.handsSlots)||e.worker!==void 0&&(!e.worker||!/^[a-f0-9]{64}$/.test(e.worker.configDigest)||!["persistent","ephemeral"].includes(e.worker.lifetime)||!Number.isFinite(Date.parse(e.worker.expiresAt)))||!o)return null;return{apiOrigin:c,orgId:e.orgId,deviceId:e.deviceId,displayName:e.displayName,registeredAt:e.registeredAt,...e.handsSlots!==void 0?{handsSlots:e.handsSlots}:{},...e.worker!==void 0?{worker:e.worker}:{},roots:o}}function Ce(r){return{version:A,apiOrigin:r.apiOrigin,orgId:r.orgId,deviceId:r.deviceId,devicePublicKey:r.devicePublicKey,displayName:r.displayName,registeredAt:r.registeredAt,...r.handsSlots!==void 0?{handsSlots:r.handsSlots}:{},...r.worker!==void 0?{worker:r.worker}:{},roots:r.roots.map((e)=>({id:e.id,label:e.label,path:e.path,pathFingerprint:e.pathFingerprint,permissions:{read:e.permissions.read,write:e.permissions.write,execute:e.permissions.execute,discover_environment:e.permissions.discover_environment,expose_mcp:e.permissions.expose_mcp}})),credentialStorage:P}}function X(r){if(!r||typeof r!=="object"||Array.isArray(r))return null;let e=r;if(!J(e,["version","apiOrigin","orgId","deviceId","devicePublicKey","displayName","registeredAt","roots","credentialStorage"],["handsSlots","worker"]))return null;let o=Y(e);if(!o||e.version!==A||e.credentialStorage!==P||!_(e.devicePublicKey))return null;return{version:A,...o,devicePublicKey:e.devicePublicKey,credentialStorage:P}}function Te(r){return new TextEncoder().encode(`${Ee}${JSON.stringify(Ce(r))}`)}function Ue(r){let e=Buffer.from(r,"base64url");return me({format:"jwk",key:{kty:"EC",crv:"P-256",x:e.subarray(1,33).toString("base64url"),y:e.subarray(33,65).toString("base64url")}})}function Fe(r){let e;try{e=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(r))}catch{throw new l("invalid_binding")}if(!e||typeof e!=="object"||Array.isArray(e))throw new l("invalid_binding");let o=e;if(!J(o,["version","state","signature"])||o.version!==Pe||typeof o.signature!=="string"||!/^[A-Za-z0-9_-]{10,128}$/.test(o.signature))throw new l("invalid_binding");let c=X(o.state);if(!c)throw new l("invalid_binding");let d=!1;try{d=Se("sha256",Te(c),Ue(c.devicePublicKey),Buffer.from(o.signature,"base64url"))}catch{d=!1}if(!d)throw new l("invalid_binding");return c}function Me(r){let{credentialStorage:e,...o}=r;return o}function Sr(r=vr(),e={}){let o=E(r),c=e.proofStore??e.credentialStore??V(),d=c.loadBinding();if(!d){if(o&&typeof o==="object"&&!Array.isArray(o)&&je(o))return null;if(o!==null)throw new l("invalid_binding");return null}let p=Fe(d),W=c.loadPublicKey();if(c.privateKeyIsNonExtractable(),W!==p.devicePublicKey)throw new l("invalid_public_key");let R=X(o);if(e.repair!==!1&&(!R||JSON.stringify(R)!==JSON.stringify(p)))Ne(r,p);return Me(p)}function je(r){let e=r,o=Y(r);if(!o)return null;if(e.version===2){if(typeof e.deviceCredential!=="string"||!/^(?:reason|ara)_dev_/.test(e.deviceCredential)||e.deviceCredential.length>4096)return null;return{state:o,credentialSource:"plaintext-v2"}}if(e.version!==3||e.credentialStorage!=="macos-keychain-v1"||"deviceCredential"in e)return null;return{state:o,credentialSource:"keychain-v3"}}function Qe(r=xe()){let e=E(r);if(!e||typeof e!=="object")return null;let o=e;if(o.version!==1||typeof o.pid!=="number"||!Number.isInteger(o.pid)||!["starting","connected","stopped","error"].includes(o.state??"")||typeof o.startedAt!=="string"||o.lastHeartbeatAt!==void 0&&typeof o.lastHeartbeatAt!=="string"||o.lastUsedAt!==void 0&&typeof o.lastUsedAt!=="string"||o.organizationId!==void 0&&typeof o.organizationId!=="string"||o.organizationName!==void 0&&typeof o.organizationName!=="string"||o.organizationSlug!==void 0&&typeof o.organizationSlug!=="string"||o.error!==void 0&&typeof o.error!=="string"||o.reconnectingSince!==void 0&&typeof o.reconnectingSince!=="string"||o.workspace!==void 0&&typeof o.workspace!=="string")return null;if(o.permissionRecovery!==void 0&&!G(o.permissionRecovery))delete o.permissionRecovery;return o}var Rt=1;function Ve(r=vr()){return m(w(r),"local-device.proxy.json")}function j(r=Ve()){let e=E(r);if(!e||typeof e!=="object"||Array.isArray(e))return null;let o=e;if(o.version!==Rt||typeof o.url!=="string"||o.url.length===0||o.caFile!==void 0&&(typeof o.caFile!=="string"||!Ae(o.caFile)))return null;return{version:Rt,url:o.url,...o.caFile?{caFile:o.caFile}:{}}}
5
- export{l,Pt,Be,br,Tt,vr,Sr,Qe,Rt,j};
2
+ import{g,$r,it,ve}from"./vm-hands-entry-lite-ckv17tn8.js";import{Vi}from"./vm-hands-entry-lite-1rrb66r9.js";import{a}from"./vm-hands-entry-lite-89z488gz.js";import{t,i,s,n}from"./vm-hands-entry-lite-907pa7f9.js";import{createHmac as bt,createPublicKey as me,randomBytes as mt,randomUUID as he,verify as Se}from"crypto";import{chmodSync as L,existsSync as z,mkdirSync as Ie,readFileSync as ke,realpathSync as St,renameSync as De,statSync as kt,unlinkSync as Le,writeFileSync as we}from"fs";import{basename as Lt,dirname as w,isAbsolute as Ae,join as m,resolve as wt}from"path";var $e=[Object.freeze({family:"ara",channel:"stable",applicationId:"so.ara.desktop"}),Object.freeze({family:"ara",channel:"staging",applicationId:"so.ara.desktop.staging"}),Object.freeze({family:"reason",channel:"stable",applicationId:"com.reasonmachines.desktop"}),Object.freeze({family:"reason",channel:"staging",applicationId:"com.reasonmachines.desktop.staging"})];var Z="REASON_DESKTOP_RUNTIME",q="REASON_DESKTOP_RUNTIME_CHANNEL",Q="REASON_DESKTOP_RUNTIME_INSTANCE_ID",ee="REASON_DESKTOP_RUNTIME_WORKSPACE_SCOPE",We={[Z]:"ARA_DESKTOP_RUNTIME",[q]:"ARA_DESKTOP_RUNTIME_CHANNEL",[Q]:"ARA_DESKTOP_RUNTIME_INSTANCE_ID",[ee]:"ARA_DESKTOP_RUNTIME_WORKSPACE_SCOPE"};function x(r){if(r===void 0)return;if(!/^[a-f0-9]{64}$/.test(r))throw Error("Invalid desktop workspace scope.");return r}import{chmodSync as h,existsSync as f,mkdirSync as S,readFileSync as N,realpathSync as te,renameSync as ne,unlinkSync as I,writeFileSync as k}from"fs";import{createPrivateKey as ie,createPublicKey as re,generateKeyPairSync as oe,randomUUID as ae,sign as se}from"crypto";import{createRequire as ce}from"module";import{homedir as le,platform as T}from"os";import{dirname as de,join as y}from"path";var O=1,ue=16384,v=65536,pe=128,ge=128,U=65536;class l extends Error{code;nativeStatus;constructor(r,e){super(`Reason Device proof boundary failed (${r}).${e===void 0?"":` Native status: ${e}.`}`);this.code=r;this.nativeStatus=e;this.name="LocalCredentialBoundaryError"}}var D=null;function F(){if(!D)try{D=ce(import.meta.url)("bun:ffi")}catch{throw new l("native_boundary_unavailable")}return D}function fe(r){if(typeof r!=="string")return null;try{let e=new URL(r);if(e.protocol!=="https:"&&e.hostname!=="127.0.0.1"&&e.hostname!=="localhost"&&e.hostname!=="[::1]"&&e.hostname!=="::1")return null;return e.origin}catch{return null}}function ye(r){if(!r||typeof r!=="object"||Array.isArray(r))throw new l("invalid_credential_record");let e=r,o=fe(e.apiOrigin);if(e.version!==O||!o||typeof e.orgId!=="string"||e.orgId.length<1||e.orgId.length>160||typeof e.deviceId!=="string"||e.deviceId.length<1||e.deviceId.length>160||typeof e.credential!=="string"||!/^(?:reason|ara)_dev_/.test(e.credential)||e.credential.length>4096)throw new l("invalid_credential_record");return{version:O,apiOrigin:o,orgId:e.orgId,deviceId:e.deviceId,credential:e.credential}}function Rt(r=process.execPath){let e=r;try{e=te(r)}catch{}return Vi(de(e))}function u(r){return F().ptr(r)}function _e(r){if(!f(r))throw new l("native_boundary_unavailable");let{dlopen:e,FFIType:o}=F();try{return e(r,{ara_device_configure_scope:{args:[o.ptr,o.u64],returns:o.i32},ara_device_key_load_public:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_create_fresh_public:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_sign:{args:[o.ptr,o.u64,o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_is_non_extractable:{args:[o.ptr],returns:o.i32},ara_device_key_delete:{args:[o.ptr],returns:o.i32},ara_device_binding_read:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_binding_create:{args:[o.ptr,o.u64],returns:o.i32},ara_device_binding_update:{args:[o.ptr,o.u64],returns:o.i32},ara_device_binding_delete:{args:[o.ptr],returns:o.i32},ara_device_keychain_read:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_keychain_delete:{args:[o.ptr],returns:o.i32}})}catch(c){if(c instanceof l)throw c;throw new l("native_boundary_unavailable")}}function K(r){return Buffer.from(r).toString("base64url")}function _(r){if(typeof r!=="string"||!/^[A-Za-z0-9_-]{87}$/.test(r))return!1;try{let e=Buffer.from(r,"base64url");return e.byteLength===65&&e[0]===4}catch{return!1}}function M(r){if(r.byteLength<8||r.byteLength>72||r[0]!==48)return!1;let e=r[1];return e!==void 0&&e<128&&e+2===r.byteLength}class Fe{libraryPath;runtimePlatform;workspaceScope;library=null;constructor(r=Rt(),e=T(),o){this.libraryPath=r;this.runtimePlatform=e;this.workspaceScope=o;x(o)}symbols(){if(this.runtimePlatform!=="darwin")throw new l("unsupported_platform");this.library??=_e(this.libraryPath);let r=new TextEncoder().encode(this.workspaceScope??""),e=this.library.symbols.ara_device_configure_scope(u(r.length?r:new Uint8Array(1)),BigInt(r.length));if(e!==0)throw new l("native_boundary_unavailable",e);return this.library.symbols}publicKey(r){let e=new Uint8Array(pe),o=new BigUint64Array(1),c=r==="load"?this.symbols().ara_device_key_load_public(u(e),BigInt(e.byteLength),u(o)):this.symbols().ara_device_key_create_fresh_public(u(e),BigInt(e.byteLength),u(o));if(c!==0)throw new l(r==="load"?"proof_key_read_failed":"proof_key_generation_failed",c);let d=Number(o[0]);if(!Number.isSafeInteger(d)||d!==65)throw new l("invalid_public_key");let p=K(e.subarray(0,d));if(!_(p))throw new l("invalid_public_key");return p}loadPublicKey(){return this.publicKey("load")}createFreshPublicKey(){return this.publicKey("create_fresh")}sign(r){if(r.byteLength<1||r.byteLength>U)throw new l("proof_sign_failed");let e=new Uint8Array(ge),o=new BigUint64Array(1),c=this.symbols().ara_device_key_sign(u(r),BigInt(r.byteLength),u(e),BigInt(e.byteLength),u(o));if(c!==0)throw new l("proof_sign_failed",c);let d=Number(o[0]);if(!Number.isSafeInteger(d)||d<1||d>e.byteLength)throw new l("invalid_signature");let p=e.subarray(0,d);if(!M(p))throw new l("invalid_signature");return K(p)}privateKeyIsNonExtractable(){let r=new Uint8Array(1),e=this.symbols().ara_device_key_is_non_extractable(u(r));if(e!==0||r[0]!==1)throw new l("proof_key_read_failed",e);return!0}deleteKey(){let r=new Uint8Array(1),e=this.symbols().ara_device_key_delete(u(r));if(e!==0)throw new l("proof_key_delete_failed",e);return r[0]===1}loadBinding(){let r=new Uint8Array(v),e=new BigUint64Array(1),o=this.symbols().ara_device_binding_read(u(r),BigInt(r.byteLength),u(e));if(o===1)return null;if(o!==0)throw new l("binding_read_failed",o);let c=Number(e[0]);if(!Number.isSafeInteger(c)||c<1||c>r.byteLength)throw new l("invalid_binding");return r.slice(0,c)}createBinding(r){if(r.byteLength<1||r.byteLength>v)throw new l("invalid_binding");let e=this.symbols().ara_device_binding_create(u(r),BigInt(r.byteLength));if(e!==0)throw new l("binding_create_failed",e)}updateBinding(r){if(r.byteLength<1||r.byteLength>v)throw new l("invalid_binding");let e=this.symbols().ara_device_binding_update(u(r),BigInt(r.byteLength));if(e!==0)throw new l("binding_update_failed",e)}deleteBinding(){let r=new Uint8Array(1),e=this.symbols().ara_device_binding_delete(u(r));if(e!==0)throw new l("binding_delete_failed",e);return r[0]===1}loadLegacyCredential(){let r=new Uint8Array(ue),e=new BigUint64Array(1),o=this.symbols().ara_device_keychain_read(u(r),BigInt(r.byteLength),u(e));if(o===1)return null;if(o!==0)throw new l("legacy_credential_read_failed",o);let c=Number(e[0]);if(!Number.isSafeInteger(c)||c<1||c>r.byteLength)throw new l("invalid_credential_record");try{let d=new TextDecoder("utf-8",{fatal:!0}).decode(r.subarray(0,c));return ye(JSON.parse(d))}catch(d){if(d instanceof l)throw d;throw new l("invalid_credential_record")}}deleteLegacyCredential(){let r=new Uint8Array(1),e=this.symbols().ara_device_keychain_delete(u(r));if(e!==0)throw new l("legacy_credential_delete_failed",e);return r[0]===1}}function C(r){let e=r.export({format:"jwk"});if(e.crv!=="P-256"||typeof e.x!=="string"||typeof e.y!=="string")throw new l("invalid_public_key");let o=Buffer.from(e.x,"base64url"),c=Buffer.from(e.y,"base64url");if(o.byteLength!==32||c.byteLength!==32)throw new l("invalid_public_key");let d=Buffer.concat([Buffer.of(4),o,c]).toString("base64url");if(!_(d))throw new l("invalid_public_key");return d}function be(){let r=process.env.XDG_CONFIG_HOME?.trim()||y(le(),".config");it(r);let e=y(r,"ara");return $r(e)?e:y(r,"reason")}class Sr{directory;constructor(r=be()){this.directory=r}keyPath(){return y(this.directory,"local-device.key")}bindingPath(){return y(this.directory,"local-device.binding")}loadPrivateKeyObject(){let r=this.keyPath();if(!f(r))throw new l("proof_key_read_failed");try{let e=N(r,"utf8");return ie({key:e,format:"pem"})}catch{throw new l("proof_key_read_failed")}}loadPublicKey(){let r=this.loadPrivateKeyObject(),e=re(r);return C(e)}createFreshPublicKey(){S(this.directory,{recursive:!0,mode:448});let{privateKey:r,publicKey:e}=oe("ec",{namedCurve:"P-256"}),o=r.export({type:"pkcs8",format:"pem"}),c=this.keyPath();return k(c,o,{mode:384}),h(c,384),C(e)}sign(r){if(r.byteLength<1||r.byteLength>U)throw new l("proof_sign_failed");let e=this.loadPrivateKeyObject(),o;try{o=se("sha256",r,e)}catch{throw new l("proof_sign_failed")}if(!M(o))throw new l("invalid_signature");return o.toString("base64url")}privateKeyIsNonExtractable(){return!1}deleteKey(){let r=this.keyPath();if(!f(r))return!1;return I(r),!0}loadBinding(){let r=this.bindingPath();if(!f(r))return null;try{return new Uint8Array(N(r))}catch{return null}}createBinding(r){if(r.byteLength<1||r.byteLength>v)throw new l("invalid_binding");S(this.directory,{recursive:!0,mode:448});let e=this.bindingPath();if(f(e))throw new l("binding_create_failed");k(e,r,{mode:384}),h(e,384)}updateBinding(r){if(r.byteLength<1||r.byteLength>v)throw new l("invalid_binding");S(this.directory,{recursive:!0,mode:448});let e=this.bindingPath();if(!f(e))throw new l("binding_update_failed");let o=`${e}.${ae()}`;try{k(o,r,{mode:384,flag:"wx"}),h(o,384),ne(o,e)}finally{if(f(o))I(o)}}deleteBinding(){let r=this.bindingPath();if(!f(r))return!1;return I(r),!0}loadLegacyCredential(){return null}deleteLegacyCredential(){return!1}}function V(){return T()==="darwin"?new Fe:new Sr}var b=t().min(1).max(160).regex(/^[A-Za-z0-9._:-]+$/),B=i({id:b,kind:n("permission_denied"),operation:s(["bash","read","write","edit"]),provenance:s(["sandbox_policy","os_permission_unknown"]),occurredAt:t().datetime(),expiresAt:t().datetime(),sessionId:b,deviceId:b,organizationId:b}).strict();var A=4;var P="macos-keychain-p256-v1",Pe=1,Ee=`ARA-DEVICE-BINDING-V1
3
+ `;function Re(r){return r===void 0||typeof r==="number"&&Number.isInteger(r)&&r>=1&&r<=4}function G(r,e=Date.now()){let o=B.safeParse(r);if(!o.success)return!1;let c=o.data,d=typeof c.occurredAt==="string"?Date.parse(c.occurredAt):NaN,p=typeof c.expiresAt==="string"?Date.parse(c.expiresAt):NaN;return c.kind==="permission_denied"&&["bash","read","write","edit"].includes(c.operation)&&["sandbox_policy","os_permission_unknown"].includes(c.provenance)&&Number.isFinite(d)&&d<=e&&p>e&&p>d&&p-d<=600000}function Ot(r,e,o=Date.now()){if(!r||!e||r.state!=="connected"||r.deviceId!==e.deviceId)return null;let c=Date.parse(r.lastHeartbeatAt??""),d=r.permissionRecovery;if(!(o-c>=0&&o-c<30000)||!G(d,o)||d.deviceId!==e.deviceId||d.organizationId!==e.orgId)return null;try{process.kill(r.pid,0)}catch{return null}return d}function H(r={},e=a()){let o=g({env:{...process.env,...r}}),c=r.XDG_CONFIG_HOME?.trim()||m(e,".config");return ve(c,...o==="staging"?["staging"]:[])}function Er(r={},e=a()){return m(H(r,e),"local-device.json")}function xe(r={},e=a()){return m(H(r,e),"local-daemon.json")}function Ne(r,e){Ie(w(r),{recursive:!0,mode:448}),L(w(r),448);let o=`${r}.${process.pid}.${he()}.tmp`;try{we(o,`${JSON.stringify(e,null,2)}
4
+ `,{mode:384,flag:"wx"}),L(o,384),De(o,r),L(r,384)}finally{if(z(o))Le(o)}return r}function E(r){if(!z(r))return null;try{return JSON.parse(ke(r,"utf8"))}catch{return null}}function Oe(r){if(!Array.isArray(r))return null;let e=[];for(let o of r){if(!o||typeof o!=="object")return null;let c=o;if(typeof c.id!=="string"||typeof c.label!=="string"||typeof c.path!=="string"||typeof c.pathFingerprint!=="string"||!c.permissions||typeof c.permissions.read!=="boolean"||typeof c.permissions.write!=="boolean"||typeof c.permissions.execute!=="boolean"||typeof c.permissions.discover_environment!=="boolean"||typeof c.permissions.expose_mcp!=="boolean")return null;e.push({id:c.id,label:c.label,path:c.path,pathFingerprint:c.pathFingerprint,permissions:c.permissions})}return e}function J(r,e,o=[]){let c=Object.keys(r);return e.every((d)=>Object.hasOwn(r,d))&&c.every((d)=>e.includes(d)||o.includes(d))}function Ke(r){if(typeof r!=="string")return null;try{let e=new URL(r);if(e.protocol!=="https:"&&e.hostname!=="127.0.0.1"&&e.hostname!=="localhost")return null;return e.origin}catch{return null}}function Y(r){if(!r||typeof r!=="object"||Array.isArray(r))return null;let e=r,o=Oe(e.roots),c=Ke(e.apiOrigin);if(!c||typeof e.orgId!=="string"||typeof e.deviceId!=="string"||typeof e.displayName!=="string"||typeof e.registeredAt!=="string"||!Re(e.handsSlots)||e.worker!==void 0&&(!e.worker||!/^[a-f0-9]{64}$/.test(e.worker.configDigest)||!["persistent","ephemeral"].includes(e.worker.lifetime)||!Number.isFinite(Date.parse(e.worker.expiresAt)))||!o)return null;return{apiOrigin:c,orgId:e.orgId,deviceId:e.deviceId,displayName:e.displayName,registeredAt:e.registeredAt,...e.handsSlots!==void 0?{handsSlots:e.handsSlots}:{},...e.worker!==void 0?{worker:e.worker}:{},roots:o}}function Ce(r){return{version:A,apiOrigin:r.apiOrigin,orgId:r.orgId,deviceId:r.deviceId,devicePublicKey:r.devicePublicKey,displayName:r.displayName,registeredAt:r.registeredAt,...r.handsSlots!==void 0?{handsSlots:r.handsSlots}:{},...r.worker!==void 0?{worker:r.worker}:{},roots:r.roots.map((e)=>({id:e.id,label:e.label,path:e.path,pathFingerprint:e.pathFingerprint,permissions:{read:e.permissions.read,write:e.permissions.write,execute:e.permissions.execute,discover_environment:e.permissions.discover_environment,expose_mcp:e.permissions.expose_mcp}})),credentialStorage:P}}function X(r){if(!r||typeof r!=="object"||Array.isArray(r))return null;let e=r;if(!J(e,["version","apiOrigin","orgId","deviceId","devicePublicKey","displayName","registeredAt","roots","credentialStorage"],["handsSlots","worker"]))return null;let o=Y(e);if(!o||e.version!==A||e.credentialStorage!==P||!_(e.devicePublicKey))return null;return{version:A,...o,devicePublicKey:e.devicePublicKey,credentialStorage:P}}function Te(r){return new TextEncoder().encode(`${Ee}${JSON.stringify(Ce(r))}`)}function Ue(r){let e=Buffer.from(r,"base64url");return me({format:"jwk",key:{kty:"EC",crv:"P-256",x:e.subarray(1,33).toString("base64url"),y:e.subarray(33,65).toString("base64url")}})}function Me(r){let e;try{e=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(r))}catch{throw new l("invalid_binding")}if(!e||typeof e!=="object"||Array.isArray(e))throw new l("invalid_binding");let o=e;if(!J(o,["version","state","signature"])||o.version!==Pe||typeof o.signature!=="string"||!/^[A-Za-z0-9_-]{10,128}$/.test(o.signature))throw new l("invalid_binding");let c=X(o.state);if(!c)throw new l("invalid_binding");let d=!1;try{d=Se("sha256",Te(c),Ue(c.devicePublicKey),Buffer.from(o.signature,"base64url"))}catch{d=!1}if(!d)throw new l("invalid_binding");return c}function je(r){let{credentialStorage:e,...o}=r;return o}function xr(r=Er(),e={}){let o=E(r),c=e.proofStore??e.credentialStore??V(),d=c.loadBinding();if(!d){if(o&&typeof o==="object"&&!Array.isArray(o)&&Ve(o))return null;if(o!==null)throw new l("invalid_binding");return null}let p=Me(d),W=c.loadPublicKey();if(c.privateKeyIsNonExtractable(),W!==p.devicePublicKey)throw new l("invalid_public_key");let R=X(o);if(e.repair!==!1&&(!R||JSON.stringify(R)!==JSON.stringify(p)))Ne(r,p);return je(p)}function Ve(r){let e=r,o=Y(r);if(!o)return null;if(e.version===2){if(typeof e.deviceCredential!=="string"||!/^(?:reason|ara)_dev_/.test(e.deviceCredential)||e.deviceCredential.length>4096)return null;return{state:o,credentialSource:"plaintext-v2"}}if(e.version!==3||e.credentialStorage!=="macos-keychain-v1"||"deviceCredential"in e)return null;return{state:o,credentialSource:"keychain-v3"}}function et(r=xe()){let e=E(r);if(!e||typeof e!=="object")return null;let o=e;if(o.version!==1||typeof o.pid!=="number"||!Number.isInteger(o.pid)||!["starting","connected","stopped","error"].includes(o.state??"")||typeof o.startedAt!=="string"||o.lastHeartbeatAt!==void 0&&typeof o.lastHeartbeatAt!=="string"||o.lastUsedAt!==void 0&&typeof o.lastUsedAt!=="string"||o.organizationId!==void 0&&typeof o.organizationId!=="string"||o.organizationName!==void 0&&typeof o.organizationName!=="string"||o.organizationSlug!==void 0&&typeof o.organizationSlug!=="string"||o.error!==void 0&&typeof o.error!=="string"||o.reconnectingSince!==void 0&&typeof o.reconnectingSince!=="string"||o.workspace!==void 0&&typeof o.workspace!=="string")return null;if(o.permissionRecovery!==void 0&&!G(o.permissionRecovery))delete o.permissionRecovery;return o}var It=1;function Be(r=Er()){return m(w(r),"local-device.proxy.json")}function j(r=Be()){let e=E(r);if(!e||typeof e!=="object"||Array.isArray(e))return null;let o=e;if(o.version!==It||typeof o.url!=="string"||o.url.length===0||o.caFile!==void 0&&(typeof o.caFile!=="string"||!Ae(o.caFile)))return null;return{version:It,url:o.url,...o.caFile?{caFile:o.caFile}:{}}}
5
+ export{l,Rt,Fe,Sr,Ot,Er,xr,et,It,j};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{rt,g,nt}from"./vm-hands-entry-lite-5p5h1eng.js";import{chmodSync as Q,existsSync as C,mkdirSync as Z,readlinkSync as S,readFileSync as b,renameSync as nn,unlinkSync as tn,writeFileSync as en}from"fs";import{homedir as u}from"os";import{basename as _,dirname as h,isAbsolute as p,join as o,normalize as A,relative as O,resolve as N}from"path";var c=3,P=1,D=2,x=1,T=1,L="Reason may read and write files and run commands in this signed-in OS account, subject to saved restrictions and operating system permissions.",M="Reason may later execute on this computer inside a Reason sandbox, limited to folders explicitly attached by the user.",F=[M,"Ara may later execute on this computer inside an Ara sandbox, limited to folders explicitly attached by the user."];function B(n){return typeof n==="string"&&F.includes(n)}var U=["future_device","updates_only","cli_only"];function f(n){return typeof n==="string"&&U.some((t)=>t===n)}function V(n=process.env,t=u()){return n.XDG_CONFIG_HOME?.trim()||o(t,".config")}function Ir(n=process.env,t=u()){let r=g({env:n}),e=V(n,t);return o(e,nt(e).state==="kept"?"ara":"reason",...r==="staging"?["staging"]:[],"installation.json")}function a(n){return typeof n==="string"&&n.trim().length>0}var K=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function z(n){return typeof n==="string"&&K.test(n)}function l(n){return a(n)&&p(n)&&A(n)===n}function y(n){if(!n||typeof n!=="object"||Array.isArray(n))return!1;let t=n;return l(t.path)&&(t.role==="launcher"&&(t.kind==="file"||t.kind==="symlink")||t.role==="worker_root"&&t.kind==="directory"||t.role==="alias"&&t.kind==="symlink"&&l(t.target))}function m(n){return n==="staging"?["reason-staging","ara-staging"]:["reason","ara"]}function Cn(n){let t=n.owned_paths.filter((e)=>e.role==="launcher").map((e)=>e.path),[r]=m(n.channel);return t.find((e)=>_(e)===r)??t[0]??null}function I(n){let[t,r]=m(n.channel==="staging"?"staging":"production"),e=[[t,r],[r,t]];return n.owned_paths?.every((i)=>i.role!=="alias"||n.installer==="shell"&&e.some(([s,R])=>i.path===o(n.install_dir,s)&&i.target===o(n.install_dir,R))&&n.owned_paths?.some((s)=>s.role==="launcher"&&s.path===i.target))??!1}function d(n,t){try{return N(h(n),S(n))===t}catch{return!1}}function Dr(n){let t=_(n),r=t==="ara"?"reason":t==="ara-staging"?"reason-staging":null;if(!r)return n;let e=o(h(n),r);return d(e,n)||d(n,e)?e:n}function w(n,t){let r=O(n,t);return r.length>0&&!r.startsWith("..")&&!p(r)}function E(n){if(n===null)return!0;if(!n||typeof n!=="object"||Array.isArray(n))return!1;let t=n;return(t.kind==="shell_profile"||t.kind==="windows_user_path")&&a(t.location)&&a(t.value)&&(typeof t.added_by_installer==="boolean"||typeof t.added_by_ara==="boolean")&&(t.added_by_installer===void 0||typeof t.added_by_installer==="boolean")&&(t.added_by_ara===void 0||typeof t.added_by_ara==="boolean")}function k(n,t){if(t===null)return n==="cli_only";if(!t||typeof t!=="object"||Array.isArray(t))return!1;let r=t;if(r.version!==x||!a(r.recorded_at))return!1;if(n==="future_device")return r.decision==="authorized"&&B(r.scope);return r.scope===null&&r.decision===(n==="updates_only"?"ask":"disabled")}function G(n){if(!n||typeof n!=="object"||Array.isArray(n))return null;let t=n;if(t.schema_version!==P||!rt.includes(t.channel)||t.install_method!=="curl"||t.installer!=="shell"&&t.installer!=="powershell"||!a(t.installed_at)||!a(t.version)||!a(t.target)||!l(t.install_dir)||!Array.isArray(t.owned_paths)||!t.owned_paths.every(y)||!t.owned_paths.every((r)=>w(t.install_dir,r.path))||!I(t)||!E(t.path_entry))return null;return{...t,schema_version:c,installation_id:null,background_mode:"cli_only",device_consent:null}}function j(n){if(!n||typeof n!=="object"||Array.isArray(n))return null;let t=n;if(t.schema_version!==D||!v(t)||!f(t.background_mode)||!k(t.background_mode,t.device_consent))return null;return{...t,schema_version:c,installation_id:null}}function v(n){return rt.includes(n.channel)&&(n.install_method==="curl"&&(n.installer==="shell"||n.installer==="powershell")||n.install_method==="desktop"&&n.installer==="desktop"&&Array.isArray(n.owned_paths)&&n.owned_paths.length===0&&n.path_entry===null)&&a(n.installed_at)&&a(n.version)&&a(n.target)&&l(n.install_dir)&&Array.isArray(n.owned_paths)&&n.owned_paths.every(y)&&n.owned_paths.every((t)=>w(n.install_dir,t.path))&&I(n)&&E(n.path_entry)}function H(n){let t=G(n);if(t)return t;let r=j(n);if(r)return r;if(!n||typeof n!=="object"||Array.isArray(n))return null;let e=n;if(e.schema_version!==c||!z(e.installation_id)||!v(e)||!f(e.background_mode)||!k(e.background_mode,e.device_consent)||e.desktop_account_access!==void 0&&(e.desktop_account_access===null||typeof e.desktop_account_access!=="object"||Array.isArray(e.desktop_account_access)||e.desktop_account_access.version!==T||e.desktop_account_access.scope!==L||!a(e.desktop_account_access.recorded_at)||!Number.isFinite(Date.parse(e.desktop_account_access.recorded_at))))return null;return e}function An(n=Ir()){if(!C(n))return null;try{return H(JSON.parse(b(n,"utf8")))}catch{return null}}export{Ir,Cn,Dr,An};
2
+ import{nt,g,it}from"./vm-hands-entry-lite-ckv17tn8.js";import{chmodSync as Q,existsSync as C,mkdirSync as Z,readlinkSync as S,readFileSync as b,renameSync as nn,unlinkSync as tn,writeFileSync as en}from"fs";import{homedir as u}from"os";import{basename as _,dirname as h,isAbsolute as p,join as o,normalize as A,relative as O,resolve as N}from"path";var c=3,P=1,D=2,x=1,T=1,L="Reason may read and write files and run commands in this signed-in OS account, subject to saved restrictions and operating system permissions.",M="Reason may later execute on this computer inside a Reason sandbox, limited to folders explicitly attached by the user.",F=[M,"Ara may later execute on this computer inside an Ara sandbox, limited to folders explicitly attached by the user."];function B(n){return typeof n==="string"&&F.includes(n)}var U=["future_device","updates_only","cli_only"];function f(n){return typeof n==="string"&&U.some((t)=>t===n)}function V(n=process.env,t=u()){return n.XDG_CONFIG_HOME?.trim()||o(t,".config")}function Nr(n=process.env,t=u()){let r=g({env:n}),e=V(n,t);return o(e,it(e).state==="kept"?"ara":"reason",...r==="staging"?["staging"]:[],"installation.json")}function a(n){return typeof n==="string"&&n.trim().length>0}var K=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function z(n){return typeof n==="string"&&K.test(n)}function l(n){return a(n)&&p(n)&&A(n)===n}function y(n){if(!n||typeof n!=="object"||Array.isArray(n))return!1;let t=n;return l(t.path)&&(t.role==="launcher"&&(t.kind==="file"||t.kind==="symlink")||t.role==="worker_root"&&t.kind==="directory"||t.role==="alias"&&t.kind==="symlink"&&l(t.target))}function m(n){return n==="staging"?["reason-staging","ara-staging"]:["reason","ara"]}function Pn(n){let t=n.owned_paths.filter((e)=>e.role==="launcher").map((e)=>e.path),[r]=m(n.channel);return t.find((e)=>_(e)===r)??t[0]??null}function I(n){let[t,r]=m(n.channel==="staging"?"staging":"production"),e=[[t,r],[r,t]];return n.owned_paths?.every((i)=>i.role!=="alias"||n.installer==="shell"&&e.some(([s,R])=>i.path===o(n.install_dir,s)&&i.target===o(n.install_dir,R))&&n.owned_paths?.some((s)=>s.role==="launcher"&&s.path===i.target))??!1}function d(n,t){try{return N(h(n),S(n))===t}catch{return!1}}function Lr(n){let t=_(n),r=t==="ara"?"reason":t==="ara-staging"?"reason-staging":null;if(!r)return n;let e=o(h(n),r);return d(e,n)||d(n,e)?e:n}function w(n,t){let r=O(n,t);return r.length>0&&!r.startsWith("..")&&!p(r)}function E(n){if(n===null)return!0;if(!n||typeof n!=="object"||Array.isArray(n))return!1;let t=n;return(t.kind==="shell_profile"||t.kind==="windows_user_path")&&a(t.location)&&a(t.value)&&(typeof t.added_by_installer==="boolean"||typeof t.added_by_ara==="boolean")&&(t.added_by_installer===void 0||typeof t.added_by_installer==="boolean")&&(t.added_by_ara===void 0||typeof t.added_by_ara==="boolean")}function k(n,t){if(t===null)return n==="cli_only";if(!t||typeof t!=="object"||Array.isArray(t))return!1;let r=t;if(r.version!==x||!a(r.recorded_at))return!1;if(n==="future_device")return r.decision==="authorized"&&B(r.scope);return r.scope===null&&r.decision===(n==="updates_only"?"ask":"disabled")}function G(n){if(!n||typeof n!=="object"||Array.isArray(n))return null;let t=n;if(t.schema_version!==P||!nt.includes(t.channel)||t.install_method!=="curl"||t.installer!=="shell"&&t.installer!=="powershell"||!a(t.installed_at)||!a(t.version)||!a(t.target)||!l(t.install_dir)||!Array.isArray(t.owned_paths)||!t.owned_paths.every(y)||!t.owned_paths.every((r)=>w(t.install_dir,r.path))||!I(t)||!E(t.path_entry))return null;return{...t,schema_version:c,installation_id:null,background_mode:"cli_only",device_consent:null}}function j(n){if(!n||typeof n!=="object"||Array.isArray(n))return null;let t=n;if(t.schema_version!==D||!v(t)||!f(t.background_mode)||!k(t.background_mode,t.device_consent))return null;return{...t,schema_version:c,installation_id:null}}function v(n){return nt.includes(n.channel)&&(n.install_method==="curl"&&(n.installer==="shell"||n.installer==="powershell")||n.install_method==="desktop"&&n.installer==="desktop"&&Array.isArray(n.owned_paths)&&n.owned_paths.length===0&&n.path_entry===null)&&a(n.installed_at)&&a(n.version)&&a(n.target)&&l(n.install_dir)&&Array.isArray(n.owned_paths)&&n.owned_paths.every(y)&&n.owned_paths.every((t)=>w(n.install_dir,t.path))&&I(n)&&E(n.path_entry)}function H(n){let t=G(n);if(t)return t;let r=j(n);if(r)return r;if(!n||typeof n!=="object"||Array.isArray(n))return null;let e=n;if(e.schema_version!==c||!z(e.installation_id)||!v(e)||!f(e.background_mode)||!k(e.background_mode,e.device_consent)||e.desktop_account_access!==void 0&&(e.desktop_account_access===null||typeof e.desktop_account_access!=="object"||Array.isArray(e.desktop_account_access)||e.desktop_account_access.version!==T||e.desktop_account_access.scope!==L||!a(e.desktop_account_access.recorded_at)||!Number.isFinite(Date.parse(e.desktop_account_access.recorded_at))))return null;return e}function Tn(n=Nr()){if(!C(n))return null;try{return H(JSON.parse(b(n,"utf8")))}catch{return null}}export{Nr,Pn,Lr,Tn};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{qe,ot}from"./vm-hands-entry-lite-8evzzh7v.js";import{at}from"./vm-hands-entry-lite-8bzqc4xa.js";import{io,le,Fr,st,oo}from"./vm-hands-entry-lite-wf7ksh4e.js";import{E}from"./vm-hands-entry-lite-0n2f3kx7.js";import{a,Ut}from"./vm-hands-entry-lite-dkcm3hyn.js";import{spawnSync as H}from"child_process";import{dirname as w}from"path";import{spawn as A}from"child_process";import{accessSync as _,constants as v}from"fs";import{basename as C,join as O}from"path";var l=null;function S(e){if(l===e)l=null;if(e.exitCode===null&&e.signalCode===null)e.kill("SIGTERM")}var Mr=(e,t)=>{if(l)S(l);let s=O(e,io);try{_(s,v.X_OK)}catch{return()=>{}}let n;try{n=A(s,["--app",e,"--name",C(e,".app"),"--permission",t==="screen"?"screen_recording":"accessibility"],{detached:!0,stdio:"ignore"})}catch{return()=>{}}return n.on("error",()=>{if(l===n)l=null}),n.once("exit",()=>{if(l===n)l=null}),n.unref(),l=n,()=>S(n)};import{chmodSync as ne,existsSync as se,mkdirSync as re,readFileSync as D,realpathSync as ie,renameSync as oe,statSync as j,writeFileSync as ae}from"fs";import{dirname as de,isAbsolute as G,join as N,resolve as T,sep as b}from"path";function F(e=a()){return N(Ut(e),"reason","protected-path-grants.json")}var f=null;function L(e){let t=JSON.parse(e);if(!Array.isArray(t?.grants))return[];return t.grants.flatMap((s)=>{let n=s;return n&&typeof n.path==="string"&&G(n.path)&&(n.kind==="file"||n.kind==="folder")&&typeof n.grantedAt==="number"?[{path:n.path,kind:n.kind,grantedAt:n.grantedAt}]:[]})}function y(e=F()){try{let{mtimeMs:t}=j(e);if(f&&f.file===e&&f.mtimeMs===t)return f.grants;let s=L(D(e,"utf8"));return f={file:e,mtimeMs:t,grants:s},s}catch{return[]}}function W(e,t){return e.kind==="file"?t===e.path:t===e.path||t.startsWith(`${e.path}${b}`)}function U(e,t){let s=T(e);return y(t).some((n)=>W(n,s))}function Ki(e,t){return E(e)&&!U(e,t)}function Ji(e,t,s){let n=t?"file-read* file-write*":"file-read*";return y(s).filter((r)=>r.path===e||r.path.startsWith(`${e}${b}`)).map((r)=>`(allow ${n} (${r.kind==="file"?"literal":"subpath"} ${JSON.stringify(r.path)}))`)}var P="x-apple.systempreferences:com.apple.preference.security",J="curl -fsSL https://reasonmachines.com/install.sh | bash",q=180000,B=2000;var k={screen:{label:"Screen & System Audio Recording",purpose:"desktop video, computer-use screenshots",level:"required",pane:`${P}?Privacy_ScreenCapture`},accessibility:{label:"Accessibility",purpose:"computer-use clicks and typing, desktop input",level:"required",pane:`${P}?Privacy_Accessibility`},disk:{label:"Full Disk Access",purpose:"Sessions in Desktop, Documents, Downloads, iCloud Drive and Mail",level:"recommended",pane:`${P}?Privacy_AllFiles`}};function R(e){return e.executable}function K(e,t){if(e==="computer_use_identity_missing")return`Reason's background identity is not installed (${e}); reinstall Reason: ${J}`;if(e==="computer_use_identity_outdated")return`Reason's background identity is outdated (${Fr(t)??"unknown"}; this CLI is ${at}) (${e}); \`reason update\` installs this release's`;return`Reason's background identity cannot run computer use for this CLI (${e}); run the installed \`reason\``}function Ro(e=a()){let t=st(e);if(t.length>0)return{state:"ready",path:w(w(w(t[0]))),prefix:t};let s=oo(t,e)??"computer_use_identity_unavailable";return{state:s,path:le(e),detail:K(s,e)}}function V(){return{identity:()=>Ro(),grants:(e)=>qe(e),request:(e,t)=>ot(e,t),worker:async()=>(await import("./status-e7r62q4e.js")).connectionMacState(),open:(e)=>{H("/usr/bin/open",e,{stdio:"ignore",timeout:1e4})},tile:Mr,restartConnection:async()=>(await import("./connect-cli-m8xafyn5.js")).restartConnection(),sleep:(e)=>new Promise((t)=>setTimeout(t,e)),now:()=>Date.now()}}function M(e,t,s){if(e.state!=="ready"||!t)return"unknown";return t[s]?"granted":"missing"}async function Oo(e){let t=e.identity(),s=t.state==="ready"?await e.grants(t.prefix):null,n=await e.worker(),r=n?R(n):null,i=!r||n?.full_disk_access==="unknown"?"unknown":n?.full_disk_access==="granted"?"granted":"missing",c=(u,d,o)=>{let{label:p,purpose:h,level:m}=k[u];return{id:u,label:p,purpose:h,level:m,state:d,holder:o}};return{identity:{state:t.state,path:t.path,detail:t.state==="ready"?null:t.detail},worker_detail:r?null:"Full Disk Access is read from this computer's running worker; `reason connect` starts it.",permissions:[c("screen",M(t,s,"screen"),t.path),c("accessibility",M(t,s,"accessibility"),t.path),c("disk",i,r)]}}function fs(e){let t=e.identity.state==="ready"?null:e.identity.state,s=e.permissions.filter((i)=>i.state==="granted").length,n=[...t?[t]:[],...e.permissions.filter((i)=>i.state!=="granted"&&!(t&&i.id!=="disk")).map((i)=>`${i.label} ${i.state}`)],r=!t&&e.permissions.some((i)=>i.state==="missing");return`Permissions: ${s} of ${e.permissions.length}${n.length>0?` (${n.join(", ")})`:""}`+(r?" \u2014 reason permissions allow":n.length>0?" \u2014 reason permissions":"")}async function x(e,t){let s=t.now()+q;for(;;){if(await e())return!0;if(t.now()>=s)return!1;await t.sleep(B)}}async function ms(e,t){let s=t.host??V(),{io:n}=t,r=await Oo(s),i=r.permissions.filter((o)=>e.includes(o.id)&&o.state!=="granted");if(i.length===0)return n.stdout.write(`Reason permissions: ${e.map((o)=>k[o].label).join(", ")} already allowed.
2
+ import{ze,st}from"./vm-hands-entry-lite-eqgj4acy.js";import{ct}from"./vm-hands-entry-lite-ggj69hbj.js";import{so,le,Ur,at,ao}from"./vm-hands-entry-lite-1xtpeh3x.js";import{E}from"./vm-hands-entry-lite-pgb514h0.js";import{a,qt}from"./vm-hands-entry-lite-89z488gz.js";import{spawnSync as H}from"child_process";import{dirname as w}from"path";import{spawn as A}from"child_process";import{accessSync as _,constants as v}from"fs";import{basename as C,join as O}from"path";var l=null;function S(e){if(l===e)l=null;if(e.exitCode===null&&e.signalCode===null)e.kill("SIGTERM")}var Br=(e,t)=>{if(l)S(l);let s=O(e,so);try{_(s,v.X_OK)}catch{return()=>{}}let n;try{n=A(s,["--app",e,"--name",C(e,".app"),"--permission",t==="screen"?"screen_recording":"accessibility"],{detached:!0,stdio:"ignore"})}catch{return()=>{}}return n.on("error",()=>{if(l===n)l=null}),n.once("exit",()=>{if(l===n)l=null}),n.unref(),l=n,()=>S(n)};import{chmodSync as ne,existsSync as se,mkdirSync as re,readFileSync as D,realpathSync as ie,renameSync as oe,statSync as j,writeFileSync as ae}from"fs";import{dirname as de,isAbsolute as G,join as N,resolve as T,sep as b}from"path";function F(e=a()){return N(qt(e),"reason","protected-path-grants.json")}var f=null;function L(e){let t=JSON.parse(e);if(!Array.isArray(t?.grants))return[];return t.grants.flatMap((s)=>{let n=s;return n&&typeof n.path==="string"&&G(n.path)&&(n.kind==="file"||n.kind==="folder")&&typeof n.grantedAt==="number"?[{path:n.path,kind:n.kind,grantedAt:n.grantedAt}]:[]})}function y(e=F()){try{let{mtimeMs:t}=j(e);if(f&&f.file===e&&f.mtimeMs===t)return f.grants;let s=L(D(e,"utf8"));return f={file:e,mtimeMs:t,grants:s},s}catch{return[]}}function W(e,t){return e.kind==="file"?t===e.path:t===e.path||t.startsWith(`${e.path}${b}`)}function U(e,t){let s=T(e);return y(t).some((n)=>W(n,s))}function Zi(e,t){return E(e)&&!U(e,t)}function Xi(e,t,s){let n=t?"file-read* file-write*":"file-read*";return y(s).filter((r)=>r.path===e||r.path.startsWith(`${e}${b}`)).map((r)=>`(allow ${n} (${r.kind==="file"?"literal":"subpath"} ${JSON.stringify(r.path)}))`)}var P="x-apple.systempreferences:com.apple.preference.security",J="curl -fsSL https://reasonmachines.com/install.sh | bash",q=180000,B=2000;var k={screen:{label:"Screen & System Audio Recording",purpose:"desktop video, computer-use screenshots",level:"required",pane:`${P}?Privacy_ScreenCapture`},accessibility:{label:"Accessibility",purpose:"computer-use clicks and typing, desktop input",level:"required",pane:`${P}?Privacy_Accessibility`},disk:{label:"Full Disk Access",purpose:"Sessions in Desktop, Documents, Downloads, iCloud Drive and Mail",level:"recommended",pane:`${P}?Privacy_AllFiles`}};function R(e){return e.executable}function K(e,t){if(e==="computer_use_identity_missing")return`Reason's background identity is not installed (${e}); reinstall Reason: ${J}`;if(e==="computer_use_identity_outdated")return`Reason's background identity is outdated (${Ur(t)??"unknown"}; this CLI is ${ct}) (${e}); \`reason update\` installs this release's`;return`Reason's background identity cannot run computer use for this CLI (${e}); run the installed \`reason\``}function Io(e=a()){let t=at(e);if(t.length>0)return{state:"ready",path:w(w(w(t[0]))),prefix:t};let s=ao(t,e)??"computer_use_identity_unavailable";return{state:s,path:le(e),detail:K(s,e)}}function V(){return{identity:()=>Io(),grants:(e)=>ze(e),request:(e,t)=>st(e,t),worker:async()=>(await import("./status-4chy5g03.js")).connectionMacState(),open:(e)=>{H("/usr/bin/open",e,{stdio:"ignore",timeout:1e4})},tile:Br,restartConnection:async()=>(await import("./connect-cli-kwxy8nva.js")).restartConnection(),sleep:(e)=>new Promise((t)=>setTimeout(t,e)),now:()=>Date.now()}}function M(e,t,s){if(e.state!=="ready"||!t)return"unknown";return t[s]?"granted":"missing"}async function Do(e){let t=e.identity(),s=t.state==="ready"?await e.grants(t.prefix):null,n=await e.worker(),r=n?R(n):null,i=!r||n?.full_disk_access==="unknown"?"unknown":n?.full_disk_access==="granted"?"granted":"missing",c=(u,d,o)=>{let{label:p,purpose:h,level:m}=k[u];return{id:u,label:p,purpose:h,level:m,state:d,holder:o}};return{identity:{state:t.state,path:t.path,detail:t.state==="ready"?null:t.detail},worker_detail:r?null:"Full Disk Access is read from this computer's running worker; `reason connect` starts it.",permissions:[c("screen",M(t,s,"screen"),t.path),c("accessibility",M(t,s,"accessibility"),t.path),c("disk",i,r)]}}function ys(e){let t=e.identity.state==="ready"?null:e.identity.state,s=e.permissions.filter((i)=>i.state==="granted").length,n=[...t?[t]:[],...e.permissions.filter((i)=>i.state!=="granted"&&!(t&&i.id!=="disk")).map((i)=>`${i.label} ${i.state}`)],r=!t&&e.permissions.some((i)=>i.state==="missing");return`Permissions: ${s} of ${e.permissions.length}${n.length>0?` (${n.join(", ")})`:""}`+(r?" \u2014 reason permissions allow":n.length>0?" \u2014 reason permissions":"")}async function x(e,t){let s=t.now()+q;for(;;){if(await e())return!0;if(t.now()>=s)return!1;await t.sleep(B)}}async function bs(e,t){let s=t.host??V(),{io:n}=t,r=await Do(s),i=r.permissions.filter((o)=>e.includes(o.id)&&o.state!=="granted");if(i.length===0)return n.stdout.write(`Reason permissions: ${e.map((o)=>k[o].label).join(", ")} already allowed.
3
3
  `),0;let c=!1,u=!1,d=s.identity();for(let o of i){let{label:p,pane:h}=k[o.id];if(o.id!=="disk"){if(d.state!=="ready"){if(!c)n.stderr.write(`Reason permissions: ${d.detail}
4
4
  `);c=!0;continue}let g=o.id;await s.request(d.prefix,g),s.open([h]);let I=s.tile(d.path,g);if(n.stdout.write(`Allow Reason in System Settings > Privacy & Security > ${p}.
5
5
  `),!t.wait)continue;if(n.stdout.write(`Waiting for it (Ctrl-C to stop)\u2026
@@ -11,4 +11,4 @@ import{qe,ot}from"./vm-hands-entry-lite-8evzzh7v.js";import{at}from"./vm-hands-e
11
11
  `),await x(async()=>(await s.worker())?.full_disk_access==="granted",s))n.stdout.write(`Full Disk Access: granted.
12
12
  `);else n.stderr.write("Full Disk Access is not reported yet. If you allowed it, `reason connect` restarts the worker with it.\n"),c=!0}if(u)try{if(await s.restartConnection())n.stdout.write(`This computer's Reason connection restarted to use them.
13
13
  `)}catch(o){n.stderr.write(`This computer's Reason connection uses them after it restarts (\`reason connect\`): ${o instanceof Error?o.message:String(o)}
14
- `)}return c?1:0}export{Ki,Ji,Mr,Ro,Oo,fs,ms};
14
+ `)}return c?1:0}export{Zi,Xi,Br,Io,Do,ys,bs};