@reason-machines/cli-linux-x64 0.2.447 → 0.2.449
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/reason +1 -1
- package/bin/vm-hands/{connect-cli-ns7rhvzr.js → connect-cli-k8qs2zrc.js} +1 -1
- package/bin/vm-hands/{custom-endpoint-device-46deqrq5.js → custom-endpoint-device-2s9qxe6t.js} +1 -1
- package/bin/vm-hands/{local-automation-w7kbsrhy.js → local-automation-dcqzzsxg.js} +1 -1
- package/bin/vm-hands/{local-capabilities-gf0fnnyp.js → local-capabilities-t846qg10.js} +1 -1
- package/bin/vm-hands/{local-display-session-eyj004s7.js → local-display-session-28e5cae4.js} +1 -1
- package/bin/vm-hands/local-display-video-d77qmw0s.js +2 -0
- package/bin/vm-hands/{local-managed-process-gtwdd02v.js → local-managed-process-5psc5bh1.js} +1 -1
- package/bin/vm-hands/{managed-runtime-vr9ems2y.js → managed-runtime-j257p94b.js} +1 -1
- package/bin/vm-hands/{permissions-6znbykm7.js → permissions-5em32gcg.js} +1 -1
- package/bin/vm-hands/{serve-service-ryzrmwp2.js → serve-service-r487wxa7.js} +1 -1
- package/bin/vm-hands/{status-f2h9bsn9.js → status-dvj49856.js} +1 -1
- package/bin/vm-hands/version-3swerjpy.js +2 -0
- package/bin/vm-hands/{vm-hands-entry-lite-n15pmxf5.js → vm-hands-entry-lite-0462ahs5.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-18gk29nq.js → vm-hands-entry-lite-43c99aqt.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-w77kkpgk.js → vm-hands-entry-lite-5rwx4xrq.js} +1 -1
- package/bin/vm-hands/vm-hands-entry-lite-619ztrvp.js +2 -0
- package/bin/vm-hands/{vm-hands-entry-lite-g5236sbr.js → vm-hands-entry-lite-7ba3dm8a.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-t24zht3x.js → vm-hands-entry-lite-7vkr3h93.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-xyh7srqs.js → vm-hands-entry-lite-89b18wqa.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-1essfbrs.js → vm-hands-entry-lite-bz0ys3fb.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-t3qf6qrj.js → vm-hands-entry-lite-dcxvxpne.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-x9e3e0wh.js → vm-hands-entry-lite-ge81taff.js} +3 -3
- package/bin/vm-hands/{vm-hands-entry-lite-p2cq97x6.js → vm-hands-entry-lite-mvt73s88.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-449qskjw.js → vm-hands-entry-lite-q6mpzzpj.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-jkehpjrw.js → vm-hands-entry-lite-vgjj3d7r.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-xvt4twzn.js → vm-hands-entry-lite-wqmtn3pd.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-ex7xfa7s.js → vm-hands-entry-lite-z3a528r1.js} +1 -1
- package/bin/vm-hands/vm-hands-entry-lite.js +1 -1
- package/bin/vm-hands/{vm-hands-executor-sa9phrat.js → vm-hands-executor-qtft2jex.js} +1 -1
- package/bin/vm-hands/{vm-hands-op-runner-d839gtw3.js → vm-hands-op-runner-bdvdqdk1.js} +1 -1
- package/bin/vm-hands/{vm-hands-runtime-cj8wf5vy.js → vm-hands-runtime-tb4ca3zd.js} +3 -3
- package/package.json +1 -1
- package/bin/vm-hands/local-display-video-vbd8x2z3.js +0 -2
- package/bin/vm-hands/version-vcrzk0tn.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-46jc1e5j.js +0 -2
package/bin/reason
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{tt,ss,as,cs}from"./vm-hands-entry-lite-
|
|
2
|
+
import{tt,ss,as,cs}from"./vm-hands-entry-lite-z3a528r1.js";import"./vm-hands-entry-lite-4fwf7wgb.js";import"./vm-hands-entry-lite-cm497v4t.js";import"./vm-hands-entry-lite-n4x7reax.js";import"./vm-hands-entry-lite-9jgf223h.js";import"./vm-hands-entry-lite-7vkr3h93.js";import"./vm-hands-entry-lite-5rwx4xrq.js";import"./vm-hands-entry-lite-7ba3dm8a.js";import"./vm-hands-entry-lite-mvt73s88.js";import"./vm-hands-entry-lite-499mywh7.js";import"./vm-hands-entry-lite-dh8f2h2d.js";import"./vm-hands-entry-lite-njs8k65s.js";import"./vm-hands-entry-lite-a3w8m8nb.js";import"./vm-hands-entry-lite-t5q30ne0.js";import"./vm-hands-entry-lite-dcxvxpne.js";import"./vm-hands-entry-lite-ge81taff.js";import"./vm-hands-entry-lite-89b18wqa.js";import"./vm-hands-entry-lite-q6mpzzpj.js";import"./vm-hands-entry-lite-3adw9jw3.js";import"./vm-hands-entry-lite-1f2cam25.js";import"./vm-hands-entry-lite-12rzrd95.js";import"./vm-hands-entry-lite-3vmhs921.js";import"./vm-hands-entry-lite-d9g1pzzx.js";import"./vm-hands-entry-lite-bz0ys3fb.js";import"./vm-hands-entry-lite-3pnjdh8m.js";import"./vm-hands-entry-lite-hw26gewc.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-0462ahs5.js";import"./vm-hands-entry-lite-jcf61cb4.js";import"./vm-hands-entry-lite-vgjj3d7r.js";import"./vm-hands-entry-lite-619ztrvp.js";import"./vm-hands-entry-lite-9sa1knn7.js";import"./vm-hands-entry-lite-r7zs4ce2.js";import"./vm-hands-entry-lite-tqc2ezda.js";import"./vm-hands-entry-lite-g9z467dk.js";import"./vm-hands-entry-lite-8j7p91hr.js";import"./vm-hands-entry-lite-em7mk9tn.js";export{ss as computerDisconnected,tt as connectionDirectory,as as connectionReport,cs as restartConnection};
|
package/bin/vm-hands/{custom-endpoint-device-46deqrq5.js → custom-endpoint-device-2s9qxe6t.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{at,Dt,xr,bn,kr,vn,Sn,En}from"./vm-hands-entry-lite-
|
|
2
|
+
import{at,Dt,xr,bn,kr,vn,Sn,En}from"./vm-hands-entry-lite-dcxvxpne.js";export{at as CUSTOM_ENDPOINT_DEVICE_CHUNK_BYTES,xr as CUSTOM_ENDPOINT_DEVICE_MAX_CHUNKS,Dt as CUSTOM_ENDPOINT_DEVICE_MAX_RESPONSE_BYTES,bn as CUSTOM_ENDPOINT_DEVICE_TIMEOUT_MS,Sn as CustomEndpointDeviceCredentialSchema,vn as CustomEndpointDeviceRequestSchema,kr as customEndpointRequestMatchesConfig,En as isCustomEndpointDeviceFailureCode};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{xn,As,Ps,Ts,Rs,kn}from"./vm-hands-entry-lite-
|
|
2
|
+
import{xn,As,Ps,Ts,Rs,kn}from"./vm-hands-entry-lite-ge81taff.js";import"./vm-hands-entry-lite-89b18wqa.js";import"./vm-hands-entry-lite-q6mpzzpj.js";import"./vm-hands-entry-lite-3adw9jw3.js";import"./vm-hands-entry-lite-1f2cam25.js";import"./vm-hands-entry-lite-12rzrd95.js";import"./vm-hands-entry-lite-3vmhs921.js";import"./vm-hands-entry-lite-d9g1pzzx.js";import"./vm-hands-entry-lite-bz0ys3fb.js";import"./vm-hands-entry-lite-3pnjdh8m.js";import"./vm-hands-entry-lite-hw26gewc.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-0462ahs5.js";import"./vm-hands-entry-lite-jcf61cb4.js";import"./vm-hands-entry-lite-vgjj3d7r.js";import"./vm-hands-entry-lite-619ztrvp.js";import"./vm-hands-entry-lite-9sa1knn7.js";import"./vm-hands-entry-lite-r7zs4ce2.js";import"./vm-hands-entry-lite-tqc2ezda.js";import"./vm-hands-entry-lite-g9z467dk.js";import"./vm-hands-entry-lite-8j7p91hr.js";import"./vm-hands-entry-lite-em7mk9tn.js";export{Ps as ensureLocalBrowser,xn as localAutomationAvailable,Ts as localBrowserProfile,As as localUserChromeHost,Rs as runAutomationCallLocally,kn as runLocalAutomation};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{zo,Li,cn,qo,Wo,Vo,Go,vs,Ss,Es,xs}from"./vm-hands-entry-lite-
|
|
2
|
+
import{zo,Li,cn,qo,Wo,Vo,Go,vs,Ss,Es,xs}from"./vm-hands-entry-lite-5rwx4xrq.js";import"./vm-hands-entry-lite-7ba3dm8a.js";import"./vm-hands-entry-lite-mvt73s88.js";import"./vm-hands-entry-lite-499mywh7.js";import"./vm-hands-entry-lite-dh8f2h2d.js";import"./vm-hands-entry-lite-njs8k65s.js";import"./vm-hands-entry-lite-a3w8m8nb.js";import"./vm-hands-entry-lite-t5q30ne0.js";import"./vm-hands-entry-lite-dcxvxpne.js";import"./vm-hands-entry-lite-ge81taff.js";import"./vm-hands-entry-lite-89b18wqa.js";import"./vm-hands-entry-lite-q6mpzzpj.js";import"./vm-hands-entry-lite-3adw9jw3.js";import"./vm-hands-entry-lite-1f2cam25.js";import"./vm-hands-entry-lite-12rzrd95.js";import"./vm-hands-entry-lite-3vmhs921.js";import"./vm-hands-entry-lite-d9g1pzzx.js";import"./vm-hands-entry-lite-bz0ys3fb.js";import"./vm-hands-entry-lite-3pnjdh8m.js";import"./vm-hands-entry-lite-hw26gewc.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-0462ahs5.js";import"./vm-hands-entry-lite-jcf61cb4.js";import"./vm-hands-entry-lite-vgjj3d7r.js";import"./vm-hands-entry-lite-619ztrvp.js";import"./vm-hands-entry-lite-9sa1knn7.js";import"./vm-hands-entry-lite-r7zs4ce2.js";import"./vm-hands-entry-lite-tqc2ezda.js";import"./vm-hands-entry-lite-g9z467dk.js";import"./vm-hands-entry-lite-8j7p91hr.js";import"./vm-hands-entry-lite-em7mk9tn.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";export{r as LocalCapabilityError,zo as SHORT_REQUEST_CAPABILITIES,vs as capabilityInventoryForRoots,Li as confinedExecutionShell,qo as defaultLocalCommandRunner,Ss as deliverLocalHandsEnvironment,Go as enrolledRootPaths,xs as executeLocalOperation,Es as rebindLocalHandsControl,Wo as runFileCapability,Vo as runTransferCapability,cn as spawnCaptured};
|
package/bin/vm-hands/{local-display-session-eyj004s7.js → local-display-session-28e5cae4.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Lt,Os,G,ze,Mt}from"./vm-hands-entry-lite-
|
|
2
|
+
import{Lt,Os,G,ze,Mt}from"./vm-hands-entry-lite-89b18wqa.js";import"./vm-hands-entry-lite-q6mpzzpj.js";import"./vm-hands-entry-lite-3adw9jw3.js";import"./vm-hands-entry-lite-1f2cam25.js";import"./vm-hands-entry-lite-12rzrd95.js";import"./vm-hands-entry-lite-3vmhs921.js";import"./vm-hands-entry-lite-d9g1pzzx.js";import"./vm-hands-entry-lite-hw26gewc.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-0462ahs5.js";import"./vm-hands-entry-lite-jcf61cb4.js";import"./vm-hands-entry-lite-vgjj3d7r.js";import"./vm-hands-entry-lite-619ztrvp.js";import"./vm-hands-entry-lite-9sa1knn7.js";import"./vm-hands-entry-lite-r7zs4ce2.js";import"./vm-hands-entry-lite-g9z467dk.js";import"./vm-hands-entry-lite-8j7p91hr.js";import"./vm-hands-entry-lite-em7mk9tn.js";export{ze as ensureLinuxDesktop,Lt as localDisplayAvailable,Os as localDisplayReady,G as privateDirectory,Mt as runLocalDisplayStream};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{An,Pn,Tn,Rn,Cr}from"./vm-hands-entry-lite-q6mpzzpj.js";import"./vm-hands-entry-lite-d9g1pzzx.js";import"./vm-hands-entry-lite-0462ahs5.js";import"./vm-hands-entry-lite-jcf61cb4.js";import"./vm-hands-entry-lite-vgjj3d7r.js";import"./vm-hands-entry-lite-619ztrvp.js";import"./vm-hands-entry-lite-9sa1knn7.js";import"./vm-hands-entry-lite-r7zs4ce2.js";export{An as MAC_SCREEN,Pn as WINDOWS_SCREEN,Tn as createDisplayVideoLane,Cr as localDisplayVideoAvailable,Rn as simulatorVideoFfmpeg};
|
package/bin/vm-hands/{local-managed-process-gtwdd02v.js → local-managed-process-5psc5bh1.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{rt,cr,ks,Cs}from"./vm-hands-entry-lite-
|
|
2
|
+
import{rt,cr,ks,Cs}from"./vm-hands-entry-lite-7ba3dm8a.js";import"./vm-hands-entry-lite-mvt73s88.js";import"./vm-hands-entry-lite-499mywh7.js";import"./vm-hands-entry-lite-dh8f2h2d.js";import"./vm-hands-entry-lite-a3w8m8nb.js";import"./vm-hands-entry-lite-t5q30ne0.js";import"./vm-hands-entry-lite-1f2cam25.js";import"./vm-hands-entry-lite-12rzrd95.js";import"./vm-hands-entry-lite-3vmhs921.js";import"./vm-hands-entry-lite-d9g1pzzx.js";import"./vm-hands-entry-lite-hw26gewc.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-9sa1knn7.js";import"./vm-hands-entry-lite-r7zs4ce2.js";import"./vm-hands-entry-lite-tqc2ezda.js";import"./vm-hands-entry-lite-g9z467dk.js";import"./vm-hands-entry-lite-8j7p91hr.js";import"./vm-hands-entry-lite-em7mk9tn.js";export{rt as ManagedProcessStoppedError,ks as controlManagedDeviceProcess,Cs as retireManagedDeviceProcess,cr as runManagedDeviceProcess};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{hs,fs,ms,gs,_s,ys,bs}from"./vm-hands-entry-lite-
|
|
2
|
+
import{hs,fs,ms,gs,_s,ys,bs}from"./vm-hands-entry-lite-7vkr3h93.js";import"./vm-hands-entry-lite-t5q30ne0.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-vgjj3d7r.js";import"./vm-hands-entry-lite-619ztrvp.js";import"./vm-hands-entry-lite-9sa1knn7.js";import"./vm-hands-entry-lite-r7zs4ce2.js";import"./vm-hands-entry-lite-8j7p91hr.js";import"./vm-hands-entry-lite-em7mk9tn.js";export{_s as acquireManagedRuntimeDirectoryLock,ms as currentManagedRuntimeVersion,bs as flushManagedRuntimeLifecycleEvents,gs as isManagedRuntimeVersionExecutable,fs as legacyManagedRuntimePaths,hs as managedRuntimePaths,ys as recordManagedRuntimeLifecycle};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Xo,Yo,Fs,js}from"./vm-hands-entry-lite-
|
|
2
|
+
import{Xo,Yo,Fs,js}from"./vm-hands-entry-lite-0462ahs5.js";import"./vm-hands-entry-lite-jcf61cb4.js";import"./vm-hands-entry-lite-vgjj3d7r.js";import"./vm-hands-entry-lite-619ztrvp.js";import"./vm-hands-entry-lite-9sa1knn7.js";import"./vm-hands-entry-lite-r7zs4ce2.js";export{js as allowMacPermissions,Fs as permissionsSummary,Yo as readMacPermissions,Xo as reasonIdentity};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ur,Ee,J,jn,Ds,uo,Ns,Ze,Zo,Un,Ls,Ms,Hr,$s,Bs}from"./vm-hands-entry-lite-
|
|
2
|
+
import{Ur,Ee,J,jn,Ds,uo,Ns,Ze,Zo,Un,Ls,Ms,Hr,$s,Bs}from"./vm-hands-entry-lite-bz0ys3fb.js";import"./vm-hands-entry-lite-3pnjdh8m.js";import"./vm-hands-entry-lite-hw26gewc.js";import"./vm-hands-entry-lite-fcvf8md1.js";import"./vm-hands-entry-lite-vgjj3d7r.js";import"./vm-hands-entry-lite-619ztrvp.js";import"./vm-hands-entry-lite-9sa1knn7.js";import"./vm-hands-entry-lite-r7zs4ce2.js";import"./vm-hands-entry-lite-8j7p91hr.js";import"./vm-hands-entry-lite-em7mk9tn.js";export{Ur as WORKER_SERVICE_ENV,J as WorkerServiceError,uo as connectServiceLabel,Ee as defaultWorkerServiceHost,Ms as installWorkerService,Ze as installedWorkerService,Ns as isConnectServiceLabel,Bs as removeWorkerService,Hr as restartWorkerService,$s as retargetWorkerServiceLogs,Zo as retireLegacyWorkerService,Ls as workerServiceDefinitionCurrent,jn as workerServiceLauncher,Un as workerServiceProcessRunning,Ds as workerServiceRetargetPending};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./vm-hands-entry-lite-9jgf223h.js";import"./vm-hands-entry-lite-fcvf8md1.js";import{g}from"./vm-hands-entry-lite-hw26gewc.js";import"./vm-hands-entry-lite-r7zs4ce2.js";import"./vm-hands-entry-lite-em7mk9tn.js";import"./vm-hands-entry-lite-n4x7reax.js";import{jt,ct}from"./vm-hands-entry-lite-1f2cam25.js";import{w,M,ar,Be,tt}from"./vm-hands-entry-lite-
|
|
2
|
+
import"./vm-hands-entry-lite-9jgf223h.js";import"./vm-hands-entry-lite-fcvf8md1.js";import{g}from"./vm-hands-entry-lite-hw26gewc.js";import"./vm-hands-entry-lite-r7zs4ce2.js";import"./vm-hands-entry-lite-em7mk9tn.js";import"./vm-hands-entry-lite-n4x7reax.js";import{jt,ct}from"./vm-hands-entry-lite-1f2cam25.js";import{w,M,ar,Be,tt}from"./vm-hands-entry-lite-z3a528r1.js";import"./vm-hands-entry-lite-tqc2ezda.js";import"./vm-hands-entry-lite-5rwx4xrq.js";import"./vm-hands-entry-lite-mvt73s88.js";import"./vm-hands-entry-lite-619ztrvp.js";import"./vm-hands-entry-lite-a3w8m8nb.js";import"./vm-hands-entry-lite-njs8k65s.js";import"./vm-hands-entry-lite-cm497v4t.js";import"./vm-hands-entry-lite-q6mpzzpj.js";import"./vm-hands-entry-lite-jcf61cb4.js";import"./vm-hands-entry-lite-vgjj3d7r.js";import"./vm-hands-entry-lite-0462ahs5.js";import"./vm-hands-entry-lite-d9g1pzzx.js";import"./vm-hands-entry-lite-7vkr3h93.js";import"./vm-hands-entry-lite-3pnjdh8m.js";import"./vm-hands-entry-lite-bz0ys3fb.js";import"./vm-hands-entry-lite-dcxvxpne.js";import"./vm-hands-entry-lite-3vmhs921.js";import"./vm-hands-entry-lite-499mywh7.js";import"./vm-hands-entry-lite-12rzrd95.js";import"./vm-hands-entry-lite-7ba3dm8a.js";import"./vm-hands-entry-lite-g9z467dk.js";import"./vm-hands-entry-lite-3adw9jw3.js";import"./vm-hands-entry-lite-89b18wqa.js";import"./vm-hands-entry-lite-ge81taff.js";import"./vm-hands-entry-lite-4fwf7wgb.js";import"./vm-hands-entry-lite-dh8f2h2d.js";import"./vm-hands-entry-lite-t5q30ne0.js";import{a}from"./vm-hands-entry-lite-9sa1knn7.js";import{t,o,u,i,s,n}from"./vm-hands-entry-lite-ba3qq0bs.js";import"./vm-hands-entry-lite-8j7p91hr.js";import{readFileSync as me,realpathSync as k,renameSync as ge,unlinkSync as fe,writeFileSync as he}from"fs";import{dirname as ye,join as I}from"path";function h(e){return`claude mcp add --transport http reason ${e}`}function C(e){return`codex mcp add reason --url ${e}
|
|
3
3
|
codex mcp login reason`}var F=h("https://mcp.reasonmachines.com/mcp"),z=C("https://mcp.reasonmachines.com/mcp"),B=`https://claude.ai/settings/connectors?add=custom&url=${encodeURIComponent("https://mcp.reasonmachines.com/mcp")}`,H=`https://cursor.com/install-mcp?name=reason&config=${encodeURIComponent(btoa(JSON.stringify({url:"https://mcp.reasonmachines.com/mcp"})))}`;var b="https://github.com/reason-machines/reason-plugins",X=`Connect a coding agent to Reason over MCP
|
|
4
4
|
|
|
5
5
|
Usage:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Xe,ft}from"./vm-hands-entry-lite-jcf61cb4.js";import{gt}from"./vm-hands-entry-lite-
|
|
2
|
+
import{Xe,ft}from"./vm-hands-entry-lite-jcf61cb4.js";import{gt}from"./vm-hands-entry-lite-619ztrvp.js";import{Co,le,Jr,mt,Ao}from"./vm-hands-entry-lite-vgjj3d7r.js";import{E}from"./vm-hands-entry-lite-qyp2a4c3.js";import{a,Qt}from"./vm-hands-entry-lite-9sa1knn7.js";import{spawnSync as H}from"child_process";import{dirname as w}from"path";import{spawn as A}from"child_process";import{accessSync as _,constants as v}from"fs";import{basename as C,join as O}from"path";var l=null;function S(e){if(l===e)l=null;if(e.exitCode===null&&e.signalCode===null)e.kill("SIGTERM")}var Gr=(e,t)=>{if(l)S(l);let s=O(e,Co);try{_(s,v.X_OK)}catch{return()=>{}}let n;try{n=A(s,["--app",e,"--name",C(e,".app"),"--permission",t==="screen"?"screen_recording":"accessibility"],{detached:!0,stdio:"ignore"})}catch{return()=>{}}return n.on("error",()=>{if(l===n)l=null}),n.once("exit",()=>{if(l===n)l=null}),n.unref(),l=n,()=>S(n)};import{chmodSync as ne,existsSync as se,mkdirSync as re,readFileSync as D,realpathSync as ie,renameSync as oe,statSync as j,writeFileSync as ae}from"fs";import{dirname as de,isAbsolute as G,join as N,resolve as T,sep as b}from"path";function F(e=a()){return N(Qt(e),"reason","protected-path-grants.json")}var f=null;function L(e){let t=JSON.parse(e);if(!Array.isArray(t?.grants))return[];return t.grants.flatMap((s)=>{let n=s;return n&&typeof n.path==="string"&&G(n.path)&&(n.kind==="file"||n.kind==="folder")&&typeof n.grantedAt==="number"?[{path:n.path,kind:n.kind,grantedAt:n.grantedAt}]:[]})}function y(e=F()){try{let{mtimeMs:t}=j(e);if(f&&f.file===e&&f.mtimeMs===t)return f.grants;let s=L(D(e,"utf8"));return f={file:e,mtimeMs:t,grants:s},s}catch{return[]}}function W(e,t){return e.kind==="file"?t===e.path:t===e.path||t.startsWith(`${e.path}${b}`)}function U(e,t){let s=T(e);return y(t).some((n)=>W(n,s))}function go(e,t){return E(e)&&!U(e,t)}function _o(e,t,s){let n=t?"file-read* file-write*":"file-read*";return y(s).filter((r)=>r.path===e||r.path.startsWith(`${e}${b}`)).map((r)=>`(allow ${n} (${r.kind==="file"?"literal":"subpath"} ${JSON.stringify(r.path)}))`)}var P="x-apple.systempreferences:com.apple.preference.security",J="curl -fsSL https://reasonmachines.com/install.sh | bash",q=180000,B=2000;var k={screen:{label:"Screen & System Audio Recording",purpose:"desktop video, computer-use screenshots",level:"required",pane:`${P}?Privacy_ScreenCapture`},accessibility:{label:"Accessibility",purpose:"computer-use clicks and typing, desktop input",level:"required",pane:`${P}?Privacy_Accessibility`},disk:{label:"Full Disk Access",purpose:"Sessions in Desktop, Documents, Downloads, iCloud Drive and Mail",level:"recommended",pane:`${P}?Privacy_AllFiles`}};function R(e){return e.executable}function K(e,t){if(e==="computer_use_identity_missing")return`Reason's background identity is not installed (${e}); reinstall Reason: ${J}`;if(e==="computer_use_identity_outdated")return`Reason's background identity is outdated (${Jr(t)??"unknown"}; this CLI is ${gt}) (${e}); \`reason update\` installs this release's`;return`Reason's background identity cannot run computer use for this CLI (${e}); run the installed \`reason\``}function Xo(e=a()){let t=mt(e);if(t.length>0)return{state:"ready",path:w(w(w(t[0]))),prefix:t};let s=Ao(t,e)??"computer_use_identity_unavailable";return{state:s,path:le(e),detail:K(s,e)}}function V(){return{identity:()=>Xo(),grants:(e)=>Xe(e),request:(e,t)=>ft(e,t),worker:async()=>(await import("./status-dvj49856.js")).connectionMacState(),open:(e)=>{H("/usr/bin/open",e,{stdio:"ignore",timeout:1e4})},tile:Gr,restartConnection:async()=>(await import("./connect-cli-k8qs2zrc.js")).restartConnection(),sleep:(e)=>new Promise((t)=>setTimeout(t,e)),now:()=>Date.now()}}function M(e,t,s){if(e.state!=="ready"||!t)return"unknown";return t[s]?"granted":"missing"}async function Yo(e){let t=e.identity(),s=t.state==="ready"?await e.grants(t.prefix):null,n=await e.worker(),r=n?R(n):null,i=!r||n?.full_disk_access==="unknown"?"unknown":n?.full_disk_access==="granted"?"granted":"missing",c=(u,d,o)=>{let{label:p,purpose:h,level:m}=k[u];return{id:u,label:p,purpose:h,level:m,state:d,holder:o}};return{identity:{state:t.state,path:t.path,detail:t.state==="ready"?null:t.detail},worker_detail:r?null:"Full Disk Access is read from this computer's running worker; `reason connect` starts it.",permissions:[c("screen",M(t,s,"screen"),t.path),c("accessibility",M(t,s,"accessibility"),t.path),c("disk",i,r)]}}function Fs(e){let t=e.identity.state==="ready"?null:e.identity.state,s=e.permissions.filter((i)=>i.state==="granted").length,n=[...t?[t]:[],...e.permissions.filter((i)=>i.state!=="granted"&&!(t&&i.id!=="disk")).map((i)=>`${i.label} ${i.state}`)],r=!t&&e.permissions.some((i)=>i.state==="missing");return`Permissions: ${s} of ${e.permissions.length}${n.length>0?` (${n.join(", ")})`:""}`+(r?" \u2014 reason permissions allow":n.length>0?" \u2014 reason permissions":"")}async function x(e,t){let s=t.now()+q;for(;;){if(await e())return!0;if(t.now()>=s)return!1;await t.sleep(B)}}async function js(e,t){let s=t.host??V(),{io:n}=t,r=await Yo(s),i=r.permissions.filter((o)=>e.includes(o.id)&&o.state!=="granted");if(i.length===0)return n.stdout.write(`Reason permissions: ${e.map((o)=>k[o].label).join(", ")} already allowed.
|
|
3
3
|
`),0;let c=!1,u=!1,d=s.identity();for(let o of i){let{label:p,pane:h}=k[o.id];if(o.id!=="disk"){if(d.state!=="ready"){if(!c)n.stderr.write(`Reason permissions: ${d.detail}
|
|
4
4
|
`);c=!0;continue}let g=o.id;await s.request(d.prefix,g),s.open([h]);let I=s.tile(d.path,g);if(n.stdout.write(`Allow Reason in System Settings > Privacy & Security > ${p}.
|
|
5
5
|
`),!t.wait)continue;if(n.stdout.write(`Waiting for it (Ctrl-C to stop)\u2026
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var Yt={name:"github-native-engineer-device-worker-production",version:"0.2.
|
|
2
|
+
var Yt={name:"github-native-engineer-device-worker-production",version:"0.2.449",private:!0,type:"module",engines:{node:">=22",bun:">=1.3.0"},workspaces:["../../packages/runtime-distribution"],dependencies:{"@anthropic-ai/sandbox-runtime":"^0.0.73","@earendil-works/pi-tui":"1.0.0","@modelcontextprotocol/sdk":"^1.29.0","@reason/runtime-distribution":"workspace:*","playwright-core":"1.60.0",zod:"^4.4.3"},overrides:{"@hono/node-server":"^1.19.15","@earendil-works/pi-agent-core":"1.0.0","@earendil-works/pi-ai":"1.0.0","@earendil-works/pi-coding-agent":"1.0.0","@earendil-works/chord":"1.0.0","@earendil-works/pi-codemode":"1.0.0","@earendil-works/pi-mcp":"1.0.0","@earendil-works/pi-telemetry":"1.0.0","@earendil-works/pi-tui":"1.0.0","brace-expansion":"2.1.7",axios:"^1.20.0","basic-ftp":"^6.2.1","@grpc/grpc-js":"^1.14.5",browserslist:"^4.28.8","engine.io":"^6.6.7","fast-uri":"^3.1.8",hono:"^4.13.7","ip-address":"^10.7.1",nanoid:"^3.3.18",dompurify:"^3.4.17",postcss:"^8.5.23",qs:"^6.16.0","shell-quote":"^1.11.0","socket.io-parser":"^4.2.7",tmp:"^0.2.7",toml:"^4.2.0",undici:"^8.10.2",ws:"^8.21.0","js-yaml":"^4.3.2","@modelcontextprotocol/sdk":"^1.31.0","proxy-addr":"^2.0.8","source-map-js":"^1.2.2"}};
|
|
3
3
|
export{Yt};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{at,Dt,xr,bn,kr,vn,Sn,En}from"./vm-hands-entry-lite-
|
|
2
|
+
import{at,Dt,xr,bn,kr,vn,Sn,En}from"./vm-hands-entry-lite-dcxvxpne.js";import{Pe,rr,Xn,_t,Io,oe,Do,No,Qe,Te,en,Qn,wt,ni,ii,oi,si,ai,ci,li,ui,di,pi,hi,fi,mi,pe,Y,Re,q,gi,_i,yi,wi,bi,vi,Si,Ei,bt,xi}from"./vm-hands-entry-lite-tqc2ezda.js";import{ue,Z,O}from"./vm-hands-entry-lite-r7zs4ce2.js";import{P,zt}from"./vm-hands-entry-lite-3vmhs921.js";import{lr,ji,Ui,nt,Hi,zi,qi,Wi,Vi,Gi,pr,hr,fr,dn,pn,mr,Ji,hn,gr,me,ge,Pt,_r,wr,Tt}from"./vm-hands-entry-lite-mvt73s88.js";import{D,R,b}from"./vm-hands-entry-lite-499mywh7.js";import{Mi,$i,ln,Bi,un,Fi,rt,cr}from"./vm-hands-entry-lite-7ba3dm8a.js";import{K}from"./vm-hands-entry-lite-d9g1pzzx.js";import{He}from"./vm-hands-entry-lite-a3w8m8nb.js";import{j}from"./vm-hands-entry-lite-1f2cam25.js";import{vr,_n,to}from"./vm-hands-entry-lite-njs8k65s.js";import{yo,wo,ht,bo,vo,So,Eo,xo}from"./vm-hands-entry-lite-jcf61cb4.js";import{Pr,Bt,Tr,On,In}from"./vm-hands-entry-lite-3adw9jw3.js";import{Lt,ze,Mt}from"./vm-hands-entry-lite-89b18wqa.js";import{Rn,x,so}from"./vm-hands-entry-lite-q6mpzzpj.js";import{go,_o}from"./vm-hands-entry-lite-0462ahs5.js";import{Nt,xn,kn}from"./vm-hands-entry-lite-ge81taff.js";import{ye,Xi,Yi}from"./vm-hands-entry-lite-dh8f2h2d.js";import{be}from"./vm-hands-entry-lite-yretc2th.js";import{It}from"./vm-hands-entry-lite-2yz6b0n3.js";import{ke,Kt,Jt,Zt,E}from"./vm-hands-entry-lite-qyp2a4c3.js";import{a,ie}from"./vm-hands-entry-lite-9sa1knn7.js";import{t,k,o,d,u,i,W,_,ee,s,n,$o}from"./vm-hands-entry-lite-ba3qq0bs.js";import{fe,Ne,Le,Me,nn}from"./vm-hands-entry-lite-8j7p91hr.js";import{$e}from"./vm-hands-entry-lite-mcjca0ez.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{request as kl}from"http";import{request as Tl}from"https";import{lookup as Dl}from"dns/promises";import{isIP as Nl}from"net";async function Ml(e){let l=new URL(e.url);return await new Promise((c,p)=>{let m=(l.protocol==="https:"?Tl:kl)(l,{method:"POST",headers:{...e.headers,"accept-encoding":"identity"},signal:e.signal,timeout:bn},(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 Qi=new Set(["ENOTFOUND","EAI_AGAIN","EAI_NONAME","EAI_NODATA","EAI_FAIL","DNSException"]),$l=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(Qi.has(c))return"custom_endpoint_host_not_found";if($l.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 Bl(e,l){let c=es(e),p=new URL(l).hostname.replace(/^\[|\]$/g,"");if(c!==null&&c!=="custom_endpoint_connection_failed"||Nl(p)!==0)return c;let m;return await Promise.race([Dl(p).then(()=>!0,(h)=>!Qi.has(String(h?.code))),new Promise((h)=>{m=setTimeout(()=>h(!0),5000)})]).finally(()=>clearTimeout(m))?c:"custom_endpoint_host_not_found"}function Fl(e){for(let l=42;;l++){if(l===127)l=256;let c=String.fromCodePoint(l);if(!e.includes(c))return c}}function Ul(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 g of h){while(f&&c[f]!==g){let v=m[f-1];w+=c.copy(S,w,0,f-v),f=v}if(c[f]===g){if(f++,f===c.length)w+=p.copy(S,w),f=0}else S[w++]=g}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=vn.safeParse(e.payload);if(!l.success)throw new r("custom_endpoint_invalid_request","Invalid local model request.");let c=l.data,p=Sn.parse(await e.credential(e.signal));if(!kr(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=Fl(p.apiKey),g=Ul(p.apiKey,w),v=async(I,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(I,A))).then(()=>{e.signal.removeEventListener("abort",L),M()},(B)=>{e.signal.removeEventListener("abort",L),N(B)})})},C=async(I)=>{if(h+=I.length,h>Dt)throw new r("custom_endpoint_response_too_large","Local model response exceeds the transport limit.");for(let A=0;A<I.length;A+=at){if(S>=xr)throw new r("custom_endpoint_response_too_large","Local model response exceeds the chunk limit.");await v(`custom_endpoint.chunk.${S++}`,{eof:!1,data:I.subarray(A,A+at).toString("base64")})}};try{let I=await Ml({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=I.response,f=I.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>Dt)throw new r("custom_endpoint_response_too_large","Local model response exceeds the transport limit.");await C(g(L))}return await C(g(Buffer.alloc(0),!0)),await v(`custom_endpoint.chunk.${S}`,{eof:!0}),{bytes:h,chunks:S}}catch(I){if(e.signal.throwIfAborted(),I instanceof r)throw I;throw new r((m?null:await Bl(I,c.url))??"custom_endpoint_request_failed","The local model server could not complete the request.")}finally{f?.()}}import{join as rs}from"path";function Hl(e,l){return e===rs(l,".ara","workspace")||e===rs(l,".reason","workspace")}function ns(e,l){let c=e.filter((p)=>Hl(p.path,l));return c.length===1?c[0].path:null}var jl=/^[a-f0-9]{64}$/;var on=32,ql=/^\/[^\x00-\x1f\x7f\\]*$/;function Er(e){if(typeof e!=="string"||e.length>4096||!ql.test(e))return!1;if(e==="/")return!0;return e.split("/").slice(1).every((l)=>l!==""&&l!=="."&&l!=="..")}function Cr(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 sn(e){if(!e||typeof e!=="object"||Array.isArray(e))return;let l=e;if(!Er(l.home)||!Array.isArray(l.roots)||l.roots.length>on)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"||!jl.test(m)||!Er(f))return;c.push({path_fingerprint:m,path:f})}return{home:l.home,roots:c}}function Wl(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 zl(e){return Wl(e)??e.email.toLowerCase()}function mn(e){let l=/^Co-authored-by:\s*([^<>\r\n]+) <([^<>\s]+)>$/i.exec(e.trim());return l?zl({name:l[1],email:l[2]}):e.trim().toLowerCase()}var jt=(e)=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/[a-z]/gi,(l)=>`[${l.toLowerCase()}${l.toUpperCase()}]`),Gl=[...ke.map((e)=>`/(${e.map(jt).join("/")})(/|$)`),...Kt.map((e)=>`/(${e.map(jt).join("/")})(/|$)`),...[...Jt].map((e)=>`/(${jt(e)})$`),`/${jt(".env.")}[^/]*$`,...Zt.map((e)=>`/[^/]*${jt(e)}$`)],os=`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"))',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{H}from"./vm-hands-entry-lite-r7zs4ce2.js";import{D,R,b}from"./vm-hands-entry-lite-499mywh7.js";import{Fe,ur,dr,fn,mn,it}from"./vm-hands-entry-lite-
|
|
2
|
+
import{H}from"./vm-hands-entry-lite-r7zs4ce2.js";import{D,R,b}from"./vm-hands-entry-lite-499mywh7.js";import{Fe,ur,dr,fn,mn,it}from"./vm-hands-entry-lite-mvt73s88.js";import{Ir}from"./vm-hands-entry-lite-1f2cam25.js";import{p,st,gn,_e,we}from"./vm-hands-entry-lite-dh8f2h2d.js";import{v,h}from"./vm-hands-entry-lite-t5q30ne0.js";import{a,Qt,Ro}from"./vm-hands-entry-lite-9sa1knn7.js";import{tn,y,t,k,o,d,es,Oe,Pi,u,i,W,_,ee,s,n,rn}from"./vm-hands-entry-lite-ba3qq0bs.js";import{se,A}from"./vm-hands-entry-lite-8j7p91hr.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{randomUUID as Q}from"crypto";import{spawn as je}from"child_process";import{existsSync as Z,lstatSync as me,mkdirSync as Le,readFileSync as We,realpathSync as G,rmSync as Ne,writeFileSync as Ve}from"fs";import{dirname as He,join as j,relative as Ue,sep as qe}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=_("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()]),Be=tn(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 f=e.first_cursor-1;for(let l of e.output){if(l.cursor<=f||l.cursor>e.next_cursor)return!1;f=l.cursor}return!0});function ae(e){return Se.includes(e)}var Xe=i({operation_constraints:ee(t(),Oe())}),Ye=i({ready:n(!0),version:n(1),execution_mode:s(["host","confined"]),max_timeout_ms:o().int().min(1000).optional()});var Ie=i({version:n(1),process_id:t().uuid(),state:s(["queued","cancelled_before_start","not_started"]),exit_code:es(),output:u(Pi()).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(),De=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=tn(De),Qe=W([J,Ie.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 Mi="preview.serve.v1",$i=43200000;var ce="preview.open.v1",de=1,ln="gid_proxy_v1",Bi="egress",un=/^(?:\*\.)?[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[1-9][0-9]{0,4})?$/,Ce=i({version:n(ln),allowed_domains:u(t().max(260).regex(un)).max(1024)}).strict(),Ae=rn((e)=>H(e)!==null,"invalid workspace"),ke=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:Ae,egress:Ce.optional()}).strict(),Fi=ke.extend({expires_at:y.datetime()}).strict();var Me=4,Te=5000;function Y(e,c,f){let l=null;try{l=st(e)}catch{}gn({deviceRelayUrl:l?.deviceRelayUrl??"",binding:l?.binding??null,jobId:c,port:l?.binding.port??0,reason:l?f:"binding_invalid"})}function le(e){let c=new Map;return{open(f){let l=(x)=>Y(f,e.claim.operation_id,x),C;try{C=st(f)}catch{return l("binding_invalid")}let{binding:w,deviceRelayUrl:z}=C,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 I=x instanceof Error?x.message:"preview_failed";if(I!=="preview_not_authorized")process.stderr.write(`${JSON.stringify({event:"worker_preview.open_failed",job_id:w.jobId,port:w.port,reason_code:I})}
|
|
3
3
|
`)}).finally(()=>{if(c.get(w.port)===L)c.delete(w.port)})},dispose(){for(let f of c.values())f.abort();c.clear()}}}class rt 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 M("process_authority_lost");return c}if(V.size>=fe)throw M("process_journal_capacity");let f={claim:e,executing:!1,cancelRequested:!1,phase:"pending"};return V.set(e.operation_id,f),f}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)),M=(e="process_outcome_uncertain")=>new r(e,"The managed process outcome could not be confirmed; inspect its saved receipt before starting another intent.");function Je(e=a(),c=ze()){let f=He(Ir({},e)),l=Ue(Qt(e),f),[C,...w]=l.split(qe);return{directory:j(c,l,"processes"),previous:[j(f,"processes"),...C==="reason"?[j(c,"ara",...w,"processes")]:[]]}}function ze(){if(process.platform!=="darwin")throw new r("process_unavailable","Managed Mac process execution is unavailable.");let e=Ro();if(!e)throw new r("process_unavailable","The private per-user process directory is unavailable.");return e}async function cr(e){if(!e.claim.owner||e.signal.aborted||e.expiresAtMs<=Date.now())throw M("process_authority_lost");let c=be(e.claim);if(c.executing)throw M("process_busy");if(c.executing=!0,c.cancelRequested)return c.phase="settling",pe(e.claim.operation_id);c.phase="starting";let f=e.journals??Je();Le(f.directory,{recursive:!0,mode:448});let l=ur({runtimeDirectory:G(f.directory),previousRuntimeDirectories:(f.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});try{for(let m of[e.root,e.cwd])if(!Fe(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 C=me(l.journalDirectory),w=e.claim.capability===he,z=()=>B.set(e.claim.operation_id,{path:l.journalDirectory,ino:C.ino,dev:C.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:D,protocolVersion:2,workerArtifactSha256:b,workerEntrypoint:R,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{Ve(L,JSON.stringify(P),{mode:384});let m=fn({configPath:L,root:e.cwd,grantedRoot:e.root,workRoot:e.root,temporaryDirectory:E});x=e.spawnWorker?.(L,P)??je(m.command,m.args,{...m.options,env:e.environment,stdio:[mn,"ignore","ignore"]})}catch(m){throw l.disposeSocket(),m}let I=!1,F=new Promise((m,S)=>{x.once("exit",(g)=>{I=!0,m(g)}),x.once("error",(g)=>{I=!0,S(g)})});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 dr(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 M(S.error);return S.job},U=!1,q=!1,te,re=()=>{U=!0,it(x,"SIGTERM")};e.signal.addEventListener("abort",re,{once:!0});let T,oe=0,ve=async(m)=>{let S=[...m.output],g={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(g))>90000&&S.length)S.shift(),g.truncated=!0,g.first_cursor=S[0]?.cursor??g.next_cursor+1;T=J.parse(g),await e.emit(T),oe=Date.now()};try{let m=Math.min(Date.now()+1e4,e.expiresAtMs);while(!Z(P.readyPath)){if(I)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 M("process_start_unconfirmed");await ue(25)}let S=JSON.parse(We(P.readyPath,"utf8"));if(S.launchId!==P.launchId||S.fenceId!==P.fenceId||S.workerArtifactSha256!==b)throw M();if(e.signal.throwIfAborted(),c.cancelRequested)return pe(e.claim.operation_id);let g;try{q=!0,g=await N("start")}catch(O){if(!(O instanceof r)||O.code!=="hands_job_result_unknown")throw O;g=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"&&!I?await N("probe"):null});if(c.cancelRequested)await c.cancel(),g=await N("inspect");for(;;){if(!["starting","running"].includes(g.state))c.phase="settling",c.cancel=void 0;if(!T||T.state!==g.state||T.next_cursor!==g.nextCursor&&Date.now()-oe>=5000)await ve(g);if(!["starting","running"].includes(g.state))break;if(e.signal.aborted||I)throw M();await ue(1000);try{g=await N("inspect"),te=void 0}catch(O){if(!(O instanceof r)||O.code!=="hands_job_result_unknown"||e.signal.aborted||I||Date.now()-(te??=Date.now())>120000)throw O}}if(!T||T.state==="uncertain")throw M();return T}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),!I&&!U)it(x,"SIGTERM");let m,S=await Promise.race([F.then((g)=>({code:g})),new Promise((g)=>{m=setTimeout(()=>g(null),6000)})]).finally(()=>{clearTimeout(m)});if(!S){try{it(x,"SIGKILL")}catch{}try{await F}finally{if(I)l.disposeSocket()}throw M("process_cleanup_unconfirmed")}try{if((U||e.signal.aborted)&&S.code===0&&q){v(E);let g=JSON.parse(h(P.directTerminalReceiptPath)),O=X.safeParse(g.observation);if(Object.keys(g).length===4&&g.launch_id===P.launchId&&g.fence_id===P.fenceId&&g.scope_id===l.scopeId&&O.success&&O.data.process_id===e.claim.operation_id){if(w)z();throw new rt(O.data)}}}catch(g){if(g instanceof rt)throw g}finally{if(I)l.disposeSocket()}if(S.code!==0&&!U&&q)throw M("process_cleanup_unconfirmed");if(!U&&S.code===0&&(T&&["exited","cancelled","expired"].includes(T.state)||!q&&c.cancelRequested)||w&&S.code===0&&!q)z()}}async function ks(e,c){if(c.kind===ce&&e.capability===he){let C=V.get(e.operation_id);if(C?.claim===e&&C.tunnels)C.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 f=V.get(e.operation_id);if(f&&f.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 Cs(e,c){V.delete(e);let f=B.get(e);if(!f||c!=="succeeded"&&!f.anyCompletion)return B.delete(e),!1;try{let l=me(f.path);if(!l.isDirectory()||l.isSymbolicLink()||l.ino!==f.ino||l.dev!==f.dev||!A(l)||G(f.path)!==f.path||Z(j(f.path,"owner.lock")))return!1;return Ne(f.path,{recursive:!0}),B.delete(e),!0}catch{return!1}}
|
|
4
4
|
export{Mi,$i,ln,Bi,un,Fi,rt,cr,ks,Cs};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{T}from"./vm-hands-entry-lite-fcvf8md1.js";import{Kr}from"./vm-hands-entry-lite-
|
|
2
|
+
import{T}from"./vm-hands-entry-lite-fcvf8md1.js";import{Kr}from"./vm-hands-entry-lite-vgjj3d7r.js";import{ut}from"./vm-hands-entry-lite-3rwtqr28.js";import{a}from"./vm-hands-entry-lite-9sa1knn7.js";import{A}from"./vm-hands-entry-lite-8j7p91hr.js";import{randomUUID as f}from"crypto";import{chmodSync as U,closeSync as h,constants as g,existsSync as me,fstatSync as F,lstatSync as R,mkdirSync as B,openSync as G,readFileSync as Y,readdirSync as z,readlinkSync as J,realpathSync as P,renameSync as _,rmSync as p,statSync as K,symlinkSync as _t,unlinkSync as M,writeFileSync as L}from"fs";import{basename as vt,dirname as S,isAbsolute as fe,join as c,relative as ge,resolve as b,sep as _e}from"path";import{createRequire as H}from"module";var q=1,j=1,ye=128,ve=65536;var he=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;var D=/^[a-z0-9_.-]{1,80}$/,be=64,Ee="so.ara.device-broker",Me=[Ee,"com.reasonmachines.device-broker"],Pt=Kr(Me);var we=["service.install_started","service.install_completed","service.install_failed","service.launcher_adopted","service.launcher_conflict","service.started","service.reconnecting","service.reconnected","service.idle_sleep_held","service.idle_sleep_released","service.idle_sleep_failed","service.start_failed","service.stopped","service.exit_failed","service.singleton_rejected","credential.migration_started","credential.migration_completed","credential.migration_failed","credential.store_started","credential.store_completed","credential.store_failed","credential.delete_started","credential.delete_completed","credential.delete_failed","update.check_started","update.not_available","update.download_started","update.downloaded","update.verified","update.activated","update.rollback","update.failed","executor.update.check_started","executor.update.not_available","executor.update.download_started","executor.update.downloaded","executor.update.verified","executor.update.activated","executor.update.rollback","executor.update.failed","identity.refresh_completed","identity.refresh_failed","update.device_moved","update.components_installed","update.deferred","update.deferral_expired","worker.previous_exit","worker.capabilities_withheld","identity.computer_use_unavailable"];function X(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function W(e,t,n=[]){let r=new Set([...t,...n]);return t.every((i)=>(i in e))&&Object.keys(e).every((i)=>r.has(i))}function E(e){return typeof e==="string"&&he.test(e)}function Z(e){return typeof e==="string"&&!Number.isNaN(Date.parse(e))&&new Date(e).toISOString()===e}function k(e){B(e,{recursive:!0,mode:448}),U(e,448)}function Re(e,t){k(S(e));let n=`${e}.${process.pid}.${f()}.tmp`;try{L(n,t,{mode:384,flag:"wx"}),U(n,384),_(n,e)}finally{if(me(n))M(n)}}function hs(e={}){if((e.platform??process.platform)!=="darwin")throw new ut("unsupported_platform","The managed Reason runtime is currently available only on macOS.");let n=e.environment??process.env,r=T(n,"REASON_CLI_CHANNEL")==="staging",i=r?T(n,"REASON_MANAGED_RUNTIME_ROOT")?.trim():void 0,o=e.root!==void 0||Boolean(i&&fe(i))?null:c(e.home??a(),"Library","Application Support"),d=e.root??(o?c(o,r?"Reason Staging":"Reason","CLI"):i);return{executableName:"reason",root:d,...o?{legacyRoot:c(o,"Ara",...r?["staging","runtime"]:["runtime"])}:{},versions:c(d,"versions"),current:c(d,"current"),previous:c(d,"previous"),brokerLock:c(d,"broker.lock"),transitionLock:c(d,"transition.lock"),lifecycleEvents:c(d,"lifecycle-events")}}function fs(e){let t=e.legacyRoot;if(!t)return null;return{root:t,versions:c(t,"versions"),current:c(t,"current"),previous:c(t,"previous"),brokerLock:c(t,"broker.lock"),transitionLock:c(t,"transition.lock"),lifecycleEvents:c(t,"lifecycle-events")}}function pe(e,t){let n;try{if(!R(e).isSymbolicLink())return null;n=J(e)}catch{return null}let r=n.match(/^versions\/(\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?)\/(ara|Reason|reason)$/);return r&&(r[2]==="ara"||r[2]===t)?r[1]:null}function ms(e){return pe(e.current,e.executableName)}function O(e,t,n){let i=ge(t,e).split(_e);return i.length===2&&E(i[0])&&(i[1]==="ara"||n!==void 0&&i[1]===n)?i[0]:null}function Le(e,t){try{return R(t).isSymbolicLink()&&b(S(t),J(t))===b(e.current)}catch{return!1}}function gs(e,t=process.execPath){try{return O(P(t),P(e.versions),e.executableName)!==null}catch{let n=b(t);return n===b(e.current)||Le(e,n)||O(n,b(e.versions),e.executableName)!==null}}function Ae(e){return X(e)&&W(e,["schema_version","pid","nonce","started_at","runtime_version"])&&e.schema_version===q&&typeof e.pid==="number"&&Number.isSafeInteger(e.pid)&&e.pid>0&&typeof e.nonce==="string"&&/^[0-9a-f-]{36}$/.test(e.nonce)&&Z(e.started_at)&&E(e.runtime_version)}function Q(e,t){try{let n=R(e);if(!n.isDirectory()||!A(n))return null;let r=G(c(e,t),g.O_RDONLY|g.O_NOFOLLOW|g.O_NONBLOCK);try{let i=F(r);if(!i.isFile()||i.nlink!==1||!A(i)||i.size>4096)return null;return Y(r,"utf8")}finally{h(r)}}catch{return null}}function N(e){try{let t=JSON.parse(Q(e,"owner.json")??"null");return Ae(t)?t:null}catch{return null}}function ee(e){try{return process.kill(e,0),!0}catch(t){return!(t instanceof Error&&("code"in t)&&t.code==="ESRCH")}}var C="lease",Ne=2,Se=4,y;function ke(){if(y!==void 0)return y;if(y=null,process.platform!=="linux"&&process.platform!=="darwin")return null;let e;try{e=H(import.meta.url)("bun:ffi")}catch{return null}let t=process.platform==="darwin"?"__error":"__errno_location",n=process.platform==="darwin"?["/usr/lib/libSystem.B.dylib"]:["libc.so.6",`libc.musl-${process.arch==="arm64"?"aarch64":"x86_64"}.so.1`];for(let r of n)try{let i=e.dlopen(r,{flock:{args:[e.FFIType.i32,e.FFIType.i32],returns:e.FFIType.i32},[t]:{args:[],returns:e.FFIType.ptr}}),s=i.symbols[t]();if(s===null)continue;return y={flock:(o,d)=>i.symbols.flock(o,d),errno:()=>e.read.i32(s),wouldBlock:process.platform==="darwin"?35:11},y}catch{}return null}var v,Ie=3221225472,Te=4,xe=128,Pe=32;function De(e){if(v===void 0){v=null;try{let s=H(import.meta.url)("bun:ffi"),{FFIType:o}=s;v={kernel:s.dlopen("kernel32.dll",{CreateFileW:{args:[o.ptr,o.u32,o.u32,o.ptr,o.u32,o.u32,o.ptr],returns:o.i64_fast},CloseHandle:{args:[o.i64_fast],returns:o.i32},GetLastError:{args:[],returns:o.u32}}).symbols,ptr:(l)=>s.ptr(l)}}catch{return null}}if(!v)return null;let{kernel:t,ptr:n}=v,r=Buffer.from(`${e}\x00`,"utf16le"),i=t.CreateFileW(n(r),Ie,0,null,Te,xe,null);if(Number(i)===-1)return t.GetLastError()===Pe?"busy":null;return{release:()=>{t.CloseHandle(i)}}}function Oe(e){if(process.platform==="win32")return De(`${e}.lease`);let t=ke();if(!t)return null;let n=G(`${e}.lease`,g.O_RDWR|g.O_CREAT|g.O_NOFOLLOW,384);try{let r=F(n);if(!r.isFile()||r.nlink!==1||!A(r))return h(n),"busy";if(t.flock(n,Ne|Se)===0)return{release:()=>h(n)};let i=t.errno();return h(n),i===t.wouldBlock?"busy":null}catch(r){throw h(n),r}}function _s(e){k(S(e.path));let t=Oe(e.path);if(t==="busy")return{acquired:!1,owner:N(e.path),recoveredStaleOwner:!1};let n=t!==null;try{let r=Ce(e,t);if(r.acquired)n=!1;return r}finally{if(n)t.release()}}function Ce(e,t){let n=e.alive??ee,r=!1;for(let i=0;i<4;i+=1){let s={schema_version:q,pid:e.pid??process.pid,nonce:e.nonce?.()??f(),started_at:(e.now?.()??new Date).toISOString(),runtime_version:e.runtimeVersion},o=`${e.path}.init-${process.pid}-${f()}`,d=!1;try{if(B(o,{mode:448}),L(c(o,"owner.json"),`${JSON.stringify(s)}
|
|
3
3
|
`,{mode:384,flag:"wx"}),t!==null)L(c(o,C),`flock
|
|
4
4
|
`,{mode:384,flag:"wx"});e.beforePublish?.();try{throw R(e.path),Object.assign(Error("Managed runtime lock exists."),{code:"EEXIST"})}catch(m){if(m.code!=="ENOENT")throw m}_(o,e.path),d=!0;let l=!1;return{acquired:!0,owner:s,recoveredStaleOwner:r,release(){if(l)return;if(l=!0,N(e.path)?.nonce===s.nonce)p(e.path,{recursive:!0,force:!0});t?.release()}}}catch(l){let m=l.code;if(!["EEXIST","ENOTEMPTY"].includes(m??""))throw l;let u=N(e.path),re=(e.now?.()??new Date).getTime(),ie=u&&e.staleAfterMs!==void 0?re-Date.parse(u.started_at)<e.staleAfterMs:!1,ae=u!==null&&!(t!==null&&Q(e.path,C)!==null)&&n(u.pid);if(!u||ae||ie)return{acquired:!1,owner:u,recoveredStaleOwner:!1};let I=`${e.path}.stale-${process.pid}-${f()}`;try{_(e.path,I),p(I,{recursive:!0,force:!0}),r=!0}catch(x){let oe=x.code;if(!["ENOENT","EEXIST"].includes(oe??""))throw x}}finally{if(!d)p(o,{recursive:!0,force:!0})}}throw new ut("lock_unavailable","Could not acquire the managed Reason runtime lock.")}function te(e){return X(e)&&W(e,["schema_version","event_id","occurred_at","event","runtime_version"],["from_version","to_version","reason_code","duration_ms","attempt_count","retry_in_ms","capabilities"])&&e.schema_version===j&&typeof e.event_id==="string"&&/^[0-9a-f-]{36}$/.test(e.event_id)&&Z(e.occurred_at)&&typeof e.event==="string"&&we.includes(e.event)&&E(e.runtime_version)&&(e.from_version===void 0||E(e.from_version))&&(e.to_version===void 0||E(e.to_version))&&(e.reason_code===void 0||typeof e.reason_code==="string"&&D.test(e.reason_code))&&(e.duration_ms===void 0||typeof e.duration_ms==="number"&&Number.isSafeInteger(e.duration_ms)&&e.duration_ms>=0&&e.duration_ms<=86400000)&&(e.attempt_count===void 0||typeof e.attempt_count==="number"&&Number.isSafeInteger(e.attempt_count)&&e.attempt_count>=1&&e.attempt_count<=1e5)&&(e.retry_in_ms===void 0||typeof e.retry_in_ms==="number"&&Number.isSafeInteger(e.retry_in_ms)&&e.retry_in_ms>=0&&e.retry_in_ms<=30000)&&(e.capabilities===void 0||Array.isArray(e.capabilities)&&e.capabilities.length<=be&&e.capabilities.every((t)=>typeof t==="string"&&D.test(t)))}var Ve=/^(\d{22}-[0-9a-f-]{36}\.json)$/,Ue=/^(\d{22}-[0-9a-f-]{36}\.json)\.sending-(\d+)-[0-9a-f-]{36}$/,Fe=300000,w=0n;function Be(e){let t=BigInt(new Date(e.occurred_at).getTime())*1000000n;return w=t>w?t:w+1n,`${String(w).padStart(22,"0")}-${e.event_id}.json`}function ne(e){try{return z(e.lifecycleEvents).filter((t)=>Ve.test(t)).sort()}catch{return[]}}function V(e){try{let t=JSON.parse(Y(e,"utf8"));return te(t)?t:null}catch{return null}}function $e(e,t=ee,n=Date.now()){let r;try{r=z(e.lifecycleEvents)}catch{return}for(let i of r){let s=i.match(Ue);if(!s)continue;let o=c(e.lifecycleEvents,i),d=c(e.lifecycleEvents,s[1]),l=!t(Number(s[2]));if(!l)try{l=n-K(o).mtimeMs>=Fe}catch{continue}if(!l)continue;try{_(o,d)}catch(m){let u=m.code;if(u==="EEXIST")M(o);else if(u!=="ENOENT")throw m}}}function Ge(e){let n=ne(e).flatMap((i)=>{try{return[{name:i,size:K(c(e.lifecycleEvents,i)).size}]}catch{return[]}}),r=n.reduce((i,s)=>i+s.size,0);while(n.length>ye||r>ve){let i=n.shift();if(!i)break;try{M(c(e.lifecycleEvents,i.name)),r-=i.size}catch(s){if(s.code!=="ENOENT")throw s}}}function ys(e,t,n={}){let r={schema_version:j,event_id:n.eventId?.()??f(),occurred_at:(n.now?.()??new Date).toISOString(),...t};if(!te(r))throw new ut("invalid_lifecycle_event","Managed runtime lifecycle event is invalid.");return k(e.lifecycleEvents),Re(c(e.lifecycleEvents,Be(r)),`${JSON.stringify(r)}
|
|
5
5
|
`),Ge(e),r}async function bs(e,t,n){$e(e);let r=0;for(let i of ne(e)){let s=c(e.lifecycleEvents,i);if(n){let l=V(s);if(!l||!n(l))continue}let o=`${s}.sending-${process.pid}-${f()}`;try{_(s,o)}catch(l){if(l.code==="ENOENT")continue;throw l}let d=V(o);if(!d){M(o);continue}try{await t(d),M(o),r+=1}catch{try{_(o,s)}catch(l){if(l.code!=="ENOENT")throw l}break}}return r}export{hs,fs,ms,gs,_s,ys,bs};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Wn,ko,Gt}from"./vm-hands-entry-lite-jcf61cb4.js";import{Cn,We,oo,An,Pn,Tn,Cr,x}from"./vm-hands-entry-lite-
|
|
2
|
+
import{Wn,ko,Gt}from"./vm-hands-entry-lite-jcf61cb4.js";import{Cn,We,oo,An,Pn,Tn,Cr,x}from"./vm-hands-entry-lite-q6mpzzpj.js";import{Et}from"./vm-hands-entry-lite-g9z467dk.js";import{Rr}from"./vm-hands-entry-lite-3adw9jw3.js";import{j}from"./vm-hands-entry-lite-1f2cam25.js";import{a}from"./vm-hands-entry-lite-9sa1knn7.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFile as z,spawn as H}from"child_process";import{randomBytes as he}from"crypto";import{chmodSync as Qe,existsSync as I,lstatSync as _e,mkdirSync as De,readFileSync as we,rmSync as ee,writeFileSync as U}from"fs";import{connect as Re}from"net";import{join as y}from"path";var P=32,w=76;var B="./desktop-wallpaper-0pjhgyfk.jpg";var O="./dock-browser-afp005mt.png";var F="./dock-files-rywdm96b.png";var k="./dock-terminal-s41cj1jp.png";var K=`# Sets the X root window background and _XROOTPMAP_ID, as feh --bg-fill does.
|
|
3
3
|
# The native Blaxel image ships no feh, hsetroot or compositor, but it does ship
|
|
4
4
|
# python3-gi and libX11. tint2 reads _XROOTPMAP_ID to draw its transparent panel.
|
|
5
5
|
# Usage: DISPLAY=:99 python3 set-root-wallpaper.py IMAGE
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{T}from"./vm-hands-entry-lite-fcvf8md1.js";import{g}from"./vm-hands-entry-lite-hw26gewc.js";import{zr,Hn,qr,zn}from"./vm-hands-entry-lite-3pnjdh8m.js";import{Jn,Xt,To}from"./vm-hands-entry-lite-
|
|
2
|
+
import{T}from"./vm-hands-entry-lite-fcvf8md1.js";import{g}from"./vm-hands-entry-lite-hw26gewc.js";import{zr,Hn,qr,zn}from"./vm-hands-entry-lite-3pnjdh8m.js";import{Jn,Xt,To}from"./vm-hands-entry-lite-vgjj3d7r.js";import{C}from"./vm-hands-entry-lite-8j7p91hr.js";import{spawnSync as v}from"child_process";import{createHash as ke,randomUUID as Se}from"crypto";import{chmodSync as we,existsSync as P,mkdirSync as $e,readdirSync as Ve,readFileSync as k,renameSync as ye,rmSync as u,statSync as ve,writeFileSync as be}from"fs";import{dirname as We,isAbsolute as q,join as p}from"path";import{spawnSync as de}from"child_process";import{readFileSync as me}from"fs";import{userInfo as D}from"os";import{join as fe}from"path";var ge="REASON_SCHEDULED_TASK";function H(r){return fe(r,"AppData","Local","Reason","Tasks")}function w(r){if(/[\0-\x1f\x7f"%]/.test(r))throw Error(`A background task cannot use a value with a double quote, percent sign or control character: ${r}`);return`'${r.replace(/['\u2018\u2019\u201a\u201b]/g,"$&$&")}'`}function M(r){if(!/^[A-Za-z0-9._-]+$/.test(r))throw Error(`Invalid Windows Scheduled Task name: ${r}`);return`$env:${ge}=${w(r)};`}function K(r){let e=Object.entries(r.environment).map(([t,i])=>{if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(t))throw Error(`Invalid Windows Scheduled Task environment name: ${t}`);return`$env:${t}=${w(i)};`}),n=`$global:LASTEXITCODE=1; & ${[r.program,...r.args].map(w).join(" ")} 2>&1 | ForEach-Object { Add-Content -LiteralPath ${w(r.log)} -Value $_.ToString() -Encoding UTF8 }; $c=$LASTEXITCODE;`;return[M(r.name),...e,"$ErrorActionPreference='Continue';",r.keepAlive?`do { ${n} if ($c) { Start-Sleep -Seconds 10 } } while ($c)`:`${n} exit $c`].join(" ")}function I(r){return r.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function pe(){let r=process.env.USERDOMAIN?.trim();return r?`${r}\\${D().username}`:D().username}function U(r){let e=I(r.user??pe()),n=r.schedule==="logon",t=r.schedule==="logon"?`<LogonTrigger><Enabled>true</Enabled><UserId>${e}</UserId></LogonTrigger>`:`<TimeTrigger><Repetition><Interval>PT${r.schedule.everyMinutes}M</Interval><StopAtDurationEnd>false</StopAtDurationEnd></Repetition><StartBoundary>2026-01-01T00:00:00</StartBoundary><Enabled>true</Enabled></TimeTrigger>`,i=`-NoProfile -NonInteractive -ExecutionPolicy Bypass -WindowStyle Hidden -Command "${r.script}"`;return`<?xml version="1.0" encoding="UTF-16"?>
|
|
3
3
|
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
4
4
|
<RegistrationInfo>
|
|
5
5
|
<Description>${I(r.description)}</Description>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t,o,i,W,ee,s,n}from"./vm-hands-entry-lite-ba3qq0bs.js";var at=32768,Dt=67108864,xr=16384,E=204800,bn=600000,_=["content-type","anthropic-version","user-agent"],m=s(["openai-completions","openai-responses","anthropic-messages"]),f=new Set(_),C=ee(t(),t().max(2048)).refine((e)=>Object.keys(e).every((r)=>f.has(r))&&Object.values(e).every((r)=>!/[\r\n\0]/.test(r)),"Only non-secret custom endpoint request headers are permitted");function
|
|
2
|
+
import{t,o,i,W,ee,s,n}from"./vm-hands-entry-lite-ba3qq0bs.js";var at=32768,Dt=67108864,xr=16384,E=204800,bn=600000,_=["content-type","anthropic-version","user-agent"],m=s(["openai-completions","openai-responses","anthropic-messages"]),f=new Set(_),C=ee(t(),t().max(2048)).refine((e)=>Object.keys(e).every((r)=>f.has(r))&&Object.values(e).every((r)=>!/[\r\n\0]/.test(r)),"Only non-secret custom endpoint request headers are permitted");function a(e){try{let r=new URL(e);return["http:","https:"].includes(r.protocol)&&!r.username&&!r.password&&!r.search&&!r.hash?r:null}catch{return null}}function kr(e,r){let c=a(e.baseUrl),l=a(r.baseUrl),u=a(e.url);if(!c||!l||!u||e.method!=="POST"||r.execution!=="device")return!1;let d=(p)=>p.origin+p.pathname.replace(/\/+$/,"");if(d(c)!==d(l)||u.origin!==c.origin)return!1;let h=r.api==="openai-completions"?"/chat/completions":r.api==="openai-responses"?"/responses":"/v1/messages";return u.pathname===c.pathname.replace(/\/+$/,"")+h}var vn=i({baseUrl:t().max(2048),url:t().max(4096),method:n("POST"),body:t().refine((e)=>new TextEncoder().encode(e).byteLength<=E).optional(),headers:C,credentialOrganizationId:t().uuid(),accountKey:t().min(1).max(256).optional()}).strict().refine((e)=>m.options.some((r)=>kr(e,{baseUrl:e.baseUrl,api:r,execution:"device"})),"Invalid custom endpoint inference URL"),x=i({status:o().int().min(200).max(599),statusText:t().max(256).refine((e)=>!/[\r\n\0]/.test(e)),headers:ee(t(),t().max(4096)).refine((e)=>Object.keys(e).every((r)=>["content-type","retry-after","x-request-id","request-id"].includes(r))&&Object.values(e).every((r)=>!/[\r\n\0]/.test(r)))}).strict(),D=W([i({eof:n(!0)}).strict(),i({eof:n(!1),data:t().max(Math.ceil(at/3)*4).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/).refine((e)=>e.length>0&&e.length*3/4-(e.endsWith("==")?2:e.endsWith("=")?1:0)<=at)}).strict()]),y=i({bytes:o().int().min(0).max(Dt),chunks:o().int().min(0).max(xr)}).strict(),Sn=i({apiKey:t().min(1).max(16384).refine((e)=>!/[\r\n\0]/.test(e)),api:m}).strict(),g=["custom_endpoint_host_not_found","custom_endpoint_connection_failed","custom_endpoint_tls_failed"];function En(e){return typeof e==="string"&&g.includes(e)}var S="Ollama listens only on 127.0.0.1 unless it is started with OLLAMA_HOST=0.0.0.0.",O={custom_endpoint_host_not_found:"Your computer couldn't resolve your model server's hostname. Check the hostname in the Base URL, and that this computer is on the network or tailnet that resolves it.",custom_endpoint_connection_failed:`Your computer's connection to your model server was refused or timed out. Check that the server is running and listening on the Base URL's address and port. ${S}`,custom_endpoint_tls_failed:"Your computer couldn't make a secure (TLS) connection to your model server. Check the server's https certificate, or use an http:// Base URL for a server on your computer or private network.",401:"Your model server refused the request (HTTP 401). Check the API key saved for it in Models.",403:"Your model server refused the request (HTTP 403). Ollama refuses requests addressed to a hostname other than localhost, such as a *.ts.net name from tailscale serve or funnel: restart it with OLLAMA_HOST=0.0.0.0, or use http://localhost:11434/v1 when it runs on the session's computer. For another server, check the API key and its access rules.",404:"Your model server answered HTTP 404 (not found). Check that the Base URL is the API root (for Ollama, http://localhost:11434/v1) and that each model ID is one the server lists."};var I=new Set(Object.values(O));export{at,Dt,xr,bn,kr,vn,Sn,En};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{qe,io,F,We,$t,Ar,x}from"./vm-hands-entry-lite-
|
|
2
|
+
import{qe,io,F,We,$t,Ar,x}from"./vm-hands-entry-lite-q6mpzzpj.js";import{K}from"./vm-hands-entry-lite-d9g1pzzx.js";import{ft}from"./vm-hands-entry-lite-jcf61cb4.js";import{mt}from"./vm-hands-entry-lite-vgjj3d7r.js";import{Gr}from"./vm-hands-entry-lite-0462ahs5.js";import{Et,Oi}from"./vm-hands-entry-lite-g9z467dk.js";import{G,ze}from"./vm-hands-entry-lite-89b18wqa.js";import{Ee,jn}from"./vm-hands-entry-lite-bz0ys3fb.js";import{bt}from"./vm-hands-entry-lite-tqc2ezda.js";import{a}from"./vm-hands-entry-lite-9sa1knn7.js";import{C}from"./vm-hands-entry-lite-8j7p91hr.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{spawn as R,spawnSync as it}from"child_process";import{createHash as st,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 pt,writeFileSync as gt}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";
|
|
@@ -849,7 +849,7 @@ if(process.env.REASON_CLOUD_GATEWAY_EXEC === "1") {
|
|
|
849
849
|
process.stdout.write(JSON.stringify(cloudAutomationFailure(error))+"\\n");process.exitCode=1;
|
|
850
850
|
}
|
|
851
851
|
}
|
|
852
|
-
`;import{spawn as
|
|
852
|
+
`;import{spawn as Te}from"child_process";import{lstatSync as V,readFileSync as Z,rmSync as Ne}from"fs";import{basename as Pe}from"path";var De="__desktop-call",Me="/usr/bin/setpriv",Ue=27262976,Le=8192,$e=2000;function q(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function Be(e){try{return JSON.parse(e)}catch{return null}}function Fe(){return[process.execPath,...Pe(process.execPath).startsWith("bun")&&process.argv[1]?[process.argv[1]]:[],De]}function Ge(e){let o=(s)=>{try{return V(s).uid}catch{return null}},t=V("/tmp/.X11-unix",{throwIfNoEntry:!1});if(!t?.isDirectory()||t.uid!==0)return;let n=["/tmp/.X99-lock","/tmp/.X11-unix/X99"].filter((s)=>{let u=o(s);return u!==null&&u!==e.uid});if(!n.length)return;let i="";try{let s=Z("/tmp/.X99-lock","utf8").trim();if(/^\d+$/.test(s))i=Z(`/proc/${s}/comm`,"utf8").trim()}catch{}if(/^X/.test(i))return;for(let s of n)Ne(s,{force:!0})}function Nt(e,o,t,n={}){if(t.throwIfAborted(),(o.op==="display"||o.op==="automation")&&process.platform==="linux"&&process.getuid?.()===0)try{Ge(e)}catch{}let i=n.command??Fe();return new Promise((s,u)=>{let c=(n.spawnProcess??Te)(Me,[`--reuid=${e.uid}`,`--regid=${e.gid}`,"--clear-groups","--no-new-privs","--",...i],{cwd:e.home,detached:!0,stdio:["pipe","pipe","pipe"],env:{HOME:e.home,USER:e.username,LOGNAME:e.username,PATH:"/usr/local/bin:/usr/bin:/bin"}}),d=[],m=0,l="",p=null,g=!1,h,y=(_)=>{try{process.kill(-c.pid,_)}catch{c.kill(_)}},I=(_)=>{p??=_,y("SIGTERM"),h??=setTimeout(()=>y("SIGKILL"),$e)},S=()=>I(new r("cancelled","Reason cancelled the desktop operation."));t.addEventListener("abort",S,{once:!0});let w=(_)=>{if(g)return;g=!0,clearTimeout(h),t.removeEventListener("abort",S),_()};if(c.stdout.on("data",(_)=>{if(m+=_.byteLength,m>Ue)I(new r("desktop_delegate_failed","Reason's desktop reply is too large."));else d.push(_)}),c.stderr.setEncoding("utf8").on("data",(_)=>{l=(l+_).slice(-Le)}),c.stdin.on("error",()=>{}),c.once("error",()=>w(()=>u(p??new r("desktop_delegate_unavailable","Reason could not start its desktop as the desktop account.")))),c.once("close",(_,Ae)=>w(()=>{if(p)return u(p);let b=Be(Buffer.concat(d).toString("utf8"));if(q(b)&&b.ok===!0&&q(b.result))return s(b.result);let O=q(b)&&b.ok===!1&&typeof b.code==="string"&&typeof b.message==="string"?new r(b.code.slice(0,120),b.message.slice(0,2000)):null,J=`exited ${_??Ae}${O?"":" with no reply"}`,Y=l.trim().split(`
|
|
853
853
|
`).at(-1)?.slice(-300)??"";if(!O||O.code==="desktop_delegate_failed")process.stderr.write(`Reason worker: desktop call ${J}${l?`: ${l.trim().slice(-500)}`:""}
|
|
854
|
-
`);if(O)return u(O);u(new r("desktop_delegate_failed",`Reason's desktop operation failed (${J}${Y?`: ${Y}`:""}).`))})),t.aborted)S();c.stdin.end(JSON.stringify(o))})}async function V(e,o,t,n={}){let s=await Nt(e,{op:"automation",call:o},t,n);if(!Number.isSafeInteger(s.code)||typeof s.stdout!=="string"||typeof s.stderr!=="string")throw new r("desktop_delegate_failed","Reason's desktop reply is malformed.");return{code:s.code,stdout:Buffer.from(s.stdout,"base64"),stderr:s.stderr}}import{execFile as $e,spawn as Be}from"child_process";import{closeSync as Fe,mkdirSync as Ge,openSync as He}from"fs";import{dirname as E,join as je}from"path";import{promisify as Ke}from"util";var Xe=Ke($e),Z="x-apple.systempreferences:com.apple.preference.security",Je={accessibility:`${Z}?Privacy_Accessibility`,screen:`${Z}?Privacy_ScreenCapture`},Ye=64,A=new Map;function T(e,o){let t=A.get(e);if(t?.has(o))return!1;if(!t){if(A.size>=Ye)A.delete(A.keys().next().value);t=new Set,A.set(e,t)}return t.add(o),!0}function Ve(){let e=a(),o=jn(Ee(e),process.env),t=je(e,".local","share","reason","desktop-install.log");Ge(E(t),{recursive:!0,mode:448});let n=He(t,"a",384);try{let s=Be(o,["desktop","install"],{detached:!0,stdio:["ignore",n,n],env:{...process.env,REASON_DESKTOP_BACKGROUND:"1"}});s.on("error",()=>{return}),s.unref()}finally{Fe(n)}}var N={open:async(e,o)=>{await Xe("/usr/bin/open",e,{signal:o,timeout:1e4,maxBuffer:8192})},request:(e,o)=>ft(e,o),tile:Gr,installDesktop:Ve},Q=!1;async function ee(e,o,t){try{await o.open(["-a","Google Chrome",e],t)}catch{t.throwIfAborted(),await o.open([e],t)}}async function oe(e,o,t,n){if(await t.open([Je[o]],n).catch(()=>{}),e[0]&&!n.aborted)t.tile(E(E(E(e[0]))),o)}async function Ze(e,o,t,n,s){for(let i of t){if(!T(e,`grant:${i}`))continue;s.throwIfAborted(),await n.request(o,i).catch(()=>null),await oe(o,i,n,s)}}var Qe={name:"open_tab",description:"Open a web page in the user's own Chrome on this Mac. Reason cannot read, screenshot or click in that tab, and no tab_id is returned: browser control needs Reason's Chrome extension. An actual browser call opens its setup page.",inputSchema:{type:"object",properties:{url:{type:"string",description:"An http or https URL."}},required:["url"],additionalProperties:!1}};function te(e){return{code:0,stderr:"",stdout:Buffer.from(JSON.stringify({ok:!0,...e}))}}function et(e){if(typeof e!=="string")return null;try{let o=new URL(e);return o.protocol==="https:"||o.protocol==="http:"?o.href:null}catch{return null}}async function re(e,o=N){let{call:t,runId:n,signal:s}=e;if(t.kind==="browser"){if(t.operation==="discover")return te({result:{tools:[Qe]}});if(t.operation!=="call")throw new r("automation_browser_setup_required","Browser control is not set up on this Mac yet. Request a browser operation or connect Chrome from Reason to set it up.")}if(e.desktopMissing&&!Q){Q=!0;try{o.installDesktop()}catch{}}if(t.kind==="computer"){if(e.identity.length>0&&T(n,"grant:probe")){let c=await o.request(e.identity).catch(()=>null),d=c?[...c.accessibility?[]:["accessibility"],...c.screen?[]:["screen"]]:[];for(let m of d)T(n,`grant:${m}`);for(let m of d)await oe(e.identity,m,o,s)}throw new r("automation_computer_setup_required","Computer use is not set up on this Mac yet; Reason asked macOS for any missing permission.")}if(T(n,"page:chrome-extension"))await ee(io,o,s).catch(()=>{});let i=t.arguments,u=t.operation==="call"&&t.tool==="open_tab"&&i&&typeof i==="object"&&!Array.isArray(i)?et(i.url):null;if(!u)throw new r("automation_browser_setup_required","Browser control is not set up on this Mac yet; Reason opened its Chrome Web Store page. open_tab still opens pages.");return await ee(u,o,s),te({result:{content:[{type:"text",text:JSON.stringify({opened:u,browser:"the user's Chrome",controllable:!1,note:"Opened for the user to see. Reason cannot read or act in this tab until Reason's Chrome extension is added (its Chrome Web Store page is open)."})}]}})}async function ne(e,o=N){if(e.call.kind!=="computer"||e.call.operation!=="permission_status"||e.output.code!==0||e.identity.length===0)return e.output;let t;try{t=JSON.parse(e.output.stdout.toString("utf8"))}catch{return e.output}if(!t||typeof t!=="object"||Array.isArray(t))return e.output;let n=t.permissions;if(!n||typeof n!=="object")return e.output;let s=n,i=[...s.accessibility==="missing"?["accessibility"]:[],...s.screenRecording==="missing"?["screen"]:[]];if(i.length===0)return e.output;return await Ze(e.runId,e.identity,i,o,e.signal),{...e.output,stdout:Buffer.from(JSON.stringify({...t,requested:i}))}}var j=172032,pt=18874368,gt=8192,ht=65536,wt=55000,_t=60000,yt=4,St=40000,xt=/^[0-9a-f-]{36}$/,ce=z,kt=me();function P(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function D(){throw new r("invalid_automation_request","Reason automation request is malformed.")}function he(e){let o=Object.keys(e).sort().join(",");if(o==="call"||o==="browser,call"){let t=e.call,n=o==="browser,call";if(!P(t)||t.version!==1||t.kind!=="computer"&&t.kind!=="browser"||n&&(e.browser!==bt||t.kind!=="browser")||JSON.stringify(t).length>ht)D();return{call:t,userChrome:n}}if(o==="offset,output_id"){if(typeof e.output_id!=="string"||!xt.test(e.output_id)||!Number.isSafeInteger(e.offset)||e.offset<0)D();return{output_id:e.output_id,offset:e.offset}}return D()}function xn(e=process.platform,o=x){if(e==="darwin")return!0;return(e==="linux"||e==="win32")&&o()?.features.computer===!0}var Rt="__computer-use";function As(e=x){return e()?.userChrome??{code:"user_chrome_browser_use_missing"}}function we(e,o,t,n){return new Promise((s)=>{let i=R(e,o,{env:t,stdio:"ignore",windowsHide:!0}),u=setTimeout(()=>{i.kill("SIGKILL"),s(-1)},n);i.once("error",()=>{clearTimeout(u),s(-1)}),i.once("exit",(c)=>{clearTimeout(u),s(c??-1)})})}function It(e,o,t,n){return new Promise((s)=>{let i=R(e,o,{env:t,stdio:["ignore","pipe","ignore"],windowsHide:!0}),u="";i.stdout.setEncoding("utf8").on("data",(d)=>{u+=d});let c=setTimeout(()=>{i.kill("SIGKILL"),s(null)},n);i.once("error",()=>{clearTimeout(c),s(null)}),i.once("close",(d)=>{clearTimeout(c),s(d===0?u:null)})})}function vt(e){return v(e)?f(L(),"open-browser-use"):"/tmp/open-browser-use"}function v(e){return e.platform==="win32-x64"||e.platform==="win32-arm64"}var Ot=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,At=33554432;function Ct(e,o){let t;try{t=e===null?null:JSON.parse(e)}catch{return null}let n=P(t)&&P(t.result)?t.result.metadata:null;if(!P(n)||n.extensionId!==o)return null;return typeof n.extensionInstanceId==="string"&&Ot.test(n.extensionInstanceId)?n.extensionInstanceId:null}async function _e(e,o,t){let n=t.storages.map((c)=>{try{return U(c).filter((d)=>d.endsWith(".log")||d.endsWith(".ldb")).map((d)=>f(c,d))}catch{return[]}}),s;try{s=n.some((c)=>c.length>0)?U(t.socketDir).filter((c)=>c.endsWith(".sock")):[]}catch{return[]}let i=[];for(let c of s){let d=f(t.socketDir,c),m=Ct(await It(e,["info","--socket",d,"--timeout","2s"],o,5000),t.extensionId);if(m)i.push({instance:m,socket:d})}let u=[];for(let[c,d]of(i.length>0?n:[]).entries())for(let m of d)try{if(ct(m).size>At)continue;let l=X(m),p=i.find((g)=>l.includes(g.instance));if(p){u.push({storage:t.storages[c],...p});break}}catch{}return u}async function Tt(e,o,t){return(await _e(e,o,t))[0]?.instance??null}function ye(e,o,t){return Tt(e.nativeHost,o,{socketDir:vt(e),extensionId:F,storages:[f(t,"browser-profile","Default","Local Extension Settings",F)]})}var le=/^(Default|Profile ([0-9]+))$/;async function Pt(e,o,t=a(),n=$t){let s=f(t,"Library","Application Support","Google","Chrome"),i=[];try{i=U(s)}catch(l){if(l.code==="EPERM")throw new r("browser_use_chrome_access_denied","macOS blocked Reason from reading Chrome's profiles. Allow Full Disk Access for Reason on this Mac and try again.")}let u=(l)=>Number(le.exec(l)?.[2]??-1),c=i.filter((l)=>le.test(l)&&M(f(s,l,"Extensions",qe))).sort((l,p)=>u(l)-u(p)),d=(l)=>f(s,l,"Local Extension Settings",qe);return(await _e(e,o,{socketDir:n,extensionId:qe,storages:c.map(d)})).map(({storage:l,instance:p,socket:g})=>({profile:c.find((h)=>d(h)===l),instance:p,socket:g}))}async function Dt(e,o,t=a(),n=$t){let s=(await Pt(e,o,t,n))[0]?.instance;if(!s)throw new r("automation_user_chrome_not_connected","No Chrome profile on this Mac is connected to Reason. Open Chrome with the Reason extension, then try again.");return s}function ue(e){return new Promise((o)=>{let t=ut({path:e}),n=(s)=>{t.destroy(),o(s)};t.setTimeout(1000,()=>n(!1)),t.once("error",()=>n(!1)),t.once("connect",()=>n(!0))})}async function be(e,o){let t=Date.now()+o;while(Date.now()<t){if(await e())return!0;await new Promise((n)=>setTimeout(n,200))}return!1}var W=new Map;function H(e,o){let t=W.get(e);if(!t)t=o().finally(()=>W.delete(e)),W.set(e,t);return t}async function Mt(e,o){if(await ue(e))return;if(at(e,{force:!0}),await we("dbus-daemon",["--session",`--address=unix:path=${e}`,"--fork"],o,1e4)!==0||!await be(()=>ue(e),5000))throw new r("automation_unavailable","Reason could not start the desktop session bus.")}async function de(e,o,t){let n=e.platform==="darwin-arm64"||v(e)?async()=>await ye(e,o,t)!==null:async()=>await we(e.nativeHost,["info"],o,5000)===0;if(await n())return;let s=["--profile-directory=Default",`--load-extension=${e.extensionDir}`,"--no-first-run","--no-default-browser-check","--window-size=1280,800","about:blank"],i,u=null,c=0;if(e.platform==="darwin-arm64"){let l=f(t,"browser-profile");G(l);let p=f(l,"NativeMessagingHosts");ie(p,{recursive:!0,mode:448});let g=Ar(e.platform).nativeHostManifests[0];se(g,f(p,ae(g)));let h=e.browser.slice(0,e.browser.indexOf(".app/")+4),y=s.filter((I)=>I!=="about:blank").concat("--no-startup-window","--use-mock-keychain");i=R("/usr/bin/open",["-g","-n","-a",h,"--args",`--user-data-dir=${l}`,...y],{env:o,stdio:"ignore"})}else if(v(e)){let l=f(t,"browser-profile");G(l),tt(C("icacls"),[B(e.browser),"/grant","*S-1-15-2-1:(OI)(CI)(RX)","*S-1-15-2-2:(OI)(CI)(RX)"],{stdio:"ignore",windowsHide:!0,timeout:60000});let p=s.filter((g)=>g!=="about:blank").concat("--no-startup-window","--keep-alive-for-test");i=R(e.browser,[`--user-data-dir=${l}`,...p],{detached:!0,stdio:"ignore",env:o})}else{let l=f(o.HOME,".config","google-chrome"),p=f(l,"NativeMessagingHosts");ie(p,{recursive:!0,mode:448});let g=Ar(e.platform).nativeHostManifests[0];se(g,f(p,ae(g)));let h=process.geteuid?.()===0?["--no-sandbox"]:[];u=f(t,"browser.log");let y=st(u,"a",384);c=nt(y).size,i=R(e.browser,[`--user-data-dir=${l}`,...s,...h,"--force-renderer-accessibility"],{detached:!0,stdio:["ignore",y,y],env:{...o,ACCESSIBILITY_ENABLED:"1"}}),rt(y)}let d=!1;i.once("error",()=>{d=!0}),i.once("exit",(l)=>{d||=l!==0}),i.unref();let m=!1;if(await be(async()=>d||(m=await n()),St),!m){if(u&&X(u).subarray(c).toString("utf8").includes("No usable sandbox"))throw new r("automation_browser_sandbox_unavailable","Chromium found no usable sandbox on this machine. Run the worker as a non-root user with unprivileged user namespaces enabled, or in a container with seccomp unconfined.");throw new r("automation_browser_unavailable","Reason could not connect the desktop browser.")}}async function Ps(e){await ke(e,!0)}function Ts(e){return Se(e,xe(e))}function Se(e,o){return e.platform==="darwin-arm64"||v(e)?f(o,"browser-profile"):f(o,"home",".config","google-chrome")}function xe(e){let o=f(e.root,"automation");if(!M(o)||!Ut(e.automation))return e.automation;if(!Lt(Se(e,o)))try{fe(o,e.automation)}catch{}return M(o)?o:e.automation}function Ut(e){try{return U(e).length===0}catch(o){return o.code==="ENOENT"}}function Lt(e){let o;try{o=it(f(e,"SingletonLock"))}catch{return!1}let t=Number(o.slice(o.lastIndexOf("-")+1));if(!Number.isSafeInteger(t)||t<=0)return!0;try{return process.kill(t,0),!0}catch(n){return n.code==="EPERM"}}async function ke(e,o){Et({root:e.root,automation:e.automation,extensionDir:e.extensionDir});let t=xe(e);G(t);let n=ge().username,s={USER:n,LOGNAME:n,REASON_AUTOMATION_OCU:e.ocu,REASON_AUTOMATION_OBU:e.nativeHost};if(e.platform==="darwin-arm64"||v(e)){let l=v(e)?{...s,...Bt(),HOME:a()}:{...s,HOME:a(),PATH:`${B(e.node)}:/usr/bin:/bin:/usr/sbin:/sbin`,REASON_AUTOMATION_OCU:process.execPath,REASON_AUTOMATION_OCU_SUBCOMMAND:Rt};if(!o)return l;await H("browser",()=>de(e,l,t));let p=await ye(e,l,t);if(!p)throw new r("automation_browser_unavailable","Reason could not connect the desktop browser.");return{...l,REASON_AUTOMATION_OBU_INSTANCE:p,REASON_AUTOMATION_BACKGROUND_TABS:"1"}}let i=await ze(),u=f(t,"home"),c=f(t,"runtime");G(u),G(c);let d=f(t,"bus"),m={...s,HOME:u,PATH:`${B(e.node)}:/usr/bin:/bin`,DISPLAY:i.display,XAUTHORITY:i.xauthority,XDG_RUNTIME_DIR:c,DBUS_SESSION_BUS_ADDRESS:`unix:path=${d}`,...i.sound?{PULSE_SERVER:We(i.sound)}:{}};if(await H("bus",()=>Mt(d,m)),o)await H("browser",()=>de(e,m,t));return m}function Bt(){let e=process.env.SystemRoot??"C:\\Windows",o=Object.fromEntries(["SystemDrive","USERPROFILE","LOCALAPPDATA","APPDATA","ProgramData","ProgramFiles","PATHEXT","ComSpec","USERNAME","USERDOMAIN","COMPUTERNAME","NUMBER_OF_PROCESSORS","PROCESSOR_ARCHITECTURE","PSModuleAnalysisCachePath"].flatMap((n)=>process.env[n]?[[n,process.env[n]]]:[])),t=f(e,"System32");return{...o,SystemRoot:e,windir:e,TEMP:L(),TMP:L(),PATH:[t,f(t,"WindowsPowerShell","v1.0"),e].join(dt)}}async function qt(e,o,t){let n=ge().username,s={USER:n,LOGNAME:n,HOME:a(),PATH:`${B(e.node)}:/usr/bin:/bin:/usr/sbin:/sbin`,REASON_AUTOMATION_OBU:o,REASON_AUTOMATION_BACKGROUND_TABS:"1"},i=await Dt(o,s);return t.throwIfAborted(),{...s,REASON_AUTOMATION_OBU_INSTANCE:i}}function Wt(e){if(process.platform!=="win32")return["--input-type=module","--eval",e];let o=f(L(),`reason-automation-${ot("sha256").update(e).digest("hex").slice(0,16)}.mjs`);if(!M(o)||X(o,"utf8")!==e){let t=`${o}.${process.pid}.tmp`;lt(t,e,{mode:384}),fe(t,o)}return[o]}function Re(e,o,t,n){if(typeof ce!=="string")return Promise.reject(new r("automation_unavailable","This Reason build has no automation runtime."));let s=ce;return new Promise((i,u)=>{let c=R(e,Wt(s),{env:{...o,REASON_CLOUD_GATEWAY_EXEC:"1",REASON_AUTOMATION_INLINE_RESULT:"1"},stdio:["pipe","pipe","pipe"],detached:process.platform!=="win32",windowsHide:!0}),d=[],m=0,l="",p=null,g=!1,h=(w)=>{if(p??=w,process.platform==="win32"&&c.pid){R(f(process.env.SystemRoot??"C:\\Windows","System32","taskkill.exe"),["/pid",String(c.pid),"/t","/f"],{stdio:"ignore",windowsHide:!0}).once("error",()=>c.kill("SIGKILL"));return}try{process.kill(-c.pid,"SIGKILL")}catch{c.kill("SIGKILL")}},y=(w)=>{if(g)return;g=!0,clearTimeout(I),n.removeEventListener("abort",S),w()},I=setTimeout(()=>h(new r("automation_timed_out","Reason automation did not finish in time.")),wt),S=()=>h(new r("cancelled","Reason cancelled the automation call."));if(n.addEventListener("abort",S,{once:!0}),c.stdout.on("data",(w)=>{if(m+=w.byteLength,m>pt)h(new r("automation_output_too_large","Reason automation output is too large."));else d.push(w)}),c.stderr.setEncoding("utf8").on("data",(w)=>{l=(l+w).slice(-gt)}),c.stdin.on("error",()=>{}),c.once("error",()=>y(()=>u(p??new r("automation_unavailable","Reason could not start the automation runtime.")))),c.once("close",(w)=>y(()=>{if(p)u(p);else i({code:w??1,stdout:Buffer.concat(d),stderr:l})})),n.aborted)S();c.stdin.end(t)})}var k=new Map;function Ft(e,o,t){for(let[s,i]of k)if(i.expiresAt<=t)k.delete(s);while(k.size>=yt)k.delete(k.keys().next().value);let n=me();return k.set(n,{runId:e,bytes:o,expiresAt:t+_t}),n}async function Ie(e,o,t,n={}){let s=await(n.environment??ke)(e,o.kind==="browser");return t.throwIfAborted(),await(n.runtime??Re)(e.node,s,JSON.stringify(o),t)}async function Rs(e,o){let t=he({call:e});if(!("call"in t))D();let n=x();if(!n?.features.computer||t.call.kind==="browser"&&!n.features.browser)throw new r("automation_unavailable","Run `reason desktop install` on this machine to enable computer and browser use.");return await Ie(n,t.call,o)}function pe(e,o,t){let n=e.stdout.byteLength>j?Ft(o,e.stdout,t):void 0;return{code:e.code,stderr:e.stderr,instance_id:kt,output_bytes:e.stdout.byteLength,chunk:e.stdout.subarray(0,j).toString("base64"),...n?{output_id:n}:{}}}async function kn(e,o={}){let t=he(e.payload),n=(o.now??Date.now)();if("output_id"in t){let h=k.get(t.output_id);if(!h||h.runId!==e.runId||h.expiresAt<=n||t.offset>h.bytes.byteLength)throw new r("automation_output_unavailable","Reason automation output expired.");return{chunk:h.bytes.subarray(t.offset,t.offset+j).toString("base64")}}let s=(o.components??x)(),i=(o.platform??process.platform)==="darwin",u=i?(o.macIdentity??mt)():[],c=o.macSetup??N,d=!s?.features.computer||t.call.kind==="browser"&&!t.userChrome&&!s.features.browser;if(i&&(d||u.length===0||t.call.kind==="browser"&&t.userChrome&&!e.userChrome))return pe(await re({runId:e.runId,call:t.call,identity:u,desktopMissing:d,signal:e.signal},c),e.runId,n);if(!s?.features.computer)throw new r("automation_unavailable","Run `reason desktop install` on this machine to enable computer and browser use.");let m=t.userChrome?e.userChrome:void 0;if(t.userChrome&&!m)throw new r("automation_user_chrome_unavailable","Your own Chrome is not enabled on this computer: run `reason desktop install` on this Mac (and `reason connect --user-chrome on` if you turned it off).");if(t.call.kind==="browser"&&!m&&!s.features.browser)throw new r("automation_browser_not_installed",!s.platform.startsWith("linux")?"Browser use is unavailable on this machine: re-run `reason desktop install`.":"Browser use is unavailable on this machine: install a non-snap Chromium at /usr/bin/chromium, then re-run `reason desktop install`.");e.signal.throwIfAborted();let l=await Oi(e.runId,e.signal,o.now),p="account"in o?o.account??null:K(),g;try{if(m){let h=await(o.userChromeEnvironment??qt)(s,m,e.signal);e.signal.throwIfAborted(),g=await(o.runtime??Re)(s.node,h,JSON.stringify(t.call),e.signal)}else if(p)g=await(o.delegate??V)(p,t.call,e.signal);else g=await Ie(s,t.call,e.signal,o)}finally{l()}if(i)g=await ne({runId:e.runId,call:t.call,identity:u,output:g,signal:e.signal},c);return pe(g,e.runId,n)}
|
|
854
|
+
`);if(O)return u(O);u(new r("desktop_delegate_failed",`Reason's desktop operation failed (${J}${Y?`: ${Y}`:""}).`))})),t.aborted)S();c.stdin.end(JSON.stringify(o))})}async function Q(e,o,t,n={}){let i=await Nt(e,{op:"automation",call:o},t,n);if(!Number.isSafeInteger(i.code)||typeof i.stdout!=="string"||typeof i.stderr!=="string")throw new r("desktop_delegate_failed","Reason's desktop reply is malformed.");return{code:i.code,stdout:Buffer.from(i.stdout,"base64"),stderr:i.stderr}}import{execFile as He,spawn as je}from"child_process";import{closeSync as Xe,mkdirSync as Ke,openSync as Je}from"fs";import{dirname as E,join as Ye}from"path";import{promisify as Ve}from"util";var Ze=Ve(He),ee="x-apple.systempreferences:com.apple.preference.security",Qe={accessibility:`${ee}?Privacy_Accessibility`,screen:`${ee}?Privacy_ScreenCapture`},et=64,A=new Map;function T(e,o){let t=A.get(e);if(t?.has(o))return!1;if(!t){if(A.size>=et)A.delete(A.keys().next().value);t=new Set,A.set(e,t)}return t.add(o),!0}function tt(){let e=a(),o=jn(Ee(e),process.env),t=Ye(e,".local","share","reason","desktop-install.log");Ke(E(t),{recursive:!0,mode:448});let n=Je(t,"a",384);try{let i=je(o,["desktop","install"],{detached:!0,stdio:["ignore",n,n],env:{...process.env,REASON_DESKTOP_BACKGROUND:"1"}});i.on("error",()=>{return}),i.unref()}finally{Xe(n)}}var N={open:async(e,o)=>{await Ze("/usr/bin/open",e,{signal:o,timeout:1e4,maxBuffer:8192})},request:(e,o)=>ft(e,o),tile:Gr,installDesktop:tt},te=!1;async function oe(e,o,t){try{await o.open(["-a","Google Chrome",e],t)}catch{t.throwIfAborted(),await o.open([e],t)}}async function ne(e,o,t,n){if(await t.open([Qe[o]],n).catch(()=>{}),e[0]&&!n.aborted)t.tile(E(E(E(e[0]))),o)}async function ot(e,o,t,n,i){for(let s of t){if(!T(e,`grant:${s}`))continue;i.throwIfAborted(),await n.request(o,s).catch(()=>null),await ne(o,s,n,i)}}var rt={name:"open_tab",description:"Open a web page in the user's own Chrome on this Mac. Reason cannot read, screenshot or click in that tab, and no tab_id is returned: browser control needs Reason's Chrome extension. An actual browser call opens its setup page.",inputSchema:{type:"object",properties:{url:{type:"string",description:"An http or https URL."}},required:["url"],additionalProperties:!1}};function re(e){return{code:0,stderr:"",stdout:Buffer.from(JSON.stringify({ok:!0,...e}))}}function nt(e){if(typeof e!=="string")return null;try{let o=new URL(e);return o.protocol==="https:"||o.protocol==="http:"?o.href:null}catch{return null}}async function ie(e,o=N){let{call:t,runId:n,signal:i}=e;if(t.kind==="browser"){if(t.operation==="discover")return re({result:{tools:[rt]}});if(t.operation!=="call")throw new r("automation_browser_setup_required","Browser control is not set up on this Mac yet. Request a browser operation or connect Chrome from Reason to set it up.")}if(e.desktopMissing&&!te){te=!0;try{o.installDesktop()}catch{}}if(t.kind==="computer"){if(e.identity.length>0&&T(n,"grant:probe")){let c=await o.request(e.identity).catch(()=>null),d=c?[...c.accessibility?[]:["accessibility"],...c.screen?[]:["screen"]]:[];for(let m of d)T(n,`grant:${m}`);for(let m of d)await ne(e.identity,m,o,i)}throw new r("automation_computer_setup_required","Computer use is not set up on this Mac yet; Reason asked macOS for any missing permission.")}if(T(n,"page:chrome-extension"))await oe(io,o,i).catch(()=>{});let s=t.arguments,u=t.operation==="call"&&t.tool==="open_tab"&&s&&typeof s==="object"&&!Array.isArray(s)?nt(s.url):null;if(!u)throw new r("automation_browser_setup_required","Browser control is not set up on this Mac yet; Reason opened its Chrome Web Store page. open_tab still opens pages.");return await oe(u,o,i),re({result:{content:[{type:"text",text:JSON.stringify({opened:u,browser:"the user's Chrome",controllable:!1,note:"Opened for the user to see. Reason cannot read or act in this tab until Reason's Chrome extension is added (its Chrome Web Store page is open)."})}]}})}async function se(e,o=N){if(e.call.kind!=="computer"||e.call.operation!=="permission_status"||e.output.code!==0||e.identity.length===0)return e.output;let t;try{t=JSON.parse(e.output.stdout.toString("utf8"))}catch{return e.output}if(!t||typeof t!=="object"||Array.isArray(t))return e.output;let n=t.permissions;if(!n||typeof n!=="object")return e.output;let i=n,s=[...i.accessibility==="missing"?["accessibility"]:[],...i.screenRecording==="missing"?["screen"]:[]];if(s.length===0)return e.output;return await ot(e.runId,e.identity,s,o,e.signal),{...e.output,stdout:Buffer.from(JSON.stringify({...t,requested:s}))}}var j=172032,_t=18874368,yt=8192,St=65536,xt=55000,kt=60000,Rt=4,It=40000,vt=/^[0-9a-f-]{36}$/,ue=z,Ot=ge();function P(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function D(){throw new r("invalid_automation_request","Reason automation request is malformed.")}function _e(e){let o=Object.keys(e).sort().join(",");if(o==="call"||o==="browser,call"){let t=e.call,n=o==="browser,call";if(!P(t)||t.version!==1||t.kind!=="computer"&&t.kind!=="browser"||n&&(e.browser!==bt||t.kind!=="browser")||JSON.stringify(t).length>St)D();return{call:t,userChrome:n}}if(o==="offset,output_id"){if(typeof e.output_id!=="string"||!vt.test(e.output_id)||!Number.isSafeInteger(e.offset)||e.offset<0)D();return{output_id:e.output_id,offset:e.offset}}return D()}function xn(e=process.platform,o=x){if(e==="darwin")return!0;return(e==="linux"||e==="win32")&&o()?.features.computer===!0}var At="__computer-use";function As(e=x){return e()?.userChrome??{code:"user_chrome_browser_use_missing"}}function ye(e,o,t,n){return new Promise((i)=>{let s=R(e,o,{env:t,stdio:"ignore",windowsHide:!0}),u=setTimeout(()=>{s.kill("SIGKILL"),i(-1)},n);s.once("error",()=>{clearTimeout(u),i(-1)}),s.once("exit",(c)=>{clearTimeout(u),i(c??-1)})})}function Ct(e,o,t,n){return new Promise((i)=>{let s=R(e,o,{env:t,stdio:["ignore","pipe","ignore"],windowsHide:!0}),u="";s.stdout.setEncoding("utf8").on("data",(d)=>{u+=d});let c=setTimeout(()=>{s.kill("SIGKILL"),i(null)},n);s.once("error",()=>{clearTimeout(c),i(null)}),s.once("close",(d)=>{clearTimeout(c),i(d===0?u:null)})})}function Tt(e){return v(e)?f(L(),"open-browser-use"):"/tmp/open-browser-use"}function v(e){return e.platform==="win32-x64"||e.platform==="win32-arm64"}var Pt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,Dt=33554432;function Mt(e,o){let t;try{t=e===null?null:JSON.parse(e)}catch{return null}let n=P(t)&&P(t.result)?t.result.metadata:null;if(!P(n)||n.extensionId!==o)return null;return typeof n.extensionInstanceId==="string"&&Pt.test(n.extensionInstanceId)?n.extensionInstanceId:null}async function be(e,o,t){let n=t.storages.map((c)=>{try{return U(c).filter((d)=>d.endsWith(".log")||d.endsWith(".ldb")).map((d)=>f(c,d))}catch{return[]}}),i;try{i=n.some((c)=>c.length>0)?U(t.socketDir).filter((c)=>c.endsWith(".sock")):[]}catch{return[]}let s=[];for(let c of i){let d=f(t.socketDir,c),m=Mt(await Ct(e,["info","--socket",d,"--timeout","2s"],o,5000),t.extensionId);if(m)s.push({instance:m,socket:d})}let u=[];for(let[c,d]of(s.length>0?n:[]).entries())for(let m of d)try{if(pt(m).size>Dt)continue;let l=X(m),p=s.find((g)=>l.includes(g.instance));if(p){u.push({storage:t.storages[c],...p});break}}catch{}return u}async function Ut(e,o,t){return(await be(e,o,t))[0]?.instance??null}function Se(e,o,t){return Ut(e.nativeHost,o,{socketDir:Tt(e),extensionId:F,storages:[f(t,"browser-profile","Default","Local Extension Settings",F)]})}var de=/^(Default|Profile ([0-9]+))$/;async function Lt(e,o,t=a(),n=$t){let i=f(t,"Library","Application Support","Google","Chrome"),s=[];try{s=U(i)}catch(l){if(l.code==="EPERM")throw new r("browser_use_chrome_access_denied","macOS blocked Reason from reading Chrome's profiles. Allow Full Disk Access for Reason on this Mac and try again.")}let u=(l)=>Number(de.exec(l)?.[2]??-1),c=s.filter((l)=>de.test(l)&&M(f(i,l,"Extensions",qe))).sort((l,p)=>u(l)-u(p)),d=(l)=>f(i,l,"Local Extension Settings",qe);return(await be(e,o,{socketDir:n,extensionId:qe,storages:c.map(d)})).map(({storage:l,instance:p,socket:g})=>({profile:c.find((h)=>d(h)===l),instance:p,socket:g}))}async function Bt(e,o,t=a(),n=$t){let i=(await Lt(e,o,t,n))[0]?.instance;if(!i)throw new r("automation_user_chrome_not_connected","No Chrome profile on this Mac is connected to Reason. Open Chrome with the Reason extension, then try again.");return i}function pe(e){return new Promise((o)=>{let t=ht({path:e}),n=(i)=>{t.destroy(),o(i)};t.setTimeout(1000,()=>n(!1)),t.once("error",()=>n(!1)),t.once("connect",()=>n(!0))})}async function xe(e,o){let t=Date.now()+o;while(Date.now()<t){if(await e())return!0;await new Promise((n)=>setTimeout(n,200))}return!1}var W=new Map;function H(e,o){let t=W.get(e);if(!t)t=o().finally(()=>W.delete(e)),W.set(e,t);return t}async function qt(e,o){if(await pe(e))return;if(dt(e,{force:!0}),await ye("dbus-daemon",["--session",`--address=unix:path=${e}`,"--fork"],o,1e4)!==0||!await xe(()=>pe(e),5000))throw new r("automation_unavailable","Reason could not start the desktop session bus.")}async function me(e,o,t){let n=e.platform==="darwin-arm64"||v(e)?async()=>await Se(e,o,t)!==null:async()=>await ye(e.nativeHost,["info"],o,5000)===0;if(await n())return;let i=["--profile-directory=Default",`--load-extension=${e.extensionDir}`,"--no-first-run","--no-default-browser-check","--window-size=1280,800","about:blank"],s,u=null,c=0;if(e.platform==="darwin-arm64"){let l=f(t,"browser-profile");G(l);let p=f(l,"NativeMessagingHosts");ce(p,{recursive:!0,mode:448});let g=Ar(e.platform).nativeHostManifests[0];ae(g,f(p,le(g)));let h=e.browser.slice(0,e.browser.indexOf(".app/")+4),y=i.filter((I)=>I!=="about:blank").concat("--no-startup-window","--use-mock-keychain");s=R("/usr/bin/open",["-g","-n","-a",h,"--args",`--user-data-dir=${l}`,...y],{env:o,stdio:"ignore"})}else if(v(e)){let l=f(t,"browser-profile");G(l),it(C("icacls"),[B(e.browser),"/grant","*S-1-15-2-1:(OI)(CI)(RX)","*S-1-15-2-2:(OI)(CI)(RX)"],{stdio:"ignore",windowsHide:!0,timeout:60000});let p=i.filter((g)=>g!=="about:blank").concat("--no-startup-window","--keep-alive-for-test");s=R(e.browser,[`--user-data-dir=${l}`,...p],{detached:!0,stdio:"ignore",env:o})}else{let l=f(o.HOME,".config","google-chrome"),p=f(l,"NativeMessagingHosts");ce(p,{recursive:!0,mode:448});let g=Ar(e.platform).nativeHostManifests[0];ae(g,f(p,le(g)));let h=process.geteuid?.()===0?["--no-sandbox"]:[];u=f(t,"browser.log");let y=lt(u,"a",384);c=ct(y).size,s=R(e.browser,[`--user-data-dir=${l}`,...i,...h,"--force-renderer-accessibility"],{detached:!0,stdio:["ignore",y,y],env:{...o,ACCESSIBILITY_ENABLED:"1"}}),at(y)}let d=!1;s.once("error",()=>{d=!0}),s.once("exit",(l)=>{d||=l!==0}),s.unref();let m=!1;if(await xe(async()=>d||(m=await n()),It),!m){if(u&&X(u).subarray(c).toString("utf8").includes("No usable sandbox"))throw new r("automation_browser_sandbox_unavailable","Chromium found no usable sandbox on this machine. Run the worker as a non-root user with unprivileged user namespaces enabled, or in a container with seccomp unconfined.");throw new r("automation_browser_unavailable","Reason could not connect the desktop browser.")}}async function Ps(e){await Ie(e,!0)}function Ts(e){return ke(e,Re(e))}function ke(e,o){return e.platform==="darwin-arm64"||v(e)?f(o,"browser-profile"):f(o,"home",".config","google-chrome")}function Re(e){let o=f(e.root,"automation");if(!M(o)||!Wt(e.automation))return e.automation;if(!Ft(ke(e,o)))try{he(o,e.automation)}catch{}return M(o)?o:e.automation}function Wt(e){try{return U(e).length===0}catch(o){return o.code==="ENOENT"}}function Ft(e){let o;try{o=ut(f(e,"SingletonLock"))}catch{return!1}let t=Number(o.slice(o.lastIndexOf("-")+1));if(!Number.isSafeInteger(t)||t<=0)return!0;try{return process.kill(t,0),!0}catch(n){return n.code==="EPERM"}}async function Ie(e,o){Et({root:e.root,automation:e.automation,extensionDir:e.extensionDir});let t=Re(e);G(t);let n=we().username,i={USER:n,LOGNAME:n,REASON_AUTOMATION_OCU:e.ocu,REASON_AUTOMATION_OBU:e.nativeHost};if(e.platform==="darwin-arm64"||v(e)){let l=v(e)?{...i,...Gt(),HOME:a()}:{...i,HOME:a(),PATH:`${B(e.node)}:/usr/bin:/bin:/usr/sbin:/sbin`,REASON_AUTOMATION_OCU:process.execPath,REASON_AUTOMATION_OCU_SUBCOMMAND:At};if(!o)return l;await H("browser",()=>me(e,l,t));let p=await Se(e,l,t);if(!p)throw new r("automation_browser_unavailable","Reason could not connect the desktop browser.");return{...l,REASON_AUTOMATION_OBU_INSTANCE:p,REASON_AUTOMATION_BACKGROUND_TABS:"1"}}let s=await ze(),u=f(t,"home"),c=f(t,"runtime");G(u),G(c);let d=f(t,"bus"),m={...i,HOME:u,PATH:`${B(e.node)}:/usr/bin:/bin`,DISPLAY:s.display,XAUTHORITY:s.xauthority,XDG_RUNTIME_DIR:c,DBUS_SESSION_BUS_ADDRESS:`unix:path=${d}`,...s.sound?{PULSE_SERVER:We(s.sound)}:{}};if(await H("bus",()=>qt(d,m)),o)await H("browser",()=>me(e,m,t));return m}function Gt(){let e=process.env.SystemRoot??"C:\\Windows",o=Object.fromEntries(["SystemDrive","USERPROFILE","LOCALAPPDATA","APPDATA","ProgramData","ProgramFiles","PATHEXT","ComSpec","USERNAME","USERDOMAIN","COMPUTERNAME","NUMBER_OF_PROCESSORS","PROCESSOR_ARCHITECTURE","PSModuleAnalysisCachePath"].flatMap((n)=>process.env[n]?[[n,process.env[n]]]:[])),t=f(e,"System32");return{...o,SystemRoot:e,windir:e,TEMP:L(),TMP:L(),PATH:[t,f(t,"WindowsPowerShell","v1.0"),e].join(wt)}}async function Ht(e,o,t){let n=we().username,i={USER:n,LOGNAME:n,HOME:a(),PATH:`${B(e.node)}:/usr/bin:/bin:/usr/sbin:/sbin`,REASON_AUTOMATION_OBU:o,REASON_AUTOMATION_BACKGROUND_TABS:"1"},s=await Bt(o,i);return t.throwIfAborted(),{...i,REASON_AUTOMATION_OBU_INSTANCE:s}}function jt(e){if(process.platform!=="win32")return["--input-type=module","--eval",e];let o=f(L(),`reason-automation-${st("sha256").update(e).digest("hex").slice(0,16)}.mjs`);if(!M(o)||X(o,"utf8")!==e){let t=`${o}.${process.pid}.tmp`;gt(t,e,{mode:384}),he(t,o)}return[o]}function ve(e,o,t,n){if(typeof ue!=="string")return Promise.reject(new r("automation_unavailable","This Reason build has no automation runtime."));let i=ue;return new Promise((s,u)=>{let c=R(e,jt(i),{env:{...o,REASON_CLOUD_GATEWAY_EXEC:"1",REASON_AUTOMATION_INLINE_RESULT:"1"},stdio:["pipe","pipe","pipe"],detached:process.platform!=="win32",windowsHide:!0}),d=[],m=0,l="",p=null,g=!1,h=(w)=>{if(p??=w,process.platform==="win32"&&c.pid){R(f(process.env.SystemRoot??"C:\\Windows","System32","taskkill.exe"),["/pid",String(c.pid),"/t","/f"],{stdio:"ignore",windowsHide:!0}).once("error",()=>c.kill("SIGKILL"));return}try{process.kill(-c.pid,"SIGKILL")}catch{c.kill("SIGKILL")}},y=(w)=>{if(g)return;g=!0,clearTimeout(I),n.removeEventListener("abort",S),w()},I=setTimeout(()=>h(new r("automation_timed_out","Reason automation did not finish in time.")),xt),S=()=>h(new r("cancelled","Reason cancelled the automation call."));if(n.addEventListener("abort",S,{once:!0}),c.stdout.on("data",(w)=>{if(m+=w.byteLength,m>_t)h(new r("automation_output_too_large","Reason automation output is too large."));else d.push(w)}),c.stderr.setEncoding("utf8").on("data",(w)=>{l=(l+w).slice(-yt)}),c.stdin.on("error",()=>{}),c.once("error",()=>y(()=>u(p??new r("automation_unavailable","Reason could not start the automation runtime.")))),c.once("close",(w)=>y(()=>{if(p)u(p);else s({code:w??1,stdout:Buffer.concat(d),stderr:l})})),n.aborted)S();c.stdin.end(t)})}var k=new Map;function Xt(e,o,t){for(let[i,s]of k)if(s.expiresAt<=t)k.delete(i);while(k.size>=Rt)k.delete(k.keys().next().value);let n=ge();return k.set(n,{runId:e,bytes:o,expiresAt:t+kt}),n}async function Oe(e,o,t,n={}){let i=await(n.environment??Ie)(e,o.kind==="browser");return t.throwIfAborted(),await(n.runtime??ve)(e.node,i,JSON.stringify(o),t)}async function Rs(e,o){let t=_e({call:e});if(!("call"in t))D();let n=x();if(!n?.features.computer||t.call.kind==="browser"&&!n.features.browser)throw new r("automation_unavailable","Run `reason desktop install` on this machine to enable computer and browser use.");return await Oe(n,t.call,o)}function fe(e,o,t){let n=e.stdout.byteLength>j?Xt(o,e.stdout,t):void 0;return{code:e.code,stderr:e.stderr,instance_id:Ot,output_bytes:e.stdout.byteLength,chunk:e.stdout.subarray(0,j).toString("base64"),...n?{output_id:n}:{}}}async function kn(e,o={}){let t=_e(e.payload),n=(o.now??Date.now)();if("output_id"in t){let h=k.get(t.output_id);if(!h||h.runId!==e.runId||h.expiresAt<=n||t.offset>h.bytes.byteLength)throw new r("automation_output_unavailable","Reason automation output expired.");return{chunk:h.bytes.subarray(t.offset,t.offset+j).toString("base64")}}let i=(o.components??x)(),s=(o.platform??process.platform)==="darwin",u=s?(o.macIdentity??mt)():[],c=o.macSetup??N,d=!i?.features.computer||t.call.kind==="browser"&&!t.userChrome&&!i.features.browser;if(s&&(d||u.length===0||t.call.kind==="browser"&&t.userChrome&&!e.userChrome))return fe(await ie({runId:e.runId,call:t.call,identity:u,desktopMissing:d,signal:e.signal},c),e.runId,n);if(!i?.features.computer)throw new r("automation_unavailable","Run `reason desktop install` on this machine to enable computer and browser use.");let m=t.userChrome?e.userChrome:void 0;if(t.userChrome&&!m)throw new r("automation_user_chrome_unavailable","Your own Chrome is not enabled on this computer: run `reason desktop install` on this Mac (and `reason connect --user-chrome on` if you turned it off).");if(t.call.kind==="browser"&&!m&&!i.features.browser)throw new r("automation_browser_not_installed",!i.platform.startsWith("linux")?"Browser use is unavailable on this machine: re-run `reason desktop install`.":"Browser use is unavailable on this machine: install a non-snap Chromium at /usr/bin/chromium, then re-run `reason desktop install`.");e.signal.throwIfAborted();let l=await Oi(e.runId,e.signal,o.now),p="account"in o?o.account??null:K(),g;try{if(m){let h=await(o.userChromeEnvironment??Ht)(i,m,e.signal);e.signal.throwIfAborted(),g=await(o.runtime??ve)(i.node,h,JSON.stringify(t.call),e.signal)}else if(p)g=await(o.delegate??Q)(p,t.call,e.signal);else g=await Oe(i,t.call,e.signal,o)}finally{l()}if(s)g=await se({runId:e.runId,call:t.call,identity:u,output:g,signal:e.signal},c);return fe(g,e.runId,n)}
|
|
855
855
|
export{Nt,xn,As,Ps,Ts,Rs,kn};
|