@reason-machines/cli-linux-x64 0.2.393 → 0.2.395

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 (93) hide show
  1. package/bin/reason +1 -1
  2. package/bin/vm-hands/api-credentials-200ret9z.js +2 -0
  3. package/bin/vm-hands/api-jcccjxss.js +2 -0
  4. package/bin/vm-hands/{ask-relay-q0ysjj22.js → ask-relay-e424fxe1.js} +3 -3
  5. package/bin/vm-hands/connect-cli-t2cf1fhv.js +2 -0
  6. package/bin/vm-hands/{custom-endpoint-device-3g0rc3wp.js → custom-endpoint-device-qd3zcysz.js} +1 -1
  7. package/bin/vm-hands/desktop-account-r5fsgx43.js +2 -0
  8. package/bin/vm-hands/{device-workspace-35hjc1ff.js → device-workspace-ntckpym4.js} +1 -1
  9. package/bin/vm-hands/{hands-worker-source-msdkfx9x.js → hands-worker-source-p6530nj7.js} +1 -1
  10. package/bin/vm-hands/{index-m32pjcjr.js → index-z6q2j1e0.js} +1 -1
  11. package/bin/vm-hands/install-receipt-kqayxfsn.js +2 -0
  12. package/bin/vm-hands/local-automation-3msswz1s.js +2 -0
  13. package/bin/vm-hands/local-capabilities-jp7mfe90.js +2 -0
  14. package/bin/vm-hands/local-desktop-users-7kbrnvba.js +2 -0
  15. package/bin/vm-hands/local-display-mac-0k5twcjj.js +2 -0
  16. package/bin/vm-hands/local-display-session-4nz3ps1j.js +2 -0
  17. package/bin/vm-hands/local-pty-session-a0fz1f9t.js +2 -0
  18. package/bin/vm-hands/{managed-runtime-bgbzjn5s.js → managed-runtime-jpkvdh9q.js} +1 -1
  19. package/bin/vm-hands/{network-contract-3h853c6e.js → network-contract-xgbrevt2.js} +1 -1
  20. package/bin/vm-hands/package-x8ct3epg.js +2 -0
  21. package/bin/vm-hands/permissions-nhtd0qmb.js +2 -0
  22. package/bin/vm-hands/{reason-hands-protocol-mw7ba8vz.js → reason-hands-protocol-90kpyg4s.js} +1 -1
  23. package/bin/vm-hands/{serve-service-qqrsrb6k.js → serve-service-sdep4jmp.js} +1 -1
  24. package/bin/vm-hands/{status-g0yna6nk.js → status-r1k521hh.js} +2 -2
  25. package/bin/vm-hands/version-svxh3eka.js +2 -0
  26. package/bin/vm-hands/{vm-hands-entry-lite-180h5amj.js → vm-hands-entry-lite-0nd56w02.js} +1 -1
  27. package/bin/vm-hands/{vm-hands-entry-lite-a1yy1yp3.js → vm-hands-entry-lite-1cs1jy20.js} +2 -2
  28. package/bin/vm-hands/{vm-hands-entry-lite-3nr9q3nf.js → vm-hands-entry-lite-29f3m7x2.js} +1 -1
  29. package/bin/vm-hands/{vm-hands-entry-lite-5x04hakp.js → vm-hands-entry-lite-2sx1a43v.js} +2 -2
  30. package/bin/vm-hands/{vm-hands-entry-lite-3ptq7p60.js → vm-hands-entry-lite-34h6rv5c.js} +1 -1
  31. package/bin/vm-hands/{vm-hands-entry-lite-1edhwzhg.js → vm-hands-entry-lite-3ypjvw3e.js} +2 -2
  32. package/bin/vm-hands/{vm-hands-entry-lite-t7g13jac.js → vm-hands-entry-lite-42chrtkc.js} +2 -2
  33. package/bin/vm-hands/{vm-hands-entry-lite-9rnba1mg.js → vm-hands-entry-lite-4d0szmz0.js} +2 -2
  34. package/bin/vm-hands/{vm-hands-entry-lite-f78n4wqt.js → vm-hands-entry-lite-5d31qv44.js} +1 -1
  35. package/bin/vm-hands/{vm-hands-entry-lite-c7qb87xk.js → vm-hands-entry-lite-6256d8j5.js} +3 -3
  36. package/bin/vm-hands/{vm-hands-entry-lite-g87z5eb6.js → vm-hands-entry-lite-69n9q5f1.js} +1 -1
  37. package/bin/vm-hands/{vm-hands-entry-lite-ezahexcb.js → vm-hands-entry-lite-6nj2ejfh.js} +1 -1
  38. package/bin/vm-hands/{vm-hands-entry-lite-nnmhnxqs.js → vm-hands-entry-lite-90r926q9.js} +2 -2
  39. package/bin/vm-hands/{vm-hands-entry-lite-8e932j3c.js → vm-hands-entry-lite-bgs4zjkf.js} +1 -1
  40. package/bin/vm-hands/{vm-hands-entry-lite-trm3dn8c.js → vm-hands-entry-lite-cfwke54v.js} +1 -1
  41. package/bin/vm-hands/{vm-hands-entry-lite-88h9vwrv.js → vm-hands-entry-lite-e1cbqqqw.js} +1 -1
  42. package/bin/vm-hands/{vm-hands-entry-lite-r166b92s.js → vm-hands-entry-lite-e4kdpq0t.js} +1 -1
  43. package/bin/vm-hands/{vm-hands-entry-lite-h0keewxv.js → vm-hands-entry-lite-e99ftdr6.js} +1 -1
  44. package/bin/vm-hands/{vm-hands-entry-lite-ksz1k1dh.js → vm-hands-entry-lite-eatqxe5y.js} +1 -1
  45. package/bin/vm-hands/{vm-hands-entry-lite-fb02h1zm.js → vm-hands-entry-lite-ek5r435m.js} +2 -2
  46. package/bin/vm-hands/{vm-hands-entry-lite-pjctaaxx.js → vm-hands-entry-lite-ep2n8nxv.js} +2 -2
  47. package/bin/vm-hands/{vm-hands-entry-lite-0apahx7m.js → vm-hands-entry-lite-errnnc9y.js} +1 -1
  48. package/bin/vm-hands/{vm-hands-entry-lite-atg4z1vg.js → vm-hands-entry-lite-f50vcbjg.js} +1 -1
  49. package/bin/vm-hands/{vm-hands-entry-lite-8pgggvbb.js → vm-hands-entry-lite-f9akybcm.js} +2 -2
  50. package/bin/vm-hands/{vm-hands-entry-lite-csecgmaa.js → vm-hands-entry-lite-gk3y60ap.js} +2 -2
  51. package/bin/vm-hands/{vm-hands-entry-lite-ebgackey.js → vm-hands-entry-lite-hx4w3r63.js} +2 -2
  52. package/bin/vm-hands/{vm-hands-entry-lite-9gjjvcmz.js → vm-hands-entry-lite-k4erfh5k.js} +1 -1
  53. package/bin/vm-hands/vm-hands-entry-lite-kbjh8x26.js +5 -0
  54. package/bin/vm-hands/{vm-hands-entry-lite-na1vayq4.js → vm-hands-entry-lite-kjjhcjp9.js} +2 -2
  55. package/bin/vm-hands/{vm-hands-entry-lite-3xtndjrw.js → vm-hands-entry-lite-nnggcccf.js} +1 -1
  56. package/bin/vm-hands/{vm-hands-entry-lite-z4q7mrn5.js → vm-hands-entry-lite-p3d5j70y.js} +7 -7
  57. package/bin/vm-hands/{vm-hands-entry-lite-n3y7495e.js → vm-hands-entry-lite-ps9gjbs5.js} +2 -2
  58. package/bin/vm-hands/{vm-hands-entry-lite-hfv2tsm9.js → vm-hands-entry-lite-q5h859gg.js} +2 -2
  59. package/bin/vm-hands/{vm-hands-entry-lite-y99g8x7f.js → vm-hands-entry-lite-q62fwa20.js} +1 -1
  60. package/bin/vm-hands/{vm-hands-entry-lite-02zaqpgh.js → vm-hands-entry-lite-qvj5560v.js} +2 -2
  61. package/bin/vm-hands/{vm-hands-entry-lite-mft9ke08.js → vm-hands-entry-lite-sbn9bmf7.js} +1 -1
  62. package/bin/vm-hands/{vm-hands-entry-lite-p1s0xyc2.js → vm-hands-entry-lite-sjn5yjvx.js} +2 -2
  63. package/bin/vm-hands/{vm-hands-entry-lite-e73s63fb.js → vm-hands-entry-lite-smrymax6.js} +1 -1
  64. package/bin/vm-hands/{vm-hands-entry-lite-yr1n57v6.js → vm-hands-entry-lite-t839nkd2.js} +2 -2
  65. package/bin/vm-hands/{vm-hands-entry-lite-mc3pkj0q.js → vm-hands-entry-lite-v0kpksbf.js} +1 -1
  66. package/bin/vm-hands/{vm-hands-entry-lite-wpcagqfw.js → vm-hands-entry-lite-vqfpryez.js} +1 -1
  67. package/bin/vm-hands/{vm-hands-entry-lite-y64x380n.js → vm-hands-entry-lite-vys6qap2.js} +2 -2
  68. package/bin/vm-hands/{vm-hands-entry-lite-0seprnh3.js → vm-hands-entry-lite-xhbjkkk5.js} +1 -1
  69. package/bin/vm-hands/vm-hands-entry-lite-y7yr8pjm.js +105 -0
  70. package/bin/vm-hands/vm-hands-entry-lite.js +1 -1
  71. package/bin/vm-hands/{vm-hands-executor-mz0bewc9.js → vm-hands-executor-pm8ns2zs.js} +1 -1
  72. package/bin/vm-hands/vm-hands-op-runner-7r51q98t.js +2 -0
  73. package/bin/vm-hands/{vm-hands-runtime-h39vjxh4.js → vm-hands-runtime-h5s04mj9.js} +3 -3
  74. package/bin/vm-hands/worker-sandbox-ecjj14h5.js +2 -0
  75. package/package.json +1 -1
  76. package/bin/vm-hands/api-2edgrjpe.js +0 -2
  77. package/bin/vm-hands/api-credentials-1bfy2pqp.js +0 -2
  78. package/bin/vm-hands/connect-cli-9xve38p0.js +0 -2
  79. package/bin/vm-hands/desktop-account-8yf4aqgb.js +0 -2
  80. package/bin/vm-hands/install-receipt-7qanbz38.js +0 -2
  81. package/bin/vm-hands/local-automation-svznxf54.js +0 -2
  82. package/bin/vm-hands/local-capabilities-a2fhpy8v.js +0 -2
  83. package/bin/vm-hands/local-desktop-users-p6n48895.js +0 -2
  84. package/bin/vm-hands/local-display-mac-7havkbhd.js +0 -2
  85. package/bin/vm-hands/local-display-session-42vasad3.js +0 -2
  86. package/bin/vm-hands/local-pty-session-pe20a847.js +0 -2
  87. package/bin/vm-hands/package-04cf0m62.js +0 -2
  88. package/bin/vm-hands/permissions-2ez0eqav.js +0 -2
  89. package/bin/vm-hands/version-5tfam1n3.js +0 -2
  90. package/bin/vm-hands/vm-hands-entry-lite-0z73amf7.js +0 -5
  91. package/bin/vm-hands/vm-hands-entry-lite-vc06etcb.js +0 -105
  92. package/bin/vm-hands/vm-hands-op-runner-6vttwrek.js +0 -2
  93. package/bin/vm-hands/worker-sandbox-nnk7fq89.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{jk as W}from"./vm-hands-entry-lite-8pgggvbb.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{nk as W}from"./vm-hands-entry-lite-f9akybcm.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{jk as W}from"./vm-hands-entry-lite-8pgggvbb.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 $W(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 KW(Q){return L(Q,!1)}function DW(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 zW(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 FW(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 wW(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 VW(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 YW(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 HW(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 XW(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 GW(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 BW(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 MW(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 qW(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 ye,R as ze,ZQ as Ae,x as Be,$Q as Ce,m as De,KQ as Ee,DQ as Fe,zQ as Ge,b as He,j as Ie,I as Je,n as Ke,HQ as Le,XQ as Me,GQ as Ne,BQ as Oe,MQ as Pe,gQ as Qe,qQ as Re,NQ as Se,mQ as Te,UQ as Ue,jQ as Ve,xQ as We,JQ as Xe,SQ as Ye,IQ as Ze,PQ as _e,TQ as $e,CQ as af,AQ as bf,bQ as cf,EQ as df,kQ as ef,LQ as ff,fQ as gf,_Q as hf,cQ as if,yQ as jf,dQ as kf,OQ as lf,hQ as mf,RQ as nf,rQ as of,pQ as pf,nQ as qf,oQ as rf,sQ as sf,iQ as tf,tQ as uf,vQ as vf,lQ as wf,uQ as xf,aQ as yf,eQ as zf,QW as Af,i as Bf,WW as Cf,ZW as Df,$W as Ef,l as Ff,KW as Gf,DW as Hf,zW as If,FW as Jf,wW as Kf,VW as Lf,YW as Mf,HW as Nf,XW as Of,GW as Pf,BW as Qf,MW as Rf,gW as Sf,qW as Tf};
42
+ export{d as Ce,R as De,ZQ as Ee,x as Fe,$Q as Ge,m as He,KQ as Ie,DQ as Je,zQ as Ke,b as Le,j as Me,I as Ne,n as Oe,HQ as Pe,XQ as Qe,GQ as Re,BQ as Se,MQ as Te,gQ as Ue,qQ as Ve,NQ as We,mQ as Xe,UQ as Ye,jQ as Ze,xQ as _e,JQ as $e,SQ as af,IQ as bf,PQ as cf,TQ as df,CQ as ef,AQ as ff,bQ as gf,EQ as hf,kQ as if,LQ as jf,fQ as kf,_Q as lf,cQ as mf,yQ as nf,dQ as of,OQ as pf,hQ as qf,RQ as rf,rQ as sf,pQ as tf,nQ as uf,oQ as vf,sQ as wf,iQ as xf,tQ as yf,vQ as zf,lQ as Af,uQ as Bf,aQ as Cf,eQ as Df,QW as Ef,i as Ff,WW as Gf,ZW as Hf,$W as If,l as Jf,KW as Kf,DW as Lf,zW as Mf,FW as Nf,wW as Of,VW as Pf,YW as Qf,HW as Rf,XW as Sf,GW as Tf,BW as Uf,MW as Vf,gW as Wf,qW as Xf};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  import{resolve as H,sep as J}from"path";var K=[[".ssh"],[".gnupg"],[".aws"],[".azure"],[".kube"],[".docker"],[".infisical"],[".password-store"],[".terraform.d"],[".config","ara"],[".config","reason"],[".config","gh"],[".config","gcloud"],[".config","infisical"],[".config","op"],[".config","1password"],[".config","pass"],[".local","share","keyrings"],["library","keychains"],["library","application support","so.ara.desktop"],["appdata","roaming","github cli"],["appdata","roaming","gcloud"],["appdata","roaming","microsoft","credentials"],["appdata","local","microsoft","credentials"],["appdata","roaming","microsoft","protect"],["appdata","roaming","1password"],["appdata","local","1password"],["appdata","roaming","microsoft","windows","start menu","programs","startup"],["documents","windowspowershell"],["documents","powershell"],["appdata","local","reason"]],V=[[".codex","config.toml"],[".cursor","mcp.json"],[".claude","settings.json"],[".claude","settings.local.json"],[".cargo","credentials"],[".cargo","credentials.toml"],[".gem","credentials"],[".config","git","config"],[".config","git","credentials"],[".config","pip","pip.conf"]],Z=new Set([".bash_login",".bash_profile",".bashrc",".bunfig.toml",".claude.json",".env",".envrc",".git-credentials",".gitconfig",".mcp.json",".netrc",".npmrc",".profile",".pypirc",".terraformrc",".yarnrc",".yarnrc.yml",".zlogin",".zlogout",".zprofile",".zshenv",".zshrc","auth.json","credentials.json","credentials.tfrc.json","local-daemon.json","local-device.json","mcp.json"]),$=[".key",".p12",".pfx",".pem"];function B(z,j){if(z.length<j.length)return!1;for(let k=0;k<=z.length-j.length;k+=1)if(j.every((b,G)=>z[k+G]===b))return!0;return!1}function A(z){let j=H(z).split(J).filter(Boolean).map((b)=>b.toLowerCase());if(K.some((b)=>B(j,b)))return!0;if(V.some((b)=>B(j,b)))return!0;let k=j.at(-1)??"";return Z.has(k)||k.startsWith(".env.")||$.some((b)=>k.endsWith(b))}
3
- export{K as Si,V as Ti,Z as Ui,$ as Vi,A as Wi};
3
+ export{K as Wi,V as Xi,Z as Yi,$ as Zi,A as _i};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{xk as b}from"./vm-hands-entry-lite-fb02h1zm.js";import{Gk as W}from"./vm-hands-entry-lite-g87z5eb6.js";import{execFileSync as C}from"child_process";import{mkdirSync as f,readdirSync as K,readFileSync as k,rmSync as G,statSync as A,writeFileSync as F}from"fs";import{join as $,sep as R}from"path";import{setTimeout as L}from"timers/promises";var O=3000,Y=null;function x(z){return $(z,"users")}function I(z){if(Y?.root===z.root)return;let H=x(z.root);f(H,{recursive:!0,mode:448}),F($(H,String(process.pid)),"",{mode:384}),Y=z}function w(){if(!Y)return;G($(x(Y.root),String(process.pid)),{force:!0}),Y=null}function B(z){try{return process.kill(z,0),!0}catch(H){return H instanceof Error&&"code"in H&&H.code==="EPERM"}}function j(){let z=process.getuid?.();if(process.platform==="linux")return K("/proc").flatMap((N)=>{if(!/^\d+$/.test(N))return[];try{if(A(`/proc/${N}`).uid!==z)return[];let Q=k(`/proc/${N}/cmdline`).toString("utf8").split("\x00").join(" ").trim();return Q?[{pid:Number(N),command:Q}]:[]}catch{return[]}});if(process.platform==="win32")return C(b("powershell.exe"),["-NoLogo","-NoProfile","-NonInteractive","-Command",'Get-CimInstance Win32_Process | ForEach-Object { "$($_.ProcessId) $($_.CommandLine)" }'],{encoding:"utf8",maxBuffer:16777216,windowsHide:!0}).split(/\r?\n/).flatMap((Q)=>{let V=/^(\d+) (.+)$/.exec(Q.trim());return V?[{pid:Number(V[1]),command:V[2]}]:[]});return C("/bin/ps",["-axww","-o","pid=,uid=,command="],{encoding:"utf8",maxBuffer:16777216}).split(`
2
+ import{Bk as b}from"./vm-hands-entry-lite-ek5r435m.js";import{Kk as W}from"./vm-hands-entry-lite-69n9q5f1.js";import{execFileSync as C}from"child_process";import{mkdirSync as f,readdirSync as K,readFileSync as k,rmSync as G,statSync as A,writeFileSync as F}from"fs";import{join as $,sep as R}from"path";import{setTimeout as L}from"timers/promises";var O=3000,Y=null;function x(z){return $(z,"users")}function I(z){if(Y?.root===z.root)return;let H=x(z.root);f(H,{recursive:!0,mode:448}),F($(H,String(process.pid)),"",{mode:384}),Y=z}function w(){if(!Y)return;G($(x(Y.root),String(process.pid)),{force:!0}),Y=null}function B(z){try{return process.kill(z,0),!0}catch(H){return H instanceof Error&&"code"in H&&H.code==="EPERM"}}function j(){let z=process.getuid?.();if(process.platform==="linux")return K("/proc").flatMap((N)=>{if(!/^\d+$/.test(N))return[];try{if(A(`/proc/${N}`).uid!==z)return[];let Q=k(`/proc/${N}/cmdline`).toString("utf8").split("\x00").join(" ").trim();return Q?[{pid:Number(N),command:Q}]:[]}catch{return[]}});if(process.platform==="win32")return C(b("powershell.exe"),["-NoLogo","-NoProfile","-NonInteractive","-Command",'Get-CimInstance Win32_Process | ForEach-Object { "$($_.ProcessId) $($_.CommandLine)" }'],{encoding:"utf8",maxBuffer:16777216,windowsHide:!0}).split(/\r?\n/).flatMap((Q)=>{let V=/^(\d+) (.+)$/.exec(Q.trim());return V?[{pid:Number(V[1]),command:V[2]}]:[]});return C("/bin/ps",["-axww","-o","pid=,uid=,command="],{encoding:"utf8",maxBuffer:16777216}).split(`
3
3
  `).flatMap((N)=>{let Q=/^\s*(\d+)\s+(\d+)\s+(.+)$/.exec(N);return Q&&Number(Q[2])===z?[{pid:Number(Q[1]),command:Q[3]}]:[]})}async function h(){let z=Y;if(!z)return{released:"unused",stopped:0};let H=x(z.root);G($(H,String(process.pid)),{force:!0}),Y=null;let N=!1;for(let J of K(H)){let U=Number(J);if(Number.isSafeInteger(U)&&U>0&&B(U))N=!0;else G($(H,J),{force:!0})}if(N)return{released:"shared",stopped:0};let Q=j().filter((J)=>J.pid!==process.pid&&(J.command.includes(`${z.root}${R}`)||J.command.includes(`${z.automation}${R}`)||J.command.includes(z.extensionDir))),V=(J,U)=>{try{process.kill(J,U)}catch{}};for(let J of Q)V(J.pid,"SIGTERM");for(let J=Date.now()+O;Date.now()<J&&Q.some((U)=>B(U.pid));)await new Promise((U)=>setTimeout(U,100));for(let J of Q)if(B(J.pid))V(J.pid,"SIGKILL");return{released:"stopped",stopped:Q.length}}var v=20000,M=30000,P=100,Z=new Map,X=null,q=[];function y(z){Z.set(z,(Z.get(z)??0)+1);let H=!1;return()=>{if(H)return;H=!0;let N=(Z.get(z)??1)-1;if(N>0){Z.set(z,N);return}if(Z.delete(z),X?.run===z)X.idleUntil=0}}function D(){return new W("automation_desktop_busy","Another Session, or another agent of this Session, is using this worker's desktop. Retry after it finishes.")}function E(z,H){return X!==null&&X.run!==z&&(X.calls>0||H<X.idleUntil)}async function u(z,H,N=Date.now){let Q=Symbol(z);q.push(Q);try{let U=N()+M;for(;;){if(!E(z,N())&&(X?.run===z||q[0]===Q))break;if(N()>=U)throw D();await L(P,void 0,{signal:H}).catch(()=>H.throwIfAborted())}}finally{q.splice(q.indexOf(Q),1)}if(X?.run!==z)X={run:z,calls:0,idleUntil:0};let V=X;V.calls+=1;let J=!1;return()=>{if(J)return;J=!0,V.calls-=1,V.idleUntil=N()+v}}
4
- export{I as kk,w as lk,h as mk,v as nk,M as ok,y as pk,u as qk};
4
+ export{I as ok,w as pk,h as qk,v as rk,M as sk,y as tk,u as uk};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{jk as w}from"./vm-hands-entry-lite-8pgggvbb.js";var S="inference.custom.v1",K=32768,P=67108864,Q=16384,T=204800,z=600000,U=["content-type","anthropic-version","user-agent"],L=w.enum(["openai-completions","openai-responses","anthropic-messages"]),V=new Set(U),W=w.record(w.string(),w.string().max(2048)).refine((j)=>Object.keys(j).every((A)=>V.has(A))&&Object.values(j).every((A)=>!/[\r\n\0]/.test(A)),"Only non-secret custom endpoint request headers are permitted");function F(j){try{let A=new URL(j);return["http:","https:"].includes(A.protocol)&&!A.username&&!A.password&&!A.search&&!A.hash?A:null}catch{return null}}function X(j,A){let B=F(j.baseUrl),H=F(A.baseUrl),D=F(j.url);if(!B||!H||!D||j.method!=="POST"||A.execution!=="device")return!1;let I=(J)=>J.origin+J.pathname.replace(/\/+$/,"");if(I(B)!==I(H)||D.origin!==B.origin)return!1;let O=A.api==="openai-completions"?"/chat/completions":A.api==="openai-responses"?"/responses":"/v1/messages";return D.pathname===B.pathname.replace(/\/+$/,"")+O}var b=w.object({baseUrl:w.string().max(2048),url:w.string().max(4096),method:w.literal("POST"),body:w.string().refine((j)=>new TextEncoder().encode(j).byteLength<=T).optional(),headers:W,credentialOrganizationId:w.string().uuid(),accountKey:w.string().min(1).max(256).optional()}).strict().refine((j)=>L.options.some((A)=>X(j,{baseUrl:j.baseUrl,api:A,execution:"device"})),"Invalid custom endpoint inference URL"),k=w.object({status:w.number().int().min(200).max(599),statusText:w.string().max(256).refine((j)=>!/[\r\n\0]/.test(j)),headers:w.record(w.string(),w.string().max(4096)).refine((j)=>Object.keys(j).every((A)=>["content-type","retry-after","x-request-id","request-id"].includes(A))&&Object.values(j).every((A)=>!/[\r\n\0]/.test(A)))}).strict(),y=w.union([w.object({eof:w.literal(!0)}).strict(),w.object({eof:w.literal(!1),data:w.string().max(Math.ceil(K/3)*4).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/).refine((j)=>j.length>0&&j.length*3/4-(j.endsWith("==")?2:j.endsWith("=")?1:0)<=K)}).strict()]),M=w.object({bytes:w.number().int().min(0).max(P),chunks:w.number().int().min(0).max(Q)}).strict(),p=w.object({apiKey:w.string().min(1).max(16384).refine((j)=>!/[\r\n\0]/.test(j)),api:L}).strict(),Y=["custom_endpoint_host_not_found","custom_endpoint_connection_failed","custom_endpoint_tls_failed"];function c(j){return typeof j==="string"&&Y.includes(j)}var Z="Ollama listens only on 127.0.0.1 unless it is started with OLLAMA_HOST=0.0.0.0.",G={custom_endpoint_host_not_found:"Your computer couldn't resolve your model server's hostname. Check the hostname in the Base URL, and that this computer is on the network or tailnet that resolves it.",custom_endpoint_connection_failed:`Your computer's connection to your model server was refused or timed out. Check that the server is running and listening on the Base URL's address and port. ${Z}`,custom_endpoint_tls_failed:"Your computer couldn't make a secure (TLS) connection to your model server. Check the server's https certificate, or use an http:// Base URL for a server on your computer or private network.",401:"Your model server refused the request (HTTP 401). Check the API key saved for it in Models.",403:"Your model server refused the request (HTTP 403). Ollama refuses requests addressed to a hostname other than localhost, such as a *.ts.net name from tailscale serve or funnel: restart it with OLLAMA_HOST=0.0.0.0, or use http://localhost:11434/v1 when it runs on the session's computer. For another server, check the API key and its access rules.",404:"Your model server answered HTTP 404 (not found). Check that the Base URL is the API root (for Ollama, http://localhost:11434/v1) and that each model ID is one the server lists."},q="Local custom endpoints require a session on your connected computer. This custom endpoint's Execution location is Your computer, so Reason cloud never calls it. Connect your computer with the Reason desktop app or CLI and run this session there, or set the endpoint's Execution location to Reason cloud with a public https Base URL in Models, or choose another model.";function _(j){return typeof j==="string"&&j.startsWith("Local custom endpoints require a session on your connected computer.")}var $=new Set(Object.values(G));function h(j){return Object.hasOwn(G,j)?G[j]:null}function v(j){return typeof j==="string"&&($.has(j)||_(j))}var N="returned HTTP 403: its firewall blocked Reason cloud",x=/^Your model endpoint \S+ (?:returned HTTP 40[34]|returned HTTP 403: its firewall blocked Reason cloud|was unreachable: it refused the connection)\.$/,C=/Attention Required! \| Cloudflare|Sorry, you have been blocked|cf-error-details/i;function n(j,A,B){if(!/^[a-z0-9.-]+$/i.test(j))return null;if(A==="connection_refused")return`Your model endpoint ${j} was unreachable: it refused the connection.`;if(A===403&&B&&C.test(B))return`Your model endpoint ${j} ${N}.`;return A===403||A===404?`Your model endpoint ${j} returned HTTP ${A}.`:null}function E(j){return typeof j==="string"&&x.test(j)}function d(j){return E(j)&&j.includes(N)}
2
+ import{nk as w}from"./vm-hands-entry-lite-f9akybcm.js";var S="inference.custom.v1",K=32768,P=67108864,Q=16384,T=204800,z=600000,U=["content-type","anthropic-version","user-agent"],L=w.enum(["openai-completions","openai-responses","anthropic-messages"]),V=new Set(U),W=w.record(w.string(),w.string().max(2048)).refine((j)=>Object.keys(j).every((A)=>V.has(A))&&Object.values(j).every((A)=>!/[\r\n\0]/.test(A)),"Only non-secret custom endpoint request headers are permitted");function F(j){try{let A=new URL(j);return["http:","https:"].includes(A.protocol)&&!A.username&&!A.password&&!A.search&&!A.hash?A:null}catch{return null}}function X(j,A){let B=F(j.baseUrl),H=F(A.baseUrl),D=F(j.url);if(!B||!H||!D||j.method!=="POST"||A.execution!=="device")return!1;let I=(J)=>J.origin+J.pathname.replace(/\/+$/,"");if(I(B)!==I(H)||D.origin!==B.origin)return!1;let O=A.api==="openai-completions"?"/chat/completions":A.api==="openai-responses"?"/responses":"/v1/messages";return D.pathname===B.pathname.replace(/\/+$/,"")+O}var b=w.object({baseUrl:w.string().max(2048),url:w.string().max(4096),method:w.literal("POST"),body:w.string().refine((j)=>new TextEncoder().encode(j).byteLength<=T).optional(),headers:W,credentialOrganizationId:w.string().uuid(),accountKey:w.string().min(1).max(256).optional()}).strict().refine((j)=>L.options.some((A)=>X(j,{baseUrl:j.baseUrl,api:A,execution:"device"})),"Invalid custom endpoint inference URL"),k=w.object({status:w.number().int().min(200).max(599),statusText:w.string().max(256).refine((j)=>!/[\r\n\0]/.test(j)),headers:w.record(w.string(),w.string().max(4096)).refine((j)=>Object.keys(j).every((A)=>["content-type","retry-after","x-request-id","request-id"].includes(A))&&Object.values(j).every((A)=>!/[\r\n\0]/.test(A)))}).strict(),y=w.union([w.object({eof:w.literal(!0)}).strict(),w.object({eof:w.literal(!1),data:w.string().max(Math.ceil(K/3)*4).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/).refine((j)=>j.length>0&&j.length*3/4-(j.endsWith("==")?2:j.endsWith("=")?1:0)<=K)}).strict()]),M=w.object({bytes:w.number().int().min(0).max(P),chunks:w.number().int().min(0).max(Q)}).strict(),p=w.object({apiKey:w.string().min(1).max(16384).refine((j)=>!/[\r\n\0]/.test(j)),api:L}).strict(),Y=["custom_endpoint_host_not_found","custom_endpoint_connection_failed","custom_endpoint_tls_failed"];function c(j){return typeof j==="string"&&Y.includes(j)}var Z="Ollama listens only on 127.0.0.1 unless it is started with OLLAMA_HOST=0.0.0.0.",G={custom_endpoint_host_not_found:"Your computer couldn't resolve your model server's hostname. Check the hostname in the Base URL, and that this computer is on the network or tailnet that resolves it.",custom_endpoint_connection_failed:`Your computer's connection to your model server was refused or timed out. Check that the server is running and listening on the Base URL's address and port. ${Z}`,custom_endpoint_tls_failed:"Your computer couldn't make a secure (TLS) connection to your model server. Check the server's https certificate, or use an http:// Base URL for a server on your computer or private network.",401:"Your model server refused the request (HTTP 401). Check the API key saved for it in Models.",403:"Your model server refused the request (HTTP 403). Ollama refuses requests addressed to a hostname other than localhost, such as a *.ts.net name from tailscale serve or funnel: restart it with OLLAMA_HOST=0.0.0.0, or use http://localhost:11434/v1 when it runs on the session's computer. For another server, check the API key and its access rules.",404:"Your model server answered HTTP 404 (not found). Check that the Base URL is the API root (for Ollama, http://localhost:11434/v1) and that each model ID is one the server lists."},q="Local custom endpoints require a session on your connected computer. This custom endpoint's Execution location is Your computer, so Reason cloud never calls it. Connect your computer with the Reason desktop app or CLI and run this session there, or set the endpoint's Execution location to Reason cloud with a public https Base URL in Models, or choose another model.";function _(j){return typeof j==="string"&&j.startsWith("Local custom endpoints require a session on your connected computer.")}var $=new Set(Object.values(G));function h(j){return Object.hasOwn(G,j)?G[j]:null}function v(j){return typeof j==="string"&&($.has(j)||_(j))}var N="returned HTTP 403: its firewall blocked Reason cloud",x=/^Your model endpoint \S+ (?:returned HTTP 40[34]|returned HTTP 403: its firewall blocked Reason cloud|was unreachable: it refused the connection)\.$/,C=/Attention Required! \| Cloudflare|Sorry, you have been blocked|cf-error-details/i;function n(j,A,B){if(!/^[a-z0-9.-]+$/i.test(j))return null;if(A==="connection_refused")return`Your model endpoint ${j} was unreachable: it refused the connection.`;if(A===403&&B&&C.test(B))return`Your model endpoint ${j} ${N}.`;return A===403||A===404?`Your model endpoint ${j} returned HTTP ${A}.`:null}function E(j){return typeof j==="string"&&x.test(j)}function d(j){return E(j)&&j.includes(N)}
3
3
  export{S as gd,K as hd,P as id,Q as jd,T as kd,z as ld,U as md,X as nd,b as od,k as pd,y as qd,M as rd,p as sd,Y as td,c as ud,q as vd,_ as wd,h as xd,v as yd,n as zd,E as Ad,d as Bd};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Ng as p}from"./vm-hands-entry-lite-n3y7495e.js";import{Ug as h}from"./vm-hands-entry-lite-wpcagqfw.js";import{ah as s}from"./vm-hands-entry-lite-a1yy1yp3.js";import{nj as d}from"./vm-hands-entry-lite-5x04hakp.js";import{Aj as i}from"./vm-hands-entry-lite-3nr9q3nf.js";import{Ek as P}from"./vm-hands-entry-lite-8e932j3c.js";import{Gk as V}from"./vm-hands-entry-lite-g87z5eb6.js";import{existsSync as U,realpathSync as l,statSync as e}from"fs";import{platform as f}from"os";import{isAbsolute as r,sep as zz}from"path";import{existsSync as n}from"fs";import{createRequire as t}from"module";var E=P(h)(()=>t(import.meta.url)("bun:ffi"),n);function m(){return process.platform==="win32"&&typeof globalThis.Bun<"u"&&E.available()}function w(z=process.env){return E.defaultShell(z)}function k(z){return E.shellArgs(z)}function v(z){let H=E.spawn({...z,env:z.environment});return H.exited.then(()=>H.close()),{write:(Q)=>H.write(Q),resize:(Q,J)=>H.resize(Q,J),kill:()=>H.close(),exited:H.exited}}var Hz=43200000,y=s,Jz=4,Qz=/^[A-Za-z0-9._:-]{1,160}$/,Vz=1000;function u(z){return Boolean(z)&&typeof z==="object"&&!Array.isArray(z)}function g(z,H){if(typeof z!=="number"||!Number.isFinite(z)||z<=0)return H;return Math.min(Vz,Math.max(1,Math.floor(z)))}function Zz(z,H=Date.now()){let Q=["relay_url","session_id","expires_at"],J=new Set([...Q,"cols","rows","cwd","workspace"]);if(!u(z)||Q.some((C)=>!(C in z))||Object.keys(z).some((C)=>!J.has(C)))throw new V("invalid_pty_request","Reason terminal request is malformed.");let{relay_url:N,session_id:Y,expires_at:R}=z;if(typeof N!=="string")throw new V("invalid_pty_request","Reason terminal relay URL is missing.");let K;try{K=new URL(N)}catch{throw new V("invalid_pty_request","Reason terminal relay URL is invalid.")}if(K.protocol!=="wss:"&&K.protocol!=="ws:"||K.username||K.password)throw new V("invalid_pty_request","Reason terminal relay URL is invalid.");if(typeof Y!=="string"||!Qz.test(Y))throw new V("invalid_pty_request","Reason terminal session identity is invalid.");let D=typeof R==="string"?Date.parse(R):Number.NaN;if(!Number.isFinite(D)||D<=H)throw new V("invalid_pty_request","Reason terminal session has already expired.");if(z.cwd!==void 0&&typeof z.cwd!=="string")throw new V("invalid_pty_request","Reason terminal working directory is invalid.");let j=z.workspace===void 0?void 0:i(z.workspace);if(j===null||j&&z.cwd!==void 0)throw new V("invalid_pty_request","Reason terminal workspace is invalid.");return{relay_url:N,session_id:Y,expires_at:new Date(Math.min(D,H+Hz)).toISOString(),cols:g(z.cols,80),rows:g(z.rows,24),...z.cwd===void 0?{}:{cwd:z.cwd},...j?{workspace:j}:{}}}function $z(z,H){if(f()==="win32")[z,H]=[z.toLowerCase(),H.toLowerCase()];return H===z||H.startsWith(z+zz)}function c(z,H){if(H===void 0)return z;if(!r(H))throw new V("pty_cwd_invalid","Reason terminal working directory must be absolute.");let Q;try{Q=l(H)}catch{throw new V("pty_cwd_invalid","Reason terminal working directory does not exist.")}if(!$z(z,Q))throw new V("pty_cwd_outside_root","Reason terminal working directory escapes the granted root.");if(!e(Q).isDirectory())throw new V("pty_cwd_invalid","Reason terminal working directory is not a directory.");return Q}function jz(z=process.env){if(f()==="win32")return w(z);let H=z.SHELL;if(H&&r(H)&&U(H))return H;for(let Q of f()==="darwin"?["/bin/zsh","/bin/bash","/bin/sh"]:["/bin/bash","/bin/sh"])if(U(Q))return Q;return"/bin/sh"}function Gz(){let z=globalThis.Bun;if(!z)throw new V("pty_unavailable","Reason terminals require the Bun runtime.");return z.spawn}function Sz(){if(f()==="win32")return m();return typeof globalThis.Bun<"u"}var Nz=(z)=>{if(f()==="win32")try{return v({...z,file:z.shell,args:k(z.shell),environment:{...z.environment,TERM:"xterm-256color"}})}catch{throw new V("pty_unavailable","Reason could not allocate a pseudo-terminal.")}let H=Gz()({cmd:[z.shell,"-i","-l"],cwd:z.cwd,env:{...z.environment,TERM:"xterm-256color"},terminal:{cols:z.cols,rows:z.rows,data:(J,N)=>{z.onData(N)}}}),Q=H.terminal;if(!Q){try{H.kill()}catch{}throw new V("pty_unavailable","Reason could not allocate a pseudo-terminal.")}return{write:(J)=>Q.write(J),resize:(J,N)=>Q.resize(J,N),kill:()=>{try{H.kill()}catch{}},exited:H.exited.then((J)=>typeof J==="number"?J:null,()=>null)}},Wz=(z,H)=>{return H===void 0?new WebSocket(z):new WebSocket(z,{proxy:H})},M=new Set;function Kz(z){if(M.size>=Jz||M.has(z))return null;M.add(z);let H=!1;return()=>{if(H)return;H=!0,M.delete(z)}}async function Tz(z,H={}){let Q=H.now??Date.now,J=Zz(z.payload,Q()),N=Kz(z.operationId);if(!N)throw new V("pty_slot_busy","This Reason Device already runs the maximum number of terminals.");let Y=Q(),R,K,D;try{let j=J.workspace?d(z.root,J.workspace):void 0;R=j?c(U(j.boundary)?l(j.boundary):j.boundary,j.path):c(z.root,J.cwd),K=H.environment??process.env,D=H.shellPath??jz(K)}catch(j){throw N(),j}return await new Promise((j,C)=>{let F=null,$=null,I=!1,B=!1,X=!1,_=null,b=0,x=0,O=[],S=0,T=null,G=(Z)=>{if(X)return;if(X=!0,T)clearTimeout(T);z.signal.removeEventListener("abort",A);try{F?.kill()}catch{}try{$?.close(1000,"pty_session_over")}catch{}if(N(),Z.kind==="rejected"){C(Z.error);return}let W={reason:Z.reason,exit_code:_,output_bytes:b,input_bytes:x,duration_ms:Math.max(0,Q()-Y)};z.emitEvent("pty.stopped",{...W}).catch(()=>{return}),j({...W})},A=()=>{let Z=z.signal.reason;G({kind:"rejected",error:Z instanceof V?Z:new V("cancelled","Reason closed the terminal session.")})};if(z.signal.aborted){A();return}z.signal.addEventListener("abort",A,{once:!0}),T=setTimeout(()=>G({kind:"resolved",reason:"session_expired"}),Math.max(1,Date.parse(J.expires_at)-Q()));let a=(Z)=>{if(b+=Z.byteLength,!I||!$){if(O.push(Z),S+=Z.byteLength,S>y)G({kind:"resolved",reason:"output_backpressure"});return}try{$.send(Z)}catch{G({kind:"resolved",reason:"relay_closed"});return}if($.bufferedAmount>y)G({kind:"resolved",reason:"output_backpressure"})};try{F=(H.spawnPty??Nz)({shell:D,args:["-i","-l"],cwd:R,cols:J.cols,rows:J.rows,environment:K,onData:(Z)=>{if(!X)a(Z)}})}catch(Z){G({kind:"rejected",error:Z instanceof V?Z:new V("pty_spawn_failed","Reason could not start the terminal shell.")});return}F.exited.then((Z)=>{if(X)return;if(_=Z,I&&$)try{$.send(JSON.stringify({t:"exit",code:Z}))}catch{}G({kind:"resolved",reason:"shell_exited"})});let o=(H.loadProxy??p)()?.url;try{$=(H.connect??Wz)(J.relay_url,o)}catch{G({kind:"rejected",error:new V("pty_relay_unavailable","Reason could not reach the terminal relay.")});return}$.binaryType="arraybuffer",$.onopen=()=>{if(X||!$)return;I=!0;try{$.send(JSON.stringify({t:"open",cols:J.cols,rows:J.rows}));for(let Z of O.splice(0))$.send(Z);S=0}catch{G({kind:"resolved",reason:"relay_closed"});return}B=!0,z.emitEvent("pty.ready",{session_id:J.session_id,cols:J.cols,rows:J.rows}).catch(()=>{return})},$.onmessage=(Z)=>{if(X||!F)return;let W=Z.data;if(typeof W==="string"){let L;try{L=JSON.parse(W)}catch{return}if(!u(L))return;if(L.t==="resize"){try{F.resize(g(L.cols,J.cols),g(L.rows,J.rows))}catch{}return}if(L.t==="close")G({kind:"resolved",reason:"client_closed"});return}let q=W instanceof ArrayBuffer?new Uint8Array(W):ArrayBuffer.isView(W)?new Uint8Array(W.buffer,W.byteOffset,W.byteLength):null;if(!q||q.byteLength===0)return;x+=q.byteLength;try{F.write(q)}catch{}},$.onclose=()=>{if(X)return;if(!B){G({kind:"rejected",error:new V("pty_relay_unavailable","Reason could not reach the terminal relay.")});return}G({kind:"resolved",reason:"relay_closed"})},$.onerror=()=>{if(X||B)return;G({kind:"rejected",error:new V("pty_relay_unavailable","Reason could not reach the terminal relay.")})}})}
3
- export{m as ng,Hz as og,y as pg,Jz as qg,Zz as rg,c as sg,jz as tg,Sz as ug,Nz as vg,Wz as wg,Tz as xg};
2
+ import{Rg as p}from"./vm-hands-entry-lite-ps9gjbs5.js";import{Yg as h}from"./vm-hands-entry-lite-vqfpryez.js";import{eh as s}from"./vm-hands-entry-lite-1cs1jy20.js";import{rj as d}from"./vm-hands-entry-lite-2sx1a43v.js";import{Ej as i}from"./vm-hands-entry-lite-29f3m7x2.js";import{Ik as P}from"./vm-hands-entry-lite-bgs4zjkf.js";import{Kk as V}from"./vm-hands-entry-lite-69n9q5f1.js";import{existsSync as U,realpathSync as l,statSync as e}from"fs";import{platform as f}from"os";import{isAbsolute as r,sep as zz}from"path";import{existsSync as n}from"fs";import{createRequire as t}from"module";var E=P(h)(()=>t(import.meta.url)("bun:ffi"),n);function m(){return process.platform==="win32"&&typeof globalThis.Bun<"u"&&E.available()}function w(z=process.env){return E.defaultShell(z)}function k(z){return E.shellArgs(z)}function v(z){let H=E.spawn({...z,env:z.environment});return H.exited.then(()=>H.close()),{write:(Q)=>H.write(Q),resize:(Q,J)=>H.resize(Q,J),kill:()=>H.close(),exited:H.exited}}var Hz=43200000,y=s,Jz=4,Qz=/^[A-Za-z0-9._:-]{1,160}$/,Vz=1000;function u(z){return Boolean(z)&&typeof z==="object"&&!Array.isArray(z)}function g(z,H){if(typeof z!=="number"||!Number.isFinite(z)||z<=0)return H;return Math.min(Vz,Math.max(1,Math.floor(z)))}function Zz(z,H=Date.now()){let Q=["relay_url","session_id","expires_at"],J=new Set([...Q,"cols","rows","cwd","workspace"]);if(!u(z)||Q.some((C)=>!(C in z))||Object.keys(z).some((C)=>!J.has(C)))throw new V("invalid_pty_request","Reason terminal request is malformed.");let{relay_url:N,session_id:Y,expires_at:R}=z;if(typeof N!=="string")throw new V("invalid_pty_request","Reason terminal relay URL is missing.");let K;try{K=new URL(N)}catch{throw new V("invalid_pty_request","Reason terminal relay URL is invalid.")}if(K.protocol!=="wss:"&&K.protocol!=="ws:"||K.username||K.password)throw new V("invalid_pty_request","Reason terminal relay URL is invalid.");if(typeof Y!=="string"||!Qz.test(Y))throw new V("invalid_pty_request","Reason terminal session identity is invalid.");let D=typeof R==="string"?Date.parse(R):Number.NaN;if(!Number.isFinite(D)||D<=H)throw new V("invalid_pty_request","Reason terminal session has already expired.");if(z.cwd!==void 0&&typeof z.cwd!=="string")throw new V("invalid_pty_request","Reason terminal working directory is invalid.");let j=z.workspace===void 0?void 0:i(z.workspace);if(j===null||j&&z.cwd!==void 0)throw new V("invalid_pty_request","Reason terminal workspace is invalid.");return{relay_url:N,session_id:Y,expires_at:new Date(Math.min(D,H+Hz)).toISOString(),cols:g(z.cols,80),rows:g(z.rows,24),...z.cwd===void 0?{}:{cwd:z.cwd},...j?{workspace:j}:{}}}function $z(z,H){if(f()==="win32")[z,H]=[z.toLowerCase(),H.toLowerCase()];return H===z||H.startsWith(z+zz)}function c(z,H){if(H===void 0)return z;if(!r(H))throw new V("pty_cwd_invalid","Reason terminal working directory must be absolute.");let Q;try{Q=l(H)}catch{throw new V("pty_cwd_invalid","Reason terminal working directory does not exist.")}if(!$z(z,Q))throw new V("pty_cwd_outside_root","Reason terminal working directory escapes the granted root.");if(!e(Q).isDirectory())throw new V("pty_cwd_invalid","Reason terminal working directory is not a directory.");return Q}function jz(z=process.env){if(f()==="win32")return w(z);let H=z.SHELL;if(H&&r(H)&&U(H))return H;for(let Q of f()==="darwin"?["/bin/zsh","/bin/bash","/bin/sh"]:["/bin/bash","/bin/sh"])if(U(Q))return Q;return"/bin/sh"}function Gz(){let z=globalThis.Bun;if(!z)throw new V("pty_unavailable","Reason terminals require the Bun runtime.");return z.spawn}function Sz(){if(f()==="win32")return m();return typeof globalThis.Bun<"u"}var Nz=(z)=>{if(f()==="win32")try{return v({...z,file:z.shell,args:k(z.shell),environment:{...z.environment,TERM:"xterm-256color"}})}catch{throw new V("pty_unavailable","Reason could not allocate a pseudo-terminal.")}let H=Gz()({cmd:[z.shell,"-i","-l"],cwd:z.cwd,env:{...z.environment,TERM:"xterm-256color"},terminal:{cols:z.cols,rows:z.rows,data:(J,N)=>{z.onData(N)}}}),Q=H.terminal;if(!Q){try{H.kill()}catch{}throw new V("pty_unavailable","Reason could not allocate a pseudo-terminal.")}return{write:(J)=>Q.write(J),resize:(J,N)=>Q.resize(J,N),kill:()=>{try{H.kill()}catch{}},exited:H.exited.then((J)=>typeof J==="number"?J:null,()=>null)}},Wz=(z,H)=>{return H===void 0?new WebSocket(z):new WebSocket(z,{proxy:H})},M=new Set;function Kz(z){if(M.size>=Jz||M.has(z))return null;M.add(z);let H=!1;return()=>{if(H)return;H=!0,M.delete(z)}}async function Tz(z,H={}){let Q=H.now??Date.now,J=Zz(z.payload,Q()),N=Kz(z.operationId);if(!N)throw new V("pty_slot_busy","This Reason Device already runs the maximum number of terminals.");let Y=Q(),R,K,D;try{let j=J.workspace?d(z.root,J.workspace):void 0;R=j?c(U(j.boundary)?l(j.boundary):j.boundary,j.path):c(z.root,J.cwd),K=H.environment??process.env,D=H.shellPath??jz(K)}catch(j){throw N(),j}return await new Promise((j,C)=>{let F=null,$=null,I=!1,B=!1,X=!1,_=null,b=0,x=0,O=[],S=0,T=null,G=(Z)=>{if(X)return;if(X=!0,T)clearTimeout(T);z.signal.removeEventListener("abort",A);try{F?.kill()}catch{}try{$?.close(1000,"pty_session_over")}catch{}if(N(),Z.kind==="rejected"){C(Z.error);return}let W={reason:Z.reason,exit_code:_,output_bytes:b,input_bytes:x,duration_ms:Math.max(0,Q()-Y)};z.emitEvent("pty.stopped",{...W}).catch(()=>{return}),j({...W})},A=()=>{let Z=z.signal.reason;G({kind:"rejected",error:Z instanceof V?Z:new V("cancelled","Reason closed the terminal session.")})};if(z.signal.aborted){A();return}z.signal.addEventListener("abort",A,{once:!0}),T=setTimeout(()=>G({kind:"resolved",reason:"session_expired"}),Math.max(1,Date.parse(J.expires_at)-Q()));let a=(Z)=>{if(b+=Z.byteLength,!I||!$){if(O.push(Z),S+=Z.byteLength,S>y)G({kind:"resolved",reason:"output_backpressure"});return}try{$.send(Z)}catch{G({kind:"resolved",reason:"relay_closed"});return}if($.bufferedAmount>y)G({kind:"resolved",reason:"output_backpressure"})};try{F=(H.spawnPty??Nz)({shell:D,args:["-i","-l"],cwd:R,cols:J.cols,rows:J.rows,environment:K,onData:(Z)=>{if(!X)a(Z)}})}catch(Z){G({kind:"rejected",error:Z instanceof V?Z:new V("pty_spawn_failed","Reason could not start the terminal shell.")});return}F.exited.then((Z)=>{if(X)return;if(_=Z,I&&$)try{$.send(JSON.stringify({t:"exit",code:Z}))}catch{}G({kind:"resolved",reason:"shell_exited"})});let o=(H.loadProxy??p)()?.url;try{$=(H.connect??Wz)(J.relay_url,o)}catch{G({kind:"rejected",error:new V("pty_relay_unavailable","Reason could not reach the terminal relay.")});return}$.binaryType="arraybuffer",$.onopen=()=>{if(X||!$)return;I=!0;try{$.send(JSON.stringify({t:"open",cols:J.cols,rows:J.rows}));for(let Z of O.splice(0))$.send(Z);S=0}catch{G({kind:"resolved",reason:"relay_closed"});return}B=!0,z.emitEvent("pty.ready",{session_id:J.session_id,cols:J.cols,rows:J.rows}).catch(()=>{return})},$.onmessage=(Z)=>{if(X||!F)return;let W=Z.data;if(typeof W==="string"){let L;try{L=JSON.parse(W)}catch{return}if(!u(L))return;if(L.t==="resize"){try{F.resize(g(L.cols,J.cols),g(L.rows,J.rows))}catch{}return}if(L.t==="close")G({kind:"resolved",reason:"client_closed"});return}let q=W instanceof ArrayBuffer?new Uint8Array(W):ArrayBuffer.isView(W)?new Uint8Array(W.buffer,W.byteOffset,W.byteLength):null;if(!q||q.byteLength===0)return;x+=q.byteLength;try{F.write(q)}catch{}},$.onclose=()=>{if(X)return;if(!B){G({kind:"rejected",error:new V("pty_relay_unavailable","Reason could not reach the terminal relay.")});return}G({kind:"resolved",reason:"relay_closed"})},$.onerror=()=>{if(X||B)return;G({kind:"rejected",error:new V("pty_relay_unavailable","Reason could not reach the terminal relay.")})}})}
3
+ export{m as rg,Hz as sg,y as tg,Jz as ug,Zz as vg,c as wg,jz as xg,Sz as yg,Nz as zg,Wz as Ag,Tz as Bg};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Hc as n}from"./vm-hands-entry-lite-h0keewxv.js";import{dd as r}from"./vm-hands-entry-lite-g7h6wjqy.js";import{tk as a,uk as s,xk as i}from"./vm-hands-entry-lite-fb02h1zm.js";import{Gk as B}from"./vm-hands-entry-lite-g87z5eb6.js";import{spawn as f,spawnSync as v}from"child_process";import{existsSync as U,mkdtempSync as o,readFileSync as t,readdirSync as _j,realpathSync as Sj,rmSync as e,statSync as jj}from"fs";import{platform as h,tmpdir as qj}from"os";import{dirname as E,join as H,win32 as T}from"path";import{fileURLToPath as Mj,pathToFileURL as y}from"url";var kj=["bwrap","socat","rg"],Fj=2000,g=20000,Pj=3,w=4000,Ej=new Set([".git",".hg",".svn","node_modules"]),Rj=["runAsHostUid","sysrq-trigger"],zj=H(E(E(Mj(import.meta.url))),"packages","sandbox-runtime"),Dj=H(zj,"src","index.ts"),Gj=!1;function oj(){Gj=!0}function Jj(){return Gj?H(E(Sj(process.execPath)),"runtime","srt"):void 0}function C(){let j=H(Jj()??zj,"vendor","srt-win"),q=H(j,process.arch,"srt-win.exe"),G=H(j,"arm64","srt-win.exe");return process.arch==="x64"&&!U(q)&&U(G)?G:q}var tj="confined commands need the Windows sandbox: run `reason connect` and approve the Windows prompt.";function ej(j=C()){let q=v(j,["status"],{encoding:"utf8",timeout:15000,windowsHide:!0});try{let G=JSON.parse(q.stdout??"");return q.status===0&&G.user?.user?.exists===!0&&G.user.cred_present===!0}catch{return!1}}function jq(j=C()){let q=v(j,["install"],{stdio:["ignore","ignore","ignore"],timeout:120000,windowsHide:!0});return q.status===0?"installed":q.status===10?"cancelled":"failed"}async function Kj(){let j=Jj();if(j&&process.platform==="linux"&&!U(H(j,"vendor","seccomp",process.arch,"apply-seccomp")))throw Error("packaged_sandbox_runtime_vendor_missing");if(j&&process.platform==="win32"&&!U(C()))throw Error("packaged_sandbox_runtime_vendor_missing");if(j){let J=t(H(j,"sandbox-runtime.mjs"),"utf8");for(let K of Rj)if(!J.includes(K))throw Error(`packaged_sandbox_runtime_fork_missing:${K}`)}let z=(await import(j?y(H(j,"sandbox-runtime.mjs")).href:y(Dj).href)).SandboxManager;if(!z||typeof z.initialize!=="function"||typeof z.wrapWithSandboxArgv!=="function")throw Error("sandbox-runtime does not expose the expected SandboxManager API.");return{SandboxManager:z}}function Wj(j={}){if((j.platformName??h())!=="linux")return!1;let G=j.fileExists??U,z=j.readFile??((J)=>t(J,"utf8"));for(let J of["/.dockerenv","/run/.containerenv"])try{if(G(J))return!0}catch{}try{return/docker|containerd|kubepods|lxc|libpod/.test(z("/proc/1/cgroup"))}catch{return!1}}function Qj(j){return["/bin/true","/usr/bin/true"].find((q)=>j(q))??null}function xj(j,q){return j==="strict"?["--ro-bind","/","/","--unshare-pid","--unshare-user","--cap-drop","ALL","--proc","/proc","--",q]:["--ro-bind","/","/","--unshare-pid","--unshare-user","--bind","/proc","/proc","--",q]}function Oj(j,q){try{let G=v("bwrap",xj(j,q),{stdio:"ignore",timeout:Fj});return!G.error&&G.status===0}catch{return!1}}function fj(j){let q=j.platformName??h(),G=j.fileExists??U;if(q==="win32")return(j.bash??a)()&&G(C())?X??"strict":null;if(q!=="linux")return null;let z=j.hasExecutable??r;if(!kj.every((V)=>z(V)))return null;let J=Qj(G);if(!J)return null;let K=X??(j.containerized??Wj({platformName:q})?"weak":"strict");return(j.probeNamespaces??((V)=>Oj(V,J)))(K)?K:null}var _=null,R=!1,Y=null,c=null,u=null,X=null,S=null,P=null,M=null,D=[],N=new Map;function W(){throw A("sandbox_mode_conflict"),new B("sandbox_unavailable","Sandbox process policy conflicts with an existing probe or session. Restart the worker.")}function qq(j){if(X!==null&&X!==j||R&&_!==null&&_!==j||S!==null&&S!==j)W();X=j}function A(j){if(!Y)process.stderr.write(`Reason worker: confined commands are off (${j})
2
+ import{Hc as n}from"./vm-hands-entry-lite-e99ftdr6.js";import{dd as r}from"./vm-hands-entry-lite-g7h6wjqy.js";import{Bk as i,xk as a,yk as s}from"./vm-hands-entry-lite-ek5r435m.js";import{Kk as B}from"./vm-hands-entry-lite-69n9q5f1.js";import{spawn as f,spawnSync as v}from"child_process";import{existsSync as U,mkdtempSync as o,readFileSync as t,readdirSync as _j,realpathSync as Sj,rmSync as e,statSync as jj}from"fs";import{platform as h,tmpdir as qj}from"os";import{dirname as E,join as H,win32 as T}from"path";import{fileURLToPath as Mj,pathToFileURL as y}from"url";var kj=["bwrap","socat","rg"],Fj=2000,g=20000,Pj=3,w=4000,Ej=new Set([".git",".hg",".svn","node_modules"]),Rj=["runAsHostUid","sysrq-trigger"],zj=H(E(E(Mj(import.meta.url))),"packages","sandbox-runtime"),Dj=H(zj,"src","index.ts"),Gj=!1;function oj(){Gj=!0}function Jj(){return Gj?H(E(Sj(process.execPath)),"runtime","srt"):void 0}function C(){let j=H(Jj()??zj,"vendor","srt-win"),q=H(j,process.arch,"srt-win.exe"),G=H(j,"arm64","srt-win.exe");return process.arch==="x64"&&!U(q)&&U(G)?G:q}var tj="confined commands need the Windows sandbox: run `reason connect` and approve the Windows prompt.";function ej(j=C()){let q=v(j,["status"],{encoding:"utf8",timeout:15000,windowsHide:!0});try{let G=JSON.parse(q.stdout??"");return q.status===0&&G.user?.user?.exists===!0&&G.user.cred_present===!0}catch{return!1}}function jq(j=C()){let q=v(j,["install"],{stdio:["ignore","ignore","ignore"],timeout:120000,windowsHide:!0});return q.status===0?"installed":q.status===10?"cancelled":"failed"}async function Kj(){let j=Jj();if(j&&process.platform==="linux"&&!U(H(j,"vendor","seccomp",process.arch,"apply-seccomp")))throw Error("packaged_sandbox_runtime_vendor_missing");if(j&&process.platform==="win32"&&!U(C()))throw Error("packaged_sandbox_runtime_vendor_missing");if(j){let J=t(H(j,"sandbox-runtime.mjs"),"utf8");for(let K of Rj)if(!J.includes(K))throw Error(`packaged_sandbox_runtime_fork_missing:${K}`)}let z=(await import(j?y(H(j,"sandbox-runtime.mjs")).href:y(Dj).href)).SandboxManager;if(!z||typeof z.initialize!=="function"||typeof z.wrapWithSandboxArgv!=="function")throw Error("sandbox-runtime does not expose the expected SandboxManager API.");return{SandboxManager:z}}function Wj(j={}){if((j.platformName??h())!=="linux")return!1;let G=j.fileExists??U,z=j.readFile??((J)=>t(J,"utf8"));for(let J of["/.dockerenv","/run/.containerenv"])try{if(G(J))return!0}catch{}try{return/docker|containerd|kubepods|lxc|libpod/.test(z("/proc/1/cgroup"))}catch{return!1}}function Qj(j){return["/bin/true","/usr/bin/true"].find((q)=>j(q))??null}function xj(j,q){return j==="strict"?["--ro-bind","/","/","--unshare-pid","--unshare-user","--cap-drop","ALL","--proc","/proc","--",q]:["--ro-bind","/","/","--unshare-pid","--unshare-user","--bind","/proc","/proc","--",q]}function Oj(j,q){try{let G=v("bwrap",xj(j,q),{stdio:"ignore",timeout:Fj});return!G.error&&G.status===0}catch{return!1}}function fj(j){let q=j.platformName??h(),G=j.fileExists??U;if(q==="win32")return(j.bash??a)()&&G(C())?X??"strict":null;if(q!=="linux")return null;let z=j.hasExecutable??r;if(!kj.every((V)=>z(V)))return null;let J=Qj(G);if(!J)return null;let K=X??(j.containerized??Wj({platformName:q})?"weak":"strict");return(j.probeNamespaces??((V)=>Oj(V,J)))(K)?K:null}var _=null,R=!1,Y=null,c=null,u=null,X=null,S=null,P=null,M=null,D=[],N=new Map;function W(){throw A("sandbox_mode_conflict"),new B("sandbox_unavailable","Sandbox process policy conflicts with an existing probe or session. Restart the worker.")}function qq(j){if(X!==null&&X!==j||R&&_!==null&&_!==j||S!==null&&S!==j)W();X=j}function A(j){if(!Y)process.stderr.write(`Reason worker: confined commands are off (${j})
3
3
  `);Y=j}function Vj(j){if(Y)return!1;if(!R){if(_=fj(j??{}),R=!0,_&&!j)Yj()}return _!==null}function vj(){return Vj()?_:null}var k=null,I=0;function x(j,q){if(Y)throw new B("sandbox_unavailable","Confined execution is unavailable in this worker process.");if(X&&j.sandboxMode&&X!==j.sandboxMode)W();let G=X??j.sandboxMode??vj();if(!G)throw new B("sandbox_unavailable","Confined command execution is unavailable on this operating system.");if(S&&S!==G)W();return S=G,k??=(async()=>{let{SandboxManager:z}=await(j.loadSandboxRuntime??Kj)();return await z.initialize(uj(G,q)),z})().catch((z)=>{if(k=null,q)P=null,process.stderr.write(`Reason worker: the Windows sandbox did not start for this folder (${String(z).slice(0,500)})
4
4
  `);else A(`initialize_failed: ${String(z)}`);throw z instanceof B?z:new B("sandbox_unavailable","The confined execution sandbox failed to start.")}),k.then((z)=>{if(Y)throw new B("sandbox_unavailable","Confined execution became unavailable during sandbox initialization.");return z})}function O(){if(I-=1,I===0)for(let j of D.splice(0))j()}async function Zj(j,q=!0,G,z){let J=z===void 0?1/0:Date.now()+z;await Bj();let K=bj();if(q)await K;let Q=JSON.stringify(j),V=!1,$=()=>{if(!V)return;V=!1;let Z=(N.get(Q)??1)-1;if(Z>0)N.set(Q,Z);else N.delete(Q)};try{for(;;){if(G?.aborted)throw new B("cancelled","Operation was cancelled.");if(Date.now()>=J)return!1;if(M){await M;continue}let Z=N.keys().next().value;if(P??=Z??Q,P===Q&&(Z===void 0||Z===Q))break;if(!V){V=!0,N.set(Q,(N.get(Q)??0)+1);continue}if(I===0&&Z===Q){$j();continue}await new Promise((L)=>{if(D.push(L),G?.addEventListener("abort",()=>L(),{once:!0}),J!==1/0)setTimeout(L,Math.max(0,J-Date.now())).unref?.()})}return I+=1,!0}finally{if(V&&I===0)for(let Z of D.splice(0))Z();$()}}function $j(){return M??=Xj().finally(()=>{M=null}),M}function Hj(j,q,G=process.env){let z=G.USERPROFILE?T.resolve(G.USERPROFILE).toLowerCase():null,J=T.resolve(j).toLowerCase(),K=z!==null&&J.startsWith(`${z}\\`),Q=q?Lj(G).filter((V)=>V.toLowerCase()===J||V.toLowerCase().startsWith(`${J}\\`)):[];return{denyRead:[],allowRead:[j],allowWrite:q?[j]:[],denyWrite:q?Q:K?[]:[j]}}function Lj(j,q=process.execPath){let G=new Map;for(let z of[...(j.PATH??j.Path??"").split(";"),T.dirname(q)]){if(!z||!T.isAbsolute(z))continue;let J=T.resolve(z);if(!G.has(J.toLowerCase()))G.set(J.toLowerCase(),J)}return[...G.values()]}function hj(j=process.env,q=process.execPath){let G=[j.SystemRoot,j.ProgramFiles,j["ProgramFiles(x86)"],j.ProgramW6432,j.ProgramData,j.USERPROFILE].filter((z)=>!!z).map((z)=>T.resolve(z).toLowerCase());return Lj(j,q).filter((z)=>{let J=z.toLowerCase();return!G.some((K)=>J===K||J.startsWith(`${K}\\`))})}var l=null,m=null;function Bj(j=C()){return m??=(async()=>{let q;try{q=JSON.parse((await Uj(j,["status"])).stdout).user?.user?.sid}catch{return null}if(typeof q!=="string"||!/^S-1-[0-9-]+$/.test(q))return null;if(!await new Promise((z)=>{let J=f(i("icacls"),[j,"/grant",`*${q}:(RX)`],{stdio:"ignore",windowsHide:!0,timeout:30000});J.on("error",()=>z(!1)),J.on("close",(K)=>z(K===0))}))process.stderr.write(`Reason worker: could not let the Windows sandbox user run srt-win.exe
5
5
  `);return q})(),m}function Uj(j,q,G){return new Promise((z)=>{let J=f(j,q,{stdio:["pipe","pipe","ignore"],windowsHide:!0,timeout:120000}),K="";J.stdout?.setEncoding("utf8").on("data",(Q)=>{K+=Q}),J.on("error",()=>z({status:null,stdout:K})),J.on("close",(Q)=>z({status:Q,stdout:K})),J.stdin?.end(G??"")})}function bj(j=C()){return l??=(async()=>{let q=hj();if(q.length===0)return;let G=await Bj(j),z=G?await Uj(j,["acl","stamp","--holder-pid",String(process.ppid),"--sandbox-user-sid",G],JSON.stringify({denyRead:[],denyWrite:q})):null;if(!z||z.status!==0&&z.status!==2)A(`program_folder_deny_failed: ${z?`exit ${z.status}`:"no sandbox user"}`),process.stderr.write(`Reason worker: could not deny the Windows sandbox writes to PATH folders (${z?`exit ${z.status}`:"no sandbox user"}); confined commands are off
@@ -242,4 +242,4 @@ var e=String.raw`(function(loadFfi, existsSync) {
242
242
  }
243
243
  return { available, unavailableReason, defaultShell, shellArgs, quoteArg, environmentBlock, spawn };
244
244
  })`;
245
- export{e as Ug};
245
+ export{e as Yg};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Hc as pZ,Ic as uZ,Jc as C4,Kc as T4,Lc as M8,Mc as lZ}from"./vm-hands-entry-lite-h0keewxv.js";import{Nc as fZ,Oc as H8,Pc as t9,Qc as _0,Rc as M9,Sc as a0,Zc as K0}from"./vm-hands-entry-lite-r166b92s.js";import{ad as B8,bd as W8,cd as aQ}from"./vm-hands-entry-lite-180h5amj.js";import{De as MZ,jf as f9,kf as t0,lf as T8,mf as m0,qf as C0,ye as NZ}from"./vm-hands-entry-lite-02zaqpgh.js";import{Gg as aZ,Mg as $8,Ng as s8}from"./vm-hands-entry-lite-n3y7495e.js";import{Sg as j4}from"./vm-hands-entry-lite-hfv2tsm9.js";import{Ah as w0,Bh as O0,Ch as o9,Jh as d8,Kh as TZ,Lh as HZ,Vg as SQ,Yg as N9,fh as jZ,gh as qZ,ih as CZ,kh as i9,lh as FZ,mh as VZ,nh as h8,qh as a9,zh as g8}from"./vm-hands-entry-lite-a1yy1yp3.js";import{ui as rZ,vi as a8}from"./vm-hands-entry-lite-csecgmaa.js";import{Wi as b0}from"./vm-hands-entry-lite-mft9ke08.js";import{mj as _8,nj as r9,qj as M4}from"./vm-hands-entry-lite-5x04hakp.js";import{Aj as KZ,Lj as A$,rj as O8,sj as o0,tj as D8,uj as r0,vj as W9,wj as V8,xj as H$,yj as i0,zj as u0}from"./vm-hands-entry-lite-3nr9q3nf.js";import{Qj as TQ}from"./vm-hands-entry-lite-nnmhnxqs.js";import{jk as x}from"./vm-hands-entry-lite-8pgggvbb.js";import{pk as q4}from"./vm-hands-entry-lite-p1s0xyc2.js";import{Bk as N4,Ck as J9,sk as L4,uk as e9,vk as OZ,wk as d$,xk as DZ,yk as d9}from"./vm-hands-entry-lite-fb02h1zm.js";import{Gk as q}from"./vm-hands-entry-lite-g87z5eb6.js";import{Hk as u1,Mk as qQ}from"./vm-hands-entry-lite-f78n4wqt.js";import{execFile as b4}from"child_process";import{createRequire as k4}from"module";import{win32 as p9}from"path";var f4=250,m4=50,y4=250,g4=4194304;function v$($){let Z=/^(?:\[([^\]]+)\]|([^:]+)):([0-9]{1,5})$/.exec($??""),Q=Number(Z?.[3]);return Z&&Q<=65535?{address:Z[1]??Z[2],port:Q}:null}function h4($){let Z=[];for(let Q of $.split(/\r?\n/)){let X=Q.trim().split(/\s+/);if(X[0]!=="TCP"||X.length<5)continue;let J=v$(X[1]),Y=v$(X[2]),z=Number(X.at(-1));if(!J||!Y||!Number.isSafeInteger(z)||z<0)continue;Z.push({pid:z,localAddress:J.address,localPort:J.port,remoteAddress:Y.address,remotePort:Y.port,listening:Y.port===0})}return Z}function v4($){if($.localAddress==="0.0.0.0"||$.localAddress==="::")return`*:${$.localPort}`;return $.localAddress.includes(":")?`[${$.localAddress}]:${$.localPort}`:`${$.localAddress}:${$.localPort}`}var S8=($)=>new Promise((Z,Q)=>b4(p9.join(d$("win32").split(";")[0],"NETSTAT.EXE"),["-ano"],{timeout:$,maxBuffer:g4,encoding:"utf8",windowsHide:!0,env:d9()},(X,J)=>X?Q(X):Z(J)));function O9($){let Z=p9.normalize($.startsWith("\\\\?\\")?$.slice(4):$);return Z.length>3&&Z.endsWith("\\")?Z.slice(0,-1):Z}function c4($,Z){let Q=$.toLowerCase(),X=Z.toLowerCase();return X===Q||X.startsWith(Q.endsWith("\\")?Q:`${Q}\\`)}function p$($,Z,Q){let X=$.cwd(Q),J=X?O9(X):null;return J&&p9.isAbsolute(J)&&c4(Z,J)?J:null}var T9;function u9(){if(T9!==void 0)return T9;if(T9=null,process.platform!=="win32"||!["x64","arm64"].includes(process.arch))return null;let $;try{$=k4(import.meta.url)("bun:ffi")}catch{return null}let{FFIType:Z,ptr:Q}=$,X,J;try{X=$.dlopen("kernel32.dll",{CreateToolhelp32Snapshot:{args:[Z.u32,Z.u32],returns:Z.u64},Process32FirstW:{args:[Z.u64,Z.ptr],returns:Z.i32},Process32NextW:{args:[Z.u64,Z.ptr],returns:Z.i32},OpenProcess:{args:[Z.u32,Z.i32,Z.u32],returns:Z.u64},ReadProcessMemory:{args:[Z.u64,Z.u64,Z.ptr,Z.u64,Z.ptr],returns:Z.i32},CloseHandle:{args:[Z.u64],returns:Z.i32}}).symbols,J=$.dlopen("ntdll.dll",{NtQueryInformationProcess:{args:[Z.u64,Z.i32,Z.ptr,Z.u32,Z.ptr],returns:Z.i32}}).symbols}catch{return null}let Y=0xFFFF_FFFF_FFFF_FFFFn,z=2,F=1040,G=568,V=(B,H,K)=>{let L=Buffer.alloc(K);return X.ReadProcessMemory(B,H,Q(L),K,null)?L:null};return T9={processes(){let B=BigInt(X.CreateToolhelp32Snapshot(z,0));if(B===Y)throw new q("process_inspection_failed","Reading this computer's processes did not complete.");try{let H=Buffer.alloc(G);H.writeUInt32LE(G,0);let K=Q(H),L=[];for(let W=X.Process32FirstW(B,K);W;W=X.Process32NextW(B,K)){let U=H.toString("utf16le",44,G),j=U.slice(0,U.includes("\x00")?U.indexOf("\x00"):void 0),O=H.readUInt32LE(8);if(O>0)L.push({pid:O,parentPid:H.readUInt32LE(32),command:j.replace(/\.exe$/i,"")||null})}return L}finally{X.CloseHandle(B)}},cwd(B){let H=BigInt(X.OpenProcess(F,0,B));if(H===0n)return null;try{let K=Buffer.alloc(48);if(J.NtQueryInformationProcess(H,0,Q(K),K.length,null)!==0)return null;let L=V(H,K.readBigUInt64LE(8)+0x20n,8)?.readBigUInt64LE(0),W=L?V(H,L+0x38n,16):null,U=W?.readUInt16LE(0)??0;if(!W||U===0||U%2!==0)return null;return V(H,W.readBigUInt64LE(8),U)?.toString("utf16le")??null}finally{X.CloseHandle(H)}}},T9}function w8($){if(!$)throw new q("process_inspection_failed","Reading this computer's processes is unavailable.");return $}async function u$($,Z){let Q;try{Q=await $(Z)}catch{throw new q("process_inspection_failed","Reading this computer's ports did not complete.")}return h4(Q)}async function O2($,Z=u9()){let Q=w8(Z),X=O9($),J=[];for(let Y of Q.processes()){if(J.length>=f4)break;let z=p$(Q,X,Y.pid);if(z)J.push({pid:Y.pid,command:Y.command,cwd:p9.relative(X,z)||"."})}return{processes:J}}async function D2($,Z=u9(),Q=S8){let X=w8(Z),J=O9($),Y=(await u$(Q,5000)).filter((V)=>V.listening&&V.pid>0).map((V)=>({pid:V.pid,port:V.localPort,address:v4(V)})).sort((V,B)=>V.pid-B.pid||V.port-B.port||(V.address<B.address?-1:V.address>B.address?1:0)),z=[...new Set(Y.map((V)=>V.pid))].slice(0,m4),F=new Set(z.filter((V)=>p$(X,J,V)!==null));if(F.size===0)return{ports:[]};let G=new Map(X.processes().map((V)=>[V.pid,V.command]));return{ports:Y.filter((V)=>F.has(V.pid)).slice(0,y4).map((V)=>({pid:V.pid,command:G.get(V.pid)??null,address:V.address}))}}function c$($,Z){let Q=new Set([Z]);for(let X=!0;X;){X=!1;for(let J of $)if(!Q.has(J.pid)&&Q.has(J.parentPid)&&J.pid!==J.parentPid)Q.add(J.pid),X=!0}return Q}function d4($,Z,Q,X){let J=(Y)=>Y==="127.0.0.1"||Y==="::ffff:127.0.0.1"||Y==="::1";return $.flatMap((Y)=>{if(!Z.has(Y.pid)||Y.localPort!==X)return[];let z=Y.listening&&(J(Y.localAddress)||["0.0.0.0","::"].includes(Y.localAddress)),F=!Y.listening&&J(Y.localAddress)&&J(Y.remoteAddress);if(!z&&!F)return[];let G=`${Y.localAddress}:${Y.localPort}>${Y.remoteAddress}:${Y.remotePort}`;return[{pid:Y.pid,processGroupId:Q,descriptor:String(Y.pid),kernelId:G,state:z?"listen":"established",port:X,peerPort:z?null:Y.remotePort,host:Y.localAddress==="::1"?"::1":"127.0.0.1"}]})}async function l$($,Z,Q=u9(),X=S8){let J=w8(Q),Y=c$(J.processes(),$),z=await u$(X,1000),F=c$(J.processes(),$);return d4(z,new Set([...Y].filter((G)=>F.has(G))),$,Z)}async function _2($,Z=u9(),Q=S8){if(!Z||$.aborted)return!1;let X=Z.processes().some((F)=>F.pid===process.pid),J=Z.cwd(process.pid),Y=J!==null&&O9(J).toLowerCase()===O9(process.cwd()).toLowerCase(),z=await Q(5000).then((F)=>/^\s*TCP\s/m.test(F),()=>!1);return X&&Y&&z&&!$.aborted}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 l9($){return $!==null&&typeof $==="object"&&!Array.isArray($)}function I0($,Z,Q=Number.MAX_SAFE_INTEGER){return typeof $==="number"&&Number.isSafeInteger($)&&$>=Z&&$<=Q}function n$($){return typeof $==="string"&&/^[a-zA-Z0-9_-]{1,160}$/.test($)}function i$($,Z){let Q=Buffer.from($,"latin1");return Buffer.concat([Buffer.from([Q.length]),Q,Z])}function R0($){if(!l9($)||Object.keys($).length!==12||![$.organizationId,$.userId,$.runId,$.deviceId,$.rootId,$.jobId,$.fenceId].every(n$)||!I0($.attachmentRevision,0)||!I0($.grantRevision,1)||!I0($.generation,1)||!I0($.port,1024,65535)||!I0($.expiresAtMs,1))throw Error("preview_binding_invalid");return Object.freeze({...$})}function d0($,Z){return Object.keys($).every((Q)=>$[Q]===Z[Q])}function _9($){if($.length>4096||!$.startsWith("/")||$.startsWith("//")||/[\\\x00-\x20\x7f#]/.test($))throw Error("preview_path_invalid");let Z=decodeURIComponent($);if(Z.startsWith("//")||/[\\\x00-\x1f\x7f]/.test(Z))throw Error("preview_path_invalid");return $}function s$($){return Array.isArray($)&&$.length<=64&&$.every((Z)=>Array.isArray(Z)&&Z.length===2&&typeof Z[0]==="string"&&/^[a-zA-Z0-9-]{1,80}$/.test(Z[0])&&typeof Z[1]==="string"&&Z[1].length<=4096&&!/[\x00-\x1f\x7f]/.test(Z[1]))}function D9($,Z=v.chunk){if($.length>Math.ceil(Z/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test($))throw Error("preview_data_invalid");let Q=Buffer.from($,"base64");if(Q.length>Z)throw Error("preview_data_too_large");return Q}function a$($){if(Array.isArray($))return Buffer.concat($);if(typeof $==="string")return Buffer.from($,"utf8");if($ instanceof ArrayBuffer)return Buffer.from($);return $}function o$($){if(Buffer.byteLength($)>v.upload*1.4+300000)throw Error("preview_frame_too_large");let Z=JSON.parse($);if(!l9(Z))throw Error("preview_frame_invalid");if(Z.type==="hello")return{type:"hello",binding:R0(Z.binding),...I0(Z.messages,v.chunk,v.upload)?{messages:Z.messages}:{},...I0(Z.window,1,v.window)?{window:Z.window}:{},...Z.bytes===!0?{bytes:!0}:{}};if(Z.type==="refused"&&typeof Z.reason==="string"&&/^[a-z_]{1,32}$/.test(Z.reason))return{type:"refused",binding:R0(Z.binding),reason:Z.reason};if(!n$(Z.id))throw Error("preview_frame_invalid");if(Z.type==="end"||Z.type==="cancel"||Z.type==="credit")return{type:Z.type,id:Z.id};if(Z.type==="ws"&&typeof Z.protocol==="string"&&/^[a-zA-Z0-9._-]{0,100}$/.test(Z.protocol))return{type:"ws",id:Z.id,protocol:Z.protocol};if(Z.type==="data"&&typeof Z.data==="string"&&typeof Z.binary==="boolean")return D9(Z.data,v.upload),{type:"data",id:Z.id,data:Z.data,binary:Z.binary};if(Z.type==="head"&&I0(Z.status,200,599)&&s$(Z.headers))return{type:"head",id:Z.id,status:Z.status,headers:Z.headers};if(Z.type==="request"&&typeof Z.method==="string"&&/^(GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS)$/.test(Z.method)&&typeof Z.path==="string"&&s$(Z.headers)&&typeof Z.body==="string"&&typeof Z.upgrade==="boolean")return D9(Z.body,v.upload),{type:"request",id:Z.id,method:Z.method,path:_9(Z.path),headers:Z.headers,body:Z.body,upgrade:Z.upgrade};throw Error("preview_frame_invalid")}function b8($){let Z=[...$],Q=new Set(Z.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 Z.filter(([J])=>!X.has(J.toLowerCase())&&!Q.has(J.toLowerCase())&&!/^(x-forwarded-|x-ara-|sec-websocket-|access-control-)/i.test(J))}async function k8($){let Z;try{return await Promise.race([Promise.resolve().then($).then((Q)=>Q===!0||(Q===!1?!1:void 0),()=>{return}),new Promise((Q)=>{Z=setTimeout(()=>Q(void 0),v.authorizationMs)})])}finally{clearTimeout(Z)}}async function A9($){return await k8($)===!0}function s9($,Z){let Q=new URL($);if(Q.username||Q.password||Q.search||Q.hash||!(Q.protocol==="wss:"||Q.protocol==="ws:"&&["127.0.0.1","[::1]"].includes(Q.hostname))||!new RegExp(`^/${Z}/[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]{32,}$`).test(Q.pathname))throw Error("preview_relay_invalid");return Q.href}function r$($){if(!l9($)||Object.keys($).length!==2||typeof $.deviceRelayUrl!=="string")throw Error("preview_open_invalid");return{binding:R0($.binding),deviceRelayUrl:s9($.deviceRelayUrl,"device")}}function t$($){if(!l9($)||Object.keys($).length!==1||!("binding"in $))throw Error("preview_close_invalid");return{binding:R0($.binding)}}import{request as s4}from"http";import{pipeline as n4}from"stream";import{constants as f8,createBrotliCompress as i4,createGzip as a4}from"zlib";import{WebSocket as x9}from"ws";import{randomBytes as p4,timingSafeEqual as u4}from"crypto";import{createServer as l4}from"net";var e$="x-preview-connection";async function $Z($,Z){if(Z.aborted)throw Error("preview_closed");let Q=p4(32).toString("base64url"),X=new Set,J=!1,Y=l4((G)=>{if(J||Z.aborted||X.size>=v.streams*2)return G.destroy();X.add(G);let V=new AbortController;G.once("close",()=>{X.delete(G),V.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{Hc as pZ,Ic as uZ,Jc as C4,Kc as T4,Lc as M8,Mc as lZ}from"./vm-hands-entry-lite-e99ftdr6.js";import{Nc as fZ,Oc as H8,Pc as t9,Qc as _0,Rc as M9,Sc as a0,Zc as K0}from"./vm-hands-entry-lite-e4kdpq0t.js";import{ad as B8,bd as W8,cd as aQ}from"./vm-hands-entry-lite-0nd56w02.js";import{Ce as NZ,He as MZ,nf as f9,of as t0,pf as T8,qf as m0,uf as C0}from"./vm-hands-entry-lite-qvj5560v.js";import{Kg as aZ,Qg as $8,Rg as s8}from"./vm-hands-entry-lite-ps9gjbs5.js";import{Wg as j4}from"./vm-hands-entry-lite-q5h859gg.js";import{Dh as g8,Eh as w0,Fh as O0,Gh as o9,Nh as d8,Oh as TZ,Ph as HZ,Zg as SQ,ah as N9,jh as jZ,kh as qZ,mh as CZ,oh as i9,ph as FZ,qh as VZ,rh as h8,uh as a9}from"./vm-hands-entry-lite-1cs1jy20.js";import{yi as rZ,zi as a8}from"./vm-hands-entry-lite-gk3y60ap.js";import{_i as b0}from"./vm-hands-entry-lite-sbn9bmf7.js";import{qj as _8,rj as r9,uj as M4}from"./vm-hands-entry-lite-2sx1a43v.js";import{Aj as V8,Bj as H$,Cj as i0,Dj as u0,Ej as KZ,Pj as A$,vj as O8,wj as o0,xj as D8,yj as r0,zj as W9}from"./vm-hands-entry-lite-29f3m7x2.js";import{Uj as TQ}from"./vm-hands-entry-lite-90r926q9.js";import{nk as x}from"./vm-hands-entry-lite-f9akybcm.js";import{tk as q4}from"./vm-hands-entry-lite-sjn5yjvx.js";import{Ak as d$,Bk as DZ,Ck as d9,Fk as N4,Gk as J9,wk as L4,yk as e9,zk as OZ}from"./vm-hands-entry-lite-ek5r435m.js";import{Kk as q}from"./vm-hands-entry-lite-69n9q5f1.js";import{Lk as u1,Qk as qQ}from"./vm-hands-entry-lite-5d31qv44.js";import{execFile as b4}from"child_process";import{createRequire as k4}from"module";import{win32 as p9}from"path";var f4=250,m4=50,y4=250,g4=4194304;function v$($){let Z=/^(?:\[([^\]]+)\]|([^:]+)):([0-9]{1,5})$/.exec($??""),Q=Number(Z?.[3]);return Z&&Q<=65535?{address:Z[1]??Z[2],port:Q}:null}function h4($){let Z=[];for(let Q of $.split(/\r?\n/)){let X=Q.trim().split(/\s+/);if(X[0]!=="TCP"||X.length<5)continue;let J=v$(X[1]),Y=v$(X[2]),z=Number(X.at(-1));if(!J||!Y||!Number.isSafeInteger(z)||z<0)continue;Z.push({pid:z,localAddress:J.address,localPort:J.port,remoteAddress:Y.address,remotePort:Y.port,listening:Y.port===0})}return Z}function v4($){if($.localAddress==="0.0.0.0"||$.localAddress==="::")return`*:${$.localPort}`;return $.localAddress.includes(":")?`[${$.localAddress}]:${$.localPort}`:`${$.localAddress}:${$.localPort}`}var S8=($)=>new Promise((Z,Q)=>b4(p9.join(d$("win32").split(";")[0],"NETSTAT.EXE"),["-ano"],{timeout:$,maxBuffer:g4,encoding:"utf8",windowsHide:!0,env:d9()},(X,J)=>X?Q(X):Z(J)));function O9($){let Z=p9.normalize($.startsWith("\\\\?\\")?$.slice(4):$);return Z.length>3&&Z.endsWith("\\")?Z.slice(0,-1):Z}function c4($,Z){let Q=$.toLowerCase(),X=Z.toLowerCase();return X===Q||X.startsWith(Q.endsWith("\\")?Q:`${Q}\\`)}function p$($,Z,Q){let X=$.cwd(Q),J=X?O9(X):null;return J&&p9.isAbsolute(J)&&c4(Z,J)?J:null}var T9;function u9(){if(T9!==void 0)return T9;if(T9=null,process.platform!=="win32"||!["x64","arm64"].includes(process.arch))return null;let $;try{$=k4(import.meta.url)("bun:ffi")}catch{return null}let{FFIType:Z,ptr:Q}=$,X,J;try{X=$.dlopen("kernel32.dll",{CreateToolhelp32Snapshot:{args:[Z.u32,Z.u32],returns:Z.u64},Process32FirstW:{args:[Z.u64,Z.ptr],returns:Z.i32},Process32NextW:{args:[Z.u64,Z.ptr],returns:Z.i32},OpenProcess:{args:[Z.u32,Z.i32,Z.u32],returns:Z.u64},ReadProcessMemory:{args:[Z.u64,Z.u64,Z.ptr,Z.u64,Z.ptr],returns:Z.i32},CloseHandle:{args:[Z.u64],returns:Z.i32}}).symbols,J=$.dlopen("ntdll.dll",{NtQueryInformationProcess:{args:[Z.u64,Z.i32,Z.ptr,Z.u32,Z.ptr],returns:Z.i32}}).symbols}catch{return null}let Y=0xFFFF_FFFF_FFFF_FFFFn,z=2,F=1040,G=568,V=(B,H,K)=>{let L=Buffer.alloc(K);return X.ReadProcessMemory(B,H,Q(L),K,null)?L:null};return T9={processes(){let B=BigInt(X.CreateToolhelp32Snapshot(z,0));if(B===Y)throw new q("process_inspection_failed","Reading this computer's processes did not complete.");try{let H=Buffer.alloc(G);H.writeUInt32LE(G,0);let K=Q(H),L=[];for(let W=X.Process32FirstW(B,K);W;W=X.Process32NextW(B,K)){let U=H.toString("utf16le",44,G),j=U.slice(0,U.includes("\x00")?U.indexOf("\x00"):void 0),O=H.readUInt32LE(8);if(O>0)L.push({pid:O,parentPid:H.readUInt32LE(32),command:j.replace(/\.exe$/i,"")||null})}return L}finally{X.CloseHandle(B)}},cwd(B){let H=BigInt(X.OpenProcess(F,0,B));if(H===0n)return null;try{let K=Buffer.alloc(48);if(J.NtQueryInformationProcess(H,0,Q(K),K.length,null)!==0)return null;let L=V(H,K.readBigUInt64LE(8)+0x20n,8)?.readBigUInt64LE(0),W=L?V(H,L+0x38n,16):null,U=W?.readUInt16LE(0)??0;if(!W||U===0||U%2!==0)return null;return V(H,W.readBigUInt64LE(8),U)?.toString("utf16le")??null}finally{X.CloseHandle(H)}}},T9}function w8($){if(!$)throw new q("process_inspection_failed","Reading this computer's processes is unavailable.");return $}async function u$($,Z){let Q;try{Q=await $(Z)}catch{throw new q("process_inspection_failed","Reading this computer's ports did not complete.")}return h4(Q)}async function O2($,Z=u9()){let Q=w8(Z),X=O9($),J=[];for(let Y of Q.processes()){if(J.length>=f4)break;let z=p$(Q,X,Y.pid);if(z)J.push({pid:Y.pid,command:Y.command,cwd:p9.relative(X,z)||"."})}return{processes:J}}async function D2($,Z=u9(),Q=S8){let X=w8(Z),J=O9($),Y=(await u$(Q,5000)).filter((V)=>V.listening&&V.pid>0).map((V)=>({pid:V.pid,port:V.localPort,address:v4(V)})).sort((V,B)=>V.pid-B.pid||V.port-B.port||(V.address<B.address?-1:V.address>B.address?1:0)),z=[...new Set(Y.map((V)=>V.pid))].slice(0,m4),F=new Set(z.filter((V)=>p$(X,J,V)!==null));if(F.size===0)return{ports:[]};let G=new Map(X.processes().map((V)=>[V.pid,V.command]));return{ports:Y.filter((V)=>F.has(V.pid)).slice(0,y4).map((V)=>({pid:V.pid,command:G.get(V.pid)??null,address:V.address}))}}function c$($,Z){let Q=new Set([Z]);for(let X=!0;X;){X=!1;for(let J of $)if(!Q.has(J.pid)&&Q.has(J.parentPid)&&J.pid!==J.parentPid)Q.add(J.pid),X=!0}return Q}function d4($,Z,Q,X){let J=(Y)=>Y==="127.0.0.1"||Y==="::ffff:127.0.0.1"||Y==="::1";return $.flatMap((Y)=>{if(!Z.has(Y.pid)||Y.localPort!==X)return[];let z=Y.listening&&(J(Y.localAddress)||["0.0.0.0","::"].includes(Y.localAddress)),F=!Y.listening&&J(Y.localAddress)&&J(Y.remoteAddress);if(!z&&!F)return[];let G=`${Y.localAddress}:${Y.localPort}>${Y.remoteAddress}:${Y.remotePort}`;return[{pid:Y.pid,processGroupId:Q,descriptor:String(Y.pid),kernelId:G,state:z?"listen":"established",port:X,peerPort:z?null:Y.remotePort,host:Y.localAddress==="::1"?"::1":"127.0.0.1"}]})}async function l$($,Z,Q=u9(),X=S8){let J=w8(Q),Y=c$(J.processes(),$),z=await u$(X,1000),F=c$(J.processes(),$);return d4(z,new Set([...Y].filter((G)=>F.has(G))),$,Z)}async function _2($,Z=u9(),Q=S8){if(!Z||$.aborted)return!1;let X=Z.processes().some((F)=>F.pid===process.pid),J=Z.cwd(process.pid),Y=J!==null&&O9(J).toLowerCase()===O9(process.cwd()).toLowerCase(),z=await Q(5000).then((F)=>/^\s*TCP\s/m.test(F),()=>!1);return X&&Y&&z&&!$.aborted}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 l9($){return $!==null&&typeof $==="object"&&!Array.isArray($)}function I0($,Z,Q=Number.MAX_SAFE_INTEGER){return typeof $==="number"&&Number.isSafeInteger($)&&$>=Z&&$<=Q}function n$($){return typeof $==="string"&&/^[a-zA-Z0-9_-]{1,160}$/.test($)}function i$($,Z){let Q=Buffer.from($,"latin1");return Buffer.concat([Buffer.from([Q.length]),Q,Z])}function R0($){if(!l9($)||Object.keys($).length!==12||![$.organizationId,$.userId,$.runId,$.deviceId,$.rootId,$.jobId,$.fenceId].every(n$)||!I0($.attachmentRevision,0)||!I0($.grantRevision,1)||!I0($.generation,1)||!I0($.port,1024,65535)||!I0($.expiresAtMs,1))throw Error("preview_binding_invalid");return Object.freeze({...$})}function d0($,Z){return Object.keys($).every((Q)=>$[Q]===Z[Q])}function _9($){if($.length>4096||!$.startsWith("/")||$.startsWith("//")||/[\\\x00-\x20\x7f#]/.test($))throw Error("preview_path_invalid");let Z=decodeURIComponent($);if(Z.startsWith("//")||/[\\\x00-\x1f\x7f]/.test(Z))throw Error("preview_path_invalid");return $}function s$($){return Array.isArray($)&&$.length<=64&&$.every((Z)=>Array.isArray(Z)&&Z.length===2&&typeof Z[0]==="string"&&/^[a-zA-Z0-9-]{1,80}$/.test(Z[0])&&typeof Z[1]==="string"&&Z[1].length<=4096&&!/[\x00-\x1f\x7f]/.test(Z[1]))}function D9($,Z=v.chunk){if($.length>Math.ceil(Z/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test($))throw Error("preview_data_invalid");let Q=Buffer.from($,"base64");if(Q.length>Z)throw Error("preview_data_too_large");return Q}function a$($){if(Array.isArray($))return Buffer.concat($);if(typeof $==="string")return Buffer.from($,"utf8");if($ instanceof ArrayBuffer)return Buffer.from($);return $}function o$($){if(Buffer.byteLength($)>v.upload*1.4+300000)throw Error("preview_frame_too_large");let Z=JSON.parse($);if(!l9(Z))throw Error("preview_frame_invalid");if(Z.type==="hello")return{type:"hello",binding:R0(Z.binding),...I0(Z.messages,v.chunk,v.upload)?{messages:Z.messages}:{},...I0(Z.window,1,v.window)?{window:Z.window}:{},...Z.bytes===!0?{bytes:!0}:{}};if(Z.type==="refused"&&typeof Z.reason==="string"&&/^[a-z_]{1,32}$/.test(Z.reason))return{type:"refused",binding:R0(Z.binding),reason:Z.reason};if(!n$(Z.id))throw Error("preview_frame_invalid");if(Z.type==="end"||Z.type==="cancel"||Z.type==="credit")return{type:Z.type,id:Z.id};if(Z.type==="ws"&&typeof Z.protocol==="string"&&/^[a-zA-Z0-9._-]{0,100}$/.test(Z.protocol))return{type:"ws",id:Z.id,protocol:Z.protocol};if(Z.type==="data"&&typeof Z.data==="string"&&typeof Z.binary==="boolean")return D9(Z.data,v.upload),{type:"data",id:Z.id,data:Z.data,binary:Z.binary};if(Z.type==="head"&&I0(Z.status,200,599)&&s$(Z.headers))return{type:"head",id:Z.id,status:Z.status,headers:Z.headers};if(Z.type==="request"&&typeof Z.method==="string"&&/^(GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS)$/.test(Z.method)&&typeof Z.path==="string"&&s$(Z.headers)&&typeof Z.body==="string"&&typeof Z.upgrade==="boolean")return D9(Z.body,v.upload),{type:"request",id:Z.id,method:Z.method,path:_9(Z.path),headers:Z.headers,body:Z.body,upgrade:Z.upgrade};throw Error("preview_frame_invalid")}function b8($){let Z=[...$],Q=new Set(Z.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 Z.filter(([J])=>!X.has(J.toLowerCase())&&!Q.has(J.toLowerCase())&&!/^(x-forwarded-|x-ara-|sec-websocket-|access-control-)/i.test(J))}async function k8($){let Z;try{return await Promise.race([Promise.resolve().then($).then((Q)=>Q===!0||(Q===!1?!1:void 0),()=>{return}),new Promise((Q)=>{Z=setTimeout(()=>Q(void 0),v.authorizationMs)})])}finally{clearTimeout(Z)}}async function A9($){return await k8($)===!0}function s9($,Z){let Q=new URL($);if(Q.username||Q.password||Q.search||Q.hash||!(Q.protocol==="wss:"||Q.protocol==="ws:"&&["127.0.0.1","[::1]"].includes(Q.hostname))||!new RegExp(`^/${Z}/[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]{32,}$`).test(Q.pathname))throw Error("preview_relay_invalid");return Q.href}function r$($){if(!l9($)||Object.keys($).length!==2||typeof $.deviceRelayUrl!=="string")throw Error("preview_open_invalid");return{binding:R0($.binding),deviceRelayUrl:s9($.deviceRelayUrl,"device")}}function t$($){if(!l9($)||Object.keys($).length!==1||!("binding"in $))throw Error("preview_close_invalid");return{binding:R0($.binding)}}import{request as s4}from"http";import{pipeline as n4}from"stream";import{constants as f8,createBrotliCompress as i4,createGzip as a4}from"zlib";import{WebSocket as x9}from"ws";import{randomBytes as p4,timingSafeEqual as u4}from"crypto";import{createServer as l4}from"net";var e$="x-preview-connection";async function $Z($,Z){if(Z.aborted)throw Error("preview_closed");let Q=p4(32).toString("base64url"),X=new Set,J=!1,Y=l4((G)=>{if(J||Z.aborted||X.size>=v.streams*2)return G.destroy();X.add(G);let V=new AbortController;G.once("close",()=>{X.delete(G),V.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();K(B,W).catch(()=>G.destroy())};G.on("data",H);async function K(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");_9(j[2]);let O=!1,C=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()===e$){C++;let m=Buffer.from(S[2].trim());O=m.length===Q.length&&u4(m,Buffer.from(Q))}else if(S[1].toLowerCase()!=="host")A.push(T)}if(!O||C!==1||J||V.signal.aborted)throw Error("preview_connection_denied");let R=await $.connect(V.signal);if(J||V.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
@@ -302,7 +302,7 @@ async (input) => {
302
302
  if (!bridge || typeof bridge.evaluate !== "function") throw new Error("Reason Hands browser bridge is not installed");
303
303
  return await bridge.evaluate(typeof input === "string" ? input : input && input.code);
304
304
  }
305
- `.trim();import{Buffer as G9}from"buffer";import{randomUUID as _1}from"crypto";class KQ extends Error{code;constructor($){super($==="hands_repl_private_profile_attribute_denied"?"Private browser attribute read denied.":$);this.code=$;this.name="HandsReplBrowserDispatcherError"}}var FQ=new Set(["__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","__proto__","constructor","prototype"]),YQ=/^hands_[A-Za-z0-9_-]{8,128}$/,A1=2048,VQ=32,HQ=1e4,x1=new Set(["href","src","alt","title","role","aria-label","aria-expanded","aria-checked","aria-selected","aria-disabled","placeholder","type","name","data-testid"]);function P1($){let Z=$.split("+"),Q=(Z.pop()??"").replace(/^Key/,"").toLowerCase();if(Q==="f12")return!0;if(Z.some((X)=>["Control","ControlOrMeta","Meta"].includes(X))&&["l","n","t","j","i","p","s","w","u","o","r","tab","pageup","pagedown"].includes(Q))return!0;if(Z.some((X)=>["Control","ControlOrMeta","Meta"].includes(X))&&Z.includes("Shift")&&Q==="c")return!0;return Z.includes("Alt")&&["d","arrowleft","arrowright","home"].includes(Q)}var I1=($)=>{let Z=$.closest("a[href],area[href]");return{password:$.tagName==="INPUT"&&$.type==="password",executableLink:Boolean(Z&&!/^(https?:|about:blank)/i.test(Z.href))}},UQ={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 KQ($)}function z0($){if(!$||typeof $!=="object"||Array.isArray($))return!1;let Z=Object.getPrototypeOf($);return Z===Object.prototype||Z===null}function z9($,Z=0,Q={nodes:0}){if(Z>VQ||++Q.nodes>HQ)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 $)z9(X,Z+1,Q);return}if(!z0($))I("hands_repl_invalid_json");for(let[X,J]of Object.entries($)){if(FQ.has(X))I("hands_repl_invalid_json");z9(J,Z+1,Q)}}function o8($){return typeof $==="string"&&Object.hasOwn(UQ,$)}function R1($){if(!$.endsWith("[]"))return null;let Z=$.slice(0,-2);return o8(Z)?Z:null}function GQ($){return z0($)&&Object.keys($).length===2&&$.$handsRepl==="bytes"&&typeof $.base64==="string"}function E1($){return z0($)&&Object.keys($).length===1&&$.$handsRepl==="undefined"}function zQ($){return z0($)&&Object.keys($).length===2&&$.$handsRepl==="routeFulfill"&&"options"in $}function k0($){return!!$&&typeof $==="object"}function X8(){return Object.freeze({$handsRepl:"undefined"})}function S1($){if(!G9.isBuffer($)&&!($ instanceof Uint8Array))I("hands_repl_expected_bytes");return Object.freeze({$handsRepl:"bytes",base64:G9.from($).toString("base64")})}function WQ($){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 Z=$.maxHandles??A1;if(!Number.isInteger(Z)||Z<3||Z>1e5)I("hands_repl_invalid_handle_limit");let Q=new Map,X=new WeakMap,J=$.createOpaqueId??_1,Y=(K,L)=>{if(!k0(L))I("hands_repl_expected_target");let W=X.get(L)?.get(K);if(W)return W;if(Q.size>=Z)I("hands_repl_handle_limit");let U="";for(let C=0;C<16;C+=1){let A=`hands_${J()}`;if(YQ.test(A)&&!Q.has(A)){U=A;break}}if(!U)I("hands_repl_invalid_opaque_id");let j=Object.freeze({$handsRepl:"handle",id:U,kind:K});Q.set(U,{kind:K,target:L});let O=X.get(L);if(!O)O=new Map,X.set(L,O);return O.set(K,j),j},z=Object.freeze({browser:Y("browser",$.browser),context:Y("context",$.context),page:Y("page",$.page)}),F=(K)=>{if(!z0(K)||Object.keys(K).length!==3||K.$handsRepl!=="handle"||typeof K.id!=="string"||!YQ.test(K.id)||!o8(K.kind))I("hands_repl_invalid_handle");let L=Q.get(K.id);if(!L||L.kind!==K.kind)I("hands_repl_unknown_handle");return L},G=(K,L=0,W=new Set)=>{if(L>VQ)I("hands_repl_json_too_complex");if(K===void 0)return X8();if(K===null||typeof K==="boolean"||typeof K==="string")return K;if(typeof K==="number"){if(!Number.isFinite(K))I("hands_repl_non_json_result");return K}if(Array.isArray(K)){if(W.has(K))I("hands_repl_cyclic_result");W.add(K);try{return K.map((U)=>G(U,L+1,W))}finally{W.delete(K)}}if(!z0(K))I("hands_repl_non_json_result");if(W.has(K))I("hands_repl_cyclic_result");W.add(K);try{let U=Object.create(null);for(let j of Object.keys(K)){let O=Object.getOwnPropertyDescriptor(K,j);if(!O||!("value"in O))continue;U[j]=G(O.value,L+1,W)}return U}finally{W.delete(K)}},V=(K,L)=>{if(L==="void")return X8();if(L==="json")return G(K);if(L==="bytes")return S1(K);let W=R1(L);if(W){if(!Array.isArray(K))I("hands_repl_expected_target_list");if(W==="context"&&K.some((U)=>U!==$.context))I("hands_repl_foreign_context");return K.map((U)=>Y(W,U))}if(K===null||K===void 0)return X8();if(!o8(L))I("hands_repl_invalid_return_kind");if(L==="context"&&K!==$.context)I("hands_repl_foreign_context");return Y(L,K)},B=(K)=>{if(z0(K)&&K.$handsRepl==="handle")return F(K).target;if(GQ(K))return G9.from(K.base64,"base64");if(E1(K))return;if(zQ(K))I("hands_repl_route_fulfill_only");if(Array.isArray(K))return K.map(B);if(!z0(K))return K;let L=Object.create(null);for(let[W,U]of Object.entries(K))L[W]=B(U);return L};return Object.freeze({roots:z,dispatch:async(K)=>{if(!z0(K)||typeof K.type!=="string")I("hands_repl_invalid_request");if(K.type==="a11y"){let T=K.target===void 0?Q.get(z.page.id):F(K.target);if(!T||T.kind!=="page"&&T.kind!=="locator")I("hands_repl_invalid_a11y_target");return G(await $.a11y(T.target))}if(K.type==="view"){if(z9(K.source),K.options!==void 0)z9(K.options);let T=GQ(K.source)?G9.from(K.source.base64,"base64"):K.source;if($.privateProfile&&!G9.isBuffer(T))I("hands_repl_profile_requires_image_bytes");return G(await $.view(T,K.options))}if(K.type!=="call")I("hands_repl_invalid_request");if(typeof K.method!=="string"||K.method.length===0||K.method.length>128)I("hands_repl_invalid_method");if(FQ.has(K.method))I("hands_repl_forbidden_method");let L=F(K.target),W=K.args??[];if(!Array.isArray(W))I("hands_repl_invalid_arguments");if(z9(W),L.kind==="page"&&K.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(K.method)){if(!$.recording||L.target!==$.context)I("hands_repl_recording_unavailable");if(W.length>(K.method==="startRecording"?1:0))I("hands_repl_invalid_arguments");return G(K.method==="startRecording"?await $.recording.start(W[0]):await $.recording.stop())}if($.privateProfile){let T=K.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 V([$.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"||!x1.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 m=Reflect.get(L.target,"all");if(typeof m!=="function")I("hands_repl_private_profile_probe_unavailable");let E=await Reflect.apply(m,L.target,[]);if(!Array.isArray(E)||E.length>HQ||!E.every(k0))I("hands_repl_private_profile_probe_unavailable");S=E}for(let m of S){let E=Reflect.get(m,"isVisible");if(typeof E!=="function"||!await Reflect.apply(E,m,[]))I("hands_repl_private_profile_hidden_value_denied")}}if(T==="press"&&typeof W[0]==="string"&&P1(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 m=await Reflect.apply(S,L.target,[I1]);if(!z0(m)||typeof m.password!=="boolean"||typeof m.executableLink!=="boolean")I("hands_repl_private_profile_probe_unavailable");if(T==="inputValue"&&m.password)I("hands_repl_private_profile_password_denied");if(T!=="inputValue"&&m.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=UQ[L.kind][K.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"&&K.method==="contexts")return[z.context];if(["addInitScript","addScriptTag","addStyleTag","screenshot","pdf","storageState"].includes(K.method)&&W.some((T)=>z0(T)&&("path"in T)))I("hands_repl_file_path_not_allowed");if(K.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,[]),m=Array.isArray(S)?S[0]:void 0,E=k0(m)?Reflect.get(m,"viewportSize"):void 0;if(typeof E!=="function")return X8();return V(await Reflect.apply(E,m,[]),U.returns)}if(U.special==="property"){let T=Reflect.get(L.target,K.method);return V(typeof T==="function"?Reflect.apply(T,L.target,[]):T,U.returns)}let j=Reflect.get(L.target,K.method);if(typeof j!=="function")I("hands_repl_method_unavailable");if(U.special==="route"){let T=W[1];if(!zQ(T))I("hands_repl_invalid_route_handler");z9(T.options);let S=B(T.options),m=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),m],N=await Reflect.apply(j,L.target,E);return V(N,U.returns)}let O=W.map(B);if(K.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"||!G9.isBuffer(E.buffer))I("hands_repl_invalid_file_input");return E}if(!$.readWorkspaceFile)I("hands_repl_workspace_required");return $.readWorkspaceFile(E)},m=O[T];O[T]=Array.isArray(m)?await Promise.all(m.map(S)):await S(m)}if(K.method==="goto")await $.beforeNavigation?.();let C=$.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"}[K.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;C?.(P,k0(S)?S:void 0)}return V(A,U.returns)}})}import{isIP as jQ}from"net";import{Resolver as w1}from"dns/promises";import{isIP as Y8}from"net";var b1=[["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 r8($){if(Y8($)!==4)return null;let Z=$.split(".");if(Z.length!==4)return null;let Q=0;for(let X of Z){let J=Number(X);if(!Number.isInteger(J)||J<0||J>255)return null;Q=Q*256+J}return Q>>>0}function k1($,Z,Q){let X=r8(Z);if(X===null)return!1;let J=Q===0?0:4294967295<<32-Q>>>0;return($&J)>>>0===(X&J)>>>0}function BQ($){let Z=r8($);if(Z===null)return!0;return b1.some(([Q,X])=>k1(Z,Q,X))}function f1($){if(Y8($)!==6)return null;let Z=$.toLowerCase(),Q=Z.indexOf("%");if(Q>=0)Z=Z.slice(0,Q);let X=[],J=Z.lastIndexOf(":"),Y=J>=0?Z.slice(J+1):"";if(Y.includes(".")){let K=r8(Y);if(K===null)return null;X=[K>>>16&65535,K&65535],Z=Z.slice(0,J+1)+"0:0"}let z=Z.split("::");if(z.length>2)return null;let F=(K)=>{if(K==="")return[];let L=[];for(let W of K.split(":")){if(W===""||W.length>4||!/^[0-9a-f]+$/.test(W))return null;L.push(Number.parseInt(W,16))}return L},G=F(z[0]??"");if(G===null)return null;if(z.length===1){let K=G;if(K.length!==8)return null;return X.length>0?K.slice(0,6).concat(X):K}let V=F(z[1]??"");if(V===null)return null;let B=8-G.length-V.length;if(B<0)return null;let H=G.concat(Array(B).fill(0),V);if(H.length!==8)return null;return X.length>0?H.slice(0,6).concat(X):H}function m1($,Z){return`${$>>8&255}.${$&255}.${Z>>8&255}.${Z&255}`}function y1($){let Z=f1($);if(Z===null)return!0;let[Q,X,J]=Z;if((Q&57344)!==8192)return!0;if(Q===8193&&(X&65024)===0)return!0;if(Q===8193&&X===3512)return!0;if(Q===16383&&(X&61440)===0)return!0;if(Q===8194)return BQ(m1(X,J));return!1}function LQ($){return $.replace(/^\[|\]$/g,"")}function J8($){let Z=LQ($.trim()),Q=Y8(Z);if(Q===4)return BQ(Z);if(Q===6)return y1(Z);return!0}function NQ($){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 MQ=5000;function g1($){return async(Z,Q)=>{if(Q?.aborted)throw Error("aborted");let X=new w1({timeout:MQ,tries:1});if($)X.setServers($);let J=()=>X.cancel();Q?.addEventListener("abort",J,{once:!0});try{let[Y,z]=await Promise.allSettled([X.resolve4(Z),X.resolve6(Z)]),F=[...Y.status==="fulfilled"?Y.value:[],...z.status==="fulfilled"?z.value:[]];if(F.length>0)return F;let G=[Y,z].flatMap((B)=>B.status==="rejected"?[B.reason]:[]);throw G.find((B)=>["dns_temporary","dns_timeout"].includes(NQ(B)))??G[0]??Object.assign(Error("DNS returned no addresses"),{code:"ENODATA"})}finally{Q?.removeEventListener("abort",J)}}}var h1=g1();async function v1($,Z,Q,X){if(X?.aborted)throw Error("aborted");let J=new AbortController,Y,z,F=Z($,J.signal);F.catch(()=>{});try{return await Promise.race([F,new Promise((G,V)=>{if(Y=setTimeout(()=>V(new DOMException("DNS lookup timed out","TimeoutError")),Q),X)z=()=>V(Error("aborted")),X.addEventListener("abort",z,{once:!0})})])}finally{if(Y!==void 0)clearTimeout(Y);if(X&&z)X.removeEventListener("abort",z);J.abort()}}async function b5($,Z=h1,Q){let X=LQ($);if(Y8(X))return J8(X)?{ok:!1,reason:"non_public_ip"}:{ok:!0,addresses:[X]};let J;try{J=await v1(X,Z,MQ,Q)}catch(Y){return{ok:!1,reason:Q?.aborted?Q.reason instanceof Error&&Q.reason.name==="TimeoutError"?"dns_timeout":"aborted":NQ(Y)}}if(J.length===0)return{ok:!1,reason:"dns_empty"};if(J.some(J8))return{ok:!1,reason:"non_public_ip"};return{ok:!0,addresses:J}}var c1=/^(?:\*\.)?[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?$/;function t8($){return $.length<=253&&c1.test($.toLowerCase())}function d1($,Z){let Q=$.trim().toLowerCase();if(!t8(Q))return!1;if(Q.startsWith("*.")){let X=Q.slice(2);return Z===X||Z.endsWith(`.${X}`)}return Q===Z}function p1($){let Z=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec($);if(!Z)return null;let Q=Z.slice(1).map(Number);return Q.some((X)=>X>255)?null:Q}function e8($,Z=[]){let Q=(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),z=parseInt(J[2],16);return`${Y>>8}.${Y&255}.${z>>8}.${z&255}`};return Z.some((X)=>Q(X)===Q($))}function l0($){$=$.toLowerCase().replace(/^\[|\]$/g,"");let Z=p1($);if(Z){let[Y,z,F]=Z;if(Y===127)return"loopback";return Y===0||Y===10||Y>=224||Y===100&&z>=64&&z<=127||Y===169&&z===254||Y===172&&z>=16&&z<=31||Y===192&&(z===168||z===0&&(F===0||F===2)||z===88&&F===99)||Y===198&&(z===18||z===19||z===51&&F===100)||Y===203&&z===0&&F===113?"private":"public"}if(!$.includes(":"))return"hostname";try{$=new URL(`http://[${$}]/`).hostname.slice(1,-1)}catch{return"private"}if($==="::1")return"loopback";let Q=/^::ffff:([\da-f]+):([\da-f]+)$/.exec($);if(Q){let Y=parseInt(Q[1],16),z=parseInt(Q[2],16);return l0(`${Y>>8}.${Y&255}.${z>>8}.${z&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 S9($,Z){let Q;try{Q=new URL($)}catch{return{allowed:!1,url:$,host:null,reason:"invalid_url"}}if(["about:","data:","blob:"].includes(Q.protocol))return{allowed:!0,url:$,host:null,reason:"local_document"};if(!["http:","https:","ws:","wss:"].includes(Q.protocol))return{allowed:!1,url:$,host:Q.hostname||null,reason:"unsupported_protocol"};let X=Q.hostname.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"");if(Z.mode==="off")return{allowed:!0,url:$,host:X,reason:"policy_off"};let J=(F)=>({allowed:!1,url:$,host:X,reason:F});if(Q.username||Q.password)return J("invalid_url");if(Z.mode==="public_web"){let F=l0(X)!=="public"&&l0(X)!=="hostname"||X==="localhost"||/\.(?:localhost|local|internal|arpa)$/.test(X)||!X.includes(".")&&!jQ(X)||Boolean(jQ(X)&&J8(X));return{allowed:!F,url:$,host:X,reason:F?"private_network":"public_web"}}let Y=Number(Q.port||(["https:","wss:"].includes(Q.protocol)?443:80));if(Z.deniedPorts?.includes(Y)||e8(X,Z.deniedHosts))return J("destination_not_allowed");let z=l0(X);if(z==="private"||["local","internal","arpa"].some((F)=>X===F||X.endsWith(`.${F}`)))return J("private_network");if(z==="loopback"||X==="localhost"||X.endsWith(".localhost"))return Z.allowedLoopbackPorts?.includes(Y)?{allowed:!0,url:$,host:X,reason:"loopback"}:J("destination_not_allowed");if(Z.allowedDomains.some((F)=>d1(F,X)))return{allowed:!0,url:$,host:X,reason:"allowed_domain"};return{allowed:!1,url:$,host:X,reason:"destination_not_allowed"}}import CQ from"child_process";import{accessSync as l1,constants as s1,readFileSync as n1,statSync as OQ}from"fs";import{createRequire as DQ}from"module";import{homedir as $$}from"os";import{dirname as i1,isAbsolute as Z$,join as s0,resolve as a1,win32 as o1}from"path";var G8=Object.freeze({schemaVersion:1,driver:"playwright-core",driverVersion:TQ.dependencies["playwright-core"],browser:"chromium"}),_Q=["/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"],Q$=["/usr/bin/chromium","/usr/bin/chromium-browser","/usr/bin/google-chrome","/usr/bin/google-chrome-stable"];function r1($=process.env){let Z=[$.ProgramFiles??"C:\\Program Files",$["ProgramFiles(x86)"]??"C:\\Program Files (x86)"],Q=$.LOCALAPPDATA?[$.LOCALAPPDATA]:[],X=(J,...Y)=>J.map((z)=>o1.join(z,...Y));return[...X([...Z,...Q],"Google","Chrome","Application","chrome.exe"),...X(Z,"Microsoft","Edge","Application","msedge.exe"),...X([...Z,...Q],"BraveSoftware","Brave-Browser","Application","brave.exe")]}function w9($){try{return l1($,s1.X_OK),Z$($)&&OQ($).isFile()}catch{return!1}}function X$($,Z=process.platform){let Q=Z==="darwin"?_Q:Z==="linux"?Q$:Z==="win32"?r1():null;return Q?($??Q).find(w9)??null:null}function t1(){if(!process.versions.bun)return;let $=Symbol.for("ara.headless-browser.bun-pipe-owners");if(Object.hasOwn(globalThis,$))return;let Z=[];CQ.spawn=new Proxy(CQ.spawn,{apply(Q,X,J){let Y=Reflect.apply(Q,X,J),z=J[1],F=J[2]?.stdio;if(Array.isArray(z)&&z.includes("--remote-debugging-pipe")&&Array.isArray(F)&&F[3]==="pipe"&&F[4]==="pipe")Z.push(Y);return Y}}),Object.defineProperty(globalThis,$,{value:Z})}async function z8($){if(t1(),$!==void 0){if(!Z$($))throw Error("hands_browser_driver_path_must_be_absolute");let X=s0($,"package.json"),J=JSON.parse(n1(X,"utf8"));if(J.name!==G8.driver)throw Error("hands_browser_wrong_driver");let Y=DQ(X)($),z=Y.default?.chromium??Y.chromium;if(!z)throw Error("hands_browser_missing_chromium");return{version:J.version,chromium:z}}let[Z,Q]=await Promise.all([import("./index-m32pjcjr.js"),import("./package-04cf0m62.js").then((m)=>u1(m.default,1))]);return{version:Q.default.version,chromium:Z.chromium}}var e1=($,Z=G8.driverVersion)=>({status:"unavailable",reason:$,expectedDriverVersion:Z}),$7=($)=>$.loadDriver?.()??z8($.driverModuleDirectory),Z7={"1.60.0":"1223"};function u5(){let $=process.platform,Z=Z7[G8.driverVersion];if(!Z||$!=="linux"&&$!=="darwin"&&$!=="win32")return!1;let Q=(X)=>process.env[X]??process.env[`npm_config_${X.toLowerCase()}`]??process.env[`npm_package_config_${X.toLowerCase()}`];try{let X=Q("PLAYWRIGHT_BROWSERS_PATH"),J=X==="0"?s0(i1(DQ(import.meta.url).resolve("playwright-core/package.json")),".local-browsers"):X?a1(Q("INIT_CWD")||process.cwd(),X):s0($==="darwin"?s0($$(),"Library","Caches"):$==="win32"?process.env.LOCALAPPDATA||s0($$(),"AppData","Local"):process.env.XDG_CACHE_HOME||s0($$(),".cache"),"ms-playwright");return OQ(s0(J,`chromium-${Z}`,"INSTALLATION_COMPLETE")).isFile()}catch{return!1}}async function K9($={}){return AQ($,G8.driverVersion)}async function J$($,Z={}){if($.driverVersion!=="1.61.1"||!Z$($.driverModuleDirectory))throw Error("hands_browser_invalid_managed_compatibility");return AQ({...Z,driverModuleDirectory:$.driverModuleDirectory,allowSystemBrowser:!0},$.driverVersion)}async function AQ($,Z){let Q=(G)=>e1(G,Z),X=$.platform??process.platform;if(X!=="linux"&&X!=="darwin"&&X!=="win32")return Q("unsupported_platform");let J;try{J=await $7($)}catch{return Q("driver_missing")}if(J.version!==Z)return Q("driver_version_mismatch");let Y=(G,V)=>({status:"resolved",executablePath:G,source:V,driverVersion:J.version});if($.executablePath!==void 0)return w9($.executablePath)?Y($.executablePath,"configured"):Q("executable_missing");let z=J.chromium.executablePath();if(w9(z))return Y(z,"managed");let F=$.allowSystemBrowser===!0?X$($.systemCandidates,X):null;return F?Y(F,"system"):Q("executable_missing")}var B7=["/usr/local/bin/chromium",...Q$];function L7($,Z=wQ()){return X$($??(Z==="linux"?B7:void 0),Z)}async function N7(){try{return(await z8()).chromium}catch{return F7(import.meta.url)("playwright-core").chromium}}var M7=1048576,j7=105000,q7=20000,IQ=5000,C7=2000,T7=1000,O7=30000,RQ=81920,D7={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".gif":"image/gif"};async function _7($,Z){let Q=new URL($.url()),X={...await $.allHeaders(),host:Q.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 F=(Q.protocol==="https:"?H7:V7)(Q,{method:$.method(),headers:X,agent:!1,lookup:(V,B,H)=>{let K=n0.isIP(Z);if(B.all)H(null,[{address:Z,family:K}]);else H(null,Z,K)}},(V)=>{let B=[],H=0;V.on("data",(K)=>{if(H+=K.length,H>33554432)F.destroy(Error("hands_browser_response_too_large"));else B.push(K)}),V.on("error",Y),V.on("end",()=>{let K={};for(let[L,W]of Object.entries(V.headers))if(W!==void 0&&!["transfer-encoding","connection","content-length"].includes(L))K[L]=Array.isArray(W)?W.join(`
305
+ `.trim();import{Buffer as G9}from"buffer";import{randomUUID as _1}from"crypto";class KQ extends Error{code;constructor($){super($==="hands_repl_private_profile_attribute_denied"?"Private browser attribute read denied.":$);this.code=$;this.name="HandsReplBrowserDispatcherError"}}var FQ=new Set(["__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","__proto__","constructor","prototype"]),YQ=/^hands_[A-Za-z0-9_-]{8,128}$/,A1=2048,VQ=32,HQ=1e4,x1=new Set(["href","src","alt","title","role","aria-label","aria-expanded","aria-checked","aria-selected","aria-disabled","placeholder","type","name","data-testid"]);function P1($){let Z=$.split("+"),Q=(Z.pop()??"").replace(/^Key/,"").toLowerCase();if(Q==="f12")return!0;if(Z.some((X)=>["Control","ControlOrMeta","Meta"].includes(X))&&["l","n","t","j","i","p","s","w","u","o","r","tab","pageup","pagedown"].includes(Q))return!0;if(Z.some((X)=>["Control","ControlOrMeta","Meta"].includes(X))&&Z.includes("Shift")&&Q==="c")return!0;return Z.includes("Alt")&&["d","arrowleft","arrowright","home"].includes(Q)}var I1=($)=>{let Z=$.closest("a[href],area[href]");return{password:$.tagName==="INPUT"&&$.type==="password",executableLink:Boolean(Z&&!/^(https?:|about:blank)/i.test(Z.href))}},UQ={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 KQ($)}function z0($){if(!$||typeof $!=="object"||Array.isArray($))return!1;let Z=Object.getPrototypeOf($);return Z===Object.prototype||Z===null}function z9($,Z=0,Q={nodes:0}){if(Z>VQ||++Q.nodes>HQ)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 $)z9(X,Z+1,Q);return}if(!z0($))I("hands_repl_invalid_json");for(let[X,J]of Object.entries($)){if(FQ.has(X))I("hands_repl_invalid_json");z9(J,Z+1,Q)}}function o8($){return typeof $==="string"&&Object.hasOwn(UQ,$)}function R1($){if(!$.endsWith("[]"))return null;let Z=$.slice(0,-2);return o8(Z)?Z:null}function GQ($){return z0($)&&Object.keys($).length===2&&$.$handsRepl==="bytes"&&typeof $.base64==="string"}function E1($){return z0($)&&Object.keys($).length===1&&$.$handsRepl==="undefined"}function zQ($){return z0($)&&Object.keys($).length===2&&$.$handsRepl==="routeFulfill"&&"options"in $}function k0($){return!!$&&typeof $==="object"}function X8(){return Object.freeze({$handsRepl:"undefined"})}function S1($){if(!G9.isBuffer($)&&!($ instanceof Uint8Array))I("hands_repl_expected_bytes");return Object.freeze({$handsRepl:"bytes",base64:G9.from($).toString("base64")})}function WQ($){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 Z=$.maxHandles??A1;if(!Number.isInteger(Z)||Z<3||Z>1e5)I("hands_repl_invalid_handle_limit");let Q=new Map,X=new WeakMap,J=$.createOpaqueId??_1,Y=(K,L)=>{if(!k0(L))I("hands_repl_expected_target");let W=X.get(L)?.get(K);if(W)return W;if(Q.size>=Z)I("hands_repl_handle_limit");let U="";for(let C=0;C<16;C+=1){let A=`hands_${J()}`;if(YQ.test(A)&&!Q.has(A)){U=A;break}}if(!U)I("hands_repl_invalid_opaque_id");let j=Object.freeze({$handsRepl:"handle",id:U,kind:K});Q.set(U,{kind:K,target:L});let O=X.get(L);if(!O)O=new Map,X.set(L,O);return O.set(K,j),j},z=Object.freeze({browser:Y("browser",$.browser),context:Y("context",$.context),page:Y("page",$.page)}),F=(K)=>{if(!z0(K)||Object.keys(K).length!==3||K.$handsRepl!=="handle"||typeof K.id!=="string"||!YQ.test(K.id)||!o8(K.kind))I("hands_repl_invalid_handle");let L=Q.get(K.id);if(!L||L.kind!==K.kind)I("hands_repl_unknown_handle");return L},G=(K,L=0,W=new Set)=>{if(L>VQ)I("hands_repl_json_too_complex");if(K===void 0)return X8();if(K===null||typeof K==="boolean"||typeof K==="string")return K;if(typeof K==="number"){if(!Number.isFinite(K))I("hands_repl_non_json_result");return K}if(Array.isArray(K)){if(W.has(K))I("hands_repl_cyclic_result");W.add(K);try{return K.map((U)=>G(U,L+1,W))}finally{W.delete(K)}}if(!z0(K))I("hands_repl_non_json_result");if(W.has(K))I("hands_repl_cyclic_result");W.add(K);try{let U=Object.create(null);for(let j of Object.keys(K)){let O=Object.getOwnPropertyDescriptor(K,j);if(!O||!("value"in O))continue;U[j]=G(O.value,L+1,W)}return U}finally{W.delete(K)}},V=(K,L)=>{if(L==="void")return X8();if(L==="json")return G(K);if(L==="bytes")return S1(K);let W=R1(L);if(W){if(!Array.isArray(K))I("hands_repl_expected_target_list");if(W==="context"&&K.some((U)=>U!==$.context))I("hands_repl_foreign_context");return K.map((U)=>Y(W,U))}if(K===null||K===void 0)return X8();if(!o8(L))I("hands_repl_invalid_return_kind");if(L==="context"&&K!==$.context)I("hands_repl_foreign_context");return Y(L,K)},B=(K)=>{if(z0(K)&&K.$handsRepl==="handle")return F(K).target;if(GQ(K))return G9.from(K.base64,"base64");if(E1(K))return;if(zQ(K))I("hands_repl_route_fulfill_only");if(Array.isArray(K))return K.map(B);if(!z0(K))return K;let L=Object.create(null);for(let[W,U]of Object.entries(K))L[W]=B(U);return L};return Object.freeze({roots:z,dispatch:async(K)=>{if(!z0(K)||typeof K.type!=="string")I("hands_repl_invalid_request");if(K.type==="a11y"){let T=K.target===void 0?Q.get(z.page.id):F(K.target);if(!T||T.kind!=="page"&&T.kind!=="locator")I("hands_repl_invalid_a11y_target");return G(await $.a11y(T.target))}if(K.type==="view"){if(z9(K.source),K.options!==void 0)z9(K.options);let T=GQ(K.source)?G9.from(K.source.base64,"base64"):K.source;if($.privateProfile&&!G9.isBuffer(T))I("hands_repl_profile_requires_image_bytes");return G(await $.view(T,K.options))}if(K.type!=="call")I("hands_repl_invalid_request");if(typeof K.method!=="string"||K.method.length===0||K.method.length>128)I("hands_repl_invalid_method");if(FQ.has(K.method))I("hands_repl_forbidden_method");let L=F(K.target),W=K.args??[];if(!Array.isArray(W))I("hands_repl_invalid_arguments");if(z9(W),L.kind==="page"&&K.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(K.method)){if(!$.recording||L.target!==$.context)I("hands_repl_recording_unavailable");if(W.length>(K.method==="startRecording"?1:0))I("hands_repl_invalid_arguments");return G(K.method==="startRecording"?await $.recording.start(W[0]):await $.recording.stop())}if($.privateProfile){let T=K.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 V([$.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"||!x1.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 m=Reflect.get(L.target,"all");if(typeof m!=="function")I("hands_repl_private_profile_probe_unavailable");let E=await Reflect.apply(m,L.target,[]);if(!Array.isArray(E)||E.length>HQ||!E.every(k0))I("hands_repl_private_profile_probe_unavailable");S=E}for(let m of S){let E=Reflect.get(m,"isVisible");if(typeof E!=="function"||!await Reflect.apply(E,m,[]))I("hands_repl_private_profile_hidden_value_denied")}}if(T==="press"&&typeof W[0]==="string"&&P1(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 m=await Reflect.apply(S,L.target,[I1]);if(!z0(m)||typeof m.password!=="boolean"||typeof m.executableLink!=="boolean")I("hands_repl_private_profile_probe_unavailable");if(T==="inputValue"&&m.password)I("hands_repl_private_profile_password_denied");if(T!=="inputValue"&&m.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=UQ[L.kind][K.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"&&K.method==="contexts")return[z.context];if(["addInitScript","addScriptTag","addStyleTag","screenshot","pdf","storageState"].includes(K.method)&&W.some((T)=>z0(T)&&("path"in T)))I("hands_repl_file_path_not_allowed");if(K.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,[]),m=Array.isArray(S)?S[0]:void 0,E=k0(m)?Reflect.get(m,"viewportSize"):void 0;if(typeof E!=="function")return X8();return V(await Reflect.apply(E,m,[]),U.returns)}if(U.special==="property"){let T=Reflect.get(L.target,K.method);return V(typeof T==="function"?Reflect.apply(T,L.target,[]):T,U.returns)}let j=Reflect.get(L.target,K.method);if(typeof j!=="function")I("hands_repl_method_unavailable");if(U.special==="route"){let T=W[1];if(!zQ(T))I("hands_repl_invalid_route_handler");z9(T.options);let S=B(T.options),m=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),m],N=await Reflect.apply(j,L.target,E);return V(N,U.returns)}let O=W.map(B);if(K.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"||!G9.isBuffer(E.buffer))I("hands_repl_invalid_file_input");return E}if(!$.readWorkspaceFile)I("hands_repl_workspace_required");return $.readWorkspaceFile(E)},m=O[T];O[T]=Array.isArray(m)?await Promise.all(m.map(S)):await S(m)}if(K.method==="goto")await $.beforeNavigation?.();let C=$.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"}[K.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;C?.(P,k0(S)?S:void 0)}return V(A,U.returns)}})}import{isIP as jQ}from"net";import{Resolver as w1}from"dns/promises";import{isIP as Y8}from"net";var b1=[["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 r8($){if(Y8($)!==4)return null;let Z=$.split(".");if(Z.length!==4)return null;let Q=0;for(let X of Z){let J=Number(X);if(!Number.isInteger(J)||J<0||J>255)return null;Q=Q*256+J}return Q>>>0}function k1($,Z,Q){let X=r8(Z);if(X===null)return!1;let J=Q===0?0:4294967295<<32-Q>>>0;return($&J)>>>0===(X&J)>>>0}function BQ($){let Z=r8($);if(Z===null)return!0;return b1.some(([Q,X])=>k1(Z,Q,X))}function f1($){if(Y8($)!==6)return null;let Z=$.toLowerCase(),Q=Z.indexOf("%");if(Q>=0)Z=Z.slice(0,Q);let X=[],J=Z.lastIndexOf(":"),Y=J>=0?Z.slice(J+1):"";if(Y.includes(".")){let K=r8(Y);if(K===null)return null;X=[K>>>16&65535,K&65535],Z=Z.slice(0,J+1)+"0:0"}let z=Z.split("::");if(z.length>2)return null;let F=(K)=>{if(K==="")return[];let L=[];for(let W of K.split(":")){if(W===""||W.length>4||!/^[0-9a-f]+$/.test(W))return null;L.push(Number.parseInt(W,16))}return L},G=F(z[0]??"");if(G===null)return null;if(z.length===1){let K=G;if(K.length!==8)return null;return X.length>0?K.slice(0,6).concat(X):K}let V=F(z[1]??"");if(V===null)return null;let B=8-G.length-V.length;if(B<0)return null;let H=G.concat(Array(B).fill(0),V);if(H.length!==8)return null;return X.length>0?H.slice(0,6).concat(X):H}function m1($,Z){return`${$>>8&255}.${$&255}.${Z>>8&255}.${Z&255}`}function y1($){let Z=f1($);if(Z===null)return!0;let[Q,X,J]=Z;if((Q&57344)!==8192)return!0;if(Q===8193&&(X&65024)===0)return!0;if(Q===8193&&X===3512)return!0;if(Q===16383&&(X&61440)===0)return!0;if(Q===8194)return BQ(m1(X,J));return!1}function LQ($){return $.replace(/^\[|\]$/g,"")}function J8($){let Z=LQ($.trim()),Q=Y8(Z);if(Q===4)return BQ(Z);if(Q===6)return y1(Z);return!0}function NQ($){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 MQ=5000;function g1($){return async(Z,Q)=>{if(Q?.aborted)throw Error("aborted");let X=new w1({timeout:MQ,tries:1});if($)X.setServers($);let J=()=>X.cancel();Q?.addEventListener("abort",J,{once:!0});try{let[Y,z]=await Promise.allSettled([X.resolve4(Z),X.resolve6(Z)]),F=[...Y.status==="fulfilled"?Y.value:[],...z.status==="fulfilled"?z.value:[]];if(F.length>0)return F;let G=[Y,z].flatMap((B)=>B.status==="rejected"?[B.reason]:[]);throw G.find((B)=>["dns_temporary","dns_timeout"].includes(NQ(B)))??G[0]??Object.assign(Error("DNS returned no addresses"),{code:"ENODATA"})}finally{Q?.removeEventListener("abort",J)}}}var h1=g1();async function v1($,Z,Q,X){if(X?.aborted)throw Error("aborted");let J=new AbortController,Y,z,F=Z($,J.signal);F.catch(()=>{});try{return await Promise.race([F,new Promise((G,V)=>{if(Y=setTimeout(()=>V(new DOMException("DNS lookup timed out","TimeoutError")),Q),X)z=()=>V(Error("aborted")),X.addEventListener("abort",z,{once:!0})})])}finally{if(Y!==void 0)clearTimeout(Y);if(X&&z)X.removeEventListener("abort",z);J.abort()}}async function b5($,Z=h1,Q){let X=LQ($);if(Y8(X))return J8(X)?{ok:!1,reason:"non_public_ip"}:{ok:!0,addresses:[X]};let J;try{J=await v1(X,Z,MQ,Q)}catch(Y){return{ok:!1,reason:Q?.aborted?Q.reason instanceof Error&&Q.reason.name==="TimeoutError"?"dns_timeout":"aborted":NQ(Y)}}if(J.length===0)return{ok:!1,reason:"dns_empty"};if(J.some(J8))return{ok:!1,reason:"non_public_ip"};return{ok:!0,addresses:J}}var c1=/^(?:\*\.)?[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?$/;function t8($){return $.length<=253&&c1.test($.toLowerCase())}function d1($,Z){let Q=$.trim().toLowerCase();if(!t8(Q))return!1;if(Q.startsWith("*.")){let X=Q.slice(2);return Z===X||Z.endsWith(`.${X}`)}return Q===Z}function p1($){let Z=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec($);if(!Z)return null;let Q=Z.slice(1).map(Number);return Q.some((X)=>X>255)?null:Q}function e8($,Z=[]){let Q=(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),z=parseInt(J[2],16);return`${Y>>8}.${Y&255}.${z>>8}.${z&255}`};return Z.some((X)=>Q(X)===Q($))}function l0($){$=$.toLowerCase().replace(/^\[|\]$/g,"");let Z=p1($);if(Z){let[Y,z,F]=Z;if(Y===127)return"loopback";return Y===0||Y===10||Y>=224||Y===100&&z>=64&&z<=127||Y===169&&z===254||Y===172&&z>=16&&z<=31||Y===192&&(z===168||z===0&&(F===0||F===2)||z===88&&F===99)||Y===198&&(z===18||z===19||z===51&&F===100)||Y===203&&z===0&&F===113?"private":"public"}if(!$.includes(":"))return"hostname";try{$=new URL(`http://[${$}]/`).hostname.slice(1,-1)}catch{return"private"}if($==="::1")return"loopback";let Q=/^::ffff:([\da-f]+):([\da-f]+)$/.exec($);if(Q){let Y=parseInt(Q[1],16),z=parseInt(Q[2],16);return l0(`${Y>>8}.${Y&255}.${z>>8}.${z&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 S9($,Z){let Q;try{Q=new URL($)}catch{return{allowed:!1,url:$,host:null,reason:"invalid_url"}}if(["about:","data:","blob:"].includes(Q.protocol))return{allowed:!0,url:$,host:null,reason:"local_document"};if(!["http:","https:","ws:","wss:"].includes(Q.protocol))return{allowed:!1,url:$,host:Q.hostname||null,reason:"unsupported_protocol"};let X=Q.hostname.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"");if(Z.mode==="off")return{allowed:!0,url:$,host:X,reason:"policy_off"};let J=(F)=>({allowed:!1,url:$,host:X,reason:F});if(Q.username||Q.password)return J("invalid_url");if(Z.mode==="public_web"){let F=l0(X)!=="public"&&l0(X)!=="hostname"||X==="localhost"||/\.(?:localhost|local|internal|arpa)$/.test(X)||!X.includes(".")&&!jQ(X)||Boolean(jQ(X)&&J8(X));return{allowed:!F,url:$,host:X,reason:F?"private_network":"public_web"}}let Y=Number(Q.port||(["https:","wss:"].includes(Q.protocol)?443:80));if(Z.deniedPorts?.includes(Y)||e8(X,Z.deniedHosts))return J("destination_not_allowed");let z=l0(X);if(z==="private"||["local","internal","arpa"].some((F)=>X===F||X.endsWith(`.${F}`)))return J("private_network");if(z==="loopback"||X==="localhost"||X.endsWith(".localhost"))return Z.allowedLoopbackPorts?.includes(Y)?{allowed:!0,url:$,host:X,reason:"loopback"}:J("destination_not_allowed");if(Z.allowedDomains.some((F)=>d1(F,X)))return{allowed:!0,url:$,host:X,reason:"allowed_domain"};return{allowed:!1,url:$,host:X,reason:"destination_not_allowed"}}import CQ from"child_process";import{accessSync as l1,constants as s1,readFileSync as n1,statSync as OQ}from"fs";import{createRequire as DQ}from"module";import{homedir as $$}from"os";import{dirname as i1,isAbsolute as Z$,join as s0,resolve as a1,win32 as o1}from"path";var G8=Object.freeze({schemaVersion:1,driver:"playwright-core",driverVersion:TQ.dependencies["playwright-core"],browser:"chromium"}),_Q=["/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"],Q$=["/usr/bin/chromium","/usr/bin/chromium-browser","/usr/bin/google-chrome","/usr/bin/google-chrome-stable"];function r1($=process.env){let Z=[$.ProgramFiles??"C:\\Program Files",$["ProgramFiles(x86)"]??"C:\\Program Files (x86)"],Q=$.LOCALAPPDATA?[$.LOCALAPPDATA]:[],X=(J,...Y)=>J.map((z)=>o1.join(z,...Y));return[...X([...Z,...Q],"Google","Chrome","Application","chrome.exe"),...X(Z,"Microsoft","Edge","Application","msedge.exe"),...X([...Z,...Q],"BraveSoftware","Brave-Browser","Application","brave.exe")]}function w9($){try{return l1($,s1.X_OK),Z$($)&&OQ($).isFile()}catch{return!1}}function X$($,Z=process.platform){let Q=Z==="darwin"?_Q:Z==="linux"?Q$:Z==="win32"?r1():null;return Q?($??Q).find(w9)??null:null}function t1(){if(!process.versions.bun)return;let $=Symbol.for("ara.headless-browser.bun-pipe-owners");if(Object.hasOwn(globalThis,$))return;let Z=[];CQ.spawn=new Proxy(CQ.spawn,{apply(Q,X,J){let Y=Reflect.apply(Q,X,J),z=J[1],F=J[2]?.stdio;if(Array.isArray(z)&&z.includes("--remote-debugging-pipe")&&Array.isArray(F)&&F[3]==="pipe"&&F[4]==="pipe")Z.push(Y);return Y}}),Object.defineProperty(globalThis,$,{value:Z})}async function z8($){if(t1(),$!==void 0){if(!Z$($))throw Error("hands_browser_driver_path_must_be_absolute");let X=s0($,"package.json"),J=JSON.parse(n1(X,"utf8"));if(J.name!==G8.driver)throw Error("hands_browser_wrong_driver");let Y=DQ(X)($),z=Y.default?.chromium??Y.chromium;if(!z)throw Error("hands_browser_missing_chromium");return{version:J.version,chromium:z}}let[Z,Q]=await Promise.all([import("./index-z6q2j1e0.js"),import("./package-x8ct3epg.js").then((m)=>u1(m.default,1))]);return{version:Q.default.version,chromium:Z.chromium}}var e1=($,Z=G8.driverVersion)=>({status:"unavailable",reason:$,expectedDriverVersion:Z}),$7=($)=>$.loadDriver?.()??z8($.driverModuleDirectory),Z7={"1.60.0":"1223"};function u5(){let $=process.platform,Z=Z7[G8.driverVersion];if(!Z||$!=="linux"&&$!=="darwin"&&$!=="win32")return!1;let Q=(X)=>process.env[X]??process.env[`npm_config_${X.toLowerCase()}`]??process.env[`npm_package_config_${X.toLowerCase()}`];try{let X=Q("PLAYWRIGHT_BROWSERS_PATH"),J=X==="0"?s0(i1(DQ(import.meta.url).resolve("playwright-core/package.json")),".local-browsers"):X?a1(Q("INIT_CWD")||process.cwd(),X):s0($==="darwin"?s0($$(),"Library","Caches"):$==="win32"?process.env.LOCALAPPDATA||s0($$(),"AppData","Local"):process.env.XDG_CACHE_HOME||s0($$(),".cache"),"ms-playwright");return OQ(s0(J,`chromium-${Z}`,"INSTALLATION_COMPLETE")).isFile()}catch{return!1}}async function K9($={}){return AQ($,G8.driverVersion)}async function J$($,Z={}){if($.driverVersion!=="1.61.1"||!Z$($.driverModuleDirectory))throw Error("hands_browser_invalid_managed_compatibility");return AQ({...Z,driverModuleDirectory:$.driverModuleDirectory,allowSystemBrowser:!0},$.driverVersion)}async function AQ($,Z){let Q=(G)=>e1(G,Z),X=$.platform??process.platform;if(X!=="linux"&&X!=="darwin"&&X!=="win32")return Q("unsupported_platform");let J;try{J=await $7($)}catch{return Q("driver_missing")}if(J.version!==Z)return Q("driver_version_mismatch");let Y=(G,V)=>({status:"resolved",executablePath:G,source:V,driverVersion:J.version});if($.executablePath!==void 0)return w9($.executablePath)?Y($.executablePath,"configured"):Q("executable_missing");let z=J.chromium.executablePath();if(w9(z))return Y(z,"managed");let F=$.allowSystemBrowser===!0?X$($.systemCandidates,X):null;return F?Y(F,"system"):Q("executable_missing")}var B7=["/usr/local/bin/chromium",...Q$];function L7($,Z=wQ()){return X$($??(Z==="linux"?B7:void 0),Z)}async function N7(){try{return(await z8()).chromium}catch{return F7(import.meta.url)("playwright-core").chromium}}var M7=1048576,j7=105000,q7=20000,IQ=5000,C7=2000,T7=1000,O7=30000,RQ=81920,D7={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".gif":"image/gif"};async function _7($,Z){let Q=new URL($.url()),X={...await $.allHeaders(),host:Q.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 F=(Q.protocol==="https:"?H7:V7)(Q,{method:$.method(),headers:X,agent:!1,lookup:(V,B,H)=>{let K=n0.isIP(Z);if(B.all)H(null,[{address:Z,family:K}]);else H(null,Z,K)}},(V)=>{let B=[],H=0;V.on("data",(K)=>{if(H+=K.length,H>33554432)F.destroy(Error("hands_browser_response_too_large"));else B.push(K)}),V.on("error",Y),V.on("end",()=>{let K={};for(let[L,W]of Object.entries(V.headers))if(W!==void 0&&!["transfer-encoding","connection","content-length"].includes(L))K[L]=Array.isArray(W)?W.join(`
306
306
  `):W;J({status:V.statusCode??502,headers:K,body:Buffer.concat(B)})})}),G=setTimeout(()=>F.destroy(Error("hands_browser_fetch_timeout")),O7);F.once("close",()=>clearTimeout(G)),F.on("error",Y),F.end($.postDataBuffer()??void 0)})}async function A7($,Z,Q=()=>{},X={lookup:(J)=>K7(J,{all:!0}),fetch:_7}){let J=new WeakSet,Y=new WeakMap,z=(F)=>{let G=Y.get(F);if(G)return G;let V=(async()=>{if(!$.newCDPSession)return;let B=await $.newCDPSession(F),H=new Map;B.on("Network.loadingFinished",({requestId:K})=>H.delete(K)),B.on("Network.loadingFailed",({requestId:K})=>H.delete(K)),B.on("Fetch.requestPaused",async(K)=>{let L=K.networkId??K.requestId,W=K.redirectedRequestId?(H.get(L)??0)+1:0;H.set(L,W);let U=S9(K.request.url,Z),j=Z.mode==="enforce"&&Boolean(K.redirectedRequestId)&&U.host!==null&&!n0.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)Q(O),await B.send("Fetch.failRequest",{requestId:K.requestId,errorReason:"BlockedByClient"});else await B.send("Fetch.continueRequest",{requestId:K.requestId})}catch{await B.send("Fetch.failRequest",{requestId:K.requestId,errorReason:"Failed"}).catch(()=>{})}}),await B.send("Network.enable"),await B.send("Fetch.enable",{patterns:[{urlPattern:"*",requestStage:"Request"}]}),J.add(F)})();return Y.set(F,V),V};return await $.route("**/*",async(F)=>{let G=F.request().url(),V=S9(G,Z);if(V.allowed&&Z.mode==="public_web"){await F.continue();return}let B=F.request();if(V.allowed&&V.host&&n0.isIP(V.host)&&B.isNavigationRequest?.()){let H=B.frame();if(J.has(H.page())&&H===H.page().mainFrame()){await F.continue();return}}if(V.allowed&&(Z.mode==="off"||V.reason==="local_document")){await F.continue();return}if(V.allowed&&V.host)try{let H=V.host,K=l0(H),L,W=await(async()=>{if(K!=="hostname")return[{address:H,family:n0.isIP(H)}];if(V.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!n0.isIP(U)||Z.mode==="enforce"&&e8(U,Z.deniedHosts)||(V.reason==="loopback"?j!=="loopback":j!=="public")}))V={...V,allowed:!1,reason:"private_network"};else{let U=await X.fetch(F.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=S9(j,Z);V=O.allowed?{...O,allowed:!1,reason:"redirect_not_supported"}:O}else{await F.fulfill(U);return}}}catch{await F.abort("failed");return}Q(V),await F.abort("blockedbyclient")}),await $.routeWebSocket("**/*",async(F)=>{let G=S9(F.url(),Z);if(Z.mode==="enforce"&&G.allowed&&(!G.host||!n0.isIP(G.host)))G={...G,allowed:!1,reason:"destination_not_allowed"};if(G.allowed){F.connectToServer();return}Q(G),await F.close({code:1008,reason:"Reason egress policy denied"})}),Z.mode==="off"?void 0:{preparePage:z}}async function bQ($,Z=wQ(),Q){if(Q){let J=await J$(Q,{platform:Z,systemCandidates:$});return J.status==="resolved"?J.executablePath:null}if($!==void 0){let J=L7($,Z);if(J)return J}let X=await K9({platform:Z,systemCandidates:$,allowSystemBrowser:!0});return X.status==="resolved"?X.executablePath:null}function EQ($,Z){if(!$)throw Error("hands_repl_workspace_required");let Q=G$($),X=F9($),J=z$(X,F9(X,Z)),z=J!==".."&&!J.startsWith(`..${K$}`)&&!PQ(J)?F9(Q,J):F9(Q,Z);if(b0(F9(X,Z))||b0(z))throw Error("hands_repl_protected_path");let F=(W)=>{let U=z$(Q,W);return U!==""&&U!==".."&&!U.startsWith(`..${K$}`)&&!PQ(U)},G=G$(z);if(b0(G))throw Error("hands_repl_protected_path");if(!F(z)||!F(G))throw Error("hands_repl_file_outside_workspace");let V=z$(Q,z).split(K$),B=[Q,...V.map((W,U)=>F9(Q,...V.slice(0,U+1)))],H=B.map((W)=>xQ(W));if(H.some((W)=>W.isSymbolicLink()))throw Error("hands_repl_file_symlink");let K=H[H.length-1];if(!K.isFile()||K.nlink!==1||K.size>16777216)throw Error("hands_repl_file_not_regular_or_too_large");let L=Y7(z,Y$.O_RDONLY|Y$.O_NOFOLLOW|Y$.O_NONBLOCK);try{let W=J7(L);if(W.dev!==K.dev||W.ino!==K.ino||!W.isFile())throw Error("hands_repl_file_changed");for(let C=0;C<B.length;C++){let A=xQ(B[C]);if(A.dev!==H[C].dev||A.ino!==H[C].ino||A.isSymbolicLink())throw Error("hands_repl_file_changed")}if(!F(G$(z)))throw Error("hands_repl_file_outside_workspace");let U=Buffer.alloc(16777217),j=0;while(j<U.length){let C=G7(L,U,j,U.length-j,null);if(!C)break;j+=C}if(j===U.length)throw Error("hands_repl_file_too_large");let O=U.subarray(0,j);return{name:U7(z),mimeType:D7[W7(z).toLowerCase()]??"application/octet-stream",buffer:O}}finally{X7(L)}}function V9($,Z){$.end(`${JSON.stringify(Z)}
307
307
  `)}function K8($){try{z7($)}catch{}}async function kQ($){if($.managedBrowser&&$.driverModuleDirectory!==void 0)throw Error("hands_browser_ambiguous_driver_configuration");let Z=$.launch||$.targetContext?null:$.managedBrowser?await J$($.managedBrowser,{executablePath:$.browserExecutablePath}):await K9({executablePath:$.browserExecutablePath,driverModuleDirectory:$.driverModuleDirectory});if(Z?.status==="unavailable")throw Error(`hands_browser_${Z.reason}`);let Q=Z?.status==="resolved"?Z.executablePath:$.browserExecutablePath;if(!Q||!w9(Q))throw Error("hands_browser_unavailable");let X=$.launch??(async(N)=>($.targetContext?await N7():(await z8($.managedBrowser?.driverModuleDirectory??$.driverModuleDirectory)).chromium).launch(N)),J=[],Y={},z=null,F=null,G=null,V=null,B=!1,H=null,K=new Map,L=new WeakMap,W=null,U=()=>{if(B)throw Error("hands_repl_stopped");if(V)throw V},j=(N)=>{let M=L.get(N);if(M)return M;let D=Promise.resolve().then(()=>N.close()).then(()=>{K.delete(N)});return L.set(N,D),D},O=async()=>{let N=[...K.entries()].reverse(),M=W??=performance.now()+T7,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[_,y]of k.entries()){if(y.status!=="rejected")continue;let c=y.reason instanceof Error&&["Error","TimeoutError","ProtocolError"].includes(y.reason.name)?y.reason.name:"unknown";f.push(Error(`hands_repl_close_failed: ${N[_][1]}: ${c}`))}if(f.length)throw AggregateError(f,"hands_repl_stop_unconfirmed")},C=(N,M)=>{if(K.set(N,M),B||V)j(N).catch(()=>{return}),U();return N},A=async()=>{let N=await X({executablePath:Q,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{C(N,"browser"),M=$.targetContext??C(await N.newContext({viewport:{width:1440,height:900},screen:{width:1440,height:900},serviceWorkers:"block",acceptDownloads:!1}),"context");let D=await A7(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:{},n,G0="image/png";if(Buffer.isBuffer(b)||b instanceof Uint8Array)n=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)))n=Buffer.from(b.replace(/^data:[^,]*,/,""),"base64");else if(typeof b==="string"){let T0=EQ($.workspaceRoot,b);n=T0.buffer,G0=T0.mimeType}else throw Error("view() needs a Buffer, a base64 string, or a path to an image file");if(n.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,g0=$.targetContext?await N.newPage():await M.newPage();try{let T0=`data:${G0};base64,${n.toString("base64")}`;for(let t=0;t<5;t+=1){let j0=await g0.evaluate(async(B0)=>{let q0=new Image;q0.src=B0.url,await q0.decode();let h0=Math.min(1,B0.maxWidth/q0.naturalWidth),Y0=document.createElement("canvas");Y0.width=Math.max(1,Math.round(q0.naturalWidth*h0)),Y0.height=Math.max(1,Math.round(q0.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(q0,0,0,Y0.width,Y0.height),{data:Y0.toDataURL("image/jpeg",B0.q/100).split(",")[1]??"",width:Y0.width,height:Y0.height,sourceWidth:q0.naturalWidth,sourceHeight:q0.naturalHeight}},{url:T0,maxWidth:U0,q:W0}),e0=Buffer.from(j0.data,"base64");if(e0.length<=RQ){let B0=M0||"image";return`<<<ARA_VIEW_IMAGE ${j0.data} image/jpeg ${B0}>>>
308
308
  Viewing ${B0} (${j0.sourceWidth}x${j0.sourceHeight} source, sent at ${j0.width}x${j0.height}, ${Math.round(e0.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(RQ/1024)}KB`)}finally{await g0.close().catch(()=>{return})}},y=WQ({browser:$.targetContext?.browser()??N,context:M,page:k,a11y:f,view:_,readWorkspaceFile:(b)=>EQ($.workspaceRoot,b),privateProfile:$.privateProfile,beforeNavigation:$.beforeNavigation,recording:$.recording,screenshotExport:$.screenshotExport,actionRecorder:()=>{let b=J,h=Y;return(d,n)=>{if(b.length<SQ)b.push(d);if(n)h.page=n}}}),c=async(b)=>{U();let h=C(await N.newContext({serviceWorkers:"block",acceptDownloads:!1}),"context");try{await h.route("**/*",(n)=>n.abort()),U(),await h.routeWebSocket("**/*",(n)=>n.close({code:1008,reason:"Reason evaluator network denied"})),U(),await h.exposeBinding("__araHandsRpc",async(n,G0)=>$.onBrowserOperation?$.onBrowserOperation(b,()=>y.dispatch(G0)):y.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(`(${XQ})(${JSON.stringify(y.roots)})`),{context:h,page:d,runId:b}}catch(d){throw await j(h).catch(()=>{return}),d}},u=await c(),r={browser:N,context:M,page:k,evaluator:u,async captureProgressFrame(b){return _(await b.screenshot({type:"jpeg",quality:65,timeout:2000}),{label:"Screen after browser action"})},async resetEvaluator(b){await j(r.evaluator.context),r.evaluator=await c(b)}};return U(),r}catch(D){throw await O().catch(()=>{return}),D}},R=async()=>{if(U(),z)return z;if(!G){F=A();let N;G=Promise.race([F,new Promise((M,D)=>{N=setTimeout(()=>D(Error("hands_browser_unavailable: startup timed out")),q7)})]).then((M)=>{return U(),z=M,M}).catch(async()=>{V=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")),IQ)})])}catch{V=Error("hands_browser_unavailable: startup cleanup unconfirmed")}finally{if(M)clearTimeout(M)}throw V}).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 u=await w.evaluator.page.evaluate(`(${JQ})(${JSON.stringify({code:N})})`);if(typeof u!=="string")throw Error("hands_repl_invalid_evaluator_output");let r=k.page;if(D&&r&&!u.includes("<<<ARA_VIEW_IMAGE")){let b=()=>w.captureProgressFrame(r);try{let h=await($.onBrowserOperation?$.onBrowserOperation(M,b):b());return k.automaticProgressImage=!0,`${u}
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Cc as v,xc as q}from"./vm-hands-entry-lite-mc3pkj0q.js";function A(j=process.platform){if(q(),j==="linux"||j==="win32")v("strict")}
2
+ import{Cc as v,xc as q}from"./vm-hands-entry-lite-v0kpksbf.js";function A(j=process.platform){if(q(),j==="linux"||j==="win32")v("strict")}
3
3
  export{A as r};