@reason-machines/cli-linux-arm64-musl 0.2.349 → 0.2.350

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 (79) hide show
  1. package/bin/ara +1 -1
  2. package/bin/vm-hands/api-credentials-4yhng00z.js +2 -0
  3. package/bin/vm-hands/api-gnear3va.js +2 -0
  4. package/bin/vm-hands/{ask-relay-qr4gmz44.js → ask-relay-hwzknt2q.js} +2 -2
  5. package/bin/vm-hands/connect-cli-jfva6b2v.js +2 -0
  6. package/bin/vm-hands/{custom-endpoint-device-syw4d5k4.js → custom-endpoint-device-j3e3zjd5.js} +1 -1
  7. package/bin/vm-hands/desktop-account-gcysz0m3.js +2 -0
  8. package/bin/vm-hands/{device-workspace-s49yhsk7.js → device-workspace-7yg5x68n.js} +1 -1
  9. package/bin/vm-hands/hands-worker-source-hbp5n31r.js +2 -0
  10. package/bin/vm-hands/{index-t1h1wd8g.js → index-swa20ch8.js} +1 -1
  11. package/bin/vm-hands/local-automation-868gxebm.js +2 -0
  12. package/bin/vm-hands/local-capabilities-r7gav8cj.js +2 -0
  13. package/bin/vm-hands/local-desktop-users-pccz3sz9.js +2 -0
  14. package/bin/vm-hands/local-display-mac-gj72gkfb.js +2 -0
  15. package/bin/vm-hands/local-display-session-ghgn5fj9.js +2 -0
  16. package/bin/vm-hands/local-pty-session-zen80k1k.js +2 -0
  17. package/bin/vm-hands/{network-contract-8d4bpy3e.js → network-contract-rm9x646s.js} +1 -1
  18. package/bin/vm-hands/package-1e3w44ve.js +2 -0
  19. package/bin/vm-hands/permissions-86q0dte2.js +2 -0
  20. package/bin/vm-hands/{reason-hands-protocol-k12eme4q.js → reason-hands-protocol-3z7bas06.js} +1 -1
  21. package/bin/vm-hands/{status-xs5bh7hf.js → status-ydtsxbg8.js} +2 -2
  22. package/bin/vm-hands/version-n5jstve3.js +2 -0
  23. package/bin/vm-hands/{vm-hands-entry-lite-wgjqxtxj.js → vm-hands-entry-lite-09depjka.js} +2 -2
  24. package/bin/vm-hands/{vm-hands-entry-lite-7qg63rj8.js → vm-hands-entry-lite-0fkstes8.js} +2 -2
  25. package/bin/vm-hands/{vm-hands-entry-lite-1wy28sjt.js → vm-hands-entry-lite-15q5nc6y.js} +1 -1
  26. package/bin/vm-hands/vm-hands-entry-lite-1tas4fnc.js +540 -0
  27. package/bin/vm-hands/{vm-hands-entry-lite-kt418g2w.js → vm-hands-entry-lite-33ttamma.js} +2 -2
  28. package/bin/vm-hands/{vm-hands-entry-lite-h1642n10.js → vm-hands-entry-lite-3dy1s2gz.js} +2 -2
  29. package/bin/vm-hands/{vm-hands-entry-lite-q756n4nh.js → vm-hands-entry-lite-3dydfh10.js} +1 -1
  30. package/bin/vm-hands/{vm-hands-entry-lite-9dx3at21.js → vm-hands-entry-lite-5b29hq7h.js} +2 -2
  31. package/bin/vm-hands/{vm-hands-entry-lite-m16qf0yy.js → vm-hands-entry-lite-66g8nb0j.js} +1 -1
  32. package/bin/vm-hands/{vm-hands-entry-lite-0jar357h.js → vm-hands-entry-lite-6f5eypjm.js} +2 -2
  33. package/bin/vm-hands/{vm-hands-entry-lite-1xjtcxpn.js → vm-hands-entry-lite-6qfax5p2.js} +1 -1
  34. package/bin/vm-hands/{vm-hands-entry-lite-289bc9v7.js → vm-hands-entry-lite-84d59wrf.js} +1 -1
  35. package/bin/vm-hands/{vm-hands-entry-lite-449p9dx7.js → vm-hands-entry-lite-9e7wr5a4.js} +3 -3
  36. package/bin/vm-hands/{vm-hands-entry-lite-svs618mf.js → vm-hands-entry-lite-bbdzz51x.js} +2 -2
  37. package/bin/vm-hands/{vm-hands-entry-lite-0wyjnvjz.js → vm-hands-entry-lite-beannz0s.js} +2 -2
  38. package/bin/vm-hands/{vm-hands-entry-lite-yeahy7rk.js → vm-hands-entry-lite-c9wp99nr.js} +2 -2
  39. package/bin/vm-hands/{vm-hands-entry-lite-1jhry648.js → vm-hands-entry-lite-dys7am1h.js} +1 -1
  40. package/bin/vm-hands/{vm-hands-entry-lite-7ba3nhgv.js → vm-hands-entry-lite-dyy62gt3.js} +2 -2
  41. package/bin/vm-hands/{vm-hands-entry-lite-pnkfgnqz.js → vm-hands-entry-lite-dztw7y81.js} +1 -1
  42. package/bin/vm-hands/{vm-hands-entry-lite-tfpebnar.js → vm-hands-entry-lite-fs3ahdgg.js} +1 -1
  43. package/bin/vm-hands/{vm-hands-entry-lite-8ynztq9j.js → vm-hands-entry-lite-gcn3rmz6.js} +1 -1
  44. package/bin/vm-hands/{vm-hands-entry-lite-x6jqyxkx.js → vm-hands-entry-lite-jfwz0br7.js} +2 -2
  45. package/bin/vm-hands/{vm-hands-entry-lite-2xh7sjs0.js → vm-hands-entry-lite-k17ntg9v.js} +2 -2
  46. package/bin/vm-hands/{vm-hands-entry-lite-knfh7w3j.js → vm-hands-entry-lite-mybm2kyz.js} +2 -2
  47. package/bin/vm-hands/{vm-hands-entry-lite-k2cvr710.js → vm-hands-entry-lite-nbtpm59m.js} +71 -168
  48. package/bin/vm-hands/{vm-hands-entry-lite-mhsv58hw.js → vm-hands-entry-lite-nd1k2jz9.js} +1 -1
  49. package/bin/vm-hands/{vm-hands-entry-lite-k469tezz.js → vm-hands-entry-lite-nvhzj5b0.js} +1 -1
  50. package/bin/vm-hands/{vm-hands-entry-lite-36xzwsxn.js → vm-hands-entry-lite-qf01e5f1.js} +2 -2
  51. package/bin/vm-hands/{vm-hands-entry-lite-k2e3q5qj.js → vm-hands-entry-lite-tdgbgcer.js} +1 -1
  52. package/bin/vm-hands/{vm-hands-entry-lite-gt5pkv4h.js → vm-hands-entry-lite-tj1y61bg.js} +1 -1
  53. package/bin/vm-hands/{vm-hands-entry-lite-f66d7y5a.js → vm-hands-entry-lite-vekw2mhw.js} +3 -3
  54. package/bin/vm-hands/{vm-hands-entry-lite-wmxksawm.js → vm-hands-entry-lite-wpx6sg6d.js} +2 -2
  55. package/bin/vm-hands/{vm-hands-entry-lite-pa111vpq.js → vm-hands-entry-lite-xhjbc3e4.js} +2 -2
  56. package/bin/vm-hands/{vm-hands-entry-lite-z0wwfy97.js → vm-hands-entry-lite-xmxpyx3x.js} +2 -2
  57. package/bin/vm-hands/vm-hands-entry-lite.js +1 -1
  58. package/bin/vm-hands/{vm-hands-executor-6q1n7hpe.js → vm-hands-executor-aqsxpvhb.js} +1 -1
  59. package/bin/vm-hands/vm-hands-op-runner-ab3h5v2e.js +2 -0
  60. package/bin/vm-hands/{vm-hands-runtime-k21dbztp.js → vm-hands-runtime-6wdanp9f.js} +3 -3
  61. package/bin/vm-hands/worker-sandbox-yw24sxyp.js +2 -0
  62. package/package.json +1 -1
  63. package/bin/vm-hands/api-credentials-d34gw13p.js +0 -2
  64. package/bin/vm-hands/api-t5zxz49k.js +0 -2
  65. package/bin/vm-hands/connect-cli-rknch17k.js +0 -2
  66. package/bin/vm-hands/desktop-account-pm3zxjjt.js +0 -2
  67. package/bin/vm-hands/hands-worker-source-0ca76sbd.js +0 -2
  68. package/bin/vm-hands/local-automation-3nabm5h3.js +0 -2
  69. package/bin/vm-hands/local-capabilities-mnz5et6y.js +0 -2
  70. package/bin/vm-hands/local-desktop-users-zxw8xxw9.js +0 -2
  71. package/bin/vm-hands/local-display-mac-jdgx19jw.js +0 -2
  72. package/bin/vm-hands/local-display-session-k2ewepn4.js +0 -2
  73. package/bin/vm-hands/local-pty-session-frp7k8fz.js +0 -2
  74. package/bin/vm-hands/package-vj1s3sye.js +0 -2
  75. package/bin/vm-hands/permissions-74dw20hk.js +0 -2
  76. package/bin/vm-hands/version-mhc6y1v9.js +0 -2
  77. package/bin/vm-hands/vm-hands-entry-lite-qwb91tgj.js +0 -529
  78. package/bin/vm-hands/vm-hands-op-runner-01szqn0m.js +0 -2
  79. package/bin/vm-hands/worker-sandbox-1kpm6af4.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{mi as W}from"./vm-hands-entry-lite-2xh7sjs0.js";var T=W.string().max(201).regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/).refine((Q)=>Q.split("/").every((Z)=>Z!=="."&&Z!=="..")),G=W.string().min(1).max(255).regex(/^[A-Za-z0-9_][A-Za-z0-9_./-]*$/).refine((Q)=>!Q.includes("..")&&!Q.includes("//")&&!Q.endsWith("/")&&!Q.endsWith(".lock")),M=W.string().regex(/^[a-f0-9]{40}$/),q=W.number().int().positive(),C=W.string().min(1).max(256),A=W.string().max(60000),B={version:W.literal(1),repoFullName:T},J=W.array(W.string().max(1024).regex(/^(?:Co-authored-by: [^<>\r\n\x00]+ <[^<>\s]+@[^<>\s]+>|Reason-Contributor-ID: rc_[a-f0-9]{32})$/)).max(1000),c=W.strictObject({expectedTrailers:J,missingFromHead:J}),y=W.discriminatedUnion("action",[W.strictObject({action:W.literal("edit"),title:C.optional(),body:A.optional(),base:G.optional()}),W.strictObject({action:W.enum(["ready","draft","close"])}),W.strictObject({action:W.literal("metadata"),field:W.enum(["reviewer","assignee","label"]),change:W.enum(["add","remove"]),value:W.string().min(1).max(100).refine((Q)=>!/[\r\n\0]/.test(Q))})]),d=W.discriminatedUnion("kind",[W.strictObject({...B,kind:W.literal("read"),path:W.string().min(1).max(2048),accept:W.enum(["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"]).optional()}),W.strictObject({...B,kind:W.literal("pr_review_context"),number:q,after:W.string().min(1).max(1024).optional()}),W.strictObject({...B,kind:W.literal("prepare"),branch:G,baseSha:M,defaultBranch:G,diagnosticsVersion:W.literal(1).optional()}),W.strictObject({...B,kind:W.literal("publish"),branch:G,defaultBranch:G,baseSha:M,remoteHeadSha:M.nullable(),contributorTrailers:J.optional()}),W.strictObject({...B,kind:W.literal("pr_create"),head:G,base:G,title:C,body:A,draft:W.boolean()}),W.strictObject({...B,kind:W.literal("pr_mutation"),number:q,mutation:y}),W.strictObject({...B,kind:W.literal("pr_merge"),number:q,expectedHeadSha:M,expectedBaseRef:G,method:W.enum(["merge","squash","rebase"]),commitBody:W.string().max(65536).optional()})]),O=["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 h(Q){return O.some((Z)=>Z===Q)}class R extends Error{code;constructor(Q){super(Q);this.code=Q}}function ZQ(Q,Z,$){let z=d.safeParse(Q);return Z==="failed"&&z.success&&z.data.kind==="prepare"&&z.data.diagnosticsVersion===1&&h($)}var x=245760,$Q=W.discriminatedUnion("kind",[W.strictObject({kind:W.literal("pr_review_context"),body:W.string().max(x)}),W.strictObject({kind:W.literal("prepare"),headSha:M}),W.strictObject({kind:W.literal("read"),status:W.number().int().min(200).max(599),headers:W.record(W.string(),W.string().max(8192)).refine((Q)=>Object.keys(Q).every((Z)=>Z==="link"||Z==="content-type")),body:W.string().max(x)}),W.strictObject({kind:W.literal("publish"),headSha:M,scannedObjectCount:W.number().int().min(0).max(5000),attribution:c.optional()}),W.strictObject({kind:W.literal("pr_create"),url:W.string().max(1024).regex(/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/pull\/[1-9][0-9]*$/)}),W.strictObject({kind:W.literal("pr_mutation"),number:q,applied:W.literal(!0)}),W.strictObject({kind:W.literal("pr_merge"),number:q,merged:W.literal(!0)})]).refine((Q)=>new TextEncoder().encode(JSON.stringify(Q)).byteLength<=x,"local_device_gh_result_too_large"),r=W.strictObject({source:W.enum(["agent","human"]),operationId:W.uuid()}),m=W.strictObject({version:W.literal(1),userId:W.guid(),deviceId:W.guid(),rootId:W.guid(),runId:W.guid(),merge:r.optional(),contributorRefresh:W.guid().optional(),repoFullName:T.nullable(),rootRevision:W.string().regex(/^[1-9][0-9]*$/),readOnly:W.boolean(),generation:W.number().int().positive().nullable(),fenceId:W.guid().nullable()}).refine((Q)=>Q.generation===null===(Q.fenceId===null));function P(Q){return/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(Q)&&Q.split("/").every((Z)=>Z!=="."&&Z!=="..")}function KQ(Q,Z,$={},z="read"){if(P(Q)&&(Z==="/search/issues"||Z.startsWith("/search/issues?")))return p(Q,Z,$);if(!P(Q)||!Z.startsWith(`/repos/${Q}/`)&&Z!==`/repos/${Q}`)throw Error("local_device_gh_repository_mismatch");if(/[\\#\u0000-\u001f]/.test(Z)||/%(?:2e|5c|00)/i.test(Z))throw Error("local_device_gh_path_denied");let V=new URL(Z,"https://api.github.com");if(V.pathname!==Z.split("?")[0]||V.username||V.password)throw Error("local_device_gh_path_denied");let Y;try{Y=decodeURIComponent(V.pathname.slice(`/repos/${Q}`.length))}catch{throw Error("local_device_gh_path_denied")}if(Y.includes("%")||Y.split("/").some((D)=>D==="."||D===".."))throw Error("local_device_gh_path_denied");if(($.method??"GET").toUpperCase()!=="GET"||$.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((D)=>D.test(Y)))throw Error("local_device_gh_path_denied");if(V.searchParams.forEach((D,X)=>{if(X==="per_page"&&/^[1-9][0-9]*$/.test(D)&&Number(D)<=100)return;if(X==="page"&&/^[1-9][0-9]*$/.test(D)&&Number(D)<=100)return;if(Y==="/pulls"&&X==="state"&&["open","closed","all"].includes(D))return;if(Y==="/pulls"&&X==="sort"&&D==="updated")return;if(Y==="/pulls"&&X==="direction"&&D==="desc")return;if(Y==="/pulls"&&["head","base"].includes(X)&&/^[A-Za-z0-9_./:-]{1,255}$/.test(D))return;throw Error("local_device_gh_query_denied")}),$.headers)new Headers($.headers).forEach((X,_)=>{if(_!=="accept"||!["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"].includes(X))throw Error("local_device_gh_header_denied")})}function p(Q,Z,$){if(/[\\#\u0000-\u001f]/.test(Z))throw Error("local_device_gh_path_denied");let z=new URL(Z,"https://api.github.com");if(z.pathname!=="/search/issues"||z.username||z.password)throw Error("local_device_gh_path_denied");if(($.method??"GET").toUpperCase()!=="GET"||$.body!=null)throw Error("local_device_gh_mutation_not_admitted");let V=null;z.searchParams.forEach((H,D)=>{if(D==="q"&&V===null){V=H;return}if(D==="per_page"&&/^[1-9][0-9]*$/.test(H)&&Number(H)<=100)return;if(D==="page"&&/^[1-9][0-9]*$/.test(H)&&Number(H)<=100)return;throw Error("local_device_gh_query_denied")});let Y=`repo:${Q.toLowerCase()} `,N=V?.toLowerCase()??"";if(N.length>512||!(N+" ").startsWith(Y)||/(?:^|\s)(?:repo|org|user):/.test(N.slice(Y.length)))throw Error("local_device_gh_query_denied");if($.headers)new Headers($.headers).forEach((H,D)=>{if(D!=="accept"||H!=="application/vnd.github+json")throw Error("local_device_gh_header_denied")})}var DQ=`query PullRequestReviewContext($owner: String!, $repo: String!, $number: Int!, $after: String) {
2
+ import{ii as W}from"./vm-hands-entry-lite-k17ntg9v.js";var T=W.string().max(201).regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/).refine((Q)=>Q.split("/").every((Z)=>Z!=="."&&Z!=="..")),G=W.string().min(1).max(255).regex(/^[A-Za-z0-9_][A-Za-z0-9_./-]*$/).refine((Q)=>!Q.includes("..")&&!Q.includes("//")&&!Q.endsWith("/")&&!Q.endsWith(".lock")),M=W.string().regex(/^[a-f0-9]{40}$/),q=W.number().int().positive(),C=W.string().min(1).max(256),A=W.string().max(60000),B={version:W.literal(1),repoFullName:T},J=W.array(W.string().max(1024).regex(/^(?:Co-authored-by: [^<>\r\n\x00]+ <[^<>\s]+@[^<>\s]+>|Reason-Contributor-ID: rc_[a-f0-9]{32})$/)).max(1000),c=W.strictObject({expectedTrailers:J,missingFromHead:J}),y=W.discriminatedUnion("action",[W.strictObject({action:W.literal("edit"),title:C.optional(),body:A.optional(),base:G.optional()}),W.strictObject({action:W.enum(["ready","draft","close"])}),W.strictObject({action:W.literal("metadata"),field:W.enum(["reviewer","assignee","label"]),change:W.enum(["add","remove"]),value:W.string().min(1).max(100).refine((Q)=>!/[\r\n\0]/.test(Q))})]),d=W.discriminatedUnion("kind",[W.strictObject({...B,kind:W.literal("read"),path:W.string().min(1).max(2048),accept:W.enum(["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"]).optional()}),W.strictObject({...B,kind:W.literal("pr_review_context"),number:q,after:W.string().min(1).max(1024).optional()}),W.strictObject({...B,kind:W.literal("prepare"),branch:G,baseSha:M,defaultBranch:G,diagnosticsVersion:W.literal(1).optional()}),W.strictObject({...B,kind:W.literal("publish"),branch:G,defaultBranch:G,baseSha:M,remoteHeadSha:M.nullable(),contributorTrailers:J.optional()}),W.strictObject({...B,kind:W.literal("pr_create"),head:G,base:G,title:C,body:A,draft:W.boolean()}),W.strictObject({...B,kind:W.literal("pr_mutation"),number:q,mutation:y}),W.strictObject({...B,kind:W.literal("pr_merge"),number:q,expectedHeadSha:M,expectedBaseRef:G,method:W.enum(["merge","squash","rebase"]),commitBody:W.string().max(65536).optional()})]),O=["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 h(Q){return O.some((Z)=>Z===Q)}class R extends Error{code;constructor(Q){super(Q);this.code=Q}}function ZQ(Q,Z,$){let z=d.safeParse(Q);return Z==="failed"&&z.success&&z.data.kind==="prepare"&&z.data.diagnosticsVersion===1&&h($)}var x=245760,$Q=W.discriminatedUnion("kind",[W.strictObject({kind:W.literal("pr_review_context"),body:W.string().max(x)}),W.strictObject({kind:W.literal("prepare"),headSha:M}),W.strictObject({kind:W.literal("read"),status:W.number().int().min(200).max(599),headers:W.record(W.string(),W.string().max(8192)).refine((Q)=>Object.keys(Q).every((Z)=>Z==="link"||Z==="content-type")),body:W.string().max(x)}),W.strictObject({kind:W.literal("publish"),headSha:M,scannedObjectCount:W.number().int().min(0).max(5000),attribution:c.optional()}),W.strictObject({kind:W.literal("pr_create"),url:W.string().max(1024).regex(/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/pull\/[1-9][0-9]*$/)}),W.strictObject({kind:W.literal("pr_mutation"),number:q,applied:W.literal(!0)}),W.strictObject({kind:W.literal("pr_merge"),number:q,merged:W.literal(!0)})]).refine((Q)=>new TextEncoder().encode(JSON.stringify(Q)).byteLength<=x,"local_device_gh_result_too_large"),r=W.strictObject({source:W.enum(["agent","human"]),operationId:W.uuid()}),m=W.strictObject({version:W.literal(1),userId:W.guid(),deviceId:W.guid(),rootId:W.guid(),runId:W.guid(),merge:r.optional(),contributorRefresh:W.guid().optional(),repoFullName:T.nullable(),rootRevision:W.string().regex(/^[1-9][0-9]*$/),readOnly:W.boolean(),generation:W.number().int().positive().nullable(),fenceId:W.guid().nullable()}).refine((Q)=>Q.generation===null===(Q.fenceId===null));function P(Q){return/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(Q)&&Q.split("/").every((Z)=>Z!=="."&&Z!=="..")}function KQ(Q,Z,$={},z="read"){if(P(Q)&&(Z==="/search/issues"||Z.startsWith("/search/issues?")))return p(Q,Z,$);if(!P(Q)||!Z.startsWith(`/repos/${Q}/`)&&Z!==`/repos/${Q}`)throw Error("local_device_gh_repository_mismatch");if(/[\\#\u0000-\u001f]/.test(Z)||/%(?:2e|5c|00)/i.test(Z))throw Error("local_device_gh_path_denied");let V=new URL(Z,"https://api.github.com");if(V.pathname!==Z.split("?")[0]||V.username||V.password)throw Error("local_device_gh_path_denied");let Y;try{Y=decodeURIComponent(V.pathname.slice(`/repos/${Q}`.length))}catch{throw Error("local_device_gh_path_denied")}if(Y.includes("%")||Y.split("/").some((D)=>D==="."||D===".."))throw Error("local_device_gh_path_denied");if(($.method??"GET").toUpperCase()!=="GET"||$.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((D)=>D.test(Y)))throw Error("local_device_gh_path_denied");if(V.searchParams.forEach((D,X)=>{if(X==="per_page"&&/^[1-9][0-9]*$/.test(D)&&Number(D)<=100)return;if(X==="page"&&/^[1-9][0-9]*$/.test(D)&&Number(D)<=100)return;if(Y==="/pulls"&&X==="state"&&["open","closed","all"].includes(D))return;if(Y==="/pulls"&&X==="sort"&&D==="updated")return;if(Y==="/pulls"&&X==="direction"&&D==="desc")return;if(Y==="/pulls"&&["head","base"].includes(X)&&/^[A-Za-z0-9_./:-]{1,255}$/.test(D))return;throw Error("local_device_gh_query_denied")}),$.headers)new Headers($.headers).forEach((X,_)=>{if(_!=="accept"||!["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"].includes(X))throw Error("local_device_gh_header_denied")})}function p(Q,Z,$){if(/[\\#\u0000-\u001f]/.test(Z))throw Error("local_device_gh_path_denied");let z=new URL(Z,"https://api.github.com");if(z.pathname!=="/search/issues"||z.username||z.password)throw Error("local_device_gh_path_denied");if(($.method??"GET").toUpperCase()!=="GET"||$.body!=null)throw Error("local_device_gh_mutation_not_admitted");let V=null;z.searchParams.forEach((H,D)=>{if(D==="q"&&V===null){V=H;return}if(D==="per_page"&&/^[1-9][0-9]*$/.test(H)&&Number(H)<=100)return;if(D==="page"&&/^[1-9][0-9]*$/.test(H)&&Number(H)<=100)return;throw Error("local_device_gh_query_denied")});let Y=`repo:${Q.toLowerCase()} `,N=V?.toLowerCase()??"";if(N.length>512||!(N+" ").startsWith(Y)||/(?:^|\s)(?:repo|org|user):/.test(N.slice(Y.length)))throw Error("local_device_gh_query_denied");if($.headers)new Headers($.headers).forEach((H,D)=>{if(D!=="accept"||H!=="application/vnd.github+json")throw Error("local_device_gh_header_denied")})}var DQ=`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) {
@@ -39,4 +39,4 @@ import{mi as W}from"./vm-hands-entry-lite-2xh7sjs0.js";var T=W.string().max(201)
39
39
  `)||!/^[a-f0-9]{64}$/.test(Q.bodySha256))throw Error("Invalid Reason Device proof input.");return Buffer.from([Z,$,Q.pathAndQuery,Q.timestamp,Q.nonce,Q.challenge,Q.bodySha256].join(`
40
40
  `),"utf8")}function K(Q){return Boolean(Q)&&typeof Q==="object"&&!Array.isArray(Q)}function t(Q,Z){return typeof Q==="string"&&Z.some(($)=>$===Q)}function k(Q){return K(Q)&&typeof Q.id==="string"&&typeof Q.label==="string"&&typeof Q.path_fingerprint==="string"}function v(Q){return K(Q)&&Number.isInteger(Q.seq)&&Number(Q.seq)>=0&&typeof Q.kind==="string"&&/^[A-Za-z0-9._:-]{1,64}$/.test(Q.kind)&&K(Q.payload)}function w(Q){throw Error(Q)}function QW(Q,Z){let $=K(Q)?Q:{},z=typeof $.error==="string"?$.error:`http_${Z}`,V=typeof $.detail==="string"?$.detail:typeof $.message==="string"?$.message:`Reason Device request failed (${Z})`;return{code:z,message:V}}function l(Q){if(!K(Q)||typeof Q.challenge!=="string"||Q.challenge.length<16||Q.challenge.length>1024||Q.challenge.includes(`
41
41
  `)||typeof Q.expires_at!=="string"||!Number.isFinite(Date.parse(Q.expires_at)))w("Reason returned an invalid Device proof challenge.");return{challenge:Q.challenge,expires_at:Q.expires_at}}function L(Q,Z){if(!K(Q)||typeof Q.device_id!=="string"||Q.auth_scheme!=="p256"||Q.organization_id!==void 0&&typeof Q.organization_id!=="string"||Q.protocol_version!==j||!Array.isArray(Q.roots)||!Q.roots.every(k)||Z&&typeof Q.organization_id!=="string"||Q.device_credential!==void 0)w(Z?"Reason returned an invalid Device enrollment.":"Reason returned an invalid Device registration.");return{...{device_id:Q.device_id,...typeof Q.organization_id==="string"?{organization_id:Q.organization_id}:{},protocol_version:j,roots:Q.roots},auth_scheme:"p256"}}function WW(Q){return L(Q,!1)}function ZW(Q){let Z=L(Q,!0);if(typeof Z.organization_id!=="string")return w("Reason returned an invalid Device enrollment.");return{...Z,organization_id:Z.organization_id}}function $W(Q){if(!K(Q)||typeof Q.server_time!=="string"||typeof Q.drain!=="boolean")return w("Reason returned an invalid Device heartbeat.");return{server_time:Q.server_time,drain:Q.drain,...f(Q),...typeof Q.update_policy==="string"||Q.update_policy===null?{update_policy:Q.update_policy}:{},...typeof Q.supported_protocol_version==="number"?{supported_protocol_version:Q.supported_protocol_version}:{},...a(Q.latest_cli_versions),...Q.hands_prespawn===!0?{hands_prespawn:!0}:{}}}var u=["account_root_metadata_supported","workspace_root_metadata_supported","account_root_path_supported","home_contained_roots_supported","root_paths_supported","startup_supported"];function f(Q){return Object.fromEntries(u.filter((Z)=>Q[Z]===!0).map((Z)=>[Z,!0]))}function KW(Q){if(!K(Q))return;try{return{...l(Q),...f(Q)}}catch{return}}function a(Q){if(!K(Q))return{};let Z={};for(let $ of s){let z=Q[$];if(typeof z==="string"&&/^(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})$/.test(z))Z[$]=z}return Object.keys(Z).length>0?{latest_cli_versions:Z}:{}}function DW(Q){if(!K(Q)||!Array.isArray(Q.roots)||!Q.roots.every(k))return w("Reason returned an invalid Device root sync.");return{roots:Q.roots}}function zW(Q){if(!K(Q)||Q.user_id!==void 0&&typeof Q.user_id!=="string"||typeof Q.organization_id!=="string"||typeof Q.organization_name!=="string"||typeof Q.organization_slug!=="string")return w("Reason returned an invalid Device identity.");return{...typeof Q.user_id==="string"?{user_id:Q.user_id}:{},organization_id:Q.organization_id,organization_name:Q.organization_name,organization_slug:Q.organization_slug}}function FW(Q){if(!K(Q)||Q.disconnected!==!0)return w("Reason did not disconnect this Device.");let Z=Q.sessions_moved;return typeof Z==="number"&&Number.isSafeInteger(Z)&&Z>=0?{disconnected:!0,sessions_moved:Z}:{disconnected:!0}}function wW(Q){if(K(Q)&&Q.ok===!0&&typeof Q.expires==="number")return{ok:!0,expires:Q.expires};if(K(Q)&&Q.ok===!1&&typeof Q.error==="string")return{ok:!1,error:Q.error};return w("Reason did not answer the local login hand-over.")}function VW(Q){if(!K(Q)||Q.accepted!==!0)return w("Reason did not accept the Device lifecycle event.");return{accepted:!0}}function e(Q){return Buffer.byteLength(JSON.stringify(Q),"utf8")}function YW(Q,Z=b){if(!K(Q)||typeof Q.operation_id!=="string"||typeof Q.attempt_id!=="string"||typeof Q.attempt_token!=="string"||!/^(?:reason|ara)_attempt_/.test(Q.attempt_token)||typeof Q.lease_until!=="string"||typeof Q.run_id!=="string"||typeof Q.root_id!=="string"||Q.owner!==void 0&&!E(Q.owner)||!t(Q.capability,Z)||!K(Q.payload)||Q.protocol_version!==j||e(Q.payload)>n||Q.authority!==void 0&&!U(Q.authority)||Q.local_github_authority!==void 0&&!m.safeParse(Q.local_github_authority).success||Q.capability==="github.local.v1"&&!m.safeParse(Q.local_github_authority).success||Q.recording_authority!==void 0&&!S(Q.recording_authority)||Q.capability==="browser.recording.v1"&&(!S(Q.recording_authority)||!E(Q.owner))||Q.capability!=="browser.recording.v1"&&Q.recording_authority!==void 0)return w("Reason returned an invalid Device operation claim.");let $={operation_id:Q.operation_id,attempt_id:Q.attempt_id,attempt_token:Q.attempt_token,lease_until:Q.lease_until,run_id:Q.run_id,root_id:Q.root_id,capability:Q.capability,payload:Q.payload,...U(Q.authority)?{authority:Q.authority}:{},...S(Q.recording_authority)?{recording_authority:Object.freeze({...Q.recording_authority})}:{},...Q.local_github_authority!==void 0?{local_github_authority:m.parse(Q.local_github_authority)}:{},...Q.capability==="hands.connect"&&K(Q.environment)&&K(Q.environment.payload)&&U(Q.environment.authority)?{environment:{payload:Q.environment.payload,authority:Q.environment.authority}}:{},protocol_version:j};if(Q.owner!==void 0)$.owner=Object.freeze({...Q.owner});return $}function HW(Q){if(!K(Q)||typeof Q.lease_until!=="string"||!Array.isArray(Q.controls)||!Q.controls.every(v)||!Number.isInteger(Q.next_control_seq)||Number(Q.next_control_seq)<0)return w("Reason returned an invalid Device operation heartbeat.");return{lease_until:Q.lease_until,controls:Q.controls,next_control_seq:Number(Q.next_control_seq)}}function XW(Q){if(!K(Q)||!Number.isInteger(Q.next_event_seq)||Number(Q.next_event_seq)<0||typeof Q.duplicate!=="boolean"||!Number.isInteger(Q.accepted_count)||Number(Q.accepted_count)<0)return w("Reason returned an invalid Device operation event result.");return{next_event_seq:Number(Q.next_event_seq),duplicate:Q.duplicate,accepted_count:Number(Q.accepted_count)}}function GW(Q){if(!K(Q)||!K(Q.payload)||!U(Q.authority))return w("Reason returned an invalid Device environment delivery.");return{payload:Q.payload,authority:Q.authority}}function QQ(Q){return Q==="succeeded"||Q==="failed"||Q==="cancelled"||Q==="expired"}function BW(Q){if(!K(Q)||!QQ(Q.status)||typeof Q.idempotent!=="boolean")return w("Reason returned an invalid Device operation completion.");return{status:Q.status,idempotent:Q.idempotent}}
42
- export{d as ld,R as md,ZQ as nd,x as od,$Q as pd,m as qd,KQ as rd,DQ as sd,zQ as td,b as ud,j as vd,I as wd,n as xd,HQ as yd,XQ as zd,GQ as Ad,BQ as Bd,MQ as Cd,gQ as Dd,qQ as Ed,NQ as Fd,mQ as Gd,UQ as Hd,jQ as Id,xQ as Jd,JQ as Kd,SQ as Ld,IQ as Md,PQ as Nd,TQ as Od,CQ as Pd,AQ as Qd,bQ as Rd,EQ as Sd,kQ as Td,LQ as Ud,fQ as Vd,_Q as Wd,cQ as Xd,yQ as Yd,dQ as Zd,OQ as _d,hQ as $d,RQ as ae,rQ as be,pQ as ce,nQ as de,oQ as ee,sQ as fe,iQ as ge,tQ as he,vQ as ie,lQ as je,uQ as ke,i as le,aQ as me,eQ as ne,QW as oe,l as pe,WW as qe,ZW as re,$W as se,KW as te,DW as ue,zW as ve,FW as we,wW as xe,VW as ye,YW as ze,HW as Ae,XW as Be,GW as Ce,BW as De};
42
+ export{d as hd,R as id,ZQ as jd,x as kd,$Q as ld,m as md,KQ as nd,DQ as od,zQ as pd,b as qd,j as rd,I as sd,n as td,HQ as ud,XQ as vd,GQ as wd,BQ as xd,MQ as yd,gQ as zd,qQ as Ad,NQ as Bd,mQ as Cd,UQ as Dd,jQ as Ed,xQ as Fd,JQ as Gd,SQ as Hd,IQ as Id,PQ as Jd,TQ as Kd,CQ as Ld,AQ as Md,bQ as Nd,EQ as Od,kQ as Pd,LQ as Qd,fQ as Rd,_Q as Sd,cQ as Td,yQ as Ud,dQ as Vd,OQ as Wd,hQ as Xd,RQ as Yd,rQ as Zd,pQ as _d,nQ as $d,oQ as ae,sQ as be,iQ as ce,tQ as de,vQ as ee,lQ as fe,uQ as ge,i as he,aQ as ie,eQ as je,QW as ke,l as le,WW as me,ZW as ne,$W as oe,KW as pe,DW as qe,zW as re,FW as se,wW as te,VW as ue,YW as ve,HW as we,XW as xe,GW as ye,BW as ze};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Mb as j,Nb as q}from"./vm-hands-entry-lite-7ba3nhgv.js";function y(v=process.platform){if(j(),v==="linux")q("strict")}
2
+ import{Lb as j,Mb as q}from"./vm-hands-entry-lite-dyy62gt3.js";function y(v=process.platform){if(j(),v==="linux")q("strict")}
3
3
  export{y as u};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  class o extends Error{code;constructor(a,r){super(r);this.code=a;this.name="LocalCapabilityError"}}
3
- export{o as ui};
3
+ export{o as qi};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Sb as kQ,Tb as fQ,Ub as z4,Vb as K4,Wb as F8}from"./vm-hands-entry-lite-wmxksawm.js";import{$b as G8,_b as MQ,ac as n9,bc as _0,cc as L9,dc as n0,kc as K0}from"./vm-hands-entry-lite-k2cvr710.js";import{pc as b0}from"./vm-hands-entry-lite-k469tezz.js";import{Vd as w9,Wd as o0,Xd as B8,Yd as g0,ae as q0,ld as $Q,qd as QQ}from"./vm-hands-entry-lite-36xzwsxn.js";import{af as Y4}from"./vm-hands-entry-lite-pa111vpq.js";import{Af as UZ}from"./vm-hands-entry-lite-h1642n10.js";import{mg as hQ,sg as a9,tg as g8}from"./vm-hands-entry-lite-kt418g2w.js";import{$g as R8,Hg as ZQ,Ig as XQ,Kg as JQ,Mg as p9,Ng as n$,Og as i$,Pg as E8,Sg as l9,ah as S0,bh as O0,ch as u9,jh as b8,kh as YQ,lh as a$,vg as OZ,yg as B9}from"./vm-hands-entry-lite-knfh7w3j.js";import{Fh as cQ,Gh as h8}from"./vm-hands-entry-lite-1xjtcxpn.js";import{Oh as M8,Ph as s9,Sh as J4}from"./vm-hands-entry-lite-9dx3at21.js";import{$h as p0,Th as L8,Uh as i0,Vh as N8,Wh as a0,Xh as H9,Yh as Y8,Zh as $$,_h as s0,ai as s$,li as B$}from"./vm-hands-entry-lite-289bc9v7.js";import{mi as x}from"./vm-hands-entry-lite-2xh7sjs0.js";import{si as G4}from"./vm-hands-entry-lite-0jar357h.js";import{ui as C}from"./vm-hands-entry-lite-gt5pkv4h.js";import{Ai as VZ,vi as P1}from"./vm-hands-entry-lite-mhsv58hw.js";var v={chunk:32768,upload:1048576,total:536870912,streams:16,queued:512,buffered:262144,relayBuffered:8388608,requestMs:30000,lifetimeMs:600000,authorizationMs:2000,window:8};function v9($){return $!==null&&typeof $==="object"&&!Array.isArray($)}function P0($,Q,Z=Number.MAX_SAFE_INTEGER){return typeof $==="number"&&Number.isSafeInteger($)&&$>=Q&&$<=Z}function S$($){return typeof $==="string"&&/^[a-zA-Z0-9_-]{1,160}$/.test($)}function w$($,Q){let Z=Buffer.from($,"latin1");return Buffer.concat([Buffer.from([Z.length]),Z,Q])}function I0($){if(!v9($)||Object.keys($).length!==12||![$.organizationId,$.userId,$.runId,$.deviceId,$.rootId,$.jobId,$.fenceId].every(S$)||!P0($.attachmentRevision,0)||!P0($.grantRevision,1)||!P0($.generation,1)||!P0($.port,1024,65535)||!P0($.expiresAtMs,1))throw Error("preview_binding_invalid");return Object.freeze({...$})}function c0($,Q){return Object.keys($).every((Z)=>$[Z]===Q[Z])}function q9($){if($.length>4096||!$.startsWith("/")||$.startsWith("//")||/[\\\x00-\x20\x7f#]/.test($))throw Error("preview_path_invalid");let Q=decodeURIComponent($);if(Q.startsWith("//")||/[\\\x00-\x1f\x7f]/.test(Q))throw Error("preview_path_invalid");return $}function E$($){return Array.isArray($)&&$.length<=64&&$.every((Q)=>Array.isArray(Q)&&Q.length===2&&typeof Q[0]==="string"&&/^[a-zA-Z0-9-]{1,80}$/.test(Q[0])&&typeof Q[1]==="string"&&Q[1].length<=4096&&!/[\x00-\x1f\x7f]/.test(Q[1]))}function C9($,Q=v.chunk){if($.length>Math.ceil(Q/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test($))throw Error("preview_data_invalid");let Z=Buffer.from($,"base64");if(Z.length>Q)throw Error("preview_data_too_large");return Z}function b$($){if(Array.isArray($))return Buffer.concat($);if(typeof $==="string")return Buffer.from($,"utf8");if($ instanceof ArrayBuffer)return Buffer.from($);return $}function k$($){if(Buffer.byteLength($)>v.upload*1.4+300000)throw Error("preview_frame_too_large");let Q=JSON.parse($);if(!v9(Q))throw Error("preview_frame_invalid");if(Q.type==="hello")return{type:"hello",binding:I0(Q.binding),...P0(Q.messages,v.chunk,v.upload)?{messages:Q.messages}:{},...P0(Q.window,1,v.window)?{window:Q.window}:{},...Q.bytes===!0?{bytes:!0}:{}};if(Q.type==="refused"&&typeof Q.reason==="string"&&/^[a-z_]{1,32}$/.test(Q.reason))return{type:"refused",binding:I0(Q.binding),reason:Q.reason};if(!S$(Q.id))throw Error("preview_frame_invalid");if(Q.type==="end"||Q.type==="cancel"||Q.type==="credit")return{type:Q.type,id:Q.id};if(Q.type==="ws"&&typeof Q.protocol==="string"&&/^[a-zA-Z0-9._-]{0,100}$/.test(Q.protocol))return{type:"ws",id:Q.id,protocol:Q.protocol};if(Q.type==="data"&&typeof Q.data==="string"&&typeof Q.binary==="boolean")return C9(Q.data,v.upload),{type:"data",id:Q.id,data:Q.data,binary:Q.binary};if(Q.type==="head"&&P0(Q.status,200,599)&&E$(Q.headers))return{type:"head",id:Q.id,status:Q.status,headers:Q.headers};if(Q.type==="request"&&typeof Q.method==="string"&&/^(GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS)$/.test(Q.method)&&typeof Q.path==="string"&&E$(Q.headers)&&typeof Q.body==="string"&&typeof Q.upgrade==="boolean")return C9(Q.body,v.upload),{type:"request",id:Q.id,method:Q.method,path:q9(Q.path),headers:Q.headers,body:Q.body,upgrade:Q.upgrade};throw Error("preview_frame_invalid")}function _8($){let Q=[...$],Z=new Set(Q.filter(([J])=>J.toLowerCase()==="connection").flatMap(([,J])=>J.toLowerCase().split(",").map((Y)=>Y.trim()))),X=new Set(["authorization","proxy-authorization","cookie","set-cookie","host","origin","referer","connection","upgrade","keep-alive","transfer-encoding","te","trailer","content-length","forwarded","alt-svc","service-worker-allowed","clear-site-data","refresh"]);return Q.filter(([J])=>!X.has(J.toLowerCase())&&!Z.has(J.toLowerCase())&&!/^(x-forwarded-|x-ara-|sec-websocket-|access-control-)/i.test(J))}async function A8($){let Q;try{return await Promise.race([Promise.resolve().then($).then((Z)=>Z===!0||(Z===!1?!1:void 0),()=>{return}),new Promise((Z)=>{Q=setTimeout(()=>Z(void 0),v.authorizationMs)})])}finally{clearTimeout(Q)}}async function T9($){return await A8($)===!0}function c9($,Q){let Z=new URL($);if(Z.username||Z.password||Z.search||Z.hash||!(Z.protocol==="wss:"||Z.protocol==="ws:"&&["127.0.0.1","[::1]"].includes(Z.hostname))||!new RegExp(`^/${Q}/[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]{32,}$`).test(Z.pathname))throw Error("preview_relay_invalid");return Z.href}function f$($){if(!v9($)||Object.keys($).length!==2||typeof $.deviceRelayUrl!=="string")throw Error("preview_open_invalid");return{binding:I0($.binding),deviceRelayUrl:c9($.deviceRelayUrl,"device")}}function g$($){if(!v9($)||Object.keys($).length!==1||!("binding"in $))throw Error("preview_close_invalid");return{binding:I0($.binding)}}import{request as D4}from"http";import{pipeline as _4}from"stream";import{constants as x8,createBrotliCompress as A4,createGzip as x4}from"zlib";import{WebSocket as O9}from"ws";import{randomBytes as q4,timingSafeEqual as T4}from"crypto";import{createServer as O4}from"net";var m$="x-preview-connection";async function y$($,Q){if(Q.aborted)throw Error("preview_closed");let Z=q4(32).toString("base64url"),X=new Set,J=!1,Y=O4((G)=>{if(J||Q.aborted||X.size>=v.streams*2)return G.destroy();X.add(G);let F=new AbortController;G.once("close",()=>{X.delete(G),F.abort()}),G.on("error",()=>G.destroy()),G.setTimeout(2000,()=>G.destroy());let B=Buffer.alloc(0),H=(L)=>{B=Buffer.concat([B,L]);let W=B.indexOf(`\r
2
+ import{Rb as kQ,Sb as fQ,Tb as z4,Ub as K4,Vb as F8}from"./vm-hands-entry-lite-wpx6sg6d.js";import{$b as n0,Wb as MQ,Xb as G8,Yb as n9,Zb as _0,_b as L9,gc as K0}from"./vm-hands-entry-lite-nbtpm59m.js";import{lc as b0}from"./vm-hands-entry-lite-nvhzj5b0.js";import{Rd as w9,Sd as o0,Td as B8,Ud as g0,Yd as q0,hd as $Q,md as QQ}from"./vm-hands-entry-lite-qf01e5f1.js";import{Ye as Y4}from"./vm-hands-entry-lite-xhjbc3e4.js";import{wf as UZ}from"./vm-hands-entry-lite-3dy1s2gz.js";import{ig as hQ,og as a9,pg as g8}from"./vm-hands-entry-lite-33ttamma.js";import{Dg as ZQ,Eg as XQ,Gg as JQ,Ig as p9,Jg as n$,Kg as i$,Lg as E8,Og as l9,Xg as R8,Yg as S0,Zg as O0,_g as u9,fh as b8,gh as YQ,hh as a$,rg as OZ,ug as B9}from"./vm-hands-entry-lite-mybm2kyz.js";import{Bh as cQ,Ch as h8}from"./vm-hands-entry-lite-6qfax5p2.js";import{Kh as M8,Lh as s9,Oh as J4}from"./vm-hands-entry-lite-5b29hq7h.js";import{Ph as L8,Qh as i0,Rh as N8,Sh as a0,Th as H9,Uh as Y8,Vh as $$,Wh as s0,Xh as p0,Yh as s$,hi as B$}from"./vm-hands-entry-lite-84d59wrf.js";import{ii as x}from"./vm-hands-entry-lite-k17ntg9v.js";import{oi as G4}from"./vm-hands-entry-lite-6f5eypjm.js";import{qi as C}from"./vm-hands-entry-lite-tj1y61bg.js";import{ri as P1,wi as VZ}from"./vm-hands-entry-lite-nd1k2jz9.js";var v={chunk:32768,upload:1048576,total:536870912,streams:16,queued:512,buffered:262144,relayBuffered:8388608,requestMs:30000,lifetimeMs:600000,authorizationMs:2000,window:8};function v9($){return $!==null&&typeof $==="object"&&!Array.isArray($)}function P0($,Q,Z=Number.MAX_SAFE_INTEGER){return typeof $==="number"&&Number.isSafeInteger($)&&$>=Q&&$<=Z}function S$($){return typeof $==="string"&&/^[a-zA-Z0-9_-]{1,160}$/.test($)}function w$($,Q){let Z=Buffer.from($,"latin1");return Buffer.concat([Buffer.from([Z.length]),Z,Q])}function I0($){if(!v9($)||Object.keys($).length!==12||![$.organizationId,$.userId,$.runId,$.deviceId,$.rootId,$.jobId,$.fenceId].every(S$)||!P0($.attachmentRevision,0)||!P0($.grantRevision,1)||!P0($.generation,1)||!P0($.port,1024,65535)||!P0($.expiresAtMs,1))throw Error("preview_binding_invalid");return Object.freeze({...$})}function c0($,Q){return Object.keys($).every((Z)=>$[Z]===Q[Z])}function q9($){if($.length>4096||!$.startsWith("/")||$.startsWith("//")||/[\\\x00-\x20\x7f#]/.test($))throw Error("preview_path_invalid");let Q=decodeURIComponent($);if(Q.startsWith("//")||/[\\\x00-\x1f\x7f]/.test(Q))throw Error("preview_path_invalid");return $}function E$($){return Array.isArray($)&&$.length<=64&&$.every((Q)=>Array.isArray(Q)&&Q.length===2&&typeof Q[0]==="string"&&/^[a-zA-Z0-9-]{1,80}$/.test(Q[0])&&typeof Q[1]==="string"&&Q[1].length<=4096&&!/[\x00-\x1f\x7f]/.test(Q[1]))}function C9($,Q=v.chunk){if($.length>Math.ceil(Q/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test($))throw Error("preview_data_invalid");let Z=Buffer.from($,"base64");if(Z.length>Q)throw Error("preview_data_too_large");return Z}function b$($){if(Array.isArray($))return Buffer.concat($);if(typeof $==="string")return Buffer.from($,"utf8");if($ instanceof ArrayBuffer)return Buffer.from($);return $}function k$($){if(Buffer.byteLength($)>v.upload*1.4+300000)throw Error("preview_frame_too_large");let Q=JSON.parse($);if(!v9(Q))throw Error("preview_frame_invalid");if(Q.type==="hello")return{type:"hello",binding:I0(Q.binding),...P0(Q.messages,v.chunk,v.upload)?{messages:Q.messages}:{},...P0(Q.window,1,v.window)?{window:Q.window}:{},...Q.bytes===!0?{bytes:!0}:{}};if(Q.type==="refused"&&typeof Q.reason==="string"&&/^[a-z_]{1,32}$/.test(Q.reason))return{type:"refused",binding:I0(Q.binding),reason:Q.reason};if(!S$(Q.id))throw Error("preview_frame_invalid");if(Q.type==="end"||Q.type==="cancel"||Q.type==="credit")return{type:Q.type,id:Q.id};if(Q.type==="ws"&&typeof Q.protocol==="string"&&/^[a-zA-Z0-9._-]{0,100}$/.test(Q.protocol))return{type:"ws",id:Q.id,protocol:Q.protocol};if(Q.type==="data"&&typeof Q.data==="string"&&typeof Q.binary==="boolean")return C9(Q.data,v.upload),{type:"data",id:Q.id,data:Q.data,binary:Q.binary};if(Q.type==="head"&&P0(Q.status,200,599)&&E$(Q.headers))return{type:"head",id:Q.id,status:Q.status,headers:Q.headers};if(Q.type==="request"&&typeof Q.method==="string"&&/^(GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS)$/.test(Q.method)&&typeof Q.path==="string"&&E$(Q.headers)&&typeof Q.body==="string"&&typeof Q.upgrade==="boolean")return C9(Q.body,v.upload),{type:"request",id:Q.id,method:Q.method,path:q9(Q.path),headers:Q.headers,body:Q.body,upgrade:Q.upgrade};throw Error("preview_frame_invalid")}function _8($){let Q=[...$],Z=new Set(Q.filter(([J])=>J.toLowerCase()==="connection").flatMap(([,J])=>J.toLowerCase().split(",").map((Y)=>Y.trim()))),X=new Set(["authorization","proxy-authorization","cookie","set-cookie","host","origin","referer","connection","upgrade","keep-alive","transfer-encoding","te","trailer","content-length","forwarded","alt-svc","service-worker-allowed","clear-site-data","refresh"]);return Q.filter(([J])=>!X.has(J.toLowerCase())&&!Z.has(J.toLowerCase())&&!/^(x-forwarded-|x-ara-|sec-websocket-|access-control-)/i.test(J))}async function A8($){let Q;try{return await Promise.race([Promise.resolve().then($).then((Z)=>Z===!0||(Z===!1?!1:void 0),()=>{return}),new Promise((Z)=>{Q=setTimeout(()=>Z(void 0),v.authorizationMs)})])}finally{clearTimeout(Q)}}async function T9($){return await A8($)===!0}function c9($,Q){let Z=new URL($);if(Z.username||Z.password||Z.search||Z.hash||!(Z.protocol==="wss:"||Z.protocol==="ws:"&&["127.0.0.1","[::1]"].includes(Z.hostname))||!new RegExp(`^/${Q}/[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]{32,}$`).test(Z.pathname))throw Error("preview_relay_invalid");return Z.href}function f$($){if(!v9($)||Object.keys($).length!==2||typeof $.deviceRelayUrl!=="string")throw Error("preview_open_invalid");return{binding:I0($.binding),deviceRelayUrl:c9($.deviceRelayUrl,"device")}}function g$($){if(!v9($)||Object.keys($).length!==1||!("binding"in $))throw Error("preview_close_invalid");return{binding:I0($.binding)}}import{request as D4}from"http";import{pipeline as _4}from"stream";import{constants as x8,createBrotliCompress as A4,createGzip as x4}from"zlib";import{WebSocket as O9}from"ws";import{randomBytes as q4,timingSafeEqual as T4}from"crypto";import{createServer as O4}from"net";var m$="x-preview-connection";async function y$($,Q){if(Q.aborted)throw Error("preview_closed");let Z=q4(32).toString("base64url"),X=new Set,J=!1,Y=O4((G)=>{if(J||Q.aborted||X.size>=v.streams*2)return G.destroy();X.add(G);let F=new AbortController;G.once("close",()=>{X.delete(G),F.abort()}),G.on("error",()=>G.destroy()),G.setTimeout(2000,()=>G.destroy());let B=Buffer.alloc(0),H=(L)=>{B=Buffer.concat([B,L]);let W=B.indexOf(`\r
3
3
  \r
4
4
  `);if(W<0){if(B.length>16384)G.destroy();return}if(G.pause(),G.off("data",H),W>16384||B.length>v.upload+16384)return G.destroy();z(B,W).catch(()=>G.destroy())};G.on("data",H);async function z(L,W){let U=L.subarray(0,W).toString("latin1").split(`\r
5
5
  `),j=/^(GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS) (\S+) HTTP\/1\.1$/.exec(U.shift()??"");if(!j)throw Error("preview_request_invalid");q9(j[2]);let O=!1,q=0,A=[];for(let T of U){let S=/^([a-zA-Z0-9-]+):[ \t]*([^\x00-\x08\x0a-\x1f\x7f]*)$/.exec(T);if(!S)throw Error("preview_header_invalid");if(S[1].toLowerCase()===m$){q++;let g=Buffer.from(S[2].trim());O=g.length===Z.length&&T4(g,Buffer.from(Z))}else if(S[1].toLowerCase()!=="host")A.push(T)}if(!O||q!==1||J||F.signal.aborted)throw Error("preview_connection_denied");let R=await $.connect(F.signal);if(J||F.signal.aborted)throw R.destroy(),Error("preview_closed");X.add(R),R.on("error",()=>G.destroy()),R.once("close",()=>{X.delete(R),G.destroy()}),G.once("close",()=>R.destroy()),G.setTimeout(0);let P=[`${j[1]} ${j[2]} HTTP/1.1`,`Host: 127.0.0.1:${R.remotePort}`,...A,"",""].join(`\r
@@ -303,7 +303,7 @@ async (input) => {
303
303
  if (!bridge || typeof bridge.evaluate !== "function") throw new Error("Reason Hands browser bridge is not installed");
304
304
  return await bridge.evaluate(typeof input === "string" ? input : input && input.code);
305
305
  }
306
- `.trim();import{Buffer as X9}from"buffer";import{randomUUID as z1}from"crypto";class tQ extends Error{code;constructor($){super($==="hands_repl_private_profile_attribute_denied"?"Private browser attribute read denied.":$);this.code=$;this.name="HandsReplBrowserDispatcherError"}}var eQ=new Set(["__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","__proto__","constructor","prototype"]),aQ=/^hands_[A-Za-z0-9_-]{8,128}$/,K1=2048,$Z=32,QZ=1e4,V1=new Set(["href","src","alt","title","role","aria-label","aria-expanded","aria-checked","aria-selected","aria-disabled","placeholder","type","name","data-testid"]);function F1($){let Q=$.split("+"),Z=(Q.pop()??"").replace(/^Key/,"").toLowerCase();if(Z==="f12")return!0;if(Q.some((X)=>["Control","ControlOrMeta","Meta"].includes(X))&&["l","n","t","j","i","p","s","w","u","o","r","tab","pageup","pagedown"].includes(Z))return!0;if(Q.some((X)=>["Control","ControlOrMeta","Meta"].includes(X))&&Q.includes("Shift")&&Z==="c")return!0;return Q.includes("Alt")&&["d","arrowleft","arrowright","home"].includes(Z)}var H1=($)=>{let Q=$.closest("a[href],area[href]");return{password:$.tagName==="INPUT"&&$.type==="password",executableLink:Boolean(Q&&!/^(https?:|about:blank)/i.test(Q.href))}},ZZ={browser:{close:{returns:"void"},contexts:{returns:"context[]"},isConnected:{returns:"json"},version:{returns:"json"}},context:{addCookies:{returns:"void"},addInitScript:{returns:"void"},browser:{returns:"browser"},clearCookies:{returns:"void"},clearPermissions:{returns:"void"},close:{returns:"void"},cookies:{returns:"json"},grantPermissions:{returns:"void"},newPage:{returns:"page"},pages:{returns:"page[]"},setDefaultNavigationTimeout:{returns:"void"},setDefaultTimeout:{returns:"void"},setExtraHTTPHeaders:{returns:"void"},setGeolocation:{returns:"void"},setHTTPCredentials:{returns:"void"},setOffline:{returns:"void"},setViewportSize:{returns:"void"},storageState:{returns:"json"},viewportSize:{returns:"json",special:"contextViewportSize"}},page:{addInitScript:{returns:"void"},addScriptTag:{returns:"void"},addStyleTag:{returns:"void"},bringToFront:{returns:"void"},close:{returns:"void"},content:{returns:"json"},context:{returns:"context"},emulateMedia:{returns:"void"},evaluate:{returns:"json",requiresStringSource:!0},frame:{returns:"frame"},frameLocator:{returns:"frameLocator"},frames:{returns:"frame[]"},getByAltText:{returns:"locator"},getByLabel:{returns:"locator"},getByPlaceholder:{returns:"locator"},getByRole:{returns:"locator"},getByTestId:{returns:"locator"},getByText:{returns:"locator"},getByTitle:{returns:"locator"},goBack:{returns:"void"},goForward:{returns:"void"},goto:{returns:"void"},isClosed:{returns:"json"},locator:{returns:"locator"},mainFrame:{returns:"frame"},opener:{returns:"page"},pdf:{returns:"bytes"},reload:{returns:"void"},screenshot:{returns:"bytes"},selectOption:{returns:"json"},setContent:{returns:"void"},setDefaultNavigationTimeout:{returns:"void"},setDefaultTimeout:{returns:"void"},setExtraHTTPHeaders:{returns:"void"},setInputFiles:{returns:"void"},setViewportSize:{returns:"void"},title:{returns:"json"},url:{returns:"json"},viewportSize:{returns:"json"},waitForFunction:{returns:"void",requiresStringSource:!0},waitForLoadState:{returns:"void"},waitForNavigation:{returns:"void"},waitForTimeout:{returns:"void"},waitForURL:{returns:"void"}},locator:{all:{returns:"locator[]"},allInnerTexts:{returns:"json"},allTextContents:{returns:"json"},and:{returns:"locator"},ariaSnapshot:{returns:"json"},blur:{returns:"void"},boundingBox:{returns:"json"},check:{returns:"void"},clear:{returns:"void"},click:{returns:"void"},contentFrame:{returns:"frameLocator"},count:{returns:"json"},dblclick:{returns:"void"},dragTo:{returns:"void"},evaluate:{returns:"json",requiresStringSource:!0},evaluateAll:{returns:"json",requiresStringSource:!0},fill:{returns:"void"},filter:{returns:"locator"},first:{returns:"locator",special:"property"},focus:{returns:"void"},getAttribute:{returns:"json"},getByAltText:{returns:"locator"},getByLabel:{returns:"locator"},getByPlaceholder:{returns:"locator"},getByRole:{returns:"locator"},getByTestId:{returns:"locator"},getByText:{returns:"locator"},getByTitle:{returns:"locator"},hover:{returns:"void"},innerHTML:{returns:"json"},innerText:{returns:"json"},inputValue:{returns:"json"},isChecked:{returns:"json"},isEditable:{returns:"json"},isEnabled:{returns:"json"},isHidden:{returns:"json"},isVisible:{returns:"json"},last:{returns:"locator",special:"property"},locator:{returns:"locator"},nth:{returns:"locator"},or:{returns:"locator"},page:{returns:"page"},press:{returns:"void"},pressSequentially:{returns:"void"},scrollIntoViewIfNeeded:{returns:"void"},screenshot:{returns:"bytes"},selectOption:{returns:"json"},setInputFiles:{returns:"void"},tap:{returns:"void"},textContent:{returns:"json"},type:{returns:"void"},uncheck:{returns:"void"},waitFor:{returns:"void"}},frame:{addScriptTag:{returns:"void"},addStyleTag:{returns:"void"},childFrames:{returns:"frame[]"},content:{returns:"json"},evaluate:{returns:"json",requiresStringSource:!0},frameLocator:{returns:"frameLocator"},getByAltText:{returns:"locator"},getByLabel:{returns:"locator"},getByPlaceholder:{returns:"locator"},getByRole:{returns:"locator"},getByTestId:{returns:"locator"},getByText:{returns:"locator"},getByTitle:{returns:"locator"},goto:{returns:"void"},isDetached:{returns:"json"},locator:{returns:"locator"},name:{returns:"json"},page:{returns:"page"},parentFrame:{returns:"frame"},setContent:{returns:"void"},title:{returns:"json"},url:{returns:"json"},waitForFunction:{returns:"void",requiresStringSource:!0},waitForLoadState:{returns:"void"},waitForNavigation:{returns:"void"},waitForTimeout:{returns:"void"},waitForURL:{returns:"void"}},frameLocator:{getByAltText:{returns:"locator"},getByLabel:{returns:"locator"},getByPlaceholder:{returns:"locator"},getByRole:{returns:"locator"},getByTestId:{returns:"locator"},getByText:{returns:"locator"},getByTitle:{returns:"locator"},locator:{returns:"locator"},owner:{returns:"locator"}}};function I($){throw new tQ($)}function z0($){if(!$||typeof $!=="object"||Array.isArray($))return!1;let Q=Object.getPrototypeOf($);return Q===Object.prototype||Q===null}function J9($,Q=0,Z={nodes:0}){if(Q>$Z||++Z.nodes>QZ)I("hands_repl_json_too_complex");if($===null||typeof $==="boolean"||typeof $==="string")return;if(typeof $==="number"){if(!Number.isFinite($))I("hands_repl_invalid_json");return}if(Array.isArray($)){for(let X of $)J9(X,Q+1,Z);return}if(!z0($))I("hands_repl_invalid_json");for(let[X,J]of Object.entries($)){if(eQ.has(X))I("hands_repl_invalid_json");J9(J,Q+1,Z)}}function v8($){return typeof $==="string"&&Object.hasOwn(ZZ,$)}function U1($){if(!$.endsWith("[]"))return null;let Q=$.slice(0,-2);return v8(Q)?Q:null}function oQ($){return z0($)&&Object.keys($).length===2&&$.$handsRepl==="bytes"&&typeof $.base64==="string"}function W1($){return z0($)&&Object.keys($).length===1&&$.$handsRepl==="undefined"}function rQ($){return z0($)&&Object.keys($).length===2&&$.$handsRepl==="routeFulfill"&&"options"in $}function k0($){return!!$&&typeof $==="object"}function t9(){return Object.freeze({$handsRepl:"undefined"})}function B1($){if(!X9.isBuffer($)&&!($ instanceof Uint8Array))I("hands_repl_expected_bytes");return Object.freeze({$handsRepl:"bytes",base64:X9.from($).toString("base64")})}function XZ($){if(!k0($.browser)||!k0($.context)||!k0($.page))I("hands_repl_invalid_roots");if(typeof $.a11y!=="function"||typeof $.view!=="function")I("hands_repl_invalid_callbacks");let Q=$.maxHandles??K1;if(!Number.isInteger(Q)||Q<3||Q>1e5)I("hands_repl_invalid_handle_limit");let Z=new Map,X=new WeakMap,J=$.createOpaqueId??z1,Y=(z,L)=>{if(!k0(L))I("hands_repl_expected_target");let W=X.get(L)?.get(z);if(W)return W;if(Z.size>=Q)I("hands_repl_handle_limit");let U="";for(let q=0;q<16;q+=1){let A=`hands_${J()}`;if(aQ.test(A)&&!Z.has(A)){U=A;break}}if(!U)I("hands_repl_invalid_opaque_id");let j=Object.freeze({$handsRepl:"handle",id:U,kind:z});Z.set(U,{kind:z,target:L});let O=X.get(L);if(!O)O=new Map,X.set(L,O);return O.set(z,j),j},K=Object.freeze({browser:Y("browser",$.browser),context:Y("context",$.context),page:Y("page",$.page)}),V=(z)=>{if(!z0(z)||Object.keys(z).length!==3||z.$handsRepl!=="handle"||typeof z.id!=="string"||!aQ.test(z.id)||!v8(z.kind))I("hands_repl_invalid_handle");let L=Z.get(z.id);if(!L||L.kind!==z.kind)I("hands_repl_unknown_handle");return L},G=(z,L=0,W=new Set)=>{if(L>$Z)I("hands_repl_json_too_complex");if(z===void 0)return t9();if(z===null||typeof z==="boolean"||typeof z==="string")return z;if(typeof z==="number"){if(!Number.isFinite(z))I("hands_repl_non_json_result");return z}if(Array.isArray(z)){if(W.has(z))I("hands_repl_cyclic_result");W.add(z);try{return z.map((U)=>G(U,L+1,W))}finally{W.delete(z)}}if(!z0(z))I("hands_repl_non_json_result");if(W.has(z))I("hands_repl_cyclic_result");W.add(z);try{let U=Object.create(null);for(let j of Object.keys(z)){let O=Object.getOwnPropertyDescriptor(z,j);if(!O||!("value"in O))continue;U[j]=G(O.value,L+1,W)}return U}finally{W.delete(z)}},F=(z,L)=>{if(L==="void")return t9();if(L==="json")return G(z);if(L==="bytes")return B1(z);let W=U1(L);if(W){if(!Array.isArray(z))I("hands_repl_expected_target_list");if(W==="context"&&z.some((U)=>U!==$.context))I("hands_repl_foreign_context");return z.map((U)=>Y(W,U))}if(z===null||z===void 0)return t9();if(!v8(L))I("hands_repl_invalid_return_kind");if(L==="context"&&z!==$.context)I("hands_repl_foreign_context");return Y(L,z)},B=(z)=>{if(z0(z)&&z.$handsRepl==="handle")return V(z).target;if(oQ(z))return X9.from(z.base64,"base64");if(W1(z))return;if(rQ(z))I("hands_repl_route_fulfill_only");if(Array.isArray(z))return z.map(B);if(!z0(z))return z;let L=Object.create(null);for(let[W,U]of Object.entries(z))L[W]=B(U);return L};return Object.freeze({roots:K,dispatch:async(z)=>{if(!z0(z)||typeof z.type!=="string")I("hands_repl_invalid_request");if(z.type==="a11y"){let T=z.target===void 0?Z.get(K.page.id):V(z.target);if(!T||T.kind!=="page"&&T.kind!=="locator")I("hands_repl_invalid_a11y_target");return G(await $.a11y(T.target))}if(z.type==="view"){if(J9(z.source),z.options!==void 0)J9(z.options);let T=oQ(z.source)?X9.from(z.source.base64,"base64"):z.source;if($.privateProfile&&!X9.isBuffer(T))I("hands_repl_profile_requires_image_bytes");return G(await $.view(T,z.options))}if(z.type!=="call")I("hands_repl_invalid_request");if(typeof z.method!=="string"||z.method.length===0||z.method.length>128)I("hands_repl_invalid_method");if(eQ.has(z.method))I("hands_repl_forbidden_method");let L=V(z.target),W=z.args??[];if(!Array.isArray(W))I("hands_repl_invalid_arguments");if(J9(W),L.kind==="page"&&z.method==="captureScreenshot"){if(W.length!==0)I("hands_repl_invalid_arguments");if(!$.screenshotExport)I("hands_repl_screenshot_export_unavailable");return G(await $.screenshotExport(L.target))}if(L.kind==="context"&&["startRecording","stopRecording"].includes(z.method)){if(!$.recording||L.target!==$.context)I("hands_repl_recording_unavailable");if(W.length>(z.method==="startRecording"?1:0))I("hands_repl_invalid_arguments");return G(z.method==="startRecording"?await $.recording.start(W[0]):await $.recording.stop())}if($.privateProfile){let T=z.method;if(["evaluate","evaluateAll","waitForFunction","addInitScript","addScriptTag","addStyleTag","setContent","setInputFiles","route","content","cookies","storageState","addCookies","clearCookies","setExtraHTTPHeaders","setHTTPCredentials","grantPermissions","clearPermissions","innerHTML","textContent","allTextContents"].includes(T)||L.kind==="browser"&&T==="close"||L.kind==="context"&&T==="close")I("hands_repl_private_profile_method_denied");if(L.kind==="browser"&&T==="contexts")return F([$.context],"context[]");if((T==="screenshot"||T==="pdf")&&z0(W[0])&&(("path"in W[0])||("style"in W[0])))I("hands_repl_private_profile_path_denied");if(T==="goto"){if(typeof W[0]!=="string")I("hands_repl_private_profile_url_denied");try{let S=new URL(W[0]);if(!["http:","https:"].includes(S.protocol)&&W[0]!=="about:blank")I("hands_repl_private_profile_url_denied")}catch{I("hands_repl_private_profile_url_denied")}}if(T==="getAttribute"&&(typeof W[0]!=="string"||!V1.has(W[0].toLowerCase())))I("hands_repl_private_profile_attribute_denied");if(L.kind==="locator"&&["innerText","allInnerTexts","getAttribute"].includes(T)){let S=[L.target];if(T==="allInnerTexts"){let g=Reflect.get(L.target,"all");if(typeof g!=="function")I("hands_repl_private_profile_probe_unavailable");let E=await Reflect.apply(g,L.target,[]);if(!Array.isArray(E)||E.length>QZ||!E.every(k0))I("hands_repl_private_profile_probe_unavailable");S=E}for(let g of S){let E=Reflect.get(g,"isVisible");if(typeof E!=="function"||!await Reflect.apply(E,g,[]))I("hands_repl_private_profile_hidden_value_denied")}}if(T==="press"&&typeof W[0]==="string"&&F1(W[0]))I("hands_repl_private_profile_browser_shortcut_denied");if(L.kind==="locator"&&["inputValue","click","dblclick","tap","press"].includes(T)){let S=Reflect.get(L.target,"evaluate");if(typeof S!=="function")I("hands_repl_private_profile_probe_unavailable");let g=await Reflect.apply(S,L.target,[H1]);if(!z0(g)||typeof g.password!=="boolean"||typeof g.executableLink!=="boolean")I("hands_repl_private_profile_probe_unavailable");if(T==="inputValue"&&g.password)I("hands_repl_private_profile_password_denied");if(T!=="inputValue"&&g.executableLink)I("hands_repl_private_profile_url_denied");if(T==="inputValue"){let E=Reflect.get(L.target,"isVisible");if(typeof E!=="function"||!await Reflect.apply(E,L.target,[]))I("hands_repl_private_profile_hidden_value_denied")}}}let U=ZZ[L.kind][z.method];if(!U)I("hands_repl_method_not_allowed");if(U.requiresStringSource&&typeof W[0]!=="string")I("hands_repl_string_source_required");if(L.kind==="browser"&&z.method==="contexts")return[K.context];if(["addInitScript","addScriptTag","addStyleTag","screenshot","pdf","storageState"].includes(z.method)&&W.some((T)=>z0(T)&&("path"in T)))I("hands_repl_file_path_not_allowed");if(z.method==="goto"&&typeof W[0]==="string"){let T;try{T=new URL(W[0]).protocol}catch{I("hands_repl_invalid_url")}if(!["http:","https:","data:","about:","blob:"].includes(T))I("hands_repl_file_path_not_allowed")}if(U.special==="contextViewportSize"){let T=Reflect.get(L.target,"pages");if(typeof T!=="function")I("hands_repl_method_unavailable");let S=await Reflect.apply(T,L.target,[]),g=Array.isArray(S)?S[0]:void 0,E=k0(g)?Reflect.get(g,"viewportSize"):void 0;if(typeof E!=="function")return t9();return F(await Reflect.apply(E,g,[]),U.returns)}if(U.special==="property"){let T=Reflect.get(L.target,z.method);return F(typeof T==="function"?Reflect.apply(T,L.target,[]):T,U.returns)}let j=Reflect.get(L.target,z.method);if(typeof j!=="function")I("hands_repl_method_unavailable");if(U.special==="route"){let T=W[1];if(!rQ(T))I("hands_repl_invalid_route_handler");J9(T.options);let S=B(T.options),g=async(M)=>{if(!k0(M))I("hands_repl_invalid_route");let D=Reflect.get(M,"fulfill");if(typeof D!=="function")I("hands_repl_invalid_route");await Reflect.apply(D,M,[S])},E=[B(W[0]??null),g],N=await Reflect.apply(j,L.target,E);return F(N,U.returns)}let O=W.map(B);if(z.method==="setInputFiles"){let T=L.kind==="locator"?0:1,S=async(E)=>{if(typeof E!=="string"){if(!z0(E)||typeof E.name!=="string"||typeof E.mimeType!=="string"||!X9.isBuffer(E.buffer))I("hands_repl_invalid_file_input");return E}if(!$.readWorkspaceFile)I("hands_repl_workspace_required");return $.readWorkspaceFile(E)},g=O[T];O[T]=Array.isArray(g)?await Promise.all(g.map(S)):await S(g)}if(z.method==="goto")await $.beforeNavigation?.();let q=$.actionRecorder?.(),A=await Reflect.apply(j,L.target,O),P={click:"Click browser element",tap:"Click browser element",dblclick:"Double click browser element",fill:"Type text",type:"Type text",pressSequentially:"Type text",clear:"Clear browser field",press:"Press key",scrollIntoViewIfNeeded:"Scroll browser element into view",dragTo:"Drag on computer",selectOption:"Select browser option",check:"Check browser control",uncheck:"Uncheck browser control",hover:"Hover browser element",focus:"Focus browser element",goto:"Open browser page",reload:"Reload browser page",goBack:"Go back in browser",goForward:"Go forward in browser",screenshot:"Take browser screenshot"}[z.method];if(P){let T=Reflect.get(L.target,"page"),S=L.kind==="page"?L.target:typeof T==="function"?Reflect.apply(T,L.target,[]):void 0;q?.(P,k0(S)?S:void 0)}return F(A,U.returns)}})}import{isIP as KZ}from"net";import{Resolver as L1}from"dns/promises";import{isIP as $8}from"net";var N1=[["0.0.0.0",8],["10.0.0.0",8],["100.64.0.0",10],["127.0.0.0",8],["169.254.0.0",16],["172.16.0.0",12],["192.0.0.0",24],["192.0.2.0",24],["192.168.0.0",16],["198.18.0.0",15],["198.51.100.0",24],["203.0.113.0",24],["224.0.0.0",4],["240.0.0.0",4]];function c8($){if($8($)!==4)return null;let Q=$.split(".");if(Q.length!==4)return null;let Z=0;for(let X of Q){let J=Number(X);if(!Number.isInteger(J)||J<0||J>255)return null;Z=Z*256+J}return Z>>>0}function M1($,Q,Z){let X=c8(Q);if(X===null)return!1;let J=Z===0?0:4294967295<<32-Z>>>0;return($&J)>>>0===(X&J)>>>0}function JZ($){let Q=c8($);if(Q===null)return!0;return N1.some(([Z,X])=>M1(Q,Z,X))}function j1($){if($8($)!==6)return null;let Q=$.toLowerCase(),Z=Q.indexOf("%");if(Z>=0)Q=Q.slice(0,Z);let X=[],J=Q.lastIndexOf(":"),Y=J>=0?Q.slice(J+1):"";if(Y.includes(".")){let z=c8(Y);if(z===null)return null;X=[z>>>16&65535,z&65535],Q=Q.slice(0,J+1)+"0:0"}let K=Q.split("::");if(K.length>2)return null;let V=(z)=>{if(z==="")return[];let L=[];for(let W of z.split(":")){if(W===""||W.length>4||!/^[0-9a-f]+$/.test(W))return null;L.push(Number.parseInt(W,16))}return L},G=V(K[0]??"");if(G===null)return null;if(K.length===1){let z=G;if(z.length!==8)return null;return X.length>0?z.slice(0,6).concat(X):z}let F=V(K[1]??"");if(F===null)return null;let B=8-G.length-F.length;if(B<0)return null;let H=G.concat(Array(B).fill(0),F);if(H.length!==8)return null;return X.length>0?H.slice(0,6).concat(X):H}function C1($,Q){return`${$>>8&255}.${$&255}.${Q>>8&255}.${Q&255}`}function q1($){let Q=j1($);if(Q===null)return!0;let[Z,X,J]=Q;if((Z&57344)!==8192)return!0;if(Z===8193&&(X&65024)===0)return!0;if(Z===8193&&X===3512)return!0;if(Z===16383&&(X&61440)===0)return!0;if(Z===8194)return JZ(C1(X,J));return!1}function YZ($){return $.replace(/^\[|\]$/g,"")}function e9($){let Q=YZ($.trim()),Z=$8(Q);if(Z===4)return JZ(Q);if(Z===6)return q1(Q);return!0}function GZ($){if($ instanceof Error&&$.name==="TimeoutError")return"dns_timeout";switch(typeof $==="object"&&$!==null&&"code"in $?$.code:void 0){case"ENOTFOUND":return"dns_not_found";case"ENODATA":return"dns_empty";case"EAI_AGAIN":case"ESERVFAIL":case"ECONNREFUSED":return"dns_temporary";case"ETIMEOUT":case"ETIMEDOUT":return"dns_timeout";default:return"dns_failed"}}var zZ=5000;function T1($){return async(Q,Z)=>{if(Z?.aborted)throw Error("aborted");let X=new L1({timeout:zZ,tries:1});if($)X.setServers($);let J=()=>X.cancel();Z?.addEventListener("abort",J,{once:!0});try{let[Y,K]=await Promise.allSettled([X.resolve4(Q),X.resolve6(Q)]),V=[...Y.status==="fulfilled"?Y.value:[],...K.status==="fulfilled"?K.value:[]];if(V.length>0)return V;let G=[Y,K].flatMap((B)=>B.status==="rejected"?[B.reason]:[]);throw G.find((B)=>["dns_temporary","dns_timeout"].includes(GZ(B)))??G[0]??Object.assign(Error("DNS returned no addresses"),{code:"ENODATA"})}finally{Z?.removeEventListener("abort",J)}}}var O1=T1();async function D1($,Q,Z,X){if(X?.aborted)throw Error("aborted");let J=new AbortController,Y,K,V=Q($,J.signal);V.catch(()=>{});try{return await Promise.race([V,new Promise((G,F)=>{if(Y=setTimeout(()=>F(new DOMException("DNS lookup timed out","TimeoutError")),Z),X)K=()=>F(Error("aborted")),X.addEventListener("abort",K,{once:!0})})])}finally{if(Y!==void 0)clearTimeout(Y);if(X&&K)X.removeEventListener("abort",K);J.abort()}}async function XX($,Q=O1,Z){let X=YZ($);if($8(X))return e9(X)?{ok:!1,reason:"non_public_ip"}:{ok:!0,addresses:[X]};let J;try{J=await D1(X,Q,zZ,Z)}catch(Y){return{ok:!1,reason:Z?.aborted?Z.reason instanceof Error&&Z.reason.name==="TimeoutError"?"dns_timeout":"aborted":GZ(Y)}}if(J.length===0)return{ok:!1,reason:"dns_empty"};if(J.some(e9))return{ok:!1,reason:"non_public_ip"};return{ok:!0,addresses:J}}var _1=/^(?:\*\.)?[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?$/;function d8($){return $.length<=253&&_1.test($.toLowerCase())}function A1($,Q){let Z=$.trim().toLowerCase();if(!d8(Z))return!1;if(Z.startsWith("*.")){let X=Z.slice(2);return Q===X||Q.endsWith(`.${X}`)}return Z===Q}function x1($){let Q=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec($);if(!Q)return null;let Z=Q.slice(1).map(Number);return Z.some((X)=>X>255)?null:Z}function p8($,Q=[]){let Z=(X)=>{if(X=X.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,""),!X.includes(":"))return X;try{X=new URL(`http://[${X}]/`).hostname.slice(1,-1)}catch{return X}let J=/^::ffff:([\da-f]+):([\da-f]+)$/.exec(X);if(!J)return X;let Y=parseInt(J[1],16),K=parseInt(J[2],16);return`${Y>>8}.${Y&255}.${K>>8}.${K&255}`};return Q.some((X)=>Z(X)===Z($))}function l0($){$=$.toLowerCase().replace(/^\[|\]$/g,"");let Q=x1($);if(Q){let[Y,K,V]=Q;if(Y===127)return"loopback";return Y===0||Y===10||Y>=224||Y===100&&K>=64&&K<=127||Y===169&&K===254||Y===172&&K>=16&&K<=31||Y===192&&(K===168||K===0&&(V===0||V===2)||K===88&&V===99)||Y===198&&(K===18||K===19||K===51&&V===100)||Y===203&&K===0&&V===113?"private":"public"}if(!$.includes(":"))return"hostname";try{$=new URL(`http://[${$}]/`).hostname.slice(1,-1)}catch{return"private"}if($==="::1")return"loopback";let Z=/^::ffff:([\da-f]+):([\da-f]+)$/.exec($);if(Z){let Y=parseInt(Z[1],16),K=parseInt(Z[2],16);return l0(`${Y>>8}.${Y&255}.${K>>8}.${K&255}`)==="public"?"public":"private"}let[X,J=0]=$.split(":").map((Y)=>parseInt(Y||"0",16));return X<8192||X>16383||X===8194||X===8193&&(J<512||J===3512)||X===16383&&J<4096?"private":"public"}function I9($,Q){let Z;try{Z=new URL($)}catch{return{allowed:!1,url:$,host:null,reason:"invalid_url"}}if(["about:","data:","blob:"].includes(Z.protocol))return{allowed:!0,url:$,host:null,reason:"local_document"};if(!["http:","https:","ws:","wss:"].includes(Z.protocol))return{allowed:!1,url:$,host:Z.hostname||null,reason:"unsupported_protocol"};let X=Z.hostname.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"");if(Q.mode==="off")return{allowed:!0,url:$,host:X,reason:"policy_off"};let J=(V)=>({allowed:!1,url:$,host:X,reason:V});if(Z.username||Z.password)return J("invalid_url");if(Q.mode==="public_web"){let V=l0(X)!=="public"&&l0(X)!=="hostname"||X==="localhost"||/\.(?:localhost|local|internal|arpa)$/.test(X)||!X.includes(".")&&!KZ(X)||Boolean(KZ(X)&&e9(X));return{allowed:!V,url:$,host:X,reason:V?"private_network":"public_web"}}let Y=Number(Z.port||(["https:","wss:"].includes(Z.protocol)?443:80));if(Q.deniedPorts?.includes(Y)||p8(X,Q.deniedHosts))return J("destination_not_allowed");let K=l0(X);if(K==="private"||["local","internal","arpa"].some((V)=>X===V||X.endsWith(`.${V}`)))return J("private_network");if(K==="loopback"||X==="localhost"||X.endsWith(".localhost"))return Q.allowedLoopbackPorts?.includes(Y)?{allowed:!0,url:$,host:X,reason:"loopback"}:J("destination_not_allowed");if(Q.allowedDomains.some((V)=>A1(V,X)))return{allowed:!0,url:$,host:X,reason:"allowed_domain"};return{allowed:!1,url:$,host:X,reason:"destination_not_allowed"}}import FZ from"child_process";import{accessSync as I1,constants as R1,readFileSync as E1,statSync as WZ}from"fs";import{createRequire as BZ}from"module";import{homedir as HZ}from"os";import{dirname as S1,isAbsolute as l8,join as Y9,resolve as w1}from"path";var Q8=Object.freeze({schemaVersion:1,driver:"playwright-core",driverVersion:UZ.dependencies["playwright-core"],browser:"chromium"}),LZ=["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge","/Applications/Brave Browser.app/Contents/MacOS/Brave Browser","/Applications/Chromium.app/Contents/MacOS/Chromium"],u8=["/usr/bin/chromium","/usr/bin/chromium-browser","/usr/bin/google-chrome","/usr/bin/google-chrome-stable"];function R9($){try{return I1($,R1.X_OK),l8($)&&WZ($).isFile()}catch{return!1}}function s8($,Q=process.platform){let Z=Q==="darwin"?LZ:Q==="linux"?u8:null;return Z?($??Z).find(R9)??null:null}function b1(){if(!process.versions.bun)return;let $=Symbol.for("ara.headless-browser.bun-pipe-owners");if(Object.hasOwn(globalThis,$))return;let Q=[];FZ.spawn=new Proxy(FZ.spawn,{apply(Z,X,J){let Y=Reflect.apply(Z,X,J),K=J[1],V=J[2]?.stdio;if(Array.isArray(K)&&K.includes("--remote-debugging-pipe")&&Array.isArray(V)&&V[3]==="pipe"&&V[4]==="pipe")Q.push(Y);return Y}}),Object.defineProperty(globalThis,$,{value:Q})}async function Z8($){if(b1(),$!==void 0){if(!l8($))throw Error("hands_browser_driver_path_must_be_absolute");let X=Y9($,"package.json"),J=JSON.parse(E1(X,"utf8"));if(J.name!==Q8.driver)throw Error("hands_browser_wrong_driver");let Y=BZ(X)($),K=Y.default?.chromium??Y.chromium;if(!K)throw Error("hands_browser_missing_chromium");return{version:J.version,chromium:K}}let[Q,Z]=await Promise.all([import("./index-t1h1wd8g.js"),import("./package-vj1s3sye.js").then((m)=>P1(m.default,1))]);return{version:Z.default.version,chromium:Q.chromium}}var k1=($,Q=Q8.driverVersion)=>({status:"unavailable",reason:$,expectedDriverVersion:Q}),f1=($)=>$.loadDriver?.()??Z8($.driverModuleDirectory),g1={"1.60.0":"1223"};function BX(){let $=process.platform,Q=g1[Q8.driverVersion];if(!Q||$!=="linux"&&$!=="darwin")return!1;let Z=(X)=>process.env[X]??process.env[`npm_config_${X.toLowerCase()}`]??process.env[`npm_package_config_${X.toLowerCase()}`];try{let X=Z("PLAYWRIGHT_BROWSERS_PATH"),J=X==="0"?Y9(S1(BZ(import.meta.url).resolve("playwright-core/package.json")),".local-browsers"):X?w1(Z("INIT_CWD")||process.cwd(),X):Y9($==="darwin"?Y9(HZ(),"Library","Caches"):process.env.XDG_CACHE_HOME||Y9(HZ(),".cache"),"ms-playwright");return WZ(Y9(J,`chromium-${Q}`,"INSTALLATION_COMPLETE")).isFile()}catch{return!1}}async function G9($={}){return NZ($,Q8.driverVersion)}async function n8($,Q={}){if($.driverVersion!=="1.61.1"||!l8($.driverModuleDirectory))throw Error("hands_browser_invalid_managed_compatibility");return NZ({...Q,driverModuleDirectory:$.driverModuleDirectory,allowSystemBrowser:!0},$.driverVersion)}async function NZ($,Q){let Z=(G)=>k1(G,Q),X=$.platform??process.platform;if(X!=="linux"&&X!=="darwin")return Z("unsupported_platform");let J;try{J=await f1($)}catch{return Z("driver_missing")}if(J.version!==Q)return Z("driver_version_mismatch");let Y=(G,F)=>({status:"resolved",executablePath:G,source:F,driverVersion:J.version});if($.executablePath!==void 0)return R9($.executablePath)?Y($.executablePath,"configured"):Z("executable_missing");let K=J.chromium.executablePath();if(R9(K))return Y(K,"managed");let V=$.allowSystemBrowser===!0?s8($.systemCandidates,X):null;return V?Y(V,"system"):Z("executable_missing")}var a1=["/usr/local/bin/chromium",...u8];function o1($,Q=DZ()){return s8($??(Q==="linux"?a1:void 0),Q)}async function r1(){try{return(await Z8()).chromium}catch{return l1(import.meta.url)("playwright-core").chromium}}var t1=1048576,e1=105000,$7=20000,CZ=5000,Q7=2000,Z7=1000,X7=30000,qZ=81920,J7={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".gif":"image/gif"};async function Y7($,Q){let Z=new URL($.url()),X={...await $.allHeaders(),host:Z.host};for(let J of Object.keys(X))if(/^(?:proxy-|connection$|upgrade$|transfer-encoding$|content-length$)/i.test(J))delete X[J];return new Promise((J,Y)=>{let V=(Z.protocol==="https:"?s1:u1)(Z,{method:$.method(),headers:X,agent:!1,lookup:(F,B,H)=>{let z=u0.isIP(Q);if(B.all)H(null,[{address:Q,family:z}]);else H(null,Q,z)}},(F)=>{let B=[],H=0;F.on("data",(z)=>{if(H+=z.length,H>33554432)V.destroy(Error("hands_browser_response_too_large"));else B.push(z)}),F.on("error",Y),F.on("end",()=>{let z={};for(let[L,W]of Object.entries(F.headers))if(W!==void 0&&!["transfer-encoding","connection","content-length"].includes(L))z[L]=Array.isArray(W)?W.join(`
306
+ `.trim();import{Buffer as X9}from"buffer";import{randomUUID as z1}from"crypto";class tQ extends Error{code;constructor($){super($==="hands_repl_private_profile_attribute_denied"?"Private browser attribute read denied.":$);this.code=$;this.name="HandsReplBrowserDispatcherError"}}var eQ=new Set(["__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","__proto__","constructor","prototype"]),aQ=/^hands_[A-Za-z0-9_-]{8,128}$/,K1=2048,$Z=32,QZ=1e4,V1=new Set(["href","src","alt","title","role","aria-label","aria-expanded","aria-checked","aria-selected","aria-disabled","placeholder","type","name","data-testid"]);function F1($){let Q=$.split("+"),Z=(Q.pop()??"").replace(/^Key/,"").toLowerCase();if(Z==="f12")return!0;if(Q.some((X)=>["Control","ControlOrMeta","Meta"].includes(X))&&["l","n","t","j","i","p","s","w","u","o","r","tab","pageup","pagedown"].includes(Z))return!0;if(Q.some((X)=>["Control","ControlOrMeta","Meta"].includes(X))&&Q.includes("Shift")&&Z==="c")return!0;return Q.includes("Alt")&&["d","arrowleft","arrowright","home"].includes(Z)}var H1=($)=>{let Q=$.closest("a[href],area[href]");return{password:$.tagName==="INPUT"&&$.type==="password",executableLink:Boolean(Q&&!/^(https?:|about:blank)/i.test(Q.href))}},ZZ={browser:{close:{returns:"void"},contexts:{returns:"context[]"},isConnected:{returns:"json"},version:{returns:"json"}},context:{addCookies:{returns:"void"},addInitScript:{returns:"void"},browser:{returns:"browser"},clearCookies:{returns:"void"},clearPermissions:{returns:"void"},close:{returns:"void"},cookies:{returns:"json"},grantPermissions:{returns:"void"},newPage:{returns:"page"},pages:{returns:"page[]"},setDefaultNavigationTimeout:{returns:"void"},setDefaultTimeout:{returns:"void"},setExtraHTTPHeaders:{returns:"void"},setGeolocation:{returns:"void"},setHTTPCredentials:{returns:"void"},setOffline:{returns:"void"},setViewportSize:{returns:"void"},storageState:{returns:"json"},viewportSize:{returns:"json",special:"contextViewportSize"}},page:{addInitScript:{returns:"void"},addScriptTag:{returns:"void"},addStyleTag:{returns:"void"},bringToFront:{returns:"void"},close:{returns:"void"},content:{returns:"json"},context:{returns:"context"},emulateMedia:{returns:"void"},evaluate:{returns:"json",requiresStringSource:!0},frame:{returns:"frame"},frameLocator:{returns:"frameLocator"},frames:{returns:"frame[]"},getByAltText:{returns:"locator"},getByLabel:{returns:"locator"},getByPlaceholder:{returns:"locator"},getByRole:{returns:"locator"},getByTestId:{returns:"locator"},getByText:{returns:"locator"},getByTitle:{returns:"locator"},goBack:{returns:"void"},goForward:{returns:"void"},goto:{returns:"void"},isClosed:{returns:"json"},locator:{returns:"locator"},mainFrame:{returns:"frame"},opener:{returns:"page"},pdf:{returns:"bytes"},reload:{returns:"void"},screenshot:{returns:"bytes"},selectOption:{returns:"json"},setContent:{returns:"void"},setDefaultNavigationTimeout:{returns:"void"},setDefaultTimeout:{returns:"void"},setExtraHTTPHeaders:{returns:"void"},setInputFiles:{returns:"void"},setViewportSize:{returns:"void"},title:{returns:"json"},url:{returns:"json"},viewportSize:{returns:"json"},waitForFunction:{returns:"void",requiresStringSource:!0},waitForLoadState:{returns:"void"},waitForNavigation:{returns:"void"},waitForTimeout:{returns:"void"},waitForURL:{returns:"void"}},locator:{all:{returns:"locator[]"},allInnerTexts:{returns:"json"},allTextContents:{returns:"json"},and:{returns:"locator"},ariaSnapshot:{returns:"json"},blur:{returns:"void"},boundingBox:{returns:"json"},check:{returns:"void"},clear:{returns:"void"},click:{returns:"void"},contentFrame:{returns:"frameLocator"},count:{returns:"json"},dblclick:{returns:"void"},dragTo:{returns:"void"},evaluate:{returns:"json",requiresStringSource:!0},evaluateAll:{returns:"json",requiresStringSource:!0},fill:{returns:"void"},filter:{returns:"locator"},first:{returns:"locator",special:"property"},focus:{returns:"void"},getAttribute:{returns:"json"},getByAltText:{returns:"locator"},getByLabel:{returns:"locator"},getByPlaceholder:{returns:"locator"},getByRole:{returns:"locator"},getByTestId:{returns:"locator"},getByText:{returns:"locator"},getByTitle:{returns:"locator"},hover:{returns:"void"},innerHTML:{returns:"json"},innerText:{returns:"json"},inputValue:{returns:"json"},isChecked:{returns:"json"},isEditable:{returns:"json"},isEnabled:{returns:"json"},isHidden:{returns:"json"},isVisible:{returns:"json"},last:{returns:"locator",special:"property"},locator:{returns:"locator"},nth:{returns:"locator"},or:{returns:"locator"},page:{returns:"page"},press:{returns:"void"},pressSequentially:{returns:"void"},scrollIntoViewIfNeeded:{returns:"void"},screenshot:{returns:"bytes"},selectOption:{returns:"json"},setInputFiles:{returns:"void"},tap:{returns:"void"},textContent:{returns:"json"},type:{returns:"void"},uncheck:{returns:"void"},waitFor:{returns:"void"}},frame:{addScriptTag:{returns:"void"},addStyleTag:{returns:"void"},childFrames:{returns:"frame[]"},content:{returns:"json"},evaluate:{returns:"json",requiresStringSource:!0},frameLocator:{returns:"frameLocator"},getByAltText:{returns:"locator"},getByLabel:{returns:"locator"},getByPlaceholder:{returns:"locator"},getByRole:{returns:"locator"},getByTestId:{returns:"locator"},getByText:{returns:"locator"},getByTitle:{returns:"locator"},goto:{returns:"void"},isDetached:{returns:"json"},locator:{returns:"locator"},name:{returns:"json"},page:{returns:"page"},parentFrame:{returns:"frame"},setContent:{returns:"void"},title:{returns:"json"},url:{returns:"json"},waitForFunction:{returns:"void",requiresStringSource:!0},waitForLoadState:{returns:"void"},waitForNavigation:{returns:"void"},waitForTimeout:{returns:"void"},waitForURL:{returns:"void"}},frameLocator:{getByAltText:{returns:"locator"},getByLabel:{returns:"locator"},getByPlaceholder:{returns:"locator"},getByRole:{returns:"locator"},getByTestId:{returns:"locator"},getByText:{returns:"locator"},getByTitle:{returns:"locator"},locator:{returns:"locator"},owner:{returns:"locator"}}};function I($){throw new tQ($)}function z0($){if(!$||typeof $!=="object"||Array.isArray($))return!1;let Q=Object.getPrototypeOf($);return Q===Object.prototype||Q===null}function J9($,Q=0,Z={nodes:0}){if(Q>$Z||++Z.nodes>QZ)I("hands_repl_json_too_complex");if($===null||typeof $==="boolean"||typeof $==="string")return;if(typeof $==="number"){if(!Number.isFinite($))I("hands_repl_invalid_json");return}if(Array.isArray($)){for(let X of $)J9(X,Q+1,Z);return}if(!z0($))I("hands_repl_invalid_json");for(let[X,J]of Object.entries($)){if(eQ.has(X))I("hands_repl_invalid_json");J9(J,Q+1,Z)}}function v8($){return typeof $==="string"&&Object.hasOwn(ZZ,$)}function U1($){if(!$.endsWith("[]"))return null;let Q=$.slice(0,-2);return v8(Q)?Q:null}function oQ($){return z0($)&&Object.keys($).length===2&&$.$handsRepl==="bytes"&&typeof $.base64==="string"}function W1($){return z0($)&&Object.keys($).length===1&&$.$handsRepl==="undefined"}function rQ($){return z0($)&&Object.keys($).length===2&&$.$handsRepl==="routeFulfill"&&"options"in $}function k0($){return!!$&&typeof $==="object"}function t9(){return Object.freeze({$handsRepl:"undefined"})}function B1($){if(!X9.isBuffer($)&&!($ instanceof Uint8Array))I("hands_repl_expected_bytes");return Object.freeze({$handsRepl:"bytes",base64:X9.from($).toString("base64")})}function XZ($){if(!k0($.browser)||!k0($.context)||!k0($.page))I("hands_repl_invalid_roots");if(typeof $.a11y!=="function"||typeof $.view!=="function")I("hands_repl_invalid_callbacks");let Q=$.maxHandles??K1;if(!Number.isInteger(Q)||Q<3||Q>1e5)I("hands_repl_invalid_handle_limit");let Z=new Map,X=new WeakMap,J=$.createOpaqueId??z1,Y=(z,L)=>{if(!k0(L))I("hands_repl_expected_target");let W=X.get(L)?.get(z);if(W)return W;if(Z.size>=Q)I("hands_repl_handle_limit");let U="";for(let q=0;q<16;q+=1){let A=`hands_${J()}`;if(aQ.test(A)&&!Z.has(A)){U=A;break}}if(!U)I("hands_repl_invalid_opaque_id");let j=Object.freeze({$handsRepl:"handle",id:U,kind:z});Z.set(U,{kind:z,target:L});let O=X.get(L);if(!O)O=new Map,X.set(L,O);return O.set(z,j),j},K=Object.freeze({browser:Y("browser",$.browser),context:Y("context",$.context),page:Y("page",$.page)}),V=(z)=>{if(!z0(z)||Object.keys(z).length!==3||z.$handsRepl!=="handle"||typeof z.id!=="string"||!aQ.test(z.id)||!v8(z.kind))I("hands_repl_invalid_handle");let L=Z.get(z.id);if(!L||L.kind!==z.kind)I("hands_repl_unknown_handle");return L},G=(z,L=0,W=new Set)=>{if(L>$Z)I("hands_repl_json_too_complex");if(z===void 0)return t9();if(z===null||typeof z==="boolean"||typeof z==="string")return z;if(typeof z==="number"){if(!Number.isFinite(z))I("hands_repl_non_json_result");return z}if(Array.isArray(z)){if(W.has(z))I("hands_repl_cyclic_result");W.add(z);try{return z.map((U)=>G(U,L+1,W))}finally{W.delete(z)}}if(!z0(z))I("hands_repl_non_json_result");if(W.has(z))I("hands_repl_cyclic_result");W.add(z);try{let U=Object.create(null);for(let j of Object.keys(z)){let O=Object.getOwnPropertyDescriptor(z,j);if(!O||!("value"in O))continue;U[j]=G(O.value,L+1,W)}return U}finally{W.delete(z)}},F=(z,L)=>{if(L==="void")return t9();if(L==="json")return G(z);if(L==="bytes")return B1(z);let W=U1(L);if(W){if(!Array.isArray(z))I("hands_repl_expected_target_list");if(W==="context"&&z.some((U)=>U!==$.context))I("hands_repl_foreign_context");return z.map((U)=>Y(W,U))}if(z===null||z===void 0)return t9();if(!v8(L))I("hands_repl_invalid_return_kind");if(L==="context"&&z!==$.context)I("hands_repl_foreign_context");return Y(L,z)},B=(z)=>{if(z0(z)&&z.$handsRepl==="handle")return V(z).target;if(oQ(z))return X9.from(z.base64,"base64");if(W1(z))return;if(rQ(z))I("hands_repl_route_fulfill_only");if(Array.isArray(z))return z.map(B);if(!z0(z))return z;let L=Object.create(null);for(let[W,U]of Object.entries(z))L[W]=B(U);return L};return Object.freeze({roots:K,dispatch:async(z)=>{if(!z0(z)||typeof z.type!=="string")I("hands_repl_invalid_request");if(z.type==="a11y"){let T=z.target===void 0?Z.get(K.page.id):V(z.target);if(!T||T.kind!=="page"&&T.kind!=="locator")I("hands_repl_invalid_a11y_target");return G(await $.a11y(T.target))}if(z.type==="view"){if(J9(z.source),z.options!==void 0)J9(z.options);let T=oQ(z.source)?X9.from(z.source.base64,"base64"):z.source;if($.privateProfile&&!X9.isBuffer(T))I("hands_repl_profile_requires_image_bytes");return G(await $.view(T,z.options))}if(z.type!=="call")I("hands_repl_invalid_request");if(typeof z.method!=="string"||z.method.length===0||z.method.length>128)I("hands_repl_invalid_method");if(eQ.has(z.method))I("hands_repl_forbidden_method");let L=V(z.target),W=z.args??[];if(!Array.isArray(W))I("hands_repl_invalid_arguments");if(J9(W),L.kind==="page"&&z.method==="captureScreenshot"){if(W.length!==0)I("hands_repl_invalid_arguments");if(!$.screenshotExport)I("hands_repl_screenshot_export_unavailable");return G(await $.screenshotExport(L.target))}if(L.kind==="context"&&["startRecording","stopRecording"].includes(z.method)){if(!$.recording||L.target!==$.context)I("hands_repl_recording_unavailable");if(W.length>(z.method==="startRecording"?1:0))I("hands_repl_invalid_arguments");return G(z.method==="startRecording"?await $.recording.start(W[0]):await $.recording.stop())}if($.privateProfile){let T=z.method;if(["evaluate","evaluateAll","waitForFunction","addInitScript","addScriptTag","addStyleTag","setContent","setInputFiles","route","content","cookies","storageState","addCookies","clearCookies","setExtraHTTPHeaders","setHTTPCredentials","grantPermissions","clearPermissions","innerHTML","textContent","allTextContents"].includes(T)||L.kind==="browser"&&T==="close"||L.kind==="context"&&T==="close")I("hands_repl_private_profile_method_denied");if(L.kind==="browser"&&T==="contexts")return F([$.context],"context[]");if((T==="screenshot"||T==="pdf")&&z0(W[0])&&(("path"in W[0])||("style"in W[0])))I("hands_repl_private_profile_path_denied");if(T==="goto"){if(typeof W[0]!=="string")I("hands_repl_private_profile_url_denied");try{let S=new URL(W[0]);if(!["http:","https:"].includes(S.protocol)&&W[0]!=="about:blank")I("hands_repl_private_profile_url_denied")}catch{I("hands_repl_private_profile_url_denied")}}if(T==="getAttribute"&&(typeof W[0]!=="string"||!V1.has(W[0].toLowerCase())))I("hands_repl_private_profile_attribute_denied");if(L.kind==="locator"&&["innerText","allInnerTexts","getAttribute"].includes(T)){let S=[L.target];if(T==="allInnerTexts"){let g=Reflect.get(L.target,"all");if(typeof g!=="function")I("hands_repl_private_profile_probe_unavailable");let E=await Reflect.apply(g,L.target,[]);if(!Array.isArray(E)||E.length>QZ||!E.every(k0))I("hands_repl_private_profile_probe_unavailable");S=E}for(let g of S){let E=Reflect.get(g,"isVisible");if(typeof E!=="function"||!await Reflect.apply(E,g,[]))I("hands_repl_private_profile_hidden_value_denied")}}if(T==="press"&&typeof W[0]==="string"&&F1(W[0]))I("hands_repl_private_profile_browser_shortcut_denied");if(L.kind==="locator"&&["inputValue","click","dblclick","tap","press"].includes(T)){let S=Reflect.get(L.target,"evaluate");if(typeof S!=="function")I("hands_repl_private_profile_probe_unavailable");let g=await Reflect.apply(S,L.target,[H1]);if(!z0(g)||typeof g.password!=="boolean"||typeof g.executableLink!=="boolean")I("hands_repl_private_profile_probe_unavailable");if(T==="inputValue"&&g.password)I("hands_repl_private_profile_password_denied");if(T!=="inputValue"&&g.executableLink)I("hands_repl_private_profile_url_denied");if(T==="inputValue"){let E=Reflect.get(L.target,"isVisible");if(typeof E!=="function"||!await Reflect.apply(E,L.target,[]))I("hands_repl_private_profile_hidden_value_denied")}}}let U=ZZ[L.kind][z.method];if(!U)I("hands_repl_method_not_allowed");if(U.requiresStringSource&&typeof W[0]!=="string")I("hands_repl_string_source_required");if(L.kind==="browser"&&z.method==="contexts")return[K.context];if(["addInitScript","addScriptTag","addStyleTag","screenshot","pdf","storageState"].includes(z.method)&&W.some((T)=>z0(T)&&("path"in T)))I("hands_repl_file_path_not_allowed");if(z.method==="goto"&&typeof W[0]==="string"){let T;try{T=new URL(W[0]).protocol}catch{I("hands_repl_invalid_url")}if(!["http:","https:","data:","about:","blob:"].includes(T))I("hands_repl_file_path_not_allowed")}if(U.special==="contextViewportSize"){let T=Reflect.get(L.target,"pages");if(typeof T!=="function")I("hands_repl_method_unavailable");let S=await Reflect.apply(T,L.target,[]),g=Array.isArray(S)?S[0]:void 0,E=k0(g)?Reflect.get(g,"viewportSize"):void 0;if(typeof E!=="function")return t9();return F(await Reflect.apply(E,g,[]),U.returns)}if(U.special==="property"){let T=Reflect.get(L.target,z.method);return F(typeof T==="function"?Reflect.apply(T,L.target,[]):T,U.returns)}let j=Reflect.get(L.target,z.method);if(typeof j!=="function")I("hands_repl_method_unavailable");if(U.special==="route"){let T=W[1];if(!rQ(T))I("hands_repl_invalid_route_handler");J9(T.options);let S=B(T.options),g=async(M)=>{if(!k0(M))I("hands_repl_invalid_route");let D=Reflect.get(M,"fulfill");if(typeof D!=="function")I("hands_repl_invalid_route");await Reflect.apply(D,M,[S])},E=[B(W[0]??null),g],N=await Reflect.apply(j,L.target,E);return F(N,U.returns)}let O=W.map(B);if(z.method==="setInputFiles"){let T=L.kind==="locator"?0:1,S=async(E)=>{if(typeof E!=="string"){if(!z0(E)||typeof E.name!=="string"||typeof E.mimeType!=="string"||!X9.isBuffer(E.buffer))I("hands_repl_invalid_file_input");return E}if(!$.readWorkspaceFile)I("hands_repl_workspace_required");return $.readWorkspaceFile(E)},g=O[T];O[T]=Array.isArray(g)?await Promise.all(g.map(S)):await S(g)}if(z.method==="goto")await $.beforeNavigation?.();let q=$.actionRecorder?.(),A=await Reflect.apply(j,L.target,O),P={click:"Click browser element",tap:"Click browser element",dblclick:"Double click browser element",fill:"Type text",type:"Type text",pressSequentially:"Type text",clear:"Clear browser field",press:"Press key",scrollIntoViewIfNeeded:"Scroll browser element into view",dragTo:"Drag on computer",selectOption:"Select browser option",check:"Check browser control",uncheck:"Uncheck browser control",hover:"Hover browser element",focus:"Focus browser element",goto:"Open browser page",reload:"Reload browser page",goBack:"Go back in browser",goForward:"Go forward in browser",screenshot:"Take browser screenshot"}[z.method];if(P){let T=Reflect.get(L.target,"page"),S=L.kind==="page"?L.target:typeof T==="function"?Reflect.apply(T,L.target,[]):void 0;q?.(P,k0(S)?S:void 0)}return F(A,U.returns)}})}import{isIP as KZ}from"net";import{Resolver as L1}from"dns/promises";import{isIP as $8}from"net";var N1=[["0.0.0.0",8],["10.0.0.0",8],["100.64.0.0",10],["127.0.0.0",8],["169.254.0.0",16],["172.16.0.0",12],["192.0.0.0",24],["192.0.2.0",24],["192.168.0.0",16],["198.18.0.0",15],["198.51.100.0",24],["203.0.113.0",24],["224.0.0.0",4],["240.0.0.0",4]];function c8($){if($8($)!==4)return null;let Q=$.split(".");if(Q.length!==4)return null;let Z=0;for(let X of Q){let J=Number(X);if(!Number.isInteger(J)||J<0||J>255)return null;Z=Z*256+J}return Z>>>0}function M1($,Q,Z){let X=c8(Q);if(X===null)return!1;let J=Z===0?0:4294967295<<32-Z>>>0;return($&J)>>>0===(X&J)>>>0}function JZ($){let Q=c8($);if(Q===null)return!0;return N1.some(([Z,X])=>M1(Q,Z,X))}function j1($){if($8($)!==6)return null;let Q=$.toLowerCase(),Z=Q.indexOf("%");if(Z>=0)Q=Q.slice(0,Z);let X=[],J=Q.lastIndexOf(":"),Y=J>=0?Q.slice(J+1):"";if(Y.includes(".")){let z=c8(Y);if(z===null)return null;X=[z>>>16&65535,z&65535],Q=Q.slice(0,J+1)+"0:0"}let K=Q.split("::");if(K.length>2)return null;let V=(z)=>{if(z==="")return[];let L=[];for(let W of z.split(":")){if(W===""||W.length>4||!/^[0-9a-f]+$/.test(W))return null;L.push(Number.parseInt(W,16))}return L},G=V(K[0]??"");if(G===null)return null;if(K.length===1){let z=G;if(z.length!==8)return null;return X.length>0?z.slice(0,6).concat(X):z}let F=V(K[1]??"");if(F===null)return null;let B=8-G.length-F.length;if(B<0)return null;let H=G.concat(Array(B).fill(0),F);if(H.length!==8)return null;return X.length>0?H.slice(0,6).concat(X):H}function C1($,Q){return`${$>>8&255}.${$&255}.${Q>>8&255}.${Q&255}`}function q1($){let Q=j1($);if(Q===null)return!0;let[Z,X,J]=Q;if((Z&57344)!==8192)return!0;if(Z===8193&&(X&65024)===0)return!0;if(Z===8193&&X===3512)return!0;if(Z===16383&&(X&61440)===0)return!0;if(Z===8194)return JZ(C1(X,J));return!1}function YZ($){return $.replace(/^\[|\]$/g,"")}function e9($){let Q=YZ($.trim()),Z=$8(Q);if(Z===4)return JZ(Q);if(Z===6)return q1(Q);return!0}function GZ($){if($ instanceof Error&&$.name==="TimeoutError")return"dns_timeout";switch(typeof $==="object"&&$!==null&&"code"in $?$.code:void 0){case"ENOTFOUND":return"dns_not_found";case"ENODATA":return"dns_empty";case"EAI_AGAIN":case"ESERVFAIL":case"ECONNREFUSED":return"dns_temporary";case"ETIMEOUT":case"ETIMEDOUT":return"dns_timeout";default:return"dns_failed"}}var zZ=5000;function T1($){return async(Q,Z)=>{if(Z?.aborted)throw Error("aborted");let X=new L1({timeout:zZ,tries:1});if($)X.setServers($);let J=()=>X.cancel();Z?.addEventListener("abort",J,{once:!0});try{let[Y,K]=await Promise.allSettled([X.resolve4(Q),X.resolve6(Q)]),V=[...Y.status==="fulfilled"?Y.value:[],...K.status==="fulfilled"?K.value:[]];if(V.length>0)return V;let G=[Y,K].flatMap((B)=>B.status==="rejected"?[B.reason]:[]);throw G.find((B)=>["dns_temporary","dns_timeout"].includes(GZ(B)))??G[0]??Object.assign(Error("DNS returned no addresses"),{code:"ENODATA"})}finally{Z?.removeEventListener("abort",J)}}}var O1=T1();async function D1($,Q,Z,X){if(X?.aborted)throw Error("aborted");let J=new AbortController,Y,K,V=Q($,J.signal);V.catch(()=>{});try{return await Promise.race([V,new Promise((G,F)=>{if(Y=setTimeout(()=>F(new DOMException("DNS lookup timed out","TimeoutError")),Z),X)K=()=>F(Error("aborted")),X.addEventListener("abort",K,{once:!0})})])}finally{if(Y!==void 0)clearTimeout(Y);if(X&&K)X.removeEventListener("abort",K);J.abort()}}async function XX($,Q=O1,Z){let X=YZ($);if($8(X))return e9(X)?{ok:!1,reason:"non_public_ip"}:{ok:!0,addresses:[X]};let J;try{J=await D1(X,Q,zZ,Z)}catch(Y){return{ok:!1,reason:Z?.aborted?Z.reason instanceof Error&&Z.reason.name==="TimeoutError"?"dns_timeout":"aborted":GZ(Y)}}if(J.length===0)return{ok:!1,reason:"dns_empty"};if(J.some(e9))return{ok:!1,reason:"non_public_ip"};return{ok:!0,addresses:J}}var _1=/^(?:\*\.)?[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?$/;function d8($){return $.length<=253&&_1.test($.toLowerCase())}function A1($,Q){let Z=$.trim().toLowerCase();if(!d8(Z))return!1;if(Z.startsWith("*.")){let X=Z.slice(2);return Q===X||Q.endsWith(`.${X}`)}return Z===Q}function x1($){let Q=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec($);if(!Q)return null;let Z=Q.slice(1).map(Number);return Z.some((X)=>X>255)?null:Z}function p8($,Q=[]){let Z=(X)=>{if(X=X.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,""),!X.includes(":"))return X;try{X=new URL(`http://[${X}]/`).hostname.slice(1,-1)}catch{return X}let J=/^::ffff:([\da-f]+):([\da-f]+)$/.exec(X);if(!J)return X;let Y=parseInt(J[1],16),K=parseInt(J[2],16);return`${Y>>8}.${Y&255}.${K>>8}.${K&255}`};return Q.some((X)=>Z(X)===Z($))}function l0($){$=$.toLowerCase().replace(/^\[|\]$/g,"");let Q=x1($);if(Q){let[Y,K,V]=Q;if(Y===127)return"loopback";return Y===0||Y===10||Y>=224||Y===100&&K>=64&&K<=127||Y===169&&K===254||Y===172&&K>=16&&K<=31||Y===192&&(K===168||K===0&&(V===0||V===2)||K===88&&V===99)||Y===198&&(K===18||K===19||K===51&&V===100)||Y===203&&K===0&&V===113?"private":"public"}if(!$.includes(":"))return"hostname";try{$=new URL(`http://[${$}]/`).hostname.slice(1,-1)}catch{return"private"}if($==="::1")return"loopback";let Z=/^::ffff:([\da-f]+):([\da-f]+)$/.exec($);if(Z){let Y=parseInt(Z[1],16),K=parseInt(Z[2],16);return l0(`${Y>>8}.${Y&255}.${K>>8}.${K&255}`)==="public"?"public":"private"}let[X,J=0]=$.split(":").map((Y)=>parseInt(Y||"0",16));return X<8192||X>16383||X===8194||X===8193&&(J<512||J===3512)||X===16383&&J<4096?"private":"public"}function I9($,Q){let Z;try{Z=new URL($)}catch{return{allowed:!1,url:$,host:null,reason:"invalid_url"}}if(["about:","data:","blob:"].includes(Z.protocol))return{allowed:!0,url:$,host:null,reason:"local_document"};if(!["http:","https:","ws:","wss:"].includes(Z.protocol))return{allowed:!1,url:$,host:Z.hostname||null,reason:"unsupported_protocol"};let X=Z.hostname.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"");if(Q.mode==="off")return{allowed:!0,url:$,host:X,reason:"policy_off"};let J=(V)=>({allowed:!1,url:$,host:X,reason:V});if(Z.username||Z.password)return J("invalid_url");if(Q.mode==="public_web"){let V=l0(X)!=="public"&&l0(X)!=="hostname"||X==="localhost"||/\.(?:localhost|local|internal|arpa)$/.test(X)||!X.includes(".")&&!KZ(X)||Boolean(KZ(X)&&e9(X));return{allowed:!V,url:$,host:X,reason:V?"private_network":"public_web"}}let Y=Number(Z.port||(["https:","wss:"].includes(Z.protocol)?443:80));if(Q.deniedPorts?.includes(Y)||p8(X,Q.deniedHosts))return J("destination_not_allowed");let K=l0(X);if(K==="private"||["local","internal","arpa"].some((V)=>X===V||X.endsWith(`.${V}`)))return J("private_network");if(K==="loopback"||X==="localhost"||X.endsWith(".localhost"))return Q.allowedLoopbackPorts?.includes(Y)?{allowed:!0,url:$,host:X,reason:"loopback"}:J("destination_not_allowed");if(Q.allowedDomains.some((V)=>A1(V,X)))return{allowed:!0,url:$,host:X,reason:"allowed_domain"};return{allowed:!1,url:$,host:X,reason:"destination_not_allowed"}}import FZ from"child_process";import{accessSync as I1,constants as R1,readFileSync as E1,statSync as WZ}from"fs";import{createRequire as BZ}from"module";import{homedir as HZ}from"os";import{dirname as S1,isAbsolute as l8,join as Y9,resolve as w1}from"path";var Q8=Object.freeze({schemaVersion:1,driver:"playwright-core",driverVersion:UZ.dependencies["playwright-core"],browser:"chromium"}),LZ=["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge","/Applications/Brave Browser.app/Contents/MacOS/Brave Browser","/Applications/Chromium.app/Contents/MacOS/Chromium"],u8=["/usr/bin/chromium","/usr/bin/chromium-browser","/usr/bin/google-chrome","/usr/bin/google-chrome-stable"];function R9($){try{return I1($,R1.X_OK),l8($)&&WZ($).isFile()}catch{return!1}}function s8($,Q=process.platform){let Z=Q==="darwin"?LZ:Q==="linux"?u8:null;return Z?($??Z).find(R9)??null:null}function b1(){if(!process.versions.bun)return;let $=Symbol.for("ara.headless-browser.bun-pipe-owners");if(Object.hasOwn(globalThis,$))return;let Q=[];FZ.spawn=new Proxy(FZ.spawn,{apply(Z,X,J){let Y=Reflect.apply(Z,X,J),K=J[1],V=J[2]?.stdio;if(Array.isArray(K)&&K.includes("--remote-debugging-pipe")&&Array.isArray(V)&&V[3]==="pipe"&&V[4]==="pipe")Q.push(Y);return Y}}),Object.defineProperty(globalThis,$,{value:Q})}async function Z8($){if(b1(),$!==void 0){if(!l8($))throw Error("hands_browser_driver_path_must_be_absolute");let X=Y9($,"package.json"),J=JSON.parse(E1(X,"utf8"));if(J.name!==Q8.driver)throw Error("hands_browser_wrong_driver");let Y=BZ(X)($),K=Y.default?.chromium??Y.chromium;if(!K)throw Error("hands_browser_missing_chromium");return{version:J.version,chromium:K}}let[Q,Z]=await Promise.all([import("./index-swa20ch8.js"),import("./package-1e3w44ve.js").then((m)=>P1(m.default,1))]);return{version:Z.default.version,chromium:Q.chromium}}var k1=($,Q=Q8.driverVersion)=>({status:"unavailable",reason:$,expectedDriverVersion:Q}),f1=($)=>$.loadDriver?.()??Z8($.driverModuleDirectory),g1={"1.60.0":"1223"};function BX(){let $=process.platform,Q=g1[Q8.driverVersion];if(!Q||$!=="linux"&&$!=="darwin")return!1;let Z=(X)=>process.env[X]??process.env[`npm_config_${X.toLowerCase()}`]??process.env[`npm_package_config_${X.toLowerCase()}`];try{let X=Z("PLAYWRIGHT_BROWSERS_PATH"),J=X==="0"?Y9(S1(BZ(import.meta.url).resolve("playwright-core/package.json")),".local-browsers"):X?w1(Z("INIT_CWD")||process.cwd(),X):Y9($==="darwin"?Y9(HZ(),"Library","Caches"):process.env.XDG_CACHE_HOME||Y9(HZ(),".cache"),"ms-playwright");return WZ(Y9(J,`chromium-${Q}`,"INSTALLATION_COMPLETE")).isFile()}catch{return!1}}async function G9($={}){return NZ($,Q8.driverVersion)}async function n8($,Q={}){if($.driverVersion!=="1.61.1"||!l8($.driverModuleDirectory))throw Error("hands_browser_invalid_managed_compatibility");return NZ({...Q,driverModuleDirectory:$.driverModuleDirectory,allowSystemBrowser:!0},$.driverVersion)}async function NZ($,Q){let Z=(G)=>k1(G,Q),X=$.platform??process.platform;if(X!=="linux"&&X!=="darwin")return Z("unsupported_platform");let J;try{J=await f1($)}catch{return Z("driver_missing")}if(J.version!==Q)return Z("driver_version_mismatch");let Y=(G,F)=>({status:"resolved",executablePath:G,source:F,driverVersion:J.version});if($.executablePath!==void 0)return R9($.executablePath)?Y($.executablePath,"configured"):Z("executable_missing");let K=J.chromium.executablePath();if(R9(K))return Y(K,"managed");let V=$.allowSystemBrowser===!0?s8($.systemCandidates,X):null;return V?Y(V,"system"):Z("executable_missing")}var a1=["/usr/local/bin/chromium",...u8];function o1($,Q=DZ()){return s8($??(Q==="linux"?a1:void 0),Q)}async function r1(){try{return(await Z8()).chromium}catch{return l1(import.meta.url)("playwright-core").chromium}}var t1=1048576,e1=105000,$7=20000,CZ=5000,Q7=2000,Z7=1000,X7=30000,qZ=81920,J7={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".gif":"image/gif"};async function Y7($,Q){let Z=new URL($.url()),X={...await $.allHeaders(),host:Z.host};for(let J of Object.keys(X))if(/^(?:proxy-|connection$|upgrade$|transfer-encoding$|content-length$)/i.test(J))delete X[J];return new Promise((J,Y)=>{let V=(Z.protocol==="https:"?s1:u1)(Z,{method:$.method(),headers:X,agent:!1,lookup:(F,B,H)=>{let z=u0.isIP(Q);if(B.all)H(null,[{address:Q,family:z}]);else H(null,Q,z)}},(F)=>{let B=[],H=0;F.on("data",(z)=>{if(H+=z.length,H>33554432)V.destroy(Error("hands_browser_response_too_large"));else B.push(z)}),F.on("error",Y),F.on("end",()=>{let z={};for(let[L,W]of Object.entries(F.headers))if(W!==void 0&&!["transfer-encoding","connection","content-length"].includes(L))z[L]=Array.isArray(W)?W.join(`
307
307
  `):W;J({status:F.statusCode??502,headers:z,body:Buffer.concat(B)})})}),G=setTimeout(()=>V.destroy(Error("hands_browser_fetch_timeout")),X7);V.once("close",()=>clearTimeout(G)),V.on("error",Y),V.end($.postDataBuffer()??void 0)})}async function G7($,Q,Z=()=>{},X={lookup:(J)=>p1(J,{all:!0}),fetch:Y7}){let J=new WeakSet,Y=new WeakMap,K=(V)=>{let G=Y.get(V);if(G)return G;let F=(async()=>{if(!$.newCDPSession)return;let B=await $.newCDPSession(V),H=new Map;B.on("Network.loadingFinished",({requestId:z})=>H.delete(z)),B.on("Network.loadingFailed",({requestId:z})=>H.delete(z)),B.on("Fetch.requestPaused",async(z)=>{let L=z.networkId??z.requestId,W=z.redirectedRequestId?(H.get(L)??0)+1:0;H.set(L,W);let U=I9(z.request.url,Q),j=Q.mode==="enforce"&&Boolean(z.redirectedRequestId)&&U.host!==null&&!u0.isIP(U.host),O=!U.allowed?U:j?{...U,allowed:!1,reason:"destination_not_allowed"}:W>20?{...U,allowed:!1,reason:"redirect_not_supported"}:null;try{if(O)Z(O),await B.send("Fetch.failRequest",{requestId:z.requestId,errorReason:"BlockedByClient"});else await B.send("Fetch.continueRequest",{requestId:z.requestId})}catch{await B.send("Fetch.failRequest",{requestId:z.requestId,errorReason:"Failed"}).catch(()=>{})}}),await B.send("Network.enable"),await B.send("Fetch.enable",{patterns:[{urlPattern:"*",requestStage:"Request"}]}),J.add(V)})();return Y.set(V,F),F};return await $.route("**/*",async(V)=>{let G=V.request().url(),F=I9(G,Q);if(F.allowed&&Q.mode==="public_web"){await V.continue();return}let B=V.request();if(F.allowed&&F.host&&u0.isIP(F.host)&&B.isNavigationRequest?.()){let H=B.frame();if(J.has(H.page())&&H===H.page().mainFrame()){await V.continue();return}}if(F.allowed&&(Q.mode==="off"||F.reason==="local_document")){await V.continue();return}if(F.allowed&&F.host)try{let H=F.host,z=l0(H),L,W=await(async()=>{if(z!=="hostname")return[{address:H,family:u0.isIP(H)}];if(F.reason==="loopback")return[{address:"127.0.0.1",family:4}];try{return await Promise.race([X.lookup(H),new Promise((U,j)=>{L=setTimeout(()=>j(Error("hands_browser_dns_timeout")),5000)})])}finally{if(L)clearTimeout(L)}})();if(!W.length||W.some(({address:U})=>{let j=l0(U);return!u0.isIP(U)||Q.mode==="enforce"&&p8(U,Q.deniedHosts)||(F.reason==="loopback"?j!=="loopback":j!=="public")}))F={...F,allowed:!1,reason:"private_network"};else{let U=await X.fetch(V.request(),W[0].address);if(U.status>=300&&U.status<400){let j=U.headers.location??G;try{j=new URL(j,G).href}catch{}let O=I9(j,Q);F=O.allowed?{...O,allowed:!1,reason:"redirect_not_supported"}:O}else{await V.fulfill(U);return}}}catch{await V.abort("failed");return}Z(F),await V.abort("blockedbyclient")}),await $.routeWebSocket("**/*",async(V)=>{let G=I9(V.url(),Q);if(Q.mode==="enforce"&&G.allowed&&(!G.host||!u0.isIP(G.host)))G={...G,allowed:!1,reason:"destination_not_allowed"};if(G.allowed){V.connectToServer();return}Z(G),await V.close({code:1008,reason:"Reason egress policy denied"})}),Q.mode==="off"?void 0:{preparePage:K}}async function _Z($,Q=DZ(),Z){if(Z){let J=await n8(Z,{platform:Q,systemCandidates:$});return J.status==="resolved"?J.executablePath:null}if($!==void 0){let J=o1($,Q);if(J)return J}let X=await G9({platform:Q,systemCandidates:$,allowSystemBrowser:!0});return X.status==="resolved"?X.executablePath:null}function TZ($,Q){if(!$)throw Error("hands_repl_workspace_required");let Z=a8($),X=z9($),J=o8(X,z9(X,Q)),K=J!==".."&&!J.startsWith(`..${r8}`)&&!jZ(J)?z9(Z,J):z9(Z,Q);if(b0(z9(X,Q))||b0(K))throw Error("hands_repl_protected_path");let V=(W)=>{let U=o8(Z,W);return U!==""&&U!==".."&&!U.startsWith(`..${r8}`)&&!jZ(U)},G=a8(K);if(b0(G))throw Error("hands_repl_protected_path");if(!V(K)||!V(G))throw Error("hands_repl_file_outside_workspace");let F=o8(Z,K).split(r8),B=[Z,...F.map((W,U)=>z9(Z,...F.slice(0,U+1)))],H=B.map((W)=>MZ(W));if(H.some((W)=>W.isSymbolicLink()))throw Error("hands_repl_file_symlink");let z=H[H.length-1];if(!z.isFile()||z.nlink!==1||z.size>16777216)throw Error("hands_repl_file_not_regular_or_too_large");let L=v1(K,i8.O_RDONLY|i8.O_NOFOLLOW|i8.O_NONBLOCK);try{let W=h1(L);if(W.dev!==z.dev||W.ino!==z.ino||!W.isFile())throw Error("hands_repl_file_changed");for(let q=0;q<B.length;q++){let A=MZ(B[q]);if(A.dev!==H[q].dev||A.ino!==H[q].ino||A.isSymbolicLink())throw Error("hands_repl_file_changed")}if(!V(a8(K)))throw Error("hands_repl_file_outside_workspace");let U=Buffer.alloc(16777217),j=0;while(j<U.length){let q=c1(L,U,j,U.length-j,null);if(!q)break;j+=q}if(j===U.length)throw Error("hands_repl_file_too_large");let O=U.subarray(0,j);return{name:n1(K),mimeType:J7[i1(K).toLowerCase()]??"application/octet-stream",buffer:O}}finally{y1(L)}}function K9($,Q){$.end(`${JSON.stringify(Q)}
308
308
  `)}function X8($){try{d1($)}catch{}}async function AZ($){if($.managedBrowser&&$.driverModuleDirectory!==void 0)throw Error("hands_browser_ambiguous_driver_configuration");let Q=$.launch||$.targetContext?null:$.managedBrowser?await n8($.managedBrowser,{executablePath:$.browserExecutablePath}):await G9({executablePath:$.browserExecutablePath,driverModuleDirectory:$.driverModuleDirectory});if(Q?.status==="unavailable")throw Error(`hands_browser_${Q.reason}`);let Z=Q?.status==="resolved"?Q.executablePath:$.browserExecutablePath;if(!Z||!R9(Z))throw Error("hands_browser_unavailable");let X=$.launch??(async(N)=>($.targetContext?await r1():(await Z8($.managedBrowser?.driverModuleDirectory??$.driverModuleDirectory)).chromium).launch(N)),J=[],Y={},K=null,V=null,G=null,F=null,B=!1,H=null,z=new Map,L=new WeakMap,W=null,U=()=>{if(B)throw Error("hands_repl_stopped");if(F)throw F},j=(N)=>{let M=L.get(N);if(M)return M;let D=Promise.resolve().then(()=>N.close()).then(()=>{z.delete(N)});return L.set(N,D),D},O=async()=>{let N=[...z.entries()].reverse(),M=W??=performance.now()+Z7,D=Promise.allSettled(N.filter(([,_])=>_==="context").map(([_])=>j(_))),w;try{await Promise.race([D,new Promise((_)=>{w=setTimeout(_,Math.max(0,M-performance.now()))})])}finally{if(w)clearTimeout(w)}let k=await Promise.allSettled(N.map(([_])=>j(_))),f=[];for(let[_,m]of k.entries()){if(m.status!=="rejected")continue;let c=m.reason instanceof Error&&["Error","TimeoutError","ProtocolError"].includes(m.reason.name)?m.reason.name:"unknown";f.push(Error(`hands_repl_close_failed: ${N[_][1]}: ${c}`))}if(f.length)throw AggregateError(f,"hands_repl_stop_unconfirmed")},q=(N,M)=>{if(z.set(N,M),B||F)j(N).catch(()=>{return}),U();return N},A=async()=>{let N=await X({executablePath:Z,headless:!0,chromiumSandbox:$.managedBrowser===void 0,args:["--disable-background-networking","--disable-quic","--disable-dev-shm-usage","--disable-gpu","--disable-software-rasterizer","--dns-prefetch-disable","--force-webrtc-ip-handling-policy=disable_non_proxied_udp","--no-pings"]}),M=null;try{q(N,"browser"),M=$.targetContext??q(await N.newContext({viewport:{width:1440,height:900},screen:{width:1440,height:900},serviceWorkers:"block",acceptDownloads:!1}),"context");let D=await G7(M,$.networkPolicy??{mode:"off"},$.onEgressDenied);if(U(),D){let b=M.newPage.bind(M);M.newPage=async()=>{let h=await b();return await D.preparePage(h),h}}let k=M.pages()[0]??await M.newPage();await D?.preparePage(k),U();let f=async(b=k)=>{let h=b;if(typeof h.ariaSnapshot==="function")return h.ariaSnapshot({timeout:1e4});return k.locator("body").innerText({timeout:1e4})},_=async(b,h={})=>{let d=h&&typeof h==="object"&&!Array.isArray(h)?h:{},u,G0="image/png";if(Buffer.isBuffer(b)||b instanceof Uint8Array)u=Buffer.from(b);else if(typeof b==="string"&&(b.startsWith("data:")||/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(b)))u=Buffer.from(b.replace(/^data:[^,]*,/,""),"base64");else if(typeof b==="string"){let T0=TZ($.workspaceRoot,b);u=T0.buffer,G0=T0.mimeType}else throw Error("view() needs a Buffer, a base64 string, or a path to an image file");if(u.length===0)throw Error("view(): the image is empty");let M0=String(d.label??"").replace(/[\r\n>]+/g," ").trim().slice(0,120),U0=Number(d.maxWidth)||1024,W0=Number(d.quality)||72,y0=$.targetContext?await N.newPage():await M.newPage();try{let T0=`data:${G0};base64,${u.toString("base64")}`;for(let r=0;r<5;r+=1){let j0=await y0.evaluate(async(B0)=>{let C0=new Image;C0.src=B0.url,await C0.decode();let h0=Math.min(1,B0.maxWidth/C0.naturalWidth),Y0=document.createElement("canvas");Y0.width=Math.max(1,Math.round(C0.naturalWidth*h0)),Y0.height=Math.max(1,Math.round(C0.naturalHeight*h0));let X0=Y0.getContext("2d");if(!X0)throw Error("view(): canvas unavailable");return X0.fillStyle="#ffffff",X0.fillRect(0,0,Y0.width,Y0.height),X0.drawImage(C0,0,0,Y0.width,Y0.height),{data:Y0.toDataURL("image/jpeg",B0.q/100).split(",")[1]??"",width:Y0.width,height:Y0.height,sourceWidth:C0.naturalWidth,sourceHeight:C0.naturalHeight}},{url:T0,maxWidth:U0,q:W0}),r0=Buffer.from(j0.data,"base64");if(r0.length<=qZ){let B0=M0||"image";return`<<<ARA_VIEW_IMAGE ${j0.data} image/jpeg ${B0}>>>
309
309
  Viewing ${B0} (${j0.sourceWidth}x${j0.sourceHeight} source, sent at ${j0.width}x${j0.height}, ${Math.round(r0.length/1024)}KB).`}if(U0>640)U0=Math.round(U0*0.75);else W0=Math.max(30,W0-15)}throw Error(`view(): could not reduce the image under ${Math.round(qZ/1024)}KB`)}finally{await y0.close().catch(()=>{return})}},m=XZ({browser:$.targetContext?.browser()??N,context:M,page:k,a11y:f,view:_,readWorkspaceFile:(b)=>TZ($.workspaceRoot,b),privateProfile:$.privateProfile,beforeNavigation:$.beforeNavigation,recording:$.recording,screenshotExport:$.screenshotExport,actionRecorder:()=>{let b=J,h=Y;return(d,u)=>{if(b.length<OZ)b.push(d);if(u)h.page=u}}}),c=async(b)=>{U();let h=q(await N.newContext({serviceWorkers:"block",acceptDownloads:!1}),"context");try{await h.route("**/*",(u)=>u.abort()),U(),await h.routeWebSocket("**/*",(u)=>u.close({code:1008,reason:"Reason evaluator network denied"})),U(),await h.exposeBinding("__araHandsRpc",async(u,G0)=>$.onBrowserOperation?$.onBrowserOperation(b,()=>m.dispatch(G0)):m.dispatch(G0)),U();let d=await h.newPage();return U(),await d.goto("data:text/html,<title>Reason Hands evaluator</title>"),U(),await d.evaluate(`(${nQ})(${JSON.stringify(m.roots)})`),{context:h,page:d,runId:b}}catch(d){throw await j(h).catch(()=>{return}),d}},l=await c(),o={browser:N,context:M,page:k,evaluator:l,async captureProgressFrame(b){return _(await b.screenshot({type:"jpeg",quality:65,timeout:2000}),{label:"Screen after browser action"})},async resetEvaluator(b){await j(o.evaluator.context),o.evaluator=await c(b)}};return U(),o}catch(D){throw await O().catch(()=>{return}),D}},R=async()=>{if(U(),K)return K;if(!G){V=A();let N;G=Promise.race([V,new Promise((M,D)=>{N=setTimeout(()=>D(Error("hands_browser_unavailable: startup timed out")),$7)})]).then((M)=>{return U(),K=M,M}).catch(async()=>{F=Error("hands_browser_unavailable: startup failed or timed out");let M;try{await Promise.race([O(),new Promise((D,w)=>{M=setTimeout(()=>w(Error("hands_repl_stop_timeout")),CZ)})])}catch{F=Error("hands_browser_unavailable: startup cleanup unconfirmed")}finally{if(M)clearTimeout(M)}throw F}).finally(()=>{if(N)clearTimeout(N)})}return G},P=async(N,M,D=!1)=>{let w=await R(),k=Y;if($.onBrowserOperation&&w.evaluator.runId!==M)await w.resetEvaluator(M);let _=(async()=>{let l=await w.evaluator.page.evaluate(`(${iQ})(${JSON.stringify({code:N})})`);if(typeof l!=="string")throw Error("hands_repl_invalid_evaluator_output");let o=k.page;if(D&&o&&!l.includes("<<<ARA_VIEW_IMAGE")){let b=()=>w.captureProgressFrame(o);try{let h=await($.onBrowserOperation?$.onBrowserOperation(M,b):b());return k.automaticProgressImage=!0,`${l}
@@ -456,4 +456,4 @@ lines.on("line", (line) => {
456
456
  `,(S)=>{if(!S)return;B(T,void 0,S)})});try{if(!G){if(Z.pid===void 0)await S9(X);throw J??Error("hands_node_repl_control_pipe_missing")}let q=await W({action:"probe"});if(q.ok!==!0||q.output!=="ARA_HANDS_REPL_READY")throw Error("hands_node_repl_probe_failed")}catch(q){Y=!0,Z.kill("SIGKILL");try{await S9(X)}finally{await Q.cleanup()}throw q}let U=Promise.resolve(),j=new Set;G$($.socketPath);let O=e7.createServer((q)=>{j.add(q),q.once("close",()=>j.delete(q)),q.setEncoding("utf8");let A="",R=!1,P=!1;q.once("close",()=>{if(P)H()}),q.on("error",()=>q.destroy()),q.on("data",(T)=>{if(R)return;if(A+=T,A.length>iZ){R=!0,V8(q,{ok:!1,error:"REPL request exceeds 1 MiB"});return}let S=A.indexOf(`
457
457
  `);if(S===-1)return;R=!0;let g=A.slice(0,S);U=U.then(async()=>{if(q.destroyed)return;try{let E=JSON.parse(g);if(E.action!=="evaluate"||typeof E.code!=="string")throw Error("Invalid REPL request");P=!0;let N=await W({action:"evaluate",code:E.code});if(P=!1,N.ok!==!0||typeof N.output!=="string")throw Error(typeof N.error==="string"?N.error:"hands_node_repl_failed");V8(q,{ok:!0,output:N.output})}catch(E){P=!1,V8(q,{ok:!1,error:E instanceof Error?E.message:String(E),stack:E instanceof Error?E.stack:void 0})}}).catch((E)=>{V8(q,{ok:!1,error:E instanceof Error?E.message:String(E)})})})});try{await new Promise((q,A)=>{O.once("error",A),O.listen($.socketPath,()=>{O.off("error",A);try{n7($.socketPath,384),q()}catch(R){O.close(()=>A(R))}})})}catch(q){Y=!0,Z.kill("SIGKILL");try{await S9(X)}finally{await Q.cleanup(),G$($.socketPath)}throw q}return{socketPath:$.socketPath,async stop(){if(Y)return;Y=!0;let q=new Promise((A)=>O.close(()=>A()));for(let A of j)A.destroy();await q,U.catch(()=>{return}),H();try{await S9(X)}finally{await Q.cleanup(),G$($.socketPath)}}}}var V$=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;var oZ="/workspace",rZ="/var/lib/reason/sessions",z6="/var/lib/reason/session-controls";function tZ($){let Q=`${rZ}/`;if(!$.startsWith(Q))return null;let Z=$.slice(Q.length);if(!V$.test(Z)||Z!==Z.toLowerCase())throw Error("personal_computer_invalid_runtime_root");return`${z6}/${Z}/job.env`}function K6($){if(!V$.test($))throw Error("personal_computer_invalid_identity");return $.toLowerCase()}function H8($){let Q=K6($);return{runtimeRoot:`${rZ}/${Q}`,workspaceRoot:`${oZ}/sessions/${Q}`,sharedRoot:oZ}}var eZ="/root/.ara/cloud-browser/repl.sock";function F$($){return $==="compute"}function $4($,Q,Z="linux"){if($)H8($);if(Z!=="linux")throw Error("cloud_browser_os_invalid");if(Q!==void 0&&(!$||!/^[1-9][0-9]{0,18}$/.test(Q)))throw Error("cloud_browser_generation_invalid");let X=$?`/var/lib/reason/browsers/${$.toLowerCase()}`:"/root/.ara/cloud-browser",J=$?`${X}/${Q?`g${Q}`:"current"}`:X,Y=$?`/root/.b/${$.toLowerCase().replaceAll("-","")}`:X;return{temporarySessionDirectory:Y,temporaryDirectory:$?`${Y}/${Q??"current"}`:`${J}/tmp`,directory:J,sessionDirectory:X,config:`${J}/config.json`,status:`${J}/status.json`,socket:`${J}/repl.sock`,bundle:`${J}/driver.mjs`,processName:$?`ara-browser-${$.toLowerCase()}${Q?`-${Q}`:""}`:"ara-cloud-browser"}}var U$="browser_egress",Q4=NQ,T6=45000,O6=l9+1500,m0=/^[A-Za-z0-9._:-]{1,160}$/,D6="/run/ara-hands";function _6($,Q,Z=V4()){if($==="darwin")return{temporaryRoot:Z,prepareRoot:!1,sessionMode:448};return{temporaryRoot:Q??D6,prepareRoot:!0,sessionMode:457}}function Z4($,Q=process.platform,Z=process.geteuid?.()){return $===!0&&Q==="linux"&&Z===0}function L$($=Y4(),Q=process.platform,Z=process.geteuid?.()){return $&&Q==="linux"&&Z===0?{uid:$.uid,gid:$.gid,home:$.home,username:$.username}:null}function A6($=L$(),Q=PZ){return $&&Q()?t8:null}function yY($=L$(),Q=process.platform,Z=process.geteuid?.()){return Q!=="linux"||Z!==0||$!==null}function hY($=process.platform,Q=process.geteuid?.()){return $!=="linux"||Q!==0}function x6($,Q){if(!Q&&($??"linux")==="linux")return eZ;return $4(Q,void 0,$??"linux").socket}function P6($){return $[N0]===!0?"sandbox_loopback":"ara_device_wss"}function W9($){return Boolean($)&&typeof $==="object"&&!Array.isArray($)}function H4($){let Q=$.toLowerCase().replace(/^\[|\]$/g,"");return Q==="localhost"||Q.endsWith(".localhost")||Q==="::1"||Q==="0:0:0:0:0:0:0:1"||Q==="0.0.0.0"||Q.startsWith("127.")}class U4 extends C{expiryDiagnostic;constructor($){super("invalid_hands_expiry","Reason Hands connection expiry is invalid.");this.expiryDiagnostic=$}}function I6($){return W9($)&&Object.keys($).every((Q)=>Q==="source_path"||Q==="branch")&&($.source_path===void 0||s0($.source_path))&&typeof $.branch==="string"&&Q$.test($.branch)}function R6($,Q,Z){let X=Q===void 0?Date.now():Q,J=["relay_url","session_id","environment_id","expires_at","policy_mode","policy_version","hands_protocol_version","hands_worker_version","hands_worker_artifact_sha256","hands_worker_entrypoint","target_generation","target_fence_id"],Y=new Set([...J,"workspace_id","legacy_workspace_id",i0,a0,"environment_binding","cloud_browser","sandbox_provider","sandbox_os","personal_workspace","workspace_path","workspace_worktree",p,N0,U$,F9,q0,o0,g0]),K=W9($)?$:null,V=K?.[U$],G=K?.[F9],F=K?.[o0],B=V===void 0||(K?.[p]===f0||F===w9&&K?.[p]===void 0)&&W9(V)&&Object.keys(V).every((q)=>q==="mode"||q==="allowed_domains")&&V.mode==="enforce"&&Array.isArray(V.allowed_domains)&&V.allowed_domains.length<=256&&V.allowed_domains.every((q)=>typeof q==="string"&&d8(q));if(!W9($)||J.some((q)=>!(q in $))||Object.keys($).some((q)=>!Y.has(q))||!B||F!==void 0&&F!==w9||K?.[g0]!==void 0&&K[g0]!==B8||K?.personal_workspace!==void 0&&(K.personal_workspace!==!0||K[p]!==f0)||K?.cloud_browser!==void 0&&(K.cloud_browser!==!0||K[p]!==f0)||K?.sandbox_provider!==void 0&&!F$(K.sandbox_provider)||K?.sandbox_os!==void 0&&K.sandbox_os!=="linux"||G!==void 0&&(K?.[p]!==V9||!e8(G))||p in $&&$[p]!==f0&&$[p]!==V9&&$[p]!==L0||N0 in $&&$[N0]!==!0||$.workspace_path!==void 0&&(!s0($.workspace_path)||$[p]!==L0)||$.workspace_worktree!==void 0&&($.workspace_path===void 0||!I6($.workspace_worktree))||typeof $.relay_url!=="string"||typeof $.session_id!=="string"||!m0.test($.session_id)||$.workspace_id!==void 0&&(typeof $.workspace_id!=="string"||!m0.test($.workspace_id))||$.legacy_workspace_id!==void 0&&(typeof $.legacy_workspace_id!=="string"||!m0.test($.legacy_workspace_id))||$[i0]!==void 0&&($[i0]!==L8||(p in $))||$[a0]!==void 0&&($[a0]!==N8||(p in $))||$[q0]!==void 0&&(typeof $[q0]!=="string"||!m0.test($[q0]))||typeof $.environment_id!=="string"||!m0.test($.environment_id)||typeof $.expires_at!=="string"||$.policy_mode!=="full_access"||$.policy_version!==1||$.hands_protocol_version!==B9||$.hands_worker_version!==L9||$.hands_worker_artifact_sha256!==K0||!dZ($.hands_worker_entrypoint)||!S0($.target_generation)||!O0($.target_fence_id))throw new C("invalid_hands_payload","Reason Hands connection payload is invalid.");let H;try{H=new URL($.relay_url)}catch{throw new C("invalid_hands_relay","Reason Hands relay URL is invalid.")}let z=$[N0]===!0,L=H4(H.hostname);if((z?H.protocol!=="ws:"||!L:L?H.protocol!=="ws:":H.protocol!=="wss:")||H.username||H.password||H.hash||!/^\/device\/[A-Za-z0-9-]+\/[A-Za-z0-9]+$/.test(H.pathname))throw new C("invalid_hands_relay","Reason Hands relay URL is not allowed.");let W=Date.parse($.expires_at),U=Number.isNaN(W)?"parse":new Date(W).toISOString()!==$.expires_at?"noncanonical":W<=X?"expired":W-X>Q4?"over_cap":"accepted",j={version:1,outcome:U,clock_source:Q===void 0?"date_now":"injected",validation_now_ms:Z9(X),expiry_ms:Z9(W),remaining_ms:Number.isSafeInteger(W-X)?W-X:null,maximum_lifetime_ms:Q4,cli_artifact:pZ()};if(U!=="accepted")throw new U4(j);try{Z?.(j)}catch{}let O=$.environment_binding===void 0?void 0:k8.safeParse($.environment_binding);if(O&&!O.success)throw new C("invalid_hands_request","Reason Hands environment binding is invalid.");return{...$.cloud_browser===!0?{cloud_browser:!0}:{},...F$($.sandbox_provider)?{sandbox_provider:$.sandbox_provider}:{},...$.sandbox_os==="linux"?{sandbox_os:$.sandbox_os}:{},...$.personal_workspace===!0?{personal_workspace:!0}:{},relay_url:H.toString(),...O?.success?{environment_binding:O.data}:{},session_id:$.session_id,...$.workspace_id===void 0?{}:{workspace_id:$.workspace_id},...$.legacy_workspace_id===void 0?{}:{legacy_workspace_id:$.legacy_workspace_id},...$[i0]===L8?{[i0]:L8}:{},...$[a0]===N8?{[a0]:N8}:{},...typeof $[q0]==="string"?{[q0]:$[q0]}:{},...$[o0]===w9?{[o0]:w9}:{},...$[g0]===B8?{[g0]:B8}:{},...typeof $.workspace_path==="string"?{workspace_path:$.workspace_path}:{},...W9($.workspace_worktree)?{workspace_worktree:{...typeof $.workspace_worktree.source_path==="string"?{source_path:$.workspace_worktree.source_path}:{},branch:String($.workspace_worktree.branch)}}:{},environment_id:$.environment_id,expires_at:$.expires_at,policy_mode:"full_access",policy_version:1,hands_protocol_version:B9,hands_worker_version:L9,hands_worker_artifact_sha256:K0,hands_worker_entrypoint:n0,target_generation:$.target_generation,target_fence_id:$.target_fence_id,...p in $?{[p]:$[p]}:{},...z?{[N0]:!0}:{},...G===void 0?{}:{[F9]:G},...V===void 0?{}:{[U$]:{mode:"enforce",allowed_domains:[...new Set(V.allowed_domains)].sort()}}}}function E6(){let $=new Map;return{acquire(Q,Z){if($.has(Q))return null;let X=[...$.values()],J=(K)=>Z.group!==void 0&&K.group===Z.group;if(Z.exclusive?!X.every(J):X.some((K)=>K.exclusive))return null;if(Z.limit!==void 0&&!X.some(J)&&new Set(X.map((K,V)=>K.group??V)).size>=Z.limit)return null;$.set(Q,Z);let Y=!1;return()=>{if(Y)return;Y=!0,$.delete(Q)}},activeOwners:()=>[...$.keys()]}}var S6=E6();function w6($,Q){N9($,{recursive:!0,mode:448});let Z=n($),X=()=>new C("invalid_hands_workspace","Reason Hands managed workspace ancestor must be a real directory, not a link.");for(let K of Q.split("/")){let V=a(Z,K);try{let F=t(V);if(F.isSymbolicLink()||!F.isDirectory())throw X()}catch(F){if(!(F&&typeof F==="object"&&("code"in F)&&F.code==="ENOENT"))throw F;try{N9(V,{mode:448})}catch(B){if(!(B&&typeof B==="object"&&("code"in B)&&B.code==="EEXIST"))throw B}}let G=t(V);if(G.isSymbolicLink()||!G.isDirectory()||n(V)!==V)throw X();Z=V}let J=t(Z),Y=L6(Z,H$.O_RDONLY|H$.O_DIRECTORY|H$.O_NOFOLLOW);try{let K=B6(Y);if(!K.isDirectory()||K.dev!==J.dev||K.ino!==J.ino||n(Z)!==Z)throw X();W6(Y,448)}finally{U6(Y)}return Z}function b6($,Q=J4(),Z,X,J){if(!m0.test($)||Z!==void 0&&!m0.test(Z))throw new C("invalid_hands_workspace","Reason Hands run identity is invalid.");let Y=V0(p0({kind:"managed",workspaceId:$,...X?{base:X}:{},...J?{layout:J}:{}})),K=w6(Q,V0(Y)),V=a(K,q6(Y)),G=!1;try{let z=t(V);if(G=!0,z.isSymbolicLink())throw new C("invalid_hands_workspace","Reason Hands workspace cannot be a symbolic link.");if(!z.isDirectory())throw new C("invalid_hands_workspace","Reason Hands workspace must be a managed directory.")}catch(z){if(z instanceof C||!(z&&typeof z==="object"&&("code"in z)&&z.code==="ENOENT"))throw z}if(J&&!G)try{let z=a(n(Q),V0(p0({kind:"managed",workspaceId:$,...X?{base:X}:{}}))),L=t(z);if(!L.isSymbolicLink()&&L.isDirectory()&&n(z)===z)U8(z,V),G=!0}catch{}if(Z&&Z!==$){let z=a(K,Z);try{let L=t(z);if(L.isSymbolicLink()||!L.isDirectory())throw new C("invalid_hands_workspace","Reason Hands legacy workspace must be a managed directory.");let W=n(z);if(V0(W)!==K)throw new C("invalid_hands_workspace","Reason Hands legacy workspace escaped its managed parent.");let U=null;if(G){U=a(K,`.${$}.previous`);try{throw t(U),new C("invalid_hands_workspace","Reason Hands previous workspace backup already exists.")}catch(j){if(j instanceof C||!(j&&typeof j==="object"&&("code"in j)&&j.code==="ENOENT"))throw j}U8(V,U)}try{U8(W,V)}catch(j){if(U)U8(U,V);throw j}G=!0}catch(L){if(L instanceof C||!(L&&typeof L==="object"&&("code"in L)&&L.code==="ENOENT"))throw L}}N9(V,{recursive:!0,mode:448}),b9(V,448);let F=n(V);if(V0(F)!==K)throw new C("invalid_hands_workspace","Reason Hands workspace escaped its managed parent.");let B=a(F,"repo");try{let z=t(B);if(z.isSymbolicLink()||!z.isDirectory())throw new C("invalid_hands_workspace","Reason Hands repository must be a managed directory.")}catch(z){if(z instanceof C||!(z&&typeof z==="object"&&("code"in z)&&z.code==="ENOENT"))throw z}N9(B,{recursive:!0,mode:448}),b9(B,448);let H=n(B);if(V0(H)!==F)throw new C("invalid_hands_workspace","Reason Hands repository escaped its managed run workspace.");return{workRoot:F,repoPath:H}}function W4($){let Q=null;try{Q=t($)}catch{}if(!Q||Q.isSymbolicLink()||!Q.isDirectory()||Q.uid!==0||Q.gid!==0||(Q.mode&4095)!==493)throw new C("cloud_workspace_root_invalid","This cloud Session's workspace root is not root's 0755 directory, so Reason Hands cannot use it.")}function k6($,Q){let Z="/";for(let X of["",...$.split("/"),...Q.split("/")].filter((J,Y)=>Y===0||J)){if(X)Z=a(Z,X);let J;try{J=t(Z)}catch{return null}if(J.uid!==0)return J.uid;if((J.mode&2)!==0&&(J.mode&512)===0&&!J.isSymbolicLink())return-1;if(J.isSymbolicLink()||!J.isDirectory())return null}return null}function f6($,Q,Z,X=process.geteuid?.(),J){if(!m0.test(Q))return null;let Y,K;try{Y=n($),K=V0(p0({kind:"managed",workspaceId:Q,...Z?{base:Z}:{},...J?{layout:J}:{}}))}catch{return null}let V=a(Y,K),G=B$(V)!==null,F=(W)=>new C("cloud_workspace_root_invalid",W),B;if(X===0){let W=k6(Y,K);if(W===null)return null;if(!G)throw new C("invalid_hands_workspace","As root, Reason Hands never prepares a workspace in folders another user owns.");B=W}else{if(!G)return null;let W,U;try{W=t(V0(V)),U=t(V)}catch{return null}if(W.isSymbolicLink()||!W.isDirectory()||W.uid===0||U.uid!==0)return null;B=W.uid}let H=Y;for(let W of K.split("/")){let U=a(H,W),j=!1;try{let O=t(U);j=!O.isSymbolicLink()&&O.isDirectory()&&n(U)===U}catch{}if(!j)throw F("This cloud Session's workspace root is missing or is not a real directory.");H=U}W4(V);let z;try{z=B4(V)}catch(W){if(W instanceof C)throw W;throw F("This cloud Session's workspace root changed while Reason Hands checked it.")}let L=null;try{L=k9(z.repoPath).uid}catch{}if(L!==B)throw new C("invalid_hands_workspace","Reason Hands repository must belong to the cloud Session's user.");return z}function B4($,Q=!1){let Z=n($),X=a(Z,"repo"),J;try{J=t(X)}catch{throw new C("invalid_hands_workspace","Reason Hands repository is missing from the granted root.")}if(Q){if(!/^\/var\/lib\/reason\/sessions\/[0-9a-f-]{36}$/.test(Z))throw new C("invalid_hands_workspace","Personal runtime identity is invalid.");if(H8(Z.slice(Z.lastIndexOf("/")+1)).runtimeRoot!==Z)throw new C("invalid_hands_workspace","Personal runtime identity is invalid.");let V=n("/workspace"),G=n(X);if(V!=="/workspace"||!k9(G).isDirectory()||!G.startsWith("/workspace/"))throw new C("invalid_hands_workspace","Personal files escaped the personal computer.");return{workRoot:Z,repoPath:G}}let Y=IZ(Z);if(Y&&J.isSymbolicLink()){let V=n(X);if(V!==n(Y)||!k9(V).isDirectory())throw new C("invalid_hands_workspace","Side chat repository must be its parent's checkout.");return{workRoot:Z,repoPath:V}}if(J.isSymbolicLink()||!J.isDirectory())throw new C("invalid_hands_workspace","Reason Hands repository must be a managed directory.");let K=n(X);if(V0(K)!==Z)throw new C("invalid_hands_workspace","Reason Hands repository escaped its granted root.");return{workRoot:Z,repoPath:K}}function N$($,Q,Z){if(Q!==void 0&&!s0(Q))throw new C("invalid_hands_workspace",`Reason Hands ${Z} is invalid.`);let X=F4($,Q??".");if(!w0($,X))throw new C("invalid_hands_workspace",`Reason Hands ${Z} escapes its granted root.`);return X}function L4($,Q,Z){if($$(Q)){let X=n(Z);return{anchor:X,target:F4(X,Q),boundary:a(X,H9)}}return{anchor:$,target:N$($,Q,"folder"),boundary:$}}function g6($,Q){if(!w0($,Q))throw new C("invalid_hands_workspace","Reason Hands folder escapes its granted root.");let Z=$;for(let X of Q.slice($.length).split("/").filter(Boolean)){Z=a(Z,X);let J=null;try{J=t(Z)}catch(Y){if(Y.code!=="ENOENT")throw Y}if(!J)N9(Z,{mode:448});else if(J.isSymbolicLink()||!J.isDirectory())throw new C("invalid_hands_workspace","Reason Hands folder must be made of real directories.")}}function N4($,Q){let Z=n(N$($,Q.source_path,"repository"));if(!w0($,Z)||!k9(Z).isDirectory())throw new C("invalid_hands_workspace","Reason Hands repository must be a folder in its granted root.");return Z}async function m6($,Q,Z,X=M8()){try{let J=n($);if(W$(L4(J,Q,X).target))return;return await kZ(N4(J,Z))??void 0}catch{return}}function y6($,Q,Z,X,J=h6,Y=M8()){let K=n($),{target:V,boundary:G,anchor:F}=L4(K,Q,Y);if(Z&&!W$(V)){let z=N4(K,Z);g6(F,V0(V));let L=["-c","core.hooksPath=/dev/null","-C",z];if(X)J([...L,"update-ref","--create-reflog","-m",X.note,`refs/heads/${Z.branch}`,X.commit,""]);let W=X?J([...L,"worktree","add",V,Z.branch]):J([...L,"worktree","add","-b",Z.branch,V]);if(!X&&W.status!==0&&/already exists/.test(W.stderr)&&!W$(V))W=J([...L,"worktree","add",V,Z.branch]);if(W.status!==0)throw new C(/not a git repository/i.test(W.stderr)?"workspace_not_git_repository":"workspace_worktree_failed","Reason could not create this Session's git worktree.")}let B;try{B=t(V)}catch{throw new C("workspace_folder_missing","This Session's folder no longer exists.")}let H=n(V);if(B.isSymbolicLink()&&!w0(G,H))throw new C("invalid_hands_workspace","Reason Hands folder resolves outside its granted root.");if(!k9(H).isDirectory()||!w0(G,H))throw new C("invalid_hands_workspace","Reason Hands folder must be a directory in its granted root.");if(b0(H))throw new C("protected_path","Credential and secret folders are unavailable to Sessions.");return H}function h6($){let Q=H6("git",$,{encoding:"utf8",timeout:60000,env:{...process.env,GIT_TERMINAL_PROMPT:"0"},stdio:["ignore","ignore","pipe"]});return{status:Q.status,stderr:Q.stderr??""}}function M4($){return tZ($)??B$($)?.jobEnv??a($,"job.env")}function v6($,Q){let Z=M4($),X=t(Z);if(X.isSymbolicLink()||!X.isFile())throw new C("invalid_hands_workspace","Reason Hands job environment must be a managed regular file.");N6(Z,Q),b9(Q,384)}function c6($){if($.workspaceMode===L0&&$.workspacePath!==void 0){let K=$.home??M8(),V=y6($.grantedRoot,$.workspacePath,$.workspaceWorktree,$.workspaceWorktreeStart,void 0,K);if($.workspaceWorktree&&$.deviceId)yZ(K,$.workspacePath,$.deviceId);return{workRoot:V,repoPath:V,workspace:{kind:"root",path:$.workspacePath},jobEnvPath:a($.temporaryDirectory,"job.env"),workspacePoolPath:null,managedWorkspace:!0}}if($.workspaceMode===f0)return{...B4($.grantedRoot,$.personalWorkspace),workspace:{kind:"root"},jobEnvPath:a($.temporaryDirectory,"job.env"),workspacePoolPath:null,managedWorkspace:!1};if($.workspaceMode===V9||$.workspaceMode===L0){let K=t($.grantedRoot);if(K.isSymbolicLink()||!K.isDirectory())throw new C("invalid_hands_workspace","Reason Hands root must be a real directory.");let V=n($.grantedRoot);return{workRoot:V,repoPath:V,workspace:{kind:"root"},jobEnvPath:a($.temporaryDirectory,"job.env"),workspacePoolPath:null,managedWorkspace:!0}}let Q=$.workspaceId??$.runId,Z={kind:"managed",workspaceId:Q,...$.workspaceBase?{base:$.workspaceBase}:{},...$.workspaceLayout?{layout:$.workspaceLayout}:{}},X=s9($.grantedRoot,Z,$.home).anchor,J=f6(X,Q,$.workspaceBase,void 0,$.workspaceLayout);if(J)return{...J,workspace:Z,jobEnvPath:a($.temporaryDirectory,"job.env"),workspacePoolPath:null,managedWorkspace:!1,cloudSessionRoot:!0};let Y=b6(Q,X,$.legacyWorkspaceId,$.workspaceBase,$.workspaceLayout);return{...Y,workspace:Z,jobEnvPath:a($.temporaryDirectory,"job.env"),workspacePoolPath:V0(Y.workRoot),managedWorkspace:!0}}function d6($){let{command:Q,prefix:Z}=f8($.executablePath,$.sourceEntrypoint),X=F8({home:C6(),temporaryDirectory:$.temporaryDirectory,path:$.path});if(X.REASON_DEVICE_ROOT=X.ARA_DEVICE_ROOT=$.grantedRoot,X.REASON_HANDS_WORKSPACE=X.ARA_HANDS_WORKSPACE=$.workRoot,X.REASON_HANDS_REPO=X.ARA_HANDS_REPO=$.root,$.workspacePoolPath)X.REASON_HANDS_WORKSPACE_POOL=X.ARA_HANDS_WORKSPACE_POOL=$.workspacePoolPath;return{command:Q,args:[...Z,"__device","__hands-worker","--config",$.configPath],options:{cwd:$.root,env:X,shell:!1,stdio:["ignore","ignore","pipe"]}}}function p6($,Q){let Z="",X=!1,J=Date.now(),Y=0,K=new Set(["connecting","open","dial_pending","socket_error","close","claim_accepted","claim_rejected","stopping","stopped","request_cancelled","permission_denied"].map((H)=>`hands.worker.${H}`)),V=new Set([null,"open_not_received","current_connection","obsolete_connection","request_aborted","request_timeout","client_closed","driver_stopped","driver_handoff","run_cancelled","run_finished","other","frame_too_large","invalid_json","invalid_claim","executor_mismatch","stale_generation","fence_conflict","SIGTERM","SIGINT","SIGHUP","expired","cleanup_complete","cleanup_failed","cancelled","settled","unsupported","unconfirmed",...["sandbox_policy","os_permission_unknown"].flatMap((H)=>["bash","read","write","edit"].map((z)=>`${H}:${z}`))]),G=["timestampMs","connectionAttempt","connectionGeneration","targetGeneration","activeRequestCount","remainingLifetimeMs","suppressedDiagnostics"],F=["peerGeneration","socketState","closeCode"],B=new Set(["event","reason","launchId",...G,...F]);return(H)=>{for(let z of H.toString().split(/(?<=\n)/)){let L=z.endsWith(`
458
458
  `);if(!X&&Z.length+z.length<=2048)Z+=z;else X=!0;if(!L)continue;let W=Z;if(Z="",X){X=!1;continue}try{let U=JSON.parse(W);if(!U||typeof U!=="object"||Array.isArray(U)||Object.keys(U).some((j)=>!B.has(j))||!K.has(U.event)||!V.has(U.reason)||U.event==="hands.worker.permission_denied"!==(typeof U.reason==="string"&&U.reason.includes(":"))||U.launchId!==$||G.some((j)=>!Number.isSafeInteger(U[j])||U[j]<0)||F.some((j)=>U[j]!==null&&(!Number.isSafeInteger(U[j])||U[j]<0)))continue;if(Date.now()-J>=60000)J=Date.now(),Y=0;if(Y>=122)continue;Y+=1,Q(U)}catch{}}}}async function l6($){let Q=$.now()+$.timeoutMs;while($.now()<Q){if($.signal.aborted)throw new C("cancelled","Reason Hands start was cancelled.");if($.spawnFailed?.()||$.child.exitCode!==null||$.child.signalCode!==null)throw new C("hands_worker_exited","Reason Hands exited before ready.");let Z=K8($.path,{pid:$.child.pid??-1,launchId:$.launchId,workerVersion:L9,protocolVersion:B9,workerArtifactSha256:K0,workerEntrypoint:n0});if(Z?.targetGeneration===$.targetGeneration&&Z.fenceId===$.fenceId)return Z;await new Promise((X)=>setTimeout(X,10))}throw new C("hands_ready_timeout","Reason Hands did not become ready.")}async function u6($,Q){let Z=()=>$.exitCode===0&&$.signalCode===null;if($.exitCode!==null||$.signalCode!==null)return Z()?"stopped":"already_exited";let X=new Promise((K)=>$.once("exit",()=>K()));try{if(!$.kill("SIGTERM"))return Z()?"stopped":"unobserved"}catch{return Z()?"stopped":"unobserved"}if(await X4(X,Q))return Z()?"stopped":"unobserved";try{$.kill("SIGKILL")}catch{}return await X4(X,Q)?"forced":"unobserved"}async function X4($,Q){let Z;try{return await Promise.race([$.then(()=>!0),new Promise((X)=>{Z=setTimeout(()=>X(!1),Q)})])}finally{clearTimeout(Z)}}function s6($){return new Promise((Q)=>{let Z=!1,X=(V)=>{if(Z)return;Z=!0,clearTimeout(K),$.signal.removeEventListener("abort",J),$.child.off("exit",Y),Q(V)},J=()=>X("cancelled"),Y=()=>X("exited"),K=setTimeout(()=>X("expired"),Math.max(0,$.expiresAt-$.now()));if($.signal.addEventListener("abort",J,{once:!0}),$.child.once("exit",Y),$.signal.aborted)J();else if($.child.exitCode!==null||$.child.signalCode!==null)Y()})}var j4=K4();function n6($,Q){if(!($ instanceof Error)||$ instanceof C)return!1;let Z=["hands_browser_driver_missing","hands_browser_driver_version_mismatch","hands_browser_executable_missing","hands_browser_unsupported_platform","hands_browser_unavailable"].includes($.message),X=["ENOENT","EACCES","EPERM"].includes($.code??"");if(!Z&&!X)return!1;try{return t(Q),!1}catch(J){return W9(J)&&J.code==="ENOENT"}}function i6($){return $.sandbox_provider==="compute"&&!$.cloud_browser&&!$[N0]&&$[p]===f0}function a6($,Q,Z){return $===void 0?{}:{dispatch_stages:{version:1,claim_to_entered_ms:H0($,Q),...Z===void 0?{}:{worker_prespawned:Z}}}}function vY(){j4().catch(()=>{return}),G9().catch(()=>{return})}async function cY($,Q={}){let Z=Q.logDiagnostic??((N)=>console.warn(N)),X=new Map,J=(N)=>{let M=Date.now();X.set(N,M);try{Z(JSON.stringify({event:"sandbox.hands_startup",stage:N,timestampMs:M}))}catch{}};J("entered");let Y=$.claimEnvironment;$.claimEnvironment=void 0;let K=Q.now??Date.now,V,G=R6($.payload,Q.now?.(),(N)=>{V=N});if($.managedPty&&($.managedPty.version!==1||!$.headless||!$.runtimeDirectory||![void 0,!0].includes($.managedPty.startupVerified)||!$.deviceIdentity||!$.claimOwner||$.claimOwner.device_id!==$.deviceIdentity.deviceId||!G.environment_binding||!["darwin","linux"].includes(process.platform)))throw new C("pty_unsupported","Bound PTY requires qualified headless Hands with private jobs and environment.");let F=async(N)=>{let M;try{await Promise.race([N,new Promise((D,w)=>{M=setTimeout(()=>w(new C("hands_event_delivery_unavailable","Hands event delivery did not settle within its deadline.")),Math.max(1,Math.min(Q.eventDeliveryTimeoutMs??5000,5000)))})])}finally{clearTimeout(M)}},B=async(N,M)=>F($.emitEvent(N,M));if($.headless&&(G.cloud_browser===!0||$.managedBrowser!==void 0||G[N0]!==void 0||G[F9]!==void 0||G[p]!==void 0&&G[p]!==L0))throw new C("invalid_hands_request","Managed sandbox extensions are unavailable to a headless worker.");let H=L$(),z=G[g0]===void 0?null:A6(H);if(G[g0]!==void 0&&(z===null||!$.headless||!Z4($.hostExecution,Q.hostIdentity?.platform,Q.hostIdentity?.euid)))throw new C("hands_model_jobs_egress_unavailable","This worker cannot hold its jobs to the guest egress guard; the Hands did not start.");if(G[o0]!==void 0&&!($.headless&&Z4($.hostExecution,Q.hostIdentity?.platform,Q.hostIdentity?.euid)))throw new C("hands_confinement_unavailable","Confined Hands need a root Linux worker in host mode.");if(G.cloud_browser&&process.platform!=="linux")throw new C("cloud_browser_target_invalid","Cloud browser is available only on a cloud machine.");let L=`${$.operationId}:${$.attemptId}`,W=G[p]===V9,U=$.headless||process.platform==="darwin"&&$.managedBrowser===void 0&&!G.cloud_browser&&!G.browser_egress&&!G[N0]&&(G[p]===void 0||G[p]===L0)||i6(G),j=W?G[F9]??"bash":null,O=j?SZ(j):null;if(O)throw new C(O,"Persistent Node REPL execution is unavailable; this benchmark profile cannot start.");let q=G[p],A=$.headless===!0&&$.ownComputer!==!0?$.handsSlots??1:void 0,R=(Q.slot??S6).acquire(L,{exclusive:A===1||q!==void 0&&q!==L0,...A!==void 0&&A>1?{limit:A}:{},...$.headless===!0&&G[q0]!==void 0?{group:G[q0]}:{}});if(!R)throw new C("hands_slot_busy",A!==void 0&&A>1?`This Reason worker runs at most ${A} sessions at a time.`:"This Reason Device runs one session at a time.");let P=$.headless===!0?G4($.runId):null,T=null,S=null,g,E;try{J("browser_resolution");let N=$.headless&&Q.browserExecutablePath===void 0?await G9():null,M=W||G.cloud_browser?null:Q.browserExecutablePath===void 0?$.headless?N?.status==="resolved"?N.executablePath:null:await _Z(void 0,process.platform,$.managedBrowser):Q.browserExecutablePath;if(!W&&!G.cloud_browser&&!U&&!M)throw new C("hands_browser_unavailable","Reason Hands requires Chrome, Edge, Brave, Chromium, or a Playwright Chromium install.");J("path_resolution");let D;try{D=await(Q.resolvePathEnvironment??j4)()}catch{D={path:z4(),source:"fallback"}}if(J("workspace_setup"),process.platform==="darwin"){let s=G[p]===L0&&G.workspace_path!==void 0?N$($.root,G.workspace_worktree?G.workspace_worktree.source_path:G.workspace_path,"folder"):null;for(let Z0 of new Set([$.root,...s?[s]:[]]))await sQ(Z0)}let k=G[p]===f0||G[p]===V9?_6(process.platform,Q.sandboxRuntimeRoot):null,f=$.headless&&$.runtimeDirectory?$.runtimeDirectory:k?k.temporaryRoot:V4();if(T="private_runtime",$.headless&&$.runtimeDirectory){_9(f);let s=n($.root);if(!P9(s,f))throw new C("invalid_hands_workspace","Private worker state must not overlap the granted workspace.")}if($.headless&&$.runtimeDirectory&&(!$.deviceIdentity||!G.environment_binding))throw new C("environment_unavailable","Headless Hands requires a server-bound private environment.");if(T="runtime_root",k?.prepareRoot)N9(f,{recursive:!0,mode:457}),b9(f,457);T="temporary_directory";let _=n(M6(a(f,"reason-hands-session-")));S=_,b9(_,k?.sessionMode??448);let m=a(_,"hands-config.json"),c=a(_,"hands-ready.json"),l=V6(),o=G.target_fence_id;T="granted_root";let b=n($.root);T="workspace_layout";let h=G[p]===L0&&G.workspace_path!==void 0&&G.workspace_worktree?await m6(b,G.workspace_path,G.workspace_worktree):void 0,{workRoot:d,repoPath:u,jobEnvPath:G0,workspacePoolPath:M0,managedWorkspace:U0,workspace:W0,cloudSessionRoot:y0}=c6({grantedRoot:b,personalWorkspace:G.personal_workspace===!0,runId:$.runId,workspaceId:G.workspace_id,legacyWorkspaceId:G.legacy_workspace_id,workspaceBase:G[i0],workspaceLayout:G[a0],temporaryDirectory:_,workspaceMode:G[p],applicationSupportPath:Q.applicationSupportPath,...G.workspace_path===void 0?{}:{workspacePath:G.workspace_path},...G.workspace_worktree?{workspaceWorktree:G.workspace_worktree}:{},...h?{workspaceWorktreeStart:h}:{},...$.deviceIdentity?{deviceId:$.deviceIdentity.deviceId}:{}}),T0=P6(G);T="jobs";let r=$.headless&&$.runtimeDirectory?VQ({runtimeDirectory:$.runtimeDirectory,root:b,runId:$.runId}):void 0;g=r?.disposeSocket;let j0=r?FQ(r):null;if(j0)try{Z(JSON.stringify({event:"hands.journal_owner_retired",run_id:$.runId,reason:j0.reason,prior_executor_launch_id:j0.executorLaunchId}))}catch{}if(r&&[d,u].some((s)=>!P9(s,r.journalDirectory)))throw new C("invalid_hands_workspace","A Session can't work in the folder that holds this worker's settings; start it in a project or repository inside it.");let r0=G.personal_workspace?d.slice(d.lastIndexOf("/")+1):void 0;if(r0&&r0!==G.workspace_id)throw new C("invalid_hands_workspace","Personal session identity does not match its Device grant.");T="browser_socket";let B0=G.cloud_browser?x6(G.sandbox_os,r0):a(r?V0(r.socketPath):_,"repl.sock");T="relay_url";let C0=H4(new URL(G.relay_url).hostname),h0=T0==="ara_device_wss"&&!C0?(Q.loadProxy??g8)()?.url:void 0,Y0;T="environment_owner";let X0=$.headless&&$.deviceIdentity&&G.environment_binding?vZ(_,{runId:$.runId,...$.deviceIdentity,binding:G.environment_binding,expiresAtMs:Date.parse(G.expires_at),identity:()=>Y0?.()??null}):void 0;T="job_environment";let M9=!X0&&W0.kind==="managed"&&U0?a(d,"job.env"):null;if(M9)try{W8(M9,"",{mode:384,flag:"wx"})}catch(s){if(!(s instanceof Error&&("code"in s)&&s.code==="EEXIST"))throw s}let j8={url:G.relay_url,transport:T0,...h0===void 0?{}:{proxyUrl:h0},...$.localGithubConfinement?{localGithubConfinement:!0}:{},...G[o0]&&X0?{gitCredentialEnvironment:!0}:{},workerVersion:L9,protocolVersion:B9,workerArtifactSha256:K0,workerEntrypoint:n0,targetGeneration:G.target_generation,fenceId:o,workRoot:d,workspaceAliasPath:d,jobEnvPath:G0,...X0?{environmentSnapshotPath:X0.path,...$.hostExecution?{executionEnvironment:gQ()}:{},environmentExpectedBinding:{runId:$.runId,...$.deviceIdentity,binding:G.environment_binding}}:M9?{jobEnvSourcePath:M9,workspacePoolPath:V0(d)}:U0?{}:{jobEnvSourcePath:M4(d)},repoPath:u,replSocketPath:B0,...G.cloud_browser?{browserRunId:$.runId}:{},readyPath:c,launchId:l,expiresAtMs:Date.parse(G.expires_at),bashTimeoutMs:300000,replTimeoutMs:120000,...r?{managedJobs:{journalDirectory:r.journalDirectory,scopeId:r.scopeId},jobControlSocketPath:r.socketPath}:{},...r&&H?{jobsUser:{...H,...z!==null?{modelGid:z}:{}}}:{},...$.managedPty&&r&&X0?{managedPty:{version:1,...$.managedPty.startupVerified===!0?{persistent:!0}:{},...process.platform==="darwin"?{shell:mQ()}:{}}}:{},...U&&!M?{allowedTools:["bash","read","write","edit"]}:W?{allowedTools:j==="bash"?["bash"]:["bash","repl"]}:{}};if(X0||U0&&!M9)W8(G0,"",{mode:384});else v6(d,G0);T="config_write",W8(m,JSON.stringify(j8),{mode:384}),T=null;let v0={session_id:G.session_id,environment_id:G.environment_id,hands_protocol_version:B9,hands_worker_version:L9,hands_worker_artifact_sha256:K0,hands_worker_entrypoint:n0,target_generation:G.target_generation,target_fence_id:G.target_fence_id,executor_launch_id:l},f9=null,M$=!1,j$=!1,C$,Q0=null,q$,T$,g9="failed",O$=null,C8=Promise.resolve(),D$=null,q8=async(s,Z0)=>{try{await B(s,Z0)}catch{}};try{J("event_started");let s,Z0=(async()=>{await $.emitEvent("hands.started",{...v0,policy_mode:"full_access",policy_version:1,path_source:D.source}),s=Date.now()})();Z0.catch(()=>{return}),J("worker_setup");let m9=G.browser_egress?{mode:"enforce",allowedDomains:G.browser_egress.allowed_domains}:{mode:"off"};if(j&&j!=="bash")f9=await(Q.startNodeRepl??aZ)({socketPath:B0,workRoot:d});else if(!W&&!G.cloud_browser&&M)f9=await(Q.startRepl??AZ)({socketPath:B0,browserExecutablePath:M,workspaceRoot:u,...$.managedBrowser?{managedBrowser:$.managedBrowser}:{},...$.desktopRecording?{recording:$.desktopRecording}:{},networkPolicy:m9,onEgressDenied:(y)=>{let F0=RZ(y.host);Z(JSON.stringify({event:"sandbox.repl_egress_denied",destination_id:F0,reason:y.reason,run_id:$.runId})),C8=C8.then(()=>B("hands.browser_egress_denied",{destination_id:F0,reason:y.reason})).catch((h9)=>{D$??=h9})}}).catch((y)=>{if(!U||$.signal.aborted||K()>=Date.parse(G.expires_at)||!n6(y,B0))throw y;return Object.assign(j8,{allowedTools:["bash","read","write","edit"]}),W8(m,JSON.stringify(j8),{mode:384}),j$=!0,null});let _$=d6({configPath:m,root:u,grantedRoot:b,workRoot:d,workspacePoolPath:M0,temporaryDirectory:_,path:D.path,executablePath:Q.executablePath,sourceEntrypoint:Q.sourceEntrypoint}),T8=Date.now(),O8,A$,D8=Q.takePrespawnedWorker?.(_$)??null;if(C$=Q.takePrespawnedWorker?D8!==null:void 0,Q0=D8??(Q.spawnWorker??((y)=>F6(y.command,y.args,y.options)))(_$),!D8)Q.adoptSpawnedWorker?.(Q0);Q0.stderr?.on("data",p6(l,(y)=>{if(y.event==="hands.worker.connecting")O8??=y.timestampMs;else if(y.event==="hands.worker.open")A$??=y.timestampMs;if(Z(JSON.stringify({...y,run_id:$.runId})),y.event==="hands.worker.permission_denied"&&typeof y.reason==="string"){let[F0,h9]=y.reason.split(":");if(["sandbox_policy","os_permission_unknown"].includes(F0??"")&&["bash","read","write","edit"].includes(h9??""))B("permission.denied",{provenance:F0,operation:h9}).catch(()=>{return})}}));let x$=!1;Q0.on("error",()=>{x$=!0}),Q0.once("exit",(y,F0)=>{try{Z(JSON.stringify({event:"hands.worker.exited",run_id:$.runId,launchId:l,exit_code:y,exit_signal:F0}))}catch{}}),E=Q0,J("worker_ready_wait");let j9=await l6({path:c,launchId:l,fenceId:o,targetGeneration:G.target_generation,child:Q0,spawnFailed:()=>x$,signal:$.signal,timeoutMs:Q.readyTimeoutMs??T6,now:K}),C4=Date.now();if(Y0=()=>{if(!Q0||Q0.exitCode!==null||Q0.signalCode!==null)return null;let y=K8(c,j9);return y?{generation:y.targetGeneration,fenceId:y.fenceId}:null},r){let y={root:b,runId:$.runId,operationId:$.operationId,scopeId:r.scopeId,socketPath:r.socketPath,generation:j9.targetGeneration,fenceId:j9.fenceId,executorLaunchId:l,expiresAtMs:Date.parse(G.expires_at),readIdentity:Y0,workspace:W0,localGithubConfinement:$.localGithubConfinement===!0};if(X0)y.environment=X0;if($.claimOwner&&$.deviceIdentity&&$.claimOwner.device_id===$.deviceIdentity.deviceId){let F0=[$.deviceIdentity.apiOrigin,G.relay_url];if(h0)F0.push(h0);y.previewAuthority={owner:Object.freeze({...$.claimOwner}),rootId:$.deviceIdentity.rootId,relayOrigin:new URL(G.relay_url).origin,deniedPorts:d$(F0)}}T$=HQ(y)}if(await new Promise((y)=>{setImmediate(y)}),y0)W4(d);let y9;if(Y&&X0){try{let y=X0.install(Y);y9={snapshot_id:y.snapshot_id,installed_revision:y.installed_revision}}catch{}try{Z(JSON.stringify({event:"hands.environment_at_claim",run_id:$.runId,installed:y9!==void 0}))}catch{}}Y=void 0,J("event_ready");let P$=F(Z0);P$.catch(()=>{return});let I$=Date.now();M$=!0,await B("hands.ready",{...v0,expiry_diagnostic:V,startup_stages:{version:1,browser_resolution_ms:H0(X.get("browser_resolution"),X.get("path_resolution")),path_resolution_ms:H0(X.get("path_resolution"),X.get("workspace_setup")),workspace_setup_ms:H0(X.get("workspace_setup"),X.get("event_started")),repl_setup_ms:H0(X.get("worker_setup"),T8),worker_boot_ms:H0(T8,O8),worker_dial_ms:H0(O8,A$),worker_ready_ms:H0(T8,C4),started_event_ms:H0(X.get("event_started"),s),started_join_wait_ms:H0(X.get("event_ready"),I$),total_ms:H0(X.get("entered"),I$)},...a6($.claimedAtMs,X.get("entered"),C$),...$.managedPty?.startupVerified===!0?{managed_pty:{version:1,execution_mode:"host",descendant_cleanup_verified:!0}}:{},policy_mode:"full_access",policy_version:1,path_source:D.source,connection_generation:j9.generation,...y9?{environment_installed:y9}:{},...U&&!f9?{browser_state:"unavailable",browser_reason_code:j$?"setup_failed":"not_resolved"}:{viewport_width:1440,viewport_height:900}}),await P$,J("ready"),q$=sZ({path:c,initial:j9,signal:$.signal,isAlive:()=>Q0!==null&&Q0.exitCode===null&&Q0.signalCode===null&&K()<Date.parse(G.expires_at),publish:(y,F0)=>$.emitEvent("hands.reconnected",{...v0,target_generation:y.targetGeneration,target_fence_id:y.fenceId,connection_generation:y.generation},F0),failed:()=>Z(JSON.stringify({event:"hands.worker.generation_proof_failed",run_id:$.runId,executor_launch_id:l}))});let R$=await s6({child:Q0,signal:$.signal,expiresAt:Date.parse(G.expires_at),now:K});if(R$==="cancelled"){let y=$.signal.reason instanceof C?$.signal.reason.code:"cancelled";throw g9=y,new C(y,"Reason Hands was cancelled.")}if(R$==="exited")throw new C("hands_worker_exited","Reason Hands exited unexpectedly.");return g9="expired",{...v0,policy_mode:"full_access",policy_version:1,ended:"expired"}}catch(s){O$=s;let Z0=s instanceof C?s.code:"hands_failed",m9=Z0==="cancelled"||["run_finished","run_cancelled","driver_handoff","driver_stopped"].includes(Z0);if(g9=m9?Z0:"failed",!m9)await q8("hands.failed",{...v0,reason_code:Z0});throw s}finally{q$?.stop(),T$?.();let s=Q0?await u6(Q0,Q.stopTimeoutMs??O6):null,Z0=!1;await $.desktopRecording?.close();try{await f9?.stop()}catch{Z0=!0}if(await C8,(s==="stopped"||s==="already_exited"&&!M$)&&!Z0)await q8("hands.stopped",{...v0,reason_code:g9});else if(s!==null||Z0){if(await q8("hands.failed",{...v0,reason_code:s==="forced"?"hands_stop_forced":"hands_stop_unconfirmed"}),O$===null||Z0)throw new C("hands_stop_unconfirmed","Reason Hands resource cleanup could not be proven.")}if(D$!==null)throw new C("hands_egress_audit_failed","Reason Hands could not persist a browser egress denial receipt.")}}catch(N){let M=xZ(T,N);if(M)try{Z(JSON.stringify({event:"sandbox.hands_workspace_failed",...M}))}catch{}throw N}finally{try{if(!E||E.exitCode!==null||E.signalCode!==null)g?.();if(S!==null&&(!E||E.exitCode!==null||E.signalCode!==null))j6(S,{recursive:!0,force:!0})}finally{P?.(),R()}}}
459
- export{v as ya,k$ as za,f$ as Aa,b4 as Ba,h$ as Ca,c$ as Da,d$ as Ea,D2 as Fa,VQ as Ga,y2 as Ha,h2 as Ia,v2 as Ja,c2 as Ka,d2 as La,p2 as Ma,WQ as Na,l2 as Oa,s2 as Pa,p as Qa,L0 as Ra,yX as Sa,hX as Ta,QJ as Ua,ZJ as Va,TQ as Wa,i9 as Xa,_9 as Ya,A9 as Za,EQ as _a,vZ as $a,Y5 as ab,bQ as bb,gQ as cb,mQ as db,S5 as eb,w5 as fb,J0 as gb,b5 as hb,k5 as ib,f5 as jb,l5 as kb,Z1 as lb,u5 as mb,P9 as nb,w0 as ob,s5 as pb,BX as qb,Y1 as rb,G1 as sb,YZ as tb,XX as ub,I9 as vb,o1 as wb,V$ as xb,tZ as yb,Z4 as zb,L$ as Ab,A6 as Bb,yY as Cb,hY as Db,U4 as Eb,E6 as Fb,W4 as Gb,B4 as Hb,d6 as Ib,vY as Jb,cY as Kb};
459
+ export{v as xa,k$ as ya,f$ as za,b4 as Aa,h$ as Ba,c$ as Ca,d$ as Da,D2 as Ea,VQ as Fa,y2 as Ga,h2 as Ha,v2 as Ia,c2 as Ja,d2 as Ka,p2 as La,WQ as Ma,l2 as Na,s2 as Oa,p as Pa,L0 as Qa,yX as Ra,hX as Sa,QJ as Ta,ZJ as Ua,TQ as Va,i9 as Wa,_9 as Xa,A9 as Ya,EQ as Za,vZ as _a,Y5 as $a,bQ as ab,gQ as bb,mQ as cb,S5 as db,w5 as eb,J0 as fb,b5 as gb,k5 as hb,f5 as ib,l5 as jb,Z1 as kb,u5 as lb,P9 as mb,w0 as nb,s5 as ob,BX as pb,Y1 as qb,G1 as rb,YZ as sb,XX as tb,I9 as ub,o1 as vb,V$ as wb,tZ as xb,Z4 as yb,L$ as zb,A6 as Ab,yY as Bb,hY as Cb,U4 as Db,E6 as Eb,W4 as Fb,B4 as Gb,d6 as Hb,vY as Ib,cY as Jb};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{pc as X}from"./vm-hands-entry-lite-k469tezz.js";import{spawn as M}from"child_process";import{existsSync as C}from"fs";import{homedir as g}from"os";import{basename as D,join as N}from"path";var Y="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",G=Y.split(":"),f=5000,I=65536,U=new Set(["zsh","bash"]),V=[[".local","bin"],[".bun","bin"],[".cargo","bin"],["go","bin"]],j=(J,K)=>new Promise((W,Z)=>{let Q;try{Q=M(J,[...K],{detached:!0,stdio:["ignore","pipe","ignore"]})}catch($){Z($);return}let z=[],x=0,R=null,B=($)=>{R??=Error($);try{if(Q.pid!==void 0)process.kill(-Q.pid,"SIGKILL")}catch{}},F=setTimeout(()=>B("login_shell_timeout"),f);Q.stdout?.on("data",($)=>{if(x+=$.length,x>I)B("login_shell_output_too_large");else z.push($)}),Q.once("error",($)=>{clearTimeout(F),Z($)}),Q.once("close",($)=>{if(clearTimeout(F),R)Z(R);else if($!==0)Z(Error("login_shell_exit_nonzero"));else W(Buffer.concat(z).toString("utf8"))})});function O(J){return typeof J==="string"&&J.startsWith("/")&&!J.includes("\x00")&&U.has(D(J))}function q(J){let K=new Set,W=[];for(let Z of J){if(K.has(Z))continue;K.add(Z),W.push(Z)}return W}function H(J){let K=J.split(`
2
+ import{lc as X}from"./vm-hands-entry-lite-nvhzj5b0.js";import{spawn as M}from"child_process";import{existsSync as C}from"fs";import{homedir as g}from"os";import{basename as D,join as N}from"path";var Y="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",G=Y.split(":"),f=5000,I=65536,U=new Set(["zsh","bash"]),V=[[".local","bin"],[".bun","bin"],[".cargo","bin"],["go","bin"]],j=(J,K)=>new Promise((W,Z)=>{let Q;try{Q=M(J,[...K],{detached:!0,stdio:["ignore","pipe","ignore"]})}catch($){Z($);return}let z=[],x=0,R=null,B=($)=>{R??=Error($);try{if(Q.pid!==void 0)process.kill(-Q.pid,"SIGKILL")}catch{}},F=setTimeout(()=>B("login_shell_timeout"),f);Q.stdout?.on("data",($)=>{if(x+=$.length,x>I)B("login_shell_output_too_large");else z.push($)}),Q.once("error",($)=>{clearTimeout(F),Z($)}),Q.once("close",($)=>{if(clearTimeout(F),R)Z(R);else if($!==0)Z(Error("login_shell_exit_nonzero"));else W(Buffer.concat(z).toString("utf8"))})});function O(J){return typeof J==="string"&&J.startsWith("/")&&!J.includes("\x00")&&U.has(D(J))}function q(J){let K=new Set,W=[];for(let Z of J){if(K.has(Z))continue;K.add(Z),W.push(Z)}return W}function H(J){let K=J.split(`
3
3
  `).at(-1)??"",W=[];for(let Z of K.split(":")){let Q=Z.trim();if(!Q.startsWith("/"))continue;if(Q.includes("\x00"))continue;if(X(Q))continue;W.push(Q)}return q(W)}function k(J){let K=J?.home??g(),W=J?.directoryExists??C,Z=V.map((Q)=>N(K,...Q)).filter((Q)=>{try{return W(Q)}catch{return!1}});return q([...Z,...G]).join(":")}async function S(J){let K=J?.shell??process.env.SHELL,W=()=>({path:k({home:J?.home,directoryExists:J?.directoryExists}),source:"fallback"});if(!O(K))return W();let Z;try{Z=await(J?.runLoginShell??j)(K,["-lic",'printf %s "$PATH"'])}catch{return W()}if(Buffer.byteLength(Z,"utf8")>I)return W();let Q=H(Z);if(Q.length===0)return W();return{path:q([...Q,...G]).join(":"),source:"login_shell"}}function v(J){let K=null;return()=>{return K??=S(J),K}}function w(J){if(J===void 0||J.includes("\x00")||Buffer.byteLength(J,"utf8")>32768)return;return J}function P(J){let K=J.source??process.env,W={HOME:J.home,PATH:J.path??Y,TMPDIR:J.temporaryDirectory,SHELL:w(K.SHELL)??"/bin/zsh",LANG:w(K.LANG)??"C.UTF-8",LC_ALL:w(K.LC_ALL)??w(K.LANG)??"C.UTF-8"},Z=w(K.LC_CTYPE),Q=w(K.TERM),z=w(K.COLORTERM);if(Z)W.LC_CTYPE=Z;if(Q)W.TERM=Q;if(z)W.COLORTERM=z;return W}
4
- export{Y as Sb,H as Tb,k as Ub,v as Vb,P as Wb};
4
+ export{Y as Rb,H as Sb,k as Tb,v as Ub,P as Vb};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Oh as J}from"./vm-hands-entry-lite-9dx3at21.js";import{readFileSync as L}from"fs";import{isAbsolute as M,normalize as Q}from"path";var W="REASON_WORKER_DESKTOP_USER",G=null;function X(q,B){for(let I of B.split(`
2
+ import{Kh as J}from"./vm-hands-entry-lite-5b29hq7h.js";import{readFileSync as L}from"fs";import{isAbsolute as M,normalize as Q}from"path";var W="REASON_WORKER_DESKTOP_USER",G=null;function X(q,B){for(let I of B.split(`
3
3
  `)){let j=I.split(":");if(j.length<7||Number(j[2])!==q||!/^\d+$/.test(j[2])||!/^\d+$/.test(j[3]))continue;let x=j[5];if(!/^[a-z_][a-z0-9_-]*$/i.test(j[0])||!M(x)||Q(x)!==x||x==="/")return null;return{username:j[0],uid:q,gid:Number(j[3]),home:x}}return null}function b(q={}){let B="value"in q?q.value:process.env[W];if(G=null,B===void 0||B==="")return null;let I=q.platform??process.platform,j="euid"in q?q.euid:process.geteuid?.(),x=/^[1-9]\d{0,9}$/.test(B)?Number(B):NaN,C=I==="linux"&&j===0&&Number.isSafeInteger(x)?X(x,(q.passwd??(()=>L("/etc/passwd","utf8")))()):null;if(!C||C.gid===0)throw Error("worker_desktop_user_invalid");return G=C,C}function k(){return G}function y(){return G?.home??J()}
4
- export{W as Ze,X as _e,b as $e,k as af,y as bf};
4
+ export{W as Ve,X as We,b as Xe,k as Ye,y as Ze};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{ge as xe}from"./vm-hands-entry-lite-36xzwsxn.js";import{Ee as W,Fe as oe,He as _t,Ie as Ne,Le as St,Me as wt,Ne as $,We as z,Xe as Je}from"./vm-hands-entry-lite-wgjqxtxj.js";import{af as Se}from"./vm-hands-entry-lite-pa111vpq.js";import{cf as Jt,ff as xt,if as Z,kf as zt,lf as ae}from"./vm-hands-entry-lite-449p9dx7.js";import{Pf as Ae,Qf as se}from"./vm-hands-entry-lite-yeahy7rk.js";import{Ih as Ot,wh as v,yh as tt,zh as D}from"./vm-hands-entry-lite-1xjtcxpn.js";import{Oh as q}from"./vm-hands-entry-lite-9dx3at21.js";import{ni as pe,ti as ye}from"./vm-hands-entry-lite-0jar357h.js";import{ui as _}from"./vm-hands-entry-lite-gt5pkv4h.js";import{spawn as I}from"child_process";import{randomUUID as Oe}from"crypto";import{closeSync as Vr,copyFileSync as de,existsSync as ut,fstatSync as Er,mkdirSync as fe,openSync as vr,readdirSync as V,readFileSync as ge,readlinkSync as to,renameSync as eo,rmSync as ro,statSync as oo}from"fs";import{connect as so}from"net";import{userInfo as Te}from"os";import{basename as le,dirname as mt,join as b}from"path";var At=`import { spawn, execFileSync } from "node:child_process";
2
+ import{ce as xe}from"./vm-hands-entry-lite-qf01e5f1.js";import{Ae as W,Be as oe,De as _t,Ee as Ne,He as St,Ie as wt,Je as $,Se as z,Te as Je}from"./vm-hands-entry-lite-09depjka.js";import{Ye as Se}from"./vm-hands-entry-lite-xhjbc3e4.js";import{_e as Jt,bf as xt,ef as Z,gf as zt,hf as ae}from"./vm-hands-entry-lite-9e7wr5a4.js";import{Lf as Ae,Mf as se}from"./vm-hands-entry-lite-c9wp99nr.js";import{Eh as Ot,sh as v,uh as tt,vh as D}from"./vm-hands-entry-lite-6qfax5p2.js";import{Kh as q}from"./vm-hands-entry-lite-5b29hq7h.js";import{ji as pe,pi as ye}from"./vm-hands-entry-lite-6f5eypjm.js";import{qi as _}from"./vm-hands-entry-lite-tj1y61bg.js";import{spawn as I}from"child_process";import{randomUUID as Oe}from"crypto";import{closeSync as Vr,copyFileSync as de,existsSync as ut,fstatSync as Er,mkdirSync as fe,openSync as vr,readdirSync as V,readFileSync as ge,readlinkSync as to,renameSync as eo,rmSync as ro,statSync as oo}from"fs";import{connect as so}from"net";import{userInfo as Te}from"os";import{basename as le,dirname as mt,join as b}from"path";var At=`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";
@@ -757,4 +757,4 @@ WantedBy=default.target
757
757
  `),1;if(t.length===1&&t[0]==="doctor"){let i=await(e.grants??Ae)(o);if(!i)return r.write(`Reason computer use: Reason's permissions could not be read (computer_use_permission_status_unavailable)
758
758
  `),1;return(e.stdout??process.stdout).write(wo(i)),0}if(t.length!==1||t[0]!=="mcp")return r.write(`Usage: reason __computer-use mcp|doctor
759
759
  `),2;let[a,...c]=o;return(e.run??xo)(a,[...c,s.ocu,"mcp"],{...process.env,OPEN_COMPUTER_USE_DISABLE_APP_AGENT_PROXY:"1"})}function Ks(t=$){return t()?.userChrome??{code:"user_chrome_browser_use_missing"}}function Ce(t,e,r,o){return new Promise((s)=>{let a=I(t,e,{env:r,stdio:"ignore"}),c=setTimeout(()=>{a.kill("SIGKILL"),s(-1)},o);a.once("error",()=>{clearTimeout(c),s(-1)}),a.once("exit",(i)=>{clearTimeout(c),s(i??-1)})})}function So(t,e,r,o){return new Promise((s)=>{let a=I(t,e,{env:r,stdio:["ignore","pipe","ignore"]}),c="";a.stdout.setEncoding("utf8").on("data",(d)=>{c+=d});let i=setTimeout(()=>{a.kill("SIGKILL"),s(null)},o);a.once("error",()=>{clearTimeout(i),s(null)}),a.once("close",(d)=>{clearTimeout(i),s(d===0?c:null)})})}var po="/tmp/open-browser-use",yo=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,Ao=33554432;function No(t,e){let r;try{r=t===null?null:JSON.parse(t)}catch{return null}let o=H(r)&&H(r.result)?r.result.metadata:null;if(!H(o)||o.extensionId!==e)return null;return typeof o.extensionInstanceId==="string"&&yo.test(o.extensionInstanceId)?o.extensionInstanceId:null}async function Be(t,e,r){let o=r.storages.map((i)=>{try{return V(i).filter((d)=>d.endsWith(".log")||d.endsWith(".ldb")).map((d)=>b(i,d))}catch{return[]}}),s;try{s=o.some((i)=>i.length>0)?V(r.socketDir).filter((i)=>i.endsWith(".sock")):[]}catch{return[]}let a=[];for(let i of s){let d=b(r.socketDir,i),f=No(await So(t,["info","--socket",d,"--timeout","2s"],e,5000),r.extensionId);if(f)a.push({instance:f,socket:d})}let c=[];for(let[i,d]of(a.length>0?o:[]).entries())for(let f of d)try{if(oo(f).size>Ao)continue;let n=ge(f),l=a.find((u)=>n.includes(u.instance));if(l){c.push({storage:r.storages[i],...l});break}}catch{}return c}async function Oo(t,e,r){return(await Be(t,e,r))[0]?.instance??null}function Ie(t,e,r){return Oo(t,e,{socketDir:po,extensionId:_t,storages:[b(r,"browser-profile","Default","Local Extension Settings",_t)]})}var ue=/^(Default|Profile ([0-9]+))$/;async function go(t,e,r=q(),o=St){let s=b(r,"Library","Application Support","Google","Chrome"),a=[];try{a=V(s)}catch(n){if(n.code==="EPERM")throw new _("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 c=(n)=>Number(ue.exec(n)?.[2]??-1),i=a.filter((n)=>ue.test(n)&&ut(b(s,n,"Extensions",W))).sort((n,l)=>c(n)-c(l)),d=(n)=>b(s,n,"Local Extension Settings",W);return(await Be(t,e,{socketDir:o,extensionId:W,storages:i.map(d)})).map(({storage:n,instance:l,socket:u})=>({profile:i.find((m)=>d(m)===n),instance:l,socket:u}))}async function To(t,e,r=q(),o=St){let s=(await go(t,e,r,o))[0]?.instance;if(!s)throw new _("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 me(t){return new Promise((e)=>{let r=so({path:t}),o=(s)=>{r.destroy(),e(s)};r.setTimeout(1000,()=>o(!1)),r.once("error",()=>o(!1)),r.once("connect",()=>o(!0))})}async function $e(t,e){let r=Date.now()+e;while(Date.now()<r){if(await t())return!0;await new Promise((o)=>setTimeout(o,200))}return!1}var ft=new Map;function lt(t,e){let r=ft.get(t);if(!r)r=e().finally(()=>ft.delete(t)),ft.set(t,r);return r}async function qo(t,e){if(await me(t))return;if(ro(t,{force:!0}),await Ce("dbus-daemon",["--session",`--address=unix:path=${t}`,"--fork"],e,1e4)!==0||!await $e(()=>me(t),5000))throw new _("automation_unavailable","Reason could not start the desktop session bus.")}async function be(t,e,r){let o=t.platform==="darwin-arm64"?async()=>await Ie(t.nativeHost,e,r)!==null:async()=>await Ce(t.nativeHost,["info"],e,5000)===0;if(await o())return;let s=["--profile-directory=Default",`--load-extension=${t.extensionDir}`,"--no-first-run","--no-default-browser-check","--window-size=1280,800","about:blank"],a,c=null,i=0;if(t.platform==="darwin-arm64"){let n=b(r,"browser-profile");z(n);let l=b(n,"NativeMessagingHosts");fe(l,{recursive:!0,mode:448});let u=wt(t.platform).nativeHostManifests[0];de(u,b(l,le(u)));let m=t.browser.slice(0,t.browser.indexOf(".app/")+4),S=s.filter((B)=>B!=="about:blank").concat("--no-startup-window","--use-mock-keychain");a=I("/usr/bin/open",["-g","-n","-a",m,"--args",`--user-data-dir=${n}`,...S],{env:e,stdio:"ignore"})}else{let n=b(e.HOME,".config","google-chrome"),l=b(n,"NativeMessagingHosts");fe(l,{recursive:!0,mode:448});let u=wt(t.platform).nativeHostManifests[0];de(u,b(l,le(u)));let m=process.geteuid?.()===0?["--no-sandbox"]:[];c=b(r,"browser.log");let S=vr(c,"a",384);i=Er(S).size,a=I(t.browser,[`--user-data-dir=${n}`,...s,...m,"--force-renderer-accessibility"],{detached:!0,stdio:["ignore",S,S],env:{...e,ACCESSIBILITY_ENABLED:"1"}}),Vr(S)}let d=!1;a.once("error",()=>{d=!0}),a.once("exit",(n)=>{d||=n!==0}),a.unref();let f=!1;if(await $e(async()=>d||(f=await o()),_o),!f){if(c&&ge(c).subarray(i).toString("utf8").includes("No usable sandbox"))throw new _("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 _("automation_browser_unavailable","Reason could not connect the desktop browser.")}}async function Vs(t){await Ge(t,!0)}function Es(t){return Fe(t,Re(t))}function Fe(t,e){return t.platform==="darwin-arm64"?b(e,"browser-profile"):b(e,"home",".config","google-chrome")}function Re(t){let e=b(t.root,"automation");if(!ut(e)||!Co(t.automation))return t.automation;if(!Bo(Fe(t,e)))try{eo(e,t.automation)}catch{}return ut(e)?e:t.automation}function Co(t){try{return V(t).length===0}catch(e){return e.code==="ENOENT"}}function Bo(t){let e;try{e=to(b(t,"SingletonLock"))}catch{return!1}let r=Number(e.slice(e.lastIndexOf("-")+1));if(!Number.isSafeInteger(r)||r<=0)return!0;try{return process.kill(r,0),!0}catch(o){return o.code==="EPERM"}}async function Ge(t,e){pe({root:t.root,automation:t.automation,extensionDir:t.extensionDir});let r=Re(t);z(r);let o=Te().username,s={USER:o,LOGNAME:o,REASON_AUTOMATION_OCU:t.ocu,REASON_AUTOMATION_OBU:t.nativeHost};if(t.platform==="darwin-arm64"){let n={...s,HOME:q(),PATH:`${mt(t.node)}:/usr/bin:/bin:/usr/sbin:/sbin`,REASON_AUTOMATION_OCU:process.execPath,REASON_AUTOMATION_OCU_SUBCOMMAND:bo};if(!e)return n;await lt("browser",()=>be(t,n,r));let l=await Ie(t.nativeHost,n,r);if(!l)throw new _("automation_browser_unavailable","Reason could not connect the desktop browser.");return{...n,REASON_AUTOMATION_OBU_INSTANCE:l,REASON_AUTOMATION_BACKGROUND_TABS:"1"}}let a=await Je(),c=b(r,"home"),i=b(r,"runtime");z(c),z(i);let d=b(r,"bus"),f={...s,HOME:c,PATH:`${mt(t.node)}:/usr/bin:/bin`,DISPLAY:a.display,XAUTHORITY:a.xauthority,XDG_RUNTIME_DIR:i,DBUS_SESSION_BUS_ADDRESS:`unix:path=${d}`,...a.sound?{PULSE_SERVER:Ne(a.sound)}:{}};if(await lt("bus",()=>qo(d,f)),e)await lt("browser",()=>be(t,f,r));return f}async function Io(t,e,r){let o=Te().username,s={USER:o,LOGNAME:o,HOME:q(),PATH:`${mt(t.node)}:/usr/bin:/bin:/usr/sbin:/sbin`,REASON_AUTOMATION_OBU:e,REASON_AUTOMATION_BACKGROUND_TABS:"1"},a=await To(e,s);return r.throwIfAborted(),{...s,REASON_AUTOMATION_OBU_INSTANCE:a}}function Ue(t,e,r,o){if(typeof _e!=="string")return Promise.reject(new _("automation_unavailable","This Reason build has no automation runtime."));let s=_e;return new Promise((a,c)=>{let i=I(t,["--input-type=module","--eval",s],{env:{...e,REASON_CLOUD_GATEWAY_EXEC:"1",REASON_AUTOMATION_INLINE_RESULT:"1"},stdio:["pipe","pipe","pipe"],detached:!0}),d=[],f=0,n="",l=null,u=!1,m=(w)=>{l??=w;try{process.kill(-i.pid,"SIGKILL")}catch{i.kill("SIGKILL")}},S=(w)=>{if(u)return;u=!0,clearTimeout(B),o.removeEventListener("abort",g),w()},B=setTimeout(()=>m(new _("automation_timed_out","Reason automation did not finish in time.")),no),g=()=>m(new _("cancelled","Reason cancelled the automation call."));if(o.addEventListener("abort",g,{once:!0}),i.stdout.on("data",(w)=>{if(f+=w.byteLength,f>ao)m(new _("automation_output_too_large","Reason automation output is too large."));else d.push(w)}),i.stderr.setEncoding("utf8").on("data",(w)=>{n=(n+w).slice(-io)}),i.stdin.on("error",()=>{}),i.once("error",()=>S(()=>c(l??new _("automation_unavailable","Reason could not start the automation runtime.")))),i.once("close",(w)=>S(()=>{if(l)c(l);else a({code:w??1,stdout:Buffer.concat(d),stderr:n})})),o.aborted)g();i.stdin.end(r)})}var C=new Map;function $o(t,e,r){for(let[s,a]of C)if(a.expiresAt<=r)C.delete(s);while(C.size>=lo)C.delete(C.keys().next().value);let o=Oe();return C.set(o,{runId:t,bytes:e,expiresAt:r+fo}),o}async function Le(t,e,r,o={}){let s=await(o.environment??Ge)(t,e.kind==="browser");return r.throwIfAborted(),await(o.runtime??Ue)(t.node,s,JSON.stringify(e),r)}async function vs(t,e){let r=qe({call:t});if(!("call"in r))K();let o=$();if(!o?.features.computer||r.call.kind==="browser"&&!o.features.browser)throw new _("automation_unavailable","Run `reason desktop install` on this machine to enable computer and browser use.");return await Le(o,r.call,e)}function we(t,e,r){let o=t.stdout.byteLength>bt?$o(e,t.stdout,r):void 0;return{code:t.code,stderr:t.stderr,instance_id:mo,output_bytes:t.stdout.byteLength,chunk:t.stdout.subarray(0,bt).toString("base64"),...o?{output_id:o}:{}}}async function ta(t,e={}){let r=qe(t.payload),o=(e.now??Date.now)();if("output_id"in r){let m=C.get(r.output_id);if(!m||m.runId!==t.runId||m.expiresAt<=o||r.offset>m.bytes.byteLength)throw new _("automation_output_unavailable","Reason automation output expired.");return{chunk:m.bytes.subarray(r.offset,r.offset+bt).toString("base64")}}let s=(e.components??$)(),a=(e.platform??process.platform)==="darwin",c=a?(e.macIdentity??xt)():[],i=e.macSetup??X,d=!s?.features.computer||r.call.kind==="browser"&&!r.userChrome&&!s.features.browser;if(a&&(d||c.length===0||r.call.kind==="browser"&&r.userChrome&&!t.userChrome))return we(await ce({runId:t.runId,call:r.call,identity:c,desktopMissing:d,signal:t.signal},i),t.runId,o);if(!s?.features.computer)throw new _("automation_unavailable","Run `reason desktop install` on this machine to enable computer and browser use.");let f=r.userChrome?t.userChrome:void 0;if(r.userChrome&&!f)throw new _("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(r.call.kind==="browser"&&!f&&!s.features.browser)throw new _("automation_browser_not_installed",s.platform==="darwin-arm64"?"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`.");t.signal.throwIfAborted();let n=await ye(t.runId,t.signal,e.now),l="account"in e?e.account??null:Se(),u;try{if(f){let m=await(e.userChromeEnvironment??Io)(s,f,t.signal);t.signal.throwIfAborted(),u=await(e.runtime??Ue)(s.node,m,JSON.stringify(r.call),t.signal)}else if(l)u=await(e.delegate??Nt)(l,r.call,t.signal);else u=await Le(s,r.call,t.signal,e)}finally{n()}if(a)u=await ne({runId:t.runId,call:r.call,identity:c,output:u,signal:t.signal},i);return we(u,t.runId,o)}
760
- export{Ut as Kc,at as Lc,Dt as Mc,A as Nc,Mt as Oc,cs as Pc,kt as Qc,ns as Rc,dt as Sc,Ur as Tc,ds as Uc,fs as Vc,ls as Wc,_s as Xc,us as Yc,ms as Zc,We as _c,bt as $c,qe as ad,Ws as bd,xo as cd,Hs as dd,Ks as ed,go as fd,To as gd,Vs as hd,Es as id,vs as jd,ta as kd};
760
+ export{Ut as Gc,at as Hc,Dt as Ic,A as Jc,Mt as Kc,cs as Lc,kt as Mc,ns as Nc,dt as Oc,Ur as Pc,ds as Qc,fs as Rc,ls as Sc,_s as Tc,us as Uc,ms as Vc,We as Wc,bt as Xc,qe as Yc,Ws as Zc,xo as _c,Hs as $c,Ks as ad,go as bd,To as cd,Vs as dd,Es as ed,vs as fd,ta as gd};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import"./vm-hands-entry-lite-1wy28sjt.js";import"./vm-hands-entry-lite-36xzwsxn.js";import"./vm-hands-entry-lite-2xh7sjs0.js";import{Ai as A}from"./vm-hands-entry-lite-mhsv58hw.js";import{readFileSync as J}from"fs";var G=performance.now();delete process.env.BUN_BE_BUN;var q=(j,b={})=>console.log(JSON.stringify({stage:j,ms:Math.round(performance.now()),...b}));async function K(){if(process.argv.includes("--vm-hands-op-runner")){let{runVmHandsOpRunner:D}=await import("./vm-hands-op-runner-01szqn0m.js");await D();return}q("parsed",{t0:Math.round(G)});let j="";try{j=J(3,"utf8")}catch{}q("fd3_read",{bytes:j.length});let b=null;if(j.trim())try{b=JSON.parse(j)}catch{b=null}if(!b||typeof b!=="object"||Array.isArray(b))q(j.trim()?"identity_invalid":"identity_free"),await new Promise(()=>{setInterval(()=>{return},1073741824)});let{parseVmHandsInit:B,runVmHands:C}=await import("./vm-hands-runtime-k21dbztp.js"),z=B(b);if(!z)q("identity_invalid"),await new Promise(()=>{setInterval(()=>{return},1073741824)});await C(z,q),process.exit(0)}K();
2
+ import"./vm-hands-entry-lite-15q5nc6y.js";import"./vm-hands-entry-lite-qf01e5f1.js";import"./vm-hands-entry-lite-k17ntg9v.js";import{wi as A}from"./vm-hands-entry-lite-nd1k2jz9.js";import{readFileSync as J}from"fs";var G=performance.now();delete process.env.BUN_BE_BUN;var q=(j,b={})=>console.log(JSON.stringify({stage:j,ms:Math.round(performance.now()),...b}));async function K(){if(process.argv.includes("--vm-hands-op-runner")){let{runVmHandsOpRunner:D}=await import("./vm-hands-op-runner-ab3h5v2e.js");await D();return}q("parsed",{t0:Math.round(G)});let j="";try{j=J(3,"utf8")}catch{}q("fd3_read",{bytes:j.length});let b=null;if(j.trim())try{b=JSON.parse(j)}catch{b=null}if(!b||typeof b!=="object"||Array.isArray(b))q(j.trim()?"identity_invalid":"identity_free"),await new Promise(()=>{setInterval(()=>{return},1073741824)});let{parseVmHandsInit:B,runVmHands:C}=await import("./vm-hands-runtime-6wdanp9f.js"),z=B(b);if(!z)q("identity_invalid"),await new Promise(()=>{setInterval(()=>{return},1073741824)});await C(z,q),process.exit(0)}K();