@reason-machines/cli-linux-arm64-musl 0.2.277 → 0.2.278
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/ara +1 -1
- package/bin/vm-hands/connect-cli-qphdm1f1.js +2 -0
- package/bin/vm-hands/custom-endpoint-device-92914wyp.js +2 -0
- package/bin/vm-hands/desktop-account-vsrtgkk9.js +2 -0
- package/bin/vm-hands/desktop-wallpaper-0pjhgyfk.jpg +0 -0
- package/bin/vm-hands/device-workspace-zk5xwd10.js +2 -0
- package/bin/vm-hands/dock-browser-afp005mt.png +0 -0
- package/bin/vm-hands/dock-files-rywdm96b.png +0 -0
- package/bin/vm-hands/dock-terminal-s41cj1jp.png +0 -0
- package/bin/vm-hands/hands-worker-source-da93x0qx.js +2 -0
- package/bin/vm-hands/index-w9nq2f0p.js +12818 -0
- package/bin/vm-hands/local-automation-tvf2dbfq.js +2 -0
- package/bin/vm-hands/local-capabilities-p579j21r.js +2 -0
- package/bin/vm-hands/local-desktop-users-3j79jbyp.js +2 -0
- package/bin/vm-hands/local-display-mac-j1v3mcgx.js +2 -0
- package/bin/vm-hands/local-display-session-jwdq3jb4.js +2 -0
- package/bin/vm-hands/network-contract-41qanjhp.js +2 -0
- package/bin/vm-hands/package-rx9y4bwe.js +2 -0
- package/bin/vm-hands/permissions-2s0qyrg0.js +2 -0
- package/bin/vm-hands/reason-hands-protocol-51gs8j7v.js +2 -0
- package/bin/vm-hands/status-2d21kwsn.js +96 -0
- package/bin/vm-hands/version-1qgvgegp.js +2 -0
- package/bin/vm-hands/vm-hands-entry-lite-1bvbhwbb.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-1hwdab4e.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-2xas56hm.js +43 -0
- package/bin/vm-hands/vm-hands-entry-lite-51hcyapr.js +529 -0
- package/bin/vm-hands/vm-hands-entry-lite-5pxbx31d.js +179 -0
- package/bin/vm-hands/vm-hands-entry-lite-65pbrs1x.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-7gh1rbn7.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-84aq8d12.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-8wyfep1z.js +343 -0
- package/bin/vm-hands/vm-hands-entry-lite-9pmag2qk.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-anaydk9m.js +4 -0
- package/bin/vm-hands/vm-hands-entry-lite-bfwf82rw.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite-bwt3y6wz.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-c2nrar90.js +4046 -0
- package/bin/vm-hands/vm-hands-entry-lite-ffg7rf02.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-fraghb8k.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite-gqncr2j0.js +42 -0
- package/bin/vm-hands/vm-hands-entry-lite-htn1genx.js +459 -0
- package/bin/vm-hands/vm-hands-entry-lite-jwqqfjba.js +759 -0
- package/bin/vm-hands/vm-hands-entry-lite-k4c504n7.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-n07kxrd1.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-ptmqg51y.js +4 -0
- package/bin/vm-hands/vm-hands-entry-lite-qvrnx0vk.js +4 -0
- package/bin/vm-hands/vm-hands-entry-lite-s2xydt0n.js +112 -0
- package/bin/vm-hands/vm-hands-entry-lite-s5qn1k80.js +4 -0
- package/bin/vm-hands/vm-hands-entry-lite-sv6xwe0h.js +66 -0
- package/bin/vm-hands/vm-hands-entry-lite-y4sjgfqz.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite.js +2 -0
- package/bin/vm-hands/vm-hands-executor-v2qjnrb5.js +9 -0
- package/bin/vm-hands/vm-hands-op-runner-ej1c20a6.js +2 -0
- package/bin/vm-hands/vm-hands-runtime-yyy4ad4z.js +4 -0
- package/bin/vm-hands/worker-sandbox-nnce49w0.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{resolve as a,sep as i}from"path";var c=[[".ssh"],[".gnupg"],[".aws"],[".azure"],[".kube"],[".docker"],[".infisical"],[".password-store"],[".terraform.d"],[".config","ara"],[".config","reason"],[".config","gh"],[".config","gcloud"],[".config","infisical"],[".config","op"],[".config","1password"],[".config","pass"],[".local","share","keyrings"],["library","keychains"],["library","application support","so.ara.desktop"]],l=[[".codex","config.toml"],[".cursor","mcp.json"],[".claude","settings.json"],[".claude","settings.local.json"],[".cargo","credentials"],[".cargo","credentials.toml"],[".gem","credentials"],[".config","git","config"],[".config","git","credentials"],[".config","pip","pip.conf"]],f=new Set([".bash_login",".bash_profile",".bashrc",".bunfig.toml",".claude.json",".env",".envrc",".git-credentials",".gitconfig",".mcp.json",".netrc",".npmrc",".profile",".pypirc",".terraformrc",".yarnrc",".yarnrc.yml",".zlogin",".zlogout",".zprofile",".zshenv",".zshrc","auth.json","credentials.json","credentials.tfrc.json","local-daemon.json","local-device.json","mcp.json"]),g=[".key",".p12",".pfx",".pem"];function t(r,n){if(r.length<n.length)return!1;for(let e=0;e<=r.length-n.length;e+=1)if(n.every((o,s)=>r[e+s]===o))return!0;return!1}function d(r){let n=a(r).split(i).filter(Boolean).map((o)=>o.toLowerCase());if(c.some((o)=>t(n,o)))return!0;if(l.some((o)=>t(n,o)))return!0;let e=n.at(-1)??"";return f.has(e)||e.startsWith(".env.")||g.some((o)=>e.endsWith(o))}
|
|
3
|
+
export{c as Vb,l as Wb,f as Xb,g as Yb,d as Zb};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{jh as m}from"./vm-hands-entry-lite-84aq8d12.js";var E=["Click browser element","Double click browser element","Type text","Clear browser field","Press key","Scroll browser element into view","Drag on computer","Select browser option","Check browser control","Uncheck browser control","Hover browser element","Focus browser element","Open browser page","Reload browser page","Go back in browser","Go forward in browser","Take browser screenshot"],VA=32;function R(x){if(!Array.isArray(x)||x.length>32||!x.every((A)=>typeof A==="string"&&E.includes(A)))return;return x.slice()}var $A="__ARA_PI_TOOL_CONFINED_SCRIPT_5f0c9e2a__",JA=262144;function Y(x){if(!x||typeof x!=="object"||Array.isArray(x))return!1;let A=x,B=Object.keys(A);return B.length===2&&B.includes("template")&&B.includes("quoteDepth")&&typeof A.template==="string"&&A.template.length<=262144&&!A.template.includes("\x00")&&A.template.split("__ARA_PI_TOOL_CONFINED_SCRIPT_5f0c9e2a__").length===2&&(A.quoteDepth===1||A.quoteDepth===2||A.quoteDepth===3)}var X=2,P=33554432,K=200000,D=4000000,Q=240000,DA=`
|
|
3
|
+
...[executor output truncated]`,j=2000,f=1,b=16384,p=32768,w=128,RA=64,i=2097152,h=1,y=16384,d=32768,YA=8388608,s=1000,c=2500,n=2000,LA=c+n,t=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,199}$/,r=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,o={text_only:4430,invalid_json:4431,invalid_cancel_request:4432,invalid_sdk_response:4433,claim_required:4434,invalid_claim:4435,executor_mismatch:4436,stale_generation:4437,fence_conflict:4438,frame_too_large:4439,result_too_large:4440,progress_too_large:4441,terminal_cleanup_started:4442,job_journal_unavailable:4443},v=new Map(Object.entries(o).map(([x,A])=>[A,x]));function OA(x,A){return A||(v.get(x)??"")}var l=["cancelled","command_failed","duplicate_request_id","duplicate_result_evicted","invalid_repl_response","invalid_request","process_group_cleanup_unconfirmed","repl_failed","result_too_large","repl_response_too_large","repl_transport_failed","request_ledger_full","request_journal_unavailable","request_outcome_uncertain","maintenance_held","request_not_found","resume_digest_mismatch","spawn_failed","stale_generation","timeout"],u=new Set(l),a=200,e=2000,AA=["maintenance_held","invalid_job_request","jobs_disabled","job_not_found","job_conflict","job_capacity","job_journal_unavailable","job_not_running","job_lease_expired","job_input_sequence","job_input_backpressure","stale_generation","pty_unsupported","job_mode_mismatch"];class G extends Error{code;constructor(x){super(x);this.name="HandsProtocolError",this.code=x}}function k(x){return new TextEncoder().encode(x).byteLength}function F(x){return typeof x==="object"&&x!==null&&!Array.isArray(x)}function W(x,A){let B=new Set(A);return Object.keys(x).every((N)=>B.has(N))}function M(x){return typeof x==="string"&&t.test(x)}function V(x){return Number.isSafeInteger(x)&&Number(x)>=1}function $(x){return typeof x==="string"&&r.test(x)}function C(x){return typeof x==="string"&&x.startsWith("pty-")&&$(x.slice(4))}function z(x){return[x.cols,x.rows].every((A)=>Number.isSafeInteger(A)&&Number(A)>=1&&Number(A)<=s)}function H(x){if(typeof x!=="string"||x.length>Math.ceil(y/3)*4||x.length%4!==0||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(x))return-1;let A=x.endsWith("==")?2:x.endsWith("=")?1:0;if(A&&"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(x[x.length-A-1])&(A===2?15:3))return-1;let N=x.length/4*3-A;return N<=y?N:-1}function S(x){return typeof x==="string"&&/^[0-9a-f]{64}$/.test(x)}function Z(x){if(k(x)>P)throw new G("frame_too_large");try{return JSON.parse(x)}catch{throw new G("invalid_json")}}function xA(x){let A=Z(x);if(!F(A)||!W(A,["version","generation","id","tool","input","semanticDigest","lifecycleLeaseId"])||A.version!==X||!V(A.generation)||!M(A.id)||!["bash","repl","resume","read","edit","write","pi_tool"].includes(String(A.tool))||!F(A.input)||A.lifecycleLeaseId!==void 0&&(A.tool!=="bash"||!$(A.lifecycleLeaseId)))throw new G("invalid_request");if(A.tool==="bash"){if(!W(A.input,["script","retainBackground","machineSdk"])||typeof A.input.script!=="string"||A.input.script.length>K||A.input.retainBackground!==void 0&&A.input.retainBackground!==!0||A.input.machineSdk!==void 0&&A.input.machineSdk!==!0||A.semanticDigest!==void 0&&!S(A.semanticDigest))throw new G("invalid_request");return{version:X,generation:A.generation,id:A.id,tool:"bash",input:{script:A.input.script,...A.input.retainBackground===!0?{retainBackground:!0}:{},...A.input.machineSdk===!0?{machineSdk:!0}:{}},...A.semanticDigest===void 0?{}:{semanticDigest:A.semanticDigest},...A.lifecycleLeaseId===void 0?{}:{lifecycleLeaseId:A.lifecycleLeaseId}}}if(A.tool==="resume"){if(A.semanticDigest!==void 0||!W(A.input,["semanticDigest"])||!S(A.input.semanticDigest))throw new G("invalid_request");return{version:X,generation:A.generation,id:A.id,tool:"resume",input:{semanticDigest:A.input.semanticDigest}}}if(A.tool==="repl"){if(!W(A.input,["code"])||typeof A.input.code!=="string"||A.input.code.length>K||A.semanticDigest!==void 0)throw new G("invalid_request");return{version:X,generation:A.generation,id:A.id,tool:"repl",input:{code:A.input.code}}}if(A.tool==="pi_tool"){let B=A.semanticDigest===void 0?BA(A.input):null;if(!B)throw new G("invalid_request");return{version:X,generation:A.generation,id:A.id,tool:"pi_tool",input:B}}if(A.tool==="read"){if(!W(A.input,["path","offset","limit"])||typeof A.input.path!=="string"||A.input.path.length<1||A.input.path.length>K||A.semanticDigest!==void 0||A.input.offset!==void 0&&(!Number.isSafeInteger(A.input.offset)||Number(A.input.offset)<1)||A.input.limit!==void 0&&(!Number.isSafeInteger(A.input.limit)||Number(A.input.limit)<1||Number(A.input.limit)>2000))throw new G("invalid_request");return{version:X,generation:A.generation,id:A.id,tool:"read",input:{path:A.input.path,...A.input.offset===void 0?{}:{offset:Number(A.input.offset)},...A.input.limit===void 0?{}:{limit:Number(A.input.limit)}}}}if(A.tool==="edit"){if(!W(A.input,["path","edits"])||typeof A.input.path!=="string"||A.input.path.length<1||!Array.isArray(A.input.edits)||A.input.edits.length<1||A.input.edits.length>128||A.semanticDigest!==void 0)throw new G("invalid_request");let B=A.input.path.length,N=[];for(let I of A.input.edits){if(!F(I)||!W(I,["oldText","newText"])||typeof I.oldText!=="string"||I.oldText.length<1||typeof I.newText!=="string")throw new G("invalid_request");if(B+=I.oldText.length+I.newText.length,B>D)throw new G("invalid_request");N.push({oldText:I.oldText,newText:I.newText})}return{version:X,generation:A.generation,id:A.id,tool:"edit",input:{path:A.input.path,edits:N}}}if(A.tool!=="write"||!W(A.input,["path","content"])||typeof A.input.path!=="string"||A.input.path.length<1||typeof A.input.content!=="string"||A.input.path.length+A.input.content.length>D||A.semanticDigest!==void 0)throw new G("invalid_request");return{version:X,generation:A.generation,id:A.id,tool:"write",input:{path:A.input.path,content:A.input.content}}}function L(x){return x===void 0||typeof x==="number"&&Number.isFinite(x)}function BA(x){let A=x.args;if(!W(x,["tool","args"])||!F(A))return null;if(x.tool==="bash")return W(A,["command","timeout"])&&typeof A.command==="string"&&A.command.length<=K&&L(A.timeout)?{tool:"bash",args:{command:A.command,...A.timeout===void 0?{}:{timeout:Number(A.timeout)}}}:null;if(typeof A.path!=="string"||A.path.length>K)return null;if(x.tool==="read")return W(A,["path","offset","limit"])&&L(A.offset)&&L(A.limit)?{tool:"read",args:{path:A.path,...A.offset===void 0?{}:{offset:Number(A.offset)},...A.limit===void 0?{}:{limit:Number(A.limit)}}}:null;if(x.tool==="write")return W(A,["path","content"])&&typeof A.content==="string"&&A.path.length+A.content.length<=D?{tool:"write",args:{path:A.path,content:A.content}}:null;if(x.tool!=="edit"||!W(A,["path","edits"])||!Array.isArray(A.edits))return null;let B=A.path.length,N=[];for(let I of A.edits){if(!F(I)||!W(I,["oldText","newText"])||typeof I.oldText!=="string"||typeof I.newText!=="string")return null;if(B+=I.oldText.length+I.newText.length,B>D)return null;N.push({oldText:I.oldText,newText:I.newText})}return{tool:"edit",args:{path:A.path,edits:N}}}function WA(x){if(!F(x))return null;if("thrown"in x)return W(x,["thrown"])&&typeof x.thrown==="string"?{thrown:x.thrown}:null;let A=x.structuredContent;if(!W(x,["content","details","structuredContent","isError"])||!Array.isArray(x.content)||x.isError!==void 0&&x.isError!==!0||A!==void 0&&(!F(A)||!W(A,["output","truncated","full_output_path","exit_code","wall_time_seconds"])||typeof A.output!=="string"||typeof A.truncated!=="boolean"||A.full_output_path!==void 0&&typeof A.full_output_path!=="string"||typeof A.exit_code!=="number"||typeof A.wall_time_seconds!=="number"))return null;let B=[];for(let N of x.content)if(F(N)&&N.type==="text"&&W(N,["type","text"])&&typeof N.text==="string")B.push({type:"text",text:N.text});else if(F(N)&&N.type==="image"&&W(N,["type","data","mimeType"])&&typeof N.data==="string"&&typeof N.mimeType==="string")B.push({type:"image",data:N.data,mimeType:N.mimeType});else return null;return{content:B,...x.details===void 0?{}:{details:x.details},...F(A)?{structuredContent:{output:String(A.output),truncated:A.truncated===!0,...typeof A.full_output_path==="string"?{full_output_path:A.full_output_path}:{},exit_code:Number(A.exit_code),wall_time_seconds:Number(A.wall_time_seconds)}}:{},...x.isError===!0?{isError:!0}:{}}}function GA(x){let A=Z(x);if(!F(A)||!W(A,["version","generation","id","ok","exitCode","stdout","stderr","cwd","error","resumed","browserActions","automaticProgressImage","piToolOutcome","workerElapsedMs","environmentWaitMs"])||A.version!==X||!V(A.generation)||!M(A.id)||typeof A.ok!=="boolean"||!Number.isSafeInteger(A.exitCode)||Number(A.exitCode)<0||Number(A.exitCode)>255||typeof A.stdout!=="string"||A.stdout.length>Q||typeof A.stderr!=="string"||A.stderr.length>Q||A.cwd!==void 0&&(typeof A.cwd!=="string"||A.cwd.length<1||A.cwd.length>4096||!A.cwd.startsWith("/")||A.cwd.includes("\x00"))||A.error!==void 0&&(typeof A.error!=="string"||A.error.length<1||A.error.length>j||!u.has(A.error))||A.browserActions!==void 0&&!R(A.browserActions)||A.automaticProgressImage!==void 0&&(A.automaticProgressImage!==!0||!A.ok)||A.resumed!==void 0&&A.resumed!==!0||A.workerElapsedMs!==void 0&&(!Number.isSafeInteger(A.workerElapsedMs)||Number(A.workerElapsedMs)<0)||A.environmentWaitMs!==void 0&&(!Number.isSafeInteger(A.environmentWaitMs)||Number(A.environmentWaitMs)<0)||A.ok&&(A.exitCode!==0||A.error!==void 0)||!A.ok&&A.exitCode===0)throw new G("invalid_result");let B=A.piToolOutcome===void 0?void 0:WA(A.piToolOutcome);if(B===null||B&&!A.ok)throw new G("invalid_result");return{version:X,generation:A.generation,id:A.id,ok:A.ok,exitCode:Number(A.exitCode),stdout:A.stdout,stderr:A.stderr,...typeof A.cwd==="string"?{cwd:A.cwd}:{},...A.browserActions!==void 0?{browserActions:R(A.browserActions)}:{},...typeof A.error==="string"?{error:A.error}:{},...A.automaticProgressImage===!0?{automaticProgressImage:!0}:{},...A.resumed===!0?{resumed:!0}:{},...B?{piToolOutcome:B}:{},...A.workerElapsedMs!==void 0?{workerElapsedMs:Number(A.workerElapsedMs)}:{},...A.environmentWaitMs!==void 0?{environmentWaitMs:Number(A.environmentWaitMs)}:{}}}function NA(x){let A=Z(x);if(!F(A)||!W(A,["type","version","generation","id","sequence","stdout","stderr"])||A.type!=="progress"||A.version!==X||!V(A.generation)||!M(A.id)||!Number.isSafeInteger(A.sequence)||Number(A.sequence)<1||typeof A.stdout!=="string"||A.stdout.length>Q||typeof A.stderr!=="string"||A.stderr.length>Q)throw new G("invalid_progress");return{type:"progress",version:X,generation:Number(A.generation),id:A.id,sequence:Number(A.sequence),stdout:A.stdout,stderr:A.stderr}}function UA(x){let A=Z(x);if(!F(A)||!W(A,["type","version","generation","fenceId","executorLaunchId","requestCancelVersion","managedJobsVersion","browserRunEnvelopeVersion","terminalCleanupVersion","guestMemoryVersion","guestMemoryDiagnosticsVersion","piToolsVersion","piToolsConfinement","backgroundBashVersion","machineSdkVersion","executionTimingVersion","environmentWaitVersion"])||A.type!=="claim"||A.version!==X||!V(A.generation)||!$(A.fenceId)||!$(A.executorLaunchId)||A.requestCancelVersion!==void 0&&A.requestCancelVersion!==1||A.managedJobsVersion!==void 0&&A.managedJobsVersion!==f||A.guestMemoryVersion!==void 0&&A.guestMemoryVersion!==1||A.guestMemoryDiagnosticsVersion!==void 0&&(A.guestMemoryDiagnosticsVersion!==1||A.guestMemoryVersion!==1)||A.terminalCleanupVersion!==void 0&&A.terminalCleanupVersion!==1||A.browserRunEnvelopeVersion!==void 0&&A.browserRunEnvelopeVersion!==1||A.piToolsVersion!==void 0&&A.piToolsVersion!==1||A.piToolsConfinement!==void 0&&(!Y(A.piToolsConfinement)||A.piToolsVersion!==1)||A.backgroundBashVersion!==void 0&&A.backgroundBashVersion!==1||A.machineSdkVersion!==void 0&&A.machineSdkVersion!==1||A.executionTimingVersion!==void 0&&A.executionTimingVersion!==1||A.environmentWaitVersion!==void 0&&(A.environmentWaitVersion!==1||A.executionTimingVersion!==1))throw new G("invalid_claim");return{type:"claim",version:X,generation:A.generation,fenceId:A.fenceId,executorLaunchId:A.executorLaunchId,...A.requestCancelVersion===1?{requestCancelVersion:1}:{},...A.managedJobsVersion===1?{managedJobsVersion:1}:{},...A.guestMemoryVersion===1?{guestMemoryVersion:1}:{},...A.guestMemoryDiagnosticsVersion===1?{guestMemoryDiagnosticsVersion:1}:{},...A.terminalCleanupVersion===1?{terminalCleanupVersion:1}:{},...A.browserRunEnvelopeVersion===1?{browserRunEnvelopeVersion:1}:{},...A.piToolsVersion===1?{piToolsVersion:1}:{},...Y(A.piToolsConfinement)?{piToolsConfinement:{template:A.piToolsConfinement.template,quoteDepth:A.piToolsConfinement.quoteDepth}}:{},...A.backgroundBashVersion===1?{backgroundBashVersion:1}:{},...A.machineSdkVersion===1?{machineSdkVersion:1}:{},...A.executionTimingVersion===1?{executionTimingVersion:1}:{},...A.environmentWaitVersion===1?{environmentWaitVersion:1}:{}}}function FA(x){let A=Z(x);if(!F(A)||!W(A,["type","version","generation","fenceId","executorLaunchId","workerVersion","workerArtifactSha256","requestCancelVersion","managedJobsVersion","lifecycleVersion","browserRunEnvelopeVersion","terminalCleanupVersion","guestMemoryVersion","guestMemoryDiagnosticsVersion","piToolsVersion","piToolsConfinementVersion","backgroundBashVersion","machineSdkVersion","executionTimingVersion","environmentWaitVersion"])||A.lifecycleVersion!==void 0&&A.lifecycleVersion!==1||A.piToolsVersion!==void 0&&A.piToolsVersion!==1||A.piToolsConfinementVersion!==void 0&&(A.piToolsConfinementVersion!==1||A.piToolsVersion!==1)||A.backgroundBashVersion!==void 0&&A.backgroundBashVersion!==1||A.machineSdkVersion!==void 0&&A.machineSdkVersion!==1||A.executionTimingVersion!==void 0&&A.executionTimingVersion!==1||A.environmentWaitVersion!==void 0&&(A.environmentWaitVersion!==1||A.executionTimingVersion!==1)||A.guestMemoryVersion!==void 0&&A.guestMemoryVersion!==1||A.guestMemoryDiagnosticsVersion!==void 0&&(A.guestMemoryDiagnosticsVersion!==1||A.guestMemoryVersion!==1)||A.terminalCleanupVersion!==void 0&&A.terminalCleanupVersion!==1||A.browserRunEnvelopeVersion!==void 0&&A.browserRunEnvelopeVersion!==1||A.type!=="claim_ack"||A.version!==X||!V(A.generation)||!$(A.fenceId)||!$(A.executorLaunchId)||!Number.isSafeInteger(A.workerVersion)||Number(A.workerVersion)<1||!S(A.workerArtifactSha256)||A.requestCancelVersion!==void 0&&A.requestCancelVersion!==1||A.managedJobsVersion!==void 0&&A.managedJobsVersion!==f)throw new G("invalid_claim_ack");return{type:"claim_ack",...A.guestMemoryVersion===1?{guestMemoryVersion:1}:{},...A.guestMemoryDiagnosticsVersion===1?{guestMemoryDiagnosticsVersion:1}:{},...A.terminalCleanupVersion===1?{terminalCleanupVersion:1}:{},...A.browserRunEnvelopeVersion===1?{browserRunEnvelopeVersion:1}:{},...A.lifecycleVersion===1?{lifecycleVersion:1}:{},...A.piToolsVersion===1?{piToolsVersion:1}:{},...A.piToolsConfinementVersion===1?{piToolsConfinementVersion:1}:{},...A.backgroundBashVersion===1?{backgroundBashVersion:1}:{},...A.machineSdkVersion===1?{machineSdkVersion:1}:{},...A.executionTimingVersion===1?{executionTimingVersion:1}:{},...A.environmentWaitVersion===1?{environmentWaitVersion:1}:{},version:X,generation:A.generation,fenceId:A.fenceId,executorLaunchId:A.executorLaunchId,workerVersion:Number(A.workerVersion),workerArtifactSha256:A.workerArtifactSha256,...A.requestCancelVersion===1?{requestCancelVersion:1}:{},...A.managedJobsVersion===1?{managedJobsVersion:1}:{}}}function zA(x){let A=Z(x);if(!F(A)||!W(A,["type","version","generation","id","jobId","action","input"])||A.type!=="job"||A.version!==X||!V(A.generation)||!M(A.id)||!M(A.jobId)||!F(A.input))throw new G("invalid_job_request");let B=A.input,N=Number.isSafeInteger(B.leaseExpiresAtMs)&&Number(B.leaseExpiresAtMs)>0,I=Number.isSafeInteger(B.sequence)&&Number(B.sequence)>=1;if(!(A.action==="start"?B.mode==="pty"?W(B,["mode","cols","rows","leaseExpiresAtMs"])&&C(A.jobId)&&z(B)&&N:W(B,["script","leaseExpiresAtMs"])&&typeof B.script==="string"&&B.script.length<=K&&N:A.action==="inspect"?W(B,["after"])&&Number.isSafeInteger(B.after)&&Number(B.after)>=0:A.action==="input"?"dataBase64"in B?W(B,["sequence","dataBase64"])&&C(A.jobId)&&I&&H(B.dataBase64)>0:W(B,["sequence","data","eof"])&&I&&typeof B.data==="string"&&B.data.length<=b&&typeof B.eof==="boolean":A.action==="resize"?W(B,["sequence","cols","rows"])&&C(A.jobId)&&I&&z(B):A.action==="renew"?W(B,["leaseExpiresAtMs"])&&N:A.action==="cancel"&&W(B,[])))throw new G("invalid_job_request");return A}function IA(x){let A=Z(x);if(!F(A)||!W(A,["type","version","generation","id","ok","job","error"])||A.type!=="job_result"||A.version!==X||!V(A.generation)||!M(A.id))throw new G("invalid_job_result");if(A.ok===!1&&A.job===void 0&&typeof A.error==="string"&&AA.some((U)=>U===A.error))return A;let B=A.job;if(A.ok!==!0||A.error!==void 0||!F(B)||!W(B,["jobId","state","startedAtMs","finishedAtMs","leaseExpiresAtMs","exitCode","inputSequence","output","firstCursor","nextCursor","truncated","process","environmentRevision","environmentSnapshotId","pty"])||!M(B.jobId)||!["starting","running","exited","cancelled","expired","uncertain"].includes(String(B.state))||!Number.isSafeInteger(B.startedAtMs)||Number(B.startedAtMs)<1||!Number.isSafeInteger(B.leaseExpiresAtMs)||Number(B.leaseExpiresAtMs)<1||B.finishedAtMs!==null&&(!Number.isSafeInteger(B.finishedAtMs)||Number(B.finishedAtMs)<Number(B.startedAtMs))||B.exitCode!==null&&(!Number.isSafeInteger(B.exitCode)||Number(B.exitCode)<0||Number(B.exitCode)>255)||!Number.isSafeInteger(B.inputSequence)||Number(B.inputSequence)<0||!Number.isSafeInteger(B.firstCursor)||Number(B.firstCursor)<1||!Number.isSafeInteger(B.nextCursor)||Number(B.nextCursor)<Number(B.firstCursor)-1||typeof B.truncated!=="boolean"||!Array.isArray(B.output)||B.output.length>w)throw new G("invalid_job_result");if(B.environmentRevision===void 0!==(B.environmentSnapshotId===void 0)||B.environmentRevision!==void 0&&(!Number.isSafeInteger(B.environmentRevision)||Number(B.environmentRevision)<1||!$(B.environmentSnapshotId)))throw new G("invalid_job_result");let N=Number(B.firstCursor)-1,I=0;for(let U of B.output){if(!F(U)||!W(U,["cursor","stream","text"])||!Number.isSafeInteger(U.cursor)||Number(U.cursor)<=N||Number(U.cursor)>Number(B.nextCursor)||!["stdout","stderr"].includes(String(U.stream))||typeof U.text!=="string")throw new G("invalid_job_result");I+=U.text.length,N=Number(U.cursor)}if(I>p)throw new G("invalid_job_result");let _=B.state==="starting"||B.state==="running";if(_&&(B.finishedAtMs!==null||B.exitCode!==null)||!_&&B.finishedAtMs===null||B.state==="uncertain"&&B.exitCode!==null||B.state==="exited"&&B.exitCode===null||B.state==="cancelled"&&B.exitCode!==130||B.state==="expired"&&B.exitCode!==124)throw new G("invalid_job_result");if(B.process!==void 0){let U=B.process;if(!F(U)||!W(U,["pid","processGroupId","executorLaunchId"])||!Number.isSafeInteger(U.pid)||Number(U.pid)<1||U.processGroupId!==U.pid||!$(U.executorLaunchId)||!["starting","running"].includes(String(B.state)))throw new G("invalid_job_result")}if(B.pty!==void 0){let U=B.pty;if(!F(U)||!W(U,["version","cols","rows","output","cleanup"])||U.version!==h||!C(B.jobId)||!z(U)||B.output.length!==0||!Array.isArray(U.output)||U.output.length>w||(_?U.cleanup!=="pending":B.state==="uncertain"?U.cleanup!=="unconfirmed":U.cleanup!=="confirmed")||B.state==="running"&&(B.process===void 0||B.environmentRevision===void 0))throw new G("invalid_job_result");let T=Number(B.firstCursor)-1,g=0;for(let J of U.output){if(!F(J)||!W(J,["cursor","dataBase64"])||!Number.isSafeInteger(J.cursor)||Number(J.cursor)<=T||Number(J.cursor)>Number(B.nextCursor))throw new G("invalid_job_result");let q=H(J.dataBase64);if(q<=0||(g+=q)>d)throw new G("invalid_job_result");T=Number(J.cursor)}}return A}function SA(x){if(k(x)>i)throw new G("frame_too_large");let A=Z(x);if(!F(A)||!W(A,["version","sessionId","operationId","runId","deviceId","rootId","workspace","binding","targetRevision","rootGrantRevision","generation","fenceId","executorLaunchId","job"])||A.version!==h||![A.sessionId,A.operationId,A.runId].every(M)||![A.deviceId,A.rootId,A.fenceId,A.executorLaunchId].every($)||!V(A.generation)||!Number.isSafeInteger(A.rootGrantRevision)||Number(A.rootGrantRevision)<1||!["workspace_source","mcp_control"].includes(String(A.binding))||!Number.isSafeInteger(A.targetRevision)||Number(A.targetRevision)<0||A.binding==="workspace_source"&&A.targetRevision!==0||!F(A.workspace))throw new G("invalid_pty_receipt");if(!m(A.workspace))throw new G("invalid_pty_receipt");let B=IA(JSON.stringify({type:"job_result",version:X,generation:A.generation,id:A.operationId,ok:!0,job:A.job}));if(!B.ok||!B.job.pty||B.job.pty.output.length!==0||B.job.process&&B.job.process.executorLaunchId!==A.executorLaunchId)throw new G("invalid_pty_receipt");return A}function TA(x){let A=Z(x);if(!F(A)||!W(A,["type","version","generation","id","targetId"])||A.type!=="cancel_request"||A.version!==X||!V(A.generation)||!M(A.id)||!M(A.targetId))throw new G("invalid_cancel_request");return A}function qA(x){let A=Z(x);if(!F(A)||!W(A,["type","version","generation","id","targetId","status"])||A.type!=="cancel_ack"||A.version!==X||!V(A.generation)||!M(A.id)||!M(A.targetId)||!["cancelled","settled","not_found","unsupported","unconfirmed"].includes(String(A.status)))throw new G("invalid_cancel_ack");return A}function wA(x){let A=JSON.stringify(x);return xA(A),A}function yA(x){let A=JSON.stringify(x);return GA(A),A}function mA(x){let A=JSON.stringify(x);return NA(A),A}function fA(x){let A=JSON.stringify(x);return UA(A),A}function hA(x){let A=JSON.stringify(x);return FA(A),A}function O(x){return typeof x==="string"&&x.length>=1&&x.length<=a&&!x.includes("\x00")}function XA(x){let A=["type","version","generation","id","jobRequestId","verb"];if(x.verb==="help")return W(x,A)?{verb:"help"}:null;if(x.verb==="describe"||x.verb==="namespace")return W(x,[...A,"name"])&&O(x.name)?{verb:x.verb,name:x.name}:null;if(x.verb==="search"){let B=x.args;if(!W(x,[...A,"query","args"])||typeof x.query!=="string"||x.query.trim().length<1||x.query.length>e)return null;if(B===void 0)return{verb:"search",query:x.query};if(!F(B)||!W(B,["namespace","limit"])||B.namespace!==void 0&&!O(B.namespace)||B.limit!==void 0&&(!Number.isSafeInteger(B.limit)||Number(B.limit)<1||Number(B.limit)>50))return null;return{verb:"search",query:x.query,args:{...typeof B.namespace==="string"?{namespace:B.namespace}:{},...B.limit===void 0?{}:{limit:Number(B.limit)}}}}if(x.verb!=="call"||!W(x,[...A,"name","args"])||!O(x.name)||!F(x.args)||JSON.stringify(x.args).length>K)return null;return{verb:"call",name:x.name,args:x.args}}function kA(x){let A=Z(x);if(!F(A)||A.type!=="sdk_request"||A.version!==X||!V(A.generation)||!M(A.id)||!M(A.jobRequestId))throw new G("invalid_sdk_request");let B=XA(A);if(!B)throw new G("invalid_sdk_request");return{type:"sdk_request",version:X,generation:Number(A.generation),id:A.id,jobRequestId:A.jobRequestId,...B}}function MA(x){let A=Z(x);if(!F(A)||A.type!=="sdk_response"||A.version!==X||!V(A.generation)||!M(A.id))throw new G("invalid_sdk_response");let B={type:"sdk_response",version:X,generation:Number(A.generation),id:A.id},N=["type","version","generation","id","ok"];if(A.ok===!0&&W(A,[...N,"result"])&&typeof A.result==="string"&&A.result.length<=Q)return{...B,ok:!0,result:A.result};if(A.ok===!1&&W(A,[...N,"error"])&&typeof A.error==="string"&&A.error.length>=1&&A.error.length<=Q)return{...B,ok:!1,error:A.error};throw new G("invalid_sdk_response")}function HA(x){let A=JSON.stringify(x);return MA(A),A}
|
|
4
|
+
export{VA as ef,$A as ff,JA as gf,X as hf,P as if,K as jf,D as kf,Q as lf,DA as mf,j as nf,f as of,b as pf,p as qf,w as rf,RA as sf,i as tf,h as uf,y as vf,d as wf,YA as xf,s as yf,c as zf,n as Af,LA as Bf,o as Cf,OA as Df,l as Ef,a as Ff,e as Gf,AA as Hf,G as If,M as Jf,V as Kf,$ as Lf,C as Mf,S as Nf,xA as Of,GA as Pf,NA as Qf,UA as Rf,FA as Sf,zA as Tf,IA as Uf,SA as Vf,TA as Wf,qA as Xf,wA as Yf,yA as Zf,mA as _f,fA as $f,hA as ag,kA as bg,MA as cg,HA as dg};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Zb as X}from"./vm-hands-entry-lite-n07kxrd1.js";import{spawn as M}from"child_process";import{existsSync as C}from"fs";import{homedir as g}from"os";import{basename as D,join as N}from"path";var Y="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",G=Y.split(":"),f=5000,I=65536,U=new Set(["zsh","bash"]),V=[[".local","bin"],[".bun","bin"],[".cargo","bin"],["go","bin"]],j=(J,K)=>new Promise((W,Z)=>{let Q;try{Q=M(J,[...K],{detached:!0,stdio:["ignore","pipe","ignore"]})}catch($){Z($);return}let z=[],x=0,R=null,B=($)=>{R??=Error($);try{if(Q.pid!==void 0)process.kill(-Q.pid,"SIGKILL")}catch{}},F=setTimeout(()=>B("login_shell_timeout"),f);Q.stdout?.on("data",($)=>{if(x+=$.length,x>I)B("login_shell_output_too_large");else z.push($)}),Q.once("error",($)=>{clearTimeout(F),Z($)}),Q.once("close",($)=>{if(clearTimeout(F),R)Z(R);else if($!==0)Z(Error("login_shell_exit_nonzero"));else W(Buffer.concat(z).toString("utf8"))})});function O(J){return typeof J==="string"&&J.startsWith("/")&&!J.includes("\x00")&&U.has(D(J))}function q(J){let K=new Set,W=[];for(let Z of J){if(K.has(Z))continue;K.add(Z),W.push(Z)}return W}function H(J){let K=J.split(`
|
|
3
|
+
`).at(-1)??"",W=[];for(let Z of K.split(":")){let Q=Z.trim();if(!Q.startsWith("/"))continue;if(Q.includes("\x00"))continue;if(X(Q))continue;W.push(Q)}return q(W)}function k(J){let K=J?.home??g(),W=J?.directoryExists??C,Z=V.map((Q)=>N(K,...Q)).filter((Q)=>{try{return W(Q)}catch{return!1}});return q([...Z,...G]).join(":")}async function S(J){let K=J?.shell??process.env.SHELL,W=()=>({path:k({home:J?.home,directoryExists:J?.directoryExists}),source:"fallback"});if(!O(K))return W();let Z;try{Z=await(J?.runLoginShell??j)(K,["-lic",'printf %s "$PATH"'])}catch{return W()}if(Buffer.byteLength(Z,"utf8")>I)return W();let Q=H(Z);if(Q.length===0)return W();return{path:q([...Q,...G]).join(":"),source:"login_shell"}}function v(J){let K=null;return()=>{return K??=S(J),K}}function w(J){if(J===void 0||J.includes("\x00")||Buffer.byteLength(J,"utf8")>32768)return;return J}function P(J){let K=J.source??process.env,W={HOME:J.home,PATH:J.path??Y,TMPDIR:J.temporaryDirectory,SHELL:w(K.SHELL)??"/bin/zsh",LANG:w(K.LANG)??"C.UTF-8",LC_ALL:w(K.LC_ALL)??w(K.LANG)??"C.UTF-8"},Z=w(K.LC_CTYPE),Q=w(K.TERM),z=w(K.COLORTERM);if(Z)W.LC_CTYPE=Z;if(Q)W.TERM=Q;if(z)W.COLORTERM=z;return W}
|
|
4
|
+
export{Y as Qb,H as Rb,k as Sb,v as Tb,P as Ub};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Gh as l}from"./vm-hands-entry-lite-ffg7rf02.js";import{execFile as zj,spawn as I}from"child_process";var Cj="h264_ws_v1",kj="video",h=["smooth","sharp","data_saver","balanced"];var Yj="video_presets";var V=8388608,Y=65536,Lj="control",Aj="v1",d=200;function s(q){if(!q||typeof q!=="object"||Array.isArray(q))return null;let j=q,J=(Q)=>typeof Q==="string"&&Q.length>0&&Q.length<=d;if(Object.keys(j).length!==2||!J(j.user_id)||!J(j.name))return null;return{user_id:j.user_id,name:j.name}}var xj="windows",Mj="v1",A=200,o=(q)=>typeof q==="string"&&h.includes(q);function fj(q){if(!q||typeof q!=="object"||Array.isArray(q))return null;let j=q;if(Object.keys(j).length!==2||j.format!=="h264_ws_v1"||!o(j.preset))return null;return{format:"h264_ws_v1",preset:j.preset}}var $={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};class U extends Error{constructor(q){super(q);this.name="DisplayVideoProtocolError"}}var e=new TextEncoder,jj=new TextDecoder("utf-8",{fatal:!0});function H(q,j){if(j.byteLength+1>V)throw new U("message_too_large");let J=new Uint8Array(5+j.byteLength),Q=new DataView(J.buffer);return Q.setUint32(0,j.byteLength+1),Q.setUint8(4,q),J.set(j,5),J}function R(q){let j=e.encode(q);if(j.byteLength>Y)throw new U("text_too_large");return j}function f(q,j){if(!Number.isInteger(q)||q<0||q>65535)throw new U(`invalid_${j}`);return q}function qj(q){if(!Number.isFinite(q))throw new U("invalid_window");return Math.max(-2147483648,Math.min(2147483647,Math.round(q)))}function hj(q){switch(q.type){case"hello":{let j=R(q.codec),J=new Uint8Array(6+j.byteLength),Q=new DataView(J.buffer);return Q.setUint16(0,f(q.width,"width")),Q.setUint16(2,f(q.height,"height")),Q.setUint8(4,Math.max(1,Math.min(240,Math.round(q.fps)))),Q.setUint8(5,h.indexOf(q.preset)),J.set(j,6),H($.hello,J)}case"frame":{let j=new Uint8Array(13+q.data.byteLength),J=new DataView(j.buffer);return J.setUint8(0,q.key?1:0),J.setUint32(1,q.seq>>>0),J.setBigUint64(5,BigInt(Math.max(0,Math.floor(q.captureMicros)))),j.set(q.data,13),H($.frame,j)}case"stats":return H($.stats,R(JSON.stringify(q.stats)));case"pong":case"ping":{let j=new Uint8Array(8);return new DataView(j.buffer).setFloat64(0,q.token),H(q.type==="ping"?$.ping:$.pong,j)}case"serverClipboard":return H($.serverClipboard,R(q.text));case"clientClipboard":return H($.clientClipboard,R(q.text));case"error":return H($.error,R(q.code));case"pointer":{let j=new Uint8Array(5),J=new DataView(j.buffer);return J.setUint16(0,f(q.x,"x")),J.setUint16(2,f(q.y,"y")),J.setUint8(4,q.buttons&255),H($.pointer,j)}case"key":{let j=new Uint8Array(5),J=new DataView(j.buffer);return J.setUint8(0,q.down?1:0),J.setUint32(1,q.keysym>>>0),H($.key,j)}case"config":return H($.config,Uint8Array.of(h.indexOf(q.preset)));case"keyframeRequest":return H($.keyframeRequest,new Uint8Array(0));case"audioHello":{let j=R(q.codec),J=new Uint8Array(5+j.byteLength),Q=new DataView(J.buffer);return Q.setUint32(0,q.sampleRate>>>0),Q.setUint8(4,q.channels&255),J.set(j,5),H($.audioHello,J)}case"audio":{let j=new Uint8Array(8+q.data.byteLength);return new DataView(j.buffer).setBigUint64(0,BigInt(Math.max(0,Math.floor(q.captureMicros)))),j.set(q.data,8),H($.audio,j)}case"control":return H($.control,R(JSON.stringify(q.control)));case"windows":{let j=q.bounds.slice(0,A),J=new Uint8Array(j.length*16),Q=new DataView(J.buffer);return j.forEach((Z,z)=>{[Z.x,Z.y,Z.width,Z.height].forEach((G,F)=>Q.setInt32(z*16+F*4,qj(G)))}),H($.windows,J)}case"audioEnable":return H($.audioEnable,Uint8Array.of(q.on?1:0));case"ack":{let j=new Uint8Array(4);return new DataView(j.buffer).setUint32(0,q.seq>>>0),H($.ack,j)}}}function T(q){let j=h[q];if(!j)throw new U("invalid_preset");return j}function C(q,j){if(q.byteLength!==j)throw new U("invalid_length")}function k(q){if(q.byteLength>Y)throw new U("text_too_large");try{return jj.decode(q)}catch{throw new U("invalid_text")}}function Jj(q){let j;try{j=JSON.parse(k(q))}catch{throw new U("invalid_stats")}let J=j;if(!J||typeof J!=="object"||["fps","kbps","dropped","restarts","queued_bytes"].some((Z)=>typeof J[Z]!=="number"||!Number.isFinite(J[Z])))throw new U("invalid_stats");return{fps:J.fps,kbps:J.kbps,dropped:J.dropped,restarts:J.restarts,queued_bytes:J.queued_bytes}}function Qj(q){let j;try{j=JSON.parse(k(q))}catch{throw new U("invalid_control")}let J=j;if(!J||typeof J!=="object"||typeof J.you!=="boolean"||typeof J.same_user!=="boolean")throw new U("invalid_control");let Q=J.holder===null?null:s(J.holder);if(Q===null&&J.holder!==null)throw new U("invalid_control");return{holder:Q,you:J.you,same_user:J.same_user}}function Zj(q,j){let J=new DataView(j.buffer,j.byteOffset,j.byteLength);switch(q){case $.hello:if(j.byteLength<6)throw new U("invalid_length");return{type:"hello",width:J.getUint16(0),height:J.getUint16(2),fps:J.getUint8(4),preset:T(J.getUint8(5)),codec:k(j.subarray(6))};case $.frame:if(j.byteLength<14)throw new U("invalid_length");if(J.getUint8(0)>1)throw new U("invalid_frame_flags");return{type:"frame",key:J.getUint8(0)===1,seq:J.getUint32(1),captureMicros:Number(J.getBigUint64(5)),data:j.subarray(13)};case $.stats:return{type:"stats",stats:Jj(j)};case $.ping:case $.pong:return C(j,8),{type:q===$.ping?"ping":"pong",token:J.getFloat64(0)};case $.serverClipboard:return{type:"serverClipboard",text:k(j)};case $.clientClipboard:return{type:"clientClipboard",text:k(j)};case $.error:return{type:"error",code:k(j)};case $.pointer:return C(j,5),{type:"pointer",x:J.getUint16(0),y:J.getUint16(2),buttons:J.getUint8(4)};case $.key:if(C(j,5),J.getUint8(0)>1)throw new U("invalid_key_flags");return{type:"key",down:J.getUint8(0)===1,keysym:J.getUint32(1)};case $.config:return C(j,1),{type:"config",preset:T(J.getUint8(0))};case $.keyframeRequest:return C(j,0),{type:"keyframeRequest"};case $.audioHello:if(j.byteLength<5)throw new U("invalid_length");return{type:"audioHello",sampleRate:J.getUint32(0),channels:J.getUint8(4),codec:k(j.subarray(5))};case $.audio:if(j.byteLength<9)throw new U("invalid_length");return{type:"audio",captureMicros:Number(J.getBigUint64(0)),data:j.subarray(8)};case $.audioEnable:if(C(j,1),J.getUint8(0)>1)throw new U("invalid_audio_flags");return{type:"audioEnable",on:J.getUint8(0)===1};case $.control:return{type:"control",control:Qj(j)};case $.windows:{if(j.byteLength%16!==0||j.byteLength>A*16)throw new U("invalid_length");let Q=[];for(let Z=0;Z<j.byteLength;Z+=16)Q.push({x:J.getInt32(Z),y:J.getInt32(Z+4),width:J.getInt32(Z+8),height:J.getInt32(Z+12)});return{type:"windows",bounds:Q}}case $.ack:return C(j,4),{type:"ack",seq:J.getUint32(0)};default:return null}}class $j{buffer=new Uint8Array(0);push(q){let j=new Uint8Array(this.buffer.byteLength+q.byteLength);j.set(this.buffer),j.set(q,this.buffer.byteLength);let J=[],Q=0;while(j.byteLength-Q>=4){let Z=new DataView(j.buffer,j.byteOffset+Q,4).getUint32(0);if(Z<1||Z>V)throw new U("invalid_message_length");if(j.byteLength-Q-4<Z)break;let z=j[Q+4],G=j.slice(Q+5,Q+4+Z),F=Zj(z,G);if(F)J.push(F);Q+=4+Z}return this.buffer=j.slice(Q),J}}var t="/usr/bin/osascript",Gj=5000,Kj=1048576,Uj=String.raw`
|
|
3
|
+
ObjC.import("CoreGraphics");
|
|
4
|
+
ObjC.import("ApplicationServices");
|
|
5
|
+
ObjC.import("AppKit");
|
|
6
|
+
ObjC.bindFunction("CGPreflightScreenCaptureAccess", ["bool", []]);
|
|
7
|
+
ObjC.bindFunction("CGRequestScreenCaptureAccess", ["bool", []]);
|
|
8
|
+
ObjC.bindFunction("getppid", ["int", []]);
|
|
9
|
+
function run(argv) {
|
|
10
|
+
const bounds = $.CGDisplayBounds($.CGMainDisplayID());
|
|
11
|
+
const stdout = $.NSFileHandle.fileHandleWithStandardOutput;
|
|
12
|
+
const screen = $.CGPreflightScreenCaptureAccess(), accessibility = $.AXIsProcessTrusted();
|
|
13
|
+
stdout.writeData($(JSON.stringify({ screen, accessibility,
|
|
14
|
+
width: bounds.size.width, height: bounds.size.height }) + "\n").dataUsingEncoding($.NSUTF8StringEncoding));
|
|
15
|
+
if (argv[0] === "request") {
|
|
16
|
+
if (!screen && argv[1] !== "accessibility") $.CGRequestScreenCaptureAccess();
|
|
17
|
+
if (!accessibility && argv[1] !== "screen") $.AXIsProcessTrustedWithOptions($({ AXTrustedCheckOptionPrompt: true }));
|
|
18
|
+
}
|
|
19
|
+
if (argv[0] === "probe" || argv[0] === "request") return;
|
|
20
|
+
if (argv[0] === "clipboard") {
|
|
21
|
+
const parent = $.getppid(), clipboard = $.NSPasteboard.generalPasteboard;
|
|
22
|
+
// Only changes made during this pairing: never export the initial pasteboard.
|
|
23
|
+
let last = Number(clipboard.changeCount);
|
|
24
|
+
while ($.getppid() === parent) {
|
|
25
|
+
$.NSThread.sleepForTimeInterval(0.1);
|
|
26
|
+
const count = Number(clipboard.changeCount);
|
|
27
|
+
if (count === last) continue;
|
|
28
|
+
last = count;
|
|
29
|
+
const text = clipboard.stringForType($.NSPasteboardTypeString);
|
|
30
|
+
if (!text) continue;
|
|
31
|
+
const bytes = text.dataUsingEncoding($.NSUTF8StringEncoding);
|
|
32
|
+
if (Number(bytes.length) > ${Y}) continue;
|
|
33
|
+
stdout.writeData($("c " + bytes.base64EncodedStringWithOptions(0).js + "\n").dataUsingEncoding($.NSUTF8StringEncoding));
|
|
34
|
+
}
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const stdin = $.NSFileHandle.fileHandleWithStandardInput;
|
|
38
|
+
let pending = "";
|
|
39
|
+
for (;;) {
|
|
40
|
+
const data = stdin.availableData;
|
|
41
|
+
if (Number(data.length) === 0) return;
|
|
42
|
+
pending += $.NSString.alloc.initWithDataEncoding(data, $.NSUTF8StringEncoding).js;
|
|
43
|
+
for (let end = pending.indexOf("\n"); end >= 0; end = pending.indexOf("\n")) {
|
|
44
|
+
const [kind, ...rest] = pending.slice(0, end).split(" ");
|
|
45
|
+
pending = pending.slice(end + 1);
|
|
46
|
+
const n = rest.map(Number);
|
|
47
|
+
let event = null;
|
|
48
|
+
if (kind === "m") {
|
|
49
|
+
event = $.CGEventCreateMouseEvent($(), n[0], { x: n[1], y: n[2] }, n[3]);
|
|
50
|
+
$.CGEventSetIntegerValueField(event, $.kCGMouseEventClickState, n[4]);
|
|
51
|
+
} else if (kind === "w") {
|
|
52
|
+
event = $.CGEventCreateScrollWheelEvent($(), $.kCGScrollEventUnitPixel, 2, n[0], n[1]);
|
|
53
|
+
} else if (kind === "k") {
|
|
54
|
+
event = $.CGEventCreateKeyboardEvent($(), n[0], n[1] === 1);
|
|
55
|
+
} else if (kind === "u") {
|
|
56
|
+
event = $.CGEventCreateKeyboardEvent($(), 0, n[0] === 1);
|
|
57
|
+
const unit = Ref("unsigned short");
|
|
58
|
+
unit[0] = n[1];
|
|
59
|
+
$.CGEventKeyboardSetUnicodeString(event, 1, unit);
|
|
60
|
+
} else if (kind === "c") {
|
|
61
|
+
const bytes = $.NSData.alloc.initWithBase64EncodedStringOptions($(rest[0] || ""), 0);
|
|
62
|
+
$.NSPasteboard.generalPasteboard.clearContents;
|
|
63
|
+
$.NSPasteboard.generalPasteboard.setStringForType($.NSString.alloc.initWithDataEncoding(bytes, $.NSUTF8StringEncoding), $.NSPasteboardTypeString);
|
|
64
|
+
}
|
|
65
|
+
if (event) {
|
|
66
|
+
$.CGEventSetFlags(event, n[n.length - 1]);
|
|
67
|
+
$.CGEventPost($.kCGHIDEventTap, event);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
`;function y(q){let j;try{j=JSON.parse(q)}catch{return null}if(!j||typeof j!=="object")return null;let J=j,Q=(G)=>typeof G==="number"&&Number.isFinite(G)?Math.min(65535,Math.round(G)):0;if(typeof J.screen!=="boolean"||typeof J.accessibility!=="boolean")return null;let Z=Q(J.width),z=Q(J.height);return Z>0&&z>0?{screen:J.screen,accessibility:J.accessibility,width:Z,height:z}:null}function w(q,...j){let[J,...Q]=[...q,t,"-l","JavaScript","-e",Uj,...j];return[J,Q]}function r(q,...j){return new Promise((J)=>{zj(...w(q,...j),{env:{},timeout:Gj,killSignal:"SIGKILL",maxBuffer:65536,encoding:"utf8"},(Q,Z)=>J(Q?null:y(Z.split(`
|
|
73
|
+
`)[0]??"")))})}function Sj(q=[]){return r(q,"probe")}function _j(q,j){return r(q,"request",...j?[j]:[])}var u=2,Fj=8,Bj=String.raw`
|
|
74
|
+
ObjC.import("CoreGraphics");
|
|
75
|
+
ObjC.import("Foundation");
|
|
76
|
+
ObjC.bindFunction("getppid", ["int", []]);
|
|
77
|
+
function run() {
|
|
78
|
+
const stdout = $.NSFileHandle.fileHandleWithStandardOutput;
|
|
79
|
+
const parent = $.getppid();
|
|
80
|
+
let last = "";
|
|
81
|
+
let wait = ${u};
|
|
82
|
+
// Ends with the worker that started it, even one that never got to kill it.
|
|
83
|
+
while ($.getppid() === parent) {
|
|
84
|
+
const list = ObjC.castRefToObject($.CGWindowListCopyWindowInfo($.kCGWindowListOptionOnScreenOnly | $.kCGWindowListExcludeDesktopElements, 0));
|
|
85
|
+
const bounds = [];
|
|
86
|
+
const count = Number(list.count);
|
|
87
|
+
for (let i = 0; i < count && bounds.length < ${A}; i++) {
|
|
88
|
+
const window = list.objectAtIndex(i);
|
|
89
|
+
if (Number(window.objectForKey("kCGWindowLayer").js) !== 0) continue;
|
|
90
|
+
const b = window.objectForKey("kCGWindowBounds");
|
|
91
|
+
bounds.push(["X", "Y", "Width", "Height"].map((key) => Math.round(Number(b.objectForKey(key).js))));
|
|
92
|
+
}
|
|
93
|
+
const line = JSON.stringify(bounds);
|
|
94
|
+
if (line !== last) {
|
|
95
|
+
last = line;
|
|
96
|
+
wait = ${u};
|
|
97
|
+
stdout.writeData($(line + "\n").dataUsingEncoding($.NSUTF8StringEncoding));
|
|
98
|
+
} else {
|
|
99
|
+
wait = Math.min(wait * 2, ${Fj});
|
|
100
|
+
}
|
|
101
|
+
$.NSThread.sleepForTimeInterval(wait);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
`;function Hj(q){let j;try{j=JSON.parse(q)}catch{return null}if(!Array.isArray(j))return null;let J=[];for(let Q of j.slice(0,A)){if(!Array.isArray(Q)||Q.length!==4||!Q.every((K)=>typeof K==="number"&&Number.isFinite(K)))return null;let[Z,z,G,F]=Q.map(Math.round);if(G>0&&F>0)J.push({x:Z,y:z,width:G,height:F})}return J}function Tj(q){let j=Date.now(),J=0,Q=!1,Z=(K,W={})=>{try{process.stderr.write(`${JSON.stringify({event:"display.windows_helper",state:K,...W})}
|
|
105
|
+
`)}catch{}},z=(K,W={})=>{if(Q)return;Q=!0,Z(K,{updates:J,duration_ms:Date.now()-j,...W})},G=I(t,["-l","JavaScript","-e",Bj],{env:{},stdio:["ignore","pipe","ignore"]});Z("started");let F="";return G.stdout.on("data",(K)=>{if(Q)return;F+=K.toString("utf8");for(let W=F.indexOf(`
|
|
106
|
+
`);W>=0;W=F.indexOf(`
|
|
107
|
+
`)){let L=Hj(F.slice(0,W));if(F=F.slice(W+1),L)J++,q(L)}if(F.length>65536)F=""}),G.once("error",(K)=>z("failed",{code:K.code??"spawn_failed"})),G.once("exit",(K,W)=>z("failed",{code:"exited",exit_code:K,signal:W})),{close(){z("stopped"),G.kill("SIGKILL")}}}var b=5,m=[{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}],Wj=[[8,1,0],[16,-1,0],[32,0,1],[64,0,-1]],g=50,Xj=500,v=4,P=131072,E=262144,x=524288,D=1048576,c=new Map([[65505,[56,P]],[65506,[60,P]],[65507,[59,E]],[65508,[62,E]],[65511,[58,x]],[65512,[61,x]],[65513,[58,x]],[65514,[61,x]],[65027,[61,x]],[65515,[55,D]],[65516,[54,D]]]),Nj=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((q,j)=>[65456+j,q]),...[122,120,99,118,96,97,98,100,101,109,103,111,105,107,113,106,64,79,80,90].map((q,j)=>[65470+j,q])]),p="asdfhgzxcv\x00bqweryt123465=97-80]ou[ip\x00lj'k;\\,/nm.\x00 `",n='~!@#$%^&*()_+{}|:"<>?',Rj="`1234567890-=[]\\;',./",M=new Map;for(let q=0;q<p.length;q++){let j=p[q];if(j==="\x00")continue;if(M.set(j.charCodeAt(0),[q,!1]),j>="a"&&j<="z")M.set(j.toUpperCase().charCodeAt(0),[q,!0])}for(let q=0;q<n.length;q++)M.set(n.charCodeAt(q),[M.get(Rj.charCodeAt(q))[0],!0]);class a{now;x=-1;y=-1;mask=0;clicks=0;lastDown=null;held=new Set;constructor(q=()=>performance.now()){this.now=q}flags(){let q=0;for(let j of this.held)q|=c.get(j)[1];return q}mouse(q,j){return`m ${q} ${this.x} ${this.y} ${j} ${q===b?0:this.clicks} ${this.flags()}`}pointer(q,j,J){let Q=[];if(q!==this.x||j!==this.y){this.x=q,this.y=j;let Z=m.find((z)=>this.mask&z.bit);Q.push(Z?this.mouse(Z.drag,Z.button):this.mouse(b,0))}for(let Z of m){let z=(this.mask&Z.bit)!==0,G=(J&Z.bit)!==0;if(!z&&G){let F=this.now(),K=this.lastDown;this.clicks=K&&K.button===Z.button&&F-K.at<=Xj&&Math.abs(q-K.x)<=v&&Math.abs(j-K.y)<=v?this.clicks+1:1,this.lastDown={button:Z.button,at:F,x:q,y:j},Q.push(this.mouse(Z.down,Z.button))}else if(z&&!G)Q.push(this.mouse(Z.up,Z.button))}for(let[Z,z,G]of Wj)if(!(this.mask&Z)&&J&Z)Q.push(`w ${z*g} ${G*g} ${this.flags()}`);return this.mask=J,Q}key(q,j){let J=q?1:0,Q=c.get(j);if(Q){if(q)this.held.add(j);else this.held.delete(j);return[`k ${Q[0]} ${J} ${this.flags()}`]}let Z=Nj.get(j);if(Z!==void 0)return[`k ${Z} ${J} ${this.flags()}`];let z=j<256?j:(j&4278190080)===16777216?j&16777215:0,G=M.get(z);if(G)return[`k ${G[0]} ${J} ${this.flags()|(G[1]?P:0)}`];if(z<160||z>65535||z>=55296&&z<57344)return[];return[`u ${J} ${z} ${this.flags()}`]}}function Vj(q,j=[]){let J=I(...w(j),{env:{},stdio:["pipe","pipe","ignore"]}),Q=new a,Z="",z=!1,G=null,F=()=>{J.kill("SIGKILL"),G?.kill("SIGKILL")},K=(B)=>{if(z)return;z=!0,F(),q.end(B)},W=(B)=>K({error:new l("display_unavailable",B)}),L=(B)=>{if(z||B.length===0)return;if(J.stdin.write(B.map((N)=>`${N}
|
|
108
|
+
`).join("")),J.stdin.writableLength>Kj)K({reason:"input_backpressure"})},i=()=>{G=I(...w(j,"clipboard"),{env:{},stdio:["ignore","pipe","ignore"]});let B="";G.stdout?.on("data",(N)=>{if(z)return;B+=N.toString("ascii");for(let X=B.indexOf(`
|
|
109
|
+
`);X>=0;X=B.indexOf(`
|
|
110
|
+
`)){let S=B.slice(0,X);if(B=B.slice(X+1),!S.startsWith("c "))continue;let O=S.slice(2);if(O.length>Math.ceil(Y/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(O)){K({reason:"display_protocol"});return}let _=Buffer.from(O,"base64");if(_.byteLength<=Y)q.clipboard(_.toString("utf8"));if(z)return}if(B.length>Math.ceil(Y/3)*4+2)K({reason:"display_protocol"})}),G.once("error",()=>W("Reason could not watch this Mac's desktop clipboard.")),G.once("exit",()=>{if(!z)W("Reason could not watch this Mac's desktop clipboard.")})};return J.stdout.on("data",(B)=>{if(z||Z===null)return;Z+=B.toString("utf8");let N=Z.indexOf(`
|
|
111
|
+
`);if(N<0){if(Z.length>4096)K({reason:"display_protocol"});return}let X=y(Z.slice(0,N));if(Z=null,!X)K({reason:"display_protocol"});else if(!X.screen||!X.accessibility)W(j.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 i(),q.ready({width:X.width,height:X.height})}),J.stdin.on("error",()=>{return}),J.once("error",()=>W("Reason could not start this Mac's desktop input.")),J.once("exit",()=>{if(Z!==null)W("Reason could not start this Mac's desktop input.");else K({reason:"display_closed"})}),{pointer:(B,N,X)=>L(Q.pointer(B,N,X)),key:(B,N)=>L(Q.key(B,N)),clipboard:(B)=>L([`c ${Buffer.from(B,"utf8").toString("base64")}`]),close(){z=!0,F()}}}
|
|
112
|
+
export{Cj as yg,kj as zg,h as Ag,Yj as Bg,Y as Cg,Lj as Dg,Aj as Eg,s as Fg,xj as Gg,Mj as Hg,fj as Ig,hj as Jg,$j as Kg,y as Lg,Sj as Mg,_j as Ng,Hj as Og,Tj as Pg,a as Qg,Vj as Rg};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Xg as J}from"./vm-hands-entry-lite-9pmag2qk.js";import{readFileSync as L}from"fs";import{isAbsolute as M,normalize as Q}from"path";var W="REASON_WORKER_DESKTOP_USER",G=null;function X(q,B){for(let I of B.split(`
|
|
3
|
+
`)){let j=I.split(":");if(j.length<7||Number(j[2])!==q||!/^\d+$/.test(j[2])||!/^\d+$/.test(j[3]))continue;let x=j[5];if(!/^[a-z_][a-z0-9_-]*$/i.test(j[0])||!M(x)||Q(x)!==x||x==="/")return null;return{username:j[0],uid:q,gid:Number(j[3]),home:x}}return null}function b(q={}){let B="value"in q?q.value:process.env[W];if(G=null,B===void 0||B==="")return null;let I=q.platform??process.platform,j="euid"in q?q.euid:process.geteuid?.(),x=/^[1-9]\d{0,9}$/.test(B)?Number(B):NaN,C=I==="linux"&&j===0&&Number.isSafeInteger(x)?X(x,(q.passwd??(()=>L("/etc/passwd","utf8")))()):null;if(!C||C.gid===0)throw Error("worker_desktop_user_invalid");return G=C,C}function k(){return G}function y(){return G?.home??J()}
|
|
4
|
+
export{W as Sg,X as Tg,b as Ug,k as Vg,y as Wg};
|