@reason-machines/cli-linux-x64 0.2.532 → 0.2.534
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/{api-credentials-z393zjpq.js → api-credentials-hynhcs1v.js} +1 -1
- package/bin/vm-hands/{api-q8098w8t.js → api-gd3afdds.js} +1 -1
- package/bin/vm-hands/{connect-cli-n23c1e42.js → connect-cli-xh2cc2c5.js} +1 -1
- package/bin/vm-hands/{local-automation-mxxzzwdy.js → local-automation-45nn289q.js} +1 -1
- package/bin/vm-hands/{local-capabilities-e4qyygbj.js → local-capabilities-qs6n7zxx.js} +1 -1
- package/bin/vm-hands/{local-display-session-8tg29vx8.js → local-display-session-3c9242sp.js} +1 -1
- package/bin/vm-hands/local-display-video-bb2bdrw3.js +2 -0
- package/bin/vm-hands/{local-managed-process-2skpwhp9.js → local-managed-process-34btcd3z.js} +1 -1
- package/bin/vm-hands/{managed-runtime-k1xbpsr0.js → managed-runtime-zp61gx6h.js} +1 -1
- package/bin/vm-hands/{permissions-0gv9a128.js → permissions-bqtevz8y.js} +1 -1
- package/bin/vm-hands/{serve-service-72d9zc7g.js → serve-service-603hhrev.js} +1 -1
- package/bin/vm-hands/{status-avj18t39.js → status-de6k7jvm.js} +1 -1
- package/bin/vm-hands/version-vma5qfjd.js +2 -0
- package/bin/vm-hands/{vm-hands-entry-lite-dwj67571.js → vm-hands-entry-lite-0e6h8ddd.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-2sbrsmdf.js → vm-hands-entry-lite-10b4f71g.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-g3371m35.js → vm-hands-entry-lite-2vh94vfz.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-75e2t3yd.js → vm-hands-entry-lite-4t4fakg5.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-wdkj6xye.js → vm-hands-entry-lite-6d0wge41.js} +1 -1
- package/bin/vm-hands/vm-hands-entry-lite-7jv0nsky.js +2 -0
- package/bin/vm-hands/{vm-hands-entry-lite-n2ym5pd8.js → vm-hands-entry-lite-8fz6cjwf.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-6mer3faz.js → vm-hands-entry-lite-af11bndd.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-xw9yfezf.js → vm-hands-entry-lite-b6xv41m1.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-tkjftjtm.js → vm-hands-entry-lite-bmxbn05p.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-ngm6gj8f.js → vm-hands-entry-lite-fgz5a87g.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-p87ekrne.js → vm-hands-entry-lite-jb8m0sm2.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-0fgjj27w.js → vm-hands-entry-lite-nc7vcg9e.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-65m6vekj.js → vm-hands-entry-lite-p7cgg4yt.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-2p4f7qfe.js → vm-hands-entry-lite-qw97ene9.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-qkq05tq8.js → vm-hands-entry-lite-xew9ydsp.js} +1 -1
- package/bin/vm-hands/vm-hands-entry-lite.js +2 -2
- package/bin/vm-hands/vm-hands-executor-qdrh0165.js +12 -0
- package/bin/vm-hands/{vm-hands-op-runner-w99xckrg.js → vm-hands-op-runner-kdrhyjs5.js} +1 -1
- package/bin/vm-hands/vm-hands-runtime-dqjz75d0.js +4 -0
- package/package.json +1 -1
- package/bin/vm-hands/local-display-video-g2hwt6mn.js +0 -2
- package/bin/vm-hands/version-m3hvs5fm.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-emfdyf11.js +0 -2
- package/bin/vm-hands/vm-hands-executor-5vn9z2q3.js +0 -12
- package/bin/vm-hands/vm-hands-runtime-dpcqbmn6.js +0 -4
package/bin/reason
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{zi,es,ts,As}from"./vm-hands-entry-lite-
|
|
2
|
+
import{zi,es,ts,As}from"./vm-hands-entry-lite-b6xv41m1.js";import"./vm-hands-entry-lite-nc7vcg9e.js";import"./vm-hands-entry-lite-04x5xjt6.js";import"./vm-hands-entry-lite-7jv0nsky.js";import"./vm-hands-entry-lite-4anjdcth.js";import"./vm-hands-entry-lite-a3p6xz53.js";import"./vm-hands-entry-lite-jvszqt0z.js";import"./vm-hands-entry-lite-a0g6c3wr.js";import"./vm-hands-entry-lite-b6gsggvp.js";import"./vm-hands-entry-lite-s85p7tqp.js";export{zi as apiOriginFromEnvironment,ts as environmentApiKey,es as explicitApiOrigin,As as resolveApiCredentials};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{D,Ps,rs}from"./vm-hands-entry-lite-
|
|
2
|
+
import{D,Ps,rs}from"./vm-hands-entry-lite-nc7vcg9e.js";import"./vm-hands-entry-lite-04x5xjt6.js";import"./vm-hands-entry-lite-7jv0nsky.js";import"./vm-hands-entry-lite-4anjdcth.js";import"./vm-hands-entry-lite-a3p6xz53.js";import"./vm-hands-entry-lite-jvszqt0z.js";import"./vm-hands-entry-lite-a0g6c3wr.js";import"./vm-hands-entry-lite-b6gsggvp.js";import"./vm-hands-entry-lite-s85p7tqp.js";export{D as ApiError,rs as ReasonApi,Ps as createMachineEnrollmentTicketWithToken};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{it,Ss,Es,xs}from"./vm-hands-entry-lite-
|
|
2
|
+
import{it,Ss,Es,xs}from"./vm-hands-entry-lite-6d0wge41.js";import"./vm-hands-entry-lite-y5hv1gjv.js";import"./vm-hands-entry-lite-13s0mfpr.js";import"./vm-hands-entry-lite-b6xv41m1.js";import"./vm-hands-entry-lite-nc7vcg9e.js";import"./vm-hands-entry-lite-04x5xjt6.js";import"./vm-hands-entry-lite-bmxbn05p.js";import"./vm-hands-entry-lite-af11bndd.js";import"./vm-hands-entry-lite-9azmqs47.js";import"./vm-hands-entry-lite-4t4fakg5.js";import"./vm-hands-entry-lite-10b4f71g.js";import"./vm-hands-entry-lite-5tnma5qb.js";import"./vm-hands-entry-lite-4r1yn35v.js";import"./vm-hands-entry-lite-2hfrcr50.js";import"./vm-hands-entry-lite-hfx1q0b0.js";import"./vm-hands-entry-lite-0e6h8ddd.js";import"./vm-hands-entry-lite-xew9ydsp.js";import"./vm-hands-entry-lite-2vh94vfz.js";import"./vm-hands-entry-lite-ct4mtq1m.js";import"./vm-hands-entry-lite-fgz5a87g.js";import"./vm-hands-entry-lite-k9vk84wa.js";import"./vm-hands-entry-lite-j5t2pj4v.js";import"./vm-hands-entry-lite-cgddp0y3.js";import"./vm-hands-entry-lite-y9jarm7q.js";import"./vm-hands-entry-lite-hv3dxd5k.js";import"./vm-hands-entry-lite-jb8m0sm2.js";import"./vm-hands-entry-lite-qw97ene9.js";import"./vm-hands-entry-lite-7jv0nsky.js";import"./vm-hands-entry-lite-vj7xzb3y.js";import"./vm-hands-entry-lite-4anjdcth.js";import"./vm-hands-entry-lite-a3p6xz53.js";import"./vm-hands-entry-lite-jvszqt0z.js";import"./vm-hands-entry-lite-a0g6c3wr.js";import"./vm-hands-entry-lite-qc6gxqgs.js";import"./vm-hands-entry-lite-37b5045h.js";import"./vm-hands-entry-lite-xe0benev.js";import"./vm-hands-entry-lite-b6gsggvp.js";import"./vm-hands-entry-lite-s85p7tqp.js";export{Ss as computerDisconnected,it as connectionDirectory,Es as connectionReport,xs as restartConnection};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Pn,Us,zs,qs,Ws,Rn}from"./vm-hands-entry-lite-
|
|
2
|
+
import{Pn,Us,zs,qs,Ws,Rn}from"./vm-hands-entry-lite-0e6h8ddd.js";import"./vm-hands-entry-lite-xew9ydsp.js";import"./vm-hands-entry-lite-2vh94vfz.js";import"./vm-hands-entry-lite-ct4mtq1m.js";import"./vm-hands-entry-lite-fgz5a87g.js";import"./vm-hands-entry-lite-k9vk84wa.js";import"./vm-hands-entry-lite-j5t2pj4v.js";import"./vm-hands-entry-lite-cgddp0y3.js";import"./vm-hands-entry-lite-y9jarm7q.js";import"./vm-hands-entry-lite-hv3dxd5k.js";import"./vm-hands-entry-lite-jb8m0sm2.js";import"./vm-hands-entry-lite-qw97ene9.js";import"./vm-hands-entry-lite-7jv0nsky.js";import"./vm-hands-entry-lite-vj7xzb3y.js";import"./vm-hands-entry-lite-4anjdcth.js";import"./vm-hands-entry-lite-a3p6xz53.js";import"./vm-hands-entry-lite-jvszqt0z.js";import"./vm-hands-entry-lite-a0g6c3wr.js";import"./vm-hands-entry-lite-qc6gxqgs.js";import"./vm-hands-entry-lite-37b5045h.js";import"./vm-hands-entry-lite-xe0benev.js";import"./vm-hands-entry-lite-b6gsggvp.js";import"./vm-hands-entry-lite-s85p7tqp.js";export{zs as ensureLocalBrowser,Pn as localAutomationAvailable,qs as localBrowserProfile,Us as localUserChromeHost,Ws as runAutomationCallLocally,Rn as runLocalAutomation};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ns,Vi,mn,is,os,ss,as,$s,Ms,Bs,Fs}from"./vm-hands-entry-lite-
|
|
2
|
+
import{ns,Vi,mn,is,os,ss,as,$s,Ms,Bs,Fs}from"./vm-hands-entry-lite-af11bndd.js";import"./vm-hands-entry-lite-9azmqs47.js";import"./vm-hands-entry-lite-4t4fakg5.js";import"./vm-hands-entry-lite-10b4f71g.js";import"./vm-hands-entry-lite-5tnma5qb.js";import"./vm-hands-entry-lite-4r1yn35v.js";import"./vm-hands-entry-lite-2hfrcr50.js";import"./vm-hands-entry-lite-hfx1q0b0.js";import"./vm-hands-entry-lite-0e6h8ddd.js";import"./vm-hands-entry-lite-xew9ydsp.js";import"./vm-hands-entry-lite-2vh94vfz.js";import"./vm-hands-entry-lite-ct4mtq1m.js";import"./vm-hands-entry-lite-fgz5a87g.js";import"./vm-hands-entry-lite-k9vk84wa.js";import"./vm-hands-entry-lite-j5t2pj4v.js";import"./vm-hands-entry-lite-cgddp0y3.js";import"./vm-hands-entry-lite-y9jarm7q.js";import"./vm-hands-entry-lite-hv3dxd5k.js";import"./vm-hands-entry-lite-jb8m0sm2.js";import"./vm-hands-entry-lite-qw97ene9.js";import"./vm-hands-entry-lite-7jv0nsky.js";import"./vm-hands-entry-lite-vj7xzb3y.js";import"./vm-hands-entry-lite-4anjdcth.js";import"./vm-hands-entry-lite-a3p6xz53.js";import"./vm-hands-entry-lite-jvszqt0z.js";import"./vm-hands-entry-lite-a0g6c3wr.js";import"./vm-hands-entry-lite-qc6gxqgs.js";import"./vm-hands-entry-lite-37b5045h.js";import"./vm-hands-entry-lite-xe0benev.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import"./vm-hands-entry-lite-b6gsggvp.js";import"./vm-hands-entry-lite-s85p7tqp.js";export{r as LocalCapabilityError,ns as SHORT_REQUEST_CAPABILITIES,$s as capabilityInventoryForRoots,Vi as confinedExecutionShell,is as defaultLocalCommandRunner,Ms as deliverLocalHandsEnvironment,as as enrolledRootPaths,Fs as executeLocalOperation,Bs as rebindLocalHandsControl,os as runFileCapability,ss as runTransferCapability,mn as spawnCaptured};
|
package/bin/vm-hands/{local-display-session-8tg29vx8.js → local-display-session-3c9242sp.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ft,Vs,G,qe,jt}from"./vm-hands-entry-lite-
|
|
2
|
+
import{Ft,Vs,G,qe,jt}from"./vm-hands-entry-lite-xew9ydsp.js";import"./vm-hands-entry-lite-2vh94vfz.js";import"./vm-hands-entry-lite-ct4mtq1m.js";import"./vm-hands-entry-lite-fgz5a87g.js";import"./vm-hands-entry-lite-k9vk84wa.js";import"./vm-hands-entry-lite-j5t2pj4v.js";import"./vm-hands-entry-lite-cgddp0y3.js";import"./vm-hands-entry-lite-y9jarm7q.js";import"./vm-hands-entry-lite-hv3dxd5k.js";import"./vm-hands-entry-lite-qw97ene9.js";import"./vm-hands-entry-lite-7jv0nsky.js";import"./vm-hands-entry-lite-4anjdcth.js";import"./vm-hands-entry-lite-a3p6xz53.js";import"./vm-hands-entry-lite-jvszqt0z.js";import"./vm-hands-entry-lite-a0g6c3wr.js";import"./vm-hands-entry-lite-xe0benev.js";import"./vm-hands-entry-lite-b6gsggvp.js";import"./vm-hands-entry-lite-s85p7tqp.js";export{qe as ensureLinuxDesktop,Ft as localDisplayAvailable,Vs as localDisplayReady,G as privateDirectory,jt as runLocalDisplayStream};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{In,Dn,On,Nn,Rr}from"./vm-hands-entry-lite-2vh94vfz.js";import"./vm-hands-entry-lite-ct4mtq1m.js";import"./vm-hands-entry-lite-fgz5a87g.js";import"./vm-hands-entry-lite-k9vk84wa.js";import"./vm-hands-entry-lite-qw97ene9.js";import"./vm-hands-entry-lite-7jv0nsky.js";import"./vm-hands-entry-lite-jvszqt0z.js";import"./vm-hands-entry-lite-a0g6c3wr.js";export{In as MAC_SCREEN,Dn as WINDOWS_SCREEN,On as createDisplayVideoLane,Rr as localDisplayVideoAvailable,Nn as simulatorVideoFfmpeg};
|
package/bin/vm-hands/{local-managed-process-2skpwhp9.js → local-managed-process-34btcd3z.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{st,fr,js,Hs}from"./vm-hands-entry-lite-
|
|
2
|
+
import{st,fr,js,Hs}from"./vm-hands-entry-lite-4t4fakg5.js";import"./vm-hands-entry-lite-10b4f71g.js";import"./vm-hands-entry-lite-5tnma5qb.js";import"./vm-hands-entry-lite-4r1yn35v.js";import"./vm-hands-entry-lite-2hfrcr50.js";import"./vm-hands-entry-lite-hfx1q0b0.js";import"./vm-hands-entry-lite-ct4mtq1m.js";import"./vm-hands-entry-lite-cgddp0y3.js";import"./vm-hands-entry-lite-y9jarm7q.js";import"./vm-hands-entry-lite-hv3dxd5k.js";import"./vm-hands-entry-lite-4anjdcth.js";import"./vm-hands-entry-lite-a3p6xz53.js";import"./vm-hands-entry-lite-jvszqt0z.js";import"./vm-hands-entry-lite-a0g6c3wr.js";import"./vm-hands-entry-lite-qc6gxqgs.js";import"./vm-hands-entry-lite-37b5045h.js";import"./vm-hands-entry-lite-xe0benev.js";import"./vm-hands-entry-lite-b6gsggvp.js";import"./vm-hands-entry-lite-s85p7tqp.js";export{st as ManagedProcessStoppedError,js as controlManagedDeviceProcess,Hs as retireManagedDeviceProcess,fr as runManagedDeviceProcess};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Rs,Ts,Is,Ds,Os,Ns,Ls}from"./vm-hands-entry-lite-
|
|
2
|
+
import{Rs,Ts,Is,Ds,Os,Ns,Ls}from"./vm-hands-entry-lite-bmxbn05p.js";import"./vm-hands-entry-lite-hfx1q0b0.js";import"./vm-hands-entry-lite-qw97ene9.js";import"./vm-hands-entry-lite-7jv0nsky.js";import"./vm-hands-entry-lite-a3p6xz53.js";import"./vm-hands-entry-lite-jvszqt0z.js";import"./vm-hands-entry-lite-a0g6c3wr.js";import"./vm-hands-entry-lite-b6gsggvp.js";import"./vm-hands-entry-lite-s85p7tqp.js";export{Os as acquireManagedRuntimeDirectoryLock,Is as currentManagedRuntimeVersion,Ls as flushManagedRuntimeLifecycleEvents,Ds as isManagedRuntimeVersionExecutable,Ts as legacyManagedRuntimePaths,Rs as managedRuntimePaths,Ns as recordManagedRuntimeLifecycle};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ls,us,Ks,Js}from"./vm-hands-entry-lite-
|
|
2
|
+
import{ls,us,Ks,Js}from"./vm-hands-entry-lite-fgz5a87g.js";import"./vm-hands-entry-lite-k9vk84wa.js";import"./vm-hands-entry-lite-qw97ene9.js";import"./vm-hands-entry-lite-7jv0nsky.js";import"./vm-hands-entry-lite-jvszqt0z.js";import"./vm-hands-entry-lite-a0g6c3wr.js";export{Js as allowMacPermissions,Ks as permissionsSummary,us as readMacPermissions,ls as reasonIdentity};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Wr,xe,J,Jn,Xs,No,Ys,Ze,ps,Xn,Zs,Qs,Vr,ea,ta}from"./vm-hands-entry-lite-
|
|
2
|
+
import{Wr,xe,J,Jn,Xs,No,Ys,Ze,ps,Xn,Zs,Qs,Vr,ea,ta}from"./vm-hands-entry-lite-jb8m0sm2.js";import"./vm-hands-entry-lite-qw97ene9.js";import"./vm-hands-entry-lite-7jv0nsky.js";import"./vm-hands-entry-lite-vj7xzb3y.js";import"./vm-hands-entry-lite-4anjdcth.js";import"./vm-hands-entry-lite-a3p6xz53.js";import"./vm-hands-entry-lite-jvszqt0z.js";import"./vm-hands-entry-lite-a0g6c3wr.js";import"./vm-hands-entry-lite-b6gsggvp.js";import"./vm-hands-entry-lite-s85p7tqp.js";export{Wr as WORKER_SERVICE_ENV,J as WorkerServiceError,No as connectServiceLabel,xe as defaultWorkerServiceHost,Qs as installWorkerService,Ze as installedWorkerService,Ys as isConnectServiceLabel,ta as removeWorkerService,Vr as restartWorkerService,ea as retargetWorkerServiceLogs,ps as retireLegacyWorkerService,Zs as workerServiceDefinitionCurrent,Jn as workerServiceLauncher,Xn as workerServiceProcessRunning,Xs as workerServiceRetargetPending};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./vm-hands-entry-lite-
|
|
2
|
+
import"./vm-hands-entry-lite-nc7vcg9e.js";import"./vm-hands-entry-lite-a3p6xz53.js";import{_}from"./vm-hands-entry-lite-4anjdcth.js";import"./vm-hands-entry-lite-a0g6c3wr.js";import"./vm-hands-entry-lite-04x5xjt6.js";import"./vm-hands-entry-lite-s85p7tqp.js";import"./vm-hands-entry-lite-7jv0nsky.js";import"./vm-hands-entry-lite-b6xv41m1.js";import{Kt,ht}from"./vm-hands-entry-lite-cgddp0y3.js";import{w,M,pr,Be,it}from"./vm-hands-entry-lite-6d0wge41.js";import"./vm-hands-entry-lite-qc6gxqgs.js";import"./vm-hands-entry-lite-37b5045h.js";import"./vm-hands-entry-lite-af11bndd.js";import"./vm-hands-entry-lite-10b4f71g.js";import"./vm-hands-entry-lite-5tnma5qb.js";import"./vm-hands-entry-lite-9azmqs47.js";import"./vm-hands-entry-lite-y5hv1gjv.js";import"./vm-hands-entry-lite-2vh94vfz.js";import"./vm-hands-entry-lite-k9vk84wa.js";import"./vm-hands-entry-lite-qw97ene9.js";import"./vm-hands-entry-lite-fgz5a87g.js";import"./vm-hands-entry-lite-ct4mtq1m.js";import"./vm-hands-entry-lite-bmxbn05p.js";import"./vm-hands-entry-lite-vj7xzb3y.js";import"./vm-hands-entry-lite-jb8m0sm2.js";import"./vm-hands-entry-lite-hv3dxd5k.js";import"./vm-hands-entry-lite-4r1yn35v.js";import"./vm-hands-entry-lite-y9jarm7q.js";import"./vm-hands-entry-lite-4t4fakg5.js";import"./vm-hands-entry-lite-xe0benev.js";import"./vm-hands-entry-lite-j5t2pj4v.js";import"./vm-hands-entry-lite-xew9ydsp.js";import"./vm-hands-entry-lite-0e6h8ddd.js";import"./vm-hands-entry-lite-13s0mfpr.js";import"./vm-hands-entry-lite-2hfrcr50.js";import"./vm-hands-entry-lite-hfx1q0b0.js";import{a}from"./vm-hands-entry-lite-jvszqt0z.js";import{t,o,u,i,s,n}from"./vm-hands-entry-lite-ztsp4gs8.js";import"./vm-hands-entry-lite-b6gsggvp.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 f(e){return`claude mcp add --transport http reason ${e}`}function h(e){return`codex mcp add reason --url ${e}
|
|
3
3
|
codex mcp login reason`}var F=f("https://mcp.reasonmachines.com/mcp"),z=h("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{We,go,F,Ve,Ht,Tr,x}from"./vm-hands-entry-lite-
|
|
2
|
+
import{We,go,F,Ve,Ht,Tr,x}from"./vm-hands-entry-lite-2vh94vfz.js";import{K}from"./vm-hands-entry-lite-ct4mtq1m.js";import{pt}from"./vm-hands-entry-lite-k9vk84wa.js";import{gt}from"./vm-hands-entry-lite-qw97ene9.js";import{Ir}from"./vm-hands-entry-lite-fgz5a87g.js";import{Pt,Hi}from"./vm-hands-entry-lite-xe0benev.js";import{G,qe}from"./vm-hands-entry-lite-xew9ydsp.js";import{xe,Jn}from"./vm-hands-entry-lite-jb8m0sm2.js";import{St}from"./vm-hands-entry-lite-qc6gxqgs.js";import{a}from"./vm-hands-entry-lite-jvszqt0z.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{C}from"./vm-hands-entry-lite-b6gsggvp.js";import{spawn as R,spawnSync as st}from"child_process";import{createHash as it,randomUUID as ge}from"crypto";import{closeSync as at,copyFileSync as ae,existsSync as M,fstatSync as ct,mkdirSync as ce,openSync as lt,readdirSync as U,readFileSync as X,readlinkSync as ut,renameSync as he,rmSync as dt,statSync as mt,writeFileSync as ft}from"fs";import{connect as ht}from"net";import{tmpdir as L,userInfo as we}from"os";import{basename as le,delimiter as wt,dirname as B,join as f}from"path";var z=`import { spawn, execFileSync } from "node:child_process";
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
import { readFileSync, readlinkSync, lstatSync, realpathSync, statSync, mkdtempSync, mkdirSync, chmodSync, writeFileSync, readdirSync, rmSync, openSync, readSync, closeSync, renameSync } from "node:fs";
|
|
5
5
|
import { tmpdir } from "node:os";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Jt,j}from"./vm-hands-entry-lite-cgddp0y3.js";import{ue,Ce,X,Ae,de,ir,et,Y,I,U,rn}from"./vm-hands-entry-lite-a0g6c3wr.js";import{Uo,ri}from"./vm-hands-entry-lite-4anjdcth.js";import{Io,P,Je,Se,Xe,ne,Ye,Vn,Ee,Qt,ae,H,N,ce,zr,qr,Kn}from"./vm-hands-entry-lite-hv3dxd5k.js";import{Pe,oe,pe,Z,Te,q,Q}from"./vm-hands-entry-lite-qc6gxqgs.js";import{Lt,Pr,lt,V,O,T,b,Cn}from"./vm-hands-entry-lite-4r1yn35v.js";import{Cr,Ar,xn,uo,Ue,kn}from"./vm-hands-entry-lite-5tnma5qb.js";import{K}from"./vm-hands-entry-lite-ct4mtq1m.js";import{ji}from"./vm-hands-entry-lite-xe0benev.js";import{p,ze,$t,ut,po,_e,we}from"./vm-hands-entry-lite-2hfrcr50.js";import{v,h,mo}from"./vm-hands-entry-lite-hfx1q0b0.js";import{E}from"./vm-hands-entry-lite-72nj66ab.js";import{tr}from"./vm-hands-entry-lite-n2ym5pd8.js";import{a,zo,qo,ie,Vo}from"./vm-hands-entry-lite-jvszqt0z.js";import{L,$i,Mi,Yo,y,t,k,At,o,d,u,i,c,g,ee,s,n}from"./vm-hands-entry-lite-ztsp4gs8.js";import{Fi}from"./vm-hands-entry-lite-pzj5s203.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{Qo,se,Ui,C,Oe,$e,A}from"./vm-hands-entry-lite-b6gsggvp.js";var Ri=()=>{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"},_={nan:"NaN"};return(w)=>{switch(w.code){case"invalid_type":{let S=_[w.expected]??w.expected,x=Yo(w.input),W=_[x]??x;return`Invalid input: expected ${S}, received ${W}`}case"invalid_value":if(w.values.length===1)return`Invalid input: expected ${Mi(w.values[0])}`;return`Invalid option: expected one of ${$i(w.values,"|")}`;case"too_big":{let S=w.inclusive?"<=":"<",x=l(w.origin);if(x)return`Too big: expected ${w.origin??"value"} to have ${S}${w.maximum.toString()} ${x.unit??"elements"}`;return`Too big: expected ${w.origin??"value"} to be ${S}${w.maximum.toString()}`}case"too_small":{let S=w.inclusive?">=":">",x=l(w.origin);if(x)return`Too small: expected ${w.origin} to have ${S}${w.minimum.toString()} ${x.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":""}: ${$i(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((x)=>`'${x}'`).join(" | ")}`;return"Invalid input";case"invalid_element":return`Invalid value in ${w.origin}`;default:return"Invalid input"}}};function gn(){return{localeError:Ri()}}L(gn());class mt extends Error{}function No(e){let l;try{l=new URL(e)}catch{throw new mt("The proxy must be a URL like https://proxy.example.com:3128.")}if(l.protocol!=="https:"&&l.protocol!=="http:")throw new mt("The proxy URL must use the https or http scheme.");if(!l.hostname)throw new mt("The proxy URL must name a host.");if(l.port!==""&&Number(l.port)<1)throw new mt("The proxy URL must use a port between 1 and 65535.");if(l.pathname!==""&&l.pathname!=="/"||l.search||l.hash)throw new mt("The proxy URL must not carry a path, query, or fragment.");return l.toString()}import{createHash as Oi}from"crypto";import{isAbsolute as Bo,join as jo,relative as Mo,resolve as qt,sep as Wo}from"path";var Vt=t().min(1).refine(Bo,"absolute path required"),Lo=c({version:n(1),apiOrigin:At(),channel:s(["staging","production"]),stateDirectory:Vt,workspaceRoot:Vt,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(Jt),url:t().refine((e)=>{try{return No(e)===e}catch{return!1}},"invalid proxy URL"),caFile:Vt.optional()}).optional(),userChrome:d().optional(),cloudSessions:n(!0).optional(),localLogins:d().optional(),folders:u(Vt).min(1).max(31).optional()}),xi=/^https:\/\/[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.trycloudflare\.com$/,B=g("channel",[Lo,Lo.extend({channel:n("local-qa"),apiOrigin:t()})]).superRefine((e,l)=>{if(e.channel==="local-qa"){if(!xi.test(e.apiOrigin))l.addIssue({code:"custom",message:"local QA worker requires an exact HTTPS trycloudflare.com quick-tunnel origin"})}else{let _=new URL(e.apiOrigin);if(_.origin!==e.apiOrigin||_.username||_.password||_.protocol!=="https:"&&!(_.protocol==="http:"&&ri(_.origin))||!ri(_.origin)&&!Uo(e.channel,_.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((_)=>!je(_,e.stateDirectory)))l.addIssue({code:"custom",message:"folders must be distinct and disjoint from state"})});function m(e){return jo(e.stateDirectory,`headless-${e.channel}`)}function je(e,l){if(Fr(l,e))return!1;return!Fr(e,l)||E(jo(Wo,Mo(qt(e),qt(l))))}function Fr(e,l){let f=Mo(qt(e),qt(l));return f===""||f!==".."&&!f.startsWith(`..${Wo}`)&&!Bo(f)}function te(e){let{proxy:l,userChrome:f,cloudSessions:_,localLogins:w,folders:S,...x}=e;return Oi("sha256").update(JSON.stringify(x)).digest("hex")}var Pi=4,Ii=[2375,2376,9222,9229];function mr(e){let l=new Set(Ii);for(let f of e){let _=new URL(f);l.add(Number(_.port||(["https:","wss:"].includes(_.protocol)?443:80)))}return l}function Gr(){throw new r("preview_unavailable","The live Hands preview binding is unavailable or stale.")}var Ai=60000;function Fo(e){let l=new AbortController,f=new Map,_=(R)=>JSON.stringify([R.jobId,R.port]);function w(R){let M=e.authority.owner;if(l.signal.aborted||!e.isCurrent()||e.expiresAtMs<=Date.now()||R.organization_id!==M.organization_id||R.user_id!==M.user_id||R.device_id!==M.device_id)Gr()}function S(R){let M;try{M=e.environment.current()}catch{return null}return M.binding.target_generation===R.generation&&M.binding.target_fence_id===R.fenceId&&M.run_id===e.runId&&M.device_id===e.authority.owner.device_id&&M.root_id===e.authority.rootId?M:null}async function x(R,M,G){let F=await W(R,M,G);if(F!=="moved")return F;let D=await W(R,M,G);return D==="moved"?null:D}async function W(R,M,G){try{w(e.authority.owner);let F=e.identity();if(!F||G.aborted||R.expiresAtMs<=Date.now()||R.expiresAtMs>e.expiresAtMs)return null;let D=M.opened,re=D!==void 0&&F.generation>D.generation,J=S(F);if(re){if(J){if(J.revision<=D.revision||R.expiresAtMs>Date.parse(J.expires_at)||J.binding.target_revision!==D.attachmentRevision||J.binding.root_grant_revision!==D.grantRevision)return null;M.recoveringSinceMs=void 0}else if(Date.now()-(M.recoveringSinceMs??=Date.now())>Ai)return null}else if(!J||R.expiresAtMs>Date.parse(J.expires_at)||D&&(F.generation!==D.generation||F.fenceId!==D.fenceId))return null;let z=await e.inspect(R.jobId,G),fe=e.identity(),ve=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?D:be;if(G.aborted||!fe)return null;if(fe.generation!==F.generation||fe.fenceId!==F.fenceId||ve?.snapshot_id!==J?.snapshot_id||ve?.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(!D&&F.generation===R.generation&&F.fenceId===R.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:R.port,expiresAtMs:R.expiresAtMs}}}catch{return null}}return{async open(R,M,G){w(M);let{binding:F,deviceRelayUrl:D}=ut(R);if(G.aborted||F.expiresAtMs<=Date.now()||F.expiresAtMs>Date.now()+p.lifetimeMs||new URL(D).origin!==e.authority.relayOrigin)Gr();let re=_(F),J=f.get(re);if(J){if(!ze(J.binding,F)||J.relay!==D)Gr();if(await J.opened,!await $t(()=>J.port.check())||G.aborted||J.abort.signal.aborted)Gr();return{opened:!0,binding:F}}if(f.size>=Pi)Gr();let z=new AbortController,fe={},ve=we({binding:F,deniedPorts:e.authority.deniedPorts,readCurrentJob:()=>x(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:D,port:ve,signal:z.signal}),Fe={binding:F,relay:D,abort:z,port:ve,opened:Re};f.set(re,Fe);let qe=()=>{if(G.removeEventListener("abort",be),l.signal.removeEventListener("abort",be),f.get(re)===Fe)f.delete(re)};try{if((await Re).closed.then(qe),G.removeEventListener("abort",be),w(M),z.signal.aborted||!await $t(()=>ve.check()))Gr();return{opened:!0,binding:F}}catch{z.abort(),qe(),Gr()}},async close(R,M){w(M);let{binding:G}=po(R),F=f.get(_(G));if(!F||!ze(F.binding,G))Gr();return F.abort.abort(),await F.opened.then((D)=>D.closed,()=>{return}),{closed:!0,binding:G}},dispose(){l.abort();for(let R of f.values())R.abort.abort();f.clear()}}}import{WebSocket as Rn}from"ws";var $o=(e)=>("data"in e)?e.data.length:e.bytes,Ko=2*Ye;function ar(e){throw new r(e,"The bound Hands terminal is unavailable or its outcome is unconfirmed.")}var ht=(e)=>!["starting","running"].includes(e.state);function eo(e,l,f=Date.now()){let _=["relay_url","session_id","expires_at","cols","rows","pty","workspace"];if(Object.keys(e).length!==_.length||Object.keys(e).some((M)=>!_.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)<=Ee))ar("invalid_pty_request");let w=e.pty;if(!w||typeof w!=="object"||Array.isArray(w))ar("invalid_pty_request");let S=w;if(Object.keys(S).length!==2||S.version!==1||!ce(S.jobId))ar("invalid_pty_request");let x;try{x=new URL(e.relay_url)}catch{return ar("invalid_pty_request")}if(!["ws:","wss:"].includes(x.protocol)||x.username||x.password||x.hash||x.protocol==="ws:"&&!["127.0.0.1","[::1]","localhost"].includes(x.hostname))ar("invalid_pty_request");let W=Date.parse(e.expires_at);if(!Number.isSafeInteger(W)||W<=f)ar("invalid_pty_request");return{workspace:U(e.workspace)??ar("invalid_pty_request"),session:{jobId:S.jobId,sessionId:e.session_id,operationId:l,relayUrl:x.href,cols:Number(e.cols),rows:Number(e.rows),leaseExpiresAtMs:Math.min(W,f+43200000)}}}async function Go(e){let{session:l,binding:f}=e;if(f.assertCurrent(),e.signal.aborted||Date.now()>=l.leaseExpiresAtMs)ar("cancelled");let _=new Rn(l.relayUrl,{followRedirects:!1,perMessageDeflate:!1,maxPayload:ne}),w=new AbortController,S=()=>{},x=()=>{w.abort(),S()};e.signal.addEventListener("abort",x,{once:!0});let W=setTimeout(x,Math.max(1,l.leaseExpiresAtMs-Date.now())),R=[],M=0,G=0,F=0,D=!1,re=!1,J=!1,z,fe,ve,be=(le)=>{ve=new r(le,"Bound terminal input was refused."),x()};_.on("error",()=>be("pty_relay_unavailable")),_.on("close",x),_.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 Ke=R.at(-1),Le=he&&Ke!==void 0&&"data"in Ke&&Ke.data.length+xe.length<=ne;if(xe.length>ne||M+xe.length>Vn){be("pty_input_backpressure");return}if(Le)Ke.data=Buffer.concat([Ke.data,xe]);else if(he)R.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,x();return}if(!Be||Be.t!=="resize"||Object.keys(Be).length!==3||![Be.cols,Be.rows].every((ke)=>Number.isSafeInteger(ke)&&ke>=1&&ke<=Ee))throw Error("invalid_control");R.push({cols:Be.cols,rows:Be.rows,bytes:xe.length})}catch{be("invalid_pty_control");return}M+=xe.length,S()});function Re(le){return Kn(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)ar(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))ar("pty_binding_changed");if(Re(he),he.process)fe??={...he.process};return he}async function qe(le){f.assertCurrent();let he=await f.request(le,w.signal);if(f.assertCurrent(),w.signal.aborted)ar("cancelled");let xe=Fe(he);if(xe.inputSequence!==G)ar("job_input_sequence");if(!ht(xe)&&xe.leaseExpiresAtMs<=Date.now())ar("pty_binding_changed");return xe}function ye(le){if(f.assertCurrent(),w.signal.aborted||_.readyState!==Rn.OPEN||_.bufferedAmount+Buffer.byteLength(le)>Ko)ar("pty_output_backpressure");_.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)ar("pty_output_gap");let xe=Buffer.from(he.dataBase64,"base64");if(_.bufferedAmount+xe.length>Ko)return!1;ye(xe),F=he.cursor}if(F!==le.nextCursor)ar("pty_output_gap");return!0}async function Ve(le,he){let xe;try{await Promise.race([e.emit(le,he),new Promise((Ke,Le)=>{xe=setTimeout(()=>Le(new r("pty_event_unavailable","Terminal metadata delivery timed out.")),2000)})])}finally{clearTimeout(xe)}}async function De(){let le=AbortSignal.timeout(Qt),he=f.request({jobId:l.jobId,action:"cancel",input:{}},le),xe,Ke=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,Ke]);if(le.aborted)ar("pty_cleanup_unconfirmed");return Fe(Le)}finally{le.removeEventListener("abort",xe)}}try{await new Promise((Le,Be)=>{let ke=setTimeout(()=>{x(),Be(new r("pty_relay_unavailable","Terminal pairing timed out."))},5000),Me=()=>{clearTimeout(ke),Be(new r("cancelled","Terminal pairing was cancelled."))};if(w.signal.addEventListener("abort",Me,{once:!0}),_.once("open",()=>{clearTimeout(ke),w.signal.removeEventListener("abort",Me),Le()}),w.signal.aborted)Me()}),f.assertCurrent(),D=!0,z=await qe({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)ar("pty_not_ready");await new Promise((Le)=>setTimeout(Le,25)),z=await qe({jobId:l.jobId,action:"inspect",input:{after:F}})}if(z.state!=="running"||z.inputSequence!==0||z.leaseExpiresAtMs<=Date.now())ar("pty_not_ready");await Ve("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,Ke=!1;while(!w.signal.aborted){let Le=z.firstCursor>F+1,Be=We(z);if(ht(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:rr}=z.pty;for(let or of[{cols:Me,rows:rr>1?rr-1:2},{cols:Me,rows:rr}]){if(ht(z))break;let Rr=++G;if(z=await qe({jobId:l.jobId,action:"resize",input:{sequence:Rr,...or}}),z.inputSequence!==Rr)ar("job_input_sequence")}continue}let ke=ht(z)||Ke?void 0:R.shift();if(ke){M-=$o(ke);let Me=++G;try{z=await qe("data"in ke?{jobId:l.jobId,action:"input",input:{sequence:Me,dataBase64:ke.data.toString("base64")}}:{jobId:l.jobId,action:"resize",input:{sequence:Me,cols:ke.cols,rows:ke.rows}})}catch(rr){if(!(rr instanceof r)||rr.code!=="job_input_backpressure")throw rr;G-=1,R.unshift(ke),M+=$o(ke),Ke=!0;continue}if(z.inputSequence!==Me)ar("job_input_sequence")}else if(await new Promise((Me)=>{let rr=setTimeout(Me,Ke||!Be?10:50);if(S=()=>{clearTimeout(rr),Me()},w.signal.aborted||!Ke&&R.length)S()}),Ke=!1,S=()=>{},!w.signal.aborted&&Be)try{z=await qe({jobId:l.jobId,action:"inspect",input:{after:F}})}catch(Me){if(!J||!(Me instanceof r)||Me.code!=="cancelled")throw Me}}}catch(le){ve??=le}finally{if(re=!1,R.length=0,clearTimeout(W),e.signal.removeEventListener("abort",x),x(),D&&(!z||!ht(z)))try{z=await De()}catch{z=void 0}try{if(!z||!ht(z)||z.pty?.cleanup!=="confirmed")ar("pty_cleanup_unconfirmed");let le=Re(z);if(_.readyState===Rn.OPEN)await new Promise((he)=>{let xe=setTimeout(he,500);_.send(JSON.stringify({t:"exit",code:z.exitCode,receipt:le}),()=>{clearTimeout(xe),he()})});await Ve("pty.stopped",le)}catch(le){ve??=le}_.terminate()}if(ve)throw ve;if(e.signal.aborted)ar("cancelled");if(!z)ar("pty_cleanup_unconfirmed");return{receipt:Re(z)}}import{createHash as Ti,randomUUID as An}from"crypto";import{spawnSync as es}from"child_process";import{closeSync as Jo,constants as On,fstatSync as Di,fsyncSync as Ci,lstatSync as Ht,mkdirSync as Hi,mkdtempSync as rs,openSync as Xo,readFileSync as Ni,readdirSync as ts,realpathSync as Vr,rmSync as Pn,unlinkSync as Li}from"fs";import{createConnection as Bi}from"net";import{dirname as Wi,join as ot,sep as In}from"path";import{tmpdir as ns}from"os";var hr=new Map,Jr=new Map;function Ur(e,l){return Ti("sha256").update(JSON.stringify([e,l])).digest("hex")}function gt(e){try{Hi(e,{mode:448})}catch(f){if(!(f instanceof Error&&("code"in f)&&f.code==="EEXIST"))throw f}let l=Ht(e);if(!l.isDirectory()||l.isSymbolicLink()||!A(l)||Vr(e)!==e)throw new r("hands_jobs_unavailable","Hands job state must be a private canonical directory.")}function zi(e){let l;try{l=Ht(e)}catch(f){if(f instanceof Error&&"code"in f&&f.code==="ENOENT")return!1;throw f}return!l.isDirectory()||l.isSymbolicLink()||ts(e).length>0}function Ki(e){if(process.platform==="win32")return Ui();let l=e.map((f)=>{try{return Vr(f)}catch{return f}});for(let f of[()=>Ui(),()=>Vr("/dev/shm"),()=>Vr(ns())]){let _;try{_=f()}catch{continue}if(!l.some((w)=>_===w||_.startsWith(w.endsWith(In)?w:w+In)))return _}throw new r("invalid_hands_workspace","A Session can't work in this computer's temporary folder itself; start it in a project folder inside it.")}function gr(e){let l=Ur(e.root,e.runId),f=e.previousRuntimeDirectories?.find((x)=>zi(ot(x,"jobs",l.slice(0,16))))??e.runtimeDirectory;gt(f);let _=ot(f,"jobs");gt(_);let w=ot(_,l.slice(0,16));if(e.maxScopes!==void 0){let x=ts(_);if(!Number.isSafeInteger(e.maxScopes)||e.maxScopes<1||x.length>e.maxScopes||!x.includes(l.slice(0,16))&&x.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.")}gt(w);let S=rs(ot(Ki(e.folders??[]),"reason-j-"));try{return gt(S),{journalDirectory:w,scopeId:l,launchDirectory:S,socketPath:process.platform==="win32"?`\\\\.\\pipe\\reason-jobs-${An()}`:ot(S,"control.sock"),disposeSocket:()=>Pn(S,{recursive:!0,force:!0})}}catch(x){throw Pn(S,{recursive:!0,force:!0}),x}}var Gi=60000,Ji=5000;function Vi(e){if(process.platform==="win32")return qi(e);let l=es("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,_=f?"JanFebMarAprMayJunJulAugSepOctNovDec".indexOf(f[1]):-1;if(!f||_<0||_%3!==0)return null;let w=new Date(Number(f[6]),_/3,Number(f[2]),Number(f[3]),Number(f[4]),Number(f[5])).getTime();return Number.isFinite(w)?w:null}function qi(e){let l=es(C("powershell"),["-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${e}).StartTime.ToUniversalTime().ToString('o')`],{encoding:"utf8",timeout:5000,windowsHide:!0,env:Oe()}),f=l.status===0?Date.parse(l.stdout.trim()):Number.NaN;return Number.isFinite(f)?f:null}function os(e,l={}){let f=ot(e.journalDirectory,"owner.lock"),_;try{_=Xo(f,On.O_RDONLY|On.O_NOFOLLOW)}catch{return null}try{let w=Di(_);if(!w.isFile()||w.nlink!==1||!A(w)||w.size>4096)return null;let S=null;try{S=JSON.parse(Ni(_,"utf8"))}catch{}let x;if(S===null){if((l.now??Date.now)()-w.mtimeMs<Gi)return null;x={reason:"never_written",executorLaunchId:null}}else{let{version:M,scopeId:G,pid:F,createdAtMs:D,executorLaunchId:re}=S;if(M!==1||G!==e.scopeId||typeof re!=="string"||typeof F!=="number"||!Number.isSafeInteger(F)||F<1||F===process.pid||typeof D!=="number"||!Number.isSafeInteger(D))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))x={reason:"owner_exited",executorLaunchId:re};else{let z=(l.startedAtMs??Vi)(F);if(z===null||z<=D+Ji)return null;x={reason:"pid_reused",executorLaunchId:re}}}let W=Ht(f);if(W.dev!==w.dev||W.ino!==w.ino)return null;Li(f);let R=Xo(e.journalDirectory,On.O_RDONLY);try{Ci(R)}finally{Jo(R)}return x}catch{return null}finally{Jo(_)}}function ss(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=Ur(l.root,l.runId);if(hr.has(f)||l.operationId!==void 0&&Jr.has(l.operationId))throw new r("hands_jobs_busy","The Session already has a live Hands job supervisor.");let _={binding:l,key:f,terminals:new Map};if(l.previewAuthority&&l.environment)_.previews=Fo({authority:l.previewAuthority,runId:l.runId,expiresAtMs:l.expiresAtMs,executorLaunchId:l.executorLaunchId,environment:l.environment,isCurrent:()=>hr.get(_.key)===_,identity:()=>{try{return bt(l)}catch{return null}},inspect:(w,S)=>{if(hr.get(_.key)!==_)throw new r("preview_unavailable","The Hands supervisor is no longer current.");return is(l,{jobId:w,action:"inspect",input:{after:0}},S)}});if(hr.set(f,_),l.operationId!==void 0)Jr.set(l.operationId,_);return()=>{if(hr.get(_.key)===_)hr.delete(_.key);if(l.operationId!==void 0&&Jr.get(l.operationId)===_)Jr.delete(l.operationId);_.previews?.dispose();for(let w of _.terminals.values())w.abort()}}var Yi=5000,Xi=20;async function to(e){let l=(w)=>{throw new r("hands_rebind_unavailable",w)};if(!N(e.operationId)||!N(e.runId)||!N(e.fenceId)||!H(e.targetGeneration))l("Reason sent an invalid Hands rebind.");let f=Jr.get(e.operationId);if(!f||f.binding.root!==e.root)return l("No live Hands supervisor owns this operation.");for(let w=Date.now()+Yi;;){if(e.signal?.aborted)l("The Hands rebind was cancelled.");if(Jr.get(e.operationId)!==f)l("The Hands supervisor is no longer current.");let S=null;try{S=bt(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((x)=>setTimeout(x,Xi))}if(Jr.get(e.operationId)!==f||hr.get(f.key)!==f)l("The Hands supervisor is no longer current.");let _=Ur(e.root,e.runId);if(f.key===_)return;if(hr.has(_))l("The taking run already has a live Hands job supervisor.");hr.delete(f.key);for(let w of f.terminals.values())w.abort();f.key=_,hr.set(_,f)}function at(e){let l="operationId"in e?Jr.get(e.operationId):hr.get(Ur(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 ro(e){let l=hr.get(Ur(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 no(e){let l=hr.get(Ur(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 io(e){let l=Ur(e.root,e.runId),f=hr.get(l),_=f?.binding,w=_?.runId,S=_?.previewAuthority,x=_?.environment,W=e.owner&&{...e.owner},R=e.authority&&{...e.authority},M=()=>{throw new r("pty_binding_unavailable","No current authenticated Hands scope owns this terminal.")};if(!f||!_||!S||!x||!W||!R||!_.workspace)return M();let G=Object.freeze({..._.workspace}),F=bt(_),D=x.current(),re=()=>{if(hr.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||I(e.workspace)!==I(G))M();let z=bt(_),fe=x.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!==D.snapshot_id||fe.revision!==D.revision||fe.binding.target_generation!==F.generation||fe.binding.target_fence_id!==F.fenceId||R.device_id!==e.deviceId||R.binding!==fe.binding.kind||R.target_revision!==fe.binding.target_revision||R.root_grant_revision!==fe.binding.root_grant_revision||R.target_generation!==F.generation||R.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 Go({session:{...e.session,leaseExpiresAtMs:Math.min(e.session.leaseExpiresAtMs,F.expiresAtMs,Date.parse(D.expires_at))},signal:AbortSignal.any([e.signal,J.signal]),emit:e.emit,binding:{assertCurrent:re,environment:{revision:D.revision,snapshotId:D.snapshot_id},scope:{runId:e.runId,deviceId:e.deviceId,rootId:e.rootId,workspace:G,binding:D.binding.kind,targetRevision:D.binding.target_revision,rootGrantRevision:D.binding.root_grant_revision,generation:F.generation,fenceId:F.fenceId,executorLaunchId:F.executorLaunchId},request:(z,fe)=>_r(F,zr(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 oo(e){if(ce(e.payload.jobId))throw new r("pty_binding_required","PTY jobs require the bound terminal capability.");let l=hr.get(Ur(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 is(l,e.payload,e.signal)}var Zi=1e4,Qi=20,ea=Se/2,ra=Je/2,ta=(e)=>e.output.reduce((l,f)=>l+f.text.length,0);async function is(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:_,...w}=l;if(_!==void 0&&(w.action!=="start"||typeof w.input!=="object"||w.input===null||!("script"in w.input)||typeof _!=="number"||!Number.isSafeInteger(_)||_<1||_>Zi))throw new r("invalid_payload","Only a script start may wait for its job, within its bound.");let S=(M)=>{let G=bt(e);return _r(G,zr(JSON.stringify({...M,type:"job",version:2,generation:G.generation,id:An()})),f)},x=await S(w);if(_===void 0)return x;let W=Date.now()+_,R=x;while(R.ok&&["starting","running"].includes(R.job.state)&&R.job.output.length<ea&&ta(R.job)<ra&&!f.aborted&&Date.now()<W){if(await new Promise((M)=>setTimeout(M,Math.min(Qi,W-Date.now()))),f.aborted)break;try{let M=await S({jobId:w.jobId,action:"inspect",input:{after:0}});if(!M.ok)break;R=M}catch{break}}return R}function bt(e){if(e.expiresAtMs<=Date.now())throw new r("hands_jobs_unavailable","Hands authority expired.");let l=e.readIdentity?e.readIdentity():e;if(!l||!H(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 _r(e,l,f){if(f.aborted)return Promise.reject(new r("cancelled","Job control was cancelled."));return new Promise((_,w)=>{let S=Bi(e.socketPath),x="",W=!1,R,M=(F,D)=>{if(W)return;if(W=!0,clearTimeout(R),f.removeEventListener("abort",G),S.destroy(),F)w(F);else _(D)},G=()=>M(new r("cancelled","Job control waiter cancelled; inspect before retrying mutations."));f.addEventListener("abort",G,{once:!0}),S.setEncoding("utf8"),R=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{Jt,j}from"./vm-hands-entry-lite-cgddp0y3.js";import{ue,Ce,X,Ae,de,ir,et,Y,I,U,rn}from"./vm-hands-entry-lite-a0g6c3wr.js";import{Uo,ri}from"./vm-hands-entry-lite-4anjdcth.js";import{Io,P,Je,Se,Xe,ne,Ye,Vn,Ee,Qt,ae,H,N,ce,zr,qr,Kn}from"./vm-hands-entry-lite-hv3dxd5k.js";import{Pe,oe,pe,Z,Te,q,Q}from"./vm-hands-entry-lite-qc6gxqgs.js";import{Lt,Pr,lt,V,O,T,b,Cn}from"./vm-hands-entry-lite-4r1yn35v.js";import{Cr,Ar,xn,uo,Ue,kn}from"./vm-hands-entry-lite-5tnma5qb.js";import{K}from"./vm-hands-entry-lite-ct4mtq1m.js";import{ji}from"./vm-hands-entry-lite-xe0benev.js";import{p,ze,$t,ut,po,_e,we}from"./vm-hands-entry-lite-2hfrcr50.js";import{v,h,mo}from"./vm-hands-entry-lite-hfx1q0b0.js";import{E}from"./vm-hands-entry-lite-72nj66ab.js";import{tr}from"./vm-hands-entry-lite-8fz6cjwf.js";import{a,zo,qo,ie,Vo}from"./vm-hands-entry-lite-jvszqt0z.js";import{L,$i,Mi,Yo,y,t,k,At,o,d,u,i,c,g,ee,s,n}from"./vm-hands-entry-lite-ztsp4gs8.js";import{Fi}from"./vm-hands-entry-lite-pzj5s203.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{Qo,se,Ui,C,Oe,$e,A}from"./vm-hands-entry-lite-b6gsggvp.js";var Ri=()=>{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"},_={nan:"NaN"};return(w)=>{switch(w.code){case"invalid_type":{let S=_[w.expected]??w.expected,x=Yo(w.input),W=_[x]??x;return`Invalid input: expected ${S}, received ${W}`}case"invalid_value":if(w.values.length===1)return`Invalid input: expected ${Mi(w.values[0])}`;return`Invalid option: expected one of ${$i(w.values,"|")}`;case"too_big":{let S=w.inclusive?"<=":"<",x=l(w.origin);if(x)return`Too big: expected ${w.origin??"value"} to have ${S}${w.maximum.toString()} ${x.unit??"elements"}`;return`Too big: expected ${w.origin??"value"} to be ${S}${w.maximum.toString()}`}case"too_small":{let S=w.inclusive?">=":">",x=l(w.origin);if(x)return`Too small: expected ${w.origin} to have ${S}${w.minimum.toString()} ${x.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":""}: ${$i(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((x)=>`'${x}'`).join(" | ")}`;return"Invalid input";case"invalid_element":return`Invalid value in ${w.origin}`;default:return"Invalid input"}}};function gn(){return{localeError:Ri()}}L(gn());class mt extends Error{}function No(e){let l;try{l=new URL(e)}catch{throw new mt("The proxy must be a URL like https://proxy.example.com:3128.")}if(l.protocol!=="https:"&&l.protocol!=="http:")throw new mt("The proxy URL must use the https or http scheme.");if(!l.hostname)throw new mt("The proxy URL must name a host.");if(l.port!==""&&Number(l.port)<1)throw new mt("The proxy URL must use a port between 1 and 65535.");if(l.pathname!==""&&l.pathname!=="/"||l.search||l.hash)throw new mt("The proxy URL must not carry a path, query, or fragment.");return l.toString()}import{createHash as Oi}from"crypto";import{isAbsolute as Bo,join as jo,relative as Mo,resolve as qt,sep as Wo}from"path";var Vt=t().min(1).refine(Bo,"absolute path required"),Lo=c({version:n(1),apiOrigin:At(),channel:s(["staging","production"]),stateDirectory:Vt,workspaceRoot:Vt,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(Jt),url:t().refine((e)=>{try{return No(e)===e}catch{return!1}},"invalid proxy URL"),caFile:Vt.optional()}).optional(),userChrome:d().optional(),cloudSessions:n(!0).optional(),localLogins:d().optional(),folders:u(Vt).min(1).max(31).optional()}),xi=/^https:\/\/[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.trycloudflare\.com$/,B=g("channel",[Lo,Lo.extend({channel:n("local-qa"),apiOrigin:t()})]).superRefine((e,l)=>{if(e.channel==="local-qa"){if(!xi.test(e.apiOrigin))l.addIssue({code:"custom",message:"local QA worker requires an exact HTTPS trycloudflare.com quick-tunnel origin"})}else{let _=new URL(e.apiOrigin);if(_.origin!==e.apiOrigin||_.username||_.password||_.protocol!=="https:"&&!(_.protocol==="http:"&&ri(_.origin))||!ri(_.origin)&&!Uo(e.channel,_.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((_)=>!je(_,e.stateDirectory)))l.addIssue({code:"custom",message:"folders must be distinct and disjoint from state"})});function m(e){return jo(e.stateDirectory,`headless-${e.channel}`)}function je(e,l){if(Fr(l,e))return!1;return!Fr(e,l)||E(jo(Wo,Mo(qt(e),qt(l))))}function Fr(e,l){let f=Mo(qt(e),qt(l));return f===""||f!==".."&&!f.startsWith(`..${Wo}`)&&!Bo(f)}function te(e){let{proxy:l,userChrome:f,cloudSessions:_,localLogins:w,folders:S,...x}=e;return Oi("sha256").update(JSON.stringify(x)).digest("hex")}var Pi=4,Ii=[2375,2376,9222,9229];function mr(e){let l=new Set(Ii);for(let f of e){let _=new URL(f);l.add(Number(_.port||(["https:","wss:"].includes(_.protocol)?443:80)))}return l}function Gr(){throw new r("preview_unavailable","The live Hands preview binding is unavailable or stale.")}var Ai=60000;function Fo(e){let l=new AbortController,f=new Map,_=(R)=>JSON.stringify([R.jobId,R.port]);function w(R){let M=e.authority.owner;if(l.signal.aborted||!e.isCurrent()||e.expiresAtMs<=Date.now()||R.organization_id!==M.organization_id||R.user_id!==M.user_id||R.device_id!==M.device_id)Gr()}function S(R){let M;try{M=e.environment.current()}catch{return null}return M.binding.target_generation===R.generation&&M.binding.target_fence_id===R.fenceId&&M.run_id===e.runId&&M.device_id===e.authority.owner.device_id&&M.root_id===e.authority.rootId?M:null}async function x(R,M,G){let F=await W(R,M,G);if(F!=="moved")return F;let D=await W(R,M,G);return D==="moved"?null:D}async function W(R,M,G){try{w(e.authority.owner);let F=e.identity();if(!F||G.aborted||R.expiresAtMs<=Date.now()||R.expiresAtMs>e.expiresAtMs)return null;let D=M.opened,re=D!==void 0&&F.generation>D.generation,J=S(F);if(re){if(J){if(J.revision<=D.revision||R.expiresAtMs>Date.parse(J.expires_at)||J.binding.target_revision!==D.attachmentRevision||J.binding.root_grant_revision!==D.grantRevision)return null;M.recoveringSinceMs=void 0}else if(Date.now()-(M.recoveringSinceMs??=Date.now())>Ai)return null}else if(!J||R.expiresAtMs>Date.parse(J.expires_at)||D&&(F.generation!==D.generation||F.fenceId!==D.fenceId))return null;let z=await e.inspect(R.jobId,G),fe=e.identity(),ve=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?D:be;if(G.aborted||!fe)return null;if(fe.generation!==F.generation||fe.fenceId!==F.fenceId||ve?.snapshot_id!==J?.snapshot_id||ve?.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(!D&&F.generation===R.generation&&F.fenceId===R.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:R.port,expiresAtMs:R.expiresAtMs}}}catch{return null}}return{async open(R,M,G){w(M);let{binding:F,deviceRelayUrl:D}=ut(R);if(G.aborted||F.expiresAtMs<=Date.now()||F.expiresAtMs>Date.now()+p.lifetimeMs||new URL(D).origin!==e.authority.relayOrigin)Gr();let re=_(F),J=f.get(re);if(J){if(!ze(J.binding,F)||J.relay!==D)Gr();if(await J.opened,!await $t(()=>J.port.check())||G.aborted||J.abort.signal.aborted)Gr();return{opened:!0,binding:F}}if(f.size>=Pi)Gr();let z=new AbortController,fe={},ve=we({binding:F,deniedPorts:e.authority.deniedPorts,readCurrentJob:()=>x(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:D,port:ve,signal:z.signal}),Fe={binding:F,relay:D,abort:z,port:ve,opened:Re};f.set(re,Fe);let qe=()=>{if(G.removeEventListener("abort",be),l.signal.removeEventListener("abort",be),f.get(re)===Fe)f.delete(re)};try{if((await Re).closed.then(qe),G.removeEventListener("abort",be),w(M),z.signal.aborted||!await $t(()=>ve.check()))Gr();return{opened:!0,binding:F}}catch{z.abort(),qe(),Gr()}},async close(R,M){w(M);let{binding:G}=po(R),F=f.get(_(G));if(!F||!ze(F.binding,G))Gr();return F.abort.abort(),await F.opened.then((D)=>D.closed,()=>{return}),{closed:!0,binding:G}},dispose(){l.abort();for(let R of f.values())R.abort.abort();f.clear()}}}import{WebSocket as Rn}from"ws";var $o=(e)=>("data"in e)?e.data.length:e.bytes,Ko=2*Ye;function ar(e){throw new r(e,"The bound Hands terminal is unavailable or its outcome is unconfirmed.")}var ht=(e)=>!["starting","running"].includes(e.state);function eo(e,l,f=Date.now()){let _=["relay_url","session_id","expires_at","cols","rows","pty","workspace"];if(Object.keys(e).length!==_.length||Object.keys(e).some((M)=>!_.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)<=Ee))ar("invalid_pty_request");let w=e.pty;if(!w||typeof w!=="object"||Array.isArray(w))ar("invalid_pty_request");let S=w;if(Object.keys(S).length!==2||S.version!==1||!ce(S.jobId))ar("invalid_pty_request");let x;try{x=new URL(e.relay_url)}catch{return ar("invalid_pty_request")}if(!["ws:","wss:"].includes(x.protocol)||x.username||x.password||x.hash||x.protocol==="ws:"&&!["127.0.0.1","[::1]","localhost"].includes(x.hostname))ar("invalid_pty_request");let W=Date.parse(e.expires_at);if(!Number.isSafeInteger(W)||W<=f)ar("invalid_pty_request");return{workspace:U(e.workspace)??ar("invalid_pty_request"),session:{jobId:S.jobId,sessionId:e.session_id,operationId:l,relayUrl:x.href,cols:Number(e.cols),rows:Number(e.rows),leaseExpiresAtMs:Math.min(W,f+43200000)}}}async function Go(e){let{session:l,binding:f}=e;if(f.assertCurrent(),e.signal.aborted||Date.now()>=l.leaseExpiresAtMs)ar("cancelled");let _=new Rn(l.relayUrl,{followRedirects:!1,perMessageDeflate:!1,maxPayload:ne}),w=new AbortController,S=()=>{},x=()=>{w.abort(),S()};e.signal.addEventListener("abort",x,{once:!0});let W=setTimeout(x,Math.max(1,l.leaseExpiresAtMs-Date.now())),R=[],M=0,G=0,F=0,D=!1,re=!1,J=!1,z,fe,ve,be=(le)=>{ve=new r(le,"Bound terminal input was refused."),x()};_.on("error",()=>be("pty_relay_unavailable")),_.on("close",x),_.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 Ke=R.at(-1),Le=he&&Ke!==void 0&&"data"in Ke&&Ke.data.length+xe.length<=ne;if(xe.length>ne||M+xe.length>Vn){be("pty_input_backpressure");return}if(Le)Ke.data=Buffer.concat([Ke.data,xe]);else if(he)R.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,x();return}if(!Be||Be.t!=="resize"||Object.keys(Be).length!==3||![Be.cols,Be.rows].every((ke)=>Number.isSafeInteger(ke)&&ke>=1&&ke<=Ee))throw Error("invalid_control");R.push({cols:Be.cols,rows:Be.rows,bytes:xe.length})}catch{be("invalid_pty_control");return}M+=xe.length,S()});function Re(le){return Kn(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)ar(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))ar("pty_binding_changed");if(Re(he),he.process)fe??={...he.process};return he}async function qe(le){f.assertCurrent();let he=await f.request(le,w.signal);if(f.assertCurrent(),w.signal.aborted)ar("cancelled");let xe=Fe(he);if(xe.inputSequence!==G)ar("job_input_sequence");if(!ht(xe)&&xe.leaseExpiresAtMs<=Date.now())ar("pty_binding_changed");return xe}function ye(le){if(f.assertCurrent(),w.signal.aborted||_.readyState!==Rn.OPEN||_.bufferedAmount+Buffer.byteLength(le)>Ko)ar("pty_output_backpressure");_.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)ar("pty_output_gap");let xe=Buffer.from(he.dataBase64,"base64");if(_.bufferedAmount+xe.length>Ko)return!1;ye(xe),F=he.cursor}if(F!==le.nextCursor)ar("pty_output_gap");return!0}async function Ve(le,he){let xe;try{await Promise.race([e.emit(le,he),new Promise((Ke,Le)=>{xe=setTimeout(()=>Le(new r("pty_event_unavailable","Terminal metadata delivery timed out.")),2000)})])}finally{clearTimeout(xe)}}async function De(){let le=AbortSignal.timeout(Qt),he=f.request({jobId:l.jobId,action:"cancel",input:{}},le),xe,Ke=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,Ke]);if(le.aborted)ar("pty_cleanup_unconfirmed");return Fe(Le)}finally{le.removeEventListener("abort",xe)}}try{await new Promise((Le,Be)=>{let ke=setTimeout(()=>{x(),Be(new r("pty_relay_unavailable","Terminal pairing timed out."))},5000),Me=()=>{clearTimeout(ke),Be(new r("cancelled","Terminal pairing was cancelled."))};if(w.signal.addEventListener("abort",Me,{once:!0}),_.once("open",()=>{clearTimeout(ke),w.signal.removeEventListener("abort",Me),Le()}),w.signal.aborted)Me()}),f.assertCurrent(),D=!0,z=await qe({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)ar("pty_not_ready");await new Promise((Le)=>setTimeout(Le,25)),z=await qe({jobId:l.jobId,action:"inspect",input:{after:F}})}if(z.state!=="running"||z.inputSequence!==0||z.leaseExpiresAtMs<=Date.now())ar("pty_not_ready");await Ve("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,Ke=!1;while(!w.signal.aborted){let Le=z.firstCursor>F+1,Be=We(z);if(ht(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:rr}=z.pty;for(let or of[{cols:Me,rows:rr>1?rr-1:2},{cols:Me,rows:rr}]){if(ht(z))break;let Rr=++G;if(z=await qe({jobId:l.jobId,action:"resize",input:{sequence:Rr,...or}}),z.inputSequence!==Rr)ar("job_input_sequence")}continue}let ke=ht(z)||Ke?void 0:R.shift();if(ke){M-=$o(ke);let Me=++G;try{z=await qe("data"in ke?{jobId:l.jobId,action:"input",input:{sequence:Me,dataBase64:ke.data.toString("base64")}}:{jobId:l.jobId,action:"resize",input:{sequence:Me,cols:ke.cols,rows:ke.rows}})}catch(rr){if(!(rr instanceof r)||rr.code!=="job_input_backpressure")throw rr;G-=1,R.unshift(ke),M+=$o(ke),Ke=!0;continue}if(z.inputSequence!==Me)ar("job_input_sequence")}else if(await new Promise((Me)=>{let rr=setTimeout(Me,Ke||!Be?10:50);if(S=()=>{clearTimeout(rr),Me()},w.signal.aborted||!Ke&&R.length)S()}),Ke=!1,S=()=>{},!w.signal.aborted&&Be)try{z=await qe({jobId:l.jobId,action:"inspect",input:{after:F}})}catch(Me){if(!J||!(Me instanceof r)||Me.code!=="cancelled")throw Me}}}catch(le){ve??=le}finally{if(re=!1,R.length=0,clearTimeout(W),e.signal.removeEventListener("abort",x),x(),D&&(!z||!ht(z)))try{z=await De()}catch{z=void 0}try{if(!z||!ht(z)||z.pty?.cleanup!=="confirmed")ar("pty_cleanup_unconfirmed");let le=Re(z);if(_.readyState===Rn.OPEN)await new Promise((he)=>{let xe=setTimeout(he,500);_.send(JSON.stringify({t:"exit",code:z.exitCode,receipt:le}),()=>{clearTimeout(xe),he()})});await Ve("pty.stopped",le)}catch(le){ve??=le}_.terminate()}if(ve)throw ve;if(e.signal.aborted)ar("cancelled");if(!z)ar("pty_cleanup_unconfirmed");return{receipt:Re(z)}}import{createHash as Ti,randomUUID as An}from"crypto";import{spawnSync as es}from"child_process";import{closeSync as Jo,constants as On,fstatSync as Di,fsyncSync as Ci,lstatSync as Ht,mkdirSync as Hi,mkdtempSync as rs,openSync as Xo,readFileSync as Ni,readdirSync as ts,realpathSync as Vr,rmSync as Pn,unlinkSync as Li}from"fs";import{createConnection as Bi}from"net";import{dirname as Wi,join as ot,sep as In}from"path";import{tmpdir as ns}from"os";var hr=new Map,Jr=new Map;function Ur(e,l){return Ti("sha256").update(JSON.stringify([e,l])).digest("hex")}function gt(e){try{Hi(e,{mode:448})}catch(f){if(!(f instanceof Error&&("code"in f)&&f.code==="EEXIST"))throw f}let l=Ht(e);if(!l.isDirectory()||l.isSymbolicLink()||!A(l)||Vr(e)!==e)throw new r("hands_jobs_unavailable","Hands job state must be a private canonical directory.")}function zi(e){let l;try{l=Ht(e)}catch(f){if(f instanceof Error&&"code"in f&&f.code==="ENOENT")return!1;throw f}return!l.isDirectory()||l.isSymbolicLink()||ts(e).length>0}function Ki(e){if(process.platform==="win32")return Ui();let l=e.map((f)=>{try{return Vr(f)}catch{return f}});for(let f of[()=>Ui(),()=>Vr("/dev/shm"),()=>Vr(ns())]){let _;try{_=f()}catch{continue}if(!l.some((w)=>_===w||_.startsWith(w.endsWith(In)?w:w+In)))return _}throw new r("invalid_hands_workspace","A Session can't work in this computer's temporary folder itself; start it in a project folder inside it.")}function gr(e){let l=Ur(e.root,e.runId),f=e.previousRuntimeDirectories?.find((x)=>zi(ot(x,"jobs",l.slice(0,16))))??e.runtimeDirectory;gt(f);let _=ot(f,"jobs");gt(_);let w=ot(_,l.slice(0,16));if(e.maxScopes!==void 0){let x=ts(_);if(!Number.isSafeInteger(e.maxScopes)||e.maxScopes<1||x.length>e.maxScopes||!x.includes(l.slice(0,16))&&x.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.")}gt(w);let S=rs(ot(Ki(e.folders??[]),"reason-j-"));try{return gt(S),{journalDirectory:w,scopeId:l,launchDirectory:S,socketPath:process.platform==="win32"?`\\\\.\\pipe\\reason-jobs-${An()}`:ot(S,"control.sock"),disposeSocket:()=>Pn(S,{recursive:!0,force:!0})}}catch(x){throw Pn(S,{recursive:!0,force:!0}),x}}var Gi=60000,Ji=5000;function Vi(e){if(process.platform==="win32")return qi(e);let l=es("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,_=f?"JanFebMarAprMayJunJulAugSepOctNovDec".indexOf(f[1]):-1;if(!f||_<0||_%3!==0)return null;let w=new Date(Number(f[6]),_/3,Number(f[2]),Number(f[3]),Number(f[4]),Number(f[5])).getTime();return Number.isFinite(w)?w:null}function qi(e){let l=es(C("powershell"),["-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${e}).StartTime.ToUniversalTime().ToString('o')`],{encoding:"utf8",timeout:5000,windowsHide:!0,env:Oe()}),f=l.status===0?Date.parse(l.stdout.trim()):Number.NaN;return Number.isFinite(f)?f:null}function os(e,l={}){let f=ot(e.journalDirectory,"owner.lock"),_;try{_=Xo(f,On.O_RDONLY|On.O_NOFOLLOW)}catch{return null}try{let w=Di(_);if(!w.isFile()||w.nlink!==1||!A(w)||w.size>4096)return null;let S=null;try{S=JSON.parse(Ni(_,"utf8"))}catch{}let x;if(S===null){if((l.now??Date.now)()-w.mtimeMs<Gi)return null;x={reason:"never_written",executorLaunchId:null}}else{let{version:M,scopeId:G,pid:F,createdAtMs:D,executorLaunchId:re}=S;if(M!==1||G!==e.scopeId||typeof re!=="string"||typeof F!=="number"||!Number.isSafeInteger(F)||F<1||F===process.pid||typeof D!=="number"||!Number.isSafeInteger(D))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))x={reason:"owner_exited",executorLaunchId:re};else{let z=(l.startedAtMs??Vi)(F);if(z===null||z<=D+Ji)return null;x={reason:"pid_reused",executorLaunchId:re}}}let W=Ht(f);if(W.dev!==w.dev||W.ino!==w.ino)return null;Li(f);let R=Xo(e.journalDirectory,On.O_RDONLY);try{Ci(R)}finally{Jo(R)}return x}catch{return null}finally{Jo(_)}}function ss(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=Ur(l.root,l.runId);if(hr.has(f)||l.operationId!==void 0&&Jr.has(l.operationId))throw new r("hands_jobs_busy","The Session already has a live Hands job supervisor.");let _={binding:l,key:f,terminals:new Map};if(l.previewAuthority&&l.environment)_.previews=Fo({authority:l.previewAuthority,runId:l.runId,expiresAtMs:l.expiresAtMs,executorLaunchId:l.executorLaunchId,environment:l.environment,isCurrent:()=>hr.get(_.key)===_,identity:()=>{try{return bt(l)}catch{return null}},inspect:(w,S)=>{if(hr.get(_.key)!==_)throw new r("preview_unavailable","The Hands supervisor is no longer current.");return is(l,{jobId:w,action:"inspect",input:{after:0}},S)}});if(hr.set(f,_),l.operationId!==void 0)Jr.set(l.operationId,_);return()=>{if(hr.get(_.key)===_)hr.delete(_.key);if(l.operationId!==void 0&&Jr.get(l.operationId)===_)Jr.delete(l.operationId);_.previews?.dispose();for(let w of _.terminals.values())w.abort()}}var Yi=5000,Xi=20;async function to(e){let l=(w)=>{throw new r("hands_rebind_unavailable",w)};if(!N(e.operationId)||!N(e.runId)||!N(e.fenceId)||!H(e.targetGeneration))l("Reason sent an invalid Hands rebind.");let f=Jr.get(e.operationId);if(!f||f.binding.root!==e.root)return l("No live Hands supervisor owns this operation.");for(let w=Date.now()+Yi;;){if(e.signal?.aborted)l("The Hands rebind was cancelled.");if(Jr.get(e.operationId)!==f)l("The Hands supervisor is no longer current.");let S=null;try{S=bt(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((x)=>setTimeout(x,Xi))}if(Jr.get(e.operationId)!==f||hr.get(f.key)!==f)l("The Hands supervisor is no longer current.");let _=Ur(e.root,e.runId);if(f.key===_)return;if(hr.has(_))l("The taking run already has a live Hands job supervisor.");hr.delete(f.key);for(let w of f.terminals.values())w.abort();f.key=_,hr.set(_,f)}function at(e){let l="operationId"in e?Jr.get(e.operationId):hr.get(Ur(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 ro(e){let l=hr.get(Ur(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 no(e){let l=hr.get(Ur(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 io(e){let l=Ur(e.root,e.runId),f=hr.get(l),_=f?.binding,w=_?.runId,S=_?.previewAuthority,x=_?.environment,W=e.owner&&{...e.owner},R=e.authority&&{...e.authority},M=()=>{throw new r("pty_binding_unavailable","No current authenticated Hands scope owns this terminal.")};if(!f||!_||!S||!x||!W||!R||!_.workspace)return M();let G=Object.freeze({..._.workspace}),F=bt(_),D=x.current(),re=()=>{if(hr.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||I(e.workspace)!==I(G))M();let z=bt(_),fe=x.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!==D.snapshot_id||fe.revision!==D.revision||fe.binding.target_generation!==F.generation||fe.binding.target_fence_id!==F.fenceId||R.device_id!==e.deviceId||R.binding!==fe.binding.kind||R.target_revision!==fe.binding.target_revision||R.root_grant_revision!==fe.binding.root_grant_revision||R.target_generation!==F.generation||R.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 Go({session:{...e.session,leaseExpiresAtMs:Math.min(e.session.leaseExpiresAtMs,F.expiresAtMs,Date.parse(D.expires_at))},signal:AbortSignal.any([e.signal,J.signal]),emit:e.emit,binding:{assertCurrent:re,environment:{revision:D.revision,snapshotId:D.snapshot_id},scope:{runId:e.runId,deviceId:e.deviceId,rootId:e.rootId,workspace:G,binding:D.binding.kind,targetRevision:D.binding.target_revision,rootGrantRevision:D.binding.root_grant_revision,generation:F.generation,fenceId:F.fenceId,executorLaunchId:F.executorLaunchId},request:(z,fe)=>_r(F,zr(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 oo(e){if(ce(e.payload.jobId))throw new r("pty_binding_required","PTY jobs require the bound terminal capability.");let l=hr.get(Ur(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 is(l,e.payload,e.signal)}var Zi=1e4,Qi=20,ea=Se/2,ra=Je/2,ta=(e)=>e.output.reduce((l,f)=>l+f.text.length,0);async function is(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:_,...w}=l;if(_!==void 0&&(w.action!=="start"||typeof w.input!=="object"||w.input===null||!("script"in w.input)||typeof _!=="number"||!Number.isSafeInteger(_)||_<1||_>Zi))throw new r("invalid_payload","Only a script start may wait for its job, within its bound.");let S=(M)=>{let G=bt(e);return _r(G,zr(JSON.stringify({...M,type:"job",version:2,generation:G.generation,id:An()})),f)},x=await S(w);if(_===void 0)return x;let W=Date.now()+_,R=x;while(R.ok&&["starting","running"].includes(R.job.state)&&R.job.output.length<ea&&ta(R.job)<ra&&!f.aborted&&Date.now()<W){if(await new Promise((M)=>setTimeout(M,Math.min(Qi,W-Date.now()))),f.aborted)break;try{let M=await S({jobId:w.jobId,action:"inspect",input:{after:0}});if(!M.ok)break;R=M}catch{break}}return R}function bt(e){if(e.expiresAtMs<=Date.now())throw new r("hands_jobs_unavailable","Hands authority expired.");let l=e.readIdentity?e.readIdentity():e;if(!l||!H(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 _r(e,l,f){if(f.aborted)return Promise.reject(new r("cancelled","Job control was cancelled."));return new Promise((_,w)=>{let S=Bi(e.socketPath),x="",W=!1,R,M=(F,D)=>{if(W)return;if(W=!0,clearTimeout(R),f.removeEventListener("abort",G),S.destroy(),F)w(F);else _(D)},G=()=>M(new r("cancelled","Job control waiter cancelled; inspect before retrying mutations."));f.addEventListener("abort",G,{once:!0}),S.setEncoding("utf8"),R=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(x+=F,Buffer.byteLength(x)>Xe)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=qr(x.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 Zo(e){let l=Vr(e.root),f=e.authority,_=Date.parse(e.leaseUntil),w=()=>{if(e.signal.throwIfAborted(),!Number.isFinite(_)||_<=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:_,assertCurrent:w};let S=Ur(l,e.runId),x=hr.get(S),W=x?.binding;if(!W?.environment||!W.workspace||W.localGithubConfinement!==!0)throw Error("local_device_gh_confinement_unavailable");let R=W.environment.current(),M=()=>{w();let F=W.environment.current(),D=bt(W);if(hr.get(S)!==x||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||D.generation!==f.generation||D.fenceId!==f.fenceId||F.snapshot_id!==R.snapshot_id||F.revision!==R.revision)throw Error("local_device_gh_authority_changed")};M();let G=ie(l,W.workspace);return{root:G.boundary,signal:e.signal,deadlineMs:_,privateDirectory:Wi(W.environment.path),repoPath:G.path,readOnly:f.readOnly,forbiddenSecretValues:Object.values(R.variables),secretNames:(F)=>Object.entries(R.variables).filter(([,D])=>D.trim()===F.trim()).map(([D])=>`variable ${D}`),assertCurrent:M}}async function so(e,l){let f=Pe.parse(e.request),_=oe.parse(e.authority);if(_.contributorRefresh&&f.kind==="read"&&_.readOnly)return l(Zo(e));let w=Boolean(_.contributorRefresh);if(w&&(_.merge||f.kind!=="pr_mutation"||f.mutation.action!=="edit"||typeof f.mutation.body!=="string"||f.mutation.title!==void 0||f.mutation.base!==void 0||_.readOnly||_.runId!==e.runId||_.repoFullName!==f.repoFullName))throw Error("local_device_gh_contributor_refresh_authority_invalid");if(f.kind!=="pr_merge"&&!w){if(_.merge)throw Error("local_device_gh_merge_authority_invalid");return l(Zo(e))}if(!w&&(!_.merge||_.readOnly||_.runId!==e.runId||_.repoFullName!==f.repoFullName||_.merge.source==="agent"&&(_.generation===null||_.fenceId===null)))throw Error("local_device_gh_merge_authority_invalid");let S=Vr(e.root),x=Ht(S),W=Date.parse(e.leaseUntil);if(!Number.isFinite(W)||W<=Date.now())throw Error("local_device_gh_lease_expired");let R=Vr(ns());if(R===S||R.startsWith(S+In))throw Error("local_device_gh_private_scope_unavailable");let M=rs(ot(R,"reason-gh-merge-"));try{gt(M);let G=()=>{if(e.signal.throwIfAborted(),Date.now()>=W)throw Error("local_device_gh_lease_expired");let F=Ht(e.root);if(F.isSymbolicLink()||F.dev!==x.dev||F.ino!==x.ino||Vr(e.root)!==S)throw Error("local_device_gh_authority_changed");gt(M)};return G(),await l({root:S,readOnly:!1,privateDirectory:M,forbiddenSecretValues:[],signal:e.signal,deadlineMs:W,assertCurrent:G})}finally{Pn(M,{recursive:!0,force:!0})}}var ds=43200000;function wt(e){return Number.isSafeInteger(e)&&Math.abs(e)<=8640000000000000?e:null}function as(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function cs(e,l){return Object.keys(e).length===l.length&&l.every((f)=>Object.hasOwn(e,f))}function ao(e){if(!as(e)||!cs(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 _ of["validation_now_ms","expiry_ms"]){let w=e[_];if(w!==null&&(typeof w!=="number"||wt(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(!as(f)||!cs(f,["kind","status","sha256","observed_at_ms"])||f.observed_at_ms!==null&&(typeof f.observed_at_ms!=="number"||wt(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()}),ls=new RegExp(lt.tokenPattern),na=c({token_url:At().max(2048),request_token:t().min(1).max(8192).regex(ls),aws_credentials_url:At().max(2048).nullable()});function us(e,l){let f=(_,w)=>{try{let S=new URL(_);return S.origin===new URL(l).origin&&S.pathname===w&&!S.username&&!S.password&&!S.search&&!S.hash}catch{return!1}};if(!ls.test(e.request_token)||!f(e.token_url,lt.tokenPath)||e.aws_credentials_url!==null&&!f(e.aws_credentials_url,lt.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 fs(e){return new TextEncoder().encode(e).byteLength}function oa(e){return fs(JSON.stringify(e)+`
|
|
4
4
|
`)}var yr=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(Lt),t().refine((e)=>!e.includes("\x00")&&fs(e)<=V.valueBytes)).refine((e)=>Object.keys(e).length<=V.variables),github_auth:n("local_gh").optional(),git:c({base_url:At().max(2048),token:t().min(1).max(4096).regex(/^[A-Za-z0-9._~-]+$/),expires_at:y.datetime({offset:!0})}).nullable(),cloud_access:na.optional()}).refine((e)=>e.github_auth!=="local_gh"||e.git===null,"conflicting git authority").refine((e)=>oa(e)<=V.snapshotBytes,"snapshot too large");import{spawn as sa}from"child_process";import{basename as ia,isAbsolute as Iu}from"path";var aa=0,ps=120000,_s=15000,ca=65536;function Dn(e=process.execPath,l=process.argv[1]){let f=ia(e),_=(f.startsWith("bun")||f.startsWith("node"))&&typeof l==="string"&&l.length>0;return{command:e,prefix:_?[l]:[]}}function co(e={}){let{command:l,prefix:f}=Dn(e.executablePath,e.sourceEntrypoint),_=e.spawnProcess??sa,w=e.now??Date.now,S=null,x=0,W=!1,R=(G)=>{try{G.kill("SIGKILL")}catch{}},M=()=>{if(W)return;if(S&&w()-x<ps-_s)return;if(S){let F=S;S=null,R(F)}let G;try{G=_(l,[...f,"__device","__hands-worker","--handoff-fd",String(aa)],{cwd:"/",env:{PATH:process.env.PATH??"/usr/local/bin:/usr/bin:/bin"},shell:!1,stdio:["pipe","ignore","pipe"]})}catch{return}S=G,x=w(),G.on("error",()=>{if(S===G)S=null}),G.once("exit",(F,D)=>{if(S!==G)return;S=null,e.log?.("hands.worker_prespawn_exited",{exit_code:F,exit_signal:D})}),e.log?.("hands.worker_prespawned",{pid:G.pid??null})};return{arm:M,take(G){let F=S;if(!F||W)return null;let D=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 D!=="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,ve={configPath:D,cwd:J,env:Object.fromEntries(Object.entries(re).filter((Re)=>typeof Re[1]==="string"))},be=JSON.stringify(ve);if(F.exitCode!==null||F.signalCode!==null||!fe||fe.destroyed||w()-x>=ps-_s||Buffer.byteLength(be,"utf8")>ca)return R(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)R(S);S=null}}}import{accessSync as _a,constants as ma,statSync as ha}from"fs";import{homedir as ga,tmpdir as ba,userInfo as wa}from"os";import{delimiter as ya,win32 as va}from"path";var da=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 la=["BUN_CONFIG_","BUN_INSPECT","DYLD_","NODE_DEBUG"],ua=new Set(["BUN_INSTALL"]);var fa=/^--(?:max-old-space-size|max-semi-space-size|stack-size)=\d{1,9}$/;function pa(e){return(e??"").split(/\s+/).filter(Boolean).every((l)=>fa.test(l.replaceAll("_","-")))}function ms(e){return Object.keys(e).filter((l)=>da.has(l)&&!(l==="NODE_OPTIONS"&&pa(e[l]))||la.some((f)=>l.startsWith(f))||l.startsWith("BUN_")&&!ua.has(l)).sort()}var ka=new Set(["HOME","PATH","PWD","OLDPWD","SHLVL","_","TMPDIR","TMP","TEMP","SHELL","BASH_ENV","ENV","ZDOTDIR","PROMPT_COMMAND","IFS","CDPATH","GLOBIGNORE","SHELLOPTS","BASHOPTS","NODE_PATH"]),Sa=/^(?:ARA_|REASON_|PI_|GIT_|GH_|GITHUB_|LD_|DYLD_|BUN_|BASH_FUNC_|SSH_)/,Ea=/TOKEN|SECRET|PASSW|PASSPHRASE|CREDENTIAL|API_?KEY|ACCESS_?KEY|PRIVATE_?KEY|AUTH/i,Ra=/^[A-Za-z_][A-Za-z0-9_]*$/;function wr(e=process.env){let l=(w)=>{if(!(process.platform==="win32"?va.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(ms(e)),_=Object.fromEntries(Object.entries(e).filter((w)=>{let[S,x]=w;return typeof x==="string"&&x.length<=32768&&!x.includes("\x00")&&S.length<=128&&Ra.test(S)&&!f.has(S)&&!ka.has(S)&&!Sa.test(S)&&!Ea.test(S)}).sort(([w],[S])=>w.localeCompare(S)).slice(0,512));return{home:l(e.HOME||(process.platform==="win32"?e.USERPROFILE:void 0)||ga()),path:((w)=>process.platform==="win32"?kn(w):w)(Ar(e.PATH??"").join(ya)||Cr),temporaryDirectory:l(e.TMPDIR||e.TMP||e.TEMP||ba()),variables:_}}function br(e=process.env,l=()=>wa().shell){if(process.platform==="win32")return se();let f=(w)=>{if(!w||!/^\/[A-Za-z0-9._/-]*\/(?:bash|zsh)$/.test(w))return!1;try{return _a(w,ma.X_OK),ha(w).isFile()}catch{return!1}};if(f(e.SHELL))return e.SHELL;let _;try{_=l()}catch{_=void 0}return f(_)?_:"/bin/zsh"}import{readdir as Oa}from"fs/promises";var xa=15000;function wn(e){let l=e instanceof Error&&"code"in e?e.code:null;return l==="EPERM"||l==="EACCES"}function bn(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 restart the Reason app or worker on this Mac and try again: until it restarts it keeps the earlier refusal.")}async function hs(e,{timeoutMs:l=xa,open:f=(_)=>Oa(_)}={}){let _,w=new Promise((S)=>{_=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(wn(S))throw bn(e);if(S instanceof r)throw S}finally{clearTimeout(_)}}import{chmodSync as sc,closeSync as ic,constants as zn,fstatSync as ac,lstatSync as Ns,openSync as cc,readSync as dc,realpathSync as $n,unlinkSync as lc}from"fs";import{lookup as uc}from"dns/promises";import{createRequire as fc}from"module";import{request as pc}from"http";import{request as _c}from"https";import it from"net";import{platform as Ws}from"os";import{basename as mc,extname as hc,isAbsolute as Ls,relative as Gn,resolve as kt,sep as Jn}from"path";var gs=String.raw`
|
|
5
5
|
async (roots) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{S,Wt,Bn,Ge,Fn,jn}from"./vm-hands-entry-lite-k9vk84wa.js";import{Zn}from"./vm-hands-entry-lite-
|
|
2
|
+
import{S,Wt,Bn,Ge,Fn,jn}from"./vm-hands-entry-lite-k9vk84wa.js";import{Zn}from"./vm-hands-entry-lite-qw97ene9.js";import{Ln}from"./vm-hands-entry-lite-ct4mtq1m.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFile as ys,spawn as qe}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 Pn,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",go="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,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{U}from"./vm-hands-entry-lite-a0g6c3wr.js";import{O,T,b}from"./vm-hands-entry-lite-4r1yn35v.js";import{je,gr,_r,Sn,En,ct}from"./vm-hands-entry-lite-
|
|
2
|
+
import{U}from"./vm-hands-entry-lite-a0g6c3wr.js";import{O,T,b}from"./vm-hands-entry-lite-4r1yn35v.js";import{je,gr,_r,Sn,En,ct}from"./vm-hands-entry-lite-10b4f71g.js";import{$r}from"./vm-hands-entry-lite-cgddp0y3.js";import{p,ut,An,_e,we}from"./vm-hands-entry-lite-2hfrcr50.js";import{v,h}from"./vm-hands-entry-lite-hfx1q0b0.js";import{a,nr,Wo}from"./vm-hands-entry-lite-jvszqt0z.js";import{an,y,t,k,o,d,ms,Ie,Bi,u,i,W,g,ee,s,n,cn}from"./vm-hands-entry-lite-ztsp4gs8.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{se,A}from"./vm-hands-entry-lite-b6gsggvp.js";import{randomUUID as Q}from"crypto";import{spawn as Le}from"child_process";import{existsSync as Z,lstatSync as me,mkdirSync as We,readFileSync as Ne,realpathSync as G,rmSync as Ve,writeFileSync as He}from"fs";import{dirname as Ue,join as j,relative as qe,sep as Je}from"path";var Se=["process.run.v1","process.full.v1"],xe=600000,Pe=1800000,Ee=20000,ne="process.cancel.v1",ie=i({action:n("start"),request_id:t().uuid(),command:t().min(1).max(16000).refine((e)=>!e.includes("\x00")),cwd:t().min(1).max(4096).refine((e)=>!e.includes("\x00")&&!e.startsWith("/")&&!e.split(/[\\/]/).includes("..")).describe("Path relative to the granted device root; omit to use that root. Must not start with /, contain a .. path segment, or contain a NUL character.").optional(),mode:s(["host","confined"]).default("host"),timeout_ms:o().int().min(1000).max(Pe).default(xe).describe("Absolute process budget including queue and startup time. Defaults to ten minutes; longer explicit requests require the selected root's advertised max_timeout_ms. Retrying never renews the deadline.")}).strict(),K={device_id:t().uuid(),root_id:t().uuid()},Re=g("action",[ie.extend(K),i({...K,action:n("inspect"),process_id:t().uuid(),after:o().int().min(0).default(0),wait_ms:o().int().min(0).max(Ee).default(0).describe("Wait for new output or a state change, bounded by this call's wait budget. Expiring this wait does not cancel the process or extend its deadline.")}).strict(),i({...K,action:n("cancel"),process_id:t().uuid()}).strict()]),Fe=an(Re,{io:"input"}),Ke=ie.extend({process_brain_fence:t().uuid(),process_expires_at:y.datetime()}).strict(),J=i({version:n(1),process_id:t().uuid(),state:s(["starting","running","exited","cancelled","expired","uncertain"]),exit_code:o().int().nullable(),first_cursor:o().int().min(0),next_cursor:o().int().min(0),truncated:d(),observed_at:y.datetime(),output:u(i({cursor:o().int().min(1),stream:s(["stdout","stderr"]),text:t().max(32768)}).strict()).max(128)}).strict().refine((e)=>{if(Buffer.byteLength(JSON.stringify(e))>1e5||e.next_cursor<e.first_cursor-1)return!1;if((e.state==="starting"||e.state==="running"||e.state==="uncertain")&&e.exit_code!==null)return!1;if(e.state==="exited"&&(e.exit_code===null||e.exit_code<0||e.exit_code>255))return!1;if(e.state==="cancelled"&&e.exit_code!==130||e.state==="expired"&&e.exit_code!==124)return!1;let _=e.first_cursor-1;for(let l of e.output){if(l.cursor<=_||l.cursor>e.next_cursor)return!1;_=l.cursor}return!0});function ae(e){return Se.includes(e)}var Xe=i({operation_constraints:ee(t(),Ie())}),Ye=i({ready:n(!0),version:n(1),execution_mode:s(["host","confined"]),max_timeout_ms:o().int().min(1000).optional()});var De=i({version:n(1),process_id:t().uuid(),state:s(["queued","cancelled_before_start","not_started"]),exit_code:ms(),output:u(Bi()).length(0),first_cursor:n(0),next_cursor:n(0),truncated:n(!1),cancellation_requested:n(!1),reason_code:s(["cancelled_before_start","process_journal_capacity","path_not_found","process_timeout_unsupported"]).optional(),expires_at:y.datetime().optional().describe("Accepted absolute process deadline. Reading, waiting and retrying do not extend it.")}).strict(),Ce=i({...J.shape,state:s(["queued","starting","running","exited","cancelled","expired","uncertain","cancelled_before_start","not_started"]),observed_at:y.datetime().optional(),expires_at:y.datetime().optional().describe("Accepted absolute process deadline. Reading, waiting and retrying do not extend it."),cancellation_requested:d(),reason_code:t().nullable().optional(),execution_authority:n("lost").optional().describe("Historical receipt only; the current Brain cannot control this older-generation process."),recovery:i({cause:n("brain_generation_changed"),terminal_confirmed:d(),next_step:s(["inspect_until_terminal","reconcile_effects_before_new_intent"])}).strict().optional().describe("Historical process recovery only. An unconfirmed outcome forbids replay. A confirmed terminal observation proves the old process stopped, not that its command had no effects. Reconcile the result; only restart still-needed, safely repeatable work with a new request_id and current authority. Respect user cancellation."),last_observed_state:J.shape.state.or(n("cancelled_before_start")).nullable().optional().describe("Last saved observation before authority was lost; a running observation does not establish current child liveness.")}).strict(),$e=an(Ce),Qe=W([J,De.refine((e)=>e.state==="cancelled_before_start")]),X=i({version:n(1),process_id:t().uuid(),state:s(["exited","cancelled","expired"]),exit_code:o().int().min(0).max(255),observed_at:y.datetime()}).strict().refine((e)=>(e.state!=="cancelled"||e.exit_code===130)&&(e.state!=="expired"||e.exit_code===124)),Ze=i({process_terminal_observation:X}).strict();var Xi="preview.serve.v1",Yi=43200000;var ce="preview.open.v1",de=1,_n="gid_proxy_v1",Zi="egress",yn=/^(?:\*\.)?[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[1-9][0-9]{0,4})?$/,Ae=i({version:n(_n),allowed_domains:u(t().max(260).regex(yn)).max(1024)}).strict(),ke=cn((e)=>U(e)!==null,"invalid workspace"),Oe=i({version:n(1),request_id:k(),session_id:k(),command:t().min(1).max(16000).refine((e)=>!e.includes("\x00")),port:o().int().min(1024).max(65535),workspace:ke,egress:Ae.optional()}).strict(),Qi=Oe.extend({expires_at:y.datetime()}).strict();var Me=4,Te=5000;function Y(e,c,_){let l=null;try{l=ut(e)}catch{}An({deviceRelayUrl:l?.deviceRelayUrl??"",binding:l?.binding??null,jobId:c,port:l?.binding.port??0,reason:l?_:"binding_invalid"})}function le(e){let c=new Map;return{open(_){let l=(x)=>Y(_,e.claim.operation_id,x),I;try{I=ut(_)}catch{return l("binding_invalid")}let{binding:w,deviceRelayUrl:z}=I,E=e.claim.owner;if(!E||w.organizationId!==E.organization_id||w.userId!==E.user_id||w.deviceId!==E.device_id||w.rootId!==e.claim.root_id||w.jobId!==e.claim.operation_id||w.fenceId!==e.claim.operation_id||w.generation!==de||w.expiresAtMs>Math.min(Date.now()+p.lifetimeMs+Te,e.expiresAtMs))return l("binding_mismatch");if(w.expiresAtMs<=Date.now())return l("binding_expired");if(c.get(w.port)?.abort(),c.delete(w.port),c.size>=Me)return l("preview_capacity");let L=new AbortController;c.set(w.port,L);let P=we({binding:w,deniedPorts:e.deniedPorts,readCurrentJob:async()=>{if(L.signal.aborted)return null;let x=await e.inspect();return x?{binding:w,executorLaunchId:e.executorLaunchId,job:x}:null}});_e({binding:w,deviceRelayUrl:z,port:P,signal:L.signal}).then((x)=>x.closed,(x)=>{let R=x instanceof Error?x.message:"preview_failed";if(R!=="preview_not_authorized")process.stderr.write(`${JSON.stringify({event:"worker_preview.open_failed",job_id:w.jobId,port:w.port,reason_code:R})}
|
|
3
3
|
`)}).finally(()=>{if(c.get(w.port)===L)c.delete(w.port)})},dispose(){for(let _ of c.values())_.abort();c.clear()}}}class st extends r{observation;constructor(e){super("process_authority_lost","Process authority was lost; the owned process group has stopped.");this.observation=e}}var fe=256,B=new Map,he="preview.serve.v1",V=new Map;function be(e){let c=V.get(e.operation_id);if(c){if(c.claim!==e)throw C("process_authority_lost");return c}if(V.size>=fe)throw C("process_journal_capacity");let _={claim:e,executing:!1,cancelRequested:!1,phase:"pending"};return V.set(e.operation_id,_),_}function pe(e){return{version:1,process_id:e,state:"cancelled_before_start",exit_code:null,output:[],first_cursor:0,next_cursor:0,truncated:!1,cancellation_requested:!1,reason_code:"cancelled_before_start"}}var ue=(e)=>new Promise((c)=>setTimeout(c,e)),C=(e="process_outcome_uncertain")=>new r(e,"The managed process outcome could not be confirmed; inspect its saved receipt before starting another intent.");function ze(e=a(),c=Ge()){let _=Ue($r({},e)),l=qe(nr(e),_),[I,...w]=l.split(Je);return{directory:j(c,l,"processes"),previous:[j(_,"processes"),...I==="reason"?[j(c,"ara",...w,"processes")]:[]]}}function Ge(){if(process.platform!=="darwin")throw new r("process_unavailable","Managed Mac process execution is unavailable.");let e=Wo();if(!e)throw new r("process_unavailable","The private per-user process directory is unavailable.");return e}async function fr(e){if(!e.claim.owner||e.signal.aborted||e.expiresAtMs<=Date.now())throw C("process_authority_lost");let c=be(e.claim);if(c.executing)throw C("process_busy");if(c.executing=!0,c.cancelRequested)return c.phase="settling",pe(e.claim.operation_id);c.phase="starting";let _=e.journals??ze();We(_.directory,{recursive:!0,mode:448});let l=gr({runtimeDirectory:G(_.directory),previousRuntimeDirectories:(_.previous??[]).filter((m)=>Z(m)).map((m)=>G(m)),root:e.root,runId:JSON.stringify([e.claim.owner,e.claim.run_id,e.claim.root_id,e.claim.operation_id]),maxScopes:fe,folders:[e.root,e.cwd]});try{for(let m of[e.root,e.cwd])if(!je(G(m),l.journalDirectory))throw new r("process_journal_inside_workspace","The selected root contains the private process journal. Select an existing narrower granted workspace root outside the journal; no command was dispatched.")}catch(m){throw l.disposeSocket(),m}let I=me(l.journalDirectory),w=e.claim.capability===he,z=()=>B.set(e.claim.operation_id,{path:l.journalDirectory,ino:I.ino,dev:I.dev,anyCompletion:w}),E=l.launchDirectory,L=j(E,"config.json"),P={url:"",transport:"local_job_ipc",directShell:{mode:e.mode,executable:e.shell,jobId:e.claim.operation_id},workerVersion:O,protocolVersion:2,workerArtifactSha256:b,workerEntrypoint:T,targetGeneration:1,fenceId:Q(),...process.platform==="win32"?{bashExecutable:se()}:{},workRoot:e.root,workspaceAliasPath:e.root,repoPath:e.cwd,jobEnvPath:j(E,"unused.env"),replSocketPath:j(E,"unused.sock"),readyPath:j(E,"ready.json"),directTerminalReceiptPath:j(E,"terminal.json"),launchId:Q(),expiresAtMs:e.expiresAtMs+5000,bashTimeoutMs:60000,replTimeoutMs:1000,allowedTools:["bash"],managedJobs:{journalDirectory:l.journalDirectory,scopeId:l.scopeId},jobControlSocketPath:l.socketPath,...e.prefix?{bashCommandPrefix:e.prefix}:{},...e.jobsUser?{jobsUser:e.jobsUser}:{}},x;try{He(L,JSON.stringify(P),{mode:384});let m=Sn({configPath:L,root:e.cwd,grantedRoot:e.root,workRoot:e.root,temporaryDirectory:E});x=e.spawnWorker?.(L,P)??Le(m.command,m.args,{...m.options,env:e.environment,stdio:[En,"ignore","ignore"]})}catch(m){throw l.disposeSocket(),m}let R=!1,F=new Promise((m,S)=>{x.once("exit",(f)=>{R=!0,m(f)}),x.once("error",(f)=>{R=!0,S(f)})});F.catch(()=>{});let ge={root:e.root,runId:e.claim.run_id,scopeId:l.scopeId,socketPath:l.socketPath,generation:1,fenceId:P.fenceId,executorLaunchId:P.launchId,expiresAtMs:P.expiresAtMs},N=async(m)=>{let S=await _r(ge,{type:"job",version:2,generation:1,id:Q(),jobId:e.claim.operation_id,...m==="start"?{action:m,input:{script:e.command,leaseExpiresAtMs:e.expiresAtMs}}:m==="inspect"?{action:m,input:{after:0}}:m==="probe"?{action:"inspect",input:{after:Number.MAX_SAFE_INTEGER}}:{action:m,input:{}}},new AbortController().signal);if(!S.ok)throw C(S.error);return S.job},H=!1,q=!1,te,re=()=>{H=!0,ct(x,"SIGTERM")};e.signal.addEventListener("abort",re,{once:!0});let M,oe=0,ve=async(m)=>{let S=[...m.output],f={version:1,process_id:e.claim.operation_id,state:m.state,exit_code:m.exitCode,first_cursor:m.firstCursor,next_cursor:m.nextCursor,truncated:m.truncated,output:S,observed_at:new Date().toISOString()};while(Buffer.byteLength(JSON.stringify(f))>90000&&S.length)S.shift(),f.truncated=!0,f.first_cursor=S[0]?.cursor??f.next_cursor+1;M=J.parse(f),await e.emit(M),oe=Date.now()};try{let m=Math.min(Date.now()+1e4,e.expiresAtMs);while(!Z(P.readyPath)){if(R)throw new r("process_start_failed","The managed process supervisor exited before accepting a command; no command was dispatched.");if(e.signal.aborted||Date.now()>=m)throw C("process_start_unconfirmed");await ue(25)}let S=JSON.parse(Ne(P.readyPath,"utf8"));if(S.launchId!==P.launchId||S.fenceId!==P.fenceId||S.workerArtifactSha256!==b)throw C();if(e.signal.throwIfAborted(),c.cancelRequested)return pe(e.claim.operation_id);let f;try{q=!0,f=await N("start")}catch(D){if(!(D instanceof r)||D.code!=="hands_job_result_unknown")throw D;f=await N("inspect")}if(c.phase="running",c.cancel=async()=>{await N("cancel")},w&&e.preview)c.tunnels=le({claim:e.claim,executorLaunchId:P.launchId,expiresAtMs:e.expiresAtMs,deniedPorts:e.preview.deniedPorts,inspect:async()=>c.phase==="running"&&!R?await N("probe"):null});if(c.cancelRequested)await c.cancel(),f=await N("inspect");for(;;){if(!["starting","running"].includes(f.state))c.phase="settling",c.cancel=void 0;if(!M||M.state!==f.state||M.next_cursor!==f.nextCursor&&Date.now()-oe>=5000)await ve(f);if(!["starting","running"].includes(f.state))break;if(e.signal.aborted||R)throw C();await ue(1000);try{f=await N("inspect"),te=void 0}catch(D){if(!(D instanceof r)||D.code!=="hands_job_result_unknown"||e.signal.aborted||R||Date.now()-(te??=Date.now())>120000)throw D}}if(!M||M.state==="uncertain")throw C();return M}finally{if(c.phase="settling",c.cancel=void 0,c.tunnels?.dispose(),c.tunnels=void 0,await c.cancelInFlight?.catch(()=>{}),e.signal.removeEventListener("abort",re),!R&&!H)ct(x,"SIGTERM");let m,S=await Promise.race([F.then((f)=>({code:f})),new Promise((f)=>{m=setTimeout(()=>f(null),6000)})]).finally(()=>{clearTimeout(m)});if(!S){try{ct(x,"SIGKILL")}catch{}try{await F}finally{if(R)l.disposeSocket()}throw C("process_cleanup_unconfirmed")}try{if((H||e.signal.aborted)&&S.code===0&&q){v(E);let f=JSON.parse(h(P.directTerminalReceiptPath)),D=X.safeParse(f.observation);if(Object.keys(f).length===4&&f.launch_id===P.launchId&&f.fence_id===P.fenceId&&f.scope_id===l.scopeId&&D.success&&D.data.process_id===e.claim.operation_id){if(w)z();throw new st(D.data)}}}catch(f){if(f instanceof st)throw f}finally{if(R)l.disposeSocket()}if(S.code!==0&&!H&&q)throw C("process_cleanup_unconfirmed");if(!H&&S.code===0&&(M&&["exited","cancelled","expired"].includes(M.state)||!q&&c.cancelRequested)||w&&S.code===0&&!q)z()}}async function js(e,c){if(c.kind===ce&&e.capability===he){let I=V.get(e.operation_id);if(I?.claim===e&&I.tunnels)I.tunnels.open(c.payload);else Y(c.payload,e.operation_id,"server_not_running");return!0}if(c.kind!==ne||!ae(e.capability)||!e.owner||c.payload.process_id!==e.operation_id)return!1;let _=V.get(e.operation_id);if(_&&_.claim!==e)return!1;let l=be(e);if(l.cancelRequested=!0,l.phase==="running"&&l.cancel)l.cancelInFlight??=l.cancel(),await l.cancelInFlight;return!0}function Hs(e,c){V.delete(e);let _=B.get(e);if(!_||c!=="succeeded"&&!_.anyCompletion)return B.delete(e),!1;try{let l=me(_.path);if(!l.isDirectory()||l.isSymbolicLink()||l.ino!==_.ino||l.dev!==_.dev||!A(l)||G(_.path)!==_.path||Z(j(_.path,"owner.lock")))return!1;return Ve(_.path,{recursive:!0}),B.delete(e),!0}catch{return!1}}
|
|
4
4
|
export{Xi,Yi,_n,Zi,yn,Qi,st,fr,js,Hs};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{_,Ho,ke}from"./vm-hands-entry-lite-4anjdcth.js";import{l,Gt,Ke,Lr,Kt,Mr,ht}from"./vm-hands-entry-lite-cgddp0y3.js";import{bt,ar}from"./vm-hands-entry-lite-qc6gxqgs.js";import{fn}from"./vm-hands-entry-lite-
|
|
2
|
+
import{_,Ho,ke}from"./vm-hands-entry-lite-4anjdcth.js";import{l,Gt,Ke,Lr,Kt,Mr,ht}from"./vm-hands-entry-lite-cgddp0y3.js";import{bt,ar}from"./vm-hands-entry-lite-qc6gxqgs.js";import{fn}from"./vm-hands-entry-lite-af11bndd.js";import{B,m,te,He}from"./vm-hands-entry-lite-10b4f71g.js";import{F}from"./vm-hands-entry-lite-2vh94vfz.js";import{Bo}from"./vm-hands-entry-lite-qw97ene9.js";import{xe,Ze,Xn,Vr}from"./vm-hands-entry-lite-jb8m0sm2.js";import{f,v,h}from"./vm-hands-entry-lite-hfx1q0b0.js";import{a}from"./vm-hands-entry-lite-jvszqt0z.js";import{Xo,an,y,t,k,At,o,d,Ie,u,i,c,g,_s,s,n,cn}from"./vm-hands-entry-lite-ztsp4gs8.js";import{closeSync as Uh,existsSync as Fh,mkdirSync as jh,openSync as qh,readdirSync as zh,realpathSync as pe,rmSync as Kh}from"fs";import{dirname as Jh,join as J,resolve as Gh}from"path";import{createHash as It}from"crypto";import{platform as Ot}from"os";import{join as Tt}from"path";var Mt=g("store",[c({version:n(1),store:n("keychain")}),c({version:n(1),store:n("file"),api_key:t().min(1).max(4096)})]),We=(e)=>Tt(e,"api-key.json");function Ne(e){let r=It("sha256").update(`reason-connect-api-key
|
|
3
3
|
${e}`).digest("hex");return new Ke(Gt(),Ot(),r)}function we(e,r=Ne(e)){if(!f(We(e)))return null;let p=Mt.parse(JSON.parse(h(We(e))));if(p.store==="file")return p.api_key;try{let b=r.loadBinding();return b?new TextDecoder().decode(b):null}catch(b){if(!(b instanceof l))throw b;throw Error("worker_api_key_unreadable")}}import{readdirSync as Zt,renameSync as Jo,rmSync as Go}from"fs";import{join as ee}from"path";import{createHash as Wt}from"crypto";import{platform as Nt}from"os";import{join as N}from"path";function w(e){return{state:N(m(e),"device.json"),control:N(m(e),"control.json"),lock:N(m(e),"lifecycle.lock"),socket:N(m(e),"control.sock"),daemon:N(m(e),"daemon.json"),releaseCheck:N(m(e),"release-check.json"),updateDeferral:N(m(e),"update-deferral.json"),firstHeartbeat:N(m(e),"first-heartbeat.json")}}var lo=i({version:n(1),device_id:t().min(1).max(160),offer:Ie().optional(),enrollment_ms:o().int().nonnegative().max(ar).optional()});function z(e,r=!1){v(m(e),r);let p=["local-device.key","local-device.binding","device.json"].filter((b)=>{let R=N(m(e),b);if(!f(R))return!1;return h(R),!0});return e.lifetime==="persistent"&&p.join()==="device.json"?Ht(e):new Lr(m(e))}function Ht(e){return new Ke(Gt(),Nt(),$t(e))}function $t(e){let r=Ft(e);return Wt("sha256").update(`reason-worker
|
|
4
4
|
${r?.directory??m(e)}`).digest("hex")}var Bt="keychain-scope.json";var Ut=c({version:n(1),directory:t().min(1),devicePublicKey:t().min(1)});function Ft(e){let r=N(m(e),Bt);if(!f(r))return null;let p=Ut.safeParse(JSON.parse(h(r))),b=w(e).state;if(!p.success||!f(b))return null;return JSON.parse(h(b))?.devicePublicKey===p.data.devicePublicKey?p.data:null}function M(e){if(!f(m(e)))return null;let r=Mr(w(e).state,{proofStore:z(e),repair:!1}),p=r!==null&&Ho(e.apiOrigin,r.apiOrigin),b=p?[te(e),te({...e,apiOrigin:r.apiOrigin})]:[te(e)];if(r&&(!b.includes(r.worker?.configDigest??"")||r.worker.lifetime!==e.lifetime||r.apiOrigin!==e.apiOrigin&&!p||r.roots.length>32||r.roots[0]?.path!==e.workspaceRoot||r.handsSlots!==e.slots))throw Error("worker_config_binding_mismatch");return r}var jt=c({version:n(1),drained:d(),revoked:d()});function H(e){let r=w(e).control;return f(r)?jt.parse(JSON.parse(h(r))):{version:1,drained:!1,revoked:!1}}var zt=c({read:d(),write:d(),execute:d(),discover_environment:d(),expose_mcp:n(!1)}),Vt=c({version:n(1),organization_id:t().min(1).max(160),enrollment_ticket:t().min(1).max(4096),code_verifier:t().regex(/^[A-Za-z0-9._~-]{43,128}$/),root_fingerprint_key:t().regex(/^[a-f0-9]{64}$/),root:c({path_fingerprint:t().regex(/^[a-f0-9]{64}$/),permissions:zt,execution_mode:s(["confined","host"]).default("confined")}),folders:u(c({path_fingerprint:t().regex(/^[a-f0-9]{64}$/)})).min(1).max(31).optional()}),So=i({device_id:t().min(1).max(160),organization_id:t().min(1).max(160),auth_scheme:n("p256"),protocol_version:n(2),roots:u(i({id:t().min(1),label:t(),path_fingerprint:t()})).min(1).max(32),headless:i({lifecycle:s(["persistent","ephemeral"]),expires_at:y.datetime({offset:!0})}),first_heartbeat:Ie().optional()});var jo=c({version:n(1),install_id:k(),fingerprint_key:t().regex(/^[a-f0-9]{64}$/)}),qo=i({enrollment_ticket:t().min(1).max(4096),expires_at:y.datetime({offset:!0}),device_kind:n("headless"),lifecycle:s(["persistent","ephemeral"]),device_expires_at:y.datetime({offset:!0})});var zo=i({credentialKind:s(["oauth","api_key"]).optional(),apiOrigin:At(),clientId:t(),accessToken:t().min(1).max(32768),refreshToken:t().max(32768),expiresAt:y.datetime({offset:!0}),scopes:u(t().max(128)).max(128),orgId:t().min(1).max(160)});var je=8;var Qt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,_e=(e)=>ee(m(e),"workspaces"),er="account.json",tr=(e)=>f(ee(e,er));function Se(e){let r;try{r=Zt(_e(e))}catch{return[]}return r.filter((p)=>Qt.test(p)).sort().map((p)=>{let b=ee(_e(e),p),R=ee(b,"worker.json"),S=null;try{let P=B.safeParse(JSON.parse(h(R)));if(P.success&&P.data.stateDirectory===b)S=P.data}catch{}return{organizationId:p,directory:b,configPath:R,config:S,account:tr(b)}})}var rr=(e)=>ee(_e(e),"listed.json");function nr(e){try{let r=JSON.parse(h(rr(e))),p=r.names&&typeof r.names==="object"&&!Array.isArray(r.names)?Object.fromEntries(Object.entries(r.names).filter((R)=>typeof R[1]==="string")):{},b=r.refused&&typeof r.refused==="object"?r.refused:null;return{listed:r.listed===!0,reason:r.reason==="sign_in"?"sign_in":null,blocked:Array.isArray(r.blocked)?r.blocked.filter((R)=>typeof R==="string"):[],names:p,...b&&typeof b.device==="string"&&typeof b.roots==="string"&&typeof b.at==="number"&&Number.isFinite(b.at)&&typeof b.count==="number"&&Number.isInteger(b.count)&&b.count>=1?{refused:{device:b.device,roots:b.roots,at:b.at,count:b.count}}:{}}}catch{return null}}function qe(e,r){let p=Se(e),b=p.filter((C)=>C.account),R=p.filter((C)=>!C.account),S=nr(e),P=S&&!S.listed?S.reason:null,E=P||R.length===0&&S&&!S.listed?[]:R;if(b.length===0&&E.length===0&&(P||S&&!S.listed))return{workspaces:null,off:P};return{off:P,workspaces:[...b,...E].map(({organizationId:C,config:T,account:I})=>{let A=!1,D=null,L=!1,he=null;try{A=T?H(T).revoked:!1,D=T&&!A?M(T):null;let Le=T?ht(w(T).daemon):null;L=r&&!!D&&Le?.state==="connected",he=L?Kt(Le,D):null}catch{}return{...he?{permission_recovery:he}:{},organization_id:C,device_id:D?.deviceId??null,name:S?.names?.[C]??null,root:D?.roots[0]?{id:D.roots[0].id,permissions:D.roots[0].permissions}:null,state:A?"removed":L?"connected":"not_running",blocked:!I&&!A&&!L&&(S?.blocked.includes(C)??!1),...I?{account:!0}:{}}})}}import{readFileSync as ir}from"fs";function pr(e){try{let r=JSON.parse(ir(`${e}.keep-awake.json`,"utf8"));return r!==null&&typeof r==="object"&&"version"in r&&r.version===1&&"enabled"in r&&r.enabled===!0?"battery_and_ac":void 0}catch(r){return r.code==="ENOENT"?"battery_and_ac":void 0}}import{chmodSync as ji,lstatSync as Xe,mkdtempSync as qi,realpathSync as sr,rmdirSync as zi,rmSync as Ki,unlinkSync as Vi}from"fs";import{createConnection as cr,createServer as Gi}from"net";import{basename as Je,dirname as Ge,join as ne}from"path";var lr=s(["status","drain","resume","stop","reload_roots"]),dr=c({version:n(1),instanceId:t(),deviceId:t(),phase:s(["starting","running","reconnecting","stopping"]),drained:d(),activeClaims:o().int().nonnegative(),activeSessions:o().int().nonnegative().optional(),executionEligible:d(),supportedOperations:u(s(bt)).max(bt.length).optional(),capabilityReadiness:_s(s(bt),d()).optional(),lastHeartbeat:t().nullable(),expiresAt:t()}),ta=c({nonce:t(),action:lr}),ur=i({nonce:k()}),fr=c({version:n(1),nonce:k(),socketPath:t().max(100)});function mr(e){return ne(w(e).lock,"control.json")}function Qe(e){return v(w(e).lock),ur.parse(JSON.parse(h(ne(w(e).lock,"owner.json"))))}function Ye(e){if(!f(e))return!1;let r=Xe(e);if(!r.isSocket()||r.uid!==process.getuid?.()||(r.mode&63)!==0)throw Error("worker_control_socket_not_private");return!0}function et(e,r){let p=mr(e);if(!f(p)){let S=w(e).socket;if(!f(S)||!Xe(S).isSocket())return null;return Ye(S)?S:null}let b=fr.parse(JSON.parse(h(p)));if(b.nonce!==r)throw Error("worker_instance_changed");if(process.platform==="win32"){if(!hr.test(b.socketPath))throw Error("worker_control_endpoint_invalid");return b.socketPath}let R=Ge(b.socketPath);if(Ge(R)!==sr("/tmp")||!/^(?:reason|ara)-worker-[A-Za-z0-9]{6}$/.test(Je(R))||Je(b.socketPath)!=="control.sock"||Buffer.byteLength(b.socketPath)>100)throw Error("worker_control_endpoint_invalid");if(!f(R))return null;return v(R),Ye(b.socketPath)?b.socketPath:null}var hr=/^\\\\\.\\pipe\\reason-worker-[0-9a-f-]{36}$/;function gr(e,r){try{let p=JSON.parse(h(ne(w(e).lock,"owner.json"))),b=p&&typeof p==="object"?p[r]:void 0;return typeof b==="string"?b:null}catch{return null}}function tt(e){return gr(e,"runtime_version")}function rt(e,r){if(r)return r.message==="worker_control_timeout"?"socket_timeout":"bad_reply";try{if(!f(ne(w(e).lock,"owner.json")))return"no_lock";return et(e,Qe(e).nonce)?"socket_refused":"no_socket"}catch{return"bad_reply"}}var ra=c({instance:t().nullable(),since:o().int().nonnegative()});async function G(e,r){let p=w(e);if(!f(ne(p.lock,"owner.json")))return null;let b=Qe(e),R=et(e,b.nonce);if(!R)return null;return new Promise((S,P)=>{let E=cr(R),C="",T=!1,I=(A,D)=>{if(T)return;if(T=!0,E.destroy(),D)P(D);else S(A)};E.setTimeout(2000,()=>E.destroy(Error("worker_control_timeout"))),E.on("connect",()=>E.write(JSON.stringify({nonce:b.nonce,action:r})+`
|
|
5
5
|
`)),E.on("data",(A)=>{if(C+=A.toString(),Buffer.byteLength(C)>16384)E.destroy(Error("worker_control_oversize"))}),E.on("error",(A)=>{if("code"in A&&["ECONNREFUSED","ENOENT"].includes(String(A.code)))I(null);else I(null,A.message==="worker_control_timeout"?A:Error("worker_control_unavailable"))}),E.on("end",()=>{try{let A=dr.parse(JSON.parse(C));if(A.instanceId!==b.nonce)throw Error("worker_instance_changed");I(A)}catch{I(null,Error("worker_control_invalid_response"))}}),E.once("close",()=>I(null,Error("worker_control_unavailable")))})}import{realpathSync as br}from"fs";import{constants as Re}from"fs";import{open as wr}from"fs/promises";var la={platform:process.platform,home:a,async openFile(e){let r=await wr(e,Re.O_RDONLY|Re.O_NOFOLLOW|Re.O_NONBLOCK);return{isFile:async()=>(await r.stat()).isFile(),close:()=>r.close()}}};var qa=Bo(br(process.execPath));var hs=Buffer.from([0,255,3,4]);import{execFile as nn}from"child_process";import{promisify as on}from"util";var Er=/#w=(\d{1,5})&h=(\d{1,5})$/;function at(e){return typeof e==="number"&&Number.isInteger(e)&&e>0&&e<=32768?e:void 0}function st(e){let r=Er.exec(e);if(!r)return;let p=at(Number(r[1])),b=at(Number(r[2]));return p&&b?{width:p,height:b}:void 0}var ct="[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}",Pr=new RegExp(`^/media/pr-screenshots/(${ct})/(${ct})/([a-z0-9][a-z0-9._-]*)\\.(png|jpe?g|gif|webp|webm|mp4)$`,"i");var Cr=new Set(["png","jpg","jpeg","gif","webp"]),Ar=new Set(["webm","mp4"]);function xr(e){if(!e)return null;try{return new URL(e).origin}catch{return null}}function Ir(e){let r=st(e);return Boolean(r&&e===`#w=${r.width}&h=${r.height}`)}function lt(e,r){let p;try{p=new URL(e)}catch{return null}let b=xr(r),R=p.hostname==="ara.so"||p.hostname.endsWith(".ara.so")||p.hostname==="reasonmachines.ai"||p.hostname.endsWith(".reasonmachines.ai")||p.hostname==="reasonmachines.com"||p.hostname.endsWith(".reasonmachines.com");if(p.protocol!=="https:"||!R&&p.origin!==b||p.username||p.password||p.port||p.search||p.hash&&!Ir(p.hash))return null;let S=Pr.exec(p.pathname);if(!S)return null;let P=S[1]?.toLowerCase(),E=S[2]?.toLowerCase(),C=S[3]?.toLowerCase(),T=S[4]?.toLowerCase();if(!P||!E||!C||!T)return null;let I=Cr.has(T)?"image":Ar.has(T)?"video":null;if(!I)return null;let A=/^(before|after)[\s:_-]+/.exec(C),D=p.pathname.replace(/^\/media\//,"");return{url:p.toString(),storagePath:D,runId:P,artifactId:E,fileName:`${C}.${T}`,kind:I,phase:A?.[1]==="before"||A?.[1]==="after"?A[1]:null}}var Or=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,dt=(e)=>Boolean(e&&typeof e==="object"&&!Array.isArray(e)),K=()=>{throw Error("cloud_browser_media_request_invalid")};function Pe(e){if(!dt(e)||Object.keys(e).some((S)=>!["runId","configuredMediaOrigin","media"].includes(S))||typeof e.runId!=="string"||!Or.test(e.runId)||typeof e.configuredMediaOrigin!=="string"||e.configuredMediaOrigin.length>2048||!Array.isArray(e.media)||e.media.length<1||e.media.length>8)return K();let r;try{r=new URL(e.configuredMediaOrigin)}catch{return K()}if(r.protocol!=="https:"||r.username||r.password||r.port||!He(r.origin,{mode:"public_web"}).allowed)return K();let p=e.runId.toLowerCase(),b=new Set,R=e.media.map((S)=>{if(!dt(S)||Object.keys(S).some((E)=>!["url","sourceUrl","kind"].includes(E))||typeof S.url!=="string"||S.url.length>2048||typeof S.sourceUrl!=="string"||S.sourceUrl.length>8192||!["image","video"].includes(String(S.kind)))return K();let P=lt(S.url,r.origin);if(!P||new URL(P.url).origin!==r.origin||P.runId!==p||P.kind!==S.kind||P.url!==S.url||b.has(S.url))return K();if(b.add(S.url),S.sourceUrl!==S.url){let E;try{E=new URL(S.sourceUrl)}catch{return K()}let C=/^\/(?:[a-f0-9]{40}|[a-f0-9]{64})\/([a-f0-9]+)$/.exec(E.pathname)?.[1];if(S.kind!=="image"||E.origin!=="https://camo.githubusercontent.com"||E.username||E.password||E.search||E.hash||!C||C.length%2!==0||Buffer.from(C,"hex").toString("utf8")!==S.url)return K()}return{url:S.url,sourceUrl:S.sourceUrl,kind:S.kind}});return{runId:e.runId,configuredMediaOrigin:r.origin,media:R}}var x=t().uuid(),X=t().regex(/^[a-f0-9]{64}$/),V=y.datetime({precision:3}),Ce=t().regex(/^[a-zA-Z0-9_-]{1,160}$/),mt=t().max(2048).regex(/^https:\/\/github\.com\/[A-Za-z0-9_-]+\/[A-Za-z0-9_.-]+\/pull\/[1-9][0-9]*$/).refine((e)=>![".",".."].includes(e.split("/")[4])),U=i({kind:n("primary_mac"),version:n(1),organizationId:Ce,userId:Ce,sessionId:Ce,runId:x,deviceId:x,rootId:x,rootRevision:t().min(1).max(64),binding:s(["workspace_source","mcp_control"]),targetRevision:o().int().nonnegative(),generation:x,profile:t().regex(/^(Default|Profile [0-9]+)$/),extensionInstanceId:t().min(1).max(1024)}).strict().refine((e)=>e.binding!=="workspace_source"||e.targetRevision===0),Tr=cn().transform((e,r)=>{try{return fn(e)}catch{return r.addIssue({code:"custom",message:"proof_visual_contract_invalid"}),Xo}}),ue=i({version:n(1),owner:U,contextId:x,preparedAt:V,expiresAt:V,prUrl:mt,headSha:t().regex(/^[a-f0-9]{40}$/),skillDigest:X,evidenceKind:s(["image","video"]),visualPlan:Tr.optional(),uploadOrigin:t().url().refine((e)=>{let r=new URL(e);return r.protocol==="https:"&&r.origin===e&&!r.username&&!r.password}).optional()}).strict().refine((e)=>Date.parse(e.expiresAt)>Date.parse(e.preparedAt)&&Date.parse(e.expiresAt)-Date.parse(e.preparedAt)<=300000),Dr=i({version:n(1),producer:n("primary_mac"),context:ue,captureId:x,operationId:x,attemptId:x,tabId:o().int().positive(),startedAt:V,finishedAt:V,sha256:X,media:g("contentType",[i({contentType:n("image/png"),sizeBytes:o().int().min(24).max(8388608),width:o().int().min(1).max(4096),height:o().int().min(1).max(4096)}).strict(),i({contentType:n("video/webm"),sizeBytes:o().int().min(128).max(10485760),durationSeconds:o().min(0.05).max(15),frameCount:o().int().min(1).max(450),receivedFrameCount:o().int().min(1).max(2000)}).strict()])}).strict().superRefine((e,r)=>{let p=Date.parse(e.startedAt),b=Date.parse(e.finishedAt);if(p<Date.parse(e.context.preparedAt)||b<p||b>Date.parse(e.context.expiresAt)||b-p>30000||e.media.contentType==="video/webm"&&(e.media.receivedFrameCount<e.media.frameCount||Math.abs((b-p)/1000-e.media.durationSeconds)>0.1))r.addIssue({code:"custom",message:"mac_pr_proof_capture_chronology_invalid"})}),yc=g("action",[i({action:n("screenshot"),context_id:x,tab_id:o().int().positive()}).strict(),i({action:n("start_video"),context_id:x,tab_id:o().int().positive(),seconds:o().int().min(1).max(15)}).strict(),i({action:n("stop_video"),recording_operation_id:x}).strict()]),fe=i({login:t().regex(/^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,37}[a-zA-Z0-9])?$/),id:t().regex(/^[1-9][0-9]{0,19}$/).nullable()}).strict(),ce=t().regex(/^[1-9][0-9]{0,19}$/),le=i({version:n(1),owner:U,expectedActorId:ce.nullable(),repositoryId:ce,repositoryFullName:t().max(200).regex(/^[A-Za-z0-9_-]+\/[A-Za-z0-9_.-]+$/).refine((e)=>![".",".."].includes(e.split("/")[1]))}).strict(),Wr=["browser_unavailable","github_page_unavailable","identity_check_failed","operation_incomplete","attachment_unavailable"],Nr=g("status",[le.extend({status:n("ready"),observedActor:fe,checkedAt:V}),le.extend({status:n("not_ready"),reason:s(["authentication_required","identity_mismatch","authority_lost","unavailable"]),cause:s(Wr).optional()})]).refine((e)=>e.status!=="ready"||e.expectedActorId===null||e.observedActor.id===e.expectedActorId),Y=i({version:n(1),owner:U,expectedActorId:ce.nullable(),authenticatedActor:fe,attemptId:x,captureId:x,prUrl:mt,repositoryId:ce,headSha:t().regex(/^[a-f0-9]{40}$/),sha256:X,sizeBytes:o().int().min(128).max(10485760),contentType:n("video/webm")}).strict(),pt=t().regex(/^https:\/\/github\.com\/user-attachments\/assets\/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/),Hr=g("status",[Y.extend({status:n("not_attempted"),reason:s(["authentication_required","attachment_unavailable","identity_mismatch","capture_invalid","authority_lost"])}),Y.extend({status:n("uncertain"),reason:n("upload_outcome_unknown")}),Y.extend({status:n("uploaded"),observedActor:fe,nativeUrl:pt,uploadedAt:V})]).refine((e)=>(e.expectedActorId===null||e.authenticatedActor.id===e.expectedActorId)&&(e.status!=="uploaded"||e.observedActor.id===e.authenticatedActor.id&&e.observedActor.login===e.authenticatedActor.login)),de=Y.extend({nativeUrl:pt,observedActor:fe,bodySha256:X}),$r=g("status",[de.extend({status:n("incomplete"),reason:s(["authentication_required","identity_mismatch","playback_unverified","authority_lost"])}),de.extend({status:n("verified"),sourceSha256:X,width:o().int().min(1).max(4096),height:o().int().min(1).max(4096),durationSeconds:o().positive().max(30),advancedSeconds:o().min(0.05).max(10),advancedFrames:o().int().positive(),playbackRestored:n(!0),verifiedAt:V})]).refine((e)=>(e.expectedActorId===null||e.authenticatedActor.id===e.expectedActorId)&&e.observedActor.id===e.authenticatedActor.id&&e.observedActor.login===e.authenticatedActor.login&&(e.status!=="verified"||e.sourceSha256===e.sha256)),Br=cn().transform((e,r)=>{try{let p=Pe(e);if(p.media.some((b)=>b.kind!=="image"))throw Error();return p}catch{return r.addIssue({code:"custom",message:"proof_media_request_invalid"}),Xo}}),Ur=g("action",[i({action:n("auth_check"),input:le}).strict(),i({action:n("prepare"),context:ue}).strict(),i({action:n("capture_png"),owner:U,contextId:x,tabId:o().int().positive()}).strict(),i({action:n("start_video"),owner:U,contextId:x,tabId:o().int().positive(),seconds:o().int().min(1).max(15)}).strict(),i({action:n("inspect_capture"),owner:U,captureId:x}).strict(),i({action:n("publish_video"),input:Y}).strict(),i({action:n("verify_png_media"),owner:U,media:Br}).strict().refine((e)=>e.media.runId===e.owner.runId),i({action:n("verify_saved_media"),input:de}).strict(),i({action:n("publish_png"),owner:U,attemptId:x,captureId:x,sha256:X,sizeBytes:o().int().min(24).max(8388608),storagePath:t().max(512),uploadUrl:t().url().max(8192)}).strict()]);var Fr=i({requestId:x,command:Ur}).strict();var jr={type:"object",required:["action"],properties:{action:{type:"string",enum:["screenshot","start_video","stop_video"]},context_id:{type:"string",format:"uuid"},tab_id:{type:"integer",minimum:1},seconds:{type:"integer",minimum:1,maximum:15},recording_operation_id:{type:"string",format:"uuid"}},additionalProperties:!1},ut={type:"string",format:"uuid",description:"capture_context_id from tools.pr.prepareProof."},ft={type:"integer",minimum:1,description:"An already-owned tab's id."},_c={...jr,oneOf:[{type:"object",required:["action","context_id","tab_id"],additionalProperties:!1,properties:{action:{type:"string",const:"screenshot"},context_id:ut,tab_id:ft}},{type:"object",required:["action","context_id","tab_id","seconds"],additionalProperties:!1,properties:{action:{type:"string",const:"start_video"},context_id:ut,tab_id:ft,seconds:{type:"integer",minimum:1,maximum:15}}},{type:"object",required:["action","recording_operation_id"],additionalProperties:!1,properties:{action:{type:"string",const:"stop_video"},recording_operation_id:{type:"string",format:"uuid",description:"The recording_operation_id start_video returned."}}}]};var Rc=i({operationId:t().uuid(),attemptId:t().uuid(),contextId:t().uuid(),tabId:o().int().positive()}).strict();var qr=String.raw`async (media) => {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var tr={name:"github-native-engineer-device-worker-production",version:"0.2.
|
|
2
|
+
var tr={name:"github-native-engineer-device-worker-production",version:"0.2.534",private:!0,type:"module",engines:{node:">=22",bun:">=1.3.0"},workspaces:["../../packages/runtime-distribution"],dependencies:{"@agentclientprotocol/sdk":"1.9.0","@anthropic-ai/sandbox-runtime":"^0.0.80","@earendil-works/pi-tui":"1.0.0","@reason/runtime-distribution":"workspace:*",diff:"8.0.4","open-browser-use-sdk":"0.1.42","playwright-core":"1.60.0",toml:"4.2.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{tr};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{nt,Et,cr,on,xt,kt,Di,sn,Oi,Ni,Li}from"./vm-hands-entry-lite-37b5045h.js";import{Pe,sr,ni,wt,Go,oe,Ko,Jo,tt,Re,nn,oi,vt,li,ui,di,pi,hi,fi,mi,gi,_i,yi,wi,bi,vi,pe,Z,Te,q,Si,Ei,xi,ki,Ci,Ai,Pi,Ri,St,Ti}from"./vm-hands-entry-lite-qc6gxqgs.js";import{ue,X,I}from"./vm-hands-entry-lite-a0g6c3wr.js";import{P,Yt}from"./vm-hands-entry-lite-hv3dxd5k.js";import{mr,eo,to,at,ro,no,io,oo,so,ao,yr,wr,br,wn,bn,vr,lo,vn,Sr,me,ge,Ot,Er,kr,Nt}from"./vm-hands-entry-lite-
|
|
2
|
+
import{nt,Et,cr,on,xt,kt,Di,sn,Oi,Ni,Li}from"./vm-hands-entry-lite-37b5045h.js";import{Pe,sr,ni,wt,Go,oe,Ko,Jo,tt,Re,nn,oi,vt,li,ui,di,pi,hi,fi,mi,gi,_i,yi,wi,bi,vi,pe,Z,Te,q,Si,Ei,xi,ki,Ci,Ai,Pi,Ri,St,Ti}from"./vm-hands-entry-lite-qc6gxqgs.js";import{ue,X,I}from"./vm-hands-entry-lite-a0g6c3wr.js";import{P,Yt}from"./vm-hands-entry-lite-hv3dxd5k.js";import{mr,eo,to,at,ro,no,io,oo,so,ao,yr,wr,br,wn,bn,vr,lo,vn,Sr,me,ge,Ot,Er,kr,Nt}from"./vm-hands-entry-lite-10b4f71g.js";import{O,T,b}from"./vm-hands-entry-lite-4r1yn35v.js";import{Xi,Yi,_n,Zi,yn,Qi,st,fr}from"./vm-hands-entry-lite-4t4fakg5.js";import{K}from"./vm-hands-entry-lite-ct4mtq1m.js";import{Ue}from"./vm-hands-entry-lite-5tnma5qb.js";import{j}from"./vm-hands-entry-lite-cgddp0y3.js";import{hr,gn,Ji}from"./vm-hands-entry-lite-9azmqs47.js";import{vo,So,dt,Eo,xo,ko,Co,Ao,Po,Ro}from"./vm-hands-entry-lite-k9vk84wa.js";import{Dr,Vt,Or,Hn,Un}from"./vm-hands-entry-lite-j5t2pj4v.js";import{Ft,qe,jt}from"./vm-hands-entry-lite-xew9ydsp.js";import{Nn,x,yo}from"./vm-hands-entry-lite-2vh94vfz.js";import{wo,bo}from"./vm-hands-entry-lite-fgz5a87g.js";import{Bt,Pn,Rn}from"./vm-hands-entry-lite-0e6h8ddd.js";import{ye,ho,fo}from"./vm-hands-entry-lite-2hfrcr50.js";import{be}from"./vm-hands-entry-lite-yretc2th.js";import{Mt}from"./vm-hands-entry-lite-yptpy066.js";import{ve,Ut,zt,qt,E}from"./vm-hands-entry-lite-72nj66ab.js";import{a,ie}from"./vm-hands-entry-lite-jvszqt0z.js";import{t,k,o,d,u,i,W,g,ee,s,n,Zo}from"./vm-hands-entry-lite-ztsp4gs8.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{fe,Ne,Le,$e,ln}from"./vm-hands-entry-lite-b6gsggvp.js";import{Me}from"./vm-hands-entry-lite-3gbf905c.js";import{request as $l}from"http";import{request as Bl}from"https";import{lookup as Fl}from"dns/promises";import{isIP as Ul}from"net";async function Hl(e){let l=new URL(e.url);return await new Promise((c,p)=>{let m=(l.protocol==="https:"?Bl:$l)(l,{method:"POST",headers:{...e.headers,"accept-encoding":"identity"},signal:e.signal,timeout:Di},(f)=>c({response:f,close:()=>{f.destroy(),m.destroy(),f.socket?.destroy()}}));m.once("error",p),m.once("timeout",()=>m.destroy(Object.assign(Error("custom_endpoint_timeout"),{code:"ETIMEDOUT"}))),m.end(e.body)})}var Ki=new Set(["ENOTFOUND","EAI_AGAIN","EAI_NONAME","EAI_NODATA","EAI_FAIL","DNSException"]),jl=new Set(["ECONNREFUSED","ETIMEDOUT","ECONNRESET","EHOSTUNREACH","ENETUNREACH","EHOSTDOWN","ENETDOWN","EPIPE","ECONNABORTED","EADDRNOTAVAIL","ConnectionRefused","ConnectionClosed","ConnectionTimedOut","Timeout"]);function es(e,l=0){if(!e||typeof e!=="object"||l>3)return null;let c=e.code;if(typeof c==="string"){if(Ki.has(c))return"custom_endpoint_host_not_found";if(jl.has(c))return"custom_endpoint_connection_failed";if(/^(?:ERR_TLS_|ERR_SSL_|CERT_|UNABLE_TO_(?:GET|VERIFY|DECRYPT)|DEPTH_ZERO_SELF_SIGNED|SELF_SIGNED_CERT|HOSTNAME_MISMATCH|EPROTO$)/.test(c))return"custom_endpoint_tls_failed"}for(let p of[...e instanceof AggregateError?e.errors:[],e.cause]){let m=es(p,l+1);if(m)return m}return null}async function ql(e,l){let c=es(e),p=new URL(l).hostname.replace(/^\[|\]$/g,"");if(c!==null&&c!=="custom_endpoint_connection_failed"||Ul(p)!==0)return c;let m;return await Promise.race([Fl(p).then(()=>!0,(h)=>!Ki.has(String(h?.code))),new Promise((h)=>{m=setTimeout(()=>h(!0),5000)})]).finally(()=>clearTimeout(m))?c:"custom_endpoint_host_not_found"}function Wl(e){for(let l=42;;l++){if(l===127)l=256;let c=String.fromCodePoint(l);if(!e.includes(c))return c}}function Vl(e,l){let c=Buffer.from(e),p=Buffer.from(l),m=new Uint32Array(c.length);for(let h=1,y=0;h<c.length;h++){while(y&&c[h]!==c[y])y=m[y-1];if(c[h]===c[y])y++;m[h]=y}let f=0;return(h,y=!1)=>{let S=Buffer.allocUnsafe(h.length*p.length+f),w=0;for(let _ of h){while(f&&c[f]!==_){let v=m[f-1];w+=c.copy(S,w,0,f-v),f=v}if(c[f]===_){if(f++,f===c.length)w+=p.copy(S,w),f=0}else S[w++]=_}if(y)w+=c.copy(S,w,0,f),f=0;return S.subarray(0,w)}}async function ts(e){e.signal.throwIfAborted();let l=Oi.safeParse(e.payload);if(!l.success)throw new r("custom_endpoint_invalid_request","Invalid local model request.");let c=l.data,p=Ni.parse(await e.credential(e.signal));if(!sn(c,{baseUrl:c.baseUrl,api:p.api,execution:"device"}))throw new r("custom_endpoint_invalid_request","The request does not match the configured API.");e.signal.throwIfAborted();let m,f,h=0,y=0,S=0,w=Wl(p.apiKey),_=Vl(p.apiKey,w),v=async(C,A)=>{e.signal.throwIfAborted(),await new Promise((M,N)=>{let L=()=>{e.signal.removeEventListener("abort",L),N(e.signal.reason)};if(e.signal.addEventListener("abort",L,{once:!0}),e.signal.aborted){L();return}Promise.resolve().then(()=>(e.signal.throwIfAborted(),e.emit(C,A))).then(()=>{e.signal.removeEventListener("abort",L),M()},(B)=>{e.signal.removeEventListener("abort",L),N(B)})})},R=async(C)=>{if(h+=C.length,h>cr)throw new r("custom_endpoint_response_too_large","Local model response exceeds the transport limit.");for(let A=0;A<C.length;A+=Et){if(S>=on)throw new r("custom_endpoint_response_too_large","Local model response exceeds the chunk limit.");await v(`custom_endpoint.chunk.${S++}`,{eof:!1,data:C.subarray(A,A+Et).toString("base64")})}};try{let C=await Hl({url:c.url,body:c.body,signal:e.signal,headers:{...c.headers,...p.api==="anthropic-messages"?{"x-api-key":p.apiKey}:{authorization:`Bearer ${p.apiKey}`}}});m=C.response,f=C.close;let A=m.statusCode??500;if(A>=300&&A<400)throw new r("custom_endpoint_redirect_refused","Local model redirects are not followed.");if(m.headers["content-encoding"]&&m.headers["content-encoding"]!=="identity")throw new r("custom_endpoint_encoding_unsupported","The local server must honor identity encoding.");let M={};for(let N of["content-type","retry-after","x-request-id","request-id"]){let L=m.headers[N];if(typeof L==="string")M[N]=L.replaceAll(p.apiKey,w).slice(0,4096)}await v("custom_endpoint.headers",{status:A,statusText:(m.statusMessage??"").replaceAll(p.apiKey,w).slice(0,256),headers:M});for await(let N of m){e.signal.throwIfAborted();let L=Buffer.isBuffer(N)?N:Buffer.from(N);if(y+=L.length,y>cr)throw new r("custom_endpoint_response_too_large","Local model response exceeds the transport limit.");await R(_(L))}return await R(_(Buffer.alloc(0),!0)),await v(`custom_endpoint.chunk.${S}`,{eof:!0}),{bytes:h,chunks:S}}catch(C){if(e.signal.throwIfAborted(),C instanceof r)throw C;throw new r((m?null:await ql(C,c.url))??"custom_endpoint_request_failed","The local model server could not complete the request.")}finally{f?.()}}import{join as rs}from"path";function zl(e,l){return e===rs(l,".ara","workspace")||e===rs(l,".reason","workspace")}function ls(e,l){let c=e.filter((p)=>zl(p.path,l));return c.length===1?c[0].path:null}var Gl=/^[a-f0-9]{64}$/;var an=32,Yl=/^\/[^\x00-\x1f\x7f\\]*$/;function Cr(e){if(typeof e!=="string"||e.length>4096||!Yl.test(e))return!1;if(e==="/")return!0;return e.split("/").slice(1).every((l)=>l!==""&&l!=="."&&l!=="..")}function Pr(e,l){let c=l==="win32"?/^([A-Za-z]):[\\/]*(.*)$/.exec(e):null;if(!c)return e;let p=c[2].split(/[\\/]+/).filter(Boolean).join("/");return`/${c[1].toUpperCase()}:${p?`/${p}`:""}`}function cn(e){if(!e||typeof e!=="object"||Array.isArray(e))return;let l=e;if(!Cr(l.home)||!Array.isArray(l.roots)||l.roots.length>an)return;let c=[];for(let p of l.roots){if(!p||typeof p!=="object"||Array.isArray(p))return;let{path_fingerprint:m,path:f}=p;if(typeof m!=="string"||!Gl.test(m)||!Cr(f))return;c.push({path_fingerprint:m,path:f})}return{home:l.home,roots:c}}function Kl(e){let l=/^Reason contributor (rc_[0-9a-f]{32})$/.exec(e.name)?.[1];return e.email.toLowerCase()==="343777287+reason-contributors@users.noreply.github.com"&&l?l:void 0}function Xl(e){return Kl(e)??e.email.toLowerCase()}function un(e){let l=/^Co-authored-by:\s*([^<>\r\n]+) <([^<>\s]+)>$/i.exec(e.trim());return l?Xl({name:l[1],email:l[2]}):e.trim().toLowerCase()}var Gt=(e)=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/[a-z]/gi,(l)=>`[${l.toLowerCase()}${l.toUpperCase()}]`),Jl=[...ve.map((e)=>`/(${e.map(Gt).join("/")})(/|$)`),...Ut.map((e)=>`/(${e.map(Gt).join("/")})(/|$)`),...[...zt].map((e)=>`/(${Gt(e)})$`),`/${Gt(".env.")}[^/]*$`,...qt.map((e)=>`/[^/]*${Gt(e)}$`)],cs=`function localGithubSandboxProfile(root, temporary) {
|
|
3
3
|
return ['(version 1)','(deny default)','(import "system.sb")','(allow process-exec process-fork)',
|
|
4
4
|
'(allow file-read* (subpath "/bin") (subpath "/sbin") (subpath "/usr/bin") (subpath "/usr/sbin") (subpath "/usr/libexec") (subpath "/usr/share") (subpath "/private/var/select") (literal "/private/var/db/xcode_select_link"))',
|
|
5
5
|
'(allow file-read-metadata (path-ancestors "/opt/homebrew/bin") (path-ancestors "/usr/local/bin") (path-ancestors "/Library/Developer/CommandLineTools"))',
|