@reason-machines/cli-linux-x64 0.2.565 → 0.2.567
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/reason +1 -1
- package/bin/vm-hands/agent-network-0sng03r6.js +2 -0
- package/bin/vm-hands/api-credentials-h4neeejt.js +2 -0
- package/bin/vm-hands/api-mr6xds10.js +2 -0
- package/bin/vm-hands/{ask-relay-v5btnjvb.js → ask-relay-c0v30hh6.js} +2 -2
- package/bin/vm-hands/connect-cli-jc4m755k.js +2 -0
- package/bin/vm-hands/credentials-nfx99zxr.js +2 -0
- package/bin/vm-hands/custom-endpoint-device-5047vdn3.js +2 -0
- package/bin/vm-hands/desktop-account-d1g1m6yb.js +2 -0
- package/bin/vm-hands/desktop-components-7ngf8byq.js +2 -0
- package/bin/vm-hands/desktop-delegate-4hb0163k.js +2 -0
- package/bin/vm-hands/device-workspace-8941tdsy.js +2 -0
- package/bin/vm-hands/{fsevents-ezcg3e40.js → fsevents-e57jgcfe.js} +1 -1
- package/bin/vm-hands/hands-worker-source-8a4kh44t.js +2 -0
- package/bin/vm-hands/{index-w92ys6ra.js → index-y21r07rf.js} +8 -8
- package/bin/vm-hands/install-receipt-rckwjqmt.js +2 -0
- package/bin/vm-hands/local-automation-3mdhfw08.js +2 -0
- package/bin/vm-hands/local-capabilities-6e0gkrqq.js +2 -0
- package/bin/vm-hands/local-desktop-users-hkdfxqtj.js +2 -0
- package/bin/vm-hands/local-display-mac-gsh74khc.js +2 -0
- package/bin/vm-hands/local-display-session-r6s0wghh.js +2 -0
- package/bin/vm-hands/local-display-video-61peg1pj.js +2 -0
- package/bin/vm-hands/local-managed-process-p8xd7m5f.js +2 -0
- package/bin/vm-hands/local-pty-session-w0yhjdvz.js +2 -0
- package/bin/vm-hands/managed-runtime-4s8q8r7f.js +2 -0
- package/bin/vm-hands/{network-auto-update-3m94436w.js → network-auto-update-wep7067g.js} +2 -2
- package/bin/vm-hands/network-contract-ht0psj5j.js +2 -0
- package/bin/vm-hands/{network-sign-in-xm79s170.js → network-sign-in-rdnerhpz.js} +2 -2
- package/bin/vm-hands/package-3rv6jngd.js +2 -0
- package/bin/vm-hands/permissions-mmg1gbdx.js +2 -0
- package/bin/vm-hands/reason-hands-protocol-9r62swp0.js +2 -0
- package/bin/vm-hands/serve-service-k3mpxpj6.js +2 -0
- package/bin/vm-hands/{status-89999mdn.js → status-2s3zjapg.js} +5 -5
- package/bin/vm-hands/version-41q9twfs.js +2 -0
- package/bin/vm-hands/{vm-hands-entry-lite-pg7nnyc6.js → vm-hands-entry-lite-04nx5y4f.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-1xhpn3hw.js → vm-hands-entry-lite-07wr95rz.js} +3 -3
- package/bin/vm-hands/{vm-hands-entry-lite-33at6g06.js → vm-hands-entry-lite-0xfme8gg.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-xfak34av.js → vm-hands-entry-lite-1as6h9ed.js} +4 -4
- package/bin/vm-hands/{vm-hands-entry-lite-gxf2r5en.js → vm-hands-entry-lite-1cdtev4n.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-fn2805g8.js → vm-hands-entry-lite-1sy80ca9.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-yg4dk99m.js → vm-hands-entry-lite-2927z566.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-ngn4tafr.js → vm-hands-entry-lite-298kzt93.js} +70 -70
- package/bin/vm-hands/{vm-hands-entry-lite-3q2ng4e9.js → vm-hands-entry-lite-3594pdj0.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-7r27208j.js → vm-hands-entry-lite-3r063pb4.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-2qfmabqn.js → vm-hands-entry-lite-4kb5rq3d.js} +3 -3
- package/bin/vm-hands/{vm-hands-entry-lite-bsk184m7.js → vm-hands-entry-lite-6g9we34r.js} +3 -3
- package/bin/vm-hands/{vm-hands-entry-lite-s93f3pbv.js → vm-hands-entry-lite-732hnx41.js} +3 -3
- package/bin/vm-hands/vm-hands-entry-lite-7aeqbfc8.js +3 -0
- package/bin/vm-hands/{vm-hands-entry-lite-y0jtj8zz.js → vm-hands-entry-lite-8twdd0ff.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-432khjd5.js → vm-hands-entry-lite-9gn7k5rp.js} +5 -5
- package/bin/vm-hands/{vm-hands-entry-lite-t43bz0ey.js → vm-hands-entry-lite-ax2w9ywb.js} +3 -3
- package/bin/vm-hands/{vm-hands-entry-lite-1eyg750p.js → vm-hands-entry-lite-b3mfma12.js} +4 -4
- package/bin/vm-hands/{vm-hands-entry-lite-qjrgvdbj.js → vm-hands-entry-lite-bbjsnjct.js} +21 -21
- package/bin/vm-hands/{vm-hands-entry-lite-zp7chzcc.js → vm-hands-entry-lite-bc9zq8gx.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-ngry8nkq.js → vm-hands-entry-lite-bqs4pkyb.js} +4 -4
- package/bin/vm-hands/{vm-hands-entry-lite-zpvr7wc6.js → vm-hands-entry-lite-bt6skt4h.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-q62g6sx0.js → vm-hands-entry-lite-chve4vmh.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-rqfhfp09.js → vm-hands-entry-lite-crjaacc2.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-gcqqnnze.js → vm-hands-entry-lite-cy8yc9gb.js} +19 -19
- package/bin/vm-hands/{vm-hands-entry-lite-ncyrz48z.js → vm-hands-entry-lite-dfphra23.js} +3 -3
- package/bin/vm-hands/{vm-hands-entry-lite-a3gq377t.js → vm-hands-entry-lite-dh87ysh2.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-sz7z1qby.js → vm-hands-entry-lite-dtw6cj95.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-tnj3483k.js → vm-hands-entry-lite-dzdjwa06.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-chq0qx9f.js → vm-hands-entry-lite-g0bpdyfz.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-rxydyqke.js → vm-hands-entry-lite-h7f5a5mb.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-13nx02p7.js → vm-hands-entry-lite-hh0kba1y.js} +4 -4
- package/bin/vm-hands/{vm-hands-entry-lite-fccn6s4j.js → vm-hands-entry-lite-hpe54h0b.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-kbnxk71q.js → vm-hands-entry-lite-hpw27zfb.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-284z7ct8.js → vm-hands-entry-lite-kankyeep.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-dy204qh4.js → vm-hands-entry-lite-n5jyzccm.js} +4 -4
- package/bin/vm-hands/{vm-hands-entry-lite-88dxn9b5.js → vm-hands-entry-lite-peyr9y6z.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-cmmb9k3g.js → vm-hands-entry-lite-r131db1f.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-pt19vacn.js → vm-hands-entry-lite-rmcdfbkk.js} +24 -24
- package/bin/vm-hands/{vm-hands-entry-lite-1b21avcs.js → vm-hands-entry-lite-sb1xtqxr.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-b1vanmtv.js → vm-hands-entry-lite-sxnvhzy5.js} +4 -4
- package/bin/vm-hands/{vm-hands-entry-lite-cc8hwgxc.js → vm-hands-entry-lite-t2rhwchw.js} +3 -3
- package/bin/vm-hands/{vm-hands-entry-lite-sh4mqy93.js → vm-hands-entry-lite-t3k90kdn.js} +3 -3
- package/bin/vm-hands/{vm-hands-entry-lite-t86kt9jz.js → vm-hands-entry-lite-tv5mcw97.js} +6 -6
- package/bin/vm-hands/{vm-hands-entry-lite-12ck5swp.js → vm-hands-entry-lite-tzv8s0e7.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-6vnjgy77.js → vm-hands-entry-lite-vedb5r12.js} +4 -4
- package/bin/vm-hands/{vm-hands-entry-lite-jj7873n8.js → vm-hands-entry-lite-vha0pf8k.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-fxptf351.js → vm-hands-entry-lite-vvhfaxpd.js} +5 -5
- package/bin/vm-hands/{vm-hands-entry-lite-3gc2bn5a.js → vm-hands-entry-lite-wtjqjvea.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-34b4tws6.js → vm-hands-entry-lite-xd393rm3.js} +6 -6
- package/bin/vm-hands/{vm-hands-entry-lite-z65xva21.js → vm-hands-entry-lite-ys4jhf7n.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-af45ma9p.js → vm-hands-entry-lite-zaj1vnnd.js} +9 -9
- package/bin/vm-hands/vm-hands-entry-lite.js +2 -2
- package/bin/vm-hands/{vm-hands-executor-kyb5t371.js → vm-hands-executor-31ea40aw.js} +4 -4
- package/bin/vm-hands/{vm-hands-op-runner-gkt79hcp.js → vm-hands-op-runner-6r390v3d.js} +1 -1
- package/bin/vm-hands/{vm-hands-runtime-tdr6j55n.js → vm-hands-runtime-z9m50n9p.js} +3 -3
- package/bin/vm-hands/worker-preview-readiness-w4zy5g2p.js +2 -0
- package/bin/vm-hands/worker-sandbox-2trfs79b.js +2 -0
- package/package.json +1 -1
- package/bin/vm-hands/agent-network-mnv1fm1c.js +0 -2
- package/bin/vm-hands/api-credentials-082cnpn9.js +0 -2
- package/bin/vm-hands/api-sq672f51.js +0 -2
- package/bin/vm-hands/connect-cli-rxb3qtra.js +0 -2
- package/bin/vm-hands/credentials-sk4sag42.js +0 -2
- package/bin/vm-hands/custom-endpoint-device-3jscber1.js +0 -2
- package/bin/vm-hands/desktop-account-xma0330a.js +0 -2
- package/bin/vm-hands/desktop-components-099xyxmz.js +0 -2
- package/bin/vm-hands/desktop-delegate-tch2qzx0.js +0 -2
- package/bin/vm-hands/device-workspace-4bj43nxq.js +0 -2
- package/bin/vm-hands/hands-worker-source-8pe7yv0m.js +0 -2
- package/bin/vm-hands/install-receipt-68xxg7hn.js +0 -2
- package/bin/vm-hands/local-automation-7pjd5nc1.js +0 -2
- package/bin/vm-hands/local-capabilities-ha0ey4zh.js +0 -2
- package/bin/vm-hands/local-desktop-users-jpf0resr.js +0 -2
- package/bin/vm-hands/local-display-mac-h5yz0ydd.js +0 -2
- package/bin/vm-hands/local-display-session-0mkswxgk.js +0 -2
- package/bin/vm-hands/local-display-video-c3fk87c5.js +0 -2
- package/bin/vm-hands/local-managed-process-ahr2jync.js +0 -2
- package/bin/vm-hands/local-pty-session-tqn2xmph.js +0 -2
- package/bin/vm-hands/managed-runtime-shzb3tr3.js +0 -2
- package/bin/vm-hands/network-contract-nkwcf4r9.js +0 -2
- package/bin/vm-hands/package-9w0mmxb5.js +0 -2
- package/bin/vm-hands/permissions-scffy1px.js +0 -2
- package/bin/vm-hands/reason-hands-protocol-pck5har9.js +0 -2
- package/bin/vm-hands/serve-service-grp91ybk.js +0 -2
- package/bin/vm-hands/version-wyshazh7.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-997y1m1r.js +0 -3
- package/bin/vm-hands/worker-preview-readiness-h96yr4wf.js +0 -2
- package/bin/vm-hands/worker-sandbox-6kkhvryn.js +0 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{createHash as M,createPublicKey as y,verify as _}from"crypto";var
|
|
3
|
-
export{
|
|
2
|
+
import{createHash as M,createPublicKey as y,verify as _}from"crypto";var Ii="libara_device_keychain.dylib",Di="libreason_device_keychain.dylib";var g=2,b=536870912,vn=262144;var yr=["darwin-arm64","darwin-x64"];class l extends Error{code;constructor(t,n){super(n);this.code=t;this.name="ManagedRuntimeError"}}var N=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/,k=/^[a-f0-9]{64}$/;function a(t){return Boolean(t)&&typeof t==="object"&&!Array.isArray(t)}function r(t,n,i=[]){let s=new Set([...n,...i]);return n.every((e)=>(e in t))&&Object.keys(t).every((e)=>s.has(e))}function p(t){return typeof t==="string"&&N.test(t)}function w(t){return typeof t==="string"&&!Number.isNaN(Date.parse(t))&&new Date(t).toISOString()===t}var mc="managed-runtime-identity.json",m="reason-macos-background-identity-v1";function f(t){if(t===null)return"null";if(typeof t==="string"||typeof t==="boolean")return JSON.stringify(t);if(typeof t==="number"){if(!Number.isFinite(t))throw new l("invalid_manifest","Manifest numbers must be finite.");return JSON.stringify(t)}if(Array.isArray(t))return`[${t.map((n)=>f(n)).join(",")}]`;if(a(t))return`{${Object.keys(t).sort().map((n)=>`${JSON.stringify(n)}:${f(t[n])}`).join(",")}}`;throw new l("invalid_manifest","Manifest contains an unsupported value.")}function d(t){if(!a(t)||!r(t,["url","sha256","size_bytes"])||typeof t.url!=="string"||typeof t.sha256!=="string"||!k.test(t.sha256)||typeof t.size_bytes!=="number"||!Number.isSafeInteger(t.size_bytes)||t.size_bytes<=0||t.size_bytes>b)throw new l("invalid_manifest","Manifest contains an invalid runtime artifact.");let n;try{n=new URL(t.url)}catch{throw new l("invalid_manifest","Runtime artifact URL is invalid.")}if(n.protocol!=="https:"||n.username||n.password||n.hash)throw new l("invalid_manifest","Runtime artifact URL must be an HTTPS URL without credentials or a fragment.");return{url:n.toString(),sha256:t.sha256,size_bytes:t.size_bytes}}function u(t){if(!a(t)||!r(t,["broker","credential_library"]))throw new l("invalid_manifest","Manifest must bind the broker and credential library as one runtime.");return{broker:d(t.broker),credential_library:d(t.credential_library)}}function I(t){if(!a(t)||!r(t,["schema_version","version","published_at","artifacts"])||t.schema_version!==g||!p(t.version)||!w(t.published_at)||!a(t.artifacts)||!r(t.artifacts,[...yr]))throw new l("invalid_manifest","Managed Reason runtime manifest is invalid.");return{schema_version:g,version:t.version,published_at:t.published_at,artifacts:{"darwin-arm64":u(t.artifacts["darwin-arm64"]),"darwin-x64":u(t.artifacts["darwin-x64"])}}}function T(t){if(!a(t)||!r(t,["schema","version","published_at","artifacts"])||t.schema!==m||!p(t.version)||!w(t.published_at)||!a(t.artifacts)||!r(t.artifacts,[...yr]))throw new l("invalid_manifest","Reason background identity manifest is invalid.");return{schema:m,version:t.version,published_at:t.published_at,artifacts:{"darwin-arm64":d(t.artifacts["darwin-arm64"]),"darwin-x64":d(t.artifacts["darwin-x64"])}}}function h(t){if(typeof t!=="string"||!/^[A-Za-z0-9+/]+={0,2}$/.test(t))throw new l("invalid_signature","Runtime manifest signature is invalid.");let n=Buffer.from(t,"base64");if(n.length!==64||n.toString("base64")!==t)throw new l("invalid_signature","Runtime manifest signature is invalid.");return n}function A(t){let n=t;if(typeof t==="string")try{n=JSON.parse(t)}catch{throw new l("invalid_manifest","Managed Reason runtime manifest is not valid JSON.")}if(!a(n)||!r(n,["key_id","manifest","signature"])||typeof n.key_id!=="string"||!/^[A-Za-z0-9._-]{1,80}$/.test(n.key_id)||typeof n.signature!=="string")throw new l("invalid_manifest","Signed managed Reason runtime manifest is invalid.");return n}function Oi(t,n){let i=A(t),s=n[i.key_id];if(!s)throw new l("untrusted_key","Runtime manifest was signed by an unknown key.");let e=I(i.manifest),c=h(i.signature),o=!1;try{o=_(null,Buffer.from(f(e)),y(s),c)}catch{throw new l("invalid_signature","Runtime manifest signature could not be verified.")}if(!o)throw new l("invalid_signature","Runtime manifest signature did not match.");return{key_id:i.key_id,manifest:e,signature:i.signature}}function gc(t,n){let i=A(t),s=n[i.key_id];if(!s)throw new l("untrusted_key","Background identity manifest was signed by an unknown key.");let e=T(i.manifest),c=h(i.signature),o=!1;try{o=_(null,Buffer.from(f(e)),y(s),c)}catch{throw new l("invalid_signature","Background identity manifest signature could not be verified.")}if(!o)throw new l("invalid_signature","Background identity manifest signature did not match.");return{key_id:i.key_id,manifest:e,signature:i.signature}}function Sn(t){return M("sha256").update(t).digest("hex")}function Gt(t,n){if(t.byteLength!==n.size_bytes)throw new l("artifact_size_mismatch","Runtime artifact size did not match its manifest.");if(Sn(t)!==n.sha256)throw new l("artifact_checksum_mismatch","Runtime artifact checksum did not match its manifest.")}import{existsSync as S}from"fs";import{join as R}from"path";function En(t){let n=R(t,Di);return S(n)?n:R(t,Ii)}
|
|
3
|
+
export{Ii,Di,vn,yr,l,mc,Oi,gc,Sn,Gt,En};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Tt,It}from"./vm-hands-entry-lite-
|
|
2
|
+
import{Tt,It}from"./vm-hands-entry-lite-04nx5y4f.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{request as Ie}from"http";import{pipeline as We}from"stream";import{constants as ne,createBrotliCompress as Re,createGzip as Be}from"zlib";import{WebSocket as U}from"ws";import{randomBytes as Ee,timingSafeEqual as Ae}from"crypto";import{createServer as Te}from"net";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 J(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function L(e,t,n=Number.MAX_SAFE_INTEGER){return typeof e==="number"&&Number.isSafeInteger(e)&&e>=t&&e<=n}function fe(e){return typeof e==="string"&&/^[a-zA-Z0-9_-]{1,160}$/.test(e)}function we(e,t){let n=Buffer.from(e,"latin1");return Buffer.concat([Buffer.from([n.length]),n,t])}function C(e){if(!J(e)||Object.keys(e).length!==12||![e.organizationId,e.userId,e.runId,e.deviceId,e.rootId,e.jobId,e.fenceId].every(fe)||!L(e.attachmentRevision,0)||!L(e.grantRevision,1)||!L(e.generation,1)||!L(e.port,1024,65535)||!L(e.expiresAtMs,1))throw Error("preview_binding_invalid");return Object.freeze({...e})}function Bt(e,t){return Object.keys(e).every((n)=>e[n]===t[n])}function H(e){if(e.length>4096||!e.startsWith("/")||e.startsWith("//")||/[\\\x00-\x20\x7f#]/.test(e))throw Error("preview_path_invalid");let t=decodeURIComponent(e);if(t.startsWith("//")||/[\\\x00-\x1f\x7f]/.test(t))throw Error("preview_path_invalid");return e}function pe(e){return Array.isArray(e)&&e.length<=64&&e.every((t)=>Array.isArray(t)&&t.length===2&&typeof t[0]==="string"&&/^[a-zA-Z0-9-]{1,80}$/.test(t[0])&&typeof t[1]==="string"&&t[1].length<=4096&&!/[\x00-\x1f\x7f]/.test(t[1]))}function z(e,t=v.chunk){if(e.length>Math.ceil(t/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e))throw Error("preview_data_invalid");let n=Buffer.from(e,"base64");if(n.length>t)throw Error("preview_data_too_large");return n}function me(e){if(Array.isArray(e))return Buffer.concat(e);if(typeof e==="string")return Buffer.from(e,"utf8");if(e instanceof ArrayBuffer)return Buffer.from(e);return e}function gi(e){if(Buffer.byteLength(e)>v.upload*1.4+300000)throw Error("preview_frame_too_large");let t=JSON.parse(e);if(!J(t))throw Error("preview_frame_invalid");if(t.type==="hello")return{type:"hello",binding:C(t.binding),...L(t.messages,v.chunk,v.upload)?{messages:t.messages}:{},...L(t.window,1,v.window)?{window:t.window}:{},...t.bytes===!0?{bytes:!0}:{}};if(t.type==="refused"&&typeof t.reason==="string"&&/^[a-z_]{1,32}$/.test(t.reason))return{type:"refused",binding:C(t.binding),reason:t.reason};if(!fe(t.id))throw Error("preview_frame_invalid");if(t.type==="end"||t.type==="cancel"||t.type==="credit")return{type:t.type,id:t.id};if(t.type==="ws"&&typeof t.protocol==="string"&&/^[a-zA-Z0-9._-]{0,100}$/.test(t.protocol))return{type:"ws",id:t.id,protocol:t.protocol};if(t.type==="data"&&typeof t.data==="string"&&typeof t.binary==="boolean")return z(t.data,v.upload),{type:"data",id:t.id,data:t.data,binary:t.binary};if(t.type==="head"&&L(t.status,200,599)&&pe(t.headers))return{type:"head",id:t.id,status:t.status,headers:t.headers};if(t.type==="request"&&typeof t.method==="string"&&/^(GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS)$/.test(t.method)&&typeof t.path==="string"&&pe(t.headers)&&typeof t.body==="string"&&typeof t.upgrade==="boolean")return z(t.body,v.upload),{type:"request",id:t.id,method:t.method,path:H(t.path),headers:t.headers,body:t.body,upgrade:t.upgrade};throw Error("preview_frame_invalid")}function re(e){let t=[...e],n=new Set(t.filter(([o])=>o.toLowerCase()==="connection").flatMap(([,o])=>o.toLowerCase().split(",").map((i)=>i.trim()))),s=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 t.filter(([o])=>!s.has(o.toLowerCase())&&!n.has(o.toLowerCase())&&!/^(x-forwarded-|x-ara-|sec-websocket-|access-control-)/i.test(o))}async function te(e){let t;try{return await Promise.race([Promise.resolve().then(e).then((n)=>n===!0||(n===!1?!1:void 0),()=>{return}),new Promise((n)=>{t=setTimeout(()=>n(void 0),v.authorizationMs)})])}finally{clearTimeout(t)}}async function ln(e){return await te(e)===!0}function V(e,t){let n=new URL(e);if(n.username||n.password||n.search||n.hash||!(n.protocol==="wss:"||n.protocol==="ws:"&&["127.0.0.1","[::1]"].includes(n.hostname))||!new RegExp(`^/${t}/[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]{32,}$`).test(n.pathname))throw Error("preview_relay_invalid");return n.href}function pr(e){if(!J(e)||Object.keys(e).length!==2||typeof e.deviceRelayUrl!=="string")throw Error("preview_open_invalid");return{binding:C(e.binding),deviceRelayUrl:V(e.deviceRelayUrl,"device")}}function oc(e){if(!J(e)||Object.keys(e).length!==1||!("binding"in e))throw Error("preview_close_invalid");return{binding:C(e.binding)}}var ge="x-preview-connection";async function be(e,t){if(t.aborted)throw Error("preview_closed");let n=Ee(32).toString("base64url"),s=new Set,o=!1,i=Te((c)=>{if(o||t.aborted||s.size>=v.streams*2)return c.destroy();s.add(c);let d=new AbortController;c.once("close",()=>{s.delete(c),d.abort()}),c.on("error",()=>c.destroy()),c.setTimeout(2000,()=>c.destroy());let g=Buffer.alloc(0),w=(m)=>{g=Buffer.concat([g,m]);let f=g.indexOf(`\r
|
|
3
3
|
\r
|
|
4
4
|
`);if(f<0){if(g.length>16384)c.destroy();return}if(c.pause(),c.off("data",w),f>16384||g.length>v.upload+16384)return c.destroy();u(g,f).catch(()=>c.destroy())};c.on("data",w);async function u(m,f){let b=m.subarray(0,f).toString("latin1").split(`\r
|
|
5
5
|
`),_=/^(GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS) (\S+) HTTP\/1\.1$/.exec(b.shift()??"");if(!_)throw Error("preview_request_invalid");H(_[2]);let k=!1,O=0,T=[];for(let B of b){let S=/^([a-zA-Z0-9-]+):[ \t]*([^\x00-\x08\x0a-\x1f\x7f]*)$/.exec(B);if(!S)throw Error("preview_header_invalid");if(S[1].toLowerCase()===ge){O++;let N=Buffer.from(S[2].trim());k=N.length===n.length&&Ae(N,Buffer.from(n))}else if(S[1].toLowerCase()!=="host")T.push(B)}if(!k||O!==1||o||d.signal.aborted)throw Error("preview_connection_denied");let P=await e.connect(d.signal);if(o||d.signal.aborted)throw P.destroy(),Error("preview_closed");s.add(P),P.on("error",()=>c.destroy()),P.once("close",()=>{s.delete(P),c.destroy()}),c.once("close",()=>P.destroy()),c.setTimeout(0);let h=[`${_[1]} ${_[2]} HTTP/1.1`,`Host: 127.0.0.1:${P.remotePort}`,...T,"",""].join(`\r
|
|
6
|
-
`);P.write(Buffer.concat([Buffer.from(h,"latin1"),m.subarray(f+4)])),P.pipe(c),c.pipe(P),c.resume()}});await new Promise((c,d)=>{i.once("error",d),i.listen(0,"127.0.0.1",c)});let a=i.address();if(!a||typeof a==="string")throw i.close(),Error("preview_bind_failed");function l(){if(o)return;o=!0,t.removeEventListener("abort",l);for(let c of s)c.destroy();s.clear(),i.close()}if(t.addEventListener("abort",l,{once:!0}),t.aborted)l();return{port:a.port,headers:{[ge]:n},close:l}}var Le=60000,Ce=1e4,Ne=5000,$e=/^(?:text\/(?!event-stream)|application\/(?:(?:x-)?javascript|json|[a-z.+-]*\+json|xml|[a-z.+-]*\+xml|wasm)|image\/svg\+xml)/i;function Me(e,t,n,s){let o=(c)=>t.find(([d])=>d.toLowerCase()===c)?.[1],i=(c)=>s.find(([d])=>d.toLowerCase()===c)?.[1],a=Number(i("content-length")??Number.NaN);if(e!=="GET"||n!==200||o("range")!==void 0||i("content-encoding")!==void 0||!$e.test(i("content-type")??"")||/\bno-transform\b/i.test(i("cache-control")??"")||a<1024)return null;let l=(c)=>new RegExp(`(?:^|,)\\s*${c}\\s*(?:,|$|;\\s*q=(?:1|0?\\.0*[1-9]))`,"i").test(o("accept-encoding")??"");return l("br")?"br":l("gzip")?"gzip":null}function Oe(e,t){let n=e.filter(([s])=>s.toLowerCase()==="vary").map(([,s])=>s).join(", ");return[...e.filter(([s])=>!["vary","etag","content-md5"].includes(s.toLowerCase())),...e.filter(([s])=>s.toLowerCase()==="etag").map(([s,o])=>[s,o.startsWith("W/")?o:`W/${o}`]),["Content-Encoding",t],["Vary",n.split(",").some((s)=>/^\s*(?:accept-encoding|\*)\s*$/i.test(s))?n:n?`${n}, Accept-Encoding`:"Accept-Encoding"]]}async function
|
|
7
|
-
`);let t=e.binding,n;try{n=V(e.deviceRelayUrl,"device")}catch{return}if(!t)return;await new Promise((s)=>{let o=new U(n,{followRedirects:!1,perMessageDeflate:!1,maxPayload:4096}),i=setTimeout(()=>{o.terminate(),s()},v.authorizationMs*2);o.addEventListener("open",()=>{o.send(JSON.stringify({type:"refused",binding:t,reason:e.reason})),o.close(1000,`worker_refused_${e.reason}`)}),o.addEventListener("error",()=>{clearTimeout(i),s()}),o.addEventListener("close",()=>{clearTimeout(i),s()})})}async function Fe(e,t){let n=Date.now()+Ce,s;for(;;){if(!t())return"closed";let o=s??=e.refusal().finally(()=>{s=void 0}),i,a=await Promise.race([o.catch(()=>"port_unproved"),new Promise((l)=>{i=setTimeout(()=>l("port_check_timeout"),v.authorizationMs)})]).finally(()=>clearTimeout(i));if(a===null)return null;if(!["listener_unproved","port_check_timeout"].includes(a)||Date.now()+500>=n)return a;await new Promise((l)=>setTimeout(l,500))}}async function ht(e){let t=C(e.binding),n=()=>!e.signal.aborted&&Date.now()<t.expiresAtMs,s=t.expiresAtMs>Date.now()+v.lifetimeMs+Ne?"binding_mismatch":await Fe(e.port,n);if(s)throw await To({deviceRelayUrl:e.deviceRelayUrl,binding:t,jobId:t.jobId,port:t.port,reason:s}),Error("preview_not_authorized",{cause:s});let o=V(e.deviceRelayUrl,"device"),i=await be(e.port,e.signal),a;try{a=new U(o,{followRedirects:!1,perMessageDeflate:!1,maxPayload:v.upload*1.4+300000})}catch(p){throw i.close(),p}let l=new Map,c=!1,d=!1,g=0,w=!1,u,m,f,b=new Promise((p)=>{f=p}),_,k,O=new Promise((p,y)=>{_=p,k=y}),T=!1,P=(p)=>{let y=Buffer.isBuffer(p)?p:JSON.stringify(p);if(g+=Buffer.byteLength(y),!n()||d||a.readyState!==U.OPEN)return h(n()?"relay_closed":"expired");if(a.bufferedAmount>v.relayBuffered)return h("relay_backlog");if(g>v.total)return h("quota");a.send(y)};function h(p="closed"){if(d)return;d=!0,clearInterval(N),clearTimeout(S),e.signal.removeEventListener("abort",B);for(let y of l.values())y.stop();l.clear(),i.close(),a.close(1000,`worker_${p}`),k(Error("preview_closed")),f()}let B=()=>h("aborted"),S=setTimeout(()=>h("pair_timeout"),v.requestMs),N=setInterval(async()=>{if(!n())return h(e.signal.aborted?"aborted":"expired");if(w)return;w=!0;try{let p=u??=Promise.resolve().then(()=>e.port.check()).finally(()=>{u=void 0}),y=await te(()=>p);if(y===!1)return h("port_refused");if(y){m=void 0;return}if(Date.now()-(m??=Date.now())>Le)return h("port_unknown");for(let E of l.values())E.stop()}finally{w=!1}},1000);if(e.signal.addEventListener("abort",B,{once:!0}),!n())h(e.signal.aborted?"aborted":"expired");a.addEventListener("open",()=>P({type:"hello",binding:t,messages:v.upload,window:v.window})),a.addEventListener("close",()=>h("relay_closed")),a.addEventListener("error",()=>h("relay_error")),a.addEventListener("message",(p)=>{try{if(!n()||d)return h(e.signal.aborted?"aborted":"expired");if(typeof p.data!=="string")throw Error("preview_frame_invalid");if(g+=Buffer.byteLength(p.data),g>v.total)return h("quota");let y=mi(p.data);if(!c){if(y.type!=="hello"||!Bt(t,y.binding))return h("binding_mismatch");c=!0,T=y.bytes===!0,clearTimeout(S),_();return}if(y.type==="hello"||y.type==="refused")return h("invalid_frame");if(y.type==="request"){q(y).catch(()=>h("invalid_request"));return}let E=l.get(y.id);if(!E)return;if(y.type==="cancel"||y.type==="end")E.stop();else if(y.type==="credit"&&E.credit)E.credit();else if(y.type==="data"&&E.ws){if(E.ws.readyState!==U.OPEN||E.ws.bufferedAmount>v.buffered)return E.stop();let I=z(y.data,v.upload);E.ws.send(y.binary?I:I.toString("utf8"))}else h("invalid_frame")}catch{h("invalid_frame")}});async function q(p){if(l.has(p.id)||l.size>=v.streams)return h("stream_limit");if(!n())return h(e.signal.aborted?"aborted":"expired");let y=new AbortController,E,I,K,Q=0,R=(W=!1)=>{if(!l.delete(p.id))return;clearTimeout(E),y.abort(),I?.close(1000,"preview_closed"),K?.(),P({type:W?"end":"cancel",id:p.id})},ae={stop:()=>R(),credit:()=>{Q++,K?.()}};if(l.set(p.id,ae),E=setTimeout(R,v.requestMs),!await cn(()=>e.port.check())||!n()||y.signal.aborted)return R();let de=H(p.path);if(p.upgrade){if(p.method!=="GET"||p.body)return R();let W=p.headers.find(([A])=>A.toLowerCase()==="sec-websocket-protocol")?.[1].split(",").map((A)=>A.trim());if(W?.some((A)=>!/^[a-zA-Z0-9._-]{1,100}$/.test(A))||(W?.length??0)>8)return R();I=new U(`ws://127.0.0.1:${i.port}${de}`,W,{headers:i.headers,followRedirects:!1,perMessageDeflate:!1,maxPayload:v.upload}),ae.ws=I,I.binaryType="arraybuffer",I.addEventListener("open",()=>{clearTimeout(E),P({type:"ws",id:p.id,protocol:I.protocol})}),I.addEventListener("message",(A)=>{let G=typeof A.data!=="string",M=me(A.data);if(M.length>v.upload)return R();P({type:"data",id:p.id,data:M.toString("base64"),binary:G})}),I.addEventListener("error",()=>R()),I.addEventListener("close",(A)=>R(A.wasClean));return}let xe=z(p.body,v.upload),ce=Ie({hostname:"127.0.0.1",port:i.port,path:de,method:p.method,headers:{...Object.fromEntries(re(p.headers)),...i.headers,connection:"close"},signal:y.signal,agent:!1,maxHeaderSize:16384},async(W)=>{try{let A=[];for(let F=0;F<W.rawHeaders.length;F+=2)A.push([W.rawHeaders[F],W.rawHeaders[F+1]]);let G=W.statusCode??502,M=Me(p.method,p.headers,G,A),ee=M==="br"?Re({flush:ne.BROTLI_OPERATION_FLUSH,params:{[ne.BROTLI_PARAM_QUALITY]:5}}):M==="gzip"?Be({level:6,flush:ne.Z_SYNC_FLUSH}):void 0;if(P({type:"head",id:p.id,status:G,headers:re(M?Oe(A,M):A)}),clearTimeout(E),ee)We(W,ee,()=>{});for await(let F of ee??W){let le=Buffer.from(F);for(let Z=0;Z<le.length;Z+=v.chunk){if(Q===0&&!y.signal.aborted)await new Promise((Se)=>{K=Se});if(K=void 0,y.signal.aborted)return;Q--;let ue=le.subarray(Z,Z+v.chunk);P(T?we(p.id,ue):{type:"data",id:p.id,data:ue.toString("base64"),binary:!0})}}R(!0)}catch{R()}});ce.on("error",()=>R()),ce.end(xe)}return await O,{close:h,closed:b}}import{execFile as ze}from"child_process";import{createRequire as He}from"module";import{win32 as X}from"path";var Ue=250,je=50,De=250,qe=4194304;function ye(e){let t=/^(?:\[([^\]]+)\]|([^:]+)):([0-9]{1,5})$/.exec(e??""),n=Number(t?.[3]);return t&&n<=65535?{address:t[1]??t[2],port:n}:null}function Ke(e){let t=[];for(let n of e.split(/\r?\n/)){let s=n.trim().split(/\s+/);if(s[0]!=="TCP"||s.length<5)continue;let o=ye(s[1]),i=ye(s[2]),a=Number(s.at(-1));if(!o||!i||!Number.isSafeInteger(a)||a<0)continue;t.push({pid:a,localAddress:o.address,localPort:o.port,remoteAddress:i.address,remotePort:i.port,listening:i.port===0})}return t}function Ge(e){if(e.localAddress==="0.0.0.0"||e.localAddress==="::")return`*:${e.localPort}`;return e.localAddress.includes(":")?`[${e.localAddress}]:${e.localPort}`:`${e.localAddress}:${e.localPort}`}var oe=(e)=>new Promise((t,n)=>ze(X.join(Tt("win32").split(";")[0],"NETSTAT.EXE"),["-ano"],{timeout:e,maxBuffer:qe,encoding:"utf8",windowsHide:!0,env:It()},(s,o)=>s?n(s):t(o)));function D(e){let t=X.normalize(e.startsWith("\\\\?\\")?e.slice(4):e);return t.length>3&&t.endsWith("\\")?t.slice(0,-1):t}function Ze(e,t){let n=e.toLowerCase(),s=t.toLowerCase();return s===n||s.startsWith(n.endsWith("\\")?n:`${n}\\`)}function Pe(e,t,n){let s=e.cwd(n),o=s?D(s):null;return o&&X.isAbsolute(o)&&Ze(t,o)?o:null}var j;function tt(){if(j!==void 0)return j;if(j=null,process.platform!=="win32"||!["x64","arm64"].includes(process.arch))return null;let e;try{e=He(import.meta.url)("bun:ffi")}catch{return null}let{FFIType:t,ptr:n}=e,s,o;try{s=e.dlopen("kernel32.dll",{CreateToolhelp32Snapshot:{args:[t.u32,t.u32],returns:t.u64},Process32FirstW:{args:[t.u64,t.ptr],returns:t.i32},Process32NextW:{args:[t.u64,t.ptr],returns:t.i32},OpenProcess:{args:[t.u32,t.i32,t.u32],returns:t.u64},ReadProcessMemory:{args:[t.u64,t.u64,t.ptr,t.u64,t.ptr],returns:t.i32},CloseHandle:{args:[t.u64],returns:t.i32}}).symbols,o=e.dlopen("ntdll.dll",{NtQueryInformationProcess:{args:[t.u64,t.i32,t.ptr,t.u32,t.ptr],returns:t.i32}}).symbols}catch{return null}let i=0xFFFFFFFFFFFFFFFFn,a=2,l=1040,c=568,d=(g,w,u)=>{let m=Buffer.alloc(u);return s.ReadProcessMemory(g,w,n(m),u,null)?m:null};return j={processes(){let g=BigInt(s.CreateToolhelp32Snapshot(a,0));if(g===i)throw new r("process_inspection_failed","Reading this computer's processes did not complete.");try{let w=Buffer.alloc(c);w.writeUInt32LE(c,0);let u=n(w),m=[];for(let f=s.Process32FirstW(g,u);f;f=s.Process32NextW(g,u)){let b=w.toString("utf16le",44,c),_=b.slice(0,b.includes("\x00")?b.indexOf("\x00"):void 0),k=w.readUInt32LE(8);if(k>0)m.push({pid:k,parentPid:w.readUInt32LE(32),command:_.replace(/\.exe$/i,"")||null})}return m}finally{s.CloseHandle(g)}},cwd(g){let w=BigInt(s.OpenProcess(l,0,g));if(w===0n)return null;try{let u=Buffer.alloc(48);if(o.NtQueryInformationProcess(w,0,n(u),u.length,null)!==0)return null;let m=d(w,u.readBigUInt64LE(8)+0x20n,8)?.readBigUInt64LE(0),f=m?d(w,m+0x38n,16):null,b=f?.readUInt16LE(0)??0;if(!f||b===0||b%2!==0)return null;return d(w,f.readBigUInt64LE(8),b)?.toString("utf16le")??null}finally{s.CloseHandle(w)}}},j}function se(e){if(!e)throw new r("process_inspection_failed","Reading this computer's processes is unavailable.");return e}async function ve(e,t){let n;try{n=await e(t)}catch{throw new r("process_inspection_failed","Reading this computer's ports did not complete.")}return Ke(n)}async function sc(e,t=tt()){let n=se(t),s=D(e),o=[];for(let i of n.processes()){if(o.length>=Ue)break;let a=Pe(n,s,i.pid);if(a)o.push({pid:i.pid,command:i.command,cwd:X.relative(s,a)||"."})}return{processes:o}}async function ac(e,t=tt(),n=oe){let s=se(t),o=D(e),i=(await ve(n,5000)).filter((d)=>d.listening&&d.pid>0).map((d)=>({pid:d.pid,port:d.localPort,address:Ge(d)})).sort((d,g)=>d.pid-g.pid||d.port-g.port||(d.address<g.address?-1:d.address>g.address?1:0)),a=[...new Set(i.map((d)=>d.pid))].slice(0,je),l=new Set(a.filter((d)=>Pe(s,o,d)!==null));if(l.size===0)return{ports:[]};let c=new Map(s.processes().map((d)=>[d.pid,d.command]));return{ports:i.filter((d)=>l.has(d.pid)).slice(0,De).map((d)=>({pid:d.pid,command:c.get(d.pid)??null,address:d.address}))}}function he(e,t){let n=new Set([t]);for(let s=!0;s;){s=!1;for(let o of e)if(!n.has(o.pid)&&n.has(o.parentPid)&&o.pid!==o.parentPid)n.add(o.pid),s=!0}return n}function Je(e,t,n,s){let o=(i)=>i==="127.0.0.1"||i==="::ffff:127.0.0.1"||i==="::1";return e.flatMap((i)=>{if(!t.has(i.pid)||i.localPort!==s)return[];let a=i.listening&&(o(i.localAddress)||["0.0.0.0","::"].includes(i.localAddress)),l=!i.listening&&o(i.localAddress)&&o(i.remoteAddress);if(!a&&!l)return[];let c=`${i.localAddress}:${i.localPort}>${i.remoteAddress}:${i.remotePort}`;return[{pid:i.pid,processGroupId:n,descriptor:String(i.pid),kernelId:c,state:a?"listen":"established",port:s,peerPort:a?null:i.remotePort,host:i.localAddress==="::1"?"::1":"127.0.0.1"}]})}async function _e(e,t,n=tt(),s=oe){let o=se(n),i=he(o.processes(),e),a=await ve(s,1000),l=he(o.processes(),e);return Je(a,new Set([...i].filter((c)=>l.has(c))),e,t)}async function cc(e,t=tt(),n=oe){if(!t||e.aborted)return!1;let s=t.processes().some((l)=>l.pid===process.pid),o=t.cwd(process.pid),i=o!==null&&D(o).toLowerCase()===D(process.cwd()).toLowerCase(),a=await n(5000).then((l)=>/^\s*TCP\s/m.test(l),()=>!1);return s&&i&&a&&!e.aborted}import{execFile as Ve}from"child_process";import{readFile as Xe,readdir as Ye,readlink as Qe}from"fs/promises";import{connect as er}from"net";import{setTimeout as rr}from"timers/promises";var tr={directory:Ye,text:(e)=>Xe(e,"utf8"),link:Qe};class ie extends Error{code;constructor(e="port_unproved"){super("preview_port_ownership_unproved");this.code=e}}var x=(e)=>new ie(e),Y="preview_listener_unproved",ke="00000000000000000000000001000000";async function nr(e,t,n=tr){let s=new Map;for(let a of["tcp","tcp6"]){let l=await n.text(`/proc/net/${a}`);if(l.length>4194304)throw x();for(let c of l.split(`
|
|
6
|
+
`);P.write(Buffer.concat([Buffer.from(h,"latin1"),m.subarray(f+4)])),P.pipe(c),c.pipe(P),c.resume()}});await new Promise((c,d)=>{i.once("error",d),i.listen(0,"127.0.0.1",c)});let a=i.address();if(!a||typeof a==="string")throw i.close(),Error("preview_bind_failed");function l(){if(o)return;o=!0,t.removeEventListener("abort",l);for(let c of s)c.destroy();s.clear(),i.close()}if(t.addEventListener("abort",l,{once:!0}),t.aborted)l();return{port:a.port,headers:{[ge]:n},close:l}}var Le=60000,Ce=1e4,Ne=5000,$e=/^(?:text\/(?!event-stream)|application\/(?:(?:x-)?javascript|json|[a-z.+-]*\+json|xml|[a-z.+-]*\+xml|wasm)|image\/svg\+xml)/i;function Me(e,t,n,s){let o=(c)=>t.find(([d])=>d.toLowerCase()===c)?.[1],i=(c)=>s.find(([d])=>d.toLowerCase()===c)?.[1],a=Number(i("content-length")??Number.NaN);if(e!=="GET"||n!==200||o("range")!==void 0||i("content-encoding")!==void 0||!$e.test(i("content-type")??"")||/\bno-transform\b/i.test(i("cache-control")??"")||a<1024)return null;let l=(c)=>new RegExp(`(?:^|,)\\s*${c}\\s*(?:,|$|;\\s*q=(?:1|0?\\.0*[1-9]))`,"i").test(o("accept-encoding")??"");return l("br")?"br":l("gzip")?"gzip":null}function Oe(e,t){let n=e.filter(([s])=>s.toLowerCase()==="vary").map(([,s])=>s).join(", ");return[...e.filter(([s])=>!["vary","etag","content-md5"].includes(s.toLowerCase())),...e.filter(([s])=>s.toLowerCase()==="etag").map(([s,o])=>[s,o.startsWith("W/")?o:`W/${o}`]),["Content-Encoding",t],["Vary",n.split(",").some((s)=>/^\s*(?:accept-encoding|\*)\s*$/i.test(s))?n:n?`${n}, Accept-Encoding`:"Accept-Encoding"]]}async function Io(e){process.stderr.write(`${JSON.stringify({event:"worker_preview.open_refused",job_id:e.jobId,port:e.port,reason_code:e.reason})}
|
|
7
|
+
`);let t=e.binding,n;try{n=V(e.deviceRelayUrl,"device")}catch{return}if(!t)return;await new Promise((s)=>{let o=new U(n,{followRedirects:!1,perMessageDeflate:!1,maxPayload:4096}),i=setTimeout(()=>{o.terminate(),s()},v.authorizationMs*2);o.addEventListener("open",()=>{o.send(JSON.stringify({type:"refused",binding:t,reason:e.reason})),o.close(1000,`worker_refused_${e.reason}`)}),o.addEventListener("error",()=>{clearTimeout(i),s()}),o.addEventListener("close",()=>{clearTimeout(i),s()})})}async function Fe(e,t){let n=Date.now()+Ce,s;for(;;){if(!t())return"closed";let o=s??=e.refusal().finally(()=>{s=void 0}),i,a=await Promise.race([o.catch(()=>"port_unproved"),new Promise((l)=>{i=setTimeout(()=>l("port_check_timeout"),v.authorizationMs)})]).finally(()=>clearTimeout(i));if(a===null)return null;if(!["listener_unproved","port_check_timeout"].includes(a)||Date.now()+500>=n)return a;await new Promise((l)=>setTimeout(l,500))}}async function ht(e){let t=C(e.binding),n=()=>!e.signal.aborted&&Date.now()<t.expiresAtMs,s=t.expiresAtMs>Date.now()+v.lifetimeMs+Ne?"binding_mismatch":await Fe(e.port,n);if(s)throw await Io({deviceRelayUrl:e.deviceRelayUrl,binding:t,jobId:t.jobId,port:t.port,reason:s}),Error("preview_not_authorized",{cause:s});let o=V(e.deviceRelayUrl,"device"),i=await be(e.port,e.signal),a;try{a=new U(o,{followRedirects:!1,perMessageDeflate:!1,maxPayload:v.upload*1.4+300000})}catch(p){throw i.close(),p}let l=new Map,c=!1,d=!1,g=0,w=!1,u,m,f,b=new Promise((p)=>{f=p}),_,k,O=new Promise((p,y)=>{_=p,k=y}),T=!1,P=(p)=>{let y=Buffer.isBuffer(p)?p:JSON.stringify(p);if(g+=Buffer.byteLength(y),!n()||d||a.readyState!==U.OPEN)return h(n()?"relay_closed":"expired");if(a.bufferedAmount>v.relayBuffered)return h("relay_backlog");if(g>v.total)return h("quota");a.send(y)};function h(p="closed"){if(d)return;d=!0,clearInterval(N),clearTimeout(S),e.signal.removeEventListener("abort",B);for(let y of l.values())y.stop();l.clear(),i.close(),a.close(1000,`worker_${p}`),k(Error("preview_closed")),f()}let B=()=>h("aborted"),S=setTimeout(()=>h("pair_timeout"),v.requestMs),N=setInterval(async()=>{if(!n())return h(e.signal.aborted?"aborted":"expired");if(w)return;w=!0;try{let p=u??=Promise.resolve().then(()=>e.port.check()).finally(()=>{u=void 0}),y=await te(()=>p);if(y===!1)return h("port_refused");if(y){m=void 0;return}if(Date.now()-(m??=Date.now())>Le)return h("port_unknown");for(let E of l.values())E.stop()}finally{w=!1}},1000);if(e.signal.addEventListener("abort",B,{once:!0}),!n())h(e.signal.aborted?"aborted":"expired");a.addEventListener("open",()=>P({type:"hello",binding:t,messages:v.upload,window:v.window})),a.addEventListener("close",()=>h("relay_closed")),a.addEventListener("error",()=>h("relay_error")),a.addEventListener("message",(p)=>{try{if(!n()||d)return h(e.signal.aborted?"aborted":"expired");if(typeof p.data!=="string")throw Error("preview_frame_invalid");if(g+=Buffer.byteLength(p.data),g>v.total)return h("quota");let y=gi(p.data);if(!c){if(y.type!=="hello"||!Bt(t,y.binding))return h("binding_mismatch");c=!0,T=y.bytes===!0,clearTimeout(S),_();return}if(y.type==="hello"||y.type==="refused")return h("invalid_frame");if(y.type==="request"){q(y).catch(()=>h("invalid_request"));return}let E=l.get(y.id);if(!E)return;if(y.type==="cancel"||y.type==="end")E.stop();else if(y.type==="credit"&&E.credit)E.credit();else if(y.type==="data"&&E.ws){if(E.ws.readyState!==U.OPEN||E.ws.bufferedAmount>v.buffered)return E.stop();let I=z(y.data,v.upload);E.ws.send(y.binary?I:I.toString("utf8"))}else h("invalid_frame")}catch{h("invalid_frame")}});async function q(p){if(l.has(p.id)||l.size>=v.streams)return h("stream_limit");if(!n())return h(e.signal.aborted?"aborted":"expired");let y=new AbortController,E,I,K,Q=0,R=(W=!1)=>{if(!l.delete(p.id))return;clearTimeout(E),y.abort(),I?.close(1000,"preview_closed"),K?.(),P({type:W?"end":"cancel",id:p.id})},ae={stop:()=>R(),credit:()=>{Q++,K?.()}};if(l.set(p.id,ae),E=setTimeout(R,v.requestMs),!await ln(()=>e.port.check())||!n()||y.signal.aborted)return R();let de=H(p.path);if(p.upgrade){if(p.method!=="GET"||p.body)return R();let W=p.headers.find(([A])=>A.toLowerCase()==="sec-websocket-protocol")?.[1].split(",").map((A)=>A.trim());if(W?.some((A)=>!/^[a-zA-Z0-9._-]{1,100}$/.test(A))||(W?.length??0)>8)return R();I=new U(`ws://127.0.0.1:${i.port}${de}`,W,{headers:i.headers,followRedirects:!1,perMessageDeflate:!1,maxPayload:v.upload}),ae.ws=I,I.binaryType="arraybuffer",I.addEventListener("open",()=>{clearTimeout(E),P({type:"ws",id:p.id,protocol:I.protocol})}),I.addEventListener("message",(A)=>{let G=typeof A.data!=="string",M=me(A.data);if(M.length>v.upload)return R();P({type:"data",id:p.id,data:M.toString("base64"),binary:G})}),I.addEventListener("error",()=>R()),I.addEventListener("close",(A)=>R(A.wasClean));return}let xe=z(p.body,v.upload),ce=Ie({hostname:"127.0.0.1",port:i.port,path:de,method:p.method,headers:{...Object.fromEntries(re(p.headers)),...i.headers,connection:"close"},signal:y.signal,agent:!1,maxHeaderSize:16384},async(W)=>{try{let A=[];for(let F=0;F<W.rawHeaders.length;F+=2)A.push([W.rawHeaders[F],W.rawHeaders[F+1]]);let G=W.statusCode??502,M=Me(p.method,p.headers,G,A),ee=M==="br"?Re({flush:ne.BROTLI_OPERATION_FLUSH,params:{[ne.BROTLI_PARAM_QUALITY]:5}}):M==="gzip"?Be({level:6,flush:ne.Z_SYNC_FLUSH}):void 0;if(P({type:"head",id:p.id,status:G,headers:re(M?Oe(A,M):A)}),clearTimeout(E),ee)We(W,ee,()=>{});for await(let F of ee??W){let le=Buffer.from(F);for(let Z=0;Z<le.length;Z+=v.chunk){if(Q===0&&!y.signal.aborted)await new Promise((Se)=>{K=Se});if(K=void 0,y.signal.aborted)return;Q--;let ue=le.subarray(Z,Z+v.chunk);P(T?we(p.id,ue):{type:"data",id:p.id,data:ue.toString("base64"),binary:!0})}}R(!0)}catch{R()}});ce.on("error",()=>R()),ce.end(xe)}return await O,{close:h,closed:b}}import{execFile as ze}from"child_process";import{createRequire as He}from"module";import{win32 as X}from"path";var Ue=250,je=50,De=250,qe=4194304;function ye(e){let t=/^(?:\[([^\]]+)\]|([^:]+)):([0-9]{1,5})$/.exec(e??""),n=Number(t?.[3]);return t&&n<=65535?{address:t[1]??t[2],port:n}:null}function Ke(e){let t=[];for(let n of e.split(/\r?\n/)){let s=n.trim().split(/\s+/);if(s[0]!=="TCP"||s.length<5)continue;let o=ye(s[1]),i=ye(s[2]),a=Number(s.at(-1));if(!o||!i||!Number.isSafeInteger(a)||a<0)continue;t.push({pid:a,localAddress:o.address,localPort:o.port,remoteAddress:i.address,remotePort:i.port,listening:i.port===0})}return t}function Ge(e){if(e.localAddress==="0.0.0.0"||e.localAddress==="::")return`*:${e.localPort}`;return e.localAddress.includes(":")?`[${e.localAddress}]:${e.localPort}`:`${e.localAddress}:${e.localPort}`}var oe=(e)=>new Promise((t,n)=>ze(X.join(Tt("win32").split(";")[0],"NETSTAT.EXE"),["-ano"],{timeout:e,maxBuffer:qe,encoding:"utf8",windowsHide:!0,env:It()},(s,o)=>s?n(s):t(o)));function D(e){let t=X.normalize(e.startsWith("\\\\?\\")?e.slice(4):e);return t.length>3&&t.endsWith("\\")?t.slice(0,-1):t}function Ze(e,t){let n=e.toLowerCase(),s=t.toLowerCase();return s===n||s.startsWith(n.endsWith("\\")?n:`${n}\\`)}function Pe(e,t,n){let s=e.cwd(n),o=s?D(s):null;return o&&X.isAbsolute(o)&&Ze(t,o)?o:null}var j;function tt(){if(j!==void 0)return j;if(j=null,process.platform!=="win32"||!["x64","arm64"].includes(process.arch))return null;let e;try{e=He(import.meta.url)("bun:ffi")}catch{return null}let{FFIType:t,ptr:n}=e,s,o;try{s=e.dlopen("kernel32.dll",{CreateToolhelp32Snapshot:{args:[t.u32,t.u32],returns:t.u64},Process32FirstW:{args:[t.u64,t.ptr],returns:t.i32},Process32NextW:{args:[t.u64,t.ptr],returns:t.i32},OpenProcess:{args:[t.u32,t.i32,t.u32],returns:t.u64},ReadProcessMemory:{args:[t.u64,t.u64,t.ptr,t.u64,t.ptr],returns:t.i32},CloseHandle:{args:[t.u64],returns:t.i32}}).symbols,o=e.dlopen("ntdll.dll",{NtQueryInformationProcess:{args:[t.u64,t.i32,t.ptr,t.u32,t.ptr],returns:t.i32}}).symbols}catch{return null}let i=0xFFFFFFFFFFFFFFFFn,a=2,l=1040,c=568,d=(g,w,u)=>{let m=Buffer.alloc(u);return s.ReadProcessMemory(g,w,n(m),u,null)?m:null};return j={processes(){let g=BigInt(s.CreateToolhelp32Snapshot(a,0));if(g===i)throw new r("process_inspection_failed","Reading this computer's processes did not complete.");try{let w=Buffer.alloc(c);w.writeUInt32LE(c,0);let u=n(w),m=[];for(let f=s.Process32FirstW(g,u);f;f=s.Process32NextW(g,u)){let b=w.toString("utf16le",44,c),_=b.slice(0,b.includes("\x00")?b.indexOf("\x00"):void 0),k=w.readUInt32LE(8);if(k>0)m.push({pid:k,parentPid:w.readUInt32LE(32),command:_.replace(/\.exe$/i,"")||null})}return m}finally{s.CloseHandle(g)}},cwd(g){let w=BigInt(s.OpenProcess(l,0,g));if(w===0n)return null;try{let u=Buffer.alloc(48);if(o.NtQueryInformationProcess(w,0,n(u),u.length,null)!==0)return null;let m=d(w,u.readBigUInt64LE(8)+0x20n,8)?.readBigUInt64LE(0),f=m?d(w,m+0x38n,16):null,b=f?.readUInt16LE(0)??0;if(!f||b===0||b%2!==0)return null;return d(w,f.readBigUInt64LE(8),b)?.toString("utf16le")??null}finally{s.CloseHandle(w)}}},j}function se(e){if(!e)throw new r("process_inspection_failed","Reading this computer's processes is unavailable.");return e}async function ve(e,t){let n;try{n=await e(t)}catch{throw new r("process_inspection_failed","Reading this computer's ports did not complete.")}return Ke(n)}async function sc(e,t=tt()){let n=se(t),s=D(e),o=[];for(let i of n.processes()){if(o.length>=Ue)break;let a=Pe(n,s,i.pid);if(a)o.push({pid:i.pid,command:i.command,cwd:X.relative(s,a)||"."})}return{processes:o}}async function ac(e,t=tt(),n=oe){let s=se(t),o=D(e),i=(await ve(n,5000)).filter((d)=>d.listening&&d.pid>0).map((d)=>({pid:d.pid,port:d.localPort,address:Ge(d)})).sort((d,g)=>d.pid-g.pid||d.port-g.port||(d.address<g.address?-1:d.address>g.address?1:0)),a=[...new Set(i.map((d)=>d.pid))].slice(0,je),l=new Set(a.filter((d)=>Pe(s,o,d)!==null));if(l.size===0)return{ports:[]};let c=new Map(s.processes().map((d)=>[d.pid,d.command]));return{ports:i.filter((d)=>l.has(d.pid)).slice(0,De).map((d)=>({pid:d.pid,command:c.get(d.pid)??null,address:d.address}))}}function he(e,t){let n=new Set([t]);for(let s=!0;s;){s=!1;for(let o of e)if(!n.has(o.pid)&&n.has(o.parentPid)&&o.pid!==o.parentPid)n.add(o.pid),s=!0}return n}function Je(e,t,n,s){let o=(i)=>i==="127.0.0.1"||i==="::ffff:127.0.0.1"||i==="::1";return e.flatMap((i)=>{if(!t.has(i.pid)||i.localPort!==s)return[];let a=i.listening&&(o(i.localAddress)||["0.0.0.0","::"].includes(i.localAddress)),l=!i.listening&&o(i.localAddress)&&o(i.remoteAddress);if(!a&&!l)return[];let c=`${i.localAddress}:${i.localPort}>${i.remoteAddress}:${i.remotePort}`;return[{pid:i.pid,processGroupId:n,descriptor:String(i.pid),kernelId:c,state:a?"listen":"established",port:s,peerPort:a?null:i.remotePort,host:i.localAddress==="::1"?"::1":"127.0.0.1"}]})}async function _e(e,t,n=tt(),s=oe){let o=se(n),i=he(o.processes(),e),a=await ve(s,1000),l=he(o.processes(),e);return Je(a,new Set([...i].filter((c)=>l.has(c))),e,t)}async function cc(e,t=tt(),n=oe){if(!t||e.aborted)return!1;let s=t.processes().some((l)=>l.pid===process.pid),o=t.cwd(process.pid),i=o!==null&&D(o).toLowerCase()===D(process.cwd()).toLowerCase(),a=await n(5000).then((l)=>/^\s*TCP\s/m.test(l),()=>!1);return s&&i&&a&&!e.aborted}import{execFile as Ve}from"child_process";import{readFile as Xe,readdir as Ye,readlink as Qe}from"fs/promises";import{connect as er}from"net";import{setTimeout as rr}from"timers/promises";var tr={directory:Ye,text:(e)=>Xe(e,"utf8"),link:Qe};class ie extends Error{code;constructor(e="port_unproved"){super("preview_port_ownership_unproved");this.code=e}}var x=(e)=>new ie(e),Y="preview_listener_unproved",ke="00000000000000000000000001000000";async function nr(e,t,n=tr){let s=new Map;for(let a of["tcp","tcp6"]){let l=await n.text(`/proc/net/${a}`);if(l.length>4194304)throw x();for(let c of l.split(`
|
|
8
8
|
`).slice(1)){let d=c.trim().split(/\s+/);if(d.length<10||!["0A","01"].includes(d[3]))continue;let[g,w]=d[1].split(":"),[u,m]=d[2].split(":");if(Number.parseInt(w,16)!==t)continue;let f=(k)=>k==="0100007F"||k==="0000000000000000FFFF00000100007F"||k===ke,b=d[3]==="0A";if(!(f(g)||b&&/^0+$/.test(g??"")))continue;if(!b&&!f(u))continue;let _=d[9];if(!/^[1-9][0-9]*$/.test(_))continue;s.set(_,{kernelId:_,port:t,peerPort:b?null:Number.parseInt(m,16),state:b?"listen":"established",host:g===ke?"::1":"127.0.0.1"})}}let o=await n.directory("/proc");if(o.length>8192)throw x();let i=[];for(let a of o){if(!/^[1-9][0-9]*$/.test(a))continue;try{let l=await n.text(`/proc/${a}/stat`),c=l.slice(l.lastIndexOf(")")+2).trim().split(/\s+/);if(Number(c[2])!==e)continue;let d=await n.directory(`/proc/${a}/fd`);if(d.length>1024)throw x();let g=[];for(let m of d){if(!/^[0-9]+$/.test(m))continue;let f=await n.link(`/proc/${a}/fd/${m}`).catch(()=>""),b=/^socket:\[([0-9]+)\]$/.exec(f)?.[1],_=b?s.get(b):void 0;if(_)g.push({..._,pid:Number(a),processGroupId:e,descriptor:m})}let w=await n.text(`/proc/${a}/stat`),u=w.slice(w.lastIndexOf(")")+2).trim().split(/\s+/);if(c[19]===u[19]&&c[2]===u[2])i.push(...g)}catch(l){if(l instanceof Error&&l.message==="preview_port_ownership_unproved")throw l}}return i}function or(e,t,n){if(e.length>2097152)throw x();let s=0,o=0,i="",a="",l="",c="",d=[],g=()=>{if(s<1||o!==t||!/^\d+$/.test(i)||!/^0x[0-9a-f]+$/i.test(a))return;let w=c==="LISTEN"&&["*","127.0.0.1","[::ffff:127.0.0.1]","[::1]"].some((m)=>l===`${m}:${n}`),u=new RegExp(`^(?:127\\.0\\.0\\.1|\\[::ffff:127\\.0\\.0\\.1\\]|\\[::1\\]):${n}->(?:127\\.0\\.0\\.1|\\[::ffff:127\\.0\\.0\\.1\\]|\\[::1\\]):([0-9]+)$`).exec(l);if(w||c==="ESTABLISHED"&&u)d.push({pid:s,processGroupId:o,descriptor:i,kernelId:a,state:w?"listen":"established",port:n,peerPort:w?null:Number(u[1]),host:l.startsWith("[::1]:")?"::1":"127.0.0.1"})};for(let w of e.split(/[\0\n]/)){let u=w.slice(1);if(w[0]==="p")g(),s=Number(u),o=0,i=a=l=c="";else if(w[0]==="g")o=Number(u);else if(w[0]==="f")g(),i=u,a=l=c="";else if(w[0]==="d")a=u;else if(w[0]==="n")l=u;else if(w.startsWith("TST="))c=w.slice(4)}return g(),d}async function sr(e,t){if(process.platform==="linux")return nr(e,t);if(process.platform==="win32")return _e(e,t);if(process.platform!=="darwin")throw x();let n=await new Promise((s,o)=>Ve("/usr/sbin/lsof",["-nP","-a","-g",String(e),`-iTCP:${t}`,"-F0pgfdnT"],{timeout:1000,maxBuffer:2097152,encoding:"utf8",env:{PATH:"/usr/bin:/bin",LC_ALL:"C"}},(i,a)=>i?o(x()):s(a)));return or(n,e,t)}function ft(e,t={}){let n=C(e.binding),s=t.inspectSockets??sr,o=t.monotonicNow??(()=>performance.now());async function i(){let u=()=>{if(Date.now()>=n.expiresAtMs)throw x("binding_expired");if(e.deniedPorts.has(n.port))throw x("port_denied")};u();let m=await e.readCurrentJob(),f=m?.job,b=f?.process;if(u(),!m)throw x("server_stopped");if(!Bt(n,m.binding)||f?.jobId!==n.jobId)throw x("binding_changed");if(f.state!=="running"||f.finishedAtMs!==null||f.leaseExpiresAtMs<n.expiresAtMs)throw x("job_not_running");if(!b||b.pid<1||b.pid!==b.processGroupId||b.executorLaunchId!==m.executorLaunchId)throw x("process_unproved");return{pid:b.pid,launch:b.executorLaunchId,started:f.startedAtMs}}let a,l;async function c(){let u=await i(),m=await s(u.pid,n.port).catch(()=>{throw Error(Y)}),f=await i();if(u.pid!==f.pid||u.launch!==f.launch||u.started!==f.started)throw x("job_restarted");return m}async function d(u){for(;;){if(l&&l.startedAt>=u)return l.sockets;if(a&&a.startedAt>=u)return await a.sockets;if(a){await a.sockets.catch(()=>{});continue}let m={startedAt:o(),sockets:c()};a=m;try{let f=await m.sockets;if(!l||l.startedAt<=m.startedAt)l={startedAt:m.startedAt,sockets:f};return f}finally{if(a===m)a=void 0}}}async function g(u=()=>{},m=o()){u();let f=await d(m);if(u(),Date.now()>=n.expiresAtMs)throw x("binding_expired");if(!f.some((b)=>b.state==="listen"))throw Error(Y);return f}async function w(){try{return await g(()=>{},o()-1000),null}catch(u){if(u instanceof Error&&u.message===Y)return"listener_unproved";return u instanceof ie?u.code:"port_unproved"}}return{refusal:w,async check(){let u=await w();if(u==="listener_unproved")throw Error(Y);return u===null},async connect(u){if(u.aborted)throw x();let m=o()+2000,f=new AbortController,b=new Promise((h)=>f.signal.addEventListener("abort",()=>h(null),{once:!0})),_,k=()=>{f.abort(),_?.destroy()},O=setTimeout(k,2000);u.addEventListener("abort",k,{once:!0});let T=()=>{if(f.signal.aborted||u.aborted||o()>=m||_?.destroyed)throw k(),x()};async function P(h){T();let B=await Promise.race([h().then((S)=>({value:S})),b]);if(T(),!B)throw x();return B.value}try{let h=await P(()=>g(T,o()-1000));T();let B=h.some((p)=>p.state==="listen"&&p.host==="127.0.0.1")?"127.0.0.1":"::1",S=er({host:B,port:n.port,signal:u});_=S,S.once("close",k),await P(()=>new Promise((p,y)=>{S.once("connect",p),S.once("error",y)}));let N=S.localPort;if(!N)throw x();let q=o();while(!(await P(()=>g(T,q))).some((p)=>p.state==="established"&&p.peerPort===N))await P(()=>rr(Math.min(20,Math.max(1,m-o())),void 0,{signal:f.signal})),q=o();return T(),S}catch(h){throw k(),h}finally{clearTimeout(O),u.removeEventListener("abort",k),_?.off("close",k),f.abort()}}}}
|
|
9
|
-
export{v,Bt,
|
|
9
|
+
export{v,Bt,gi,ln,pr,oc,Io,ht,tt,sc,ac,cc,ft};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{s}from"./vm-hands-entry-lite-
|
|
3
|
-
`)){let e=c.split(":");if(e.length<7||Number(e[2])!==t||!/^\d+$/.test(e[2])||!/^\d+$/.test(e[3]))continue;let n=e[5];if(!/^[a-z_][a-z0-9_-]*$/i.test(e[0])||!i(n)||m(n)!==n||n==="/")return null;return{username:e[0],uid:t,gid:Number(e[3]),home:n}}return null}function kr(t={}){let o="value"in t?t.value:process.env[p];if(u=null,o===void 0||o==="")return null;let c=t.platform??process.platform,e="euid"in t?t.euid:process.geteuid?.(),n=/^[1-9]\d{0,9}$/.test(o)?Number(o):NaN,r=c==="linux"&&e===0&&Number.isSafeInteger(n)?d(n,(t.passwd??(()=>l("/etc/passwd","utf8")))()):null;if(!r||r.gid===0)throw Error("worker_desktop_user_invalid");return u=r,r}function ue(){return u}function
|
|
4
|
-
export{kr,ue,
|
|
2
|
+
import{s}from"./vm-hands-entry-lite-tzv8s0e7.js";import{readFileSync as l}from"fs";import{isAbsolute as i,normalize as m}from"path";var p="REASON_WORKER_DESKTOP_USER",u=null;function d(t,o){for(let c of o.split(`
|
|
3
|
+
`)){let e=c.split(":");if(e.length<7||Number(e[2])!==t||!/^\d+$/.test(e[2])||!/^\d+$/.test(e[3]))continue;let n=e[5];if(!/^[a-z_][a-z0-9_-]*$/i.test(e[0])||!i(n)||m(n)!==n||n==="/")return null;return{username:e[0],uid:t,gid:Number(e[3]),home:n}}return null}function kr(t={}){let o="value"in t?t.value:process.env[p];if(u=null,o===void 0||o==="")return null;let c=t.platform??process.platform,e="euid"in t?t.euid:process.geteuid?.(),n=/^[1-9]\d{0,9}$/.test(o)?Number(o):NaN,r=c==="linux"&&e===0&&Number.isSafeInteger(n)?d(n,(t.passwd??(()=>l("/etc/passwd","utf8")))()):null;if(!r||r.gid===0)throw Error("worker_desktop_user_invalid");return u=r,r}function ue(){return u}function ns(){return u?.home??s()}
|
|
4
|
+
export{kr,ue,ns};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{B}from"./vm-hands-entry-lite-
|
|
3
|
-
`).flatMap((n)=>{let s=/^\s*(\d+)\s+(\d+)\s+(.+)$/.exec(n);return s&&Number(s[2])===e?[{pid:Number(s[1]),command:s[3]}]:[]})}async function
|
|
4
|
-
export{qr,Dl,
|
|
2
|
+
import{B}from"./vm-hands-entry-lite-04nx5y4f.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFileSync as h}from"child_process";import{mkdirSync as k,readdirSync as D,readFileSync as w,rmSync as g,statSync as x,writeFileSync as L}from"fs";import{join as p,sep as y}from"path";import{setTimeout as _}from"timers/promises";var P=3000,u=null;function S(e){return p(e,"users")}function qr(e){if(u?.root===e.root)return;let o=S(e.root);k(o,{recursive:!0,mode:448}),L(p(o,String(process.pid)),"",{mode:384}),u=e}function Dl(){if(!u)return;g(p(S(u.root),String(process.pid)),{force:!0}),u=null}function m(e){try{return process.kill(e,0),!0}catch(o){return o instanceof Error&&"code"in o&&o.code==="EPERM"}}function E(){let e=process.getuid?.();if(process.platform==="linux")return D("/proc").flatMap((n)=>{if(!/^\d+$/.test(n))return[];try{if(x(`/proc/${n}`).uid!==e)return[];let s=w(`/proc/${n}/cmdline`).toString("utf8").split("\x00").join(" ").trim();return s?[{pid:Number(n),command:s}]:[]}catch{return[]}});if(process.platform==="win32")return h(B("powershell.exe"),["-NoLogo","-NoProfile","-NonInteractive","-Command",'Get-CimInstance Win32_Process | ForEach-Object { "$($_.ProcessId) $($_.CommandLine)" }'],{encoding:"utf8",maxBuffer:16777216,windowsHide:!0}).split(/\r?\n/).flatMap((s)=>{let l=/^(\d+) (.+)$/.exec(s.trim());return l?[{pid:Number(l[1]),command:l[2]}]:[]});return h("/bin/ps",["-axww","-o","pid=,uid=,command="],{encoding:"utf8",maxBuffer:16777216}).split(`
|
|
3
|
+
`).flatMap((n)=>{let s=/^\s*(\d+)\s+(\d+)\s+(.+)$/.exec(n);return s&&Number(s[2])===e?[{pid:Number(s[1]),command:s[3]}]:[]})}async function wa(){let e=u;if(!e)return{released:"unused",stopped:0};let o=S(e.root);g(p(o,String(process.pid)),{force:!0}),u=null;let n=!1;for(let t of D(o)){let c=Number(t);if(Number.isSafeInteger(c)&&c>0&&m(c))n=!0;else g(p(o,t),{force:!0})}if(n)return{released:"shared",stopped:0};let s=E().filter((t)=>t.pid!==process.pid&&(t.command.includes(`${e.root}${y}`)||t.command.includes(`${e.automation}${y}`)||t.command.includes(e.extensionDir))),l=(t,c)=>{try{process.kill(t,c)}catch{}};for(let t of s)l(t.pid,"SIGTERM");for(let t=Date.now()+P;Date.now()<t&&s.some((c)=>m(c.pid));)await new Promise((c)=>setTimeout(c,100));for(let t of s)if(m(t.pid))l(t.pid,"SIGKILL");return{released:"stopped",stopped:s.length}}var M=20000,N=30000,O=100,a=new Map,i=null,b=0,f=[];function ba(e){a.set(e,(a.get(e)??0)+1);let o=!1;return()=>{if(o)return;o=!0;let n=(a.get(e)??1)-1;if(n>0){a.set(e,n);return}if(a.delete(e),i?.run===e)i.idleUntil=0}}function T(){return new r("automation_desktop_busy","Another Session, or another agent of this Session, is using this worker's desktop. Retry after it finishes.")}function U(e,o){return i!==null&&i.run!==e&&(i.calls>0||o<i.idleUntil)}async function va(e,o,n=Date.now,s="run"){let l=Symbol(e);f.push(l);try{let d=n()+N;for(;;){if(b===0&&!U(e,n())&&(i?.run===e||f[0]===l))break;if(n()>=d)throw T();await _(O,void 0,{signal:o}).catch(()=>o.throwIfAborted())}}finally{f.splice(f.indexOf(l),1)}if(s==="call"&&!(i?.run===e&&(i.calls>0||n()<i.idleUntil))){b+=1;let d=!1;return()=>{if(d)return;d=!0,b-=1}}if(i?.run!==e)i={run:e,calls:0,idleUntil:0};let t=i;t.calls+=1;let c=!1;return()=>{if(c)return;c=!0,t.calls-=1,t.idleUntil=n()+M}}
|
|
4
|
+
export{qr,Dl,wa,ba,va};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{g}from"./vm-hands-entry-lite-
|
|
2
|
+
import{g}from"./vm-hands-entry-lite-crjaacc2.js";import{s}from"./vm-hands-entry-lite-tzv8s0e7.js";import{randomUUID as P}from"crypto";import{spawnSync as b}from"child_process";import{chmodSync as z,cpSync as Z,existsSync as x,lstatSync as A,mkdirSync as L,readdirSync as ee,readFileSync as C,readlinkSync as te,realpathSync as T,renameSync as _,rmdirSync as ne,rmSync as y,symlinkSync as D,writeFileSync as re}from"fs";import{dirname as h,join as u,relative as ie,resolve as oe}from"path";var ms="so.ara.cli",w=[ms,"com.reasonmachines.cli"],ji="5LJFSBRY2F";function Hi(e){return`(${e.map((t)=>`identifier "${t}"`).join(" or ")}) and anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] exists and certificate leaf[field.1.2.840.113635.100.6.1.13] exists and certificate leaf[subject.OU] = "${ji}"`}var Y="ReasonBackgroundIdentity",Bc="Contents/Helpers/ReasonPermissionTile",se="so.ara.cli.permission-tile",be=Hi([se,"com.reasonmachines.cli.permission-tile"]),k="AraBackgroundIdentity",ce="Reason",Ae=Hi(w),ae=`anchor apple generic and (${w.map((e)=>`identifier "${e}"`).join(" or ")}) and certificate leaf[subject.OU] = "${ji}"`;class St extends Error{code;constructor(e,t){super(t);this.code=e;this.name="MacOSBackgroundIdentityError"}}var Nn="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";function st(e=s()){return u(e,"Library","Application Support","Reason","Background","Reason.app")}function O(e=s()){return u(e,"Library","Application Support","Ara","Background","Ara.app")}function ue(e){try{return A(e).isFile()}catch{return!1}}function v(e){return[Y,k].map((t)=>u(e,"Contents","MacOS",t)).find(ue)??null}function d(e){try{if(!A(e).isDirectory())return!1;let t=C(u(e,"Contents","Info.plist"),"utf8");return w.some((n)=>t.includes(`<string>${n}</string>`))&&(t.includes(`<string>${ce}</string>`)||t.includes("<string>Ara</string>"))&&v(e)!==null}catch{return!1}}function Yt(e=s()){let t=st(e);if(!d(t))return null;try{let n=C(u(t,"Contents","Info.plist"),"utf8");return/<key>CFBundleVersion<\/key>\s*<string>(\d+\.\d+\.\d+)<\/string>/.exec(n)?.[1]??null}catch{return null}}function gs(e,t=s()){let n=Yt(t);return n===null||V(R(n.split(".")),R(e.split(/[.-]/).slice(0,3)))}var le=1e4;function F(e,t){return b(e,[...t],{stdio:"ignore",timeout:le}).status??1}var G=new Set;function K(e){if(process.env.REASON_TEST_REFUSE_REAL_IDENTITY!=="1")return;let t=(n)=>{try{return T(n)}catch{return oe(n)}};if(e!==void 0&&t(e)!==t(s()))return;throw Error("A test tried to change this computer's real Reason background identity; pass a temporary home. Refused by scripts/test-env.ts.")}var W=/\/(?:runtime|CLI)\/versions\/(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$|\/\.(?:ara|reason)(?:-staging)?-worker-(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$/,H=new Set(["ara","ara.exe","reason","reason.exe"]);function R(e){return e.map((t)=>Number(t))}function V(e,t){for(let n=0;n<3;n+=1)if(e[n]!==t[n])return e[n]<t[n];return!1}var de=[0,2,161];function fe(e){if(e===null)return!0;let t=de,n=null;try{n=T(process.execPath)}catch{}return e.some((r)=>{let i=W.exec(r);if(i){let f=i[1]===void 0?i.slice(4,7):i.slice(1,4);return V(R(f),t)}let o=r.slice(r.lastIndexOf("/")+1);return H.has(o)&&r!==n&&r!==process.execPath})}function pe(){let e=b("/bin/ps",["-xo","pid=,comm="],{encoding:"utf8",timeout:5000});if(e.status!==0)return null;let t=[];for(let n of e.stdout.split(`
|
|
3
3
|
`)){let r=/^\s*(\d+)\s+(\S.*)$/.exec(n);if(!r||Number(r[1])===process.pid)continue;let i=r[2].trimEnd(),o=i.slice(i.lastIndexOf("/")+1);if(!W.test(i)&&H.has(o)){let a=b("/usr/sbin/lsof",["-a","-p",r[1],"-d","txt","-Fn"],{encoding:"utf8",timeout:5000}).stdout?.split(`
|
|
4
|
-
`).find((l)=>l.startsWith("n/"));if(a)i=a.slice(1)}t.push(i)}return t}function
|
|
5
|
-
`)}}function ge(e,t,n,r){let i=v(e);if(!i)return;let o=O(t),f=h(o),a=(c)=>u(c,"Contents","MacOS",k),l=ie(h(a(o)),i),m=`${process.pid}.${P()}`,S=X(o);if(S===null)return;let I=S==="bundle";if(I)n(
|
|
6
|
-
`?[i,"--spawn"]:[]}var U=new Map;function Tr(e=s()){let t=
|
|
7
|
-
`,U.set(n,r)}return r?t:[]}function
|
|
4
|
+
`).find((l)=>l.startsWith("n/"));if(a)i=a.slice(1)}t.push(i)}return t}function _s(e){if(K(e.home),!d(e.sourceApp))throw new St("identity_invalid","The packaged Reason background identity is missing or invalid.");let t=e.command??F,n=st(e.home),r=h(n);L(r,{recursive:!0,mode:448}),z(r,448);let i=T(e.sourceApp),o=null;try{o=T(n)}catch{}if(i!==o){let f=`${process.pid}.${P()}`,a=u(r,`.Reason.app.${f}.tmp`),l=u(r,`.Reason.app.${f}.old`),m=!1;try{if(Z(i,a,{recursive:!0,errorOnExist:!0,preserveTimestamps:!0}),!d(a))throw new St("identity_invalid","The copied Reason background identity is invalid.");let S=e.releaseSigned?["--test-requirement",`=${ae}`]:[];if(t("/usr/bin/codesign",["--verify","--strict",...S,a])!==0)throw new St("identity_invalid_signature","The installed Reason background identity has an invalid signature.");let I=!1;for(let p=0;p<4;p+=1){let E=!1;try{_(n,l),E=!0,m=!0}catch(c){if(c.code!=="ENOENT")throw c}if(p===0)e.beforePublish?.();try{_(a,n),I=!0}catch(c){let Q=c.code;if(!["EEXIST","ENOTEMPTY"].includes(Q??""))throw c;if(E)y(l,{recursive:!0,force:!0}),m=!1;if(p===3)throw c;continue}if(E)y(l,{recursive:!0,force:!0}),m=!1;break}if(!I)throw Error("Could not publish Reason's background identity.")}catch(S){if(m&&!x(n)&&x(l))_(l,n);throw S}finally{y(a,{recursive:!0,force:!0}),y(l,{recursive:!0,force:!0})}}return q(n,e,{verified:i!==o}),n}function J(e){return u(h(e),".Reason.app.registered")}function j(e){try{let t=A(e);return t.isDirectory()?`${t.ino}:${t.birthtimeMs}`:null}catch{return null}}function N(e){let t=j(e);try{return t!==null&&C(J(e),"utf8")===t}catch{return!1}}function X(e){if(d(e))return"bundle";try{if(A(u(e,"Contents","Info.plist"),{throwIfNoEntry:!1}))return null;return A(u(e,"Contents","MacOS",k)).isSymbolicLink()?"retired":null}catch{return null}}function q(e,t,n={}){let r=t.command??F;if(!n.verified&&r("/usr/bin/codesign",["--verify","--strict",e])!==0)throw new St("identity_invalid_signature","The installed Reason background identity has an invalid signature.");if(r(Nn,["-f",e])!==0)throw new St("identity_register_failed","Could not register Reason's macOS background identity.");let i=j(e);try{if(i)re(J(e),i,{mode:384})}catch{}try{ge(e,t.home,r,t.runningExecutables??pe)}catch(o){let f=o.code??"unknown";process.stderr.write(`Reason background identity: legacy_identity_retire_failed (${f})
|
|
5
|
+
`)}}function ge(e,t,n,r){let i=v(e);if(!i)return;let o=O(t),f=h(o),a=(c)=>u(c,"Contents","MacOS",k),l=ie(h(a(o)),i),m=`${process.pid}.${P()}`,S=X(o);if(S===null)return;let I=S==="bundle";if(I)n(Nn,["-u",o]);let p=u(f,`.Ara.app.${m}.old`);if(!G.has(o)&&!fe(r())){if(!I)n(Nn,["-u",o]);try{_(o,p)}catch(c){if(c.code==="ENOENT")return;throw c}y(p,{recursive:!0,force:!0}),ye(f);return}if(!I){if(te(a(o))===l)return;let c=`${a(o)}.${m}`;D(l,c);try{_(c,a(o))}finally{y(c,{force:!0})}return}let E=u(f,`.Ara.app.${m}.shim`);L(h(a(E)),{recursive:!0}),D(l,a(E));try{try{_(o,p)}catch(c){if(c.code==="ENOENT")return;throw c}try{_(E,o)}catch(c){if(x(o))return;throw _(p,o),c}}finally{y(E,{recursive:!0,force:!0}),y(p,{recursive:!0,force:!0})}}function ye(e){try{if(ee(e).some((n)=>n!==".DS_Store"))return;y(u(e,".DS_Store"),{force:!0}),ne(e)}catch{}}var M=new Map;function ys(e=s()){let t=M.get(e);if(t)return t;if(process.platform!=="darwin")return[];let n=B(e);if(n===null&&x(h(st(e))))Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,100),n=B(e);if(n===null)return[];return M.set(e,n),n}function B(e){let t=st(e),n=O(e);if(!d(t)||!N(t))try{Ui({home:e,skipWhenSettled:!0})}catch{}let r=d(t)&&(N(t)||!d(n))?t:d(n)?n:null,i=r?v(r):null;if(!i)return null;if(r===n)G.add(n);let o=b(i,["--can-spawn"],{env:{},timeout:2000,encoding:"utf8"});return o.status===0&&o.stdout===`spawn
|
|
6
|
+
`?[i,"--spawn"]:[]}var U=new Map;function Tr(e=s()){let t=ys(e),n=t[0];if(!n)return[];let r=U.get(n);if(r===void 0){let i=b(n,["--can-spawn-computer-use"],{env:{},timeout:2000,encoding:"utf8"});r=i.status===0&&i.stdout===`spawn
|
|
7
|
+
`,U.set(n,r)}return r?t:[]}function Ln(e=Tr(),t=s()){if(e.length>0)return null;if(Yt(t)===null)return"computer_use_identity_missing";return gs(g,t)?"computer_use_identity_outdated":"computer_use_identity_unavailable"}function Ui(e={}){K(e.home);let t=st(e.home);if(e.skipWhenSettled&&d(t)&&N(t)&&X(O(e.home))===null)return!0;if(!d(t)){let n=O(e.home);if(!d(n))return!1;try{return _s({...e,sourceApp:n}),!0}catch(r){if(!d(t))throw r}}return q(t,e),!0}var $n="REASON_WORKER_IDENTITY_APP";function Fc(e,t=process.env,n=s()){let r=t[$n];return r&&r===st(n)?r:e}function jc(e,t){if(process.platform!=="darwin")return null;let n=st(e),r=u(n,"Contents","MacOS",Y),i=b(r,["--can-run-worker",t],{env:{},timeout:2000,encoding:"utf8"});return i.status===0&&i.stdout===`run-worker
|
|
8
8
|
`?{app:n,executable:r}:null}
|
|
9
|
-
export{
|
|
9
|
+
export{ms,ji,Hi,Bc,St,Nn,st,Yt,gs,_s,ys,Tr,Ln,Ui,$n,Fc,jc};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ke,Zt,X}from"./vm-hands-entry-lite-
|
|
2
|
+
import{Ke,Zt,X}from"./vm-hands-entry-lite-hpw27zfb.js";import{execFileSync as l}from"child_process";import{existsSync as c,realpathSync as a}from"fs";import{userInfo as f}from"os";import{isAbsolute as u,join as t,normalize as d,parse as p}from"path";function s(){let r=d(f().homedir);if(!u(r)||r===p(r).root)throw Error("Could not resolve the canonical user home.");return r}function Uc(r){return p(r).root===r}var zc=(r)=>`Reason can't work in ${r}, the top of a drive: use a folder inside it, such as a project folder`;function Ge(r,n,e=s()){let i=X(n);if(n.kind==="managed"&&n.base){let o=a(e);return{anchor:o,boundary:t(o,n.base),path:t(o,i)}}if(n.kind==="root"&&Zt(n.path)){let o=a(e);return{anchor:o,boundary:t(o,Ke),path:t(o,i)}}return{anchor:r,boundary:r,path:t(r,i)}}function Et(r=s()){return t(r,".config")}function qc(){if(process.platform!=="darwin")return null;try{let r=l("/usr/bin/getconf",["DARWIN_USER_DIR"],{encoding:"utf8",timeout:5000}).trim();return u(r)?a(r):null}catch{return null}}function Wc(r=s()){let n=t(r,"Library","Application Support","Ara"),e=t(r,"Library","Application Support","Reason");return c(n)&&!c(e)?n:e}
|
|
3
3
|
export{s,Uc,zc,Ge,Et,qc,Wc};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{D}from"./vm-hands-entry-lite-
|
|
2
|
+
import{D}from"./vm-hands-entry-lite-hh0kba1y.js";import{ys}from"./vm-hands-entry-lite-tv5mcw97.js";import{ns}from"./vm-hands-entry-lite-t2rhwchw.js";import{s}from"./vm-hands-entry-lite-tzv8s0e7.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{createHash as pe}from"crypto";import{once as Te}from"events";import{createWriteStream as Ne,existsSync as Ae,mkdirSync as Me,mkdtempSync as Pt,readFileSync as L,readdirSync as Dt,renameSync as Ue,realpathSync as He,rmSync as Le,statSync as z,writeFileSync as je}from"fs";import{delimiter as Nt,dirname as J,join as a}from"path";import{finished as Fe}from"stream/promises";var Xt="omljlfpmafedpplnpkkahegadhkimdje",yc="https://chromewebstore.google.com/detail/reason/omljlfpmafedpplnpkkahegadhkimdje";var x={ocu:{repository:"https://github.com/iFurySt/open-codex-computer-use.git",revision:"386a260d1ab8b690adbbb27f7471595cf0c2b752",version:"0.3.5"},obu:{repository:"https://github.com/iFurySt/open-browser-use.git",revision:"ac015846df75928fbcf0f3a0f3ba3a210ce1a507",version:"0.1.42"}},S={version:"155.0.8059.84",macArm64Sha256:"13b9e98ce56f5ce18e100a009f455c9285f399e7c9dc8a76fdf2f3a9755bb5f2",linux64Sha256:"cf0f049892dea22e6a6db26d47ed0d7776b7158edcbec4634086633df8bafcbc",win64Sha256:"507f2a031441d10c62b5e3d4e863f09ac1198a571c1419976cbd8387f639afde"};var R={ocu:{url:`https://registry.npmjs.org/open-computer-use/-/open-computer-use-${x.ocu.version}.tgz`,sha256:"7c16a87c8cd357787b02c0ebd040dd5f93880c1fb51c1901caa2e0c05d063130",size_bytes:5844280},obu:{url:`https://registry.npmjs.org/open-browser-use/-/open-browser-use-${x.obu.version}.tgz`,sha256:"9386d8ce0a147b3f55e1807b68edf736836378807541c457c9b5f6ca2cabaa4e",size_bytes:21372018},extension:{url:`https://github.com/iFurySt/open-browser-use/releases/download/v${x.obu.version}/open-browser-use-chrome-extension-${x.obu.version}.zip`,sha256:"c9c07bec1175e12ea6985b0e7784a5ef01fd03f014b958224a1e17dcd838a241",size_bytes:31070}},le="pnbmoicbkopffjjgfgfglopechaiemkp";import{spawn as B}from"child_process";import{createRequire as Se}from"module";import{join as ke}from"path";var Ee=30000,Ce=1048576;function G(){return process.env.SystemRoot??"C:\\Windows"}function Ie(){return ke(G(),"System32","WindowsPowerShell","v1.0","powershell.exe")}var Oe=String.raw`
|
|
3
3
|
$ErrorActionPreference = "Stop"
|
|
4
4
|
Add-Type -TypeDefinition @"
|
|
5
5
|
using System;
|
|
@@ -69,7 +69,7 @@ while ($null -ne ($line = [Console]::In.ReadLine())) {
|
|
|
69
69
|
`).join("")),t.stdin.writableLength>Ce)d({reason:"input_backpressure"})},y=()=>{l=B(...W("clipboard"),{env:K(),stdio:["ignore","pipe","ignore"],windowsHide:!0});let u="";l.stdout?.on("data",(m)=>{if(i)return;u+=m.toString("ascii");for(let g=u.indexOf(`
|
|
70
70
|
`);g>=0;g=u.indexOf(`
|
|
71
71
|
`)){let T=u.slice(0,g).replace(/\r$/,"");if(u=u.slice(g+1),!T.startsWith("c "))continue;let v=T.slice(2);if(v.length>Math.ceil(D/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(v)){d({reason:"display_protocol"});return}let p=Buffer.from(v,"base64");if(p.byteLength<=D)e.clipboard(p.toString("utf8"));if(i)return}if(u.length>Math.ceil(D/3)*4+4)d({reason:"display_protocol"})}),l.once("error",()=>f("Reason could not watch this computer's desktop clipboard.")),l.once("exit",()=>{if(!i)f("Reason could not watch this computer's desktop clipboard.")})};return t.stdout.on("data",(u)=>{if(i||o===null)return;o+=u.toString("utf8");let m=o.indexOf(`
|
|
72
|
-
`);if(m<0){if(o.length>4096)d({reason:"display_protocol"});return}let g=ie(o.slice(0,m).trim());if(o=null,!g)d({reason:"display_protocol"});else if(g.session===0)f("This Windows worker runs as a service, which has no desktop: run it in the signed-in desktop session.");else y(),e.ready({width:g.width,height:g.height})}),t.stdin.on("error",()=>{return}),t.once("error",()=>f("Reason could not start this computer's desktop input.")),t.once("exit",()=>{if(o!==null)f("Reason could not start this computer's desktop input.");else d({reason:"display_closed"})}),{pointer:(u,m,g)=>h(n.pointer(u,m,g)),key:(u,m)=>h(n.key(u,m)),clipboard:(u)=>h([`c ${Buffer.from(u,"utf8").toString("base64")}`]),close(){i=!0,c()}}}var Be=["none","standard","all"],H="22.23.4",Ge={"linux-x64":"b8492284c76a54baf58d61668dd0e41ee0fc98adabf9503d30f05d08f55b4406","linux-arm64":"f7a1e486dbc8b286847815b477d4fb5e9fb963ed4489c3e1588853d685f589f9","darwin-arm64":"c9e1dbc748b33ed2d14f42445191ecaf14c56259c7a9a26d0042c49ec2b66428","win32-x64":"cbc74b5e0982c9dbb41525fd8fb5dcd32fbee237863f7829072f4639a1ce5f20","win32-arm64":"a8b8cd79cbbb3062435f449591d98dd63730bbbf30ce2d7cc3a6376c236cb111"},X={"linux-x64":{ocu:"dist/linux/amd64/open-computer-use",obu:"native/linux-amd64/open-browser-use"},"linux-arm64":{ocu:"dist/linux/arm64/open-computer-use",obu:"native/linux-arm64/open-browser-use"},"darwin-arm64":{ocu:"dist/Open Computer Use.app/Contents/MacOS/OpenComputerUse",obu:"native/darwin-arm64/open-browser-use"},"win32-x64":{ocu:"dist/windows/amd64/open-computer-use.exe",obu:"native/windows-amd64/open-browser-use.exe"},"win32-arm64":{ocu:"dist/windows/arm64/open-computer-use.exe",obu:"native/windows-arm64/open-browser-use.exe"}},fe="chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing",me="chrome-win64/chrome.exe",E={version:"9.0.2",url:"https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffmpeg.zip",sha256:"c8ed4c4e6978a03c485edbfe4e0a5dc2380f8a30bba5150531b31b094492d924"},We={version:E.version,url:"https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffprobe.zip",sha256:"fcbe839537485eaee7a7a8bc5cbc0f90d53617e80943e8a5b2e31cb851197ea6"},V={version:E.version,url:`https://github.com/GyanD/codexffmpeg/releases/download/${E.version}/ffmpeg-${E.version}-essentials_build.zip`,sha256:"60f467265b1e312373dbcd92200c2618a74850f98d3d078e94296bb3fa2047ba"},ue=`ffmpeg-${V.version}-essentials_build/bin`,k="com.ifuryst.open_browser_use.extension",ge="com.reasonmachines.browser_use.extension",Sr="/tmp/reason-browser-use",q=["tint2","picom","xterm","pcmanfm"],he=["fonts-droid-fallback"],be=["pulseaudio"],xe=["tigervnc-standalone-server"],Ke=["xvfb","openbox","x11vnc","x11-utils","x11-xserver-utils","xdotool","dbus-x11","at-spi2-core","python3","python3-gi","gir1.2-atspi-2.0","gir1.2-gtk-3.0","fonts-dejavu-core",...he,"galculator","chromium","ffmpeg","tmux",...be,...xe,...q],Xe=new Set([...q,...he,...be,...xe]),de=Ke.filter((e)=>e!=="chromium"&&!Xe.has(e)),Ve=["Xvfb","openbox","x11vnc","xdotool","dbus-launch","python3","ffmpeg","tmux"],U="/usr/bin/chromium",ze=["/usr/local/bin","/usr/bin","/bin","/opt/homebrew/bin"];function we(e=process.platform,t=process.arch){let n=`${e}-${t}`;return n==="linux-x64"||n==="linux-arm64"||n==="darwin-arm64"||n==="win32-x64"||n==="win32-arm64"?n:null}function C(e){return e==="win32-x64"||e==="win32-arm64"}function Y(e){return C(e)?`node-v${H}-${e.replace("win32","win")}`:`node-v${H}-${e}`}function j(e){return{node:{version:H,url:`https://nodejs.org/dist/v${H}/${Y(e)}${C(e)?".zip":".tar.gz"}`,sha256:Ge[e]},open_computer_use:{version:x.ocu.version,url:R.ocu.url,sha256:R.ocu.sha256},open_browser_use:{version:x.obu.version,url:R.obu.url,sha256:R.obu.sha256},...e==="darwin-arm64"?{chrome_for_testing:{version:S.version,url:`https://storage.googleapis.com/chrome-for-testing-public/${S.version}/mac-arm64/chrome-mac-arm64.zip`,sha256:S.macArm64Sha256}}:C(e)?{chrome_for_testing:{version:S.version,url:`https://storage.googleapis.com/chrome-for-testing-public/${S.version}/win64/chrome-win64.zip`,sha256:S.win64Sha256}}:{}}}function Je(e){let t={extension:le};for(let[n,o]of Object.entries(j(e)))t[n]=`${o.version}@${o.sha256}`;return t}function ye(e){return a(e,".local","share","reason","desktop")}function Er(e,t=
|
|
72
|
+
`);if(m<0){if(o.length>4096)d({reason:"display_protocol"});return}let g=ie(o.slice(0,m).trim());if(o=null,!g)d({reason:"display_protocol"});else if(g.session===0)f("This Windows worker runs as a service, which has no desktop: run it in the signed-in desktop session.");else y(),e.ready({width:g.width,height:g.height})}),t.stdin.on("error",()=>{return}),t.once("error",()=>f("Reason could not start this computer's desktop input.")),t.once("exit",()=>{if(o!==null)f("Reason could not start this computer's desktop input.");else d({reason:"display_closed"})}),{pointer:(u,m,g)=>h(n.pointer(u,m,g)),key:(u,m)=>h(n.key(u,m)),clipboard:(u)=>h([`c ${Buffer.from(u,"utf8").toString("base64")}`]),close(){i=!0,c()}}}var Be=["none","standard","all"],H="22.23.4",Ge={"linux-x64":"b8492284c76a54baf58d61668dd0e41ee0fc98adabf9503d30f05d08f55b4406","linux-arm64":"f7a1e486dbc8b286847815b477d4fb5e9fb963ed4489c3e1588853d685f589f9","darwin-arm64":"c9e1dbc748b33ed2d14f42445191ecaf14c56259c7a9a26d0042c49ec2b66428","win32-x64":"cbc74b5e0982c9dbb41525fd8fb5dcd32fbee237863f7829072f4639a1ce5f20","win32-arm64":"a8b8cd79cbbb3062435f449591d98dd63730bbbf30ce2d7cc3a6376c236cb111"},X={"linux-x64":{ocu:"dist/linux/amd64/open-computer-use",obu:"native/linux-amd64/open-browser-use"},"linux-arm64":{ocu:"dist/linux/arm64/open-computer-use",obu:"native/linux-arm64/open-browser-use"},"darwin-arm64":{ocu:"dist/Open Computer Use.app/Contents/MacOS/OpenComputerUse",obu:"native/darwin-arm64/open-browser-use"},"win32-x64":{ocu:"dist/windows/amd64/open-computer-use.exe",obu:"native/windows-amd64/open-browser-use.exe"},"win32-arm64":{ocu:"dist/windows/arm64/open-computer-use.exe",obu:"native/windows-arm64/open-browser-use.exe"}},fe="chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing",me="chrome-win64/chrome.exe",E={version:"9.0.2",url:"https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffmpeg.zip",sha256:"c8ed4c4e6978a03c485edbfe4e0a5dc2380f8a30bba5150531b31b094492d924"},We={version:E.version,url:"https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffprobe.zip",sha256:"fcbe839537485eaee7a7a8bc5cbc0f90d53617e80943e8a5b2e31cb851197ea6"},V={version:E.version,url:`https://github.com/GyanD/codexffmpeg/releases/download/${E.version}/ffmpeg-${E.version}-essentials_build.zip`,sha256:"60f467265b1e312373dbcd92200c2618a74850f98d3d078e94296bb3fa2047ba"},ue=`ffmpeg-${V.version}-essentials_build/bin`,k="com.ifuryst.open_browser_use.extension",ge="com.reasonmachines.browser_use.extension",Sr="/tmp/reason-browser-use",q=["tint2","picom","xterm","pcmanfm"],he=["fonts-droid-fallback"],be=["pulseaudio"],xe=["tigervnc-standalone-server"],Ke=["xvfb","openbox","x11vnc","x11-utils","x11-xserver-utils","xdotool","dbus-x11","at-spi2-core","python3","python3-gi","gir1.2-atspi-2.0","gir1.2-gtk-3.0","fonts-dejavu-core",...he,"galculator","chromium","ffmpeg","tmux",...be,...xe,...q],Xe=new Set([...q,...he,...be,...xe]),de=Ke.filter((e)=>e!=="chromium"&&!Xe.has(e)),Ve=["Xvfb","openbox","x11vnc","xdotool","dbus-launch","python3","ffmpeg","tmux"],U="/usr/bin/chromium",ze=["/usr/local/bin","/usr/bin","/bin","/opt/homebrew/bin"];function we(e=process.platform,t=process.arch){let n=`${e}-${t}`;return n==="linux-x64"||n==="linux-arm64"||n==="darwin-arm64"||n==="win32-x64"||n==="win32-arm64"?n:null}function C(e){return e==="win32-x64"||e==="win32-arm64"}function Y(e){return C(e)?`node-v${H}-${e.replace("win32","win")}`:`node-v${H}-${e}`}function j(e){return{node:{version:H,url:`https://nodejs.org/dist/v${H}/${Y(e)}${C(e)?".zip":".tar.gz"}`,sha256:Ge[e]},open_computer_use:{version:x.ocu.version,url:R.ocu.url,sha256:R.ocu.sha256},open_browser_use:{version:x.obu.version,url:R.obu.url,sha256:R.obu.sha256},...e==="darwin-arm64"?{chrome_for_testing:{version:S.version,url:`https://storage.googleapis.com/chrome-for-testing-public/${S.version}/mac-arm64/chrome-mac-arm64.zip`,sha256:S.macArm64Sha256}}:C(e)?{chrome_for_testing:{version:S.version,url:`https://storage.googleapis.com/chrome-for-testing-public/${S.version}/win64/chrome-win64.zip`,sha256:S.win64Sha256}}:{}}}function Je(e){let t={extension:le};for(let[n,o]of Object.entries(j(e)))t[n]=`${o.version}@${o.sha256}`;return t}function ye(e){return a(e,".local","share","reason","desktop")}function Er(e,t=ns()){let n=ye(t),o=(u)=>a(n,u,j(e)[u]?.version??""),i=o("open_computer_use"),l=o("open_browser_use"),c=e==="darwin-arm64",d=C(e),f=a(t,"Library","Application Support"),h=a(process.platform==="win32"&&process.env.LOCALAPPDATA?process.env.LOCALAPPDATA:a(t,"AppData","Local"),"OpenBrowserUse"),y=c?a(f,"Google","Chrome","NativeMessagingHosts",`${k}.json`):d?a(h,"NativeMessagingHosts",`${k}.json`):a(t,".config","google-chrome","NativeMessagingHosts",`${k}.json`);return{root:n,automation:a(J(n),"automation"),receipt:a(n,"receipt.json"),minimal:Q(t),node:d?a(o("node"),Y(e),"node.exe"):a(o("node"),"bin","node"),ocuDir:i,ocu:a(i,X[e].ocu),ocuApp:c?a(i,"dist","Open Computer Use.app"):null,obuDir:l,obu:a(l,"cli","open-browser-use.js"),nativeHost:a(l,X[e].obu),extensionDir:c?a(f,"OpenBrowserUse","chrome-extension","release"):d?a(h,"chrome-extension","release"):a(t,".local","share","open-browser-use","chrome-extension","release"),setupNativeHostManifest:y,nativeHostManifests:c?[y,a(f,"Google","ChromeForTesting","NativeMessagingHosts",`${k}.json`)]:d?[y]:[a(t,".config","chromium","NativeMessagingHosts",`${k}.json`),a(t,".config","google-chrome-for-testing","NativeMessagingHosts",`${k}.json`)],browser:c?a(o("chrome_for_testing"),fe):d?a(o("chrome_for_testing"),me):U,userChromeHost:c?a(n,"user-chrome","reason-browser-use"):null,userChromeRegistration:c?a(f,"Google","Chrome","NativeMessagingHosts",`${ge}.json`):null,ffmpegDir:a(n,"ffmpeg"),ffmpeg:c?a(n,"ffmpeg",E.version,"ffmpeg"):d?a(n,"ffmpeg",V.version,ue,"ffmpeg.exe"):null,ffprobe:c?a(n,"ffprobe",We.version,"ffprobe"):d?a(n,"ffmpeg",V.version,ue,"ffprobe.exe"):null}}function _e(e){try{let t=JSON.parse(L(e,"utf8"));if(typeof t!=="object"||t===null)return null;let n=t,o=n.pins;if(n.schema_version!==1||typeof n.platform!=="string"||typeof o!=="object"||o===null||!Object.values(o).every((i)=>typeof i==="string")||!Be.includes(n.permissions)||!Array.isArray(n.missing_system_packages)||!n.missing_system_packages.every((i)=>typeof i==="string")||typeof n.updated_at!=="string")return null;return{schema_version:1,platform:n.platform,pins:o,permissions:n.permissions,missing_system_packages:n.missing_system_packages,updated_at:n.updated_at}}catch{return null}}function qe(e,t,n=384){Me(J(e),{recursive:!0,mode:448});let o=`${e}.pending.${process.pid}`;je(o,t,{mode:n}),Ue(o,e)}function w(e){try{return z(e).isFile()}catch{return!1}}function ve(e){try{let t=z(e);return t.isFile()&&(t.mode&73)!==0}catch{return!1}}function Ye(e){try{return L(e,"utf8")}catch{return null}}function _(e){for(let t of ze){let n=a(t,e);try{let o=z(n);if(o.isFile()&&(o.mode&73)!==0)return n}catch{}}return null}function Ze(e){try{let t=JSON.parse(L(a(e,"package.json"),"utf8"));return typeof t==="object"&&t!==null&&typeof t.version==="string"?t.version:null}catch{return null}}function Qe(e,t,n){let o=j(n)[e];if(!o)return!1;let i=C(n);if(e==="node")return w(i?a(t,Y(n),"node.exe"):a(t,"bin","node"));if(e==="chrome_for_testing")return w(a(t,i?me:fe));let l=X[n][e==="open_computer_use"?"ocu":"obu"];return Ze(t)===o.version&&w(a(t,l))&&(e==="open_computer_use"||w(a(t,"cli","open-browser-use.js")))}function et(e){return pe("sha256").update(Buffer.from(e,"base64")).digest("hex").slice(0,32).replace(/./g,(t)=>String.fromCharCode(97+Number.parseInt(t,16)))}function Z(e){try{let t=JSON.parse(L(e,"utf8"));return typeof t==="object"&&t!==null&&!Array.isArray(t)?t:null}catch{return null}}function tt(e){let t=Z(a(e.extensionDir,"manifest.json"));return t!==null&&t.version===x.obu.version&&typeof t.key==="string"&&et(t.key)===le}function nt(e,t){let n=e?.allowed_origins;return e!==null&&e.name===k&&Array.isArray(n)&&n.length===1&&n[0]===`chrome-extension://${le}/`&&(t===void 0||e.path===t)}function ot(e){return tt(e)&&w(e.nativeHost)&&e.nativeHostManifests.every((t)=>nt(Z(t),e.nativeHost))}function st(e){return`#!/bin/sh
|
|
73
73
|
# Reason's Chrome extension host (reason desktop install): Open Browser Use on Reason's socket directory.
|
|
74
74
|
obu=${`'${e.replaceAll("'","'\\''")}'`}
|
|
75
75
|
case "$1" in
|
|
@@ -77,5 +77,5 @@ case "$1" in
|
|
|
77
77
|
mcp) shift; exec "$obu" mcp --socket-dir ${Sr} "$@" ;;
|
|
78
78
|
esac
|
|
79
79
|
exec "$obu" "$@"
|
|
80
|
-
`}function rt(e){let t=Z(e),n=t?.allowed_origins;return t!==null&&t.name===ge&&t.type==="stdio"&&Array.isArray(n)&&n.includes(`chrome-extension://${Xt}/`)&&typeof t.path==="string"&&ve(t.path)}function it(e,t){if(!e.userChromeHost||!e.userChromeRegistration)return null;if(!t||Ye(e.userChromeHost)!==st(e.nativeHost)||!ve(e.userChromeHost))return{code:"user_chrome_browser_use_missing"};return rt(e.userChromeRegistration)?{host:e.userChromeHost}:{code:"user_chrome_native_host_unregistered"}}var at={display:["display","desktop_session","desktop_video"],computer:["display","desktop_session","system_packages","node","open_computer_use"],browser:["display","desktop_session","system_packages","node","open_computer_use","open_browser_use","browser_extension","browser","chrome_for_testing"]};function A(e={}){let t=e.platform===void 0?we():e.platform;if(!t)return null;let n=Er(t,e.home),o=_e(n.receipt),i=Je(t),l=o!==null&&o.platform===t&&JSON.stringify(Object.entries(o.pins).sort())===JSON.stringify(Object.entries(i).sort()),c=[],d=j(t);for(let p of["node","open_computer_use","open_browser_use","chrome_for_testing"]){let b=d[p];if(!b)continue;let N=Qe(p,a(n.root,p,b.version),t),I=o?.pins[p],M=N&&I===i[p]?"ready":I!==void 0&&I!==i[p]?"outdated":"missing";c.push({name:p,state:M,detail:b.version})}let f=o?.pins.extension===le&&ot(n);c.push({name:"browser_extension",state:f?"ready":"missing",detail:le});let h=_("Xvfb"),y=_("x11vnc"),u=_("openbox");if(C(t))c.push(ae()?{name:"desktop_session",state:"ready",detail:"signed-in desktop session"}:{name:"desktop_session",state:"missing",detail:"run the worker in the signed-in desktop session, not as a service"}),c.push(n.ffmpeg&&w(n.ffmpeg)?{name:"desktop_video",state:"ready",detail:n.ffmpeg}:{name:"desktop_video",state:"missing",detail:"run `reason desktop install` for desktop video"});else if(t!=="darwin-arm64"){c.push(w(U)?{name:"browser",state:"ready",detail:U}:{name:"browser",state:"missing",detail:`non-snap Chromium at ${U}`});let p=h!==null&&y!==null&&u!==null;c.push({name:"display",state:p?"ready":"missing",detail:"Xvfb + openbox + x11vnc"});let b=Ve.filter((O)=>_(O)===null),N=(o?.missing_system_packages??de).filter((O)=>de.includes(O)),I=b.length===0&&N.length===0;c.push(I?{name:"system_packages",state:"ready"}:{name:"system_packages",state:"missing",detail:[...new Set([...N,...b])].join(" ")});let M=q.filter((O)=>_(O)===null);c.push(M.length===0?{name:"desktop_look",state:"ready"}:{name:"desktop_look",state:"missing",detail:M.join(" ")})}let m=n.ffmpeg&&w(n.ffmpeg)?n.ffmpeg:_("ffmpeg"),g=!m?null:m===n.ffmpeg?n.ffprobe:a(J(He(m)),"ffprobe"),T=l&&c.every((p)=>p.state==="ready"),v=(p)=>l&&c.every((b)=>!at[p].includes(b.name)||b.state==="ready");return{platform:t,root:n.root,automation:n.automation,ready:T,features:{display:v("display"),computer:v("computer"),browser:v("browser")},node:n.node,ocu:n.ocu,obu:n.obu,nativeHost:n.nativeHost,extensionDir:n.extensionDir,browser:n.browser,ffmpeg:m,ffprobe:g&&w(g)?g:null,userChrome:it(n,l&&["node","open_browser_use"].every((p)=>c.find((b)=>b.name===p)?.state==="ready")),pulseaudio:_("pulseaudio"),xvnc:_("Xvnc"),xvfb:h,x11vnc:y,openbox:u,components:c}}function
|
|
81
|
-
`)}function
|
|
80
|
+
`}function rt(e){let t=Z(e),n=t?.allowed_origins;return t!==null&&t.name===ge&&t.type==="stdio"&&Array.isArray(n)&&n.includes(`chrome-extension://${Xt}/`)&&typeof t.path==="string"&&ve(t.path)}function it(e,t){if(!e.userChromeHost||!e.userChromeRegistration)return null;if(!t||Ye(e.userChromeHost)!==st(e.nativeHost)||!ve(e.userChromeHost))return{code:"user_chrome_browser_use_missing"};return rt(e.userChromeRegistration)?{host:e.userChromeHost}:{code:"user_chrome_native_host_unregistered"}}var at={display:["display","desktop_session","desktop_video"],computer:["display","desktop_session","system_packages","node","open_computer_use"],browser:["display","desktop_session","system_packages","node","open_computer_use","open_browser_use","browser_extension","browser","chrome_for_testing"]};function A(e={}){let t=e.platform===void 0?we():e.platform;if(!t)return null;let n=Er(t,e.home),o=_e(n.receipt),i=Je(t),l=o!==null&&o.platform===t&&JSON.stringify(Object.entries(o.pins).sort())===JSON.stringify(Object.entries(i).sort()),c=[],d=j(t);for(let p of["node","open_computer_use","open_browser_use","chrome_for_testing"]){let b=d[p];if(!b)continue;let N=Qe(p,a(n.root,p,b.version),t),I=o?.pins[p],M=N&&I===i[p]?"ready":I!==void 0&&I!==i[p]?"outdated":"missing";c.push({name:p,state:M,detail:b.version})}let f=o?.pins.extension===le&&ot(n);c.push({name:"browser_extension",state:f?"ready":"missing",detail:le});let h=_("Xvfb"),y=_("x11vnc"),u=_("openbox");if(C(t))c.push(ae()?{name:"desktop_session",state:"ready",detail:"signed-in desktop session"}:{name:"desktop_session",state:"missing",detail:"run the worker in the signed-in desktop session, not as a service"}),c.push(n.ffmpeg&&w(n.ffmpeg)?{name:"desktop_video",state:"ready",detail:n.ffmpeg}:{name:"desktop_video",state:"missing",detail:"run `reason desktop install` for desktop video"});else if(t!=="darwin-arm64"){c.push(w(U)?{name:"browser",state:"ready",detail:U}:{name:"browser",state:"missing",detail:`non-snap Chromium at ${U}`});let p=h!==null&&y!==null&&u!==null;c.push({name:"display",state:p?"ready":"missing",detail:"Xvfb + openbox + x11vnc"});let b=Ve.filter((O)=>_(O)===null),N=(o?.missing_system_packages??de).filter((O)=>de.includes(O)),I=b.length===0&&N.length===0;c.push(I?{name:"system_packages",state:"ready"}:{name:"system_packages",state:"missing",detail:[...new Set([...N,...b])].join(" ")});let M=q.filter((O)=>_(O)===null);c.push(M.length===0?{name:"desktop_look",state:"ready"}:{name:"desktop_look",state:"missing",detail:M.join(" ")})}let m=n.ffmpeg&&w(n.ffmpeg)?n.ffmpeg:_("ffmpeg"),g=!m?null:m===n.ffmpeg?n.ffprobe:a(J(He(m)),"ffprobe"),T=l&&c.every((p)=>p.state==="ready"),v=(p)=>l&&c.every((b)=>!at[p].includes(b.name)||b.state==="ready");return{platform:t,root:n.root,automation:n.automation,ready:T,features:{display:v("display"),computer:v("computer"),browser:v("browser")},node:n.node,ocu:n.ocu,obu:n.obu,nativeHost:n.nativeHost,extensionDir:n.extensionDir,browser:n.browser,ffmpeg:m,ffprobe:g&&w(g)?g:null,userChrome:it(n,l&&["node","open_browser_use"].every((p)=>c.find((b)=>b.name===p)?.state==="ready")),pulseaudio:_("pulseaudio"),xvnc:_("Xvnc"),xvfb:h,x11vnc:y,openbox:u,components:c}}function Qo(e){return ct(e)?ys():[]}function ct(e){return e?.platform==="darwin-arm64"&&e.ffmpeg===a(e.root,"ffmpeg",E.version,"ffmpeg")}async function es(e,t,n,o=fetch){try{let i=await o(e,{redirect:"follow"});if(!i.ok||!i.body)throw Error(`download failed (HTTP ${i.status}): ${e}`);let l=pe("sha256"),c=Ne(n,{mode:384});try{let f=i.body.getReader();for(let h=await f.read();!h.done;h=await f.read())if(l.update(h.value),!c.write(h.value))await Te(c,"drain")}finally{c.end(),await Fe(c)}let d=l.digest("hex");if(d!==t)throw Error(`digest mismatch for ${e}: expected ${t}, got ${d}`)}catch(i){throw Le(n,{force:!0}),i}}function Q(e){return a(ye(e),"minimal.json")}function ut(e=s()){return Ae(Q(e))}function ts(e={}){qe(Q(e.home??s()),`${JSON.stringify({version:1,minimal_at:(e.now?.()??new Date).toISOString()})}
|
|
81
|
+
`)}function rs(e={}){let t=e.platform===void 0?we():e.platform;if(t===null)return null;let n=e.home??s();if(_e(Er(t,n).receipt)!==null)return"refresh";return ut(n)?null:"install"}export{Xt,yc,le,wc,bc,Sr,Er,A,Qo,es,ts,rs};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{w}from"./vm-hands-entry-lite-
|
|
2
|
+
import{w}from"./vm-hands-entry-lite-0xfme8gg.js";import{existsSync as T,mkdirSync as k,readFileSync as d,rmSync as y,writeFileSync as b}from"fs";import{homedir as l,hostname as M}from"os";import{dirname as N,join as h}from"path";function f(t){let e=t.trim().slice(t.trim().indexOf("#")+1),o=["rn1-","tincan1"].find((a)=>e.startsWith(a));if(!o)return null;let n=Buffer.from(e.slice(o.length),"base64url"),r=32,i=(a)=>(r+=a,r<=n.length),m=()=>{let a=n[r];if(a===void 0||!i(1))return!1;if(a!==255)return i(a);let s=n[r];return s!==void 0&&i(1)&&i(s)};if(n.length<32||!m()||!m()||!m())return null;let u=n[r];if(u===void 0||!i(1))return null;for(let a=0;a<u;a+=1){let s=n[r];if(!i(1)||!i(s===4?4:s===6?16:Number.NaN)||!i(2))return null}let g=[];for(;r+32<=n.length;r+=32)g.push(n.subarray(r,r+32).toString("hex"));return{team:n.subarray(0,16).toString("hex"),name:n.subarray(33,33+n[32]).toString("utf8"),secret:n.subarray(16,32).toString("hex"),machines:g}}var p=(t)=>h(t,".reason","ask.json");function A(t){try{let e=JSON.parse(d(p(t),"utf8"));if(typeof e.orgId!=="string"||typeof e.team!=="string")return null;let o=e.pendingRotation;return{orgId:e.orgId,team:e.team,...typeof e.checkedAt==="number"?{checkedAt:e.checkedAt}:{},...o&&typeof o.link==="string"&&typeof o.team==="string"&&typeof o.replaces==="string"?{pendingRotation:o}:{}}}catch{return null}}var c=(t)=>{let e=w();return h(t,".reason",e==="production"?"network-team.json":`network-team.${e}.json`)};function ka(t=l()){return c(t).replace(/\.json$/,"-login.json")}function xa(t=l()){try{let e=JSON.parse(d(c(t),"utf8"));return typeof e.team==="string"?{team:e.team,setupDone:e.setupDone===!0,registered:typeof e.registered==="string"?e.registered:null,account:typeof e.account==="string"?e.account:null}:null}catch{return null}}function Ca(t,e=l()){k(N(c(e)),{recursive:!0}),b(c(e),`${JSON.stringify(t)}
|
|
3
3
|
`,{mode:384}),y(p(e),{force:!0})}function Kr(t=l()){let e=A(t);return e?{orgId:e.orgId,team:e.team}:null}function Jr(t){let e=f(t);return e&&e.machines.length>0?{teamId:e.team,teamName:e.name,secret:e.secret}:null}
|
|
4
|
-
export{
|
|
4
|
+
export{ka,xa,Ca,Kr,Jr};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{rr,jr}from"./vm-hands-entry-lite-
|
|
2
|
+
import{rr,jr}from"./vm-hands-entry-lite-1cdtev4n.js";import{t,Ur,V,o,_,d,h,P,$e,c,i}from"./vm-hands-entry-lite-bt6skt4h.js";var w=t().max(201).regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/).refine((e)=>e.split("/").every((n)=>n!=="."&&n!=="..")),b=t().min(1).max(255).regex(/^[A-Za-z0-9_][A-Za-z0-9_./-]*$/).refine((e)=>!e.includes("..")&&!e.includes("//")&&!e.endsWith("/")&&!e.endsWith(".lock")),L=t().regex(/^[a-f0-9]{40}$/),O=o().int().positive(),I=t().min(1).max(256),T=t().max(60000),y={version:i(1),repoFullName:w},A=d(t().max(1024).regex(/^(?:Co-authored-by: [^<>\r\n\x00]+ <[^<>\s]+@[^<>\s]+>|Reason-Contributor-ID: rc_[a-f0-9]{32})$/)).max(1000),j=h({expectedTrailers:A,missingFromHead:A}),G=P("action",[h({action:i("edit"),title:I.optional(),body:T.optional(),base:b.optional()}),h({action:c(["ready","draft","close"])}),h({action:i("metadata"),field:c(["reviewer","assignee","label"]),change:c(["add","remove"]),value:t().min(1).max(100).refine((e)=>!/[\r\n\0]/.test(e))})]),Ct=P("kind",[h({...y,kind:i("read"),path:t().min(1).max(2048),accept:c(["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"]).optional()}),h({...y,kind:i("pr_review_context"),number:O,after:t().min(1).max(1024).optional()}),h({...y,kind:i("prepare"),branch:b,baseSha:L,defaultBranch:b,diagnosticsVersion:i(1).optional()}),h({...y,kind:i("publish"),branch:b,defaultBranch:b,baseSha:L,remoteHeadSha:L.nullable(),contributorTrailers:A.optional()}),h({...y,kind:i("pr_create"),head:b,base:b,title:I,body:T,draft:_()}),h({...y,kind:i("pr_mutation"),number:O,mutation:G}),h({...y,kind:i("pr_merge"),number:O,expectedHeadSha:L,expectedBaseRef:b,method:c(["merge","squash","rebase"]),commitBody:t().max(65536).optional()})]),z=["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 B(e){return z.some((n)=>n===e)}class Fn extends Error{code;constructor(e){super(e);this.code=e}}function vs(e,n,r){let p=Ct.safeParse(e);return n==="failed"&&p.success&&p.data.kind==="prepare"&&p.data.diagnosticsVersion===1&&B(r)}var Or=245760,Vc=P("kind",[h({kind:i("pr_review_context"),body:t().max(Or)}),h({kind:i("prepare"),headSha:L}),h({kind:i("read"),status:o().int().min(200).max(599),headers:$e(t(),t().max(8192)).refine((e)=>Object.keys(e).every((n)=>n==="link"||n==="content-type")),body:t().max(Or)}),h({kind:i("publish"),headSha:L,scannedObjectCount:o().int().min(0).max(5000),attribution:j.optional()}),h({kind:i("pr_create"),url:t().max(1024).regex(/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/pull\/[1-9][0-9]*$/)}),h({kind:i("pr_mutation"),number:O,applied:i(!0)}),h({kind:i("pr_merge"),number:O,merged:i(!0)})]).refine((e)=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=Or,"local_device_gh_result_too_large"),F=h({source:c(["agent","human"]),operationId:V()}),Je=h({version:i(1),userId:Ur(),deviceId:Ur(),rootId:Ur(),runId:Ur(),merge:F.optional(),contributorRefresh:Ur().optional(),repoFullName:w.nullable(),rootRevision:t().regex(/^[1-9][0-9]*$/),readOnly:_(),generation:o().int().positive().nullable(),fenceId:Ur().nullable()}).refine((e)=>e.generation===null===(e.fenceId===null));function v(e){return/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(e)&&e.split("/").every((n)=>n!=="."&&n!=="..")}function Gc(e,n,r={},p="read"){if(v(e)&&(n==="/search/issues"||n.startsWith("/search/issues?")))return Y(e,n,r);if(!v(e)||!n.startsWith(`/repos/${e}/`)&&n!==`/repos/${e}`)throw Error("local_device_gh_repository_mismatch");if(/[\\#\u0000-\u001f]/.test(n)||/%(?:2e|5c|00)/i.test(n))throw Error("local_device_gh_path_denied");let m=new URL(n,"https://api.github.com");if(m.pathname!==n.split("?")[0]||m.username||m.password)throw Error("local_device_gh_path_denied");let R;try{R=decodeURIComponent(m.pathname.slice(`/repos/${e}`.length))}catch{throw Error("local_device_gh_path_denied")}if(R.includes("%")||R.split("/").some((s)=>s==="."||s===".."))throw Error("local_device_gh_path_denied");if((r.method??"GET").toUpperCase()!=="GET"||r.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((s)=>s.test(R)))throw Error("local_device_gh_path_denied");if(m.searchParams.forEach((s,f)=>{if(f==="per_page"&&/^[1-9][0-9]*$/.test(s)&&Number(s)<=100)return;if(f==="page"&&/^[1-9][0-9]*$/.test(s)&&Number(s)<=100)return;if(R==="/pulls"&&f==="state"&&["open","closed","all"].includes(s))return;if(R==="/pulls"&&f==="sort"&&s==="updated")return;if(R==="/pulls"&&f==="direction"&&s==="desc")return;if(R==="/pulls"&&["head","base"].includes(f)&&/^[A-Za-z0-9_./:-]{1,255}$/.test(s))return;throw Error("local_device_gh_query_denied")}),r.headers)new Headers(r.headers).forEach((f,q)=>{if(q!=="accept"||!["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"].includes(f))throw Error("local_device_gh_header_denied")})}function Y(e,n,r){if(/[\\#\u0000-\u001f]/.test(n))throw Error("local_device_gh_path_denied");let p=new URL(n,"https://api.github.com");if(p.pathname!=="/search/issues"||p.username||p.password)throw Error("local_device_gh_path_denied");if((r.method??"GET").toUpperCase()!=="GET"||r.body!=null)throw Error("local_device_gh_mutation_not_admitted");let m=null;p.searchParams.forEach((g,s)=>{if(s==="q"&&m===null){m=g;return}if(s==="per_page"&&/^[1-9][0-9]*$/.test(g)&&Number(g)<=100)return;if(s==="page"&&/^[1-9][0-9]*$/.test(g)&&Number(g)<=100)return;throw Error("local_device_gh_query_denied")});let R=`repo:${e.toLowerCase()} `,x=m?.toLowerCase()??"";if(x.length>512||!(x+" ").startsWith(R)||/(?:^|\s)(?:repo|org|user):/.test(x.slice(R.length)))throw Error("local_device_gh_query_denied");if(r.headers)new Headers(r.headers).forEach((g,s)=>{if(s!=="accept"||g!=="application/vnd.github+json")throw Error("local_device_gh_header_denied")})}var Kc=`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{rr,jr}from"./vm-hands-entry-lite-gxf2r5en.js";import{t,Ur,V,o,_,d,h,P,$e,
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
}`;function Qt(e){return e.kind==="read"||e.kind==="pr_review_context"}var Nr=["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 er=2,N="/app/local-runtime",Xe=262144,
|
|
37
|
+
}`;function Qt(e){return e.kind==="read"||e.kind==="pr_review_context"}var Nr=["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 er=2,N="/app/local-runtime",Xe=262144,Ss="x-reason-relay-host-alias",Es="v1";function l(e,n){return{path:`${N}${e}`,routerPath:e,auth:n}}function E(e,n){return{...l(e,"device_proof"),forOperation(r){return l(`/operations/${encodeURIComponent(r)}${n}`,"device_proof")}}}var M={register:l("/register","registration_bearer"),enroll:l("/enroll","none"),authChallenge:l("/auth/challenge","none"),identity:l("/identity","device_proof"),heartbeat:l("/heartbeat","device_proof"),rootsSync:l("/roots/sync","device_proof"),disconnect:l("/disconnect","device_proof"),lifecycle:l("/lifecycle","device_proof"),localSubscription:l("/local-subscription","device_proof"),ownerWorkspaces:l("/owner-workspaces","device_proof"),ownerWorkspaceEnrollment:l("/owner-workspaces/enrollment","device_proof"),sessionWorktrees:l("/session-worktrees","device_proof"),operationClaim:l("/operations/claim","device_proof"),operationHeartbeat:E("/operations/:operationId/heartbeat","/heartbeat"),operationEvents:E("/operations/:operationId/events","/events"),operationComplete:E("/operations/:operationId/complete","/complete"),operationEnvironment:E("/operations/:operationId/environment","/environment"),operationEnvironmentAck:E("/operations/:operationId/environment-ack","/environment-ack"),operationCustomEndpointCredential:E("/operations/:operationId/custom-endpoint-credential","/custom-endpoint-credential")},At=`${N}/session`;var J=[/^\/app\/local-runtime\/heartbeat$/,/^\/app\/local-runtime\/operations\/claim$/,/^\/app\/local-runtime\/operations\/[0-9a-fA-F-]{36}\/(?:heartbeat|events|complete|environment|environment-ack)$/];function ks(e){return J.some((n)=>n.test(e))}var jn=60000;var xs="hands_control_v1",Lr="environment.deliver",Cs="vm_hands_workspace_deferred",As="vm_hands.workspace_grant",Ps="hands.unbind_unverified",Rs="claim_v1",Ts="environment_at_claim",Is="ready_v1",Ds="workspace_check",Os="rebind_v1",Ns="resident_rebind",Ls="hands.rebind",$s="snapshot_v1",Ms="cloud_access",Bs="playwright_v1",Fs="headless_browser",js="v1",Hs="job_env_large_values",ct="srt_root_v1",Le="hands_confinement",Pt="gid_v1",xe="model_jobs_egress",Us="setpriv_v1",zs="jobs_user",qs="spawning_attempt_v1",pe="hands_session_group";var Ws="session_cap",Vs="none",Gs="same_launch_v1",Ks="exit_v1",Js="start_wait",$r="user_chrome",Xs="cloud_sessions";function C(e){if(!a(e)||Object.keys(e).length!==5||e.version!==1)return!1;let n=/^[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((r)=>typeof e[r]==="string"&&n.test(e[r]))&&typeof e.root_version==="string"&&/^[0-9]{1,20}(?:\.[0-9]{1,6})?$/.test(e.root_version)}function S(e){if(!a(e)||Object.keys(e).length!==6)return!1;let n=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return typeof e.device_id==="string"&&n.test(e.device_id)&&(e.binding==="workspace_source"||e.binding==="mcp_control")&&Number.isSafeInteger(e.target_revision)&&Number(e.target_revision)>=0&&Number.isSafeInteger(e.root_grant_revision)&&Number(e.root_grant_revision)>0&&Number.isSafeInteger(e.target_generation)&&Number(e.target_generation)>0&&typeof e.target_fence_id==="string"&&n.test(e.target_fence_id)}var Ys=["lock_acquired","enrollment_started","enrollment_completed","readiness_started","readiness_completed","inventory_completed","control_ready"],tr=86400000;var W=["production","staging"];function k(e){if(!a(e)||Object.keys(e).length!==3)return!1;let n=/^[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((r)=>Object.hasOwn(e,r)&&typeof e[r]==="string"&&n.test(e[r])&&e[r]!=="00000000-0000-0000-0000-000000000000")}var K="DEVICE-PROOF-V2";function Mr(e,n=K){let r=e.method.toUpperCase();if(!/^[A-Z]+$/.test(r)||!e.pathAndQuery.startsWith(`${N}/`)||e.pathAndQuery.includes(`
|
|
38
38
|
`)||!/^[0-9]{1,20}$/.test(e.timestamp)||!/^[A-Za-z0-9_-]{22,43}$/.test(e.nonce)||e.challenge.length<16||e.challenge.length>1024||e.challenge.includes(`
|
|
39
39
|
`)||!/^[a-f0-9]{64}$/.test(e.bodySha256))throw Error("Invalid Reason Device proof input.");return Buffer.from([n,r,e.pathAndQuery,e.timestamp,e.nonce,e.challenge,e.bodySha256].join(`
|
|
40
|
-
`),"utf8")}function a(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function Z(e,n){return typeof e==="string"&&n.some((r)=>r===e)}function D(e){return a(e)&&typeof e.id==="string"&&typeof e.label==="string"&&typeof e.path_fingerprint==="string"}function X(e){return a(e)&&Number.isInteger(e.seq)&&Number(e.seq)>=0&&typeof e.kind==="string"&&/^[A-Za-z0-9._:-]{1,64}$/.test(e.kind)&&a(e.payload)}function u(e){throw Error(e)}function
|
|
41
|
-
`)||typeof e.expires_at!=="string"||!Number.isFinite(Date.parse(e.expires_at)))u("Reason returned an invalid Device proof challenge.");return{challenge:e.challenge,expires_at:e.expires_at}}function H(e,n){if(!a(e)||typeof e.device_id!=="string"||e.auth_scheme!=="p256"||e.organization_id!==void 0&&typeof e.organization_id!=="string"||e.protocol_version!==er||!Array.isArray(e.roots)||!e.roots.every(D)||n&&typeof e.organization_id!=="string"||e.device_credential!==void 0)u(n?"Reason returned an invalid Device enrollment.":"Reason returned an invalid Device registration.");return{...{device_id:e.device_id,...typeof e.organization_id==="string"?{organization_id:e.organization_id}:{},protocol_version:er,roots:e.roots},auth_scheme:"p256"}}function
|
|
42
|
-
export{Ct,
|
|
40
|
+
`),"utf8")}function a(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function Z(e,n){return typeof e==="string"&&n.some((r)=>r===e)}function D(e){return a(e)&&typeof e.id==="string"&&typeof e.label==="string"&&typeof e.path_fingerprint==="string"}function X(e){return a(e)&&Number.isInteger(e.seq)&&Number(e.seq)>=0&&typeof e.kind==="string"&&/^[A-Za-z0-9._:-]{1,64}$/.test(e.kind)&&a(e.payload)}function u(e){throw Error(e)}function Zs(e,n){let r=a(e)?e:{},p=typeof r.error==="string"?r.error:`http_${n}`,m=typeof r.detail==="string"?r.detail:typeof r.message==="string"?r.message:`Reason Device request failed (${n})`;return{code:p,message:m}}function Gi(e){if(!a(e)||typeof e.challenge!=="string"||e.challenge.length<16||e.challenge.length>1024||e.challenge.includes(`
|
|
41
|
+
`)||typeof e.expires_at!=="string"||!Number.isFinite(Date.parse(e.expires_at)))u("Reason returned an invalid Device proof challenge.");return{challenge:e.challenge,expires_at:e.expires_at}}function H(e,n){if(!a(e)||typeof e.device_id!=="string"||e.auth_scheme!=="p256"||e.organization_id!==void 0&&typeof e.organization_id!=="string"||e.protocol_version!==er||!Array.isArray(e.roots)||!e.roots.every(D)||n&&typeof e.organization_id!=="string"||e.device_credential!==void 0)u(n?"Reason returned an invalid Device enrollment.":"Reason returned an invalid Device registration.");return{...{device_id:e.device_id,...typeof e.organization_id==="string"?{organization_id:e.organization_id}:{},protocol_version:er,roots:e.roots},auth_scheme:"p256"}}function Qs(e){return H(e,!1)}function ea(e){let n=H(e,!0);if(typeof n.organization_id!=="string")return u("Reason returned an invalid Device enrollment.");return{...n,organization_id:n.organization_id}}function ta(e){if(!a(e)||typeof e.server_time!=="string"||typeof e.drain!=="boolean")return u("Reason returned an invalid Device heartbeat.");return{server_time:e.server_time,drain:e.drain,...U(e),...typeof e.update_policy==="string"||e.update_policy===null?{update_policy:e.update_policy}:{},...typeof e.supported_protocol_version==="number"?{supported_protocol_version:e.supported_protocol_version}:{},...ee(e.latest_cli_versions),...e.hands_prespawn===!0?{hands_prespawn:!0}:{}}}var Q=["account_root_metadata_supported","workspace_root_metadata_supported","account_root_path_supported","home_contained_roots_supported","root_paths_supported","startup_supported"];function U(e){return Object.fromEntries(Q.filter((n)=>e[n]===!0).map((n)=>[n,!0]))}function Hn(e){if(!a(e))return;try{return{...Gi(e),...U(e)}}catch{return}}function ee(e){if(!a(e))return{};let n={};for(let r of W){let p=e[r];if(typeof p==="string"&&/^(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})$/.test(p))n[r]=p}return Object.keys(n).length>0?{latest_cli_versions:n}:{}}function ra(e){if(!a(e)||!Array.isArray(e.roots)||!e.roots.every(D))return u("Reason returned an invalid Device root sync.");return{roots:e.roots}}function na(e){if(!a(e)||e.user_id!==void 0&&typeof e.user_id!=="string"||typeof e.organization_id!=="string"||typeof e.organization_name!=="string"||typeof e.organization_slug!=="string")return u("Reason returned an invalid Device identity.");return{...typeof e.user_id==="string"?{user_id:e.user_id}:{},organization_id:e.organization_id,organization_name:e.organization_name,organization_slug:e.organization_slug}}function ia(e){if(!a(e)||e.disconnected!==!0)return u("Reason did not disconnect this Device.");let n=e.sessions_moved;return typeof n==="number"&&Number.isSafeInteger(n)&&n>=0?{disconnected:!0,sessions_moved:n}:{disconnected:!0}}function oa(e){if(a(e)&&e.ok===!0&&typeof e.expires==="number")return{ok:!0,expires:e.expires};if(a(e)&&e.ok===!1&&typeof e.error==="string")return{ok:!1,error:e.error};return u("Reason did not answer the local login hand-over.")}function sa(e){if(!a(e)||e.accepted!==!0)return u("Reason did not accept the Device lifecycle event.");return{accepted:!0}}function te(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function aa(e,n=Nr){if(!a(e)||typeof e.operation_id!=="string"||typeof e.attempt_id!=="string"||typeof e.attempt_token!=="string"||!/^(?:reason|ara)_attempt_/.test(e.attempt_token)||typeof e.lease_until!=="string"||typeof e.run_id!=="string"||typeof e.root_id!=="string"||e.owner!==void 0&&!k(e.owner)||!Z(e.capability,n)||!a(e.payload)||e.protocol_version!==er||te(e.payload)>(e.capability===rr?jr:Xe)||e.authority!==void 0&&!S(e.authority)||e.local_github_authority!==void 0&&!Je.safeParse(e.local_github_authority).success||e.capability==="github.local.v1"&&!Je.safeParse(e.local_github_authority).success||e.recording_authority!==void 0&&!C(e.recording_authority)||e.capability==="browser.recording.v1"&&(!C(e.recording_authority)||!k(e.owner))||e.capability!=="browser.recording.v1"&&e.recording_authority!==void 0)return u("Reason returned an invalid Device operation claim.");let r={operation_id:e.operation_id,attempt_id:e.attempt_id,attempt_token:e.attempt_token,lease_until:e.lease_until,run_id:e.run_id,root_id:e.root_id,capability:e.capability,payload:e.payload,...S(e.authority)?{authority:e.authority}:{},...C(e.recording_authority)?{recording_authority:Object.freeze({...e.recording_authority})}:{},...e.local_github_authority!==void 0?{local_github_authority:Je.parse(e.local_github_authority)}:{},...e.capability==="hands.connect"&&a(e.environment)&&a(e.environment.payload)&&S(e.environment.authority)?{environment:{payload:e.environment.payload,authority:e.environment.authority}}:{},protocol_version:er};if(e.owner!==void 0)r.owner=Object.freeze({...e.owner});return r}function ca(e){if(!a(e)||typeof e.lease_until!=="string"||!Array.isArray(e.controls)||!e.controls.every(X)||!Number.isInteger(e.next_control_seq)||Number(e.next_control_seq)<0)return u("Reason returned an invalid Device operation heartbeat.");return{lease_until:e.lease_until,controls:e.controls,next_control_seq:Number(e.next_control_seq)}}function la(e){if(!a(e)||!Number.isInteger(e.next_event_seq)||Number(e.next_event_seq)<0||typeof e.duplicate!=="boolean"||!Number.isInteger(e.accepted_count)||Number(e.accepted_count)<0)return u("Reason returned an invalid Device operation event result.");return{next_event_seq:Number(e.next_event_seq),duplicate:e.duplicate,accepted_count:Number(e.accepted_count)}}function ua(e){if(!a(e)||!a(e.payload)||!S(e.authority))return u("Reason returned an invalid Device environment delivery.");return{payload:e.payload,authority:e.authority}}function oe(e){return e==="succeeded"||e==="failed"||e==="cancelled"||e==="expired"}function da(e){if(!a(e)||!oe(e.status)||typeof e.idempotent!=="boolean")return u("Reason returned an invalid Device operation completion.");return{status:e.status,idempotent:e.idempotent}}
|
|
42
|
+
export{Ct,Fn,vs,Or,Vc,Je,Gc,Kc,Qt,Nr,er,Xe,Ss,Es,M,At,ks,jn,xs,Lr,Cs,As,Ps,Rs,Ts,Is,Ds,Os,Ns,Ls,$s,Ms,Bs,Fs,js,Hs,ct,Le,Pt,xe,Us,zs,qs,pe,Ws,Vs,Gs,Ks,Js,$r,Xs,Ys,tr,Mr,Zs,Gi,Qs,ea,ta,Hn,ra,na,ia,oa,sa,aa,ca,la,ua,da};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{lt}from"./vm-hands-entry-lite-
|
|
3
|
-
export{
|
|
2
|
+
import{lt}from"./vm-hands-entry-lite-1sy80ca9.js";var lo=lt(function(t,e){e.exports={name:"playwright-core",version:"1.60.0",description:"A high-level API to automate web browsers",repository:{type:"git",url:"git+https://github.com/microsoft/playwright.git"},homepage:"https://playwright.dev",engines:{node:">=18"},author:{name:"Microsoft Corporation"},license:"Apache-2.0",exports:{".":{types:"./index.d.ts",import:"./index.mjs",require:"./index.js",default:"./index.js"},"./package.json":"./package.json","./lib/bootstrap":"./lib/bootstrap.js","./lib/coreBundle":"./lib/coreBundle.js","./lib/utilsBundle":"./lib/utilsBundle.js","./lib/tools/cli-client/program":"./lib/tools/cli-client/program.js"},bin:{"playwright-core":"cli.js"},types:"types/types.d.ts"}});
|
|
3
|
+
export{lo};
|