@reason-machines/cli-linux-x64 0.2.521 → 0.2.523

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.
Files changed (106) hide show
  1. package/bin/reason +2 -2
  2. package/bin/vm-hands/api-credentials-e57krknv.js +2 -0
  3. package/bin/vm-hands/api-jec93cnj.js +2 -0
  4. package/bin/vm-hands/connect-cli-yzezydnr.js +2 -0
  5. package/bin/vm-hands/credentials-md79hkqh.js +2 -0
  6. package/bin/vm-hands/custom-endpoint-device-hzgdnyx2.js +2 -0
  7. package/bin/vm-hands/desktop-account-gm7m5bwr.js +2 -0
  8. package/bin/vm-hands/{fsevents-sw63c1nr.js → fsevents-fev1pxw2.js} +1 -1
  9. package/bin/vm-hands/grok-dock-browser-pzw59wnd.png +0 -0
  10. package/bin/vm-hands/grok-dock-files-eckq444x.png +0 -0
  11. package/bin/vm-hands/grok-dock-terminal-hcpz3e43.png +0 -0
  12. package/bin/vm-hands/grok-wallpaper-71zwn2pj.jpg +0 -0
  13. package/bin/vm-hands/{hands-worker-source-h0qmr1jt.js → hands-worker-source-hzkacxxz.js} +1 -1
  14. package/bin/vm-hands/{index-j4gb3cze.js → index-gmsadq51.js} +4 -4
  15. package/bin/vm-hands/install-receipt-qtwtzafq.js +2 -0
  16. package/bin/vm-hands/local-automation-rmedb06z.js +2 -0
  17. package/bin/vm-hands/local-capabilities-mvnm7kc8.js +2 -0
  18. package/bin/vm-hands/local-desktop-users-qdpbfh6s.js +2 -0
  19. package/bin/vm-hands/local-display-mac-4654wqzs.js +2 -0
  20. package/bin/vm-hands/local-display-session-e662q50r.js +2 -0
  21. package/bin/vm-hands/local-display-video-0pb76z1k.js +2 -0
  22. package/bin/vm-hands/local-managed-process-s90s65vr.js +2 -0
  23. package/bin/vm-hands/local-pty-session-s60ca00y.js +2 -0
  24. package/bin/vm-hands/managed-runtime-cc93epas.js +2 -0
  25. package/bin/vm-hands/network-contract-5wc6wbn2.js +2 -0
  26. package/bin/vm-hands/package-way7qesn.js +2 -0
  27. package/bin/vm-hands/permissions-tjhfq2b6.js +2 -0
  28. package/bin/vm-hands/{reason-hands-protocol-6fxcbhzd.js → reason-hands-protocol-zffy7kc8.js} +1 -1
  29. package/bin/vm-hands/serve-service-qhsnbxmy.js +2 -0
  30. package/bin/vm-hands/{status-qvgxpr8f.js → status-h7fq0xa9.js} +1 -1
  31. package/bin/vm-hands/version-whw9wgya.js +2 -0
  32. package/bin/vm-hands/{vm-hands-entry-lite-4wgq9vfr.js → vm-hands-entry-lite-06mdg33e.js} +5 -5
  33. package/bin/vm-hands/{vm-hands-entry-lite-d7kdqz8w.js → vm-hands-entry-lite-06mges91.js} +4 -4
  34. package/bin/vm-hands/{vm-hands-entry-lite-gj1ce9nc.js → vm-hands-entry-lite-0bp8kbe3.js} +1 -1
  35. package/bin/vm-hands/{vm-hands-entry-lite-wzq3qsh1.js → vm-hands-entry-lite-0tavq3p4.js} +2 -2
  36. package/bin/vm-hands/{vm-hands-entry-lite-qz74j563.js → vm-hands-entry-lite-1kt82jes.js} +2 -2
  37. package/bin/vm-hands/{vm-hands-entry-lite-spb0z2m4.js → vm-hands-entry-lite-3a8ra8ah.js} +4 -4
  38. package/bin/vm-hands/{vm-hands-entry-lite-70x16hkx.js → vm-hands-entry-lite-4cdn822w.js} +3 -3
  39. package/bin/vm-hands/{vm-hands-entry-lite-qxeegp2n.js → vm-hands-entry-lite-5wsygx6n.js} +2 -2
  40. package/bin/vm-hands/{vm-hands-entry-lite-ydgedg8n.js → vm-hands-entry-lite-88yjxxvf.js} +5 -5
  41. package/bin/vm-hands/{vm-hands-entry-lite-148nz8be.js → vm-hands-entry-lite-9x81cr3a.js} +3 -3
  42. package/bin/vm-hands/{vm-hands-entry-lite-fcvf8md1.js → vm-hands-entry-lite-a3p6xz53.js} +2 -2
  43. package/bin/vm-hands/{vm-hands-entry-lite-dcrz19xf.js → vm-hands-entry-lite-a6w60nv9.js} +3 -3
  44. package/bin/vm-hands/{vm-hands-entry-lite-25yzr6m8.js → vm-hands-entry-lite-baxqey3h.js} +42 -42
  45. package/bin/vm-hands/{vm-hands-entry-lite-wx1fmrbs.js → vm-hands-entry-lite-bvqwsd3b.js} +3 -3
  46. package/bin/vm-hands/{vm-hands-entry-lite-fgppp6x9.js → vm-hands-entry-lite-c0t5xpzh.js} +1 -1
  47. package/bin/vm-hands/{vm-hands-entry-lite-ymqb2927.js → vm-hands-entry-lite-c4959xva.js} +2 -2
  48. package/bin/vm-hands/vm-hands-entry-lite-f8ts9y2q.js +3 -0
  49. package/bin/vm-hands/vm-hands-entry-lite-ghva8qrf.js +2 -0
  50. package/bin/vm-hands/{vm-hands-entry-lite-x9qp374y.js → vm-hands-entry-lite-h33trj58.js} +7 -7
  51. package/bin/vm-hands/{vm-hands-entry-lite-0sh835na.js → vm-hands-entry-lite-haws181e.js} +2 -2
  52. package/bin/vm-hands/{vm-hands-entry-lite-gh0yjzye.js → vm-hands-entry-lite-hc11hecd.js} +1 -1
  53. package/bin/vm-hands/{vm-hands-entry-lite-cwsjrxqj.js → vm-hands-entry-lite-j1qppwnx.js} +2 -2
  54. package/bin/vm-hands/{vm-hands-entry-lite-v0zva5nj.js → vm-hands-entry-lite-krnvgf71.js} +1 -1
  55. package/bin/vm-hands/{vm-hands-entry-lite-90y6pf98.js → vm-hands-entry-lite-kwmjn9y3.js} +3 -3
  56. package/bin/vm-hands/{vm-hands-entry-lite-mma9qt5r.js → vm-hands-entry-lite-mfvtp7py.js} +1 -1
  57. package/bin/vm-hands/{vm-hands-entry-lite-3f6bayc8.js → vm-hands-entry-lite-mxyry9da.js} +2 -2
  58. package/bin/vm-hands/{vm-hands-entry-lite-19dpjtpb.js → vm-hands-entry-lite-n3274tws.js} +1 -1
  59. package/bin/vm-hands/{vm-hands-entry-lite-gtnpk3sc.js → vm-hands-entry-lite-nb0n1vy1.js} +2 -2
  60. package/bin/vm-hands/{vm-hands-entry-lite-423rvptb.js → vm-hands-entry-lite-nercg1yz.js} +19 -19
  61. package/bin/vm-hands/{vm-hands-entry-lite-zc8fsn2e.js → vm-hands-entry-lite-pzj5s203.js} +2 -2
  62. package/bin/vm-hands/{vm-hands-entry-lite-svd5v9dr.js → vm-hands-entry-lite-q1yvw4xz.js} +1 -1
  63. package/bin/vm-hands/{vm-hands-entry-lite-1nrxnm0y.js → vm-hands-entry-lite-sfmeafdm.js} +9 -9
  64. package/bin/vm-hands/{vm-hands-entry-lite-5eg3tgdq.js → vm-hands-entry-lite-t82dzcxb.js} +2 -2
  65. package/bin/vm-hands/{vm-hands-entry-lite-q80xmhrx.js → vm-hands-entry-lite-tash5m18.js} +14 -14
  66. package/bin/vm-hands/{vm-hands-entry-lite-ndhspax6.js → vm-hands-entry-lite-tns12zqc.js} +2 -2
  67. package/bin/vm-hands/{vm-hands-entry-lite-wh0xwp85.js → vm-hands-entry-lite-wc730qz7.js} +3 -3
  68. package/bin/vm-hands/{vm-hands-entry-lite-5np5k3wb.js → vm-hands-entry-lite-wfc0agnt.js} +3 -3
  69. package/bin/vm-hands/{vm-hands-entry-lite-zk6hbpa3.js → vm-hands-entry-lite-xjpb3g9t.js} +3 -3
  70. package/bin/vm-hands/vm-hands-entry-lite-z35nbedn.js +150 -0
  71. package/bin/vm-hands/{vm-hands-entry-lite-1jdt74g0.js → vm-hands-entry-lite-z4jrseer.js} +1 -1
  72. package/bin/vm-hands/{vm-hands-entry-lite-g6fr9e30.js → vm-hands-entry-lite-zrs8h4rf.js} +5 -5
  73. package/bin/vm-hands/vm-hands-entry-lite.js +2 -2
  74. package/bin/vm-hands/{vm-hands-executor-v24y415a.js → vm-hands-executor-5n4k8t53.js} +3 -3
  75. package/bin/vm-hands/vm-hands-op-runner-mzyesbyf.js +2 -0
  76. package/bin/vm-hands/{vm-hands-runtime-gsjba3vg.js → vm-hands-runtime-zhsw99cm.js} +3 -3
  77. package/bin/vm-hands/worker-preview-readiness-8ftb3nbw.js +2 -0
  78. package/bin/vm-hands/worker-sandbox-k0vx97tx.js +2 -0
  79. package/package.json +1 -1
  80. package/bin/vm-hands/api-693jj5gc.js +0 -2
  81. package/bin/vm-hands/api-credentials-jed7tp30.js +0 -2
  82. package/bin/vm-hands/connect-cli-wstfzzds.js +0 -2
  83. package/bin/vm-hands/credentials-yf556ykn.js +0 -2
  84. package/bin/vm-hands/custom-endpoint-device-vbct7bj9.js +0 -2
  85. package/bin/vm-hands/desktop-account-j6fjngt1.js +0 -2
  86. package/bin/vm-hands/install-receipt-gwv1qv2m.js +0 -2
  87. package/bin/vm-hands/local-automation-06wtwxjp.js +0 -2
  88. package/bin/vm-hands/local-capabilities-wj42bc6s.js +0 -2
  89. package/bin/vm-hands/local-desktop-users-4hc6jysa.js +0 -2
  90. package/bin/vm-hands/local-display-mac-fjeyb4h9.js +0 -2
  91. package/bin/vm-hands/local-display-session-n5pv37tf.js +0 -2
  92. package/bin/vm-hands/local-display-video-kdybca06.js +0 -2
  93. package/bin/vm-hands/local-managed-process-c890ref6.js +0 -2
  94. package/bin/vm-hands/local-pty-session-4h4ekakp.js +0 -2
  95. package/bin/vm-hands/managed-runtime-ar9pn1mp.js +0 -2
  96. package/bin/vm-hands/network-contract-4wew8f21.js +0 -2
  97. package/bin/vm-hands/package-sng72tm1.js +0 -2
  98. package/bin/vm-hands/permissions-t03k97w0.js +0 -2
  99. package/bin/vm-hands/serve-service-nrb9h8af.js +0 -2
  100. package/bin/vm-hands/version-0r7g0x44.js +0 -2
  101. package/bin/vm-hands/vm-hands-entry-lite-60pnam39.js +0 -3
  102. package/bin/vm-hands/vm-hands-entry-lite-etg5ft0x.js +0 -2
  103. package/bin/vm-hands/vm-hands-entry-lite-y5b73xe5.js +0 -128
  104. package/bin/vm-hands/vm-hands-op-runner-7derp3tq.js +0 -2
  105. package/bin/vm-hands/worker-preview-readiness-ye6cvg3k.js +0 -2
  106. package/bin/vm-hands/worker-sandbox-j6cmex8e.js +0 -2
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- var l=Object.create;var{getPrototypeOf:m,defineProperty:h,getOwnPropertyNames:n}=Object;var k=Object.prototype.hasOwnProperty;function o(a){return this[a]}var p,q,Bi=(a,b,c)=>{var d=a!=null&&typeof a==="object";if(d){var i=b?p??=new WeakMap:q??=new WeakMap,j=i.get(a);if(j)return j}c=a!=null?l(m(a)):{};let f=b||!a||!a.__esModule||!k.call(a,"default")?h(c,"default",{value:a,enumerable:!0}):c;if(a&&typeof a==="object"||typeof a==="function"){for(let g of n(a))if(!k.call(f,g))h(f,g,{get:o.bind(a,g),enumerable:!0})}if(d)i.set(a,f);return f};var he=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var r=(a)=>a;function s(a,b){this[a]=r.bind(null,b)}var ms=(a,b)=>{for(var c in b)h(a,c,{get:b[c],enumerable:!0,configurable:!0,set:s.bind(b,c)})};var gs=(a,b,c)=>()=>{if(a)try{b=a(a=0)}catch(d){c=[d]}if(c)throw c[0];return b};var e=import.meta.require;
3
- export{Bi,he,ms,gs,e};
2
+ var l=Object.create;var{getPrototypeOf:m,defineProperty:h,getOwnPropertyNames:n}=Object;var k=Object.prototype.hasOwnProperty;function o(a){return this[a]}var p,q,Fi=(a,b,c)=>{var d=a!=null&&typeof a==="object";if(d){var i=b?p??=new WeakMap:q??=new WeakMap,j=i.get(a);if(j)return j}c=a!=null?l(m(a)):{};let f=b||!a||!a.__esModule||!k.call(a,"default")?h(c,"default",{value:a,enumerable:!0}):c;if(a&&typeof a==="object"||typeof a==="function"){for(let g of n(a))if(!k.call(f,g))h(f,g,{get:o.bind(a,g),enumerable:!0})}if(d)i.set(a,f);return f};var he=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var r=(a)=>a;function s(a,b){this[a]=r.bind(null,b)}var ys=(a,b)=>{for(var c in b)h(a,c,{get:b[c],enumerable:!0,configurable:!0,set:s.bind(b,c)})};var bs=(a,b,c)=>()=>{if(a)try{b=a(a=0)}catch(d){c=[d]}if(c)throw c[0];return b};var e=import.meta.require;
3
+ export{Fi,he,ys,bs,e};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{he}from"./vm-hands-entry-lite-zc8fsn2e.js";var hn=he(function(t,e){e.exports={name:"playwright-core",version:"1.60.0",description:"A high-level API to automate web browsers",repository:{type:"git",url:"git+https://github.com/microsoft/playwright.git"},homepage:"https://playwright.dev",engines:{node:">=18"},author:{name:"Microsoft Corporation"},license:"Apache-2.0",exports:{".":{types:"./index.d.ts",import:"./index.mjs",require:"./index.js",default:"./index.js"},"./package.json":"./package.json","./lib/bootstrap":"./lib/bootstrap.js","./lib/coreBundle":"./lib/coreBundle.js","./lib/utilsBundle":"./lib/utilsBundle.js","./lib/tools/cli-client/program":"./lib/tools/cli-client/program.js"},bin:{"playwright-core":"cli.js"},types:"types/types.d.ts"}});
2
+ import{he}from"./vm-hands-entry-lite-pzj5s203.js";var hn=he(function(t,e){e.exports={name:"playwright-core",version:"1.60.0",description:"A high-level API to automate web browsers",repository:{type:"git",url:"git+https://github.com/microsoft/playwright.git"},homepage:"https://playwright.dev",engines:{node:">=18"},author:{name:"Microsoft Corporation"},license:"Apache-2.0",exports:{".":{types:"./index.d.ts",import:"./index.mjs",require:"./index.js",default:"./index.js"},"./package.json":"./package.json","./lib/bootstrap":"./lib/bootstrap.js","./lib/coreBundle":"./lib/coreBundle.js","./lib/utilsBundle":"./lib/utilsBundle.js","./lib/tools/cli-client/program":"./lib/tools/cli-client/program.js"},bin:{"playwright-core":"cli.js"},types:"types/types.d.ts"}});
3
3
  export{hn};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFile as ie,spawn as E}from"child_process";var wo="h264_ws_v1",bo="video",dt=["smooth","sharp","data_saver","balanced"];var vo="video_presets";var L=8388608,S=65536,So="control",Eo="v1",X=200;function Mn(t){if(!t||typeof t!=="object"||Array.isArray(t))return null;let e=t,n=(i)=>typeof i==="string"&&i.length>0&&i.length<=X;if(Object.keys(e).length!==2||!n(e.user_id)||!n(e.name))return null;return{user_id:e.user_id,name:e.name}}var xo="windows",ko="v1",D=200,J=(t)=>typeof t==="string"&&dt.includes(t);function Co(t){if(!t||typeof t!=="object"||Array.isArray(t))return null;let e=t;if(Object.keys(e).length!==2||e.format!=="h264_ws_v1"||!J(e.preset))return null;return{format:"h264_ws_v1",preset:e.preset}}var o={hello:1,frame:2,stats:3,pong:4,serverClipboard:5,error:6,audioHello:7,audio:8,control:9,windows:10,pointer:16,key:17,config:18,ping:19,clientClipboard:20,keyframeRequest:21,ack:22,audioEnable:23,resize:24};class l extends Error{constructor(t){super(t);this.name="DisplayVideoProtocolError"}}var Z=new TextEncoder,Q=new TextDecoder("utf-8",{fatal:!0});function p(t,e){if(e.byteLength+1>L)throw new l("message_too_large");let n=new Uint8Array(5+e.byteLength),i=new DataView(n.buffer);return i.setUint32(0,e.byteLength+1),i.setUint8(4,t),n.set(e,5),n}function w(t){let e=Z.encode(t);if(e.byteLength>S)throw new l("text_too_large");return e}function _(t,e){if(!Number.isInteger(t)||t<0||t>65535)throw new l(`invalid_${e}`);return t}function ee(t){if(!Number.isFinite(t))throw new l("invalid_window");return Math.max(-2147483648,Math.min(2147483647,Math.round(t)))}function Wt(t){switch(t.type){case"hello":{let e=w(t.codec),n=new Uint8Array(6+e.byteLength),i=new DataView(n.buffer);return i.setUint16(0,_(t.width,"width")),i.setUint16(2,_(t.height,"height")),i.setUint8(4,Math.max(1,Math.min(240,Math.round(t.fps)))),i.setUint8(5,dt.indexOf(t.preset)),n.set(e,6),p(o.hello,n)}case"frame":{let e=new Uint8Array(13+t.data.byteLength),n=new DataView(e.buffer);return n.setUint8(0,t.key?1:0),n.setUint32(1,t.seq>>>0),n.setBigUint64(5,BigInt(Math.max(0,Math.floor(t.captureMicros)))),e.set(t.data,13),p(o.frame,e)}case"stats":return p(o.stats,w(JSON.stringify(t.stats)));case"pong":case"ping":{let e=new Uint8Array(8);return new DataView(e.buffer).setFloat64(0,t.token),p(t.type==="ping"?o.ping:o.pong,e)}case"serverClipboard":return p(o.serverClipboard,w(t.text));case"clientClipboard":return p(o.clientClipboard,w(t.text));case"error":return p(o.error,w(t.code));case"pointer":{let e=new Uint8Array(5),n=new DataView(e.buffer);return n.setUint16(0,_(t.x,"x")),n.setUint16(2,_(t.y,"y")),n.setUint8(4,t.buttons&255),p(o.pointer,e)}case"key":{let e=new Uint8Array(5),n=new DataView(e.buffer);return n.setUint8(0,t.down?1:0),n.setUint32(1,t.keysym>>>0),p(o.key,e)}case"config":return p(o.config,Uint8Array.of(dt.indexOf(t.preset)));case"keyframeRequest":return p(o.keyframeRequest,new Uint8Array(0));case"audioHello":{let e=w(t.codec),n=new Uint8Array(5+e.byteLength),i=new DataView(n.buffer);return i.setUint32(0,t.sampleRate>>>0),i.setUint8(4,t.channels&255),n.set(e,5),p(o.audioHello,n)}case"audio":{let e=new Uint8Array(8+t.data.byteLength);return new DataView(e.buffer).setBigUint64(0,BigInt(Math.max(0,Math.floor(t.captureMicros)))),e.set(t.data,8),p(o.audio,e)}case"control":return p(o.control,w(JSON.stringify(t.control)));case"windows":{let e=t.bounds.slice(0,D),n=new Uint8Array(e.length*16),i=new DataView(n.buffer);return e.forEach((s,a)=>{[s.x,s.y,s.width,s.height].forEach((c,d)=>i.setInt32(a*16+d*4,ee(c)))}),p(o.windows,n)}case"audioEnable":return p(o.audioEnable,Uint8Array.of(t.on?1:0));case"resize":{let e=new Uint8Array(4),n=new DataView(e.buffer);return n.setUint16(0,_(t.width,"width")),n.setUint16(2,_(t.height,"height")),p(o.resize,e)}case"ack":{let e=new Uint8Array(4);return new DataView(e.buffer).setUint32(0,t.seq>>>0),p(o.ack,e)}}}function M(t){let e=dt[t];if(!e)throw new l("invalid_preset");return e}function y(t,e){if(t.byteLength!==e)throw new l("invalid_length")}function x(t){if(t.byteLength>S)throw new l("text_too_large");try{return Q.decode(t)}catch{throw new l("invalid_text")}}function te(t){let e;try{e=JSON.parse(x(t))}catch{throw new l("invalid_stats")}let n=e;if(!n||typeof n!=="object"||["fps","kbps","dropped","restarts","queued_bytes"].some((s)=>typeof n[s]!=="number"||!Number.isFinite(n[s])))throw new l("invalid_stats");return{fps:n.fps,kbps:n.kbps,dropped:n.dropped,restarts:n.restarts,queued_bytes:n.queued_bytes}}function ne(t){let e;try{e=JSON.parse(x(t))}catch{throw new l("invalid_control")}let n=e;if(!n||typeof n!=="object"||typeof n.you!=="boolean"||typeof n.same_user!=="boolean")throw new l("invalid_control");let i=n.holder===null?null:Mn(n.holder);if(i===null&&n.holder!==null)throw new l("invalid_control");return{holder:i,you:n.you,same_user:n.same_user}}function re(t,e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(t){case o.hello:if(e.byteLength<6)throw new l("invalid_length");return{type:"hello",width:n.getUint16(0),height:n.getUint16(2),fps:n.getUint8(4),preset:M(n.getUint8(5)),codec:x(e.subarray(6))};case o.frame:if(e.byteLength<14)throw new l("invalid_length");if(n.getUint8(0)>1)throw new l("invalid_frame_flags");return{type:"frame",key:n.getUint8(0)===1,seq:n.getUint32(1),captureMicros:Number(n.getBigUint64(5)),data:e.subarray(13)};case o.stats:return{type:"stats",stats:te(e)};case o.ping:case o.pong:return y(e,8),{type:t===o.ping?"ping":"pong",token:n.getFloat64(0)};case o.serverClipboard:return{type:"serverClipboard",text:x(e)};case o.clientClipboard:return{type:"clientClipboard",text:x(e)};case o.error:return{type:"error",code:x(e)};case o.pointer:return y(e,5),{type:"pointer",x:n.getUint16(0),y:n.getUint16(2),buttons:n.getUint8(4)};case o.key:if(y(e,5),n.getUint8(0)>1)throw new l("invalid_key_flags");return{type:"key",down:n.getUint8(0)===1,keysym:n.getUint32(1)};case o.config:return y(e,1),{type:"config",preset:M(n.getUint8(0))};case o.keyframeRequest:return y(e,0),{type:"keyframeRequest"};case o.audioHello:if(e.byteLength<5)throw new l("invalid_length");return{type:"audioHello",sampleRate:n.getUint32(0),channels:n.getUint8(4),codec:x(e.subarray(5))};case o.audio:if(e.byteLength<9)throw new l("invalid_length");return{type:"audio",captureMicros:Number(n.getBigUint64(0)),data:e.subarray(8)};case o.audioEnable:if(y(e,1),n.getUint8(0)>1)throw new l("invalid_audio_flags");return{type:"audioEnable",on:n.getUint8(0)===1};case o.resize:return y(e,4),{type:"resize",width:n.getUint16(0),height:n.getUint16(2)};case o.control:return{type:"control",control:ne(e)};case o.windows:{if(e.byteLength%16!==0||e.byteLength>D*16)throw new l("invalid_length");let i=[];for(let s=0;s<e.byteLength;s+=16)i.push({x:n.getInt32(s),y:n.getInt32(s+4),width:n.getInt32(s+8),height:n.getInt32(s+12)});return{type:"windows",bounds:i}}case o.ack:return y(e,4),{type:"ack",seq:n.getUint32(0)};default:return null}}class $n{buffer=new Uint8Array(0);push(t){let e=new Uint8Array(this.buffer.byteLength+t.byteLength);e.set(this.buffer),e.set(t,this.buffer.byteLength);let n=[],i=0;while(e.byteLength-i>=4){let s=new DataView(e.buffer,e.byteOffset+i,4).getUint32(0);if(s<1||s>L)throw new l("invalid_message_length");if(e.byteLength-i-4<s)break;let a=e[i+4],c=e.slice(i+5,i+4+s),d=re(a,c);if(d)n.push(d);i+=4+s}return this.buffer=e.slice(i),n}}var Y="/usr/bin/osascript",se=5000,oe=1048576,ae=String.raw`
2
+ import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFile as se,spawn as E}from"child_process";var bo="h264_ws_v1",vo="video",dt=["smooth","sharp","data_saver","balanced"];var So="video_presets";var M=8388608,S=65536,Eo="control",xo="v1",X=200;function Mn(t){if(!t||typeof t!=="object"||Array.isArray(t))return null;let e=t,n=(i)=>typeof i==="string"&&i.length>0&&i.length<=X;if(Object.keys(e).length!==2||!n(e.user_id)||!n(e.name))return null;return{user_id:e.user_id,name:e.name}}var ko="windows",Co="v1",Ao="look",Po="v1",J=["reason","grok"];function $n(t){return typeof t==="string"&&J.includes(t)?t:null}var D=200,Z=(t)=>typeof t==="string"&&dt.includes(t);function Ro(t){if(!t||typeof t!=="object"||Array.isArray(t))return null;let e=t;if(Object.keys(e).length!==2||e.format!=="h264_ws_v1"||!Z(e.preset))return null;return{format:"h264_ws_v1",preset:e.preset}}var o={hello:1,frame:2,stats:3,pong:4,serverClipboard:5,error:6,audioHello:7,audio:8,control:9,windows:10,pointer:16,key:17,config:18,ping:19,clientClipboard:20,keyframeRequest:21,ack:22,audioEnable:23,resize:24};class l extends Error{constructor(t){super(t);this.name="DisplayVideoProtocolError"}}var Q=new TextEncoder,ee=new TextDecoder("utf-8",{fatal:!0});function p(t,e){if(e.byteLength+1>M)throw new l("message_too_large");let n=new Uint8Array(5+e.byteLength),i=new DataView(n.buffer);return i.setUint32(0,e.byteLength+1),i.setUint8(4,t),n.set(e,5),n}function w(t){let e=Q.encode(t);if(e.byteLength>S)throw new l("text_too_large");return e}function _(t,e){if(!Number.isInteger(t)||t<0||t>65535)throw new l(`invalid_${e}`);return t}function te(t){if(!Number.isFinite(t))throw new l("invalid_window");return Math.max(-2147483648,Math.min(2147483647,Math.round(t)))}function Wt(t){switch(t.type){case"hello":{let e=w(t.codec),n=new Uint8Array(6+e.byteLength),i=new DataView(n.buffer);return i.setUint16(0,_(t.width,"width")),i.setUint16(2,_(t.height,"height")),i.setUint8(4,Math.max(1,Math.min(240,Math.round(t.fps)))),i.setUint8(5,dt.indexOf(t.preset)),n.set(e,6),p(o.hello,n)}case"frame":{let e=new Uint8Array(13+t.data.byteLength),n=new DataView(e.buffer);return n.setUint8(0,t.key?1:0),n.setUint32(1,t.seq>>>0),n.setBigUint64(5,BigInt(Math.max(0,Math.floor(t.captureMicros)))),e.set(t.data,13),p(o.frame,e)}case"stats":return p(o.stats,w(JSON.stringify(t.stats)));case"pong":case"ping":{let e=new Uint8Array(8);return new DataView(e.buffer).setFloat64(0,t.token),p(t.type==="ping"?o.ping:o.pong,e)}case"serverClipboard":return p(o.serverClipboard,w(t.text));case"clientClipboard":return p(o.clientClipboard,w(t.text));case"error":return p(o.error,w(t.code));case"pointer":{let e=new Uint8Array(5),n=new DataView(e.buffer);return n.setUint16(0,_(t.x,"x")),n.setUint16(2,_(t.y,"y")),n.setUint8(4,t.buttons&255),p(o.pointer,e)}case"key":{let e=new Uint8Array(5),n=new DataView(e.buffer);return n.setUint8(0,t.down?1:0),n.setUint32(1,t.keysym>>>0),p(o.key,e)}case"config":return p(o.config,Uint8Array.of(dt.indexOf(t.preset)));case"keyframeRequest":return p(o.keyframeRequest,new Uint8Array(0));case"audioHello":{let e=w(t.codec),n=new Uint8Array(5+e.byteLength),i=new DataView(n.buffer);return i.setUint32(0,t.sampleRate>>>0),i.setUint8(4,t.channels&255),n.set(e,5),p(o.audioHello,n)}case"audio":{let e=new Uint8Array(8+t.data.byteLength);return new DataView(e.buffer).setBigUint64(0,BigInt(Math.max(0,Math.floor(t.captureMicros)))),e.set(t.data,8),p(o.audio,e)}case"control":return p(o.control,w(JSON.stringify(t.control)));case"windows":{let e=t.bounds.slice(0,D),n=new Uint8Array(e.length*16),i=new DataView(n.buffer);return e.forEach((s,a)=>{[s.x,s.y,s.width,s.height].forEach((c,d)=>i.setInt32(a*16+d*4,te(c)))}),p(o.windows,n)}case"audioEnable":return p(o.audioEnable,Uint8Array.of(t.on?1:0));case"resize":{let e=new Uint8Array(4),n=new DataView(e.buffer);return n.setUint16(0,_(t.width,"width")),n.setUint16(2,_(t.height,"height")),p(o.resize,e)}case"ack":{let e=new Uint8Array(4);return new DataView(e.buffer).setUint32(0,t.seq>>>0),p(o.ack,e)}}}function L(t){let e=dt[t];if(!e)throw new l("invalid_preset");return e}function y(t,e){if(t.byteLength!==e)throw new l("invalid_length")}function x(t){if(t.byteLength>S)throw new l("text_too_large");try{return ee.decode(t)}catch{throw new l("invalid_text")}}function ne(t){let e;try{e=JSON.parse(x(t))}catch{throw new l("invalid_stats")}let n=e;if(!n||typeof n!=="object"||["fps","kbps","dropped","restarts","queued_bytes"].some((s)=>typeof n[s]!=="number"||!Number.isFinite(n[s])))throw new l("invalid_stats");return{fps:n.fps,kbps:n.kbps,dropped:n.dropped,restarts:n.restarts,queued_bytes:n.queued_bytes}}function re(t){let e;try{e=JSON.parse(x(t))}catch{throw new l("invalid_control")}let n=e;if(!n||typeof n!=="object"||typeof n.you!=="boolean"||typeof n.same_user!=="boolean")throw new l("invalid_control");let i=n.holder===null?null:Mn(n.holder);if(i===null&&n.holder!==null)throw new l("invalid_control");return{holder:i,you:n.you,same_user:n.same_user}}function ie(t,e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(t){case o.hello:if(e.byteLength<6)throw new l("invalid_length");return{type:"hello",width:n.getUint16(0),height:n.getUint16(2),fps:n.getUint8(4),preset:L(n.getUint8(5)),codec:x(e.subarray(6))};case o.frame:if(e.byteLength<14)throw new l("invalid_length");if(n.getUint8(0)>1)throw new l("invalid_frame_flags");return{type:"frame",key:n.getUint8(0)===1,seq:n.getUint32(1),captureMicros:Number(n.getBigUint64(5)),data:e.subarray(13)};case o.stats:return{type:"stats",stats:ne(e)};case o.ping:case o.pong:return y(e,8),{type:t===o.ping?"ping":"pong",token:n.getFloat64(0)};case o.serverClipboard:return{type:"serverClipboard",text:x(e)};case o.clientClipboard:return{type:"clientClipboard",text:x(e)};case o.error:return{type:"error",code:x(e)};case o.pointer:return y(e,5),{type:"pointer",x:n.getUint16(0),y:n.getUint16(2),buttons:n.getUint8(4)};case o.key:if(y(e,5),n.getUint8(0)>1)throw new l("invalid_key_flags");return{type:"key",down:n.getUint8(0)===1,keysym:n.getUint32(1)};case o.config:return y(e,1),{type:"config",preset:L(n.getUint8(0))};case o.keyframeRequest:return y(e,0),{type:"keyframeRequest"};case o.audioHello:if(e.byteLength<5)throw new l("invalid_length");return{type:"audioHello",sampleRate:n.getUint32(0),channels:n.getUint8(4),codec:x(e.subarray(5))};case o.audio:if(e.byteLength<9)throw new l("invalid_length");return{type:"audio",captureMicros:Number(n.getBigUint64(0)),data:e.subarray(8)};case o.audioEnable:if(y(e,1),n.getUint8(0)>1)throw new l("invalid_audio_flags");return{type:"audioEnable",on:n.getUint8(0)===1};case o.resize:return y(e,4),{type:"resize",width:n.getUint16(0),height:n.getUint16(2)};case o.control:return{type:"control",control:re(e)};case o.windows:{if(e.byteLength%16!==0||e.byteLength>D*16)throw new l("invalid_length");let i=[];for(let s=0;s<e.byteLength;s+=16)i.push({x:n.getInt32(s),y:n.getInt32(s+4),width:n.getInt32(s+8),height:n.getInt32(s+12)});return{type:"windows",bounds:i}}case o.ack:return y(e,4),{type:"ack",seq:n.getUint32(0)};default:return null}}class Bn{buffer=new Uint8Array(0);push(t){let e=new Uint8Array(this.buffer.byteLength+t.byteLength);e.set(this.buffer),e.set(t,this.buffer.byteLength);let n=[],i=0;while(e.byteLength-i>=4){let s=new DataView(e.buffer,e.byteOffset+i,4).getUint32(0);if(s<1||s>M)throw new l("invalid_message_length");if(e.byteLength-i-4<s)break;let a=e[i+4],c=e.slice(i+5,i+4+s),d=ie(a,c);if(d)n.push(d);i+=4+s}return this.buffer=e.slice(i),n}}var j="/usr/bin/osascript",oe=5000,ae=1048576,ce=String.raw`
3
3
  ObjC.import("CoreGraphics");
4
4
  ObjC.import("ApplicationServices");
5
5
  ObjC.import("AppKit");
@@ -69,8 +69,8 @@ function run(argv) {
69
69
  }
70
70
  }
71
71
  }
72
- `;function q(t){let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!=="object")return null;let n=e,i=(c)=>typeof c==="number"&&Number.isFinite(c)?Math.min(65535,Math.round(c)):0;if(typeof n.screen!=="boolean"||typeof n.accessibility!=="boolean")return null;let s=i(n.width),a=i(n.height);return s>0&&a>0?{screen:n.screen,accessibility:n.accessibility,width:s,height:a}:null}function k(t,...e){let[n,...i]=[...t,Y,"-l","JavaScript","-e",ae,...e];return[n,i]}function H(t,...e){return new Promise((n)=>{ie(...k(t,...e),{env:{},timeout:se,killSignal:"SIGKILL",maxBuffer:65536,encoding:"utf8"},(i,s)=>n(i?null:q(s.split(`
73
- `)[0]??"")))})}function Ge(t=[]){return H(t,"probe")}function pt(t,e){return H(t,"request",...e?[e]:[])}var N=2,ce=8,ue=String.raw`
72
+ `;function q(t){let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!=="object")return null;let n=e,i=(c)=>typeof c==="number"&&Number.isFinite(c)?Math.min(65535,Math.round(c)):0;if(typeof n.screen!=="boolean"||typeof n.accessibility!=="boolean")return null;let s=i(n.width),a=i(n.height);return s>0&&a>0?{screen:n.screen,accessibility:n.accessibility,width:s,height:a}:null}function v(t,...e){let[n,...i]=[...t,j,"-l","JavaScript","-e",ce,...e];return[n,i]}function H(t,...e){return new Promise((n)=>{se(...v(t,...e),{env:{},timeout:oe,killSignal:"SIGKILL",maxBuffer:65536,encoding:"utf8"},(i,s)=>n(i?null:q(s.split(`
73
+ `)[0]??"")))})}function Ge(t=[]){return H(t,"probe")}function pt(t,e){return H(t,"request",...e?[e]:[])}var N=2,ue=8,le=String.raw`
74
74
  ObjC.import("CoreGraphics");
75
75
  ObjC.import("Foundation");
76
76
  ObjC.bindFunction("getppid", ["int", []]);
@@ -96,17 +96,17 @@ function run() {
96
96
  wait = ${N};
97
97
  stdout.writeData($(line + "\n").dataUsingEncoding($.NSUTF8StringEncoding));
98
98
  } else {
99
- wait = Math.min(wait * 2, ${ce});
99
+ wait = Math.min(wait * 2, ${ue});
100
100
  }
101
101
  $.NSThread.sleepForTimeInterval(wait);
102
102
  }
103
103
  }
104
- `;function le(t){let e;try{e=JSON.parse(t)}catch{return null}if(!Array.isArray(e))return null;let n=[];for(let i of e.slice(0,D)){if(!Array.isArray(i)||i.length!==4||!i.every((u)=>typeof u==="number"&&Number.isFinite(u)))return null;let[s,a,c,d]=i.map(Math.round);if(c>0&&d>0)n.push({x:s,y:a,width:c,height:d})}return n}function Bn(t){let e=Date.now(),n=0,i=!1,s=(u,b={})=>{try{process.stderr.write(`${JSON.stringify({event:"display.windows_helper",state:u,...b})}
105
- `)}catch{}},a=(u,b={})=>{if(i)return;i=!0,s(u,{updates:n,duration_ms:Date.now()-e,...b})},c=E(Y,["-l","JavaScript","-e",ue],{env:{},stdio:["ignore","pipe","ignore"]});s("started");let d="";return c.stdout.on("data",(u)=>{if(i)return;d+=u.toString("utf8");for(let b=d.indexOf(`
104
+ `;function de(t){let e;try{e=JSON.parse(t)}catch{return null}if(!Array.isArray(e))return null;let n=[];for(let i of e.slice(0,D)){if(!Array.isArray(i)||i.length!==4||!i.every((u)=>typeof u==="number"&&Number.isFinite(u)))return null;let[s,a,c,d]=i.map(Math.round);if(c>0&&d>0)n.push({x:s,y:a,width:c,height:d})}return n}function Fn(t){let e=Date.now(),n=0,i=!1,s=(u,b={})=>{try{process.stderr.write(`${JSON.stringify({event:"display.windows_helper",state:u,...b})}
105
+ `)}catch{}},a=(u,b={})=>{if(i)return;i=!0,s(u,{updates:n,duration_ms:Date.now()-e,...b})},c=E(j,["-l","JavaScript","-e",le],{env:{},stdio:["ignore","pipe","ignore"]});s("started");let d="";return c.stdout.on("data",(u)=>{if(i)return;d+=u.toString("utf8");for(let b=d.indexOf(`
106
106
  `);b>=0;b=d.indexOf(`
107
- `)){let m=le(d.slice(0,b));if(d=d.slice(b+1),m)n++,t(m)}if(d.length>65536)d=""}),c.once("error",(u)=>a("failed",{code:u.code??"spawn_failed"})),c.once("exit",(u,b)=>a("failed",{code:"exited",exit_code:u,signal:b})),{close(){a("stopped"),c.kill("SIGKILL")}}}var T=5,R=[{bit:1,button:0,down:1,up:2,drag:6},{bit:4,button:1,down:3,up:4,drag:7},{bit:2,button:2,down:25,up:26,drag:27}],de=[[8,1,0],[16,-1,0],[32,0,1],[64,0,-1]],P=50,fe=500,V=4,I=131072,W=262144,O=524288,F=1048576,B=new Map([[65505,[56,I]],[65506,[60,I]],[65507,[59,W]],[65508,[62,W]],[65511,[58,O]],[65512,[61,O]],[65513,[58,O]],[65514,[61,O]],[65027,[61,O]],[65515,[55,F]],[65516,[54,F]]]),pe=new Map([[65288,51],[65289,48],[65056,48],[65293,36],[65307,53],[65535,117],[65509,57],[65360,115],[65361,123],[65362,126],[65363,124],[65364,125],[65365,116],[65366,121],[65367,119],[65379,114],[65386,114],[65291,71],[65408,49],[65421,76],[65429,115],[65430,123],[65431,126],[65432,124],[65433,125],[65434,116],[65435,121],[65436,119],[65437,71],[65438,114],[65439,117],[65450,67],[65451,69],[65452,65],[65453,78],[65454,65],[65455,75],[65469,81],...[82,83,84,85,86,87,88,89,91,92].map((t,e)=>[65456+e,t]),...[122,120,99,118,96,97,98,100,101,109,103,111,105,107,113,106,64,79,80,90].map((t,e)=>[65470+e,t])]),G="asdfhgzxcv\x00bqweryt123465=97-80]ou[ip\x00lj'k;\\,/nm.\x00 `",j='~!@#$%^&*()_+{}|:"<>?',be="`1234567890-=[]\\;',./",v=new Map;for(let t=0;t<G.length;t++){let e=G[t];if(e==="\x00")continue;if(v.set(e.charCodeAt(0),[t,!1]),e>="a"&&e<="z")v.set(e.toUpperCase().charCodeAt(0),[t,!0])}for(let t=0;t<j.length;t++)v.set(j.charCodeAt(t),[v.get(be.charCodeAt(t))[0],!0]);class K{now;x=-1;y=-1;mask=0;clicks=0;lastDown=null;held=new Set;constructor(t=()=>performance.now()){this.now=t}flags(){let t=0;for(let e of this.held)t|=B.get(e)[1];return t}mouse(t,e){return`m ${t} ${this.x} ${this.y} ${e} ${t===T?0:this.clicks} ${this.flags()}`}pointer(t,e,n){let i=[];if(t!==this.x||e!==this.y){this.x=t,this.y=e;let s=R.find((a)=>this.mask&a.bit);i.push(s?this.mouse(s.drag,s.button):this.mouse(T,0))}for(let s of R){let a=(this.mask&s.bit)!==0,c=(n&s.bit)!==0;if(!a&&c){let d=this.now(),u=this.lastDown;this.clicks=u&&u.button===s.button&&d-u.at<=fe&&Math.abs(t-u.x)<=V&&Math.abs(e-u.y)<=V?this.clicks+1:1,this.lastDown={button:s.button,at:d,x:t,y:e},i.push(this.mouse(s.down,s.button))}else if(a&&!c)i.push(this.mouse(s.up,s.button))}for(let[s,a,c]of de)if(!(this.mask&s)&&n&s)i.push(`w ${a*P} ${c*P} ${this.flags()}`);return this.mask=n,i}key(t,e){let n=t?1:0,i=B.get(e);if(i){if(t)this.held.add(e);else this.held.delete(e);return[`k ${i[0]} ${n} ${this.flags()}`]}let s=pe.get(e);if(s!==void 0)return[`k ${s} ${n} ${this.flags()}`];let a=e<256?e:(e&4278190080)===16777216?e&16777215:0,c=v.get(a);if(c)return[`k ${c[0]} ${n} ${this.flags()|(c[1]?I:0)}`];if(a<160||a>65535||a>=55296&&a<57344)return[];return[`u ${n} ${a} ${this.flags()}`]}}function Fn(t,e=[]){let n=E(...k(e),{env:{},stdio:["pipe","pipe","ignore"]}),i=new K,s="",a=!1,c=null,d=()=>{n.kill("SIGKILL"),c?.kill("SIGKILL")},u=(f)=>{if(a)return;a=!0,d(),t.end(f)},b=(f)=>u({error:new r("display_unavailable",f)}),m=(f)=>{if(a||f.length===0)return;if(n.stdin.write(f.map((g)=>`${g}
108
- `).join("")),n.stdin.writableLength>oe)u({reason:"input_backpressure"})},z=()=>{c=E(...k(e,"clipboard"),{env:{},stdio:["ignore","pipe","ignore"]});let f="";c.stdout?.on("data",(g)=>{if(a)return;f+=g.toString("ascii");for(let h=f.indexOf(`
107
+ `)){let m=de(d.slice(0,b));if(d=d.slice(b+1),m)n++,t(m)}if(d.length>65536)d=""}),c.once("error",(u)=>a("failed",{code:u.code??"spawn_failed"})),c.once("exit",(u,b)=>a("failed",{code:"exited",exit_code:u,signal:b})),{close(){a("stopped"),c.kill("SIGKILL")}}}var T=5,R=[{bit:1,button:0,down:1,up:2,drag:6},{bit:4,button:1,down:3,up:4,drag:7},{bit:2,button:2,down:25,up:26,drag:27}],fe=[[8,1,0],[16,-1,0],[32,0,1],[64,0,-1]],P=50,pe=500,V=4,I=131072,W=262144,O=524288,F=1048576,B=new Map([[65505,[56,I]],[65506,[60,I]],[65507,[59,W]],[65508,[62,W]],[65511,[58,O]],[65512,[61,O]],[65513,[58,O]],[65514,[61,O]],[65027,[61,O]],[65515,[55,F]],[65516,[54,F]]]),be=new Map([[65288,51],[65289,48],[65056,48],[65293,36],[65307,53],[65535,117],[65509,57],[65360,115],[65361,123],[65362,126],[65363,124],[65364,125],[65365,116],[65366,121],[65367,119],[65379,114],[65386,114],[65291,71],[65408,49],[65421,76],[65429,115],[65430,123],[65431,126],[65432,124],[65433,125],[65434,116],[65435,121],[65436,119],[65437,71],[65438,114],[65439,117],[65450,67],[65451,69],[65452,65],[65453,78],[65454,65],[65455,75],[65469,81],...[82,83,84,85,86,87,88,89,91,92].map((t,e)=>[65456+e,t]),...[122,120,99,118,96,97,98,100,101,109,103,111,105,107,113,106,64,79,80,90].map((t,e)=>[65470+e,t])]),G="asdfhgzxcv\x00bqweryt123465=97-80]ou[ip\x00lj'k;\\,/nm.\x00 `",Y='~!@#$%^&*()_+{}|:"<>?',he="`1234567890-=[]\\;',./",k=new Map;for(let t=0;t<G.length;t++){let e=G[t];if(e==="\x00")continue;if(k.set(e.charCodeAt(0),[t,!1]),e>="a"&&e<="z")k.set(e.toUpperCase().charCodeAt(0),[t,!0])}for(let t=0;t<Y.length;t++)k.set(Y.charCodeAt(t),[k.get(he.charCodeAt(t))[0],!0]);class K{now;x=-1;y=-1;mask=0;clicks=0;lastDown=null;held=new Set;constructor(t=()=>performance.now()){this.now=t}flags(){let t=0;for(let e of this.held)t|=B.get(e)[1];return t}mouse(t,e){return`m ${t} ${this.x} ${this.y} ${e} ${t===T?0:this.clicks} ${this.flags()}`}pointer(t,e,n){let i=[];if(t!==this.x||e!==this.y){this.x=t,this.y=e;let s=R.find((a)=>this.mask&a.bit);i.push(s?this.mouse(s.drag,s.button):this.mouse(T,0))}for(let s of R){let a=(this.mask&s.bit)!==0,c=(n&s.bit)!==0;if(!a&&c){let d=this.now(),u=this.lastDown;this.clicks=u&&u.button===s.button&&d-u.at<=pe&&Math.abs(t-u.x)<=V&&Math.abs(e-u.y)<=V?this.clicks+1:1,this.lastDown={button:s.button,at:d,x:t,y:e},i.push(this.mouse(s.down,s.button))}else if(a&&!c)i.push(this.mouse(s.up,s.button))}for(let[s,a,c]of fe)if(!(this.mask&s)&&n&s)i.push(`w ${a*P} ${c*P} ${this.flags()}`);return this.mask=n,i}key(t,e){let n=t?1:0,i=B.get(e);if(i){if(t)this.held.add(e);else this.held.delete(e);return[`k ${i[0]} ${n} ${this.flags()}`]}let s=be.get(e);if(s!==void 0)return[`k ${s} ${n} ${this.flags()}`];let a=e<256?e:(e&4278190080)===16777216?e&16777215:0,c=k.get(a);if(c)return[`k ${c[0]} ${n} ${this.flags()|(c[1]?I:0)}`];if(a<160||a>65535||a>=55296&&a<57344)return[];return[`u ${n} ${a} ${this.flags()}`]}}function jn(t,e=[]){let n=E(...v(e),{env:{},stdio:["pipe","pipe","ignore"]}),i=new K,s="",a=!1,c=null,d=()=>{n.kill("SIGKILL"),c?.kill("SIGKILL")},u=(f)=>{if(a)return;a=!0,d(),t.end(f)},b=(f)=>u({error:new r("display_unavailable",f)}),m=(f)=>{if(a||f.length===0)return;if(n.stdin.write(f.map((g)=>`${g}
108
+ `).join("")),n.stdin.writableLength>ae)u({reason:"input_backpressure"})},z=()=>{c=E(...v(e,"clipboard"),{env:{},stdio:["ignore","pipe","ignore"]});let f="";c.stdout?.on("data",(g)=>{if(a)return;f+=g.toString("ascii");for(let h=f.indexOf(`
109
109
  `);h>=0;h=f.indexOf(`
110
110
  `)){let U=f.slice(0,h);if(f=f.slice(h+1),!U.startsWith("c "))continue;let A=U.slice(2);if(A.length>Math.ceil(S/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(A)){u({reason:"display_protocol"});return}let C=Buffer.from(A,"base64");if(C.byteLength<=S)t.clipboard(C.toString("utf8"));if(a)return}if(f.length>Math.ceil(S/3)*4+2)u({reason:"display_protocol"})}),c.once("error",()=>b("Reason could not watch this Mac's desktop clipboard.")),c.once("exit",()=>{if(!a)b("Reason could not watch this Mac's desktop clipboard.")})};return n.stdout.on("data",(f)=>{if(a||s===null)return;s+=f.toString("utf8");let g=s.indexOf(`
111
111
  `);if(g<0){if(s.length>4096)u({reason:"display_protocol"});return}let h=q(s.slice(0,g));if(s=null,!h)u({reason:"display_protocol"});else if(!h.screen||!h.accessibility)b(e.length>0?"Reason's background worker needs Screen Recording and Accessibility on this Mac (its own Reason entry in System Settings > Privacy & Security, not the Reason app's): run `reason permissions allow` on this Mac.":"Allow Screen Recording and Accessibility for this Mac's Reason worker, then restart it.");else z(),t.ready({width:h.width,height:h.height})}),n.stdin.on("error",()=>{return}),n.once("error",()=>b("Reason could not start this Mac's desktop input.")),n.once("exit",()=>{if(s!==null)b("Reason could not start this Mac's desktop input.");else u({reason:"display_closed"})}),{pointer:(f,g,h)=>m(i.pointer(f,g,h)),key:(f,g)=>m(i.key(f,g)),clipboard:(f)=>m([`c ${Buffer.from(f,"utf8").toString("base64")}`]),close(){a=!0,d()}}}
112
- export{wo,bo,dt,vo,S,So,Eo,Mn,xo,ko,Co,Wt,$n,Ge,pt,Bn,Fn};
112
+ export{bo,vo,dt,So,S,Eo,xo,Mn,ko,Co,Ao,Po,$n,Ro,Wt,Bn,Ge,pt,Fn,jn};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{T}from"./vm-hands-entry-lite-fcvf8md1.js";import{basename as ln}from"path";var _t=["production","staging"],un="https://api.reasonmachines.com",fn="https://staging-api.reasonmachines.com";var A={production:{api:"https://api.reasonmachines.ai",app:"https://reasonmachines.ai"},staging:{api:"https://staging-api.reasonmachines.ai",app:"https://staging.reasonmachines.ai"}},gn=new Set(["ara-staging","ara-staging.exe","reason-staging","reason-staging.exe"]);function _(n={}){let e=T(n.env??process.env,"REASON_CLI_CHANNEL")?.trim().toLowerCase();if(e){if(_t.includes(e))return e;throw Error(`Unknown Reason CLI channel: ${e}`)}let r=ln(n.executablePath??process.execPath).toLowerCase();return gn.has(r)?"staging":"production"}function rr(n){return n==="staging"?fn:un}var U={production:["https://api.ara.so",A.production.api],staging:["https://api-staging.ara.so",A.staging.api]};function Xr(n){let e;try{e=new URL(n).origin}catch{return n}let r=_t.find((t)=>U[t].includes(e));return r?rr(r):e}function Mo(n,e){return n===e||Xr(n)===Xr(e)}function $o(n,e){return _t.some((r)=>U[r].includes(n)&&e===rr(r))}function Bo(n,e){try{let r=new URL(e);return!r.username&&!r.password&&(r.origin===rr(n)||r.origin===A[n].api)}catch{return!1}}function ti(n){try{let e=new URL(n).hostname.replace(/^\[|\]$/g,"").toLowerCase();return e==="localhost"||e==="127.0.0.1"||e==="::1"}catch{return!1}}import{randomBytes as J}from"crypto";import{chmodSync as q,closeSync as B,constants as bn,linkSync as V,lstatSync as w,mkdirSync as z,openSync as En,readdirSync as L,readFileSync as Wn,readlinkSync as v,renameSync as S,rmdirSync as Q,symlinkSync as N,unlinkSync as d}from"fs";import{createRequire as Nn}from"module";import{constants as Sn}from"os";import{basename as R,join as l,sep as kn}from"path";import{existsSync as O,lstatSync as j,readdirSync as pn,readFileSync as mn,readlinkSync as dn,realpathSync as yn}from"fs";import{join as m,sep as hn}from"path";function G(n,...e){let r=m(n,"ara"),t=m(n,"reason");if(!Yr(r))return m(t,...e);if(!O(t))return m(r,...e);return O(m(r,...e))&&!O(m(t,...e))?m(r,...e):m(t,...e)}function Yr(n){try{let e=j(n);if(!e.isSymbolicLink())return e.isDirectory();return dn(n)!=="reason"&&O(n)}catch{return!1}}function X(n,e=[]){if(!Yr(n))return!1;let r;try{r=[n,...pn(n,{withFileTypes:!0}).filter((t)=>t.isDirectory()).map((t)=>m(n,t.name))]}catch{return!1}return r.some((t)=>["connect","connect-once"].filter((i)=>!e.includes(m(t,i))).some((i)=>{let s=m(t,i,"worker.json");try{j(s)}catch{return!1}try{let a=JSON.parse(mn(s,"utf8"))?.stateDirectory;if(typeof a!=="string")return!0;let c=(o,u)=>o===u||o.startsWith(u+hn);return c(a,n)||c(M(a),M(n))}catch{return!0}}))}function M(n){try{return yn(n)}catch{return n}}var P=new Set(["credentials.json","local-device.json","local-device.revoked.json","local-device.auth-migration.json","local-device.json.registration-pending.json","local-daemon.json","local-daemon.json.workspaces.json","local-root-fingerprint-key.json","instances","workspaces"]),Z=new Set(["local-device.proxy.json"]),Cn=new Set(["local-device.key","local-device.binding"]),W=new Map;function yt(n,e,r){let t=l(n,"ara");if(process.platform==="win32"||/[/\\]\.reason-ssh[/\\][^/\\]+[/\\]installer-home[/\\]\.config$/.test(n))return{state:p(t)?.isDirectory()?"kept":"absent"};return vn(t,l(n,"reason"),{linkAlways:!0,kept:(i)=>X(i,r??[]),native:e===void 0?An:()=>e},r!==void 0)}function ke(n,...e){return yt(n),G(n,...e)}var nn="config_rename_unavailable:busy";function vn(n,e,r,t=!1){let i=t?void 0:W.get(n);if(i)return i;let s;try{s=_n(n,e,r)}catch(a){let c=`config_rename_unavailable:${b(a)??"failed"}`;try{return{state:p(n)?.isDirectory()?"kept":"absent",problem:c}}catch{return{state:"kept",problem:c}}}if(!(s.state==="absent"&&r.linkAlways)&&s.problem!==nn&&!(s.state==="kept"&&!s.problem))W.set(n,s);return s}function _n(n,e,r){wn(e,r.native);let t=!1;for(let i=0;i<8;i+=1){let s=p(n);if(s?.isSymbolicLink())return v(n)===R(e)?{state:t?"renamed":"linked"}:{state:"kept"};if(!s){if(D(e))f(()=>d(e),"ENOENT");if(!(t||r.linkAlways)||!x(e))return{state:"absent"};let o=C(e,"link");N(R(e),o);try{f(()=>S(o,n),"EISDIR","ENOTEMPTY","EEXIST","ENOTDIR")}finally{f(()=>d(o),"ENOENT")}continue}if(!s.isDirectory())return{state:"absent"};if(r.kept(n))return K(e),{state:"kept"};let a=r.native();if(!a)return K(e),{state:"kept",problem:"config_rename_unavailable:no_native"};let c=In(a,n);if(!c)return{state:"kept",problem:nn};try{if(w(n).isSymbolicLink())continue;let o=Rn(a,n,e);if(o)return{state:"kept",problem:o};t=!0}finally{c()}}throw Object.assign(Error("legacy directory rename did not settle"),{code:"unsettled"})}function Rn(n,e,r){let t=p(r);if(!t||D(r)){if(!t)N(R(r),r);try{n.exchange(e,r)}catch(o){if(D(r))f(()=>d(r),"ENOENT");return`config_rename_unavailable:${b(o)??"exchange_failed"}`}return null}if(!t.isDirectory())return"config_rename_unavailable:ENOTDIR";if(t.dev!==w(e).dev)return"config_rename_unavailable:EXDEV";let i=[C(r,"probe"),C(r,"probe")];try{N("a",i[0]),N("b",i[1]),n.exchange(i[0],i[1])}catch(o){return`config_rename_unavailable:${b(o)??"exchange_failed"}`}finally{for(let o of i)f(()=>d(o),"ENOENT")}let s=cn(r);for(let o of Cn){let u=p(l(r,o)),g=p(l(e,o));if(u&&g&&u.ino!==g.ino)z(`${s}-replaced`,{mode:448,recursive:!0}),S(l(r,o),l(`${s}-replaced`,o))}let a={linked:new Map,unitsKept:new Set};rn(e,r,"",a);let c=C(r,"rename");N(R(r),c);try{n.exchange(e,c)}catch(o){return f(()=>d(c),"ENOENT"),`config_rename_unavailable:${b(o)??"exchange_failed"}`}return tn(c,r,a,s),null}function en(n){return n===""||!n.includes(kn)}function rn(n,e,r,t){let i=en(r)&&sn(l(e,r),l(n,r));if(i)t.unitsKept.add(r);for(let s of L(l(n,r))){if(i&&(P.has(s)||Z.has(s)))continue;let a=l(r,s),c=l(n,a),o=l(e,a),u=p(c);if(!u)continue;let g=p(o);if(u.isDirectory()){if(!g)f(()=>z(o,{mode:u.mode&4095}),"EEXIST"),q(o,u.mode&4095);if(x(o))rn(n,e,a,t)}else if(!g){if(u.isSymbolicLink())f(()=>N(v(c),o),"EEXIST");else if(f(()=>V(c,o),"EEXIST","ENOENT"))t.linked.set(a,u.ino)}}}function wn(n,e){let r;try{if(!x(n))return;r=L(n)}catch{return}for(let t of r){let i=/^\.(rename|link|probe|claim)-(\d+)-[0-9a-f]+$/.exec(t);if(!i)continue;let s=l(n,t),a=p(s);if(!a)continue;if(!a.isDirectory()){if(!Y(Number(i[2])))f(()=>d(s),"ENOENT");continue}let c=e(),o=null;if(c){try{o=c.lock(s)}catch{continue}if(!o)continue}else if(Y(Number(i[2])))continue;try{let u=C(n,"claim");if(f(()=>S(s,u),"ENOENT"))tn(u,n,null,cn(n))}finally{o?.()}}}function tn(n,e,r,t){for(let[i,s]of r?.linked??[])if(!p(l(n,i))&&p(l(e,i))?.ino===s)f(()=>d(l(e,i)),"ENOENT");if(on(n,e,"",r),f(()=>Q(n),"ENOTEMPTY","EEXIST"))return;S(n,t),q(t,448)}function on(n,e,r,t){let i=en(r)&&(t?t.unitsKept.has(r):sn(l(e,r),l(n,r)));for(let s of L(l(n,r))){let a=l(r,s),c=l(n,a),o=l(e,a),u=w(c),g=p(o);if(g&&u.ino===g.ino&&u.dev===g.dev){d(c);continue}if(u.isFile()&&g?.isFile()&&t?.linked.get(a)===g.ino){S(c,o);continue}if(i&&(P.has(s)||Z.has(s)))continue;if(!g){if(u.isFile()){if(f(()=>V(c,o),"EEXIST"))d(c)}else f(()=>S(c,o),"EEXIST","ENOTEMPTY");continue}if(u.isDirectory()&&g.isDirectory())on(n,e,a,t),f(()=>Q(c),"ENOTEMPTY","EEXIST")}}function sn(n,e){for(let r of P)if(an(l(n,r),l(e,r)))return!0;return!1}function an(n,e){let r=p(n);if(!r)return!1;let t=p(e);if(!t)return!0;if(r.isDirectory()){if(!t.isDirectory())return!0;return L(n).some((i)=>an(l(n,i),l(e,i)))}if(r.isSymbolicLink())return!t.isSymbolicLink()||v(n)!==v(e);return r.ino!==t.ino||r.dev!==t.dev}function K(n){if(D(n))f(()=>d(n),"ENOENT")}function cn(n){return l(n,`.pre-rename-${new Date().toISOString().replace(/[:.]/g,"-")}-${J(3).toString("hex")}`)}function D(n){try{return w(n).isSymbolicLink()&&v(n)===R(n)}catch{return!1}}function x(n){let e=p(n);return e!==null&&e.isDirectory()}function In(n,e){for(let r=0;r<40;r+=1){let t=n.lock(e);if(t)return t;Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,50)}return null}function C(n,e){return l(n,`.${e}-${process.pid}-${J(6).toString("hex")}`)}function Y(n){if(n===process.pid)return!1;try{return process.kill(n,0),!0}catch(e){return b(e)==="EPERM"}}function p(n){try{return w(n)}catch(e){if(b(e)==="ENOENT"||b(e)==="ENOTDIR")return null;throw e}}function f(n,...e){try{return n(),!0}catch(r){if(e.includes(b(r)??""))return!1;throw r}}function b(n){return n instanceof Error&&"code"in n&&typeof n.code==="string"?n.code:void 0}var k,On=2,Dn=4,Ln=2,Tn=2,H=-100;function An(){if(k!==void 0)return k;if(k=null,process.platform!=="linux"&&process.platform!=="darwin")return null;let n;try{n=Nn(import.meta.url)("bun:ffi")}catch{return null}let e=process.platform==="darwin",r=e?"__error":"__errno_location",t=e?["/usr/lib/libSystem.B.dylib"]:["libc.so.6",`libc.musl-${process.arch==="arm64"?"aarch64":"x86_64"}.so.1`],{FFIType:i}=n;for(let s of t)try{let a=e?"renamex_np":"renameat2",o=n.dlopen(s,{flock:{args:[i.i32,i.i32],returns:i.i32},[r]:{args:[],returns:i.ptr},[a]:e?{args:[i.ptr,i.ptr,i.u32],returns:i.i32}:{args:[i.i32,i.ptr,i.i32,i.ptr,i.u32],returns:i.i32}}).symbols,u=o[r]();if(u===null)continue;let g=(E)=>{let h=n.read.i32(u),y=Object.entries(Sn.errno).find(([,I])=>I===h)?.[0]??`errno_${h}`;return Object.assign(Error(`${E} failed: ${y}`),{code:y})},F=(E)=>Buffer.from(`${E}\x00`,"utf8");return k={exchange(E,h){let y=F(E),I=F(h);if((e?o[a](n.ptr(y),n.ptr(I),Ln):o[a](H,n.ptr(y),H,n.ptr(I),Tn))!==0)throw g("exchange")},lock(E){let h=En(E,bn.O_RDONLY);if(o.flock(h,On|Dn)===0)return()=>B(h);let y=g("lock");if(B(h),y.code==="EWOULDBLOCK"||y.code==="EAGAIN")return null;throw y}},k}catch{}return null}
3
- export{_t,_,rr,Xr,Mo,$o,Bo,ti,Yr,yt,ke};
2
+ import{R}from"./vm-hands-entry-lite-a3p6xz53.js";import{basename as ln}from"path";var _t=["production","staging"],un="https://api.reasonmachines.com",fn="https://staging-api.reasonmachines.com";var A={production:{api:"https://api.reasonmachines.ai",app:"https://reasonmachines.ai"},staging:{api:"https://staging-api.reasonmachines.ai",app:"https://staging.reasonmachines.ai"}},gn=new Set(["ara-staging","ara-staging.exe","reason-staging","reason-staging.exe"]);function _(n={}){let e=R(n.env??process.env,"REASON_CLI_CHANNEL")?.trim().toLowerCase();if(e){if(_t.includes(e))return e;throw Error(`Unknown Reason CLI channel: ${e}`)}let r=ln(n.executablePath??process.execPath).toLowerCase();return gn.has(r)?"staging":"production"}function rr(n){return n==="staging"?fn:un}var U={production:["https://api.ara.so",A.production.api],staging:["https://api-staging.ara.so",A.staging.api]};function Xr(n){let e;try{e=new URL(n).origin}catch{return n}let r=_t.find((t)=>U[t].includes(e));return r?rr(r):e}function Fo(n,e){return n===e||Xr(n)===Xr(e)}function jo(n,e){return _t.some((r)=>U[r].includes(n)&&e===rr(r))}function Uo(n,e){try{let r=new URL(e);return!r.username&&!r.password&&(r.origin===rr(n)||r.origin===A[n].api)}catch{return!1}}function ri(n){try{let e=new URL(n).hostname.replace(/^\[|\]$/g,"").toLowerCase();return e==="localhost"||e==="127.0.0.1"||e==="::1"}catch{return!1}}import{randomBytes as J}from"crypto";import{chmodSync as q,closeSync as B,constants as bn,linkSync as V,lstatSync as I,mkdirSync as z,openSync as En,readdirSync as T,readFileSync as Wn,readlinkSync as v,renameSync as S,rmdirSync as Q,symlinkSync as N,unlinkSync as d}from"fs";import{createRequire as Nn}from"module";import{constants as Sn}from"os";import{basename as w,join as l,sep as kn}from"path";import{existsSync as D,lstatSync as j,readdirSync as pn,readFileSync as mn,readlinkSync as dn,realpathSync as yn}from"fs";import{join as m,sep as hn}from"path";function G(n,...e){let r=m(n,"ara"),t=m(n,"reason");if(!Yr(r))return m(t,...e);if(!D(t))return m(r,...e);return D(m(r,...e))&&!D(m(t,...e))?m(r,...e):m(t,...e)}function Yr(n){try{let e=j(n);if(!e.isSymbolicLink())return e.isDirectory();return dn(n)!=="reason"&&D(n)}catch{return!1}}function X(n,e=[]){if(!Yr(n))return!1;let r;try{r=[n,...pn(n,{withFileTypes:!0}).filter((t)=>t.isDirectory()).map((t)=>m(n,t.name))]}catch{return!1}return r.some((t)=>["connect","connect-once"].filter((i)=>!e.includes(m(t,i))).some((i)=>{let s=m(t,i,"worker.json");try{j(s)}catch{return!1}try{let a=JSON.parse(mn(s,"utf8"))?.stateDirectory;if(typeof a!=="string")return!0;let c=(o,u)=>o===u||o.startsWith(u+hn);return c(a,n)||c(M(a),M(n))}catch{return!0}}))}function M(n){try{return yn(n)}catch{return n}}var P=new Set(["credentials.json","local-device.json","local-device.revoked.json","local-device.auth-migration.json","local-device.json.registration-pending.json","local-daemon.json","local-daemon.json.workspaces.json","local-root-fingerprint-key.json","instances","workspaces"]),Z=new Set(["local-device.proxy.json"]),Cn=new Set(["local-device.key","local-device.binding"]),W=new Map;function yt(n,e,r){let t=l(n,"ara");if(process.platform==="win32"||/[/\\]\.reason-ssh[/\\][^/\\]+[/\\]installer-home[/\\]\.config$/.test(n))return{state:p(t)?.isDirectory()?"kept":"absent"};return vn(t,l(n,"reason"),{linkAlways:!0,kept:(i)=>X(i,r??[]),native:e===void 0?An:()=>e},r!==void 0)}function ke(n,...e){return yt(n),G(n,...e)}var nn="config_rename_unavailable:busy";function vn(n,e,r,t=!1){let i=t?void 0:W.get(n);if(i)return i;let s;try{s=_n(n,e,r)}catch(a){let c=`config_rename_unavailable:${b(a)??"failed"}`;try{return{state:p(n)?.isDirectory()?"kept":"absent",problem:c}}catch{return{state:"kept",problem:c}}}if(!(s.state==="absent"&&r.linkAlways)&&s.problem!==nn&&!(s.state==="kept"&&!s.problem))W.set(n,s);return s}function _n(n,e,r){wn(e,r.native);let t=!1;for(let i=0;i<8;i+=1){let s=p(n);if(s?.isSymbolicLink())return v(n)===w(e)?{state:t?"renamed":"linked"}:{state:"kept"};if(!s){if(L(e))f(()=>d(e),"ENOENT");if(!(t||r.linkAlways)||!x(e))return{state:"absent"};let o=C(e,"link");N(w(e),o);try{f(()=>S(o,n),"EISDIR","ENOTEMPTY","EEXIST","ENOTDIR")}finally{f(()=>d(o),"ENOENT")}continue}if(!s.isDirectory())return{state:"absent"};if(r.kept(n))return K(e),{state:"kept"};let a=r.native();if(!a)return K(e),{state:"kept",problem:"config_rename_unavailable:no_native"};let c=In(a,n);if(!c)return{state:"kept",problem:nn};try{if(I(n).isSymbolicLink())continue;let o=Rn(a,n,e);if(o)return{state:"kept",problem:o};t=!0}finally{c()}}throw Object.assign(Error("legacy directory rename did not settle"),{code:"unsettled"})}function Rn(n,e,r){let t=p(r);if(!t||L(r)){if(!t)N(w(r),r);try{n.exchange(e,r)}catch(o){if(L(r))f(()=>d(r),"ENOENT");return`config_rename_unavailable:${b(o)??"exchange_failed"}`}return null}if(!t.isDirectory())return"config_rename_unavailable:ENOTDIR";if(t.dev!==I(e).dev)return"config_rename_unavailable:EXDEV";let i=[C(r,"probe"),C(r,"probe")];try{N("a",i[0]),N("b",i[1]),n.exchange(i[0],i[1])}catch(o){return`config_rename_unavailable:${b(o)??"exchange_failed"}`}finally{for(let o of i)f(()=>d(o),"ENOENT")}let s=cn(r);for(let o of Cn){let u=p(l(r,o)),g=p(l(e,o));if(u&&g&&u.ino!==g.ino)z(`${s}-replaced`,{mode:448,recursive:!0}),S(l(r,o),l(`${s}-replaced`,o))}let a={linked:new Map,unitsKept:new Set};rn(e,r,"",a);let c=C(r,"rename");N(w(r),c);try{n.exchange(e,c)}catch(o){return f(()=>d(c),"ENOENT"),`config_rename_unavailable:${b(o)??"exchange_failed"}`}return tn(c,r,a,s),null}function en(n){return n===""||!n.includes(kn)}function rn(n,e,r,t){let i=en(r)&&sn(l(e,r),l(n,r));if(i)t.unitsKept.add(r);for(let s of T(l(n,r))){if(i&&(P.has(s)||Z.has(s)))continue;let a=l(r,s),c=l(n,a),o=l(e,a),u=p(c);if(!u)continue;let g=p(o);if(u.isDirectory()){if(!g)f(()=>z(o,{mode:u.mode&4095}),"EEXIST"),q(o,u.mode&4095);if(x(o))rn(n,e,a,t)}else if(!g){if(u.isSymbolicLink())f(()=>N(v(c),o),"EEXIST");else if(f(()=>V(c,o),"EEXIST","ENOENT"))t.linked.set(a,u.ino)}}}function wn(n,e){let r;try{if(!x(n))return;r=T(n)}catch{return}for(let t of r){let i=/^\.(rename|link|probe|claim)-(\d+)-[0-9a-f]+$/.exec(t);if(!i)continue;let s=l(n,t),a=p(s);if(!a)continue;if(!a.isDirectory()){if(!Y(Number(i[2])))f(()=>d(s),"ENOENT");continue}let c=e(),o=null;if(c){try{o=c.lock(s)}catch{continue}if(!o)continue}else if(Y(Number(i[2])))continue;try{let u=C(n,"claim");if(f(()=>S(s,u),"ENOENT"))tn(u,n,null,cn(n))}finally{o?.()}}}function tn(n,e,r,t){for(let[i,s]of r?.linked??[])if(!p(l(n,i))&&p(l(e,i))?.ino===s)f(()=>d(l(e,i)),"ENOENT");if(on(n,e,"",r),f(()=>Q(n),"ENOTEMPTY","EEXIST"))return;S(n,t),q(t,448)}function on(n,e,r,t){let i=en(r)&&(t?t.unitsKept.has(r):sn(l(e,r),l(n,r)));for(let s of T(l(n,r))){let a=l(r,s),c=l(n,a),o=l(e,a),u=I(c),g=p(o);if(g&&u.ino===g.ino&&u.dev===g.dev){d(c);continue}if(u.isFile()&&g?.isFile()&&t?.linked.get(a)===g.ino){S(c,o);continue}if(i&&(P.has(s)||Z.has(s)))continue;if(!g){if(u.isFile()){if(f(()=>V(c,o),"EEXIST"))d(c)}else f(()=>S(c,o),"EEXIST","ENOTEMPTY");continue}if(u.isDirectory()&&g.isDirectory())on(n,e,a,t),f(()=>Q(c),"ENOTEMPTY","EEXIST")}}function sn(n,e){for(let r of P)if(an(l(n,r),l(e,r)))return!0;return!1}function an(n,e){let r=p(n);if(!r)return!1;let t=p(e);if(!t)return!0;if(r.isDirectory()){if(!t.isDirectory())return!0;return T(n).some((i)=>an(l(n,i),l(e,i)))}if(r.isSymbolicLink())return!t.isSymbolicLink()||v(n)!==v(e);return r.ino!==t.ino||r.dev!==t.dev}function K(n){if(L(n))f(()=>d(n),"ENOENT")}function cn(n){return l(n,`.pre-rename-${new Date().toISOString().replace(/[:.]/g,"-")}-${J(3).toString("hex")}`)}function L(n){try{return I(n).isSymbolicLink()&&v(n)===w(n)}catch{return!1}}function x(n){let e=p(n);return e!==null&&e.isDirectory()}function In(n,e){for(let r=0;r<40;r+=1){let t=n.lock(e);if(t)return t;Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,50)}return null}function C(n,e){return l(n,`.${e}-${process.pid}-${J(6).toString("hex")}`)}function Y(n){if(n===process.pid)return!1;try{return process.kill(n,0),!0}catch(e){return b(e)==="EPERM"}}function p(n){try{return I(n)}catch(e){if(b(e)==="ENOENT"||b(e)==="ENOTDIR")return null;throw e}}function f(n,...e){try{return n(),!0}catch(r){if(e.includes(b(r)??""))return!1;throw r}}function b(n){return n instanceof Error&&"code"in n&&typeof n.code==="string"?n.code:void 0}var k,On=2,Dn=4,Ln=2,Tn=2,H=-100;function An(){if(k!==void 0)return k;if(k=null,process.platform!=="linux"&&process.platform!=="darwin")return null;let n;try{n=Nn(import.meta.url)("bun:ffi")}catch{return null}let e=process.platform==="darwin",r=e?"__error":"__errno_location",t=e?["/usr/lib/libSystem.B.dylib"]:["libc.so.6",`libc.musl-${process.arch==="arm64"?"aarch64":"x86_64"}.so.1`],{FFIType:i}=n;for(let s of t)try{let a=e?"renamex_np":"renameat2",o=n.dlopen(s,{flock:{args:[i.i32,i.i32],returns:i.i32},[r]:{args:[],returns:i.ptr},[a]:e?{args:[i.ptr,i.ptr,i.u32],returns:i.i32}:{args:[i.i32,i.ptr,i.i32,i.ptr,i.u32],returns:i.i32}}).symbols,u=o[r]();if(u===null)continue;let g=(E)=>{let h=n.read.i32(u),y=Object.entries(Sn.errno).find(([,O])=>O===h)?.[0]??`errno_${h}`;return Object.assign(Error(`${E} failed: ${y}`),{code:y})},F=(E)=>Buffer.from(`${E}\x00`,"utf8");return k={exchange(E,h){let y=F(E),O=F(h);if((e?o[a](n.ptr(y),n.ptr(O),Ln):o[a](H,n.ptr(y),H,n.ptr(O),Tn))!==0)throw g("exchange")},lock(E){let h=En(E,bn.O_RDONLY);if(o.flock(h,On|Dn)===0)return()=>B(h);let y=g("lock");if(B(h),y.code==="EWOULDBLOCK"||y.code==="EAGAIN")return null;throw y}},k}catch{}return null}
3
+ export{_t,_,rr,Xr,Fo,jo,Uo,ri,Yr,yt,ke};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Qr,en,tn,or}from"./vm-hands-entry-lite-39qv4sqt.js";import{Po,To,P,Br,Fr,Hn,ft,zn,jr,Je,Se,qn,Ze,ne,Xe,Ee,Yt,Ur,Hr,Vn}from"./vm-hands-entry-lite-fgppp6x9.js";import{lr}from"./vm-hands-entry-lite-s85p7tqp.js";import{Zt}from"./vm-hands-entry-lite-td73npv3.js";import{ve}from"./vm-hands-entry-lite-70hq7mrs.js";var r=["cgroup_membership_read_failed","cgroup_v2_membership_absent","cgroup_scope_invalid","cgroup_root_unavailable","cgroup_directory_unavailable","cgroup_limit_read_failed","cgroup_events_read_failed","cgroup_current_read_failed","cgroup_stat_read_failed","boot_id_read_failed","boot_id_invalid","guest_meminfo_read_failed","guest_vmstat_read_failed","memory_counter_invalid","memory_field_missing","memory_capacity_invalid"];var o=String.raw`(function(fs, path) {
2
+ import{Qr,en,tn,or}from"./vm-hands-entry-lite-39qv4sqt.js";import{Oo,Io,P,Br,Fr,zn,ft,qn,jr,Je,Se,Wn,Ze,ne,Xe,Ee,Yt,Ur,Hr,Gn}from"./vm-hands-entry-lite-c0t5xpzh.js";import{lr}from"./vm-hands-entry-lite-s85p7tqp.js";import{Zt}from"./vm-hands-entry-lite-td73npv3.js";import{ve}from"./vm-hands-entry-lite-70hq7mrs.js";var r=["cgroup_membership_read_failed","cgroup_v2_membership_absent","cgroup_scope_invalid","cgroup_root_unavailable","cgroup_directory_unavailable","cgroup_limit_read_failed","cgroup_events_read_failed","cgroup_current_read_failed","cgroup_stat_read_failed","boot_id_read_failed","boot_id_invalid","guest_meminfo_read_failed","guest_vmstat_read_failed","memory_counter_invalid","memory_field_missing","memory_capacity_invalid"];var o=String.raw`(function(fs, path) {
3
3
  const fail = (message, reasonCode) => { throw Object.assign(Error(message), {reasonCode}); };
4
4
  const read = (p, reasonCode, trim=true) => { try { const text=fs.readFileSync(p, "utf8"); return trim?text.trim():text; }
5
5
  catch { fail("memory_read", reasonCode); } };
@@ -309,7 +309,7 @@ function fileOperation(request) {
309
309
  });
310
310
  return { promise, cancel() {} };
311
311
  }
312
- `;var s="a3e39eb55160acfc116fa9871ccc594c68be7a642d2331b24baa707c8f601ec0";import{createHash as I}from"crypto";var H=Object.freeze({"api.ara.so":"api.reasonmachines.com","api.reasonmachines.ai":"api.reasonmachines.com","api-staging.ara.so":"staging-api.reasonmachines.com","staging-api.reasonmachines.ai":"staging-api.reasonmachines.com"});var a=Object.freeze({trailingSlashPattern:/\/+$/.source,keyPrefix:"http.",keySuffix:"/.extraheader",valuePrefix:"Authorization: Bearer "});var l=Object.freeze({tokenEnv:"ARA_GIT_BROKER_TOKEN",reasonTokenEnv:"REASON_GIT_BROKER_TOKEN",urlEnv:"ARA_GIT_BROKER_URL",keyPrefix:"credential.",keySuffix:"/.helper",value:'!f(){ printf "username=%s\\npassword=%s\\n" "ara-run" "${REASON_GIT_BROKER_TOKEN:-$ARA_GIT_BROKER_TOKEN}"; };f'});var Lt=/^[A-Za-z_][A-Za-z0-9_]*$/;var h=new Set(["ARA_INFERENCE_TOKEN","AI_GATEWAY_API_KEY","CLOUD_AGENT_AI_GATEWAY_API_KEY","INFERENCE_V2_GATEWAY_API_KEY","VERCEL_AI_GATEWAY_API_KEY","INFERENCE_V2_CONCENTRATE_API_KEY","INFERENCE_V2_OPENAI_API_KEY","INFERENCE_V2_ANTHROPIC_API_KEY","INFERENCE_V2_FINGERPRINT_SECRET","OPENAI_API_KEY","OPENROUTER_API_KEY","ANTHROPIC_API_KEY","CODEX_ACCESS_TOKEN","GITHUB_COPILOT_API_KEY","AZURE_OPENAI_API_KEY","AZURE_OPENAI_CLIENT_SECRET"]),m=new Set(["ARA_OPERATOR_KEY","BL_API_KEY","BLAXEL_API_KEY","NSC_TOKEN","NSC_TOKEN_FILE","NAMESPACE_API_KEY","NAMESPACE_ACCESS_TOKEN","NAMESPACE_TOKEN","NAMESPACE_TOKEN_JSON","NAMESPACE_SANDBOX_TOKEN_JSON","ARA_LOCAL_QA_NAMESPACE_WORKLOAD_TOKEN_FILE","NAMESPACE_SANDBOX_USE_LOCAL_USER_TOKEN","COMPUTE_SERVICE_TOKEN"]),g=["INFISICAL_","NSC_"],_=new Set(["ARA_JOB_ENV","ARA_DELIVERY_BASE_SHA","WORK_ROOT","REPO_DIR","ARA_CONTROL_DIR","ARA_PRESERVE_WORKSPACE","ARA_PINNED_CHECKOUT_REUSE","FOLLOWUP_BRANCH","REPO_URL","TOKENLESS_URL","REPOSITORY_IDENTITY_URL","DEFAULT_BRANCH","BRANCH","BRANCH_GENERATED","BASE_REF","REPO_EMPTY","REPO_WRITABLE","ARA_DELIVERY_BASE_BRANCH","ARA_SERVER_GIT_PUBLICATION","ARA_EMPTY_REPOSITORY_COMMIT","REASON_MODEL","REASON_DELIVERY_BASE_BRANCH","REASON_DELIVERY_BASE_SHA","REASON_EMPTY_REPOSITORY_COMMIT","REASON_SCRATCH_SESSION_ID","REASON_SERVER_GIT_PUBLICATION","REASON_ALLOW_INSTALL_SCRIPTS","SCM_TOKEN","SCM_TOKEN_USER","REASON_OIDC_TOKEN_URL","REASON_OIDC_REQUEST_TOKEN","AWS_CONTAINER_CREDENTIALS_FULL_URI","AWS_CONTAINER_AUTHORIZATION_TOKEN","AWS_CONTAINER_CREDENTIALS_RELATIVE_URI","AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE","BASH_ENV","ENV","BASHOPTS","SHELLOPTS","PS4","IFS","CDPATH","GLOBIGNORE","PROMPT_COMMAND","PATH","HOME","TMPDIR","TMP","TEMP","XDG_CONFIG_HOME","GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_COMMON_DIR","GIT_NAMESPACE","GIT_CEILING_DIRECTORIES","GIT_DISCOVERY_ACROSS_FILESYSTEM","GIT_SHALLOW_FILE","GIT_ALLOW_PROTOCOL","GIT_PROTOCOL_FROM_USER","GIT_REPLACE_REF_BASE","NODE_OPTIONS","NODE_PATH","NODE_REPL_EXTERNAL_MODULES","CLASSPATH","PYTHONPATH","PYTHONSTARTUP","PYTHONHOME","RUBYOPT","RUBYLIB","PERL5LIB","PERL5OPT","JAVA_TOOL_OPTIONS","_JAVA_OPTIONS","JDK_JAVA_OPTIONS","GEM_PATH","GEM_HOME","GIT_SSH","GIT_SSH_COMMAND","GIT_EXEC_PATH","GIT_TEMPLATE_DIR","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_PROXY_COMMAND","GIT_EXTERNAL_DIFF","GIT_PAGER","GIT_EDITOR","GIT_ASKPASS","SSH_ASKPASS","PAGER","EDITOR","TAR_OPTIONS","CURL_HOME","WGETRC","APT_CONFIG","PERLLIB","GIT_GRAFT_FILE","POSIXLY_CORRECT"]),y=["GIT_TRACE","CONTEXT_REPO_","ARA_CHECKPOINT_BOOTSTRAP_","_","ARA_HANDS_","ARA_DEVICE_","ARA_GIT_BROKER_","REASON_HANDS_","REASON_DEVICE_","REASON_GIT_BROKER_","LD_","DYLD_","GIT_CONFIG","BASH_FUNC_"];var t="^(?!(?:"+[...h,...m,..._].join("|")+")$)(?!(?:"+[...g,...y].join("|")+"))"+Lt.source.slice(1),W=new RegExp(t);var v=["HOME","PWD","OLDPWD","TMPDIR","TMP","TEMP","SHELL","USER","LOGNAME","SCM_TOKEN","SCM_TOKEN_USER","GH_TOKEN","GITHUB_TOKEN","GH_ENTERPRISE_TOKEN","GITHUB_ENTERPRISE_TOKEN","GITLAB_TOKEN"],E=["ARA_HANDS_","ARA_DEVICE_","ARA_GIT_BROKER_","REASON_HANDS_","REASON_DEVICE_","REASON_GIT_BROKER_","BUN_"],S="^(?!(?:"+v.join("|")+")$)(?!(?:"+E.join("|")+"))"+t.slice(1),w="ARA_DELIVERY_BASE_SHA|WORK_ROOT|FOLLOWUP_BRANCH|ARA_PRESERVE_WORKSPACE|ARA_PINNED_CHECKOUT_REUSE|CONTEXT_REPO_[A-Z0-9_]+|REPO_URL|TOKENLESS_URL|REPOSITORY_IDENTITY_URL|DEFAULT_BRANCH|BRANCH|BRANCH_GENERATED|BASE_REF|REPO_EMPTY|REPO_WRITABLE|ARA_DELIVERY_BASE_BRANCH|ARA_SERVER_GIT_PUBLICATION|ARA_EMPTY_REPOSITORY_COMMIT|REASON_MODEL|REASON_DELIVERY_BASE_BRANCH|REASON_DELIVERY_BASE_SHA|REASON_EMPTY_REPOSITORY_COMMIT|REASON_SCRATCH_SESSION_ID|REASON_SERVER_GIT_PUBLICATION|REASON_ALLOW_INSTALL_SCRIPTS",n="^(?:"+w+"|"+S.slice(1,-1)+")$",O=new RegExp(n);function Pr(u){return O.test(u)}var lt=Object.freeze({tokenPath:"/identity/token",awsPath:"/identity/aws",tokenPattern:/^[A-Za-z0-9_.~-]+$/.source}),V=Object.freeze({variables:256,valueBytes:130816,snapshotBytes:1048576}),Z=Object.freeze({valueChars:16384,snapshotBytes:65536});var c=["set -g history-limit 50000","set -g status off","set -g window-size smallest","set -gq fill-character ' '","set -g escape-time 10","set -g prefix None","set -g prefix2 None","set -g terminal-overrides ',*:smcup@:rmcup@'"];var D=2,R="ara-hands-worker.cjs",d=["/usr/local/go/bin","/opt/node/bin","/usr/local/bin","/usr/sbin","/usr/bin","/sbin","/bin","/usr/local/cargo/bin"],A=d.join(":"),T=["/opt/homebrew/bin",...d].join(":"),k='(platform, linuxPath, macosPath) => platform === "darwin" ? macosPath : linuxPath';var N=String.raw`(function(anchor, pid, native) {
312
+ `;var s="a3e39eb55160acfc116fa9871ccc594c68be7a642d2331b24baa707c8f601ec0";import{createHash as R}from"crypto";var H=Object.freeze({"api.ara.so":"api.reasonmachines.com","api.reasonmachines.ai":"api.reasonmachines.com","api-staging.ara.so":"staging-api.reasonmachines.com","staging-api.reasonmachines.ai":"staging-api.reasonmachines.com"});var a=Object.freeze({trailingSlashPattern:/\/+$/.source,keyPrefix:"http.",keySuffix:"/.extraheader",valuePrefix:"Authorization: Bearer "});var l=Object.freeze({tokenEnv:"ARA_GIT_BROKER_TOKEN",reasonTokenEnv:"REASON_GIT_BROKER_TOKEN",urlEnv:"ARA_GIT_BROKER_URL",keyPrefix:"credential.",keySuffix:"/.helper",value:'!f(){ printf "username=%s\\npassword=%s\\n" "ara-run" "${REASON_GIT_BROKER_TOKEN:-$ARA_GIT_BROKER_TOKEN}"; };f'});var Lt=/^[A-Za-z_][A-Za-z0-9_]*$/;var h=new Set(["ARA_INFERENCE_TOKEN","AI_GATEWAY_API_KEY","CLOUD_AGENT_AI_GATEWAY_API_KEY","INFERENCE_V2_GATEWAY_API_KEY","VERCEL_AI_GATEWAY_API_KEY","INFERENCE_V2_CONCENTRATE_API_KEY","INFERENCE_V2_OPENAI_API_KEY","INFERENCE_V2_ANTHROPIC_API_KEY","INFERENCE_V2_FINGERPRINT_SECRET","OPENAI_API_KEY","OPENROUTER_API_KEY","ANTHROPIC_API_KEY","CODEX_ACCESS_TOKEN","GITHUB_COPILOT_API_KEY","AZURE_OPENAI_API_KEY","AZURE_OPENAI_CLIENT_SECRET"]),m=new Set(["ARA_OPERATOR_KEY","BL_API_KEY","BLAXEL_API_KEY","NSC_TOKEN","NSC_TOKEN_FILE","NAMESPACE_API_KEY","NAMESPACE_ACCESS_TOKEN","NAMESPACE_TOKEN","NAMESPACE_TOKEN_JSON","NAMESPACE_SANDBOX_TOKEN_JSON","ARA_LOCAL_QA_NAMESPACE_WORKLOAD_TOKEN_FILE","NAMESPACE_SANDBOX_USE_LOCAL_USER_TOKEN","COMPUTE_SERVICE_TOKEN"]),g=["INFISICAL_","NSC_"],_=new Set(["ARA_JOB_ENV","ARA_DELIVERY_BASE_SHA","WORK_ROOT","REPO_DIR","ARA_CONTROL_DIR","ARA_PRESERVE_WORKSPACE","ARA_PINNED_CHECKOUT_REUSE","FOLLOWUP_BRANCH","REPO_URL","TOKENLESS_URL","REPOSITORY_IDENTITY_URL","DEFAULT_BRANCH","BRANCH","BRANCH_GENERATED","BASE_REF","REPO_EMPTY","REPO_WRITABLE","ARA_DELIVERY_BASE_BRANCH","ARA_SERVER_GIT_PUBLICATION","ARA_EMPTY_REPOSITORY_COMMIT","REASON_MODEL","REASON_DELIVERY_BASE_BRANCH","REASON_DELIVERY_BASE_SHA","REASON_EMPTY_REPOSITORY_COMMIT","REASON_SCRATCH_SESSION_ID","REASON_SERVER_GIT_PUBLICATION","REASON_ALLOW_INSTALL_SCRIPTS","SCM_TOKEN","SCM_TOKEN_USER","REASON_OIDC_TOKEN_URL","REASON_OIDC_REQUEST_TOKEN","AWS_CONTAINER_CREDENTIALS_FULL_URI","AWS_CONTAINER_AUTHORIZATION_TOKEN","AWS_CONTAINER_CREDENTIALS_RELATIVE_URI","AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE","BASH_ENV","ENV","BASHOPTS","SHELLOPTS","PS4","IFS","CDPATH","GLOBIGNORE","PROMPT_COMMAND","PATH","HOME","TMPDIR","TMP","TEMP","XDG_CONFIG_HOME","GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_COMMON_DIR","GIT_NAMESPACE","GIT_CEILING_DIRECTORIES","GIT_DISCOVERY_ACROSS_FILESYSTEM","GIT_SHALLOW_FILE","GIT_ALLOW_PROTOCOL","GIT_PROTOCOL_FROM_USER","GIT_REPLACE_REF_BASE","NODE_OPTIONS","NODE_PATH","NODE_REPL_EXTERNAL_MODULES","CLASSPATH","PYTHONPATH","PYTHONSTARTUP","PYTHONHOME","RUBYOPT","RUBYLIB","PERL5LIB","PERL5OPT","JAVA_TOOL_OPTIONS","_JAVA_OPTIONS","JDK_JAVA_OPTIONS","GEM_PATH","GEM_HOME","GIT_SSH","GIT_SSH_COMMAND","GIT_EXEC_PATH","GIT_TEMPLATE_DIR","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_PROXY_COMMAND","GIT_EXTERNAL_DIFF","GIT_PAGER","GIT_EDITOR","GIT_ASKPASS","SSH_ASKPASS","PAGER","EDITOR","TAR_OPTIONS","CURL_HOME","WGETRC","APT_CONFIG","PERLLIB","GIT_GRAFT_FILE","POSIXLY_CORRECT"]),y=["GIT_TRACE","CONTEXT_REPO_","ARA_CHECKPOINT_BOOTSTRAP_","_","ARA_HANDS_","ARA_DEVICE_","ARA_GIT_BROKER_","REASON_HANDS_","REASON_DEVICE_","REASON_GIT_BROKER_","LD_","DYLD_","GIT_CONFIG","BASH_FUNC_"];var t="^(?!(?:"+[...h,...m,..._].join("|")+")$)(?!(?:"+[...g,...y].join("|")+"))"+Lt.source.slice(1),W=new RegExp(t);var v=["HOME","PWD","OLDPWD","TMPDIR","TMP","TEMP","SHELL","USER","LOGNAME","SCM_TOKEN","SCM_TOKEN_USER","GH_TOKEN","GITHUB_TOKEN","GH_ENTERPRISE_TOKEN","GITHUB_ENTERPRISE_TOKEN","GITLAB_TOKEN"],E=["ARA_HANDS_","ARA_DEVICE_","ARA_GIT_BROKER_","REASON_HANDS_","REASON_DEVICE_","REASON_GIT_BROKER_","BUN_"],S="^(?!(?:"+v.join("|")+")$)(?!(?:"+E.join("|")+"))"+t.slice(1),w="ARA_DELIVERY_BASE_SHA|WORK_ROOT|FOLLOWUP_BRANCH|ARA_PRESERVE_WORKSPACE|ARA_PINNED_CHECKOUT_REUSE|CONTEXT_REPO_[A-Z0-9_]+|REPO_URL|TOKENLESS_URL|REPOSITORY_IDENTITY_URL|DEFAULT_BRANCH|BRANCH|BRANCH_GENERATED|BASE_REF|REPO_EMPTY|REPO_WRITABLE|ARA_DELIVERY_BASE_BRANCH|ARA_SERVER_GIT_PUBLICATION|ARA_EMPTY_REPOSITORY_COMMIT|REASON_MODEL|REASON_DELIVERY_BASE_BRANCH|REASON_DELIVERY_BASE_SHA|REASON_EMPTY_REPOSITORY_COMMIT|REASON_SCRATCH_SESSION_ID|REASON_SERVER_GIT_PUBLICATION|REASON_ALLOW_INSTALL_SCRIPTS",n="^(?:"+w+"|"+S.slice(1,-1)+")$",O=new RegExp(n);function Pr(u){return O.test(u)}var lt=Object.freeze({tokenPath:"/identity/token",awsPath:"/identity/aws",tokenPattern:/^[A-Za-z0-9_.~-]+$/.source}),V=Object.freeze({variables:256,valueBytes:130816,snapshotBytes:1048576}),Z=Object.freeze({valueChars:16384,snapshotBytes:65536});var c=["set -g history-limit 50000","set -g status off","set -g window-size smallest","set -gq fill-character ' '","set -g escape-time 10","set -g prefix None","set -g prefix2 None","set -g terminal-overrides ',*:smcup@:rmcup@'"];var D=2,T="ara-hands-worker.cjs",d=["/usr/local/go/bin","/opt/node/bin","/usr/local/bin","/usr/sbin","/usr/bin","/sbin","/bin","/usr/local/cargo/bin"],I=d.join(":"),A=["/opt/homebrew/bin",...d].join(":"),k='(platform, linuxPath, macosPath) => platform === "darwin" ? macosPath : linuxPath';var N=String.raw`(function(anchor, pid, native) {
313
313
  const token = native.identity(pid);
314
314
  const session = native.session(pid);
315
315
  if (!native.same(anchor)) throw new Error("pty_session_identity_lost");
@@ -348,7 +348,7 @@ function fileOperation(request) {
348
348
  require("node:fs").writeSync(3, "subreaper\n");
349
349
  api.execve(ptr(args[0]), ptr(argv), ptr(envp));
350
350
  throw new Error("pty_exec_failed");
351
- })`,os=String.raw`
351
+ })`,cs=String.raw`
352
352
  "use strict";
353
353
  const crypto = require("node:crypto");
354
354
  const fs = require("node:fs");
@@ -364,7 +364,7 @@ const DEVICE_ENVIRONMENT_LIMITS = ${JSON.stringify(V)};
364
364
 
365
365
  const VERSION = ${P};
366
366
  const WORKER_VERSION = ${D};
367
- const WORKER_ENTRYPOINT = ${JSON.stringify(R)};
367
+ const WORKER_ENTRYPOINT = ${JSON.stringify(T)};
368
368
  const GUEST_MEMORY_UNAVAILABLE_REASONS = ${JSON.stringify(r)};
369
369
  const sampleGuestMemory = ${o};
370
370
  const inspectMacPtyMember = ${N};
@@ -375,16 +375,16 @@ const CLOSE_CODES = ${JSON.stringify(Hr)};
375
375
  const SHA256_RE = /^[0-9a-f]{64}$/;
376
376
  const MAX_FRAME_BYTES = ${Br};
377
377
  const MAX_INPUT_CHARS = ${Fr};
378
- const MAX_STRUCTURED_INPUT_CHARS = ${Hn};
378
+ const MAX_STRUCTURED_INPUT_CHARS = ${zn};
379
379
  const MAX_OUTPUT_CHARS = ${ft};
380
- const WORKSPACE_BEFORE_MAX_OUTPUT_CHARS = ${Vn};
381
- const MAX_ERROR_CHARS = ${zn};
380
+ const WORKSPACE_BEFORE_MAX_OUTPUT_CHARS = ${Gn};
381
+ const MAX_ERROR_CHARS = ${qn};
382
382
  const MAX_LEDGER_IDS = 16384;
383
383
  const MAX_CACHED_RESULTS = 256;
384
384
  const MAX_JOB_INPUT_CHARS = ${jr};
385
385
  const MAX_JOB_OUTPUT_CHARS = ${Je};
386
386
  const MAX_JOB_OUTPUT_CHUNKS = ${Se};
387
- const MAX_JOBS = ${qn};
387
+ const MAX_JOBS = ${Wn};
388
388
  const MAX_JOB_RECORD_BYTES = 262144;
389
389
  const MAX_JOB_JOURNAL_BYTES = MAX_JOBS * MAX_JOB_RECORD_BYTES;
390
390
  const MAX_JOB_CONTROL_FRAME_BYTES = ${Ze};
@@ -492,8 +492,8 @@ function jobsUserPrefix(model) {
492
492
  return user ? ["/usr/bin/setpriv", "--reuid=" + user.uid, "--regid=" + gid, "--clear-groups", "--no-new-privs", "--",
493
493
  "/usr/bin/env", "HOME=" + user.home, "USER=" + user.username, "LOGNAME=" + user.username] : [];
494
494
  }
495
- const FIXED_CLOUD_CHILD_PATH = ${JSON.stringify(A)};
496
- const FIXED_MACOS_CLOUD_CHILD_PATH = ${JSON.stringify(T)};
495
+ const FIXED_CLOUD_CHILD_PATH = ${JSON.stringify(I)};
496
+ const FIXED_MACOS_CLOUD_CHILD_PATH = ${JSON.stringify(A)};
497
497
  const selectCloudChildPath = ${k};
498
498
  const config = JSON.parse(fs.readFileSync(process.argv[2], "utf8"));
499
499
  const FIXED_BASH = WINDOWS ? config.bashExecutable : "/bin/bash";
@@ -3362,10 +3362,10 @@ const PI_EXIT_STDIO_GRACE_MS = 100;
3362
3362
  // the token once under quoteDepth layers of single quoting, so the confined
3363
3363
  // script is byte-identical to what the Brain's confineBashPayload gives the
3364
3364
  // bash tool: srt/bwrap, the payload uid, the network allowlist and allowWrite.
3365
- const PI_TOOL_CONFINEMENT_TOKEN = "${Po}";
3365
+ const PI_TOOL_CONFINEMENT_TOKEN = "${Oo}";
3366
3366
  function validPiToolConfinement(value) {
3367
3367
  return hasOnlyKeys(value, ["template", "quoteDepth"]) && typeof value.template === "string"
3368
- && value.template.length <= ${To} && !value.template.includes("\0")
3368
+ && value.template.length <= ${Io} && !value.template.includes("\0")
3369
3369
  && value.template.split(PI_TOOL_CONFINEMENT_TOKEN).length === 2 && [1, 2, 3].includes(value.quoteDepth);
3370
3370
  }
3371
3371
  // The script T when this command is exactly this policy's confineBashPayload(T)
@@ -4176,5 +4176,5 @@ void startJobControl().then(() => {
4176
4176
  try { loadJobs(); prepareRequestJournal(); } catch { process.exit(44); }
4177
4177
  if (validPrivateJob) markReady(); else connect();
4178
4178
  }, () => process.exit(45));
4179
- `.trimStart();var b=I("sha256").update(os,"utf8").digest("hex"),Cn={42:"worker_config_invalid",43:"workspace_alias_failed",44:"job_journal_unavailable",45:"job_control_failed",46:"job_journal_owned"};
4180
- export{Lt,Pr,lt,V,D,R,os,b,Cn};
4179
+ `.trimStart();var b=R("sha256").update(cs,"utf8").digest("hex"),Cn={42:"worker_config_invalid",43:"workspace_alias_failed",44:"job_journal_unavailable",45:"job_control_failed",46:"job_journal_owned"};
4180
+ export{Lt,Pr,lt,V,D,T,cs,b,Cn};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- var i="libara_device_keychain.dylib",e="libreason_device_keychain.dylib";class mt extends Error{code;constructor(n,t){super(t);this.code=n;this.name="ManagedRuntimeError"}}import{existsSync as s}from"fs";import{join as a}from"path";function Oo(n){let t=a(n,e);return s(t)?t:a(n,i)}
3
- export{mt,Oo};
2
+ var i="libara_device_keychain.dylib",e="libreason_device_keychain.dylib";class mt extends Error{code;constructor(n,t){super(t);this.code=n;this.name="ManagedRuntimeError"}}import{existsSync as s}from"fs";import{join as a}from"path";function No(n){let t=a(n,e);return s(t)?t:a(n,i)}
3
+ export{mt,No};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{H}from"./vm-hands-entry-lite-39qv4sqt.js";import{D,R,b}from"./vm-hands-entry-lite-q80xmhrx.js";import{je,gr,_r,Sn,En,ct}from"./vm-hands-entry-lite-423rvptb.js";import{Mr}from"./vm-hands-entry-lite-gh0yjzye.js";import{p,ut,An,_e,we}from"./vm-hands-entry-lite-90y6pf98.js";import{v,h}from"./vm-hands-entry-lite-ymqb2927.js";import{a,nr,Uo}from"./vm-hands-entry-lite-0sh835na.js";import{an,y,t,k,o,d,ps,Oe,$i,u,i,W,g,ee,s,n,cn}from"./vm-hands-entry-lite-70x16hkx.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{se,A}from"./vm-hands-entry-lite-qz74j563.js";import{randomUUID as Q}from"crypto";import{spawn as Le}from"child_process";import{existsSync as Z,lstatSync as me,mkdirSync as We,readFileSync as Ne,realpathSync as G,rmSync as Ve,writeFileSync as He}from"fs";import{dirname as Ue,join as j,relative as qe,sep as Je}from"path";var Se=["process.run.v1","process.full.v1"],xe=600000,Pe=1800000,Ee=20000,ne="process.cancel.v1",ie=i({action:n("start"),request_id:t().uuid(),command:t().min(1).max(16000).refine((e)=>!e.includes("\x00")),cwd:t().min(1).max(4096).refine((e)=>!e.includes("\x00")&&!e.startsWith("/")&&!e.split(/[\\/]/).includes("..")).describe("Path relative to the granted device root; omit to use that root. Must not start with /, contain a .. path segment, or contain a NUL character.").optional(),mode:s(["host","confined"]).default("host"),timeout_ms:o().int().min(1000).max(Pe).default(xe).describe("Absolute process budget including queue and startup time. Defaults to ten minutes; longer explicit requests require the selected root's advertised max_timeout_ms. Retrying never renews the deadline.")}).strict(),K={device_id:t().uuid(),root_id:t().uuid()},Re=g("action",[ie.extend(K),i({...K,action:n("inspect"),process_id:t().uuid(),after:o().int().min(0).default(0),wait_ms:o().int().min(0).max(Ee).default(0).describe("Wait for new output or a state change, bounded by this call's wait budget. Expiring this wait does not cancel the process or extend its deadline.")}).strict(),i({...K,action:n("cancel"),process_id:t().uuid()}).strict()]),Fe=an(Re,{io:"input"}),Ke=ie.extend({process_brain_fence:t().uuid(),process_expires_at:y.datetime()}).strict(),J=i({version:n(1),process_id:t().uuid(),state:s(["starting","running","exited","cancelled","expired","uncertain"]),exit_code:o().int().nullable(),first_cursor:o().int().min(0),next_cursor:o().int().min(0),truncated:d(),observed_at:y.datetime(),output:u(i({cursor:o().int().min(1),stream:s(["stdout","stderr"]),text:t().max(32768)}).strict()).max(128)}).strict().refine((e)=>{if(Buffer.byteLength(JSON.stringify(e))>1e5||e.next_cursor<e.first_cursor-1)return!1;if((e.state==="starting"||e.state==="running"||e.state==="uncertain")&&e.exit_code!==null)return!1;if(e.state==="exited"&&(e.exit_code===null||e.exit_code<0||e.exit_code>255))return!1;if(e.state==="cancelled"&&e.exit_code!==130||e.state==="expired"&&e.exit_code!==124)return!1;let _=e.first_cursor-1;for(let l of e.output){if(l.cursor<=_||l.cursor>e.next_cursor)return!1;_=l.cursor}return!0});function ae(e){return Se.includes(e)}var Xe=i({operation_constraints:ee(t(),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:ps(),output:u($i()).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=an(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 Ki="preview.serve.v1",Ji=43200000;var ce="preview.open.v1",de=1,_n="gid_proxy_v1",Zi="egress",yn=/^(?:\*\.)?[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[1-9][0-9]{0,4})?$/,Ce=i({version:n(_n),allowed_domains:u(t().max(260).regex(yn)).max(1024)}).strict(),Ae=cn((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(),Xi=ke.extend({expires_at:y.datetime()}).strict();var Me=4,Te=5000;function Y(e,c,_){let l=null;try{l=ut(e)}catch{}An({deviceRelayUrl:l?.deviceRelayUrl??"",binding:l?.binding??null,jobId:c,port:l?.binding.port??0,reason:l?_:"binding_invalid"})}function le(e){let c=new Map;return{open(_){let l=(x)=>Y(_,e.claim.operation_id,x),C;try{C=ut(_)}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
- `)}).finally(()=>{if(c.get(w.port)===L)c.delete(w.port)})},dispose(){for(let _ of c.values())_.abort();c.clear()}}}class st extends r{observation;constructor(e){super("process_authority_lost","Process authority was lost; the owned process group has stopped.");this.observation=e}}var fe=256,B=new Map,he="preview.serve.v1",V=new Map;function be(e){let c=V.get(e.operation_id);if(c){if(c.claim!==e)throw M("process_authority_lost");return c}if(V.size>=fe)throw M("process_journal_capacity");let _={claim:e,executing:!1,cancelRequested:!1,phase:"pending"};return V.set(e.operation_id,_),_}function pe(e){return{version:1,process_id:e,state:"cancelled_before_start",exit_code:null,output:[],first_cursor:0,next_cursor:0,truncated:!1,cancellation_requested:!1,reason_code:"cancelled_before_start"}}var ue=(e)=>new Promise((c)=>setTimeout(c,e)),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 ze(e=a(),c=Ge()){let _=Ue(Mr({},e)),l=qe(nr(e),_),[C,...w]=l.split(Je);return{directory:j(c,l,"processes"),previous:[j(_,"processes"),...C==="reason"?[j(c,"ara",...w,"processes")]:[]]}}function Ge(){if(process.platform!=="darwin")throw new r("process_unavailable","Managed Mac process execution is unavailable.");let e=Uo();if(!e)throw new r("process_unavailable","The private per-user process directory is unavailable.");return e}async function fr(e){if(!e.claim.owner||e.signal.aborted||e.expiresAtMs<=Date.now())throw 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 _=e.journals??ze();We(_.directory,{recursive:!0,mode:448});let l=gr({runtimeDirectory:G(_.directory),previousRuntimeDirectories:(_.previous??[]).filter((m)=>Z(m)).map((m)=>G(m)),root:e.root,runId:JSON.stringify([e.claim.owner,e.claim.run_id,e.claim.root_id,e.claim.operation_id]),maxScopes:fe});try{for(let m of[e.root,e.cwd])if(!je(G(m),l.journalDirectory))throw new r("process_journal_inside_workspace","The selected root contains the private process journal. Select an existing narrower granted workspace root outside the journal; no command was dispatched.")}catch(m){throw l.disposeSocket(),m}let 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{He(L,JSON.stringify(P),{mode:384});let m=Sn({configPath:L,root:e.cwd,grantedRoot:e.root,workRoot:e.root,temporaryDirectory:E});x=e.spawnWorker?.(L,P)??Le(m.command,m.args,{...m.options,env:e.environment,stdio:[En,"ignore","ignore"]})}catch(m){throw l.disposeSocket(),m}let I=!1,F=new Promise((m,S)=>{x.once("exit",(f)=>{I=!0,m(f)}),x.once("error",(f)=>{I=!0,S(f)})});F.catch(()=>{});let ge={root:e.root,runId:e.claim.run_id,scopeId:l.scopeId,socketPath:l.socketPath,generation:1,fenceId:P.fenceId,executorLaunchId:P.launchId,expiresAtMs:P.expiresAtMs},N=async(m)=>{let S=await _r(ge,{type:"job",version:2,generation:1,id:Q(),jobId:e.claim.operation_id,...m==="start"?{action:m,input:{script:e.command,leaseExpiresAtMs:e.expiresAtMs}}:m==="inspect"?{action:m,input:{after:0}}:m==="probe"?{action:"inspect",input:{after:Number.MAX_SAFE_INTEGER}}:{action:m,input:{}}},new AbortController().signal);if(!S.ok)throw M(S.error);return S.job},U=!1,q=!1,te,re=()=>{U=!0,ct(x,"SIGTERM")};e.signal.addEventListener("abort",re,{once:!0});let T,oe=0,ve=async(m)=>{let S=[...m.output],f={version:1,process_id:e.claim.operation_id,state:m.state,exit_code:m.exitCode,first_cursor:m.firstCursor,next_cursor:m.nextCursor,truncated:m.truncated,output:S,observed_at:new Date().toISOString()};while(Buffer.byteLength(JSON.stringify(f))>90000&&S.length)S.shift(),f.truncated=!0,f.first_cursor=S[0]?.cursor??f.next_cursor+1;T=J.parse(f),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(Ne(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 f;try{q=!0,f=await N("start")}catch(O){if(!(O instanceof r)||O.code!=="hands_job_result_unknown")throw O;f=await N("inspect")}if(c.phase="running",c.cancel=async()=>{await N("cancel")},w&&e.preview)c.tunnels=le({claim:e.claim,executorLaunchId:P.launchId,expiresAtMs:e.expiresAtMs,deniedPorts:e.preview.deniedPorts,inspect:async()=>c.phase==="running"&&!I?await N("probe"):null});if(c.cancelRequested)await c.cancel(),f=await N("inspect");for(;;){if(!["starting","running"].includes(f.state))c.phase="settling",c.cancel=void 0;if(!T||T.state!==f.state||T.next_cursor!==f.nextCursor&&Date.now()-oe>=5000)await ve(f);if(!["starting","running"].includes(f.state))break;if(e.signal.aborted||I)throw M();await ue(1000);try{f=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)ct(x,"SIGTERM");let m,S=await Promise.race([F.then((f)=>({code:f})),new Promise((f)=>{m=setTimeout(()=>f(null),6000)})]).finally(()=>{clearTimeout(m)});if(!S){try{ct(x,"SIGKILL")}catch{}try{await F}finally{if(I)l.disposeSocket()}throw M("process_cleanup_unconfirmed")}try{if((U||e.signal.aborted)&&S.code===0&&q){v(E);let f=JSON.parse(h(P.directTerminalReceiptPath)),O=X.safeParse(f.observation);if(Object.keys(f).length===4&&f.launch_id===P.launchId&&f.fence_id===P.fenceId&&f.scope_id===l.scopeId&&O.success&&O.data.process_id===e.claim.operation_id){if(w)z();throw new st(O.data)}}}catch(f){if(f instanceof st)throw f}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 $s(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 _=V.get(e.operation_id);if(_&&_.claim!==e)return!1;let l=be(e);if(l.cancelRequested=!0,l.phase==="running"&&l.cancel)l.cancelInFlight??=l.cancel(),await l.cancelInFlight;return!0}function Bs(e,c){V.delete(e);let _=B.get(e);if(!_||c!=="succeeded"&&!_.anyCompletion)return B.delete(e),!1;try{let l=me(_.path);if(!l.isDirectory()||l.isSymbolicLink()||l.ino!==_.ino||l.dev!==_.dev||!A(l)||G(_.path)!==_.path||Z(j(_.path,"owner.lock")))return!1;return Ve(_.path,{recursive:!0}),B.delete(e),!0}catch{return!1}}
4
- export{Ki,Ji,_n,Zi,yn,Xi,st,fr,$s,Bs};
2
+ import{H}from"./vm-hands-entry-lite-39qv4sqt.js";import{D,T,b}from"./vm-hands-entry-lite-tash5m18.js";import{je,gr,_r,Sn,En,ct}from"./vm-hands-entry-lite-nercg1yz.js";import{Mr}from"./vm-hands-entry-lite-hc11hecd.js";import{p,ut,An,_e,we}from"./vm-hands-entry-lite-kwmjn9y3.js";import{v,h}from"./vm-hands-entry-lite-c4959xva.js";import{a,nr,qo}from"./vm-hands-entry-lite-haws181e.js";import{an,y,t,k,o,d,ms,Oe,Bi,u,i,W,g,ee,s,n,cn}from"./vm-hands-entry-lite-4cdn822w.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{se,A}from"./vm-hands-entry-lite-1kt82jes.js";import{randomUUID as Q}from"crypto";import{spawn as Le}from"child_process";import{existsSync as Z,lstatSync as me,mkdirSync as We,readFileSync as Ne,realpathSync as G,rmSync as Ve,writeFileSync as He}from"fs";import{dirname as Ue,join as j,relative as qe,sep as Je}from"path";var Se=["process.run.v1","process.full.v1"],xe=600000,Pe=1800000,Ee=20000,ne="process.cancel.v1",ie=i({action:n("start"),request_id:t().uuid(),command:t().min(1).max(16000).refine((e)=>!e.includes("\x00")),cwd:t().min(1).max(4096).refine((e)=>!e.includes("\x00")&&!e.startsWith("/")&&!e.split(/[\\/]/).includes("..")).describe("Path relative to the granted device root; omit to use that root. Must not start with /, contain a .. path segment, or contain a NUL character.").optional(),mode:s(["host","confined"]).default("host"),timeout_ms:o().int().min(1000).max(Pe).default(xe).describe("Absolute process budget including queue and startup time. Defaults to ten minutes; longer explicit requests require the selected root's advertised max_timeout_ms. Retrying never renews the deadline.")}).strict(),K={device_id:t().uuid(),root_id:t().uuid()},Re=g("action",[ie.extend(K),i({...K,action:n("inspect"),process_id:t().uuid(),after:o().int().min(0).default(0),wait_ms:o().int().min(0).max(Ee).default(0).describe("Wait for new output or a state change, bounded by this call's wait budget. Expiring this wait does not cancel the process or extend its deadline.")}).strict(),i({...K,action:n("cancel"),process_id:t().uuid()}).strict()]),Fe=an(Re,{io:"input"}),Ke=ie.extend({process_brain_fence:t().uuid(),process_expires_at:y.datetime()}).strict(),J=i({version:n(1),process_id:t().uuid(),state:s(["starting","running","exited","cancelled","expired","uncertain"]),exit_code:o().int().nullable(),first_cursor:o().int().min(0),next_cursor:o().int().min(0),truncated:d(),observed_at:y.datetime(),output:u(i({cursor:o().int().min(1),stream:s(["stdout","stderr"]),text:t().max(32768)}).strict()).max(128)}).strict().refine((e)=>{if(Buffer.byteLength(JSON.stringify(e))>1e5||e.next_cursor<e.first_cursor-1)return!1;if((e.state==="starting"||e.state==="running"||e.state==="uncertain")&&e.exit_code!==null)return!1;if(e.state==="exited"&&(e.exit_code===null||e.exit_code<0||e.exit_code>255))return!1;if(e.state==="cancelled"&&e.exit_code!==130||e.state==="expired"&&e.exit_code!==124)return!1;let _=e.first_cursor-1;for(let l of e.output){if(l.cursor<=_||l.cursor>e.next_cursor)return!1;_=l.cursor}return!0});function ae(e){return Se.includes(e)}var Xe=i({operation_constraints:ee(t(),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:ms(),output:u(Bi()).length(0),first_cursor:n(0),next_cursor:n(0),truncated:n(!1),cancellation_requested:n(!1),reason_code:s(["cancelled_before_start","process_journal_capacity","path_not_found","process_timeout_unsupported"]).optional(),expires_at:y.datetime().optional().describe("Accepted absolute process deadline. Reading, waiting and retrying do not extend it.")}).strict(),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=an(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 Ji="preview.serve.v1",Zi=43200000;var ce="preview.open.v1",de=1,_n="gid_proxy_v1",Xi="egress",yn=/^(?:\*\.)?[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[1-9][0-9]{0,4})?$/,Ce=i({version:n(_n),allowed_domains:u(t().max(260).regex(yn)).max(1024)}).strict(),Ae=cn((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(),Yi=ke.extend({expires_at:y.datetime()}).strict();var Me=4,Te=5000;function Y(e,c,_){let l=null;try{l=ut(e)}catch{}An({deviceRelayUrl:l?.deviceRelayUrl??"",binding:l?.binding??null,jobId:c,port:l?.binding.port??0,reason:l?_:"binding_invalid"})}function le(e){let c=new Map;return{open(_){let l=(x)=>Y(_,e.claim.operation_id,x),I;try{I=ut(_)}catch{return l("binding_invalid")}let{binding:w,deviceRelayUrl:z}=I,E=e.claim.owner;if(!E||w.organizationId!==E.organization_id||w.userId!==E.user_id||w.deviceId!==E.device_id||w.rootId!==e.claim.root_id||w.jobId!==e.claim.operation_id||w.fenceId!==e.claim.operation_id||w.generation!==de||w.expiresAtMs>Math.min(Date.now()+p.lifetimeMs+Te,e.expiresAtMs))return l("binding_mismatch");if(w.expiresAtMs<=Date.now())return l("binding_expired");if(c.get(w.port)?.abort(),c.delete(w.port),c.size>=Me)return l("preview_capacity");let L=new AbortController;c.set(w.port,L);let P=we({binding:w,deniedPorts:e.deniedPorts,readCurrentJob:async()=>{if(L.signal.aborted)return null;let x=await e.inspect();return x?{binding:w,executorLaunchId:e.executorLaunchId,job:x}:null}});_e({binding:w,deviceRelayUrl:z,port:P,signal:L.signal}).then((x)=>x.closed,(x)=>{let R=x instanceof Error?x.message:"preview_failed";if(R!=="preview_not_authorized")process.stderr.write(`${JSON.stringify({event:"worker_preview.open_failed",job_id:w.jobId,port:w.port,reason_code:R})}
3
+ `)}).finally(()=>{if(c.get(w.port)===L)c.delete(w.port)})},dispose(){for(let _ of c.values())_.abort();c.clear()}}}class st extends r{observation;constructor(e){super("process_authority_lost","Process authority was lost; the owned process group has stopped.");this.observation=e}}var fe=256,B=new Map,he="preview.serve.v1",V=new Map;function be(e){let c=V.get(e.operation_id);if(c){if(c.claim!==e)throw O("process_authority_lost");return c}if(V.size>=fe)throw O("process_journal_capacity");let _={claim:e,executing:!1,cancelRequested:!1,phase:"pending"};return V.set(e.operation_id,_),_}function pe(e){return{version:1,process_id:e,state:"cancelled_before_start",exit_code:null,output:[],first_cursor:0,next_cursor:0,truncated:!1,cancellation_requested:!1,reason_code:"cancelled_before_start"}}var ue=(e)=>new Promise((c)=>setTimeout(c,e)),O=(e="process_outcome_uncertain")=>new r(e,"The managed process outcome could not be confirmed; inspect its saved receipt before starting another intent.");function ze(e=a(),c=Ge()){let _=Ue(Mr({},e)),l=qe(nr(e),_),[I,...w]=l.split(Je);return{directory:j(c,l,"processes"),previous:[j(_,"processes"),...I==="reason"?[j(c,"ara",...w,"processes")]:[]]}}function Ge(){if(process.platform!=="darwin")throw new r("process_unavailable","Managed Mac process execution is unavailable.");let e=qo();if(!e)throw new r("process_unavailable","The private per-user process directory is unavailable.");return e}async function fr(e){if(!e.claim.owner||e.signal.aborted||e.expiresAtMs<=Date.now())throw O("process_authority_lost");let c=be(e.claim);if(c.executing)throw O("process_busy");if(c.executing=!0,c.cancelRequested)return c.phase="settling",pe(e.claim.operation_id);c.phase="starting";let _=e.journals??ze();We(_.directory,{recursive:!0,mode:448});let l=gr({runtimeDirectory:G(_.directory),previousRuntimeDirectories:(_.previous??[]).filter((m)=>Z(m)).map((m)=>G(m)),root:e.root,runId:JSON.stringify([e.claim.owner,e.claim.run_id,e.claim.root_id,e.claim.operation_id]),maxScopes:fe});try{for(let m of[e.root,e.cwd])if(!je(G(m),l.journalDirectory))throw new r("process_journal_inside_workspace","The selected root contains the private process journal. Select an existing narrower granted workspace root outside the journal; no command was dispatched.")}catch(m){throw l.disposeSocket(),m}let I=me(l.journalDirectory),w=e.claim.capability===he,z=()=>B.set(e.claim.operation_id,{path:l.journalDirectory,ino:I.ino,dev:I.dev,anyCompletion:w}),E=l.launchDirectory,L=j(E,"config.json"),P={url:"",transport:"local_job_ipc",directShell:{mode:e.mode,executable:e.shell,jobId:e.claim.operation_id},workerVersion:D,protocolVersion:2,workerArtifactSha256:b,workerEntrypoint:T,targetGeneration:1,fenceId:Q(),...process.platform==="win32"?{bashExecutable:se()}:{},workRoot:e.root,workspaceAliasPath:e.root,repoPath:e.cwd,jobEnvPath:j(E,"unused.env"),replSocketPath:j(E,"unused.sock"),readyPath:j(E,"ready.json"),directTerminalReceiptPath:j(E,"terminal.json"),launchId:Q(),expiresAtMs:e.expiresAtMs+5000,bashTimeoutMs:60000,replTimeoutMs:1000,allowedTools:["bash"],managedJobs:{journalDirectory:l.journalDirectory,scopeId:l.scopeId},jobControlSocketPath:l.socketPath,...e.prefix?{bashCommandPrefix:e.prefix}:{},...e.jobsUser?{jobsUser:e.jobsUser}:{}},x;try{He(L,JSON.stringify(P),{mode:384});let m=Sn({configPath:L,root:e.cwd,grantedRoot:e.root,workRoot:e.root,temporaryDirectory:E});x=e.spawnWorker?.(L,P)??Le(m.command,m.args,{...m.options,env:e.environment,stdio:[En,"ignore","ignore"]})}catch(m){throw l.disposeSocket(),m}let R=!1,F=new Promise((m,S)=>{x.once("exit",(f)=>{R=!0,m(f)}),x.once("error",(f)=>{R=!0,S(f)})});F.catch(()=>{});let ge={root:e.root,runId:e.claim.run_id,scopeId:l.scopeId,socketPath:l.socketPath,generation:1,fenceId:P.fenceId,executorLaunchId:P.launchId,expiresAtMs:P.expiresAtMs},N=async(m)=>{let S=await _r(ge,{type:"job",version:2,generation:1,id:Q(),jobId:e.claim.operation_id,...m==="start"?{action:m,input:{script:e.command,leaseExpiresAtMs:e.expiresAtMs}}:m==="inspect"?{action:m,input:{after:0}}:m==="probe"?{action:"inspect",input:{after:Number.MAX_SAFE_INTEGER}}:{action:m,input:{}}},new AbortController().signal);if(!S.ok)throw O(S.error);return S.job},U=!1,q=!1,te,re=()=>{U=!0,ct(x,"SIGTERM")};e.signal.addEventListener("abort",re,{once:!0});let M,oe=0,ve=async(m)=>{let S=[...m.output],f={version:1,process_id:e.claim.operation_id,state:m.state,exit_code:m.exitCode,first_cursor:m.firstCursor,next_cursor:m.nextCursor,truncated:m.truncated,output:S,observed_at:new Date().toISOString()};while(Buffer.byteLength(JSON.stringify(f))>90000&&S.length)S.shift(),f.truncated=!0,f.first_cursor=S[0]?.cursor??f.next_cursor+1;M=J.parse(f),await e.emit(M),oe=Date.now()};try{let m=Math.min(Date.now()+1e4,e.expiresAtMs);while(!Z(P.readyPath)){if(R)throw new r("process_start_failed","The managed process supervisor exited before accepting a command; no command was dispatched.");if(e.signal.aborted||Date.now()>=m)throw O("process_start_unconfirmed");await ue(25)}let S=JSON.parse(Ne(P.readyPath,"utf8"));if(S.launchId!==P.launchId||S.fenceId!==P.fenceId||S.workerArtifactSha256!==b)throw O();if(e.signal.throwIfAborted(),c.cancelRequested)return pe(e.claim.operation_id);let f;try{q=!0,f=await N("start")}catch(C){if(!(C instanceof r)||C.code!=="hands_job_result_unknown")throw C;f=await N("inspect")}if(c.phase="running",c.cancel=async()=>{await N("cancel")},w&&e.preview)c.tunnels=le({claim:e.claim,executorLaunchId:P.launchId,expiresAtMs:e.expiresAtMs,deniedPorts:e.preview.deniedPorts,inspect:async()=>c.phase==="running"&&!R?await N("probe"):null});if(c.cancelRequested)await c.cancel(),f=await N("inspect");for(;;){if(!["starting","running"].includes(f.state))c.phase="settling",c.cancel=void 0;if(!M||M.state!==f.state||M.next_cursor!==f.nextCursor&&Date.now()-oe>=5000)await ve(f);if(!["starting","running"].includes(f.state))break;if(e.signal.aborted||R)throw O();await ue(1000);try{f=await N("inspect"),te=void 0}catch(C){if(!(C instanceof r)||C.code!=="hands_job_result_unknown"||e.signal.aborted||R||Date.now()-(te??=Date.now())>120000)throw C}}if(!M||M.state==="uncertain")throw O();return M}finally{if(c.phase="settling",c.cancel=void 0,c.tunnels?.dispose(),c.tunnels=void 0,await c.cancelInFlight?.catch(()=>{}),e.signal.removeEventListener("abort",re),!R&&!U)ct(x,"SIGTERM");let m,S=await Promise.race([F.then((f)=>({code:f})),new Promise((f)=>{m=setTimeout(()=>f(null),6000)})]).finally(()=>{clearTimeout(m)});if(!S){try{ct(x,"SIGKILL")}catch{}try{await F}finally{if(R)l.disposeSocket()}throw O("process_cleanup_unconfirmed")}try{if((U||e.signal.aborted)&&S.code===0&&q){v(E);let f=JSON.parse(h(P.directTerminalReceiptPath)),C=X.safeParse(f.observation);if(Object.keys(f).length===4&&f.launch_id===P.launchId&&f.fence_id===P.fenceId&&f.scope_id===l.scopeId&&C.success&&C.data.process_id===e.claim.operation_id){if(w)z();throw new st(C.data)}}}catch(f){if(f instanceof st)throw f}finally{if(R)l.disposeSocket()}if(S.code!==0&&!U&&q)throw O("process_cleanup_unconfirmed");if(!U&&S.code===0&&(M&&["exited","cancelled","expired"].includes(M.state)||!q&&c.cancelRequested)||w&&S.code===0&&!q)z()}}async function js(e,c){if(c.kind===ce&&e.capability===he){let I=V.get(e.operation_id);if(I?.claim===e&&I.tunnels)I.tunnels.open(c.payload);else Y(c.payload,e.operation_id,"server_not_running");return!0}if(c.kind!==ne||!ae(e.capability)||!e.owner||c.payload.process_id!==e.operation_id)return!1;let _=V.get(e.operation_id);if(_&&_.claim!==e)return!1;let l=be(e);if(l.cancelRequested=!0,l.phase==="running"&&l.cancel)l.cancelInFlight??=l.cancel(),await l.cancelInFlight;return!0}function Us(e,c){V.delete(e);let _=B.get(e);if(!_||c!=="succeeded"&&!_.anyCompletion)return B.delete(e),!1;try{let l=me(_.path);if(!l.isDirectory()||l.isSymbolicLink()||l.ino!==_.ino||l.dev!==_.dev||!A(l)||G(_.path)!==_.path||Z(j(_.path,"owner.lock")))return!1;return Ve(_.path,{recursive:!0}),B.delete(e),!0}catch{return!1}}
4
+ export{Ji,Zi,_n,Xi,yn,Yi,st,fr,js,Us};
@@ -1,7 +1,7 @@
1
1
  // @bun
2
- import{$t}from"./vm-hands-entry-lite-ckezse0f.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{fe,se,C}from"./vm-hands-entry-lite-qz74j563.js";import{spawn as J,spawnSync as ee}from"child_process";import{existsSync as h,mkdtempSync as ne,readFileSync as K,readdirSync as te,realpathSync as re,rmSync as oe,statSync as G}from"fs";import{platform as T,tmpdir as ie}from"os";import{dirname as A,join as c,win32 as w}from"path";import{fileURLToPath as ae,pathToFileURL as W}from"url";var le=["bwrap","socat","rg"],de=2000;var ce=3,L=4000,ue=new Set([".git",".hg",".svn","node_modules"]),me=["runAsHostUid","sysrq-trigger"],X=c(A(A(ae(import.meta.url))),"packages","sandbox-runtime"),pe=c(X,"src","index.ts"),z=!1;function Wi(){z=!0}function j(){return z?c(A(re(process.execPath)),"runtime","srt"):void 0}function y(){let e=c(j()??X,"vendor","srt-win");return c(e,process.arch,"srt-win.exe")}async function Y(){let e=j();if(e&&process.platform==="linux"&&!h(c(e,"vendor","seccomp",process.arch,"apply-seccomp")))throw Error("packaged_sandbox_runtime_vendor_missing");if(e&&process.platform==="win32"&&!h(y()))throw Error("packaged_sandbox_runtime_vendor_missing");if(e){let i=K(c(e,"sandbox-runtime.mjs"),"utf8");for(let s of me)if(!i.includes(s))throw Error(`packaged_sandbox_runtime_fork_missing:${s}`)}let n=(await import(e?W(c(e,"sandbox-runtime.mjs")).href:W(pe).href)).SandboxManager;if(!n||typeof n.initialize!=="function"||typeof n.wrapWithSandboxArgv!=="function")throw Error("sandbox-runtime does not expose the expected SandboxManager API.");return{SandboxManager:n}}function ge(e={}){if((e.platformName??T())!=="linux")return!1;let o=e.fileExists??h,n=e.readFile??((i)=>K(i,"utf8"));for(let i of["/.dockerenv","/run/.containerenv"])try{if(o(i))return!0}catch{}try{return/docker|containerd|kubepods|lxc|libpod/.test(n("/proc/1/cgroup"))}catch{return!1}}function we(e){return["/bin/true","/usr/bin/true"].find((t)=>e(t))??null}function Se(e,t){return e==="strict"?["--ro-bind","/","/","--unshare-pid","--unshare-user","--cap-drop","ALL","--proc","/proc","--",t]:["--ro-bind","/","/","--unshare-pid","--unshare-user","--bind","/proc","/proc","--",t]}function be(e,t){try{let o=ee("bwrap",Se(e,t),{stdio:"ignore",timeout:de});return!o.error&&o.status===0}catch{return!1}}function xe(e){let t=e.platformName??T(),o=e.fileExists??h;if(t==="win32")return(e.bash??fe)()&&o(y())?m??"strict":null;if(t!=="linux")return null;let n=e.hasExecutable??$t;if(!le.every((l)=>n(l)))return null;let i=we(o);if(!i)return null;let s=m??(e.containerized??ge({platformName:t})?"weak":"strict");return(e.probeNamespaces??((l)=>be(l,i)))(s)?s:null}var S=null,M=!1,p=null,F=null;var m=null,P=null,_=null,E=null,v=[],g=new Map;function D(){throw b("sandbox_mode_conflict"),new r("sandbox_unavailable","Sandbox process policy conflicts with an existing probe or session. Restart the worker.")}function Vi(e){if(m!==null&&m!==e||M&&S!==null&&S!==e||P!==null&&P!==e)D();m=e}function b(e){if(!p)process.stderr.write(`Reason worker: confined commands are off (${e})
2
+ import{$t}from"./vm-hands-entry-lite-ckezse0f.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{fe,se,C}from"./vm-hands-entry-lite-1kt82jes.js";import{spawn as J,spawnSync as ee}from"child_process";import{existsSync as h,mkdtempSync as ne,readFileSync as K,readdirSync as te,realpathSync as re,rmSync as oe,statSync as G}from"fs";import{platform as T,tmpdir as ie}from"os";import{dirname as A,join as c,win32 as w}from"path";import{fileURLToPath as ae,pathToFileURL as W}from"url";var le=["bwrap","socat","rg"],de=2000;var ce=3,L=4000,ue=new Set([".git",".hg",".svn","node_modules"]),me=["runAsHostUid","sysrq-trigger"],X=c(A(A(ae(import.meta.url))),"packages","sandbox-runtime"),pe=c(X,"src","index.ts"),z=!1;function Vi(){z=!0}function j(){return z?c(A(re(process.execPath)),"runtime","srt"):void 0}function y(){let e=c(j()??X,"vendor","srt-win");return c(e,process.arch,"srt-win.exe")}async function Y(){let e=j();if(e&&process.platform==="linux"&&!h(c(e,"vendor","seccomp",process.arch,"apply-seccomp")))throw Error("packaged_sandbox_runtime_vendor_missing");if(e&&process.platform==="win32"&&!h(y()))throw Error("packaged_sandbox_runtime_vendor_missing");if(e){let i=K(c(e,"sandbox-runtime.mjs"),"utf8");for(let s of me)if(!i.includes(s))throw Error(`packaged_sandbox_runtime_fork_missing:${s}`)}let n=(await import(e?W(c(e,"sandbox-runtime.mjs")).href:W(pe).href)).SandboxManager;if(!n||typeof n.initialize!=="function"||typeof n.wrapWithSandboxArgv!=="function")throw Error("sandbox-runtime does not expose the expected SandboxManager API.");return{SandboxManager:n}}function ge(e={}){if((e.platformName??T())!=="linux")return!1;let o=e.fileExists??h,n=e.readFile??((i)=>K(i,"utf8"));for(let i of["/.dockerenv","/run/.containerenv"])try{if(o(i))return!0}catch{}try{return/docker|containerd|kubepods|lxc|libpod/.test(n("/proc/1/cgroup"))}catch{return!1}}function we(e){return["/bin/true","/usr/bin/true"].find((t)=>e(t))??null}function Se(e,t){return e==="strict"?["--ro-bind","/","/","--unshare-pid","--unshare-user","--cap-drop","ALL","--proc","/proc","--",t]:["--ro-bind","/","/","--unshare-pid","--unshare-user","--bind","/proc","/proc","--",t]}function be(e,t){try{let o=ee("bwrap",Se(e,t),{stdio:"ignore",timeout:de});return!o.error&&o.status===0}catch{return!1}}function xe(e){let t=e.platformName??T(),o=e.fileExists??h;if(t==="win32")return(e.bash??fe)()&&o(y())?m??"strict":null;if(t!=="linux")return null;let n=e.hasExecutable??$t;if(!le.every((l)=>n(l)))return null;let i=we(o);if(!i)return null;let s=m??(e.containerized??ge({platformName:t})?"weak":"strict");return(e.probeNamespaces??((l)=>be(l,i)))(s)?s:null}var S=null,M=!1,p=null,F=null;var m=null,P=null,_=null,E=null,v=[],g=new Map;function D(){throw b("sandbox_mode_conflict"),new r("sandbox_unavailable","Sandbox process policy conflicts with an existing probe or session. Restart the worker.")}function Gi(e){if(m!==null&&m!==e||M&&S!==null&&S!==e||P!==null&&P!==e)D();m=e}function b(e){if(!p)process.stderr.write(`Reason worker: confined commands are off (${e})
3
3
  `);p=e}function hr(e){if(p)return!1;if(!M){if(S=xe(e??{}),M=!0,S&&!e)Ce()}return S!==null}function he(){return hr()?S:null}var R=null,x=0;function I(e,t){if(p)throw new r("sandbox_unavailable","Confined execution is unavailable in this worker process.");if(m&&e.sandboxMode&&m!==e.sandboxMode)D();let o=m??e.sandboxMode??he();if(!o)throw new r("sandbox_unavailable","Confined command execution is unavailable on this operating system.");if(P&&P!==o)D();return P=o,R??=(async()=>{let{SandboxManager:n}=await(e.loadSandboxRuntime??Y)();return await n.initialize(Ne(o,t)),n})().catch((n)=>{if(R=null,t)_=null,process.stderr.write(`Reason worker: the Windows sandbox did not start for this folder (${String(n).slice(0,500)})
4
4
  `);else b(`initialize_failed: ${String(n)}`);throw n instanceof r?n:new r("sandbox_unavailable","The confined execution sandbox failed to start.")}),R.then((n)=>{if(p)throw new r("sandbox_unavailable","Confined execution became unavailable during sandbox initialization.");return n})}function O(){if(x-=1,x===0)for(let e of v.splice(0))e()}async function ye(e,t=!0,o,n){let i=n===void 0?1/0:Date.now()+n;await Q();let s=_e();if(t)await s;let a=JSON.stringify(e),l=!1,u=()=>{if(!l)return;l=!1;let d=(g.get(a)??1)-1;if(d>0)g.set(a,d);else g.delete(a)};try{for(;;){if(o?.aborted)throw new r("cancelled","Operation was cancelled.");if(Date.now()>=i)return!1;if(E){await E;continue}let d=g.keys().next().value;if(_??=d??a,_===a&&(d===void 0||d===a))break;if(!l){l=!0,g.set(a,(g.get(a)??0)+1);continue}if(x===0&&d===a){Pe();continue}await new Promise((f)=>{if(v.push(f),o?.addEventListener("abort",()=>f(),{once:!0}),i!==1/0)setTimeout(f,Math.max(0,i-Date.now())).unref?.()})}return x+=1,!0}finally{if(l&&x===0)for(let d of v.splice(0))d();u()}}function Pe(){return E??=Me().finally(()=>{E=null}),E}function Ee(e,t,o=process.env){let n=o.USERPROFILE?w.resolve(o.USERPROFILE).toLowerCase():null,i=w.resolve(e).toLowerCase(),s=n!==null&&i.startsWith(`${n}\\`),a=t?q(o).filter((l)=>l.toLowerCase()===i||l.toLowerCase().startsWith(`${i}\\`)):[];return{denyRead:[],allowRead:[e],allowWrite:t?[e]:[],denyWrite:t?a:s?[]:[e]}}function q(e,t=process.execPath){let o=new Map;for(let n of[...(e.PATH??e.Path??"").split(";"),w.dirname(t)]){if(!n||!w.isAbsolute(n))continue;let i=w.resolve(n);if(!o.has(i.toLowerCase()))o.set(i.toLowerCase(),i)}return[...o.values()]}function Re(e=process.env,t=process.execPath){let o=[e.SystemRoot,e.ProgramFiles,e["ProgramFiles(x86)"],e.ProgramW6432,e.ProgramData,e.USERPROFILE].filter((n)=>!!n).map((n)=>w.resolve(n).toLowerCase());return q(e,t).filter((n)=>{let i=n.toLowerCase();return!o.some((s)=>i===s||i.startsWith(`${s}\\`))})}var U=null,H=null;function Q(e=y()){return H??=(async()=>{let t;try{t=JSON.parse((await V(e,["status"])).stdout).user?.user?.sid}catch{return null}if(typeof t!=="string"||!/^S-1-[0-9-]+$/.test(t))return null;if(!await new Promise((n)=>{let i=J(C("icacls"),[e,"/grant",`*${t}:(RX)`],{stdio:"ignore",windowsHide:!0,timeout:30000});i.on("error",()=>n(!1)),i.on("close",(s)=>n(s===0))}))process.stderr.write(`Reason worker: could not let the Windows sandbox user run srt-win.exe
5
5
  `);return t})(),H}function V(e,t,o){return new Promise((n)=>{let i=J(e,t,{stdio:["pipe","pipe","ignore"],windowsHide:!0,timeout:120000}),s="";i.stdout?.setEncoding("utf8").on("data",(a)=>{s+=a}),i.on("error",()=>n({status:null,stdout:s})),i.on("close",(a)=>n({status:a,stdout:s})),i.stdin?.end(o??"")})}function _e(e=y()){return U??=(async()=>{let t=Re();if(t.length===0)return;let o=await Q(e),n=o?await V(e,["acl","stamp","--holder-pid",String(process.ppid),"--sandbox-user-sid",o],JSON.stringify({denyRead:[],denyWrite:t})):null;if(!n||n.status!==0&&n.status!==2)b(`program_folder_deny_failed: ${n?`exit ${n.status}`:"no sandbox user"}`),process.stderr.write(`Reason worker: could not deny the Windows sandbox writes to PATH folders (${n?`exit ${n.status}`:"no sandbox user"}); confined commands are off
6
- `)})(),U}var Ae=`h=$(mktemp -d) || exit 125; trap 'rm -rf "$h"' EXIT; mkdir -p "$h/AppData/Roaming" "$h/AppData/Local"; w=$(cygpath -w "$h"); export HOME="$h" USERPROFILE="$w" APPDATA="$w\\AppData\\Roaming" LOCALAPPDATA="$w\\AppData\\Local" TEMP="$w" TMP="$w"; `;async function Me(){let e=R;if(R=null,_=null,!e)return;try{await(await e).reset()}catch{}}async function Ce(e={}){if(p)return!1;if(e.loadSandboxRuntime)return B(e.loadSandboxRuntime);if(!hr())return!1;return F??=B(Y),F}async function B(e){try{let{SandboxManager:t}=await e();if(process.platform==="win32"){if(!h(y()))b("dependencies_missing: srt-win.exe");return!p}let o=t.checkDependencies().errors;if(o.length>0)return b(`dependencies_missing: ${o.join(", ")}`),!1;return!p}catch(t){return b(`load_failed: ${String(t)}`),!1}}function gn(e=h,t=T()){if(t==="win32")return se("win32");return["/bin/bash","/bin/sh"].find((o)=>e(o))??"/bin/sh"}function ve(e){return e.map((t)=>`'${t.replaceAll("'","'\\''")}'`).join(" ")}function De(e,t,o=(n)=>te(n,{withFileTypes:!0}).filter((i)=>i.isDirectory()||i.isFile()).map((i)=>i.name)){let n=[],i=[{path:e,depth:0}],s=0;while(i.length>0&&s<L){let a=i.pop(),l;try{l=o(a.path)}catch{continue}for(let u of l){if(s+=1,s>L)break;let d=c(a.path,u);if(t(d)){n.push(d);continue}if(a.depth+1<ce&&!ue.has(u))i.push({path:d,depth:a.depth+1})}}return n}function Te(e){let t=c(e.root,".git"),o=[];try{if(G(t).isDirectory())o=[c(t,"config"),c(t,"hooks")]}catch{}return{denyRead:["/home","/root","/tmp","/tmp/.X11-unix",...e.protectedPaths],allowRead:[e.root,e.temporaryDirectory],allowWrite:[...e.allowWrite?[e.root]:[],e.temporaryDirectory],denyWrite:[...e.protectedPaths,...o]}}function ke(e,t){let o=c(t,".git"),n=[];try{if(G(o).isDirectory())n=[c(o,"config"),c(o,"hooks")]}catch{}return{denyRead:[...e],allowRead:[],allowWrite:[],denyWrite:[...e,...n]}}function Ne(e,t){if(t)return{network:{allowedDomains:[],deniedDomains:[]},filesystem:t,windows:{srtWin:{path:y()}}};return{network:{allowedDomains:[],deniedDomains:[]},filesystem:{denyRead:[],allowRead:[],allowWrite:[],denyWrite:[]},...e==="weak"?{enableWeakerNestedSandbox:!0}:{}}}function Gi(e){let t=e.createTemporaryDirectory??(()=>ne(c(ie(),"reason-device-"))),o=e.removeTemporaryDirectory??((n)=>oe(n,{recursive:!0,force:!0}));return async(n,i,s)=>{let a=process.platform==="win32",l;if(a){let d=Ee(s.root,s.allowWrite);if(!await ye(d,!s.workerProbe,s.signal,s.timeoutMs))return{exitCode:null,signal:null,stdout:"",stderr:"",timedOut:!0,truncated:!1};try{l=await I(e,d)}catch(f){throw O(),f}}else l=await I(e),x+=1;let u;try{u=t();let d=De(s.root,e.isProtectedPath),f;try{f=await l.wrapWithSandboxArgv((a?Ae:"")+ve([n,...i]),e.shell??gn(),{filesystem:a?ke(d,s.root):Te({root:s.root,allowWrite:s.allowWrite,temporaryDirectory:u,protectedPaths:d})},s.signal,s.cwd)}catch(N){throw N instanceof r?N:new r("sandbox_unavailable","The confined execution sandbox could not wrap the command.")}let[k,...Z]=f.argv;if(!k)throw new r("sandbox_unavailable","The confined execution sandbox produced no command.");return await e.spawnCaptured(k,Z,{cwd:s.cwd,timeoutMs:s.timeoutMs,signal:s.signal,env:a?f.env:e.scrubEnvironment(s.root,u)})}finally{O();try{l.cleanupAfterCommand()}catch{}if(u!==void 0)o(u)}}}
7
- export{Wi,Vi,hr,gn,Gi};
6
+ `)})(),U}var Ae=`h=$(mktemp -d) || exit 125; trap 'rm -rf "$h"' EXIT; mkdir -p "$h/AppData/Roaming" "$h/AppData/Local"; w=$(cygpath -w "$h"); export HOME="$h" USERPROFILE="$w" APPDATA="$w\\AppData\\Roaming" LOCALAPPDATA="$w\\AppData\\Local" TEMP="$w" TMP="$w"; `;async function Me(){let e=R;if(R=null,_=null,!e)return;try{await(await e).reset()}catch{}}async function Ce(e={}){if(p)return!1;if(e.loadSandboxRuntime)return B(e.loadSandboxRuntime);if(!hr())return!1;return F??=B(Y),F}async function B(e){try{let{SandboxManager:t}=await e();if(process.platform==="win32"){if(!h(y()))b("dependencies_missing: srt-win.exe");return!p}let o=t.checkDependencies().errors;if(o.length>0)return b(`dependencies_missing: ${o.join(", ")}`),!1;return!p}catch(t){return b(`load_failed: ${String(t)}`),!1}}function gn(e=h,t=T()){if(t==="win32")return se("win32");return["/bin/bash","/bin/sh"].find((o)=>e(o))??"/bin/sh"}function ve(e){return e.map((t)=>`'${t.replaceAll("'","'\\''")}'`).join(" ")}function De(e,t,o=(n)=>te(n,{withFileTypes:!0}).filter((i)=>i.isDirectory()||i.isFile()).map((i)=>i.name)){let n=[],i=[{path:e,depth:0}],s=0;while(i.length>0&&s<L){let a=i.pop(),l;try{l=o(a.path)}catch{continue}for(let u of l){if(s+=1,s>L)break;let d=c(a.path,u);if(t(d)){n.push(d);continue}if(a.depth+1<ce&&!ue.has(u))i.push({path:d,depth:a.depth+1})}}return n}function Te(e){let t=c(e.root,".git"),o=[];try{if(G(t).isDirectory())o=[c(t,"config"),c(t,"hooks")]}catch{}return{denyRead:["/home","/root","/tmp","/tmp/.X11-unix",...e.protectedPaths],allowRead:[e.root,e.temporaryDirectory],allowWrite:[...e.allowWrite?[e.root]:[],e.temporaryDirectory],denyWrite:[...e.protectedPaths,...o]}}function ke(e,t){let o=c(t,".git"),n=[];try{if(G(o).isDirectory())n=[c(o,"config"),c(o,"hooks")]}catch{}return{denyRead:[...e],allowRead:[],allowWrite:[],denyWrite:[...e,...n]}}function Ne(e,t){if(t)return{network:{allowedDomains:[],deniedDomains:[]},filesystem:t,windows:{srtWin:{path:y()}}};return{network:{allowedDomains:[],deniedDomains:[]},filesystem:{denyRead:[],allowRead:[],allowWrite:[],denyWrite:[]},...e==="weak"?{enableWeakerNestedSandbox:!0}:{}}}function Ki(e){let t=e.createTemporaryDirectory??(()=>ne(c(ie(),"reason-device-"))),o=e.removeTemporaryDirectory??((n)=>oe(n,{recursive:!0,force:!0}));return async(n,i,s)=>{let a=process.platform==="win32",l;if(a){let d=Ee(s.root,s.allowWrite);if(!await ye(d,!s.workerProbe,s.signal,s.timeoutMs))return{exitCode:null,signal:null,stdout:"",stderr:"",timedOut:!0,truncated:!1};try{l=await I(e,d)}catch(f){throw O(),f}}else l=await I(e),x+=1;let u;try{u=t();let d=De(s.root,e.isProtectedPath),f;try{f=await l.wrapWithSandboxArgv((a?Ae:"")+ve([n,...i]),e.shell??gn(),{filesystem:a?ke(d,s.root):Te({root:s.root,allowWrite:s.allowWrite,temporaryDirectory:u,protectedPaths:d})},s.signal,s.cwd)}catch(N){throw N instanceof r?N:new r("sandbox_unavailable","The confined execution sandbox could not wrap the command.")}let[k,...Z]=f.argv;if(!k)throw new r("sandbox_unavailable","The confined execution sandbox produced no command.");return await e.spawnCaptured(k,Z,{cwd:s.cwd,timeoutMs:s.timeoutMs,signal:s.signal,env:a?f.env:e.scrubEnvironment(s.root,u)})}finally{O();try{l.cleanupAfterCommand()}catch{}if(u!==void 0)o(u)}}}
7
+ export{Vi,Gi,hr,gn,Ki};