@reason-machines/cli-linux-x64 0.2.388 → 0.2.390
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.
- package/bin/ara +2 -2
- package/bin/vm-hands/api-2edgrjpe.js +2 -0
- package/bin/vm-hands/api-credentials-1bfy2pqp.js +2 -0
- package/bin/vm-hands/{ask-relay-rpekz0vc.js → ask-relay-fhcfxc8e.js} +3 -3
- package/bin/vm-hands/connect-cli-9aczr82r.js +2 -0
- package/bin/vm-hands/{custom-endpoint-device-baqm3872.js → custom-endpoint-device-3g0rc3wp.js} +1 -1
- package/bin/vm-hands/desktop-account-8yf4aqgb.js +2 -0
- package/bin/vm-hands/{device-workspace-0kk5ef85.js → device-workspace-35hjc1ff.js} +1 -1
- package/bin/vm-hands/{hands-worker-source-mshf7c6v.js → hands-worker-source-msdkfx9x.js} +1 -1
- package/bin/vm-hands/{index-cvnymkkb.js → index-m32pjcjr.js} +1 -1
- package/bin/vm-hands/{install-receipt-352cy8vj.js → install-receipt-7qanbz38.js} +1 -1
- package/bin/vm-hands/local-automation-dcqf14d4.js +2 -0
- package/bin/vm-hands/local-capabilities-pv3gr2hy.js +2 -0
- package/bin/vm-hands/local-desktop-users-p6n48895.js +2 -0
- package/bin/vm-hands/local-display-mac-7havkbhd.js +2 -0
- package/bin/vm-hands/local-display-session-gnx1pp3w.js +2 -0
- package/bin/vm-hands/local-pty-session-8ny1n2fv.js +2 -0
- package/bin/vm-hands/{managed-runtime-wzk0q157.js → managed-runtime-7zsf50b5.js} +1 -1
- package/bin/vm-hands/network-contract-3h853c6e.js +2 -0
- package/bin/vm-hands/package-04cf0m62.js +2 -0
- package/bin/vm-hands/permissions-dsmaj350.js +2 -0
- package/bin/vm-hands/{reason-hands-protocol-z95pxxbh.js → reason-hands-protocol-mw7ba8vz.js} +1 -1
- package/bin/vm-hands/{serve-service-d2q1pdxh.js → serve-service-qax96kty.js} +1 -1
- package/bin/vm-hands/{status-x8g58cxm.js → status-1v4paztv.js} +2 -2
- package/bin/vm-hands/version-8eeqhkse.js +2 -0
- package/bin/vm-hands/{vm-hands-entry-lite-jx3w1z5q.js → vm-hands-entry-lite-00800vjk.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-v2ptg6br.js → vm-hands-entry-lite-02zaqpgh.js} +5 -5
- package/bin/vm-hands/{vm-hands-entry-lite-zr8gf6nd.js → vm-hands-entry-lite-0seprnh3.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-qnnfvm5r.js → vm-hands-entry-lite-0z73amf7.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-y55f8dyw.js → vm-hands-entry-lite-180h5amj.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-pk3q774c.js → vm-hands-entry-lite-3nr9q3nf.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-b1ygrkbq.js → vm-hands-entry-lite-3ptq7p60.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-fyvgav60.js → vm-hands-entry-lite-5x04hakp.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-yzaz1e8r.js → vm-hands-entry-lite-6t0a7k6v.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-zs3jsffv.js → vm-hands-entry-lite-7s9z3tdn.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-stbfyev7.js → vm-hands-entry-lite-88h9vwrv.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-f89wk20p.js → vm-hands-entry-lite-8e932j3c.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-e05sgnwe.js → vm-hands-entry-lite-8pgggvbb.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-ammr3xbc.js → vm-hands-entry-lite-a1yy1yp3.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-289qftes.js → vm-hands-entry-lite-adpzn7fe.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-mbs7d7ye.js → vm-hands-entry-lite-atg4z1vg.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-y2s2w174.js → vm-hands-entry-lite-bwpay74g.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-e2mjbqmr.js → vm-hands-entry-lite-csecgmaa.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-spccx392.js → vm-hands-entry-lite-e73s63fb.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-p6g561rq.js → vm-hands-entry-lite-ebgackey.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-d7cvwy3k.js → vm-hands-entry-lite-ecsgqm1s.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-ezahexcb.js +5 -0
- package/bin/vm-hands/{vm-hands-entry-lite-grjkhbf2.js → vm-hands-entry-lite-f78n4wqt.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-te0p47ak.js → vm-hands-entry-lite-fb02h1zm.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-fw5ztpwn.js → vm-hands-entry-lite-g87z5eb6.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-6shgavn0.js → vm-hands-entry-lite-gq3bzj7d.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-s7k376cz.js → vm-hands-entry-lite-h0keewxv.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-fb5dzy9x.js → vm-hands-entry-lite-hfv2tsm9.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-3vb4he21.js → vm-hands-entry-lite-hp0ccw3e.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-jjgqsan6.js → vm-hands-entry-lite-jsbgswhd.js} +3 -3
- package/bin/vm-hands/{vm-hands-entry-lite-ma001vzh.js → vm-hands-entry-lite-ksz1k1dh.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-kb981w39.js → vm-hands-entry-lite-mc3pkj0q.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-sex82vb1.js → vm-hands-entry-lite-mft9ke08.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-9fc26f9c.js → vm-hands-entry-lite-n11e88ty.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-sb7n76g7.js → vm-hands-entry-lite-p1s0xyc2.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-n25efwqt.js → vm-hands-entry-lite-r166b92s.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-6tv7j3ej.js → vm-hands-entry-lite-rnmy7f5e.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-sv8bb7jq.js → vm-hands-entry-lite-rxg5nf73.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-nf0avf46.js → vm-hands-entry-lite-t6dxxwc8.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-30rnhzfj.js → vm-hands-entry-lite-trm3dn8c.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-r7czqrtj.js → vm-hands-entry-lite-wjwwzxej.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-2e18tm6w.js → vm-hands-entry-lite-wpcagqfw.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-nr1narzb.js → vm-hands-entry-lite-y99g8x7f.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-axe84b1n.js → vm-hands-entry-lite-zd5pw8gj.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite.js +1 -1
- package/bin/vm-hands/{vm-hands-executor-j4q5snaz.js → vm-hands-executor-zsepc201.js} +1 -1
- package/bin/vm-hands/vm-hands-op-runner-sfhzq9bc.js +2 -0
- package/bin/vm-hands/vm-hands-runtime-r0y0c22t.js +4 -0
- package/bin/vm-hands/worker-sandbox-nnk7fq89.js +2 -0
- package/package.json +1 -1
- package/bin/vm-hands/api-9jsc2wk3.js +0 -2
- package/bin/vm-hands/api-credentials-jhaxk9e6.js +0 -2
- package/bin/vm-hands/connect-cli-xk4wx40j.js +0 -2
- package/bin/vm-hands/desktop-account-374pyd2h.js +0 -2
- package/bin/vm-hands/local-automation-fqf1yxn8.js +0 -2
- package/bin/vm-hands/local-capabilities-0xqv6w37.js +0 -2
- package/bin/vm-hands/local-desktop-users-39d8h875.js +0 -2
- package/bin/vm-hands/local-display-mac-yt4tpb96.js +0 -2
- package/bin/vm-hands/local-display-session-12q3s3p1.js +0 -2
- package/bin/vm-hands/local-pty-session-142rrpf9.js +0 -2
- package/bin/vm-hands/network-contract-m55ndrgk.js +0 -2
- package/bin/vm-hands/package-k4xz7vcr.js +0 -2
- package/bin/vm-hands/permissions-zajmtjzs.js +0 -2
- package/bin/vm-hands/version-55234k7v.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-wzqzjd6f.js +0 -5
- package/bin/vm-hands/vm-hands-op-runner-btwvjt4p.js +0 -2
- package/bin/vm-hands/vm-hands-runtime-gw2wdm13.js +0 -4
- package/bin/vm-hands/worker-sandbox-r41yz175.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
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) {
|
|
3
3
|
repository(owner: $owner, name: $repo) {
|
|
4
4
|
nameWithOwner
|
|
5
5
|
pullRequest(number: $number) {
|
|
@@ -34,9 +34,9 @@ import{ik as W}from"./vm-hands-entry-lite-e05sgnwe.js";var T=W.string().max(201)
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
}`;function zQ(Q){return Q.kind==="read"||Q.kind==="pr_review_context"}var b=["inspect_project","fs.read","fs.write","fs.search","fs.watch","fs.upload","fs.export","fs.import","fs.download","exec.run","exec.full","process.run.v1","process.full.v1","pty.start","pty.input","pty.resize","pty.close","git.run","process.list","process.signal","ports.list","tunnel.open","tunnel.close","env.discover","setup.run","mcp.discover","mcp.start","mcp.proxy","browser.snapshot","browser.navigate","browser.act","computer.snapshot","computer.act","computer.use","browser.use","browser.recording.v1","browser.pr-proof.v1","hands.connect","jobs.control","environment.install","github.local.v1","inference.ollama.v1","inference.custom.v1","delegate.devin.copy.v1","delegate.cursor.copy.v1","display.stream.v1","automation.call.v1","preview.serve.v1","workspace.setup.v1","simulator.call.v1","simulator.stream.v1"];var j=2,I="/app/local-runtime",n=262144,HQ="x-reason-relay-host-alias",XQ="v1";function F(Q,Z){return{path:`${I}${Q}`,routerPath:Q,auth:Z}}function g(Q,Z){return{...F(Q,"device_proof"),forOperation($){return F(`/operations/${encodeURIComponent($)}${Z}`,"device_proof")}}}var GQ={register:F("/register","registration_bearer"),enroll:F("/enroll","none"),authChallenge:F("/auth/challenge","none"),identity:F("/identity","device_proof"),heartbeat:F("/heartbeat","device_proof"),rootsSync:F("/roots/sync","device_proof"),disconnect:F("/disconnect","device_proof"),lifecycle:F("/lifecycle","device_proof"),localSubscription:F("/local-subscription","device_proof"),ownerWorkspaces:F("/owner-workspaces","device_proof"),ownerWorkspaceEnrollment:F("/owner-workspaces/enrollment","device_proof"),sessionWorktrees:F("/session-worktrees","device_proof"),operationClaim:F("/operations/claim","device_proof"),operationHeartbeat:g("/operations/:operationId/heartbeat","/heartbeat"),operationEvents:g("/operations/:operationId/events","/events"),operationComplete:g("/operations/:operationId/complete","/complete"),operationEnvironment:g("/operations/:operationId/environment","/environment"),operationEnvironmentAck:g("/operations/:operationId/environment-ack","/environment-ack"),operationCustomEndpointCredential:g("/operations/:operationId/custom-endpoint-credential","/custom-endpoint-credential")},BQ=`${I}/session`,MQ=4096,gQ=5000,o=[/^\/app\/local-runtime\/heartbeat$/,/^\/app\/local-runtime\/operations\/claim$/,/^\/app\/local-runtime\/operations\/[0-9a-fA-F-]{36}\/(?:heartbeat|events|complete|environment|environment-ack)$/];function qQ(Q){return o.some((Z)=>Z.test(Q))}var NQ="vm_hands_v1",mQ=60000,UQ={unauthenticated:4401,unavailable:4404,overloaded:4429,serviceRestart:1012},jQ="hands_control_v1",xQ="environment.deliver",JQ="vm_hands_workspace_deferred",SQ="vm_hands.workspace_grant",IQ="
|
|
37
|
+
}`;function zQ(Q){return Q.kind==="read"||Q.kind==="pr_review_context"}var b=["inspect_project","fs.read","fs.write","fs.search","fs.watch","fs.upload","fs.export","fs.import","fs.download","exec.run","exec.full","process.run.v1","process.full.v1","pty.start","pty.input","pty.resize","pty.close","git.run","process.list","process.signal","ports.list","tunnel.open","tunnel.close","env.discover","setup.run","mcp.discover","mcp.start","mcp.proxy","browser.snapshot","browser.navigate","browser.act","computer.snapshot","computer.act","computer.use","browser.use","browser.recording.v1","browser.pr-proof.v1","hands.connect","jobs.control","environment.install","github.local.v1","inference.ollama.v1","inference.custom.v1","delegate.devin.copy.v1","delegate.cursor.copy.v1","display.stream.v1","automation.call.v1","preview.serve.v1","workspace.setup.v1","simulator.call.v1","simulator.stream.v1"];var j=2,I="/app/local-runtime",n=262144,HQ="x-reason-relay-host-alias",XQ="v1";function F(Q,Z){return{path:`${I}${Q}`,routerPath:Q,auth:Z}}function g(Q,Z){return{...F(Q,"device_proof"),forOperation($){return F(`/operations/${encodeURIComponent($)}${Z}`,"device_proof")}}}var GQ={register:F("/register","registration_bearer"),enroll:F("/enroll","none"),authChallenge:F("/auth/challenge","none"),identity:F("/identity","device_proof"),heartbeat:F("/heartbeat","device_proof"),rootsSync:F("/roots/sync","device_proof"),disconnect:F("/disconnect","device_proof"),lifecycle:F("/lifecycle","device_proof"),localSubscription:F("/local-subscription","device_proof"),ownerWorkspaces:F("/owner-workspaces","device_proof"),ownerWorkspaceEnrollment:F("/owner-workspaces/enrollment","device_proof"),sessionWorktrees:F("/session-worktrees","device_proof"),operationClaim:F("/operations/claim","device_proof"),operationHeartbeat:g("/operations/:operationId/heartbeat","/heartbeat"),operationEvents:g("/operations/:operationId/events","/events"),operationComplete:g("/operations/:operationId/complete","/complete"),operationEnvironment:g("/operations/:operationId/environment","/environment"),operationEnvironmentAck:g("/operations/:operationId/environment-ack","/environment-ack"),operationCustomEndpointCredential:g("/operations/:operationId/custom-endpoint-credential","/custom-endpoint-credential")},BQ=`${I}/session`,MQ=4096,gQ=5000,o=[/^\/app\/local-runtime\/heartbeat$/,/^\/app\/local-runtime\/operations\/claim$/,/^\/app\/local-runtime\/operations\/[0-9a-fA-F-]{36}\/(?:heartbeat|events|complete|environment|environment-ack)$/];function qQ(Q){return o.some((Z)=>Z.test(Q))}var NQ="vm_hands_v1",mQ=60000,UQ={unauthenticated:4401,unavailable:4404,overloaded:4429,serviceRestart:1012},jQ="hands_control_v1",xQ="environment.deliver",JQ="vm_hands_workspace_deferred",SQ="vm_hands.workspace_grant",IQ="hands.unbind_unverified",PQ="claim_v1",TQ="environment_at_claim",CQ="rebind_v1",AQ="resident_rebind",bQ="hands.rebind",EQ="snapshot_v1",kQ="cloud_access",LQ="playwright_v1",fQ="headless_browser",_Q="v1",cQ="job_env_large_values",yQ="srt_root_v1",dQ="hands_confinement",OQ="gid_v1",hQ="model_jobs_egress",RQ="setpriv_v1",rQ="jobs_user",pQ="spawning_attempt_v1",nQ="hands_session_group",oQ="session_cap",sQ="none",iQ="same_launch_v1",tQ="exit_v1",vQ="start_wait",lQ="user_chrome",uQ="cloud_sessions";function S(Q){if(!K(Q)||Object.keys(Q).length!==5||Q.version!==1)return!1;let Z=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return["boot_generation","recording_operation_id","recording_attempt_id"].every(($)=>typeof Q[$]==="string"&&Z.test(Q[$]))&&typeof Q.root_version==="string"&&/^[0-9]{1,20}(?:\.[0-9]{1,6})?$/.test(Q.root_version)}function U(Q){if(!K(Q)||Object.keys(Q).length!==6)return!1;let Z=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return typeof Q.device_id==="string"&&Z.test(Q.device_id)&&(Q.binding==="workspace_source"||Q.binding==="mcp_control")&&Number.isSafeInteger(Q.target_revision)&&Number(Q.target_revision)>=0&&Number.isSafeInteger(Q.root_grant_revision)&&Number(Q.root_grant_revision)>0&&Number.isSafeInteger(Q.target_generation)&&Number(Q.target_generation)>0&&typeof Q.target_fence_id==="string"&&Z.test(Q.target_fence_id)}var aQ=["lock_acquired","enrollment_started","enrollment_completed","readiness_started","readiness_completed","inventory_completed","control_ready"],eQ=86400000,QW=["service.install_started","service.install_completed","service.install_failed","service.launcher_adopted","service.launcher_conflict","service.started","service.reconnecting","service.reconnected","service.idle_sleep_held","service.idle_sleep_released","service.idle_sleep_failed","service.start_failed","service.stopped","service.exit_failed","service.singleton_rejected","credential.migration_started","credential.migration_completed","credential.migration_failed","credential.store_started","credential.store_completed","credential.store_failed","credential.delete_started","credential.delete_completed","credential.delete_failed","update.check_started","update.not_available","update.download_started","update.downloaded","update.verified","update.activated","update.rollback","update.failed","executor.update.check_started","executor.update.not_available","executor.update.download_started","executor.update.downloaded","executor.update.verified","executor.update.activated","executor.update.rollback","executor.update.failed","identity.refresh_completed","identity.refresh_failed","update.device_moved","update.components_installed","update.deferred","update.deferral_expired","worker.previous_exit","worker.capabilities_withheld","identity.computer_use_unavailable"],s=["production","staging"];function E(Q){if(!K(Q)||Object.keys(Q).length!==3)return!1;let Z=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return["organization_id","user_id","device_id"].every(($)=>Object.hasOwn(Q,$)&&typeof Q[$]==="string"&&Z.test(Q[$])&&Q[$]!=="00000000-0000-0000-0000-000000000000")}var i="DEVICE-PROOF-V2",WW="ARA-DEVICE-V1";function ZW(Q,Z=i){let $=Q.method.toUpperCase();if(!/^[A-Z]+$/.test($)||!Q.pathAndQuery.startsWith(`${I}/`)||Q.pathAndQuery.includes(`
|
|
38
38
|
`)||!/^[0-9]{1,20}$/.test(Q.timestamp)||!/^[A-Za-z0-9_-]{22,43}$/.test(Q.nonce)||Q.challenge.length<16||Q.challenge.length>1024||Q.challenge.includes(`
|
|
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
|
-
`),"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
|
|
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
|
|
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,
|
|
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
|
+
`)||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};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Cc as v,xc as q}from"./vm-hands-entry-lite-
|
|
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")}
|
|
3
3
|
export{A as r};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{mi as A,ni as x,oi as u,xi as y}from"./vm-hands-entry-lite-csecgmaa.js";import{Di as c}from"./vm-hands-entry-lite-ksz1k1dh.js";import{randomUUID as m}from"crypto";import{chmodSync as l,existsSync as p,mkdirSync as jJ,readlinkSync as YJ,readFileSync as GJ,renameSync as OJ,unlinkSync as VJ,writeFileSync as FJ}from"fs";import{homedir as d}from"os";import{basename as P,dirname as H,isAbsolute as v,join as I,normalize as n,relative as HJ,resolve as LJ}from"path";import{unlinkSync as WJ}from"fs";import{dirname as XJ,join as ZJ}from"path";function $J(J){return ZJ(XJ(J),"future-device-grant.json")}function o(J){try{WJ($J(J))}catch(Q){if(!(Q instanceof Error&&("code"in Q)&&Q.code==="ENOENT"))throw Q}}var N=3,NJ=1,TJ=2,D=1,a=1,r="Reason may read and write files and run commands in this signed-in OS account, subject to saved restrictions and operating system permissions.",b="Reason may later execute on this computer inside a Reason sandbox, limited to folders explicitly attached by the user.",zJ=[b,"Ara may later execute on this computer inside an Ara sandbox, limited to folders explicitly attached by the user."];function i(J){return typeof J==="string"&&zJ.includes(J)}var BJ=["future_device","updates_only","cli_only"];function h(J){return typeof J==="string"&&BJ.some((Q)=>Q===J)}function SJ(J=process.env,Q=d()){return J.XDG_CONFIG_HOME?.trim()||I(Q,".config")}function K(J=process.env,Q=d()){let U=x({env:J}),W=SJ(J,Q);return I(W,y(W).state==="kept"?"ara":"reason",...U==="staging"?["staging"]:[],"installation.json")}function G(J){return typeof J==="string"&&J.trim().length>0}var _J=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function IJ(J){return typeof J==="string"&&_J.test(J)}function C(J){return G(J)&&v(J)&&n(J)===J}function t(J){if(!J||typeof J!=="object"||Array.isArray(J))return!1;let Q=J;return C(Q.path)&&(Q.role==="launcher"&&(Q.kind==="file"||Q.kind==="symlink")||Q.role==="worker_root"&&Q.kind==="directory"||Q.role==="alias"&&Q.kind==="symlink"&&C(Q.target))}function g(J){return J.owned_paths?.every((Q)=>Q.role!=="alias"||J.installer==="shell"&&Q.path===I(J.install_dir,J.channel==="staging"?"reason-staging":"reason")&&Q.target===I(J.install_dir,J.channel==="staging"?"ara-staging":"ara")&&J.owned_paths?.some((U)=>U.role==="launcher"&&U.path===Q.target))??!1}function e(J,Q){try{return LJ(H(J),YJ(J))===Q}catch{return!1}}function vJ(J){let Q=P(J),U=Q==="ara"?"reason":Q==="ara-staging"?"reason-staging":null;if(!U)return J;let W=I(H(J),U);return e(W,J)?W:J}function M(J,Q){let U=HJ(J,Q);return U.length>0&&!U.startsWith("..")&&!v(U)}function JJ(J){if(J===null)return!0;if(!J||typeof J!=="object"||Array.isArray(J))return!1;let Q=J;return(Q.kind==="shell_profile"||Q.kind==="windows_user_path")&&G(Q.location)&&G(Q.value)&&(typeof Q.added_by_installer==="boolean"||typeof Q.added_by_ara==="boolean")&&(Q.added_by_installer===void 0||typeof Q.added_by_installer==="boolean")&&(Q.added_by_ara===void 0||typeof Q.added_by_ara==="boolean")}function q(J){return J.added_by_installer??J.added_by_ara??!1}function QJ(J,Q){if(Q===null)return J==="cli_only";if(!Q||typeof Q!=="object"||Array.isArray(Q))return!1;let U=Q;if(U.version!==D||!G(U.recorded_at))return!1;if(J==="future_device")return U.decision==="authorized"&&i(U.scope);return U.scope===null&&U.decision===(J==="updates_only"?"ask":"disabled")}function AJ(J){if(!J||typeof J!=="object"||Array.isArray(J))return null;let Q=J;if(Q.schema_version!==NJ||!A.includes(Q.channel)||Q.install_method!=="curl"||Q.installer!=="shell"&&Q.installer!=="powershell"||!G(Q.installed_at)||!G(Q.version)||!G(Q.target)||!C(Q.install_dir)||!Array.isArray(Q.owned_paths)||!Q.owned_paths.every(t)||!Q.owned_paths.every((U)=>M(Q.install_dir,U.path))||!g(Q)||!JJ(Q.path_entry))return null;return{...Q,schema_version:N,installation_id:null,background_mode:"cli_only",device_consent:null}}function DJ(J){if(!J||typeof J!=="object"||Array.isArray(J))return null;let Q=J;if(Q.schema_version!==TJ||!UJ(Q)||!h(Q.background_mode)||!QJ(Q.background_mode,Q.device_consent))return null;return{...Q,schema_version:N,installation_id:null}}function UJ(J){return A.includes(J.channel)&&(J.install_method==="curl"&&(J.installer==="shell"||J.installer==="powershell")||J.install_method==="desktop"&&J.installer==="desktop"&&Array.isArray(J.owned_paths)&&J.owned_paths.length===0&&J.path_entry===null)&&G(J.installed_at)&&G(J.version)&&G(J.target)&&C(J.install_dir)&&Array.isArray(J.owned_paths)&&J.owned_paths.every(t)&&J.owned_paths.every((Q)=>M(J.install_dir,Q.path))&&g(J)&&JJ(J.path_entry)}function KJ(J){let Q=AJ(J);if(Q)return Q;let U=DJ(J);if(U)return U;if(!J||typeof J!=="object"||Array.isArray(J))return null;let W=J;if(W.schema_version!==N||!IJ(W.installation_id)||!UJ(W)||!h(W.background_mode)||!QJ(W.background_mode,W.device_consent)||W.desktop_account_access!==void 0&&(W.desktop_account_access===null||typeof W.desktop_account_access!=="object"||Array.isArray(W.desktop_account_access)||W.desktop_account_access.version!==a||W.desktop_account_access.scope!==r||!G(W.desktop_account_access.recorded_at)||!Number.isFinite(Date.parse(W.desktop_account_access.recorded_at))))return null;return W}function E(J=K()){if(!p(J))return null;try{return KJ(JSON.parse(GJ(J,"utf8")))}catch{return null}}function f(J){return Boolean(J?.installation_id&&J.background_mode==="future_device"&&J.device_consent?.version===D&&J.device_consent.decision==="authorized"&&i(J.device_consent.scope))}function s(J,Q){let U=E(Q);if(!(f(U)&&f(J)&&U.installation_id===J.installation_id&&U.channel===J.channel))o(Q);jJ(H(Q),{recursive:!0,mode:448}),l(H(Q),448);let X=`${Q}.${process.pid}.${m()}.tmp`;try{FJ(X,`${JSON.stringify(J,null,2)}
|
|
3
3
|
`,{mode:384,flag:"wx"}),l(X,384),OJ(X,Q)}finally{if(p(X))VJ(X)}let Y=H(Q),$=P(Y)==="staging"?H(Y):Y;if(P($)==="reason")y(H($));return J}function RJ(J=K(),Q=new Date){let U=E(J);if(!U?.installation_id)throw Error("Reason installation ownership is missing; reinstall the current CLI before enabling Device execution");if(f(U))return U;let W={...U,background_mode:"future_device",device_consent:{version:D,decision:"authorized",scope:b,recorded_at:Q.toISOString()}};return delete W.desktop_account_access,s(W,J)}function hJ(J,Q=K(),U=new Date){if(!A.includes(J.channel))throw Error("invalid installation channel");if(!J.version.trim())throw Error("installation version is required");if(!J.target.trim())throw Error("installation target is required");let W=_(J.installDir,"install directory"),X=E(Q);if(X?.installation_id&&!J.accountAccess)return RJ(Q,U);return s({...X??{schema_version:N,channel:J.channel,install_method:"desktop",installer:"desktop",installed_at:U.toISOString(),version:J.version.trim(),target:J.target.trim(),install_dir:W,owned_paths:[],path_entry:null},schema_version:N,installation_id:X?.installation_id??m(),background_mode:"future_device",...J.accountAccess?{desktop_account_access:{version:a,scope:r,recorded_at:U.toISOString()}}:{},device_consent:{version:D,decision:"authorized",scope:b,recorded_at:U.toISOString()}},Q)}function qJ(J,Q){return J.kind===Q.kind&&J.location===Q.location&&J.value===Q.value}function _(J,Q){let U=n(J);if(!v(U))throw Error(`${Q} must be an absolute path`);return U}function CJ(J,Q=K(),U=new Date){if(!A.includes(J.channel))throw Error("invalid installation channel");if(!J.version.trim())throw Error("installation version is required");if(!J.target.trim())throw Error("installation target is required");let W=_(J.install_dir,"install directory"),X=E(Q),Y=J.backgroundMode??"preserve",$=Y==="preserve"?X?.background_mode??"cli_only":Y,L=X?.channel===J.channel&&f(X)&&$==="future_device",T=Y==="preserve"&&!X||X?.channel===J.channel&&(Y==="preserve"||L),O={path:_(J.launcherPath,"launcher path"),kind:J.launcherKind,role:"launcher"};if(!M(W,O.path))throw Error("launcher path must be inside the install directory");let z=(J.workerRoots??[]).map((j)=>_(j,"worker root"));if(z.some((j)=>!M(W,j)))throw Error("worker root must be inside the install directory");let B=[];if(J.aliasPath){let j={path:_(J.aliasPath,"alias path"),kind:"symlink",role:"alias",target:O.path};if(!g({installer:J.installer,channel:J.channel,install_dir:W,owned_paths:[O,j]})||!e(j.path,j.target))throw Error("alias must be the channel's symlink to its canonical launcher");B.push(j)}let R=[...X?.channel===J.channel&&X.install_dir===W?X.owned_paths:[],O,...B,...z.map((j)=>({path:j,kind:"directory",role:"worker_root"}))],k=Array.from(new Map(R.map((j)=>[j.path,j])).values()),Z=J.pathEntry??null,F=Z?X?.path_entry&&qJ(Z,X.path_entry)?{...Z,added_by_installer:q(Z)||q(X.path_entry),added_by_ara:q(Z)||q(X.path_entry)}:Z:X?.path_entry??null,S={schema_version:N,installation_id:X?.installation_id??m(),channel:J.channel,install_method:"curl",installer:J.installer,installed_at:U.toISOString(),version:J.version.trim(),target:J.target.trim(),install_dir:W,owned_paths:k,path_entry:F,background_mode:$,device_consent:T?X?.device_consent??null:{version:D,decision:$==="future_device"?"authorized":$==="updates_only"?"ask":"disabled",scope:$==="future_device"?b:null,recorded_at:U.toISOString()},...L&&X.desktop_account_access?{desktop_account_access:X.desktop_account_access}:{}};return s(S,Q)}function w(J,Q){let U=J.indexOf(Q);if(U===-1)return;let W=J[U+1];if(!W||W.startsWith("--"))throw Error(`${Q} needs a value`);return W}function V(J,Q){let U=w(J,Q);if(!U)throw Error(`${Q} is required`);return U}function gJ(J,Q={}){let U=Q.io??{stdout:process.stdout,stderr:process.stderr};try{let W=new Set(["--channel","--installer","--version","--target","--install-dir","--launcher-path","--launcher-kind","--worker-root","--path-kind","--path-location","--path-value","--background-mode"]);for(let Z=0;Z<J.length;Z+=1){let F=J[Z];if(F==="--path-added")continue;if(!W.has(F))throw Error(`unknown option: ${F}`);if(Z+=1,Z>=J.length)throw Error(`${F} needs a value`)}let X=Q.env??process.env,Y=V(J,"--channel"),$=x({env:X,executablePath:Q.executablePath});if(Y!==$)throw Error(`installer channel ${Y} does not match running ${$} CLI`);let L=V(J,"--installer");if(L!=="shell"&&L!=="powershell")throw Error("--installer must be shell or powershell");let T=V(J,"--launcher-kind");if(T!=="file"&&T!=="symlink")throw Error("--launcher-kind must be file or symlink");let O=w(J,"--path-kind"),z=null;if(O){if(O!=="shell_profile"&&O!=="windows_user_path")throw Error("--path-kind must be shell_profile or windows_user_path");z={kind:O,location:V(J,"--path-location"),value:V(J,"--path-value"),added_by_installer:J.includes("--path-added"),added_by_ara:J.includes("--path-added")}}else if(J.includes("--path-location")||J.includes("--path-value")||J.includes("--path-added"))throw Error("path entry flags require --path-kind");let B={channel:$,install_method:"curl",installer:L,version:V(J,"--version"),target:V(J,"--target"),install_dir:V(J,"--install-dir"),launcherPath:V(J,"--launcher-path"),launcherKind:T,workerRoots:J.flatMap((Z,F)=>{if(Z!=="--worker-root")return[];let S=J[F+1];if(!S||S.startsWith("--"))throw Error("--worker-root needs a value");return[S]}),pathEntry:z,backgroundMode:(()=>{let Z=w(J,"--background-mode")??"preserve";if(Z!=="preserve"&&!h(Z))throw Error("--background-mode must be future_device, updates_only, cli_only, or preserve");return Z})()},R=c(X,"REASON_INSTALL_ALIAS_PATH");if(R)B.aliasPath=R;let k=K(u(X,$),Q.home??d());return(Q.writeReceipt??CJ)(B,k,Q.now?.()??new Date),0}catch(W){return U.stderr.write(`Reason installer receipt: ${W instanceof Error?W.message:String(W)}
|
|
4
4
|
`),1}}
|
|
5
5
|
export{N as ge,D as he,a as ie,r as je,b as ke,BJ as le,SJ as me,K as ne,e as oe,vJ as pe,q as qe,KJ as re,E as se,f as te,RJ as ue,hJ as ve,CJ as we,gJ as xe};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Ck as N}from"./vm-hands-entry-lite-fb02h1zm.js";import{randomUUID as K}from"crypto";import{closeSync as L,constants as V,fstatSync as M,lstatSync as Z,mkdirSync as $,openSync as O,readFileSync as T,realpathSync as b,renameSync as U,unlinkSync as X,writeFileSync as Y}from"fs";import{dirname as g,resolve as z}from"path";var A=65536;function J(j){try{return Z(j),!0}catch(q){if(q instanceof Error&&"code"in q&&q.code==="ENOENT")return!1;throw q}}function I(j,q=!1){if(!J(j)){if(!q)throw Error("worker_state_missing");D(j),$(j,{mode:448})}let C=Z(j);if(!C.isDirectory()||C.isSymbolicLink()||!N(C)||b(j)!==z(j))throw Error("worker_state_directory_not_private_or_canonical")}function D(j){let q=g(j);if(!J(q))D(q),$(q,{mode:448});if(b(q)!==z(q))throw Error("worker_parent_not_canonical")}function u(j,q=A){let C=O(j,V.O_RDONLY|V.O_NOFOLLOW);try{let G=M(C);if(!G.isFile()||G.nlink!==1||!N(G)||G.size>q)throw Error("worker_file_not_private");return T(C,"utf8")}finally{L(C)}}function f(j,q,C=A){let G=JSON.stringify(q);if(G===void 0)throw Error("worker_file_invalid");let Q=G+`
|
|
3
3
|
`;if(Buffer.byteLength(Q,"utf8")>C)throw Error("worker_file_too_large");if(I(g(j)),J(j))u(j,C);let H=`${j}.${K()}`;try{Y(H,Q,{mode:384,flag:"wx"}),U(H,j)}finally{if(J(H))X(H)}}
|
|
4
4
|
export{J as $c,I as ad,u as bd,f as cd};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var U=".reason/workspace",T="workspace_base",y="sessions",W="workspace_layout",g=".reason/workspace/sessions",B=/^[0-9a-f]{8}$/;function C(j){if(!J(j))return!1;let q=".reason/workspace/sessions/";if(!j.startsWith(q))return!1;let z=j.slice(q.length).split("/");return z.length===2&&B.test(z[0])}var G=4096,X="workspaces/pi";function J(j){if(typeof j!=="string"||!j||j.length>G)return!1;if(j.startsWith("/")||j.includes("\x00")||j.includes("\\"))return!1;return j.split("/").every((q)=>q!==""&&q!=="."&&q!=="..")}function Z(j){if(j.kind==="root"){if(j.path===void 0)return".";if(!J(j.path))throw Error("invalid_device_workspace_identity");return j.path}if(!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,159}$/.test(j.workspaceId)||j.workspaceId==="."||j.workspaceId==="..")throw Error("invalid_device_workspace_identity");let q=j.layout==="sessions"?"sessions":X;return`${j.base?`${j.base}/`:""}${q}/${j.workspaceId}/repo`}function L(j){if(!j||typeof j!=="object"||Array.isArray(j))return null;let q=j;if(q.kind==="root"&&Object.keys(q).length===1)return{kind:"root"};if(q.kind==="root"&&Object.keys(q).length===2&&J(q.path))return{kind:"root",path:q.path};if(q.kind!=="managed"||typeof q.workspaceId!=="string"||Object.keys(q).length!==2+(q.base===void 0?0:1)+(q.layout===void 0?0:1)||q.base!==void 0&&q.base!==".reason/workspace"||q.layout!==void 0&&q.layout!=="sessions")return null;let z={kind:"managed",workspaceId:q.workspaceId,...q.base===".reason/workspace"?{base:".reason/workspace"}:{},...q.layout==="sessions"?{layout:"sessions"}:{}};try{return Z(z),z}catch{return null}}var b="/home/runner",P=10001,x="/run/reason/sessions",f=/^(?:\/[A-Za-z0-9._-]+)+$/,M=/-sidechat-([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/,H=/^(.+)-repository-[a-z0-9][a-z0-9._-]*-[0-9a-f]{12}$/;function K(j){return M.exec(j)?.[1]??H.exec(j)?.[1]??j}var $=/^((?:\/[A-Za-z0-9._-]+)+)\/\.reason\/workspace\/(workspaces\/pi|sessions)\/([^/]+)$/,A="*/.reason/workspace/workspaces/pi/*|*/.reason/workspace/sessions/*";function N(j,q=b,z="sessions"){if(!f.test(q)||q.split("/").some((V)=>V==="."||V===".."))throw Error("invalid_cloud_payload_home");let Q=`${q}/${Z({kind:"managed",workspaceId:j,base:".reason/workspace",...z?{layout:z}:{}})}`,F=`${x}/${K(j)}`;return{home:q,root:Q.slice(0,-5),checkout:Q,control:F,jobEnv:`${F}/job.env`,cloudAccess:`${F}/cloud-access`,logs:`${F}/logs`,pin:`${F}/ws`}}function Y(j){return $.exec(j.replace(/\/+$/,""))?.[2]==="sessions"?"sessions":null}function D(j){return{kind:"managed",workspaceId:j,layout:"sessions"}}function R(j){let q=$.exec(j.replace(/\/+$/,""));if(!q)return null;try{let z=N(q[3],q[1],Y(j));return z.root===j.replace(/\/+$/,"")?z:null}catch{return null}}
|
|
3
|
-
export{U as
|
|
3
|
+
export{U as rj,T as sj,y as tj,W as uj,g as vj,B as wj,C as xj,J as yj,Z as zj,L as Aj,b as Bj,P as Cj,x as Dj,M as Ej,H as Fj,$ as Gj,A as Hj,N as Ij,Y as Jj,D as Kj,R as Lj};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{jk as q}from"./vm-hands-entry-lite-8pgggvbb.js";var u=25,U=q.object({machine:q.string().min(1).max(200),person:q.string().min(1).max(200),team:q.string().min(1).max(200),version:q.string().max(64).optional(),wait_seconds:q.number().int().min(0).max(u).optional()}),x=q.discriminatedUnion("kind",[q.object({id:q.string(),kind:q.literal("who"),all:q.boolean().optional()}),q.object({id:q.string(),kind:q.literal("send"),to:q.string(),body:q.string(),from_name:q.string(),from_agent:q.string(),wake:q.boolean(),reply_to:q.string().max(100).optional(),notify:q.boolean().optional()})]),V=q.object({job:x.nullable(),retry_after_seconds:q.number().optional()}),B=q.object({address:q.string(),person:q.string(),machine:q.string(),agent:q.string(),repo:q.string().nullable(),branch:q.string().nullable(),status:q.string(),since:q.number().nullable(),doing:q.string().nullable(),worker:q.boolean(),tier:q.string().max(10).optional()}),F=q.object({person:q.string(),machine:q.string(),online:q.boolean()}),G=q.object({team:q.string().nullable(),sessions:q.array(B).max(2000),machines:q.array(F).max(500),all:q.boolean().optional()}),H=q.object({address:q.string().max(300),state:q.string().max(40),note:q.string().max(500)}),X=q.union([q.object({who:G}),q.object({sent:q.object({ids:q.array(q.string().max(100)).max(500),recipients:q.array(q.string().max(300)).max(500),from:q.string().max(300),deliveries:q.array(H).max(500).optional()})}),q.object({error:q.string().min(1).max(2000)})]),K=q.object({id:q.string().max(100),from:q.string().max(300),from_agent:q.string().max(100).nullable(),to:q.string().max(300),reply_to:q.string().max(100).nullable(),body:q.string().max(64000),sent_at:q.number()}),Z=q.object({messages:q.array(K).max(100)});
|
|
3
3
|
export{u as va,V as wa};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{Q as
|
|
2
|
+
import{vj as X,xj as Y,zj as Z}from"./vm-hands-entry-lite-3nr9q3nf.js";import{execFileSync as z}from"child_process";import{existsSync as V,realpathSync as M}from"fs";import{userInfo as D}from"os";import{isAbsolute as $,join as C,normalize as F,parse as K}from"path";function Q(){let q=F(D().homedir);if(!$(q)||q===K(q).root)throw Error("Could not resolve the canonical user home.");return q}function O(q,B,J=Q()){let L=Z(B);if(B.kind==="managed"&&B.base){let G=M(J);return{anchor:G,boundary:C(G,B.base),path:C(G,L)}}if(B.kind==="root"&&Y(B.path)){let G=M(J);return{anchor:G,boundary:C(G,X),path:C(G,L)}}return{anchor:q,boundary:q,path:C(q,L)}}function _(q=Q()){return C(q,".config")}function b(){if(process.platform!=="darwin")return null;try{let q=z("/usr/bin/getconf",["DARWIN_USER_DIR"],{encoding:"utf8",timeout:5000}).trim();return $(q)?M(q):null}catch{return null}}function g(q=Q()){let B=C(q,"Library","Application Support","Ara"),J=C(q,"Library","Application Support","Reason");return V(B)&&!V(J)?B:J}
|
|
3
|
+
export{Q as mj,O as nj,_ as oj,b as pj,g as qj};
|
|
@@ -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-s7k376cz.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-n25efwqt.js";import{ad as B8,bd as W8,cd as aQ}from"./vm-hands-entry-lite-y55f8dyw.js";import{De as MZ,if as f9,jf as t0,kf as T8,lf as m0,pf as C0,ye as NZ}from"./vm-hands-entry-lite-v2ptg6br.js";import{Fg as aZ,Lg as $8,Mg as s8}from"./vm-hands-entry-lite-jx3w1z5q.js";import{Rg as j4}from"./vm-hands-entry-lite-fb5dzy9x.js";import{Ah as O0,Bh as o9,Ih as d8,Jh as TZ,Kh as HZ,Ug as SQ,Xg as N9,eh as jZ,fh as qZ,hh as CZ,jh as i9,kh as FZ,lh as VZ,mh as h8,ph as a9,yh as g8,zh as w0}from"./vm-hands-entry-lite-ammr3xbc.js";import{ti as rZ,ui as a8}from"./vm-hands-entry-lite-e2mjbqmr.js";import{Vi as b0}from"./vm-hands-entry-lite-sex82vb1.js";import{lj as _8,mj as r9,pj as M4}from"./vm-hands-entry-lite-fyvgav60.js";import{Kj as A$,qj as O8,rj as o0,sj as D8,tj as r0,uj as W9,vj as V8,wj as H$,xj as i0,yj as u0,zj as KZ}from"./vm-hands-entry-lite-pk3q774c.js";import{Pj as TQ}from"./vm-hands-entry-lite-d7cvwy3k.js";import{ik as x}from"./vm-hands-entry-lite-e05sgnwe.js";import{ok as q4}from"./vm-hands-entry-lite-sb7n76g7.js";import{Ak as N4,Bk as J9,rk as L4,tk as e9,uk as OZ,vk as d$,wk as DZ,xk as d9}from"./vm-hands-entry-lite-te0p47ak.js";import{Fk as q}from"./vm-hands-entry-lite-fw5ztpwn.js";import{Gk as u1,Lk as qQ}from"./vm-hands-entry-lite-grjkhbf2.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-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-00800vjk.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-ecsgqm1s.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
|
|
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-cvnymkkb.js"),import("./package-k4xz7vcr.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-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(`
|
|
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}
|