@reason-machines/cli-linux-x64 0.2.418 → 0.2.420
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/{connect-cli-pn1h0b08.js → connect-cli-s5smpb2n.js} +1 -1
- package/bin/vm-hands/{local-automation-7nc6cgjp.js → local-automation-3amth2kd.js} +1 -1
- package/bin/vm-hands/{local-capabilities-5f36fr9x.js → local-capabilities-hgmepv53.js} +1 -1
- package/bin/vm-hands/{local-display-session-zg4dpnf1.js → local-display-session-e4n5hx0v.js} +1 -1
- package/bin/vm-hands/local-display-video-28gmymr4.js +2 -0
- package/bin/vm-hands/{local-managed-process-gjc8gvgb.js → local-managed-process-2313kw42.js} +1 -1
- package/bin/vm-hands/{managed-runtime-f85h6h7f.js → managed-runtime-3z71qd28.js} +1 -1
- package/bin/vm-hands/{permissions-bhbnb1bp.js → permissions-9yn6rcvc.js} +1 -1
- package/bin/vm-hands/{serve-service-58ea9cwx.js → serve-service-s57v1tq2.js} +1 -1
- package/bin/vm-hands/{status-z9r8nq3y.js → status-grxd9vg7.js} +1 -1
- package/bin/vm-hands/version-bqwnackx.js +2 -0
- package/bin/vm-hands/{vm-hands-entry-lite-j43nqe8y.js → vm-hands-entry-lite-004yshd1.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-6wt5ja1k.js → vm-hands-entry-lite-1xwxazmz.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-m8nqnd9j.js → vm-hands-entry-lite-2n4n9cs8.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-hn76pcgk.js → vm-hands-entry-lite-2rd6t7ry.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-2wzsnnsp.js → vm-hands-entry-lite-37kgczw8.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-s3cg1dsk.js → vm-hands-entry-lite-4vgwtn85.js} +5 -5
- package/bin/vm-hands/{vm-hands-entry-lite-svvysppj.js → vm-hands-entry-lite-6b0dxpkm.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-ppmvge7n.js → vm-hands-entry-lite-cbrtaz8j.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-2nkj0dpx.js → vm-hands-entry-lite-ev1k9x73.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-ah6fwqxp.js → vm-hands-entry-lite-f2qkz14f.js} +1 -1
- package/bin/vm-hands/vm-hands-entry-lite-hqmyd73s.js +2 -0
- package/bin/vm-hands/{vm-hands-entry-lite-w8w451gj.js → vm-hands-entry-lite-m2bswqxe.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-nefcet81.js → vm-hands-entry-lite-sbtjmy0e.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-stmbekq0.js → vm-hands-entry-lite-zjxzm61j.js} +1 -1
- package/bin/vm-hands/vm-hands-entry-lite.js +1 -1
- package/bin/vm-hands/{vm-hands-executor-73b49jkg.js → vm-hands-executor-p92kw8nz.js} +1 -1
- package/bin/vm-hands/{vm-hands-op-runner-ef9ts9c6.js → vm-hands-op-runner-ekgtqc07.js} +1 -1
- package/bin/vm-hands/{vm-hands-runtime-8z6rx1fj.js → vm-hands-runtime-tj93a1pm.js} +3 -3
- package/package.json +1 -1
- package/bin/vm-hands/local-display-video-remg1c30.js +0 -2
- package/bin/vm-hands/version-p0g28erd.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-mmdwr0mf.js +0 -2
package/bin/reason
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{rt,cs,ls,us}from"./vm-hands-entry-lite-
|
|
2
|
+
import{rt,cs,ls,us}from"./vm-hands-entry-lite-4vgwtn85.js";import"./vm-hands-entry-lite-ec9jemny.js";import"./vm-hands-entry-lite-z76nfb19.js";import"./vm-hands-entry-lite-50zbqwkv.js";import"./vm-hands-entry-lite-8r31b0ps.js";import"./vm-hands-entry-lite-6b0dxpkm.js";import"./vm-hands-entry-lite-ev1k9x73.js";import"./vm-hands-entry-lite-m2bswqxe.js";import"./vm-hands-entry-lite-004yshd1.js";import"./vm-hands-entry-lite-beyyy1gz.js";import"./vm-hands-entry-lite-s4bharcb.js";import"./vm-hands-entry-lite-vpz54vwj.js";import"./vm-hands-entry-lite-s5qkb1fk.js";import"./vm-hands-entry-lite-wx4ax7wg.js";import"./vm-hands-entry-lite-bx5zy5bd.js";import"./vm-hands-entry-lite-cbrtaz8j.js";import"./vm-hands-entry-lite-f2qkz14f.js";import"./vm-hands-entry-lite-2n4n9cs8.js";import"./vm-hands-entry-lite-nzmkyezg.js";import"./vm-hands-entry-lite-pf5qtbj5.js";import"./vm-hands-entry-lite-21qpxvt8.js";import"./vm-hands-entry-lite-tdgtpx8e.js";import"./vm-hands-entry-lite-hk6trmwa.js";import"./vm-hands-entry-lite-zjxzm61j.js";import"./vm-hands-entry-lite-g4zd2d5n.js";import"./vm-hands-entry-lite-aj139v8j.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-sbtjmy0e.js";import"./vm-hands-entry-lite-jzz73e3f.js";import"./vm-hands-entry-lite-2rd6t7ry.js";import"./vm-hands-entry-lite-hqmyd73s.js";import"./vm-hands-entry-lite-jev771b3.js";import"./vm-hands-entry-lite-3krzmhkk.js";import"./vm-hands-entry-lite-4vks5phw.js";import"./vm-hands-entry-lite-fbhqfzbq.js";import"./vm-hands-entry-lite-6c67a3jc.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{cs as computerDisconnected,rt as connectionDirectory,ls as connectionReport,us as restartConnection};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Cn,Os,Is,Ds,Ns,An}from"./vm-hands-entry-lite-
|
|
2
|
+
import{Cn,Os,Is,Ds,Ns,An}from"./vm-hands-entry-lite-cbrtaz8j.js";import"./vm-hands-entry-lite-f2qkz14f.js";import"./vm-hands-entry-lite-2n4n9cs8.js";import"./vm-hands-entry-lite-nzmkyezg.js";import"./vm-hands-entry-lite-pf5qtbj5.js";import"./vm-hands-entry-lite-21qpxvt8.js";import"./vm-hands-entry-lite-tdgtpx8e.js";import"./vm-hands-entry-lite-hk6trmwa.js";import"./vm-hands-entry-lite-zjxzm61j.js";import"./vm-hands-entry-lite-g4zd2d5n.js";import"./vm-hands-entry-lite-aj139v8j.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-sbtjmy0e.js";import"./vm-hands-entry-lite-jzz73e3f.js";import"./vm-hands-entry-lite-2rd6t7ry.js";import"./vm-hands-entry-lite-hqmyd73s.js";import"./vm-hands-entry-lite-jev771b3.js";import"./vm-hands-entry-lite-3krzmhkk.js";import"./vm-hands-entry-lite-4vks5phw.js";import"./vm-hands-entry-lite-fbhqfzbq.js";import"./vm-hands-entry-lite-6c67a3jc.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{Is as ensureLocalBrowser,Cn as localAutomationAvailable,Ds as localBrowserProfile,Os as localUserChromeHost,Ns as runAutomationCallLocally,An as runLocalAutomation};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Wo,$i,un,Vo,Go,Es,xs,Ko,Jo,ks,Cs,As,Ps}from"./vm-hands-entry-lite-
|
|
2
|
+
import{Wo,$i,un,Vo,Go,Es,xs,Ko,Jo,ks,Cs,As,Ps}from"./vm-hands-entry-lite-ev1k9x73.js";import"./vm-hands-entry-lite-m2bswqxe.js";import"./vm-hands-entry-lite-004yshd1.js";import"./vm-hands-entry-lite-beyyy1gz.js";import"./vm-hands-entry-lite-s4bharcb.js";import"./vm-hands-entry-lite-vpz54vwj.js";import"./vm-hands-entry-lite-s5qkb1fk.js";import"./vm-hands-entry-lite-wx4ax7wg.js";import"./vm-hands-entry-lite-bx5zy5bd.js";import"./vm-hands-entry-lite-cbrtaz8j.js";import"./vm-hands-entry-lite-f2qkz14f.js";import"./vm-hands-entry-lite-2n4n9cs8.js";import"./vm-hands-entry-lite-nzmkyezg.js";import"./vm-hands-entry-lite-pf5qtbj5.js";import"./vm-hands-entry-lite-21qpxvt8.js";import"./vm-hands-entry-lite-tdgtpx8e.js";import"./vm-hands-entry-lite-hk6trmwa.js";import"./vm-hands-entry-lite-zjxzm61j.js";import"./vm-hands-entry-lite-g4zd2d5n.js";import"./vm-hands-entry-lite-aj139v8j.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-sbtjmy0e.js";import"./vm-hands-entry-lite-jzz73e3f.js";import"./vm-hands-entry-lite-2rd6t7ry.js";import"./vm-hands-entry-lite-hqmyd73s.js";import"./vm-hands-entry-lite-jev771b3.js";import"./vm-hands-entry-lite-3krzmhkk.js";import"./vm-hands-entry-lite-4vks5phw.js";import"./vm-hands-entry-lite-fbhqfzbq.js";import"./vm-hands-entry-lite-6c67a3jc.js";import"./vm-hands-entry-lite-rfz60hb3.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";export{r as LocalCapabilityError,Wo as SHORT_REQUEST_CAPABILITIES,ks as capabilityInventoryForRoots,$i as confinedExecutionShell,Vo as defaultLocalCommandRunner,Cs as deliverLocalHandsEnvironment,Jo as enrolledRootPaths,Ps as executeLocalOperation,xs as grantLocalHandsWorkspaceControl,Es as openHandsWorkspaceGrant,As as rebindLocalHandsControl,Go as runFileCapability,Ko as runTransferCapability,un as spawnCaptured};
|
package/bin/vm-hands/{local-display-session-zg4dpnf1.js → local-display-session-e4n5hx0v.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$t,Ls,G,qe,Bt}from"./vm-hands-entry-lite-
|
|
2
|
+
import{$t,Ls,G,qe,Bt}from"./vm-hands-entry-lite-f2qkz14f.js";import"./vm-hands-entry-lite-2n4n9cs8.js";import"./vm-hands-entry-lite-nzmkyezg.js";import"./vm-hands-entry-lite-pf5qtbj5.js";import"./vm-hands-entry-lite-21qpxvt8.js";import"./vm-hands-entry-lite-tdgtpx8e.js";import"./vm-hands-entry-lite-hk6trmwa.js";import"./vm-hands-entry-lite-aj139v8j.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-sbtjmy0e.js";import"./vm-hands-entry-lite-jzz73e3f.js";import"./vm-hands-entry-lite-2rd6t7ry.js";import"./vm-hands-entry-lite-hqmyd73s.js";import"./vm-hands-entry-lite-jev771b3.js";import"./vm-hands-entry-lite-3krzmhkk.js";import"./vm-hands-entry-lite-fbhqfzbq.js";import"./vm-hands-entry-lite-6c67a3jc.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{qe as ensureLinuxDesktop,$t as localDisplayAvailable,Ls as localDisplayReady,G as privateDirectory,Bt as runLocalDisplayStream};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Tn,Rn,On,In,Pr}from"./vm-hands-entry-lite-2n4n9cs8.js";import"./vm-hands-entry-lite-hk6trmwa.js";import"./vm-hands-entry-lite-sbtjmy0e.js";import"./vm-hands-entry-lite-jzz73e3f.js";import"./vm-hands-entry-lite-2rd6t7ry.js";import"./vm-hands-entry-lite-hqmyd73s.js";import"./vm-hands-entry-lite-jev771b3.js";import"./vm-hands-entry-lite-3krzmhkk.js";export{Tn as MAC_SCREEN,Rn as WINDOWS_SCREEN,On as createDisplayVideoLane,Pr as localDisplayVideoAvailable,In as simulatorVideoFfmpeg};
|
package/bin/vm-hands/{local-managed-process-gjc8gvgb.js → local-managed-process-2313kw42.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{nt,ur,Ts,Rs}from"./vm-hands-entry-lite-
|
|
2
|
+
import{nt,ur,Ts,Rs}from"./vm-hands-entry-lite-m2bswqxe.js";import"./vm-hands-entry-lite-004yshd1.js";import"./vm-hands-entry-lite-beyyy1gz.js";import"./vm-hands-entry-lite-s4bharcb.js";import"./vm-hands-entry-lite-s5qkb1fk.js";import"./vm-hands-entry-lite-wx4ax7wg.js";import"./vm-hands-entry-lite-pf5qtbj5.js";import"./vm-hands-entry-lite-21qpxvt8.js";import"./vm-hands-entry-lite-tdgtpx8e.js";import"./vm-hands-entry-lite-hk6trmwa.js";import"./vm-hands-entry-lite-aj139v8j.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-jev771b3.js";import"./vm-hands-entry-lite-3krzmhkk.js";import"./vm-hands-entry-lite-4vks5phw.js";import"./vm-hands-entry-lite-fbhqfzbq.js";import"./vm-hands-entry-lite-6c67a3jc.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{nt as ManagedProcessStoppedError,Ts as controlManagedDeviceProcess,Rs as retireManagedDeviceProcess,ur as runManagedDeviceProcess};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ms,gs,_s,ys,bs,vs,Ss}from"./vm-hands-entry-lite-
|
|
2
|
+
import{ms,gs,_s,ys,bs,vs,Ss}from"./vm-hands-entry-lite-6b0dxpkm.js";import"./vm-hands-entry-lite-wx4ax7wg.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-2rd6t7ry.js";import"./vm-hands-entry-lite-hqmyd73s.js";import"./vm-hands-entry-lite-jev771b3.js";import"./vm-hands-entry-lite-3krzmhkk.js";import"./vm-hands-entry-lite-6c67a3jc.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{bs as acquireManagedRuntimeDirectoryLock,_s as currentManagedRuntimeVersion,Ss as flushManagedRuntimeLifecycleEvents,ys as isManagedRuntimeVersionExecutable,gs as legacyManagedRuntimePaths,ms as managedRuntimePaths,vs as recordManagedRuntimeLifecycle};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Qo,es,zs,qs}from"./vm-hands-entry-lite-
|
|
2
|
+
import{Qo,es,zs,qs}from"./vm-hands-entry-lite-sbtjmy0e.js";import"./vm-hands-entry-lite-jzz73e3f.js";import"./vm-hands-entry-lite-2rd6t7ry.js";import"./vm-hands-entry-lite-hqmyd73s.js";import"./vm-hands-entry-lite-jev771b3.js";import"./vm-hands-entry-lite-3krzmhkk.js";export{qs as allowMacPermissions,zs as permissionsSummary,es as readMacPermissions,Qo as reasonIdentity};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{zr,Ee,J,Hn,$s,ho,Bs,Xe,Yo,zn,Fs,js,qr,Us,Hs}from"./vm-hands-entry-lite-
|
|
2
|
+
import{zr,Ee,J,Hn,$s,ho,Bs,Xe,Yo,zn,Fs,js,qr,Us,Hs}from"./vm-hands-entry-lite-zjxzm61j.js";import"./vm-hands-entry-lite-g4zd2d5n.js";import"./vm-hands-entry-lite-aj139v8j.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-2rd6t7ry.js";import"./vm-hands-entry-lite-hqmyd73s.js";import"./vm-hands-entry-lite-jev771b3.js";import"./vm-hands-entry-lite-3krzmhkk.js";import"./vm-hands-entry-lite-6c67a3jc.js";import"./vm-hands-entry-lite-rfz60hb3.js";export{zr as WORKER_SERVICE_ENV,J as WorkerServiceError,ho as connectServiceLabel,Ee as defaultWorkerServiceHost,js as installWorkerService,Xe as installedWorkerService,Bs as isConnectServiceLabel,Hs as removeWorkerService,qr as restartWorkerService,Us as retargetWorkerServiceLogs,Yo as retireLegacyWorkerService,Fs as workerServiceDefinitionCurrent,Hn as workerServiceLauncher,zn as workerServiceProcessRunning,$s as workerServiceRetargetPending};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./vm-hands-entry-lite-8r31b0ps.js";import"./vm-hands-entry-lite-fcvf8md1.js";import{g}from"./vm-hands-entry-lite-aj139v8j.js";import"./vm-hands-entry-lite-3krzmhkk.js";import"./vm-hands-entry-lite-rfz60hb3.js";import"./vm-hands-entry-lite-50zbqwkv.js";import{Ht,lt}from"./vm-hands-entry-lite-pf5qtbj5.js";import{w,M,lr,Fe,rt}from"./vm-hands-entry-lite-
|
|
2
|
+
import"./vm-hands-entry-lite-8r31b0ps.js";import"./vm-hands-entry-lite-fcvf8md1.js";import{g}from"./vm-hands-entry-lite-aj139v8j.js";import"./vm-hands-entry-lite-3krzmhkk.js";import"./vm-hands-entry-lite-rfz60hb3.js";import"./vm-hands-entry-lite-50zbqwkv.js";import{Ht,lt}from"./vm-hands-entry-lite-pf5qtbj5.js";import{w,M,lr,Fe,rt}from"./vm-hands-entry-lite-4vgwtn85.js";import"./vm-hands-entry-lite-4vks5phw.js";import"./vm-hands-entry-lite-ev1k9x73.js";import"./vm-hands-entry-lite-004yshd1.js";import"./vm-hands-entry-lite-hqmyd73s.js";import"./vm-hands-entry-lite-s5qkb1fk.js";import"./vm-hands-entry-lite-vpz54vwj.js";import"./vm-hands-entry-lite-z76nfb19.js";import"./vm-hands-entry-lite-2n4n9cs8.js";import"./vm-hands-entry-lite-jzz73e3f.js";import"./vm-hands-entry-lite-2rd6t7ry.js";import"./vm-hands-entry-lite-sbtjmy0e.js";import"./vm-hands-entry-lite-hk6trmwa.js";import"./vm-hands-entry-lite-6b0dxpkm.js";import"./vm-hands-entry-lite-g4zd2d5n.js";import"./vm-hands-entry-lite-zjxzm61j.js";import"./vm-hands-entry-lite-bx5zy5bd.js";import"./vm-hands-entry-lite-tdgtpx8e.js";import"./vm-hands-entry-lite-beyyy1gz.js";import"./vm-hands-entry-lite-21qpxvt8.js";import"./vm-hands-entry-lite-m2bswqxe.js";import"./vm-hands-entry-lite-fbhqfzbq.js";import"./vm-hands-entry-lite-nzmkyezg.js";import"./vm-hands-entry-lite-f2qkz14f.js";import"./vm-hands-entry-lite-cbrtaz8j.js";import"./vm-hands-entry-lite-ec9jemny.js";import"./vm-hands-entry-lite-s4bharcb.js";import"./vm-hands-entry-lite-wx4ax7wg.js";import{a}from"./vm-hands-entry-lite-jev771b3.js";import{t,o,u,i,s,n}from"./vm-hands-entry-lite-avc65bd7.js";import"./vm-hands-entry-lite-6c67a3jc.js";import{readFileSync as me,realpathSync as k,renameSync as ge,unlinkSync as fe,writeFileSync as he}from"fs";import{dirname as ye,join as I}from"path";function h(e){return`claude mcp add --transport http reason ${e}`}function C(e){return`codex mcp add reason --url ${e}
|
|
3
3
|
codex mcp login reason`}var F=h("https://mcp.reasonmachines.com/mcp"),z=C("https://mcp.reasonmachines.com/mcp"),B=`https://claude.ai/settings/connectors?add=custom&url=${encodeURIComponent("https://mcp.reasonmachines.com/mcp")}`,H=`https://cursor.com/install-mcp?name=reason&config=${encodeURIComponent(btoa(JSON.stringify({url:"https://mcp.reasonmachines.com/mcp"})))}`;var b="https://github.com/reason-machines/reason-plugins",X=`Connect a coding agent to Reason over MCP
|
|
4
4
|
|
|
5
5
|
Usage:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{zt,j}from"./vm-hands-entry-lite-pf5qtbj5.js";import{ue,Ce,Z,Ae,de,rr,Qe,X,O,H,tn}from"./vm-hands-entry-lite-3krzmhkk.js";import{_o,Vn}from"./vm-hands-entry-lite-aj139v8j.js";import{lo,P,Ke,ve,Je,ne,Ze,Bn,Se,Gt,ae,U,N,ce,Ur,Hr,jn}from"./vm-hands-entry-lite-tdgtpx8e.js";import{Pe,oe,pe,Y,Oe,q,Q}from"./vm-hands-entry-lite-4vks5phw.js";import{It,Sr,st,V,D,R,b}from"./vm-hands-entry-lite-beyyy1gz.js";import{xr,kr,bn,io,ze,vn}from"./vm-hands-entry-lite-s5qkb1fk.js";import{K}from"./vm-hands-entry-lite-hk6trmwa.js";import{Ii}from"./vm-hands-entry-lite-fbhqfzbq.js";import{p,He,Dt,at,Yi,_e,we}from"./vm-hands-entry-lite-s4bharcb.js";import{v,h,oo}from"./vm-hands-entry-lite-wx4ax7wg.js";import{E}from"./vm-hands-entry-lite-dk79tnax.js";import{er}from"./vm-hands-entry-lite-6wt5ja1k.js";import{a,ie,Do}from"./vm-hands-entry-lite-jev771b3.js";import{L,Pi,Ti,Bo,y,t,k,xt,o,d,u,i,c,_,ee,s,n}from"./vm-hands-entry-lite-avc65bd7.js";import{Oi}from"./vm-hands-entry-lite-hbs3tpdg.js";import{jo,se,Uo,C,Ne,$e,A}from"./vm-hands-entry-lite-6c67a3jc.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";var li=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function l(w){return e[w]??null}let f={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},g={nan:"NaN"};return(w)=>{switch(w.code){case"invalid_type":{let S=g[w.expected]??w.expected,I=Bo(w.input),W=g[I]??I;return`Invalid input: expected ${S}, received ${W}`}case"invalid_value":if(w.values.length===1)return`Invalid input: expected ${Ti(w.values[0])}`;return`Invalid option: expected one of ${Pi(w.values,"|")}`;case"too_big":{let S=w.inclusive?"<=":"<",I=l(w.origin);if(I)return`Too big: expected ${w.origin??"value"} to have ${S}${w.maximum.toString()} ${I.unit??"elements"}`;return`Too big: expected ${w.origin??"value"} to be ${S}${w.maximum.toString()}`}case"too_small":{let S=w.inclusive?">=":">",I=l(w.origin);if(I)return`Too small: expected ${w.origin} to have ${S}${w.minimum.toString()} ${I.unit}`;return`Too small: expected ${w.origin} to be ${S}${w.minimum.toString()}`}case"invalid_format":{let S=w;if(S.format==="starts_with")return`Invalid string: must start with "${S.prefix}"`;if(S.format==="ends_with")return`Invalid string: must end with "${S.suffix}"`;if(S.format==="includes")return`Invalid string: must include "${S.includes}"`;if(S.format==="regex")return`Invalid string: must match pattern ${S.pattern}`;return`Invalid ${f[S.format]??w.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${w.divisor}`;case"unrecognized_keys":return`Unrecognized key${w.keys.length>1?"s":""}: ${Pi(w.keys,", ")}`;case"invalid_key":return`Invalid key in ${w.origin}`;case"invalid_union":if(w.options&&Array.isArray(w.options)&&w.options.length>0)return`Invalid discriminator value. Expected ${w.options.map((I)=>`'${I}'`).join(" | ")}`;return"Invalid input";case"invalid_element":return`Invalid value in ${w.origin}`;default:return"Invalid input"}}};function En(){return{localeError:li()}}L(En());class _t extends Error{}function Ro(e){let l;try{l=new URL(e)}catch{throw new _t("The proxy must be a URL like https://proxy.example.com:3128.")}if(l.protocol!=="https:"&&l.protocol!=="http:")throw new _t("The proxy URL must use the https or http scheme.");if(!l.hostname)throw new _t("The proxy URL must name a host.");if(l.port!==""&&Number(l.port)<1)throw new _t("The proxy URL must use a port between 1 and 65535.");if(l.pathname!==""&&l.pathname!=="/"||l.search||l.hash)throw new _t("The proxy URL must not carry a path, query, or fragment.");return l.toString()}import{createHash as ui}from"crypto";import{isAbsolute as Oo,join as xo,relative as Po,resolve as Yt,sep as Io}from"path";var qt=t().min(1).refine(Oo,"absolute path required"),On=c({version:n(1),apiOrigin:xt(),channel:s(["staging","production"]),stateDirectory:qt,workspaceRoot:qt,lifetime:s(["persistent","ephemeral"]),executionMode:s(["confined","host"]).default("confined"),name:t().min(1).max(160).default("Reason headless worker"),slots:o().int().min(1).max(4).default(1),shutdownGraceMs:o().int().min(0).max(300000).default(30000),proxy:c({version:n(zt),url:t().refine((e)=>{try{return Ro(e)===e}catch{return!1}},"invalid proxy URL"),caFile:qt.optional()}).optional(),userChrome:d().optional(),cloudSessions:n(!0).optional(),localLogins:d().optional(),folders:u(qt).min(1).max(31).optional()}),fi=/^https:\/\/[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.trycloudflare\.com$/,B=_("channel",[On,On.extend({channel:n("pr"),apiOrigin:t(),prEnvironment:t()}),On.extend({channel:n("local-qa"),apiOrigin:t()})]).superRefine((e,l)=>{if(e.channel==="local-qa"){if(!fi.test(e.apiOrigin))l.addIssue({code:"custom",message:"local QA worker requires an exact HTTPS trycloudflare.com quick-tunnel origin"})}else if(e.channel==="pr"){let g=e.prEnvironment,w=/^https:\/\/([a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)\.up\.railway\.app$/.exec(e.apiOrigin),S=w?.[1]?.match(/(?:^|-)pr-[0-9]+(?=-|$)/g)?.map((I)=>I.replace(/^-/,""));if(!g||/^pr-[1-9][0-9]*$/.exec(g)?.[0]!==g||w?.[0]!==e.apiOrigin||S?.length!==1||S[0]!==g)l.addIssue({code:"custom",message:"PR worker requires explicit prEnvironment and an exact same-PR HTTPS Railway origin"})}else{let g=new URL(e.apiOrigin);if(g.origin!==e.apiOrigin||g.username||g.password||g.protocol!=="https:"&&!(g.protocol==="http:"&&Vn(g.origin))||!Vn(g.origin)&&!_o(e.channel,g.origin))l.addIssue({code:"custom",message:"API origin must match channel (or loopback)"})}if(!je(e.workspaceRoot,e.stateDirectory))l.addIssue({code:"custom",message:"state and workspace must be disjoint"});let f=e.folders??[];if(new Set([e.workspaceRoot,...f]).size!==f.length+1||f.some((g)=>!je(g,e.stateDirectory)))l.addIssue({code:"custom",message:"folders must be distinct and disjoint from state"})});function m(e){return xo(e.stateDirectory,`headless-${e.channel==="pr"?e.prEnvironment:e.channel}`)}function je(e,l){if($r(l,e))return!1;return!$r(e,l)||E(xo(Io,Po(Yt(e),Yt(l))))}function $r(e,l){let f=Po(Yt(e),Yt(l));return f===""||f!==".."&&!f.startsWith(`..${Io}`)&&!Oo(f)}function te(e){let{proxy:l,userChrome:f,cloudSessions:g,localLogins:w,folders:S,...I}=e;return ui("sha256").update(JSON.stringify(I)).digest("hex")}var pi=4,_i=[2375,2376,9222,9229];function dr(e){let l=new Set(_i);for(let f of e){let g=new URL(f);l.add(Number(g.port||(["https:","wss:"].includes(g.protocol)?443:80)))}return l}function Vr(){throw new r("preview_unavailable","The live Hands preview binding is unavailable or stale.")}var mi=60000;function Ao(e){let l=new AbortController,f=new Map,g=(x)=>JSON.stringify([x.jobId,x.port]);function w(x){let M=e.authority.owner;if(l.signal.aborted||!e.isCurrent()||e.expiresAtMs<=Date.now()||x.organization_id!==M.organization_id||x.user_id!==M.user_id||x.device_id!==M.device_id)Vr()}function S(x){let M;try{M=e.environment.current()}catch{return null}return M.binding.target_generation===x.generation&&M.binding.target_fence_id===x.fenceId&&M.run_id===e.runId&&M.device_id===e.authority.owner.device_id&&M.root_id===e.authority.rootId?M:null}async function I(x,M,G){let F=await W(x,M,G);if(F!=="moved")return F;let T=await W(x,M,G);return T==="moved"?null:T}async function W(x,M,G){try{w(e.authority.owner);let F=e.identity();if(!F||G.aborted||x.expiresAtMs<=Date.now()||x.expiresAtMs>e.expiresAtMs)return null;let T=M.opened,re=T!==void 0&&F.generation>T.generation,J=S(F);if(re){if(J){if(J.revision<=T.revision||x.expiresAtMs>Date.parse(J.expires_at)||J.binding.target_revision!==T.attachmentRevision||J.binding.root_grant_revision!==T.grantRevision)return null;M.recoveringSinceMs=void 0}else if(Date.now()-(M.recoveringSinceMs??=Date.now())>mi)return null}else if(!J||x.expiresAtMs>Date.parse(J.expires_at)||T&&(F.generation!==T.generation||F.fenceId!==T.fenceId))return null;let z=await e.inspect(x.jobId,G),fe=e.identity(),ke=fe&&S(fe);w(e.authority.owner);let be=J&&{generation:F.generation,fenceId:F.fenceId,snapshotId:J.snapshot_id,revision:J.revision,attachmentRevision:J.binding.target_revision,grantRevision:J.binding.root_grant_revision},Re=re?T:be;if(G.aborted||!fe)return null;if(fe.generation!==F.generation||fe.fenceId!==F.fenceId||ke?.snapshot_id!==J?.snapshot_id||ke?.revision!==J?.revision)return"moved";let Fe=z.ok&&z.job.environmentSnapshotId!==void 0&&z.job.environmentRevision!==void 0?{snapshotId:z.job.environmentSnapshotId,revision:z.job.environmentRevision}:null;if(!z.ok||z.generation!==F.generation||!Re||!Fe)return null;if((Fe.snapshotId!==Re.snapshotId||Fe.revision!==Re.revision)&&(re||!e.environment.carried(Fe.snapshotId,Fe.revision)))return null;if(!T&&F.generation===x.generation&&F.fenceId===x.fenceId)M.opened={...Re,...Fe};return{executorLaunchId:e.executorLaunchId,job:z.job,binding:{organizationId:e.authority.owner.organization_id,userId:e.authority.owner.user_id,deviceId:e.authority.owner.device_id,rootId:e.authority.rootId,runId:e.runId,attachmentRevision:Re.attachmentRevision,grantRevision:Re.grantRevision,generation:Re.generation,fenceId:Re.fenceId,jobId:z.job.jobId,port:x.port,expiresAtMs:x.expiresAtMs}}}catch{return null}}return{async open(x,M,G){w(M);let{binding:F,deviceRelayUrl:T}=at(x);if(G.aborted||F.expiresAtMs<=Date.now()||F.expiresAtMs>Date.now()+p.lifetimeMs||new URL(T).origin!==e.authority.relayOrigin)Vr();let re=g(F),J=f.get(re);if(J){if(!He(J.binding,F)||J.relay!==T)Vr();if(await J.opened,!await Dt(()=>J.port.check())||G.aborted||J.abort.signal.aborted)Vr();return{opened:!0,binding:F}}if(f.size>=pi)Vr();let z=new AbortController,fe={},ke=we({binding:F,deniedPorts:e.authority.deniedPorts,readCurrentJob:()=>I(F,fe,z.signal)}),be=()=>z.abort();if(G.addEventListener("abort",be,{once:!0}),l.signal.addEventListener("abort",be,{once:!0}),G.aborted||l.signal.aborted)be();let Re=_e({binding:F,deviceRelayUrl:T,port:ke,signal:z.signal}),Fe={binding:F,relay:T,abort:z,port:ke,opened:Re};f.set(re,Fe);let Ye=()=>{if(G.removeEventListener("abort",be),l.signal.removeEventListener("abort",be),f.get(re)===Fe)f.delete(re)};try{if((await Re).closed.then(Ye),G.removeEventListener("abort",be),w(M),z.signal.aborted||!await Dt(()=>ke.check()))Vr();return{opened:!0,binding:F}}catch{z.abort(),Ye(),Vr()}},async close(x,M){w(M);let{binding:G}=Yi(x),F=f.get(g(G));if(!F||!He(F.binding,G))Vr();return F.abort.abort(),await F.opened.then((T)=>T.closed,()=>{return}),{closed:!0,binding:G}},dispose(){l.abort();for(let x of f.values())x.abort.abort();f.clear()}}}import{WebSocket as xn}from"ws";var To=(e)=>("data"in e)?e.data.length:e.bytes,Co=2*Ze;function cr(e){throw new r(e,"The bound Hands terminal is unavailable or its outcome is unconfirmed.")}var mt=(e)=>!["starting","running"].includes(e.state);function Hi(e,l,f=Date.now()){let g=["relay_url","session_id","expires_at","cols","rows","pty","workspace"];if(Object.keys(e).length!==g.length||Object.keys(e).some((M)=>!g.includes(M))||!ae(l)||!ae(e.session_id)||typeof e.expires_at!=="string"||typeof e.relay_url!=="string"||e.relay_url.length>4096||![e.cols,e.rows].every((M)=>Number.isSafeInteger(M)&&Number(M)>=1&&Number(M)<=Se))cr("invalid_pty_request");let w=e.pty;if(!w||typeof w!=="object"||Array.isArray(w))cr("invalid_pty_request");let S=w;if(Object.keys(S).length!==2||S.version!==1||!ce(S.jobId))cr("invalid_pty_request");let I;try{I=new URL(e.relay_url)}catch{return cr("invalid_pty_request")}if(!["ws:","wss:"].includes(I.protocol)||I.username||I.password||I.hash||I.protocol==="ws:"&&!["127.0.0.1","[::1]","localhost"].includes(I.hostname))cr("invalid_pty_request");let W=Date.parse(e.expires_at);if(!Number.isSafeInteger(W)||W<=f)cr("invalid_pty_request");return{workspace:H(e.workspace)??cr("invalid_pty_request"),session:{jobId:S.jobId,sessionId:e.session_id,operationId:l,relayUrl:I.href,cols:Number(e.cols),rows:Number(e.rows),leaseExpiresAtMs:Math.min(W,f+43200000)}}}async function Ho(e){let{session:l,binding:f}=e;if(f.assertCurrent(),e.signal.aborted||Date.now()>=l.leaseExpiresAtMs)cr("cancelled");let g=new xn(l.relayUrl,{followRedirects:!1,perMessageDeflate:!1,maxPayload:ne}),w=new AbortController,S=()=>{},I=()=>{w.abort(),S()};e.signal.addEventListener("abort",I,{once:!0});let W=setTimeout(I,Math.max(1,l.leaseExpiresAtMs-Date.now())),x=[],M=0,G=0,F=0,T=!1,re=!1,J=!1,z,fe,ke,be=(le)=>{ke=new r(le,"Bound terminal input was refused."),I()};g.on("error",()=>be("pty_relay_unavailable")),g.on("close",I),g.on("message",(le,he)=>{if(w.signal.aborted)return;if(!re){be("pty_not_ready");return}let xe=Array.isArray(le)?Buffer.concat(le):le instanceof ArrayBuffer?Buffer.from(le):le;if(xe.length===0)return;let Ge=x.at(-1),Le=he&&Ge!==void 0&&"data"in Ge&&Ge.data.length+xe.length<=ne;if(xe.length>ne||M+xe.length>Bn){be("pty_input_backpressure");return}if(Le)Ge.data=Buffer.concat([Ge.data,xe]);else if(he)x.push({data:Buffer.from(xe)});else try{let Be=JSON.parse(xe.toString("utf8"));if(Be&&Be.t==="close"&&Object.keys(Be).length===1){J=!0,I();return}if(!Be||Be.t!=="resize"||Object.keys(Be).length!==3||![Be.cols,Be.rows].every((Ee)=>Number.isSafeInteger(Ee)&&Ee>=1&&Ee<=Se))throw Error("invalid_control");x.push({cols:Be.cols,rows:Be.rows,bytes:xe.length})}catch{be("invalid_pty_control");return}M+=xe.length,S()});function Re(le){return jn(JSON.stringify({...f.scope,version:1,sessionId:l.sessionId,operationId:l.operationId,job:{...le,output:[],pty:le.pty?{...le.pty,output:[]}:void 0}}))}function Fe(le){if(!le.ok)cr(le.error);let he=le.job;if(le.generation!==f.scope.generation||he.jobId!==l.jobId||!he.pty||he.leaseExpiresAtMs>l.leaseExpiresAtMs||he.process&&he.process.executorLaunchId!==f.scope.executorLaunchId||he.process&&fe&&(he.process.pid!==fe.pid||he.process.processGroupId!==fe.processGroupId)||he.state!=="starting"&&(he.environmentRevision!==f.environment.revision||he.environmentSnapshotId!==f.environment.snapshotId))cr("pty_binding_changed");if(Re(he),he.process)fe??={...he.process};return he}async function Ye(le){f.assertCurrent();let he=await f.request(le,w.signal);if(f.assertCurrent(),w.signal.aborted)cr("cancelled");let xe=Fe(he);if(xe.inputSequence!==G)cr("job_input_sequence");if(!mt(xe)&&xe.leaseExpiresAtMs<=Date.now())cr("pty_binding_changed");return xe}function ye(le){if(f.assertCurrent(),w.signal.aborted||g.readyState!==xn.OPEN||g.bufferedAmount+Buffer.byteLength(le)>Co)cr("pty_output_backpressure");g.send(le)}function We(le){if(le.firstCursor>F+1)F=le.firstCursor-1;for(let he of le.pty.output){if(he.cursor<=F)continue;if(he.cursor!==F+1)cr("pty_output_gap");let xe=Buffer.from(he.dataBase64,"base64");if(g.bufferedAmount+xe.length>Co)return!1;ye(xe),F=he.cursor}if(F!==le.nextCursor)cr("pty_output_gap");return!0}async function qe(le,he){let xe;try{await Promise.race([e.emit(le,he),new Promise((Ge,Le)=>{xe=setTimeout(()=>Le(new r("pty_event_unavailable","Terminal metadata delivery timed out.")),2000)})])}finally{clearTimeout(xe)}}async function Te(){let le=AbortSignal.timeout(Gt),he=f.request({jobId:l.jobId,action:"cancel",input:{}},le),xe,Ge=new Promise((Le,Be)=>{if(xe=()=>Be(new r("pty_cleanup_unconfirmed","Terminal cleanup acknowledgement was not observed within authority.")),le.addEventListener("abort",xe,{once:!0}),le.aborted)xe()});try{let Le=await Promise.race([he,Ge]);if(le.aborted)cr("pty_cleanup_unconfirmed");return Fe(Le)}finally{le.removeEventListener("abort",xe)}}try{await new Promise((Le,Be)=>{let Ee=setTimeout(()=>{I(),Be(new r("pty_relay_unavailable","Terminal pairing timed out."))},5000),Me=()=>{clearTimeout(Ee),Be(new r("cancelled","Terminal pairing was cancelled."))};if(w.signal.addEventListener("abort",Me,{once:!0}),g.once("open",()=>{clearTimeout(Ee),w.signal.removeEventListener("abort",Me),Le()}),w.signal.aborted)Me()}),f.assertCurrent(),T=!0,z=await Ye({jobId:l.jobId,action:"start",input:{mode:"pty",cols:l.cols,rows:l.rows,leaseExpiresAtMs:l.leaseExpiresAtMs}});let le=Date.now()+5000;while(z.state==="starting"){if(Date.now()>=le)cr("pty_not_ready");await new Promise((Le)=>setTimeout(Le,25)),z=await Ye({jobId:l.jobId,action:"inspect",input:{after:F}})}if(z.state!=="running"||z.inputSequence!==0||z.leaseExpiresAtMs<=Date.now())cr("pty_not_ready");await qe("pty.ready",Re(z)),re=!0,ye(JSON.stringify({t:"open",cols:z.pty.cols,rows:z.pty.rows,receipt:Re(z)}));let he=!1,xe=0,Ge=!1;while(!w.signal.aborted){let Le=z.firstCursor>F+1,Be=We(z);if(mt(z)){if(Be)break}else if(Le)he=!0;else if(he&&Be&&Date.now()>=xe){he=!1,xe=Date.now()+1000;let{cols:Me,rows:or}=z.pty;for(let sr of[{cols:Me,rows:or>1?or-1:2},{cols:Me,rows:or}]){if(mt(z))break;let Ir=++G;if(z=await Ye({jobId:l.jobId,action:"resize",input:{sequence:Ir,...sr}}),z.inputSequence!==Ir)cr("job_input_sequence")}continue}let Ee=mt(z)||Ge?void 0:x.shift();if(Ee){M-=To(Ee);let Me=++G;try{z=await Ye("data"in Ee?{jobId:l.jobId,action:"input",input:{sequence:Me,dataBase64:Ee.data.toString("base64")}}:{jobId:l.jobId,action:"resize",input:{sequence:Me,cols:Ee.cols,rows:Ee.rows}})}catch(or){if(!(or instanceof r)||or.code!=="job_input_backpressure")throw or;G-=1,x.unshift(Ee),M+=To(Ee),Ge=!0;continue}if(z.inputSequence!==Me)cr("job_input_sequence")}else if(await new Promise((Me)=>{let or=setTimeout(Me,Ge||!Be?10:50);if(S=()=>{clearTimeout(or),Me()},w.signal.aborted||!Ge&&x.length)S()}),Ge=!1,S=()=>{},!w.signal.aborted&&Be)try{z=await Ye({jobId:l.jobId,action:"inspect",input:{after:F}})}catch(Me){if(!J||!(Me instanceof r)||Me.code!=="cancelled")throw Me}}}catch(le){ke??=le}finally{if(re=!1,x.length=0,clearTimeout(W),e.signal.removeEventListener("abort",I),I(),T&&(!z||!mt(z)))try{z=await Te()}catch{z=void 0}try{if(!z||!mt(z)||z.pty?.cleanup!=="confirmed")cr("pty_cleanup_unconfirmed");let le=Re(z);if(g.readyState===xn.OPEN)await new Promise((he)=>{let xe=setTimeout(he,500);g.send(JSON.stringify({t:"exit",code:z.exitCode,receipt:le}),()=>{clearTimeout(xe),he()})});await qe("pty.stopped",le)}catch(le){ke??=le}g.terminate()}if(ke)throw ke;if(e.signal.aborted)cr("cancelled");if(!z)cr("pty_cleanup_unconfirmed");return{receipt:Re(z)}}import{createHash as hi,randomUUID as An}from"crypto";import{spawnSync as Wo}from"child_process";import{closeSync as No,constants as Pn,fstatSync as gi,fsyncSync as bi,lstatSync as Bt,mkdirSync as wi,mkdtempSync as Fo,openSync as Lo,readFileSync as yi,readdirSync as zo,realpathSync as Lt,rmSync as In,unlinkSync as vi}from"fs";import{createConnection as ki}from"net";import{dirname as Si,join as nt,sep as Ei}from"path";import{tmpdir as Ri}from"os";var Pr=new Map,qr=new Map;function Kr(e,l){return hi("sha256").update(JSON.stringify([e,l])).digest("hex")}function ht(e){try{wi(e,{mode:448})}catch(f){if(!(f instanceof Error&&("code"in f)&&f.code==="EEXIST"))throw f}let l=Bt(e);if(!l.isDirectory()||l.isSymbolicLink()||!A(l)||Lt(e)!==e)throw new r("hands_jobs_unavailable","Hands job state must be a private canonical directory.")}function xi(e){let l;try{l=Bt(e)}catch(f){if(f instanceof Error&&"code"in f&&f.code==="ENOENT")return!1;throw f}return!l.isDirectory()||l.isSymbolicLink()||zo(e).length>0}function pr(e){let l=Kr(e.root,e.runId),f=e.previousRuntimeDirectories?.find((I)=>xi(nt(I,"jobs",l.slice(0,16))))??e.runtimeDirectory;ht(f);let g=nt(f,"jobs");ht(g);let w=nt(g,l.slice(0,16));if(e.maxScopes!==void 0){let I=zo(g);if(!Number.isSafeInteger(e.maxScopes)||e.maxScopes<1||I.length>e.maxScopes||!I.includes(l.slice(0,16))&&I.length>=e.maxScopes)throw new r("process_journal_capacity","Managed process receipt capacity is full; preserve uncertain jobs and reconcile their existing receipts before starting more work.")}ht(w);let S=Fo(nt(Uo(),"reason-j-"));try{return ht(S),{journalDirectory:w,scopeId:l,launchDirectory:S,socketPath:process.platform==="win32"?`\\\\.\\pipe\\reason-jobs-${An()}`:nt(S,"control.sock"),disposeSocket:()=>In(S,{recursive:!0,force:!0})}}catch(I){throw In(S,{recursive:!0,force:!0}),I}}var Ai=60000,Di=5000;function Ci(e){if(process.platform==="win32")return Ni(e);let l=Wo("ps",["-o","lstart=","-p",String(e)],{encoding:"utf8",timeout:2000,env:{...process.env,LC_ALL:"C",LANG:"C"}}),f=l.status===0?/^\w{3} (\w{3}) +(\d{1,2}) (\d{2}):(\d{2}):(\d{2}) (\d{4})$/.exec(l.stdout.trim()):null,g=f?"JanFebMarAprMayJunJulAugSepOctNovDec".indexOf(f[1]):-1;if(!f||g<0||g%3!==0)return null;let w=new Date(Number(f[6]),g/3,Number(f[2]),Number(f[3]),Number(f[4]),Number(f[5])).getTime();return Number.isFinite(w)?w:null}function Ni(e){let l=Wo(C("powershell"),["-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${e}).StartTime.ToUniversalTime().ToString('o')`],{encoding:"utf8",timeout:5000,windowsHide:!0,env:Ne()}),f=l.status===0?Date.parse(l.stdout.trim()):Number.NaN;return Number.isFinite(f)?f:null}function $o(e,l={}){let f=nt(e.journalDirectory,"owner.lock"),g;try{g=Lo(f,Pn.O_RDONLY|Pn.O_NOFOLLOW)}catch{return null}try{let w=gi(g);if(!w.isFile()||w.nlink!==1||!A(w)||w.size>4096)return null;let S=null;try{S=JSON.parse(yi(g,"utf8"))}catch{}let I;if(S===null){if((l.now??Date.now)()-w.mtimeMs<Ai)return null;I={reason:"never_written",executorLaunchId:null}}else{let{version:M,scopeId:G,pid:F,createdAtMs:T,executorLaunchId:re}=S;if(M!==1||G!==e.scopeId||typeof re!=="string"||typeof F!=="number"||!Number.isSafeInteger(F)||F<1||F===process.pid||typeof T!=="number"||!Number.isSafeInteger(T))return null;if(!(l.exists??((z)=>{try{return process.kill(z,0),!0}catch(fe){return!(fe instanceof Error&&("code"in fe)&&fe.code==="ESRCH")}}))(F))I={reason:"owner_exited",executorLaunchId:re};else{let z=(l.startedAtMs??Ci)(F);if(z===null||z<=T+Di)return null;I={reason:"pid_reused",executorLaunchId:re}}}let W=Bt(f);if(W.dev!==w.dev||W.ino!==w.ino)return null;vi(f);let x=Lo(e.journalDirectory,Pn.O_RDONLY);try{bi(x)}finally{No(x)}return I}catch{return null}finally{No(g)}}function Ko(e){let l={...e,workspace:e.workspace&&Object.freeze({...e.workspace}),previewAuthority:e.previewAuthority&&Object.freeze({...e.previewAuthority,owner:Object.freeze({...e.previewAuthority.owner}),deniedPorts:new Set(e.previewAuthority.deniedPorts)})},f=Kr(l.root,l.runId);if(Pr.has(f)||l.operationId!==void 0&&qr.has(l.operationId))throw new r("hands_jobs_busy","The Session already has a live Hands job supervisor.");let g={binding:l,key:f,terminals:new Map};if(l.previewAuthority&&l.environment)g.previews=Ao({authority:l.previewAuthority,runId:l.runId,expiresAtMs:l.expiresAtMs,executorLaunchId:l.executorLaunchId,environment:l.environment,isCurrent:()=>Pr.get(g.key)===g,identity:()=>{try{return gt(l)}catch{return null}},inspect:(w,S)=>{if(Pr.get(g.key)!==g)throw new r("preview_unavailable","The Hands supervisor is no longer current.");return Go(l,{jobId:w,action:"inspect",input:{after:0}},S)}});if(Pr.set(f,g),l.operationId!==void 0)qr.set(l.operationId,g);return()=>{if(Pr.get(g.key)===g)Pr.delete(g.key);if(l.operationId!==void 0&&qr.get(l.operationId)===g)qr.delete(l.operationId);g.previews?.dispose();for(let w of g.terminals.values())w.abort()}}var Li=5000,Bi=20;async function zi(e){let l=(w)=>{throw new r("hands_rebind_unavailable",w)};if(!N(e.operationId)||!N(e.runId)||!N(e.fenceId)||!U(e.targetGeneration))l("Reason sent an invalid Hands rebind.");let f=qr.get(e.operationId);if(!f||f.binding.root!==e.root)return l("No live Hands supervisor owns this operation.");for(let w=Date.now()+Li;;){if(e.signal?.aborted)l("The Hands rebind was cancelled.");if(qr.get(e.operationId)!==f)l("The Hands supervisor is no longer current.");let S=null;try{S=gt(f.binding)}catch{}if(S&&S.generation===e.targetGeneration&&S.fenceId===e.fenceId)break;if(S&&S.generation>e.targetGeneration||Date.now()>=w)l("The executor did not adopt this take.");await new Promise((I)=>setTimeout(I,Bi))}if(qr.get(e.operationId)!==f||Pr.get(f.key)!==f)l("The Hands supervisor is no longer current.");let g=Kr(e.root,e.runId);if(f.key===g)return;if(Pr.has(g))l("The taking run already has a live Hands job supervisor.");Pr.delete(f.key);for(let w of f.terminals.values())w.abort();f.key=g,Pr.set(g,f)}function it(e){let l="operationId"in e?qr.get(e.operationId):Pr.get(Kr(e.root,e.runId)),f=l&&l.binding.root===e.root?l.binding:void 0;if(!f?.environment||f.expiresAtMs<=Date.now())throw new r("environment_unavailable","No live Hands supervisor owns this environment.");return f.environment.install(e.payload)}async function qi(e){let l=Pr.get(Kr(e.root,e.runId));if(!l?.previews||!e.owner)throw new r("preview_unavailable","No authenticated Hands supervisor owns this preview.");return l.previews.open(e.payload,e.owner,e.signal)}async function Wi(e){let l=Pr.get(Kr(e.root,e.runId));if(!l?.previews||!e.owner||e.signal.aborted)throw new r("preview_unavailable","No authenticated Hands supervisor owns this preview.");return l.previews.close(e.payload,e.owner)}async function Vi(e){let l=Kr(e.root,e.runId),f=Pr.get(l),g=f?.binding,w=g?.runId,S=g?.previewAuthority,I=g?.environment,W=e.owner&&{...e.owner},x=e.authority&&{...e.authority},M=()=>{throw new r("pty_binding_unavailable","No current authenticated Hands scope owns this terminal.")};if(!f||!g||!S||!I||!W||!x||!g.workspace)return M();let G=Object.freeze({...g.workspace}),F=gt(g),T=I.current(),re=()=>{if(Pr.get(l)!==f||W.organization_id!==S.owner.organization_id||W.user_id!==S.owner.user_id||W.device_id!==S.owner.device_id||e.deviceId!==S.owner.device_id||e.rootId!==S.rootId||O(e.workspace)!==O(G))M();let z=gt(g),fe=I.current();if(z.generation!==F.generation||z.fenceId!==F.fenceId||fe.run_id!==w||fe.device_id!==e.deviceId||fe.root_id!==e.rootId||fe.snapshot_id!==T.snapshot_id||fe.revision!==T.revision||fe.binding.target_generation!==F.generation||fe.binding.target_fence_id!==F.fenceId||x.device_id!==e.deviceId||x.binding!==fe.binding.kind||x.target_revision!==fe.binding.target_revision||x.root_grant_revision!==fe.binding.root_grant_revision||x.target_generation!==F.generation||x.target_fence_id!==F.fenceId)M()};if(re(),new URL(e.session.relayUrl).origin!==S.relayOrigin||f.terminals.has(e.session.jobId)||f.terminals.size>=4)return M();let J=new AbortController;f.terminals.set(e.session.jobId,J);try{return await Ho({session:{...e.session,leaseExpiresAtMs:Math.min(e.session.leaseExpiresAtMs,F.expiresAtMs,Date.parse(T.expires_at))},signal:AbortSignal.any([e.signal,J.signal]),emit:e.emit,binding:{assertCurrent:re,environment:{revision:T.revision,snapshotId:T.snapshot_id},scope:{runId:e.runId,deviceId:e.deviceId,rootId:e.rootId,workspace:G,binding:T.binding.kind,targetRevision:T.binding.target_revision,rootGrantRevision:T.binding.root_grant_revision,generation:F.generation,fenceId:F.fenceId,executorLaunchId:F.executorLaunchId},request:(z,fe)=>hr(F,Ur(JSON.stringify({...z,type:"job",version:2,generation:F.generation,id:An()})),fe)}})}finally{if(f.terminals.get(e.session.jobId)===J)f.terminals.delete(e.session.jobId)}}async function Gi(e){if(ce(e.payload.jobId))throw new r("pty_binding_required","PTY jobs require the bound terminal capability.");let l=Pr.get(Kr(e.root,e.runId))?.binding;if(!l||l.expiresAtMs<=Date.now())throw new r("hands_jobs_unavailable","No live Hands supervisor owns this Session and root.");return Go(l,e.payload,e.signal)}var ji=1e4,Mi=20,Fi=ve/2,Ui=Ke/2,$i=(e)=>e.output.reduce((l,f)=>l+f.text.length,0);async function Go(e,l,f){if(Object.keys(l).some((M)=>!["jobId","action","input","waitForExitMs"].includes(M)))throw new r("invalid_payload","Unexpected job control field.");let{waitForExitMs:g,...w}=l;if(g!==void 0&&(w.action!=="start"||typeof w.input!=="object"||w.input===null||!("script"in w.input)||typeof g!=="number"||!Number.isSafeInteger(g)||g<1||g>ji))throw new r("invalid_payload","Only a script start may wait for its job, within its bound.");let S=(M)=>{let G=gt(e);return hr(G,Ur(JSON.stringify({...M,type:"job",version:2,generation:G.generation,id:An()})),f)},I=await S(w);if(g===void 0)return I;let W=Date.now()+g,x=I;while(x.ok&&["starting","running"].includes(x.job.state)&&x.job.output.length<Fi&&$i(x.job)<Ui&&!f.aborted&&Date.now()<W){if(await new Promise((M)=>setTimeout(M,Math.min(Mi,W-Date.now()))),f.aborted)break;try{let M=await S({jobId:w.jobId,action:"inspect",input:{after:0}});if(!M.ok)break;x=M}catch{break}}return x}function gt(e){if(e.expiresAtMs<=Date.now())throw new r("hands_jobs_unavailable","Hands authority expired.");let l=e.readIdentity?e.readIdentity():e;if(!l||!U(l.generation)||!N(l.fenceId)||l.generation<e.generation||l.generation===e.generation&&l.fenceId!==e.fenceId)throw new r("hands_jobs_unavailable","The live Hands fencing identity could not be verified.");return e.generation=l.generation,e.fenceId=l.fenceId,{...e}}function hr(e,l,f){if(f.aborted)return Promise.reject(new r("cancelled","Job control was cancelled."));return new Promise((g,w)=>{let S=ki(e.socketPath),I="",W=!1,x,M=(F,T)=>{if(W)return;if(W=!0,clearTimeout(x),f.removeEventListener("abort",G),S.destroy(),F)w(F);else g(T)},G=()=>M(new r("cancelled","Job control waiter cancelled; inspect before retrying mutations."));f.addEventListener("abort",G,{once:!0}),S.setEncoding("utf8"),x=setTimeout(()=>M(new r("hands_job_result_unknown","Job control timed out; inspect before retrying mutations.")),Math.min(1e4,Math.max(1,e.expiresAtMs-Date.now()))),S.on("error",()=>M(new r("hands_job_result_unknown","Hands job control connection failed."))),S.once("connect",()=>S.write(JSON.stringify({version:1,scopeId:e.scopeId,fenceId:e.fenceId,executorLaunchId:e.executorLaunchId,request:l})+`
|
|
2
|
+
import{zt,j}from"./vm-hands-entry-lite-pf5qtbj5.js";import{ue,Ce,Z,Ae,de,rr,Qe,X,O,H,tn}from"./vm-hands-entry-lite-3krzmhkk.js";import{_o,Vn}from"./vm-hands-entry-lite-aj139v8j.js";import{lo,P,Ke,ve,Je,ne,Ze,Bn,Se,Gt,ae,U,N,ce,Ur,Hr,jn}from"./vm-hands-entry-lite-tdgtpx8e.js";import{Pe,oe,pe,Y,Oe,q,Q}from"./vm-hands-entry-lite-4vks5phw.js";import{It,Sr,st,V,D,R,b}from"./vm-hands-entry-lite-beyyy1gz.js";import{xr,kr,bn,io,ze,vn}from"./vm-hands-entry-lite-s5qkb1fk.js";import{K}from"./vm-hands-entry-lite-hk6trmwa.js";import{Ii}from"./vm-hands-entry-lite-fbhqfzbq.js";import{p,He,Dt,at,Yi,_e,we}from"./vm-hands-entry-lite-s4bharcb.js";import{v,h,oo}from"./vm-hands-entry-lite-wx4ax7wg.js";import{E}from"./vm-hands-entry-lite-dk79tnax.js";import{er}from"./vm-hands-entry-lite-1xwxazmz.js";import{a,ie,Do}from"./vm-hands-entry-lite-jev771b3.js";import{L,Pi,Ti,Bo,y,t,k,xt,o,d,u,i,c,_,ee,s,n}from"./vm-hands-entry-lite-avc65bd7.js";import{Oi}from"./vm-hands-entry-lite-hbs3tpdg.js";import{jo,se,Uo,C,Ne,$e,A}from"./vm-hands-entry-lite-6c67a3jc.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";var li=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function l(w){return e[w]??null}let f={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},g={nan:"NaN"};return(w)=>{switch(w.code){case"invalid_type":{let S=g[w.expected]??w.expected,I=Bo(w.input),W=g[I]??I;return`Invalid input: expected ${S}, received ${W}`}case"invalid_value":if(w.values.length===1)return`Invalid input: expected ${Ti(w.values[0])}`;return`Invalid option: expected one of ${Pi(w.values,"|")}`;case"too_big":{let S=w.inclusive?"<=":"<",I=l(w.origin);if(I)return`Too big: expected ${w.origin??"value"} to have ${S}${w.maximum.toString()} ${I.unit??"elements"}`;return`Too big: expected ${w.origin??"value"} to be ${S}${w.maximum.toString()}`}case"too_small":{let S=w.inclusive?">=":">",I=l(w.origin);if(I)return`Too small: expected ${w.origin} to have ${S}${w.minimum.toString()} ${I.unit}`;return`Too small: expected ${w.origin} to be ${S}${w.minimum.toString()}`}case"invalid_format":{let S=w;if(S.format==="starts_with")return`Invalid string: must start with "${S.prefix}"`;if(S.format==="ends_with")return`Invalid string: must end with "${S.suffix}"`;if(S.format==="includes")return`Invalid string: must include "${S.includes}"`;if(S.format==="regex")return`Invalid string: must match pattern ${S.pattern}`;return`Invalid ${f[S.format]??w.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${w.divisor}`;case"unrecognized_keys":return`Unrecognized key${w.keys.length>1?"s":""}: ${Pi(w.keys,", ")}`;case"invalid_key":return`Invalid key in ${w.origin}`;case"invalid_union":if(w.options&&Array.isArray(w.options)&&w.options.length>0)return`Invalid discriminator value. Expected ${w.options.map((I)=>`'${I}'`).join(" | ")}`;return"Invalid input";case"invalid_element":return`Invalid value in ${w.origin}`;default:return"Invalid input"}}};function En(){return{localeError:li()}}L(En());class _t extends Error{}function Ro(e){let l;try{l=new URL(e)}catch{throw new _t("The proxy must be a URL like https://proxy.example.com:3128.")}if(l.protocol!=="https:"&&l.protocol!=="http:")throw new _t("The proxy URL must use the https or http scheme.");if(!l.hostname)throw new _t("The proxy URL must name a host.");if(l.port!==""&&Number(l.port)<1)throw new _t("The proxy URL must use a port between 1 and 65535.");if(l.pathname!==""&&l.pathname!=="/"||l.search||l.hash)throw new _t("The proxy URL must not carry a path, query, or fragment.");return l.toString()}import{createHash as ui}from"crypto";import{isAbsolute as Oo,join as xo,relative as Po,resolve as Yt,sep as Io}from"path";var qt=t().min(1).refine(Oo,"absolute path required"),On=c({version:n(1),apiOrigin:xt(),channel:s(["staging","production"]),stateDirectory:qt,workspaceRoot:qt,lifetime:s(["persistent","ephemeral"]),executionMode:s(["confined","host"]).default("confined"),name:t().min(1).max(160).default("Reason headless worker"),slots:o().int().min(1).max(4).default(1),shutdownGraceMs:o().int().min(0).max(300000).default(30000),proxy:c({version:n(zt),url:t().refine((e)=>{try{return Ro(e)===e}catch{return!1}},"invalid proxy URL"),caFile:qt.optional()}).optional(),userChrome:d().optional(),cloudSessions:n(!0).optional(),localLogins:d().optional(),folders:u(qt).min(1).max(31).optional()}),fi=/^https:\/\/[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.trycloudflare\.com$/,B=_("channel",[On,On.extend({channel:n("pr"),apiOrigin:t(),prEnvironment:t()}),On.extend({channel:n("local-qa"),apiOrigin:t()})]).superRefine((e,l)=>{if(e.channel==="local-qa"){if(!fi.test(e.apiOrigin))l.addIssue({code:"custom",message:"local QA worker requires an exact HTTPS trycloudflare.com quick-tunnel origin"})}else if(e.channel==="pr"){let g=e.prEnvironment,w=/^https:\/\/([a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)\.up\.railway\.app$/.exec(e.apiOrigin),S=w?.[1]?.match(/(?:^|-)pr-[0-9]+(?=-|$)/g)?.map((I)=>I.replace(/^-/,""));if(!g||/^pr-[1-9][0-9]*$/.exec(g)?.[0]!==g||w?.[0]!==e.apiOrigin||S?.length!==1||S[0]!==g)l.addIssue({code:"custom",message:"PR worker requires explicit prEnvironment and an exact same-PR HTTPS Railway origin"})}else{let g=new URL(e.apiOrigin);if(g.origin!==e.apiOrigin||g.username||g.password||g.protocol!=="https:"&&!(g.protocol==="http:"&&Vn(g.origin))||!Vn(g.origin)&&!_o(e.channel,g.origin))l.addIssue({code:"custom",message:"API origin must match channel (or loopback)"})}if(!je(e.workspaceRoot,e.stateDirectory))l.addIssue({code:"custom",message:"state and workspace must be disjoint"});let f=e.folders??[];if(new Set([e.workspaceRoot,...f]).size!==f.length+1||f.some((g)=>!je(g,e.stateDirectory)))l.addIssue({code:"custom",message:"folders must be distinct and disjoint from state"})});function m(e){return xo(e.stateDirectory,`headless-${e.channel==="pr"?e.prEnvironment:e.channel}`)}function je(e,l){if($r(l,e))return!1;return!$r(e,l)||E(xo(Io,Po(Yt(e),Yt(l))))}function $r(e,l){let f=Po(Yt(e),Yt(l));return f===""||f!==".."&&!f.startsWith(`..${Io}`)&&!Oo(f)}function te(e){let{proxy:l,userChrome:f,cloudSessions:g,localLogins:w,folders:S,...I}=e;return ui("sha256").update(JSON.stringify(I)).digest("hex")}var pi=4,_i=[2375,2376,9222,9229];function dr(e){let l=new Set(_i);for(let f of e){let g=new URL(f);l.add(Number(g.port||(["https:","wss:"].includes(g.protocol)?443:80)))}return l}function Vr(){throw new r("preview_unavailable","The live Hands preview binding is unavailable or stale.")}var mi=60000;function Ao(e){let l=new AbortController,f=new Map,g=(x)=>JSON.stringify([x.jobId,x.port]);function w(x){let M=e.authority.owner;if(l.signal.aborted||!e.isCurrent()||e.expiresAtMs<=Date.now()||x.organization_id!==M.organization_id||x.user_id!==M.user_id||x.device_id!==M.device_id)Vr()}function S(x){let M;try{M=e.environment.current()}catch{return null}return M.binding.target_generation===x.generation&&M.binding.target_fence_id===x.fenceId&&M.run_id===e.runId&&M.device_id===e.authority.owner.device_id&&M.root_id===e.authority.rootId?M:null}async function I(x,M,G){let F=await W(x,M,G);if(F!=="moved")return F;let T=await W(x,M,G);return T==="moved"?null:T}async function W(x,M,G){try{w(e.authority.owner);let F=e.identity();if(!F||G.aborted||x.expiresAtMs<=Date.now()||x.expiresAtMs>e.expiresAtMs)return null;let T=M.opened,re=T!==void 0&&F.generation>T.generation,J=S(F);if(re){if(J){if(J.revision<=T.revision||x.expiresAtMs>Date.parse(J.expires_at)||J.binding.target_revision!==T.attachmentRevision||J.binding.root_grant_revision!==T.grantRevision)return null;M.recoveringSinceMs=void 0}else if(Date.now()-(M.recoveringSinceMs??=Date.now())>mi)return null}else if(!J||x.expiresAtMs>Date.parse(J.expires_at)||T&&(F.generation!==T.generation||F.fenceId!==T.fenceId))return null;let z=await e.inspect(x.jobId,G),fe=e.identity(),ke=fe&&S(fe);w(e.authority.owner);let be=J&&{generation:F.generation,fenceId:F.fenceId,snapshotId:J.snapshot_id,revision:J.revision,attachmentRevision:J.binding.target_revision,grantRevision:J.binding.root_grant_revision},Re=re?T:be;if(G.aborted||!fe)return null;if(fe.generation!==F.generation||fe.fenceId!==F.fenceId||ke?.snapshot_id!==J?.snapshot_id||ke?.revision!==J?.revision)return"moved";let Fe=z.ok&&z.job.environmentSnapshotId!==void 0&&z.job.environmentRevision!==void 0?{snapshotId:z.job.environmentSnapshotId,revision:z.job.environmentRevision}:null;if(!z.ok||z.generation!==F.generation||!Re||!Fe)return null;if((Fe.snapshotId!==Re.snapshotId||Fe.revision!==Re.revision)&&(re||!e.environment.carried(Fe.snapshotId,Fe.revision)))return null;if(!T&&F.generation===x.generation&&F.fenceId===x.fenceId)M.opened={...Re,...Fe};return{executorLaunchId:e.executorLaunchId,job:z.job,binding:{organizationId:e.authority.owner.organization_id,userId:e.authority.owner.user_id,deviceId:e.authority.owner.device_id,rootId:e.authority.rootId,runId:e.runId,attachmentRevision:Re.attachmentRevision,grantRevision:Re.grantRevision,generation:Re.generation,fenceId:Re.fenceId,jobId:z.job.jobId,port:x.port,expiresAtMs:x.expiresAtMs}}}catch{return null}}return{async open(x,M,G){w(M);let{binding:F,deviceRelayUrl:T}=at(x);if(G.aborted||F.expiresAtMs<=Date.now()||F.expiresAtMs>Date.now()+p.lifetimeMs||new URL(T).origin!==e.authority.relayOrigin)Vr();let re=g(F),J=f.get(re);if(J){if(!He(J.binding,F)||J.relay!==T)Vr();if(await J.opened,!await Dt(()=>J.port.check())||G.aborted||J.abort.signal.aborted)Vr();return{opened:!0,binding:F}}if(f.size>=pi)Vr();let z=new AbortController,fe={},ke=we({binding:F,deniedPorts:e.authority.deniedPorts,readCurrentJob:()=>I(F,fe,z.signal)}),be=()=>z.abort();if(G.addEventListener("abort",be,{once:!0}),l.signal.addEventListener("abort",be,{once:!0}),G.aborted||l.signal.aborted)be();let Re=_e({binding:F,deviceRelayUrl:T,port:ke,signal:z.signal}),Fe={binding:F,relay:T,abort:z,port:ke,opened:Re};f.set(re,Fe);let Ye=()=>{if(G.removeEventListener("abort",be),l.signal.removeEventListener("abort",be),f.get(re)===Fe)f.delete(re)};try{if((await Re).closed.then(Ye),G.removeEventListener("abort",be),w(M),z.signal.aborted||!await Dt(()=>ke.check()))Vr();return{opened:!0,binding:F}}catch{z.abort(),Ye(),Vr()}},async close(x,M){w(M);let{binding:G}=Yi(x),F=f.get(g(G));if(!F||!He(F.binding,G))Vr();return F.abort.abort(),await F.opened.then((T)=>T.closed,()=>{return}),{closed:!0,binding:G}},dispose(){l.abort();for(let x of f.values())x.abort.abort();f.clear()}}}import{WebSocket as xn}from"ws";var To=(e)=>("data"in e)?e.data.length:e.bytes,Co=2*Ze;function cr(e){throw new r(e,"The bound Hands terminal is unavailable or its outcome is unconfirmed.")}var mt=(e)=>!["starting","running"].includes(e.state);function Hi(e,l,f=Date.now()){let g=["relay_url","session_id","expires_at","cols","rows","pty","workspace"];if(Object.keys(e).length!==g.length||Object.keys(e).some((M)=>!g.includes(M))||!ae(l)||!ae(e.session_id)||typeof e.expires_at!=="string"||typeof e.relay_url!=="string"||e.relay_url.length>4096||![e.cols,e.rows].every((M)=>Number.isSafeInteger(M)&&Number(M)>=1&&Number(M)<=Se))cr("invalid_pty_request");let w=e.pty;if(!w||typeof w!=="object"||Array.isArray(w))cr("invalid_pty_request");let S=w;if(Object.keys(S).length!==2||S.version!==1||!ce(S.jobId))cr("invalid_pty_request");let I;try{I=new URL(e.relay_url)}catch{return cr("invalid_pty_request")}if(!["ws:","wss:"].includes(I.protocol)||I.username||I.password||I.hash||I.protocol==="ws:"&&!["127.0.0.1","[::1]","localhost"].includes(I.hostname))cr("invalid_pty_request");let W=Date.parse(e.expires_at);if(!Number.isSafeInteger(W)||W<=f)cr("invalid_pty_request");return{workspace:H(e.workspace)??cr("invalid_pty_request"),session:{jobId:S.jobId,sessionId:e.session_id,operationId:l,relayUrl:I.href,cols:Number(e.cols),rows:Number(e.rows),leaseExpiresAtMs:Math.min(W,f+43200000)}}}async function Ho(e){let{session:l,binding:f}=e;if(f.assertCurrent(),e.signal.aborted||Date.now()>=l.leaseExpiresAtMs)cr("cancelled");let g=new xn(l.relayUrl,{followRedirects:!1,perMessageDeflate:!1,maxPayload:ne}),w=new AbortController,S=()=>{},I=()=>{w.abort(),S()};e.signal.addEventListener("abort",I,{once:!0});let W=setTimeout(I,Math.max(1,l.leaseExpiresAtMs-Date.now())),x=[],M=0,G=0,F=0,T=!1,re=!1,J=!1,z,fe,ke,be=(le)=>{ke=new r(le,"Bound terminal input was refused."),I()};g.on("error",()=>be("pty_relay_unavailable")),g.on("close",I),g.on("message",(le,he)=>{if(w.signal.aborted)return;if(!re){be("pty_not_ready");return}let xe=Array.isArray(le)?Buffer.concat(le):le instanceof ArrayBuffer?Buffer.from(le):le;if(xe.length===0)return;let Ge=x.at(-1),Le=he&&Ge!==void 0&&"data"in Ge&&Ge.data.length+xe.length<=ne;if(xe.length>ne||M+xe.length>Bn){be("pty_input_backpressure");return}if(Le)Ge.data=Buffer.concat([Ge.data,xe]);else if(he)x.push({data:Buffer.from(xe)});else try{let Be=JSON.parse(xe.toString("utf8"));if(Be&&Be.t==="close"&&Object.keys(Be).length===1){J=!0,I();return}if(!Be||Be.t!=="resize"||Object.keys(Be).length!==3||![Be.cols,Be.rows].every((Ee)=>Number.isSafeInteger(Ee)&&Ee>=1&&Ee<=Se))throw Error("invalid_control");x.push({cols:Be.cols,rows:Be.rows,bytes:xe.length})}catch{be("invalid_pty_control");return}M+=xe.length,S()});function Re(le){return jn(JSON.stringify({...f.scope,version:1,sessionId:l.sessionId,operationId:l.operationId,job:{...le,output:[],pty:le.pty?{...le.pty,output:[]}:void 0}}))}function Fe(le){if(!le.ok)cr(le.error);let he=le.job;if(le.generation!==f.scope.generation||he.jobId!==l.jobId||!he.pty||he.leaseExpiresAtMs>l.leaseExpiresAtMs||he.process&&he.process.executorLaunchId!==f.scope.executorLaunchId||he.process&&fe&&(he.process.pid!==fe.pid||he.process.processGroupId!==fe.processGroupId)||he.state!=="starting"&&(he.environmentRevision!==f.environment.revision||he.environmentSnapshotId!==f.environment.snapshotId))cr("pty_binding_changed");if(Re(he),he.process)fe??={...he.process};return he}async function Ye(le){f.assertCurrent();let he=await f.request(le,w.signal);if(f.assertCurrent(),w.signal.aborted)cr("cancelled");let xe=Fe(he);if(xe.inputSequence!==G)cr("job_input_sequence");if(!mt(xe)&&xe.leaseExpiresAtMs<=Date.now())cr("pty_binding_changed");return xe}function ye(le){if(f.assertCurrent(),w.signal.aborted||g.readyState!==xn.OPEN||g.bufferedAmount+Buffer.byteLength(le)>Co)cr("pty_output_backpressure");g.send(le)}function We(le){if(le.firstCursor>F+1)F=le.firstCursor-1;for(let he of le.pty.output){if(he.cursor<=F)continue;if(he.cursor!==F+1)cr("pty_output_gap");let xe=Buffer.from(he.dataBase64,"base64");if(g.bufferedAmount+xe.length>Co)return!1;ye(xe),F=he.cursor}if(F!==le.nextCursor)cr("pty_output_gap");return!0}async function qe(le,he){let xe;try{await Promise.race([e.emit(le,he),new Promise((Ge,Le)=>{xe=setTimeout(()=>Le(new r("pty_event_unavailable","Terminal metadata delivery timed out.")),2000)})])}finally{clearTimeout(xe)}}async function Te(){let le=AbortSignal.timeout(Gt),he=f.request({jobId:l.jobId,action:"cancel",input:{}},le),xe,Ge=new Promise((Le,Be)=>{if(xe=()=>Be(new r("pty_cleanup_unconfirmed","Terminal cleanup acknowledgement was not observed within authority.")),le.addEventListener("abort",xe,{once:!0}),le.aborted)xe()});try{let Le=await Promise.race([he,Ge]);if(le.aborted)cr("pty_cleanup_unconfirmed");return Fe(Le)}finally{le.removeEventListener("abort",xe)}}try{await new Promise((Le,Be)=>{let Ee=setTimeout(()=>{I(),Be(new r("pty_relay_unavailable","Terminal pairing timed out."))},5000),Me=()=>{clearTimeout(Ee),Be(new r("cancelled","Terminal pairing was cancelled."))};if(w.signal.addEventListener("abort",Me,{once:!0}),g.once("open",()=>{clearTimeout(Ee),w.signal.removeEventListener("abort",Me),Le()}),w.signal.aborted)Me()}),f.assertCurrent(),T=!0,z=await Ye({jobId:l.jobId,action:"start",input:{mode:"pty",cols:l.cols,rows:l.rows,leaseExpiresAtMs:l.leaseExpiresAtMs}});let le=Date.now()+5000;while(z.state==="starting"){if(Date.now()>=le)cr("pty_not_ready");await new Promise((Le)=>setTimeout(Le,25)),z=await Ye({jobId:l.jobId,action:"inspect",input:{after:F}})}if(z.state!=="running"||z.inputSequence!==0||z.leaseExpiresAtMs<=Date.now())cr("pty_not_ready");await qe("pty.ready",Re(z)),re=!0,ye(JSON.stringify({t:"open",cols:z.pty.cols,rows:z.pty.rows,receipt:Re(z)}));let he=!1,xe=0,Ge=!1;while(!w.signal.aborted){let Le=z.firstCursor>F+1,Be=We(z);if(mt(z)){if(Be)break}else if(Le)he=!0;else if(he&&Be&&Date.now()>=xe){he=!1,xe=Date.now()+1000;let{cols:Me,rows:or}=z.pty;for(let sr of[{cols:Me,rows:or>1?or-1:2},{cols:Me,rows:or}]){if(mt(z))break;let Ir=++G;if(z=await Ye({jobId:l.jobId,action:"resize",input:{sequence:Ir,...sr}}),z.inputSequence!==Ir)cr("job_input_sequence")}continue}let Ee=mt(z)||Ge?void 0:x.shift();if(Ee){M-=To(Ee);let Me=++G;try{z=await Ye("data"in Ee?{jobId:l.jobId,action:"input",input:{sequence:Me,dataBase64:Ee.data.toString("base64")}}:{jobId:l.jobId,action:"resize",input:{sequence:Me,cols:Ee.cols,rows:Ee.rows}})}catch(or){if(!(or instanceof r)||or.code!=="job_input_backpressure")throw or;G-=1,x.unshift(Ee),M+=To(Ee),Ge=!0;continue}if(z.inputSequence!==Me)cr("job_input_sequence")}else if(await new Promise((Me)=>{let or=setTimeout(Me,Ge||!Be?10:50);if(S=()=>{clearTimeout(or),Me()},w.signal.aborted||!Ge&&x.length)S()}),Ge=!1,S=()=>{},!w.signal.aborted&&Be)try{z=await Ye({jobId:l.jobId,action:"inspect",input:{after:F}})}catch(Me){if(!J||!(Me instanceof r)||Me.code!=="cancelled")throw Me}}}catch(le){ke??=le}finally{if(re=!1,x.length=0,clearTimeout(W),e.signal.removeEventListener("abort",I),I(),T&&(!z||!mt(z)))try{z=await Te()}catch{z=void 0}try{if(!z||!mt(z)||z.pty?.cleanup!=="confirmed")cr("pty_cleanup_unconfirmed");let le=Re(z);if(g.readyState===xn.OPEN)await new Promise((he)=>{let xe=setTimeout(he,500);g.send(JSON.stringify({t:"exit",code:z.exitCode,receipt:le}),()=>{clearTimeout(xe),he()})});await qe("pty.stopped",le)}catch(le){ke??=le}g.terminate()}if(ke)throw ke;if(e.signal.aborted)cr("cancelled");if(!z)cr("pty_cleanup_unconfirmed");return{receipt:Re(z)}}import{createHash as hi,randomUUID as An}from"crypto";import{spawnSync as Wo}from"child_process";import{closeSync as No,constants as Pn,fstatSync as gi,fsyncSync as bi,lstatSync as Bt,mkdirSync as wi,mkdtempSync as Fo,openSync as Lo,readFileSync as yi,readdirSync as zo,realpathSync as Lt,rmSync as In,unlinkSync as vi}from"fs";import{createConnection as ki}from"net";import{dirname as Si,join as nt,sep as Ei}from"path";import{tmpdir as Ri}from"os";var Pr=new Map,qr=new Map;function Kr(e,l){return hi("sha256").update(JSON.stringify([e,l])).digest("hex")}function ht(e){try{wi(e,{mode:448})}catch(f){if(!(f instanceof Error&&("code"in f)&&f.code==="EEXIST"))throw f}let l=Bt(e);if(!l.isDirectory()||l.isSymbolicLink()||!A(l)||Lt(e)!==e)throw new r("hands_jobs_unavailable","Hands job state must be a private canonical directory.")}function xi(e){let l;try{l=Bt(e)}catch(f){if(f instanceof Error&&"code"in f&&f.code==="ENOENT")return!1;throw f}return!l.isDirectory()||l.isSymbolicLink()||zo(e).length>0}function pr(e){let l=Kr(e.root,e.runId),f=e.previousRuntimeDirectories?.find((I)=>xi(nt(I,"jobs",l.slice(0,16))))??e.runtimeDirectory;ht(f);let g=nt(f,"jobs");ht(g);let w=nt(g,l.slice(0,16));if(e.maxScopes!==void 0){let I=zo(g);if(!Number.isSafeInteger(e.maxScopes)||e.maxScopes<1||I.length>e.maxScopes||!I.includes(l.slice(0,16))&&I.length>=e.maxScopes)throw new r("process_journal_capacity","Managed process receipt capacity is full; preserve uncertain jobs and reconcile their existing receipts before starting more work.")}ht(w);let S=Fo(nt(Uo(),"reason-j-"));try{return ht(S),{journalDirectory:w,scopeId:l,launchDirectory:S,socketPath:process.platform==="win32"?`\\\\.\\pipe\\reason-jobs-${An()}`:nt(S,"control.sock"),disposeSocket:()=>In(S,{recursive:!0,force:!0})}}catch(I){throw In(S,{recursive:!0,force:!0}),I}}var Ai=60000,Di=5000;function Ci(e){if(process.platform==="win32")return Ni(e);let l=Wo("ps",["-o","lstart=","-p",String(e)],{encoding:"utf8",timeout:2000,env:{...process.env,LC_ALL:"C",LANG:"C"}}),f=l.status===0?/^\w{3} (\w{3}) +(\d{1,2}) (\d{2}):(\d{2}):(\d{2}) (\d{4})$/.exec(l.stdout.trim()):null,g=f?"JanFebMarAprMayJunJulAugSepOctNovDec".indexOf(f[1]):-1;if(!f||g<0||g%3!==0)return null;let w=new Date(Number(f[6]),g/3,Number(f[2]),Number(f[3]),Number(f[4]),Number(f[5])).getTime();return Number.isFinite(w)?w:null}function Ni(e){let l=Wo(C("powershell"),["-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${e}).StartTime.ToUniversalTime().ToString('o')`],{encoding:"utf8",timeout:5000,windowsHide:!0,env:Ne()}),f=l.status===0?Date.parse(l.stdout.trim()):Number.NaN;return Number.isFinite(f)?f:null}function $o(e,l={}){let f=nt(e.journalDirectory,"owner.lock"),g;try{g=Lo(f,Pn.O_RDONLY|Pn.O_NOFOLLOW)}catch{return null}try{let w=gi(g);if(!w.isFile()||w.nlink!==1||!A(w)||w.size>4096)return null;let S=null;try{S=JSON.parse(yi(g,"utf8"))}catch{}let I;if(S===null){if((l.now??Date.now)()-w.mtimeMs<Ai)return null;I={reason:"never_written",executorLaunchId:null}}else{let{version:M,scopeId:G,pid:F,createdAtMs:T,executorLaunchId:re}=S;if(M!==1||G!==e.scopeId||typeof re!=="string"||typeof F!=="number"||!Number.isSafeInteger(F)||F<1||F===process.pid||typeof T!=="number"||!Number.isSafeInteger(T))return null;if(!(l.exists??((z)=>{try{return process.kill(z,0),!0}catch(fe){return!(fe instanceof Error&&("code"in fe)&&fe.code==="ESRCH")}}))(F))I={reason:"owner_exited",executorLaunchId:re};else{let z=(l.startedAtMs??Ci)(F);if(z===null||z<=T+Di)return null;I={reason:"pid_reused",executorLaunchId:re}}}let W=Bt(f);if(W.dev!==w.dev||W.ino!==w.ino)return null;vi(f);let x=Lo(e.journalDirectory,Pn.O_RDONLY);try{bi(x)}finally{No(x)}return I}catch{return null}finally{No(g)}}function Ko(e){let l={...e,workspace:e.workspace&&Object.freeze({...e.workspace}),previewAuthority:e.previewAuthority&&Object.freeze({...e.previewAuthority,owner:Object.freeze({...e.previewAuthority.owner}),deniedPorts:new Set(e.previewAuthority.deniedPorts)})},f=Kr(l.root,l.runId);if(Pr.has(f)||l.operationId!==void 0&&qr.has(l.operationId))throw new r("hands_jobs_busy","The Session already has a live Hands job supervisor.");let g={binding:l,key:f,terminals:new Map};if(l.previewAuthority&&l.environment)g.previews=Ao({authority:l.previewAuthority,runId:l.runId,expiresAtMs:l.expiresAtMs,executorLaunchId:l.executorLaunchId,environment:l.environment,isCurrent:()=>Pr.get(g.key)===g,identity:()=>{try{return gt(l)}catch{return null}},inspect:(w,S)=>{if(Pr.get(g.key)!==g)throw new r("preview_unavailable","The Hands supervisor is no longer current.");return Go(l,{jobId:w,action:"inspect",input:{after:0}},S)}});if(Pr.set(f,g),l.operationId!==void 0)qr.set(l.operationId,g);return()=>{if(Pr.get(g.key)===g)Pr.delete(g.key);if(l.operationId!==void 0&&qr.get(l.operationId)===g)qr.delete(l.operationId);g.previews?.dispose();for(let w of g.terminals.values())w.abort()}}var Li=5000,Bi=20;async function zi(e){let l=(w)=>{throw new r("hands_rebind_unavailable",w)};if(!N(e.operationId)||!N(e.runId)||!N(e.fenceId)||!U(e.targetGeneration))l("Reason sent an invalid Hands rebind.");let f=qr.get(e.operationId);if(!f||f.binding.root!==e.root)return l("No live Hands supervisor owns this operation.");for(let w=Date.now()+Li;;){if(e.signal?.aborted)l("The Hands rebind was cancelled.");if(qr.get(e.operationId)!==f)l("The Hands supervisor is no longer current.");let S=null;try{S=gt(f.binding)}catch{}if(S&&S.generation===e.targetGeneration&&S.fenceId===e.fenceId)break;if(S&&S.generation>e.targetGeneration||Date.now()>=w)l("The executor did not adopt this take.");await new Promise((I)=>setTimeout(I,Bi))}if(qr.get(e.operationId)!==f||Pr.get(f.key)!==f)l("The Hands supervisor is no longer current.");let g=Kr(e.root,e.runId);if(f.key===g)return;if(Pr.has(g))l("The taking run already has a live Hands job supervisor.");Pr.delete(f.key);for(let w of f.terminals.values())w.abort();f.key=g,Pr.set(g,f)}function it(e){let l="operationId"in e?qr.get(e.operationId):Pr.get(Kr(e.root,e.runId)),f=l&&l.binding.root===e.root?l.binding:void 0;if(!f?.environment||f.expiresAtMs<=Date.now())throw new r("environment_unavailable","No live Hands supervisor owns this environment.");return f.environment.install(e.payload)}async function qi(e){let l=Pr.get(Kr(e.root,e.runId));if(!l?.previews||!e.owner)throw new r("preview_unavailable","No authenticated Hands supervisor owns this preview.");return l.previews.open(e.payload,e.owner,e.signal)}async function Wi(e){let l=Pr.get(Kr(e.root,e.runId));if(!l?.previews||!e.owner||e.signal.aborted)throw new r("preview_unavailable","No authenticated Hands supervisor owns this preview.");return l.previews.close(e.payload,e.owner)}async function Vi(e){let l=Kr(e.root,e.runId),f=Pr.get(l),g=f?.binding,w=g?.runId,S=g?.previewAuthority,I=g?.environment,W=e.owner&&{...e.owner},x=e.authority&&{...e.authority},M=()=>{throw new r("pty_binding_unavailable","No current authenticated Hands scope owns this terminal.")};if(!f||!g||!S||!I||!W||!x||!g.workspace)return M();let G=Object.freeze({...g.workspace}),F=gt(g),T=I.current(),re=()=>{if(Pr.get(l)!==f||W.organization_id!==S.owner.organization_id||W.user_id!==S.owner.user_id||W.device_id!==S.owner.device_id||e.deviceId!==S.owner.device_id||e.rootId!==S.rootId||O(e.workspace)!==O(G))M();let z=gt(g),fe=I.current();if(z.generation!==F.generation||z.fenceId!==F.fenceId||fe.run_id!==w||fe.device_id!==e.deviceId||fe.root_id!==e.rootId||fe.snapshot_id!==T.snapshot_id||fe.revision!==T.revision||fe.binding.target_generation!==F.generation||fe.binding.target_fence_id!==F.fenceId||x.device_id!==e.deviceId||x.binding!==fe.binding.kind||x.target_revision!==fe.binding.target_revision||x.root_grant_revision!==fe.binding.root_grant_revision||x.target_generation!==F.generation||x.target_fence_id!==F.fenceId)M()};if(re(),new URL(e.session.relayUrl).origin!==S.relayOrigin||f.terminals.has(e.session.jobId)||f.terminals.size>=4)return M();let J=new AbortController;f.terminals.set(e.session.jobId,J);try{return await Ho({session:{...e.session,leaseExpiresAtMs:Math.min(e.session.leaseExpiresAtMs,F.expiresAtMs,Date.parse(T.expires_at))},signal:AbortSignal.any([e.signal,J.signal]),emit:e.emit,binding:{assertCurrent:re,environment:{revision:T.revision,snapshotId:T.snapshot_id},scope:{runId:e.runId,deviceId:e.deviceId,rootId:e.rootId,workspace:G,binding:T.binding.kind,targetRevision:T.binding.target_revision,rootGrantRevision:T.binding.root_grant_revision,generation:F.generation,fenceId:F.fenceId,executorLaunchId:F.executorLaunchId},request:(z,fe)=>hr(F,Ur(JSON.stringify({...z,type:"job",version:2,generation:F.generation,id:An()})),fe)}})}finally{if(f.terminals.get(e.session.jobId)===J)f.terminals.delete(e.session.jobId)}}async function Gi(e){if(ce(e.payload.jobId))throw new r("pty_binding_required","PTY jobs require the bound terminal capability.");let l=Pr.get(Kr(e.root,e.runId))?.binding;if(!l||l.expiresAtMs<=Date.now())throw new r("hands_jobs_unavailable","No live Hands supervisor owns this Session and root.");return Go(l,e.payload,e.signal)}var ji=1e4,Mi=20,Fi=ve/2,Ui=Ke/2,$i=(e)=>e.output.reduce((l,f)=>l+f.text.length,0);async function Go(e,l,f){if(Object.keys(l).some((M)=>!["jobId","action","input","waitForExitMs"].includes(M)))throw new r("invalid_payload","Unexpected job control field.");let{waitForExitMs:g,...w}=l;if(g!==void 0&&(w.action!=="start"||typeof w.input!=="object"||w.input===null||!("script"in w.input)||typeof g!=="number"||!Number.isSafeInteger(g)||g<1||g>ji))throw new r("invalid_payload","Only a script start may wait for its job, within its bound.");let S=(M)=>{let G=gt(e);return hr(G,Ur(JSON.stringify({...M,type:"job",version:2,generation:G.generation,id:An()})),f)},I=await S(w);if(g===void 0)return I;let W=Date.now()+g,x=I;while(x.ok&&["starting","running"].includes(x.job.state)&&x.job.output.length<Fi&&$i(x.job)<Ui&&!f.aborted&&Date.now()<W){if(await new Promise((M)=>setTimeout(M,Math.min(Mi,W-Date.now()))),f.aborted)break;try{let M=await S({jobId:w.jobId,action:"inspect",input:{after:0}});if(!M.ok)break;x=M}catch{break}}return x}function gt(e){if(e.expiresAtMs<=Date.now())throw new r("hands_jobs_unavailable","Hands authority expired.");let l=e.readIdentity?e.readIdentity():e;if(!l||!U(l.generation)||!N(l.fenceId)||l.generation<e.generation||l.generation===e.generation&&l.fenceId!==e.fenceId)throw new r("hands_jobs_unavailable","The live Hands fencing identity could not be verified.");return e.generation=l.generation,e.fenceId=l.fenceId,{...e}}function hr(e,l,f){if(f.aborted)return Promise.reject(new r("cancelled","Job control was cancelled."));return new Promise((g,w)=>{let S=ki(e.socketPath),I="",W=!1,x,M=(F,T)=>{if(W)return;if(W=!0,clearTimeout(x),f.removeEventListener("abort",G),S.destroy(),F)w(F);else g(T)},G=()=>M(new r("cancelled","Job control waiter cancelled; inspect before retrying mutations."));f.addEventListener("abort",G,{once:!0}),S.setEncoding("utf8"),x=setTimeout(()=>M(new r("hands_job_result_unknown","Job control timed out; inspect before retrying mutations.")),Math.min(1e4,Math.max(1,e.expiresAtMs-Date.now()))),S.on("error",()=>M(new r("hands_job_result_unknown","Hands job control connection failed."))),S.once("connect",()=>S.write(JSON.stringify({version:1,scopeId:e.scopeId,fenceId:e.fenceId,executorLaunchId:e.executorLaunchId,request:l})+`
|
|
3
3
|
`)),S.on("data",(F)=>{if(I+=F,Buffer.byteLength(I)>Je)M(new r("hands_job_result_unknown","Hands job result exceeded its bound."))}),S.once("end",()=>{if(Date.now()>=e.expiresAtMs){M(new r("hands_job_result_unknown","Hands authority expired before the result was acknowledged."));return}try{let F=Hr(I.trim());if(F.id!==l.id||F.generation!==e.generation||F.ok&&F.job.jobId!==l.jobId)throw Error("identity");M(void 0,F)}catch{M(new r("hands_job_result_unknown","Hands job response identity or shape was invalid."))}}),S.once("close",()=>{if(!W)M(new r("hands_job_result_unknown","Hands job control closed before an acknowledged result."))})})}function Mo(e){let l=Lt(e.root),f=e.authority,g=Date.parse(e.leaseUntil),w=()=>{if(e.signal.throwIfAborted(),!Number.isFinite(g)||g<=Date.now())throw Error("local_device_gh_lease_expired")};if(w(),f.readOnly&&f.generation===null)return{root:l,readOnly:!0,signal:e.signal,deadlineMs:g,assertCurrent:w};let S=Kr(l,e.runId),I=Pr.get(S),W=I?.binding;if(!W?.environment||!W.workspace||W.localGithubConfinement!==!0)throw Error("local_device_gh_confinement_unavailable");let x=W.environment.current(),M=()=>{w();let F=W.environment.current(),T=gt(W);if(Pr.get(S)!==I||F.github_auth!=="local_gh"||F.run_id!==W.runId||f.runId!==e.runId||F.device_id!==f.deviceId||F.root_id!==f.rootId||String(F.binding.root_grant_revision)!==f.rootRevision||F.binding.target_generation!==f.generation||F.binding.target_fence_id!==f.fenceId||T.generation!==f.generation||T.fenceId!==f.fenceId||F.snapshot_id!==x.snapshot_id||F.revision!==x.revision)throw Error("local_device_gh_authority_changed")};M();let G=ie(l,W.workspace);return{root:G.boundary,signal:e.signal,deadlineMs:g,privateDirectory:Si(W.environment.path),repoPath:G.path,readOnly:f.readOnly,forbiddenSecretValues:Object.values(x.variables),secretNames:(F)=>Object.entries(x.variables).filter(([,T])=>T.trim()===F.trim()).map(([T])=>`variable ${T}`),assertCurrent:M}}async function Ki(e,l){let f=Pe.parse(e.request),g=oe.parse(e.authority);if(g.contributorRefresh&&f.kind==="read"&&g.readOnly)return l(Mo(e));let w=Boolean(g.contributorRefresh);if(w&&(g.merge||f.kind!=="pr_mutation"||f.mutation.action!=="edit"||typeof f.mutation.body!=="string"||f.mutation.title!==void 0||f.mutation.base!==void 0||g.readOnly||g.runId!==e.runId||g.repoFullName!==f.repoFullName))throw Error("local_device_gh_contributor_refresh_authority_invalid");if(f.kind!=="pr_merge"&&!w){if(g.merge)throw Error("local_device_gh_merge_authority_invalid");return l(Mo(e))}if(!w&&(!g.merge||g.readOnly||g.runId!==e.runId||g.repoFullName!==f.repoFullName||g.merge.source==="agent"&&(g.generation===null||g.fenceId===null)))throw Error("local_device_gh_merge_authority_invalid");let S=Lt(e.root),I=Bt(S),W=Date.parse(e.leaseUntil);if(!Number.isFinite(W)||W<=Date.now())throw Error("local_device_gh_lease_expired");let x=Lt(Ri());if(x===S||x.startsWith(S+Ei))throw Error("local_device_gh_private_scope_unavailable");let M=Fo(nt(x,"reason-gh-merge-"));try{ht(M);let G=()=>{if(e.signal.throwIfAborted(),Date.now()>=W)throw Error("local_device_gh_lease_expired");let F=Bt(e.root);if(F.isSymbolicLink()||F.dev!==I.dev||F.ino!==I.ino||Lt(e.root)!==S)throw Error("local_device_gh_authority_changed");ht(M)};return G(),await l({root:S,readOnly:!1,privateDirectory:M,forbiddenSecretValues:[],signal:e.signal,deadlineMs:W,assertCurrent:G})}finally{In(M,{recursive:!0,force:!0})}}var qo=43200000;function bt(e){return Number.isSafeInteger(e)&&Math.abs(e)<=8640000000000000?e:null}function Jo(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function Vo(e,l){return Object.keys(e).length===l.length&&l.every((f)=>Object.hasOwn(e,f))}function Ji(e){if(!Jo(e)||!Vo(e,["version","outcome","clock_source","validation_now_ms","expiry_ms","remaining_ms","maximum_lifetime_ms","cli_artifact"])||e.version!==1||e.maximum_lifetime_ms!==43200000||typeof e.outcome!=="string"||!["accepted","parse","noncanonical","expired","over_cap"].includes(e.outcome)||typeof e.clock_source!=="string"||!["date_now","injected"].includes(e.clock_source))return null;for(let g of["validation_now_ms","expiry_ms"]){let w=e[g];if(w!==null&&(typeof w!=="number"||bt(w)===null))return null}if(e.remaining_ms!==null&&(typeof e.remaining_ms!=="number"||!Number.isSafeInteger(e.remaining_ms)))return null;let l=typeof e.expiry_ms==="number"&&typeof e.validation_now_ms==="number"?e.expiry_ms-e.validation_now_ms:null;if(e.remaining_ms!==(l!==null&&Number.isSafeInteger(l)?l:null))return null;if(e.outcome==="parse"&&e.expiry_ms!==null)return null;if(e.outcome!=="parse"&&e.expiry_ms===null)return null;if(e.outcome==="expired"&&!(typeof l==="number"&&l<=0))return null;if(e.outcome==="over_cap"&&!(typeof l==="number"&&l>43200000))return null;if(e.outcome==="accepted"&&!(typeof l==="number"&&l>0&&l<=43200000))return null;let f=e.cli_artifact;if(!Jo(f)||!Vo(f,["kind","status","sha256","observed_at_ms"])||f.observed_at_ms!==null&&(typeof f.observed_at_ms!=="number"||bt(f.observed_at_ms)===null))return null;if(f.kind==="entrypoint_file"){if(f.status!=="observed"||typeof f.sha256!=="string"||!/^[a-f0-9]{64}$/.test(f.sha256)||f.observed_at_ms===null)return null}else if(f.kind!=="unavailable"||f.sha256!==null||typeof f.status!=="string"||!["unsupported_entrypoint","read_failed","file_changed","size_limit","time_limit"].includes(f.status))return null;return e}var Tn=c({kind:s(["workspace_source","mcp_control"]),target_revision:o().int().nonnegative(),root_grant_revision:o().int().positive()}),Yo=new RegExp(st.tokenPattern),Qi=c({token_url:xt().max(2048),request_token:t().min(1).max(8192).regex(Yo),aws_credentials_url:xt().max(2048).nullable()});function Xo(e,l){let f=(g,w)=>{try{let S=new URL(g);return S.origin===new URL(l).origin&&S.pathname===w&&!S.username&&!S.password&&!S.search&&!S.hash}catch{return!1}};if(!Yo.test(e.request_token)||!f(e.token_url,st.tokenPath)||e.aws_credentials_url!==null&&!f(e.aws_credentials_url,st.awsPath))return null;return{REASON_OIDC_TOKEN_URL:e.token_url,REASON_OIDC_REQUEST_TOKEN:e.request_token,...e.aws_credentials_url!==null?{AWS_CONTAINER_CREDENTIALS_FULL_URI:e.aws_credentials_url,AWS_CONTAINER_AUTHORIZATION_TOKEN:e.request_token}:{}}}function Zo(e){return new TextEncoder().encode(e).byteLength}function ea(e){return Zo(JSON.stringify(e)+`
|
|
4
4
|
`)}var fr=c({version:n(1),snapshot_id:k(),revision:o().int().positive(),run_id:t().min(1).max(160),device_id:k(),root_id:k(),binding:Tn.extend({target_generation:o().int().positive(),target_fence_id:k()}),expires_at:y.datetime({offset:!0}),variables:ee(t().max(128).regex(It),t().refine((e)=>!e.includes("\x00")&&Zo(e)<=V.valueBytes)).refine((e)=>Object.keys(e).length<=V.variables),github_auth:n("local_gh").optional(),git:c({base_url:xt().max(2048),token:t().min(1).max(4096).regex(/^[A-Za-z0-9._~-]+$/),expires_at:y.datetime({offset:!0})}).nullable(),cloud_access:Qi.optional()}).refine((e)=>e.github_auth!=="local_gh"||e.git===null,"conflicting git authority").refine((e)=>ea(e)<=V.snapshotBytes,"snapshot too large");import{spawn as ra}from"child_process";import{basename as ta,isAbsolute as Eu}from"path";var na=0,Qo=120000,es=15000,oa=65536;function Dn(e=process.execPath,l=process.argv[1]){let f=ta(e),g=(f.startsWith("bun")||f.startsWith("node"))&&typeof l==="string"&&l.length>0;return{command:e,prefix:g?[l]:[]}}function Zi(e={}){let{command:l,prefix:f}=Dn(e.executablePath,e.sourceEntrypoint),g=e.spawnProcess??ra,w=e.now??Date.now,S=null,I=0,W=!1,x=(G)=>{try{G.kill("SIGKILL")}catch{}},M=()=>{if(W)return;if(S&&w()-I<Qo-es)return;if(S){let F=S;S=null,x(F)}let G;try{G=g(l,[...f,"__device","__hands-worker","--handoff-fd",String(na)],{cwd:"/",env:{PATH:process.env.PATH??"/usr/local/bin:/usr/bin:/bin"},shell:!1,stdio:["pipe","ignore","pipe"]})}catch{return}S=G,I=w(),G.on("error",()=>{if(S===G)S=null}),G.once("exit",(F,T)=>{if(S!==G)return;S=null,e.log?.("hands.worker_prespawn_exited",{exit_code:F,exit_signal:T})}),e.log?.("hands.worker_prespawned",{pid:G.pid??null})};return{arm:M,take(G){let F=S;if(!F||W)return null;let T=G.args.at(-1),re=G.options.env,J=G.options.cwd,z=[...f,"__device","__hands-worker","--config"];if(G.command!==l||G.args.length!==z.length+1||z.some((Re,Fe)=>G.args[Fe]!==Re)||typeof T!=="string"||!re||typeof J!=="string"||G.options.shell||JSON.stringify(G.options.stdio)!==JSON.stringify(["ignore","ignore","pipe"]))return null;S=null;let fe=F.stdin,ke={configPath:T,cwd:J,env:Object.fromEntries(Object.entries(re).filter((Re)=>typeof Re[1]==="string"))},be=JSON.stringify(ke);if(F.exitCode!==null||F.signalCode!==null||!fe||fe.destroyed||w()-I>=Qo-es||Buffer.byteLength(be,"utf8")>oa)return x(F),null;return fe.on("error",()=>{return}),fe.end(be),F.once("exit",()=>{M()}),e.log?.("hands.worker_prespawn_taken",{pid:F.pid??null}),F},adopt(G){G.once("exit",()=>{M()})},close(){if(W=!0,S)x(S);S=null}}}import{accessSync as la,constants as ua,statSync as fa}from"fs";import{homedir as pa,tmpdir as _a,userInfo as ma}from"os";import{delimiter as ha,win32 as ga}from"path";var sa=new Set(["ALL_PROXY","BUN_BE_BUN","BUN_OPTIONS","CURL_CA_BUNDLE","GIT_SSL_CAINFO","GRPC_DEFAULT_SSL_ROOTS_FILE_PATH","HTTPS_PROXY","HTTP_PROXY","NO_PROXY","NODE_EXTRA_CA_CERTS","NODE_OPTIONS","NODE_TLS_REJECT_UNAUTHORIZED","REQUESTS_CA_BUNDLE","SSLKEYLOGFILE","SSL_CERT_DIR","SSL_CERT_FILE","all_proxy","http_proxy","https_proxy","no_proxy"]);var ia=["BUN_CONFIG_","BUN_INSPECT","DYLD_","NODE_DEBUG"],aa=new Set(["BUN_INSTALL"]);var ca=/^--(?:max-old-space-size|max-semi-space-size|stack-size)=\d{1,9}$/;function da(e){return(e??"").split(/\s+/).filter(Boolean).every((l)=>ca.test(l.replaceAll("_","-")))}function rs(e){return Object.keys(e).filter((l)=>sa.has(l)&&!(l==="NODE_OPTIONS"&&da(e[l]))||ia.some((f)=>l.startsWith(f))||l.startsWith("BUN_")&&!aa.has(l)).sort()}var ba=new Set(["HOME","PATH","PWD","OLDPWD","SHLVL","_","TMPDIR","TMP","TEMP","SHELL","BASH_ENV","ENV","ZDOTDIR","PROMPT_COMMAND","IFS","CDPATH","GLOBIGNORE","SHELLOPTS","BASHOPTS","NODE_PATH"]),wa=/^(?:ARA_|REASON_|PI_|GIT_|GH_|GITHUB_|LD_|DYLD_|BUN_|BASH_FUNC_|SSH_)/,ya=/TOKEN|SECRET|PASSW|PASSPHRASE|CREDENTIAL|API_?KEY|ACCESS_?KEY|PRIVATE_?KEY|AUTH/i,va=/^[A-Za-z_][A-Za-z0-9_]*$/;function mr(e=process.env){let l=(w)=>{if(!(process.platform==="win32"?ga.isAbsolute(w):w.startsWith("/"))||/[\0\r\n]/.test(w)||w.length>32768)throw Error("invalid_host_execution_environment");return w};if(e.PATH!==void 0&&(/[\0\r\n]/.test(e.PATH)||e.PATH.length>32768))throw Error("invalid_host_execution_environment");let f=new Set(rs(e)),g=Object.fromEntries(Object.entries(e).filter((w)=>{let[S,I]=w;return typeof I==="string"&&I.length<=32768&&!I.includes("\x00")&&S.length<=128&&va.test(S)&&!f.has(S)&&!ba.has(S)&&!wa.test(S)&&!ya.test(S)}).sort(([w],[S])=>w.localeCompare(S)).slice(0,512));return{home:l(e.HOME||(process.platform==="win32"?e.USERPROFILE:void 0)||pa()),path:((w)=>process.platform==="win32"?vn(w):w)(kr(e.PATH??"").join(ha)||xr),temporaryDirectory:l(e.TMPDIR||e.TMP||e.TEMP||_a()),variables:g}}function gr(e=process.env,l=()=>ma().shell){if(process.platform==="win32")return se();let f=(w)=>{if(!w||!/^\/[A-Za-z0-9._/-]*\/(?:bash|zsh)$/.test(w))return!1;try{return la(w,ua.X_OK),fa(w).isFile()}catch{return!1}};if(f(e.SHELL))return e.SHELL;let g;try{g=l()}catch{g=void 0}return f(g)?g:"/bin/zsh"}import{readdir as ka}from"fs/promises";var Sa=15000;function hn(e){let l=e instanceof Error&&"code"in e?e.code:null;return l==="EPERM"||l==="EACCES"}function fn(e){return new r("folder_access_denied",`macOS blocked Reason from opening ${e}. Allow Reason in System Settings \u203A Privacy & Security \u203A Files and Folders `+"(or Full Disk Access), then try again.")}async function ts(e,{timeoutMs:l=Sa,open:f=(g)=>ka(g)}={}){let g,w=new Promise((S)=>{g=setTimeout(()=>S("pending"),l)});try{if(await Promise.race([f(e).then(()=>"open"),w])==="pending")throw new r("folder_access_pending",`macOS is asking whether Reason may open ${e}. Answer the prompt on this Mac, then try again.`)}catch(S){if(hn(S))throw fn(e);if(S instanceof r)throw S}finally{clearTimeout(g)}}import{chmodSync as rc,closeSync as tc,constants as $n,fstatSync as nc,lstatSync as vs,openSync as oc,readSync as sc,realpathSync as Kn,unlinkSync as ic}from"fs";import{lookup as ac}from"dns/promises";import{createRequire as cc}from"module";import{request as dc}from"http";import{request as lc}from"https";import dt from"net";import{platform as Os}from"os";import{basename as uc,extname as fc,isAbsolute as ks,relative as Gn,resolve as vt,sep as Jn}from"path";var ns=String.raw`
|
|
5
5
|
async (roots) => {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var er={name:"github-native-engineer-device-worker-production",version:"0.2.
|
|
2
|
+
var er={name:"github-native-engineer-device-worker-production",version:"0.2.420",private:!0,type:"module",engines:{node:">=22",bun:">=1.3.0"},workspaces:["../../packages/runtime-distribution"],dependencies:{"@anthropic-ai/sandbox-runtime":"^0.0.73","@earendil-works/pi-tui":"1.0.0","@modelcontextprotocol/sdk":"^1.29.0","@reason/runtime-distribution":"workspace:*","playwright-core":"1.60.0",zod:"^4.4.3"},overrides:{"@hono/node-server":"^1.19.15","@earendil-works/pi-agent-core":"1.0.0","@earendil-works/pi-ai":"1.0.0","@earendil-works/pi-coding-agent":"1.0.0","@earendil-works/chord":"1.0.0","@earendil-works/pi-codemode":"1.0.0","@earendil-works/pi-mcp":"1.0.0","@earendil-works/pi-telemetry":"1.0.0","@earendil-works/pi-tui":"1.0.0","brace-expansion":"2.1.7",axios:"^1.20.0","basic-ftp":"^6.2.1","@grpc/grpc-js":"^1.14.5",browserslist:"^4.28.8","engine.io":"^6.6.7","fast-uri":"^3.1.8",hono:"^4.13.7","ip-address":"^10.7.1",nanoid:"^3.3.18",dompurify:"^3.4.17",postcss:"^8.5.23",qs:"^6.16.0","shell-quote":"^1.11.0","socket.io-parser":"^4.2.7",tmp:"^0.2.7",toml:"^4.2.0",undici:"^8.10.2",ws:"^8.21.0","js-yaml":"^4.3.2","@modelcontextprotocol/sdk":"^1.31.0","proxy-addr":"^2.0.8","source-map-js":"^1.2.2"}};
|
|
3
3
|
export{er};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{S,Jt,Kn,Ye,Jn,Zn}from"./vm-hands-entry-lite-jzz73e3f.js";import{Yn}from"./vm-hands-entry-lite-
|
|
2
|
+
import{S,Jt,Kn,Ye,Jn,Zn}from"./vm-hands-entry-lite-jzz73e3f.js";import{Yn}from"./vm-hands-entry-lite-2rd6t7ry.js";import{Un}from"./vm-hands-entry-lite-hk6trmwa.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFile as ys,spawn as Xe}from"child_process";import{existsSync as ws}from"fs";import{connect as xs}from"net";function pn(){let e=new Set,t=null,n=(s)=>({holder:t?.viewer??null,you:t===s,same_user:Boolean(t?.viewer&&s.viewer&&t.viewer.user_id===s.viewer.user_id)}),o=()=>{for(let s of e)s.notify(n(s))};return{join(s){return e.add(s),s.notify(n(s)),()=>{if(!e.delete(s))return;if(t!==s)return;t=null,o()}},claim(s){if(t===s||!e.has(s))return;t=s,o()}}}var ut=pn();import{createHash as St}from"crypto";import{once as Sn}from"events";import{createWriteStream as vn,existsSync as mr,mkdirSync as gr,mkdtempSync as hr,readFileSync as le,readdirSync as br,renameSync as yr,realpathSync as En,rmSync as Dn,statSync as Ne,writeFileSync as wr}from"fs";import{delimiter as _r,dirname as vt,join as b}from"path";import{finished as Cn}from"stream/promises";var We="omljlfpmafedpplnpkkahegadhkimdje",so="https://chromewebstore.google.com/detail/reason/omljlfpmafedpplnpkkahegadhkimdje";var O={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"}},H={version:"155.0.8059.84",macArm64Sha256:"13b9e98ce56f5ce18e100a009f455c9285f399e7c9dc8a76fdf2f3a9755bb5f2",linux64Sha256:"cf0f049892dea22e6a6db26d47ed0d7776b7158edcbec4634086633df8bafcbc",win64Sha256:"507f2a031441d10c62b5e3d4e863f09ac1198a571c1419976cbd8387f639afde"};var J={ocu:{url:`https://registry.npmjs.org/open-computer-use/-/open-computer-use-${O.ocu.version}.tgz`,sha256:"7c16a87c8cd357787b02c0ebd040dd5f93880c1fb51c1901caa2e0c05d063130",size_bytes:5844280},obu:{url:`https://registry.npmjs.org/open-browser-use/-/open-browser-use-${O.obu.version}.tgz`,sha256:"9386d8ce0a147b3f55e1807b68edf736836378807541c457c9b5f6ca2cabaa4e",size_bytes:21372018},extension:{url:`https://github.com/iFurySt/open-browser-use/releases/download/v${O.obu.version}/open-browser-use-chrome-extension-${O.obu.version}.zip`,sha256:"c9c07bec1175e12ea6985b0e7784a5ef01fd03f014b958224a1e17dcd838a241",size_bytes:31070}},F="pnbmoicbkopffjjgfgfglopechaiemkp";import{spawn as Me}from"child_process";import{createRequire as fn}from"module";import{join as mn}from"path";var gn=30000,hn=1048576;function Te(){return process.env.SystemRoot??"C:\\Windows"}function bn(){return mn(Te(),"System32","WindowsPowerShell","v1.0","powershell.exe")}var yn=String.raw`
|
|
3
3
|
$ErrorActionPreference = "Stop"
|
|
4
4
|
Add-Type -TypeDefinition @"
|
|
5
5
|
using System;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{_t}from"./vm-hands-entry-lite-
|
|
2
|
+
import{_t}from"./vm-hands-entry-lite-hqmyd73s.js";import{a}from"./vm-hands-entry-lite-jev771b3.js";import{randomUUID as L}from"crypto";import{spawnSync as b}from"child_process";import{chmodSync as ee,cpSync as te,existsSync as x,lstatSync as A,mkdirSync as Y,readdirSync as ne,readFileSync as w,readlinkSync as re,realpathSync as T,renameSync as E,rmdirSync as ie,rmSync as g,symlinkSync as M,writeFileSync as oe}from"fs";import{dirname as I,join as u,relative as se,resolve as ce}from"path";var Xn="so.ara.cli",k=[Xn,"com.reasonmachines.cli"],F="5LJFSBRY2F";function Zr(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] = "${F}"`}var G="ReasonBackgroundIdentity",Po="Contents/Helpers/ReasonPermissionTile",ae="so.ara.cli.permission-tile",Ne=Zr([ae,"com.reasonmachines.cli.permission-tile"]),v="AraBackgroundIdentity",ue="Reason",Ce=Zr(k),de=`anchor apple generic and (${k.map((e)=>`identifier "${e}"`).join(" or ")}) and certificate leaf[subject.OU] = "${F}"`;class h extends Error{code;constructor(e,t){super(t);this.code=e;this.name="MacOSBackgroundIdentityError"}}var R="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";function le(e=a()){return u(e,"Library","Application Support","Reason","Background","Reason.app")}function O(e=a()){return u(e,"Library","Application Support","Ara","Background","Ara.app")}function fe(e){try{return A(e).isFile()}catch{return!1}}function D(e){return[G,v].map((t)=>u(e,"Contents","MacOS",t)).find(fe)??null}function d(e){try{if(!A(e).isDirectory())return!1;let t=w(u(e,"Contents","Info.plist"),"utf8");return k.some((n)=>t.includes(`<string>${n}</string>`))&&(t.includes(`<string>${ue}</string>`)||t.includes("<string>Ara</string>"))&&D(e)!==null}catch{return!1}}function Xr(e=a()){let t=le(e);if(!d(t))return null;try{let n=w(u(t,"Contents","Info.plist"),"utf8");return/<key>CFBundleVersion<\/key>\s*<string>(\d+\.\d+\.\d+)<\/string>/.exec(n)?.[1]??null}catch{return null}}function pe(e,t=a()){let n=Xr(t);return n===null||j(N(n.split(".")),N(e.split(/[.-]/).slice(0,3)))}var ge=1e4;function K(e,t){return b(e,[...t],{stdio:"ignore",timeout:ge}).status??1}var W=new Set;function H(e){if(process.env.REASON_TEST_REFUSE_REAL_IDENTITY!=="1")return;let t=(n)=>{try{return T(n)}catch{return ce(n)}};if(e!==void 0&&t(e)!==t(a()))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 V=/\/(?:runtime|CLI)\/versions\/(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$|\/\.(?:ara|reason)(?:-staging)?-worker-(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$/,J=new Set(["ara","ara.exe","reason","reason.exe"]);function N(e){return e.map((t)=>Number(t))}function j(e,t){for(let n=0;n<3;n+=1)if(e[n]!==t[n])return e[n]<t[n];return!1}var ye=[0,2,161];function me(e){if(e===null)return!0;let t=ye,n=null;try{n=T(process.execPath)}catch{}return e.some((r)=>{let i=V.exec(r);if(i){let f=i[1]===void 0?i.slice(4,7):i.slice(1,4);return j(N(f),t)}let o=r.slice(r.lastIndexOf("/")+1);return J.has(o)&&r!==n&&r!==process.execPath})}function Ee(){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(!V.test(i)&&J.has(o)){let c=b("/usr/sbin/lsof",["-a","-p",r[1],"-d","txt","-Fn"],{encoding:"utf8",timeout:5000}).stdout?.split(`
|
|
4
4
|
`).find((l)=>l.startsWith("n/"));if(c)i=c.slice(1)}t.push(i)}return t}function _e(e){if(H(e.home),!d(e.sourceApp))throw new h("identity_invalid","The packaged Reason background identity is missing or invalid.");let t=e.command??K,n=le(e.home),r=I(n);Y(r,{recursive:!0,mode:448}),ee(r,448);let i=T(e.sourceApp),o=null;try{o=T(n)}catch{}if(i!==o){let f=`${process.pid}.${L()}`,c=u(r,`.Reason.app.${f}.tmp`),l=u(r,`.Reason.app.${f}.old`),y=!1;try{if(te(i,c,{recursive:!0,errorOnExist:!0,preserveTimestamps:!0}),!d(c))throw new h("identity_invalid","The copied Reason background identity is invalid.");let _=e.releaseSigned?["--test-requirement",`=${de}`]:[];if(t("/usr/bin/codesign",["--verify","--strict",..._,c])!==0)throw new h("identity_invalid_signature","The installed Reason background identity has an invalid signature.");let S=!1;for(let p=0;p<4;p+=1){let m=!1;try{E(n,l),m=!0,y=!0}catch(s){if(s.code!=="ENOENT")throw s}if(p===0)e.beforePublish?.();try{E(c,n),S=!0}catch(s){let Z=s.code;if(!["EEXIST","ENOTEMPTY"].includes(Z??""))throw s;if(m)g(l,{recursive:!0,force:!0}),y=!1;if(p===3)throw s;continue}if(m)g(l,{recursive:!0,force:!0}),y=!1;break}if(!S)throw Error("Could not publish Reason's background identity.")}catch(_){if(y&&!x(n)&&x(l))E(l,n);throw _}finally{g(c,{recursive:!0,force:!0}),g(l,{recursive:!0,force:!0})}}return z(n,e,{verified:i!==o}),n}function X(e){return u(I(e),".Reason.app.registered")}function q(e){try{let t=A(e);return t.isDirectory()?`${t.ino}:${t.birthtimeMs}`:null}catch{return null}}function C(e){let t=q(e);try{return t!==null&&w(X(e),"utf8")===t}catch{return!1}}function Q(e){if(d(e))return"bundle";try{if(A(u(e,"Contents","Info.plist"),{throwIfNoEntry:!1}))return null;return A(u(e,"Contents","MacOS",v)).isSymbolicLink()?"retired":null}catch{return null}}function z(e,t,n={}){let r=t.command??K;if(!n.verified&&r("/usr/bin/codesign",["--verify","--strict",e])!==0)throw new h("identity_invalid_signature","The installed Reason background identity has an invalid signature.");if(r(R,["-f",e])!==0)throw new h("identity_register_failed","Could not register Reason's macOS background identity.");let i=q(e);try{if(i)oe(X(e),i,{mode:384})}catch{}try{Se(e,t.home,r,t.runningExecutables??Ee)}catch(o){let f=o.code??"unknown";process.stderr.write(`Reason background identity: legacy_identity_retire_failed (${f})
|
|
5
5
|
`)}}function Se(e,t,n,r){let i=D(e);if(!i)return;let o=O(t),f=I(o),c=(s)=>u(s,"Contents","MacOS",v),l=se(I(c(o)),i),y=`${process.pid}.${L()}`,_=Q(o);if(_===null)return;let S=_==="bundle";if(S)n(R,["-u",o]);let p=u(f,`.Ara.app.${y}.old`);if(!W.has(o)&&!me(r())){if(!S)n(R,["-u",o]);try{E(o,p)}catch(s){if(s.code==="ENOENT")return;throw s}g(p,{recursive:!0,force:!0}),Ie(f);return}if(!S){if(re(c(o))===l)return;let s=`${c(o)}.${y}`;M(l,s);try{E(s,c(o))}finally{g(s,{force:!0})}return}let m=u(f,`.Ara.app.${y}.shim`);Y(I(c(m)),{recursive:!0}),M(l,c(m));try{try{E(o,p)}catch(s){if(s.code==="ENOENT")return;throw s}try{E(m,o)}catch(s){if(x(o))return;throw E(p,o),s}}finally{g(m,{recursive:!0,force:!0}),g(p,{recursive:!0,force:!0})}}function Ie(e){try{if(ne(e).some((n)=>n!==".DS_Store"))return;g(u(e,".DS_Store"),{force:!0}),ie(e)}catch{}}var B=new Map;function Yn(e=a()){let t=B.get(e);if(t)return t;if(process.platform!=="darwin")return[];let n=U(e);if(n===null&&x(I(le(e))))Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,100),n=U(e);if(n===null)return[];return B.set(e,n),n}function U(e){let t=le(e),n=O(e);if(!d(t)||!C(t))try{he({home:e,skipWhenSettled:!0})}catch{}let r=d(t)&&(C(t)||!d(n))?t:d(n)?n:null,i=r?D(r):null;if(!i)return null;if(r===n)W.add(n);let o=b(i,["--can-spawn"],{env:{},timeout:2000,encoding:"utf8"});return o.status===0&&o.stdout===`spawn
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{readdirSync as b,readFileSync as P}from"fs";import{userInfo as k}from"os";var ar="--vm-hands-op-runner-kind=person",cr="--vm-hands-op-runner-kind=surface",Ct="--vm-hands-surface-uid=",At="--vm-hands-surface-dir=",Pt=new Set(["automation.call.v1","display.stream.v1","preview.serve.v1"]);function R(t){let c=new Set([t]),l=[];try{l=b("/proc")}catch{}for(let o of l){if(!/^\d+$/.test(o))continue;try{let d=P(`/proc/${o}/stat`,"utf8");if(Number(d.slice(d.lastIndexOf(")")+2).split(" ")[3])===t)c.add(Number(o))}catch{}}for(let o of c)try{process.kill(o,"SIGKILL")}catch{}}var A=(t)=>{let c=globalThis.Bun;if(!c)throw new r("pty_unavailable","Reason terminals require the Bun runtime.");let l=c.spawn({cmd:[t.shell,...t.args],cwd:t.cwd,env:{...t.environment,TERM:"xterm-256color"},terminal:{cols:t.cols,rows:t.rows,data:(i,s)=>t.onData(s)}}),o=l.terminal,d=()=>{R(l.pid);try{o?.close()}catch{}};if(!o)throw d(),new r("pty_unavailable","Reason could not allocate a pseudo-terminal.");return{write:(i)=>o.write(i),resize:(i,s)=>o.resize(i,s),kill:d,exited:l.exited.then((i)=>typeof i==="number"?i:null,()=>null)}};function x(){let t=(()=>{try{return k().username}catch{return}})();return{PATH:process.env.PATH,HOME:process.env.HOME,SHELL:process.env.SHELL,LANG:"C.UTF-8",...t?{USER:t,LOGNAME:t}:{}}}async function E(t){let[{localAutomationAvailable:c},{localDisplayReady:l},{localDisplayVideoAvailable:o},{probeWorkerPreview:d},y]=await Promise.all([import("./local-automation-
|
|
2
|
+
import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{readdirSync as b,readFileSync as P}from"fs";import{userInfo as k}from"os";var ar="--vm-hands-op-runner-kind=person",cr="--vm-hands-op-runner-kind=surface",Ct="--vm-hands-surface-uid=",At="--vm-hands-surface-dir=",Pt=new Set(["automation.call.v1","display.stream.v1","preview.serve.v1"]);function R(t){let c=new Set([t]),l=[];try{l=b("/proc")}catch{}for(let o of l){if(!/^\d+$/.test(o))continue;try{let d=P(`/proc/${o}/stat`,"utf8");if(Number(d.slice(d.lastIndexOf(")")+2).split(" ")[3])===t)c.add(Number(o))}catch{}}for(let o of c)try{process.kill(o,"SIGKILL")}catch{}}var A=(t)=>{let c=globalThis.Bun;if(!c)throw new r("pty_unavailable","Reason terminals require the Bun runtime.");let l=c.spawn({cmd:[t.shell,...t.args],cwd:t.cwd,env:{...t.environment,TERM:"xterm-256color"},terminal:{cols:t.cols,rows:t.rows,data:(i,s)=>t.onData(s)}}),o=l.terminal,d=()=>{R(l.pid);try{o?.close()}catch{}};if(!o)throw d(),new r("pty_unavailable","Reason could not allocate a pseudo-terminal.");return{write:(i)=>o.write(i),resize:(i,s)=>o.resize(i,s),kill:d,exited:l.exited.then((i)=>typeof i==="number"?i:null,()=>null)}};function x(){let t=(()=>{try{return k().username}catch{return}})();return{PATH:process.env.PATH,HOME:process.env.HOME,SHELL:process.env.SHELL,LANG:"C.UTF-8",...t?{USER:t,LOGNAME:t}:{}}}async function E(t){let[{localAutomationAvailable:c},{localDisplayReady:l},{localDisplayVideoAvailable:o},{probeWorkerPreview:d},y]=await Promise.all([import("./local-automation-3amth2kd.js"),import("./local-display-session-e4n5hx0v.js"),import("./local-display-video-28gmymr4.js"),import("./worker-preview-readiness-w62n91kr.js"),import("fs")]),i=AbortSignal.timeout(15000),s=null;try{y.mkdirSync(t,{recursive:!0,mode:448}),s=y.mkdtempSync(`${t}/probe-`);let[g,p,m]=await Promise.all([Promise.resolve().then(()=>c()).catch(()=>!1),l().catch(()=>!1),d(s,i).catch(()=>!1)]);return{t:"readiness",display_video:p&&await o().catch(()=>!1),lanes:{"automation.call.v1":g,"display.stream.v1":p,"preview.serve.v1":m,"tunnel.open":m,"tunnel.close":m}}}finally{if(s)y.rmSync(s,{recursive:!0,force:!0})}}async function as(){let[{executeLocalOperation:t,spawnCaptured:c},{runLocalPtySession:l},{configureDesktopAccount:o,desktopAccount:d},{configureWorkerSandbox:y}]=await Promise.all([import("./local-capabilities-hgmepv53.js"),import("./local-pty-session-rpk05ap5.js"),import("./desktop-account-6sjrxy69.js"),import("./worker-sandbox-2r5nseff.js")]);y();let i=process.argv.includes(ar),s=process.argv.includes(cr),g=(a,e,u)=>c(a,e[0]==="-lic"?["-lc",...e.slice(1)]:e,u),p=(process.geteuid?.()??0)!==0;if(s){p=!1;let a=process.argv.find((e)=>e.startsWith(Ct))?.slice(Ct.length);if((process.geteuid?.()??-1)===0&&a)try{p=o({value:a})!==null&&d()!==null}catch{p=!1}}let m=new Map,v=new Map,f=(a)=>{try{process.send?.(a)}catch{}};if(process.on("message",(a)=>{let e=a;if(e?.t==="cancel"){m.get(e.id)?.abort();return}if(e?.t==="control"){let n=v.get(e.id);if(s&&n&&e.control&&typeof e.control.kind==="string")import("./local-managed-process-2313kw42.js").then(({controlManagedDeviceProcess:_})=>_(n,{kind:e.control.kind,payload:e.control.payload??{}})).catch(()=>!1);return}if(e?.t==="retire"){if(s&&typeof e.operation_id==="string"&&typeof e.status==="string")import("./local-managed-process-2313kw42.js").then(({retireManagedDeviceProcess:n})=>n(e.operation_id,e.status)).catch(()=>!1);return}if(e?.t!=="op")return;if(!p){f({t:"done",id:e.id,completion:{status:"failed",error_code:"vm_hands_payload_account_unavailable"}});return}let u=e.claim.capability;if(u==="pty.start"&&!i){f({t:"done",id:e.id,completion:{status:"failed",error_code:"capability_not_granted"}});return}if(Pt.has(u)!==s){f({t:"done",id:e.id,completion:{status:"failed",error_code:"capability_not_granted"}});return}let w=new AbortController;m.set(e.id,w),v.set(e.id,e.claim);let S=u==="pty.start"?{runPtySession:(n)=>l(n,{spawnPty:A,environment:x(),loadProxy:()=>null})}:{worker:e.worker,...u==="exec.full"?{spawnFullControl:g}:{}};t(e.state,e.claim,{...S,signal:w.signal,emit:(n)=>{let{deliverySignal:_,...h}=n;f({t:"event",id:e.id,event:h})}}).then((n)=>f({t:"done",id:e.id,completion:n}),(n)=>f({t:"done",id:e.id,completion:{status:"failed",error_code:n&&typeof n==="object"&&"code"in n&&typeof n.code==="string"?n.code:"vm_hands_op_failed"}})).finally(()=>{m.delete(e.id),v.delete(e.id)})}),process.on("disconnect",()=>process.exit(0)),s){let a=process.argv.find((u)=>u.startsWith(At))?.slice(At.length),e={t:"readiness",display_video:!1,lanes:{}};f(p&&a?await E(a).catch(()=>e):e)}await new Promise(()=>{})}
|
|
3
3
|
export{ar,cr,Ct,At,Pt,as};
|