@reason-machines/cli-linux-arm64-musl 0.2.349 → 0.2.351
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/api-credentials-4yhng00z.js +2 -0
- package/bin/vm-hands/api-gnear3va.js +2 -0
- package/bin/vm-hands/{ask-relay-qr4gmz44.js → ask-relay-qf8d5xpy.js} +2 -2
- package/bin/vm-hands/connect-cli-7c8vbna3.js +2 -0
- package/bin/vm-hands/{custom-endpoint-device-syw4d5k4.js → custom-endpoint-device-j3e3zjd5.js} +1 -1
- package/bin/vm-hands/desktop-account-gcysz0m3.js +2 -0
- package/bin/vm-hands/{device-workspace-s49yhsk7.js → device-workspace-7yg5x68n.js} +1 -1
- package/bin/vm-hands/hands-worker-source-hbp5n31r.js +2 -0
- package/bin/vm-hands/{index-t1h1wd8g.js → index-swa20ch8.js} +1 -1
- package/bin/vm-hands/local-automation-m17wy455.js +2 -0
- package/bin/vm-hands/local-capabilities-16kxm20x.js +2 -0
- package/bin/vm-hands/local-desktop-users-pccz3sz9.js +2 -0
- package/bin/vm-hands/local-display-mac-gj72gkfb.js +2 -0
- package/bin/vm-hands/local-display-session-cyme96v0.js +2 -0
- package/bin/vm-hands/local-pty-session-zen80k1k.js +2 -0
- package/bin/vm-hands/{network-contract-8d4bpy3e.js → network-contract-rm9x646s.js} +1 -1
- package/bin/vm-hands/package-1e3w44ve.js +2 -0
- package/bin/vm-hands/permissions-55kd0742.js +2 -0
- package/bin/vm-hands/{reason-hands-protocol-k12eme4q.js → reason-hands-protocol-3z7bas06.js} +1 -1
- package/bin/vm-hands/{status-xs5bh7hf.js → status-syh8gkdn.js} +2 -2
- package/bin/vm-hands/version-8hqpwvge.js +2 -0
- package/bin/vm-hands/{vm-hands-entry-lite-kt418g2w.js → vm-hands-entry-lite-33ttamma.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-9dx3at21.js → vm-hands-entry-lite-5b29hq7h.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-m16qf0yy.js → vm-hands-entry-lite-66g8nb0j.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-0jar357h.js → vm-hands-entry-lite-6f5eypjm.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-1xjtcxpn.js → vm-hands-entry-lite-6qfax5p2.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-289bc9v7.js → vm-hands-entry-lite-84d59wrf.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-z0wwfy97.js → vm-hands-entry-lite-9hg7kf63.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-wgjqxtxj.js → vm-hands-entry-lite-9pdp5zwb.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-0wyjnvjz.js → vm-hands-entry-lite-beannz0s.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-yeahy7rk.js → vm-hands-entry-lite-c9wp99nr.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-1jhry648.js → vm-hands-entry-lite-dys7am1h.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-7ba3nhgv.js → vm-hands-entry-lite-dyy62gt3.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-pnkfgnqz.js → vm-hands-entry-lite-dztw7y81.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-tfpebnar.js → vm-hands-entry-lite-fs3ahdgg.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-8ynztq9j.js → vm-hands-entry-lite-gcn3rmz6.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-x6jqyxkx.js → vm-hands-entry-lite-jfwz0br7.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-2xh7sjs0.js → vm-hands-entry-lite-k17ntg9v.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-knfh7w3j.js → vm-hands-entry-lite-mybm2kyz.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-k2cvr710.js → vm-hands-entry-lite-nbtpm59m.js} +71 -168
- package/bin/vm-hands/{vm-hands-entry-lite-mhsv58hw.js → vm-hands-entry-lite-nd1k2jz9.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-k469tezz.js → vm-hands-entry-lite-nvhzj5b0.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-f66d7y5a.js → vm-hands-entry-lite-nxgwmr81.js} +3 -3
- package/bin/vm-hands/{vm-hands-entry-lite-36xzwsxn.js → vm-hands-entry-lite-qf01e5f1.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-7qg63rj8.js → vm-hands-entry-lite-r74312vd.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-q756n4nh.js → vm-hands-entry-lite-rp5t2mgn.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-k2e3q5qj.js → vm-hands-entry-lite-tdgbgcer.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-449p9dx7.js → vm-hands-entry-lite-tghzdfbq.js} +3 -3
- package/bin/vm-hands/{vm-hands-entry-lite-gt5pkv4h.js → vm-hands-entry-lite-tj1y61bg.js} +1 -1
- package/bin/vm-hands/vm-hands-entry-lite-tnss4txf.js +540 -0
- package/bin/vm-hands/{vm-hands-entry-lite-h1642n10.js → vm-hands-entry-lite-v8emwzqa.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-wmxksawm.js → vm-hands-entry-lite-wpx6sg6d.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-pa111vpq.js → vm-hands-entry-lite-xhjbc3e4.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-svs618mf.js → vm-hands-entry-lite-y4ca65b0.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-zrvaqawr.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite.js +1 -1
- package/bin/vm-hands/{vm-hands-executor-6q1n7hpe.js → vm-hands-executor-9amzgbjf.js} +1 -1
- package/bin/vm-hands/vm-hands-op-runner-cpt65f58.js +2 -0
- package/bin/vm-hands/{vm-hands-runtime-k21dbztp.js → vm-hands-runtime-cd76m4zz.js} +3 -3
- package/bin/vm-hands/worker-sandbox-yw24sxyp.js +2 -0
- package/package.json +1 -1
- package/bin/vm-hands/api-credentials-d34gw13p.js +0 -2
- package/bin/vm-hands/api-t5zxz49k.js +0 -2
- package/bin/vm-hands/connect-cli-rknch17k.js +0 -2
- package/bin/vm-hands/desktop-account-pm3zxjjt.js +0 -2
- package/bin/vm-hands/hands-worker-source-0ca76sbd.js +0 -2
- package/bin/vm-hands/local-automation-3nabm5h3.js +0 -2
- package/bin/vm-hands/local-capabilities-mnz5et6y.js +0 -2
- package/bin/vm-hands/local-desktop-users-zxw8xxw9.js +0 -2
- package/bin/vm-hands/local-display-mac-jdgx19jw.js +0 -2
- package/bin/vm-hands/local-display-session-k2ewepn4.js +0 -2
- package/bin/vm-hands/local-pty-session-frp7k8fz.js +0 -2
- package/bin/vm-hands/package-vj1s3sye.js +0 -2
- package/bin/vm-hands/permissions-74dw20hk.js +0 -2
- package/bin/vm-hands/version-mhc6y1v9.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-1wy28sjt.js +0 -5
- package/bin/vm-hands/vm-hands-entry-lite-qwb91tgj.js +0 -529
- package/bin/vm-hands/vm-hands-op-runner-01szqn0m.js +0 -2
- package/bin/vm-hands/worker-sandbox-1kpm6af4.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Yh as f}from"./vm-hands-entry-lite-84d59wrf.js";var j=["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"],$A=32;function R(x){if(!Array.isArray(x)||x.length>32||!x.every((A)=>typeof A==="string"&&j.includes(A)))return;return x.slice()}var KA="__ARA_PI_TOOL_CONFINED_SCRIPT_5f0c9e2a__",QA=262144;function Y(x){if(!x||typeof x!=="object"||Array.isArray(x))return!1;let A=x,W=Object.keys(A);return W.length===2&&W.includes("template")&&W.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 I=2,b=33554432,K=200000,D=4000000,_=240000,YA=`
|
|
3
3
|
...[executor output truncated]`,p=2000,k=1,i=16384,d=32768,y=128,LA=64,s=2097152,H=1,m=16384,c=32768,OA=8388608,n=1000,t=2500,r=2000,zA=t+r,o=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,199}$/,v=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,l={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},u=new Map(Object.entries(l).map(([x,A])=>[A,x]));function SA(x,A){return A||(u.get(x)??"")}var a=["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"],e=new Set(a),w=16384,AA=200,xA=2000,WA=["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 g(x){return new TextEncoder().encode(x).byteLength}function U(x){return typeof x==="object"&&x!==null&&!Array.isArray(x)}function B(x,A){let W=new Set(A);return Object.keys(x).every((N)=>W.has(N))}function M(x){return typeof x==="string"&&o.test(x)}function Z(x){return Number.isSafeInteger(x)&&Number(x)>=1}function J(x){return typeof x==="string"&&v.test(x)}function C(x){return typeof x==="string"&&x.startsWith("pty-")&&J(x.slice(4))}function z(x){return[x.cols,x.rows].every((A)=>Number.isSafeInteger(A)&&Number(A)>=1&&Number(A)<=n)}function E(x){if(typeof x!=="string"||x.length>Math.ceil(m/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<=m?N:-1}function S(x){return typeof x==="string"&&/^[0-9a-f]{64}$/.test(x)}function $(x){if(g(x)>b)throw new G("frame_too_large");try{return JSON.parse(x)}catch{throw new G("invalid_json")}}function BA(x){let A=$(x);if(!U(A)||!B(A,["version","generation","id","tool","input","semanticDigest","lifecycleLeaseId","workspaceBefore"])||A.version!==I||!Z(A.generation)||!M(A.id)||!["bash","repl","resume","read","edit","write","pi_tool"].includes(String(A.tool))||!U(A.input)||A.lifecycleLeaseId!==void 0&&(A.tool!=="bash"||!J(A.lifecycleLeaseId))||A.workspaceBefore!==void 0&&(!(A.tool==="bash"||A.tool==="repl"||A.tool==="pi_tool"&&A.input.tool==="bash")||!U(A.workspaceBefore)||!B(A.workspaceBefore,["script"])||typeof A.workspaceBefore.script!=="string"||A.workspaceBefore.script.length>K))throw new G("invalid_request");let W=U(A.workspaceBefore)&&typeof A.workspaceBefore.script==="string"?{workspaceBefore:{script:A.workspaceBefore.script}}:{};if(A.tool==="bash"){if(!B(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:I,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},...W}}if(A.tool==="resume"){if(A.semanticDigest!==void 0||!B(A.input,["semanticDigest"])||!S(A.input.semanticDigest))throw new G("invalid_request");return{version:I,generation:A.generation,id:A.id,tool:"resume",input:{semanticDigest:A.input.semanticDigest}}}if(A.tool==="repl"){if(!B(A.input,["code"])||typeof A.input.code!=="string"||A.input.code.length>K||A.semanticDigest!==void 0)throw new G("invalid_request");return{version:I,generation:A.generation,id:A.id,tool:"repl",input:{code:A.input.code},...W}}if(A.tool==="pi_tool"){let N=A.semanticDigest===void 0?GA(A.input):null;if(!N)throw new G("invalid_request");return{version:I,generation:A.generation,id:A.id,tool:"pi_tool",input:N,...W}}if(A.tool==="read"){if(!B(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:I,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(!B(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 N=A.input.path.length,X=[];for(let V of A.input.edits){if(!U(V)||!B(V,["oldText","newText"])||typeof V.oldText!=="string"||V.oldText.length<1||typeof V.newText!=="string")throw new G("invalid_request");if(N+=V.oldText.length+V.newText.length,N>D)throw new G("invalid_request");X.push({oldText:V.oldText,newText:V.newText})}return{version:I,generation:A.generation,id:A.id,tool:"edit",input:{path:A.input.path,edits:X}}}if(A.tool!=="write"||!B(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:I,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 GA(x){let A=x.args;if(!B(x,["tool","args"])||!U(A))return null;if(x.tool==="bash")return B(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 B(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 B(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"||!B(A,["path","edits"])||!Array.isArray(A.edits))return null;let W=A.path.length,N=[];for(let X of A.edits){if(!U(X)||!B(X,["oldText","newText"])||typeof X.oldText!=="string"||typeof X.newText!=="string")return null;if(W+=X.oldText.length+X.newText.length,W>D)return null;N.push({oldText:X.oldText,newText:X.newText})}return{tool:"edit",args:{path:A.path,edits:N}}}function NA(x){if(!U(x))return null;if("thrown"in x)return B(x,["thrown"])&&typeof x.thrown==="string"?{thrown:x.thrown}:null;let A=x.structuredContent;if(!B(x,["content","details","structuredContent","isError"])||!Array.isArray(x.content)||x.isError!==void 0&&x.isError!==!0||A!==void 0&&(!U(A)||!B(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 W=[];for(let N of x.content)if(U(N)&&N.type==="text"&&B(N,["type","text"])&&typeof N.text==="string")W.push({type:"text",text:N.text});else if(U(N)&&N.type==="image"&&B(N,["type","data","mimeType"])&&typeof N.data==="string"&&typeof N.mimeType==="string")W.push({type:"image",data:N.data,mimeType:N.mimeType});else return null;return{content:W,...x.details===void 0?{}:{details:x.details},...U(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 UA(x){let A=$(x);if(!U(A)||!B(A,["version","generation","id","ok","exitCode","stdout","stderr","cwd","error","resumed","browserActions","automaticProgressImage","piToolOutcome","workerElapsedMs","environmentWaitMs","workspaceBefore"])||A.version!==I||!Z(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>_||typeof A.stderr!=="string"||A.stderr.length>_||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>p||!e.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.workspaceBefore!==void 0&&!h(A.workspaceBefore)||A.ok&&(A.exitCode!==0||A.error!==void 0)||!A.ok&&A.exitCode===0)throw new G("invalid_result");let W=A.piToolOutcome===void 0?void 0:NA(A.piToolOutcome);if(W===null||W&&!A.ok)throw new G("invalid_result");return{version:I,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}:{},...W?{piToolOutcome:W}:{},...A.workerElapsedMs!==void 0?{workerElapsedMs:Number(A.workerElapsedMs)}:{},...A.environmentWaitMs!==void 0?{environmentWaitMs:Number(A.environmentWaitMs)}:{},...h(A.workspaceBefore)?{workspaceBefore:{exitCode:A.workspaceBefore.exitCode,stdout:A.workspaceBefore.stdout,stderr:A.workspaceBefore.stderr}}:{}}}function h(x){return U(x)&&B(x,["exitCode","stdout","stderr"])&&Number.isSafeInteger(x.exitCode)&&Number(x.exitCode)>=0&&Number(x.exitCode)<=255&&typeof x.stdout==="string"&&x.stdout.length<=w&&typeof x.stderr==="string"&&x.stderr.length<=w}function FA(x){let A=$(x);if(!U(A)||!B(A,["type","version","generation","id","sequence","stdout","stderr"])||A.type!=="progress"||A.version!==I||!Z(A.generation)||!M(A.id)||!Number.isSafeInteger(A.sequence)||Number(A.sequence)<1||typeof A.stdout!=="string"||A.stdout.length>_||typeof A.stderr!=="string"||A.stderr.length>_)throw new G("invalid_progress");return{type:"progress",version:I,generation:Number(A.generation),id:A.id,sequence:Number(A.sequence),stdout:A.stdout,stderr:A.stderr}}function IA(x){let A=$(x);if(!U(A)||!B(A,["type","version","generation","fenceId","executorLaunchId","requestCancelVersion","managedJobsVersion","browserRunEnvelopeVersion","terminalCleanupVersion","guestMemoryVersion","guestMemoryDiagnosticsVersion","piToolsVersion","piToolsConfinement","backgroundBashVersion","machineSdkVersion","executionTimingVersion","environmentWaitVersion","workspaceBeforeVersion"])||A.type!=="claim"||A.version!==I||!Z(A.generation)||!J(A.fenceId)||!J(A.executorLaunchId)||A.requestCancelVersion!==void 0&&A.requestCancelVersion!==1||A.managedJobsVersion!==void 0&&A.managedJobsVersion!==k||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)||A.workspaceBeforeVersion!==void 0&&A.workspaceBeforeVersion!==1)throw new G("invalid_claim");return{type:"claim",version:I,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}:{},...A.workspaceBeforeVersion===1?{workspaceBeforeVersion:1}:{}}}function XA(x){let A=$(x);if(!U(A)||!B(A,["type","version","generation","fenceId","executorLaunchId","workerVersion","workerArtifactSha256","requestCancelVersion","managedJobsVersion","lifecycleVersion","browserRunEnvelopeVersion","terminalCleanupVersion","guestMemoryVersion","guestMemoryDiagnosticsVersion","piToolsVersion","piToolsConfinementVersion","backgroundBashVersion","machineSdkVersion","executionTimingVersion","environmentWaitVersion","workspaceBeforeVersion"])||A.lifecycleVersion!==void 0&&A.lifecycleVersion!==1||A.workspaceBeforeVersion!==void 0&&A.workspaceBeforeVersion!==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!==I||!Z(A.generation)||!J(A.fenceId)||!J(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!==k)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}:{},...A.workspaceBeforeVersion===1?{workspaceBeforeVersion:1}:{},version:I,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 TA(x){let A=$(x);if(!U(A)||!B(A,["type","version","generation","id","jobId","action","input"])||A.type!=="job"||A.version!==I||!Z(A.generation)||!M(A.id)||!M(A.jobId)||!U(A.input))throw new G("invalid_job_request");let W=A.input,N=Number.isSafeInteger(W.leaseExpiresAtMs)&&Number(W.leaseExpiresAtMs)>0,X=Number.isSafeInteger(W.sequence)&&Number(W.sequence)>=1;if(!(A.action==="start"?W.mode==="pty"?B(W,["mode","cols","rows","leaseExpiresAtMs"])&&C(A.jobId)&&z(W)&&N:B(W,["script","leaseExpiresAtMs"])&&typeof W.script==="string"&&W.script.length<=K&&N:A.action==="inspect"?B(W,["after"])&&Number.isSafeInteger(W.after)&&Number(W.after)>=0:A.action==="input"?"dataBase64"in W?B(W,["sequence","dataBase64"])&&C(A.jobId)&&X&&E(W.dataBase64)>0:B(W,["sequence","data","eof"])&&X&&typeof W.data==="string"&&W.data.length<=i&&typeof W.eof==="boolean":A.action==="resize"?B(W,["sequence","cols","rows"])&&C(A.jobId)&&X&&z(W):A.action==="renew"?B(W,["leaseExpiresAtMs"])&&N:A.action==="cancel"&&B(W,[])))throw new G("invalid_job_request");return A}function MA(x){let A=$(x);if(!U(A)||!B(A,["type","version","generation","id","ok","job","error"])||A.type!=="job_result"||A.version!==I||!Z(A.generation)||!M(A.id))throw new G("invalid_job_result");if(A.ok===!1&&A.job===void 0&&typeof A.error==="string"&&WA.some((F)=>F===A.error))return A;let W=A.job;if(A.ok!==!0||A.error!==void 0||!U(W)||!B(W,["jobId","state","startedAtMs","finishedAtMs","leaseExpiresAtMs","exitCode","inputSequence","output","firstCursor","nextCursor","truncated","process","environmentRevision","environmentSnapshotId","pty"])||!M(W.jobId)||!["starting","running","exited","cancelled","expired","uncertain"].includes(String(W.state))||!Number.isSafeInteger(W.startedAtMs)||Number(W.startedAtMs)<1||!Number.isSafeInteger(W.leaseExpiresAtMs)||Number(W.leaseExpiresAtMs)<1||W.finishedAtMs!==null&&(!Number.isSafeInteger(W.finishedAtMs)||Number(W.finishedAtMs)<Number(W.startedAtMs))||W.exitCode!==null&&(!Number.isSafeInteger(W.exitCode)||Number(W.exitCode)<0||Number(W.exitCode)>255)||!Number.isSafeInteger(W.inputSequence)||Number(W.inputSequence)<0||!Number.isSafeInteger(W.firstCursor)||Number(W.firstCursor)<1||!Number.isSafeInteger(W.nextCursor)||Number(W.nextCursor)<Number(W.firstCursor)-1||typeof W.truncated!=="boolean"||!Array.isArray(W.output)||W.output.length>y)throw new G("invalid_job_result");if(W.environmentRevision===void 0!==(W.environmentSnapshotId===void 0)||W.environmentRevision!==void 0&&(!Number.isSafeInteger(W.environmentRevision)||Number(W.environmentRevision)<1||!J(W.environmentSnapshotId)))throw new G("invalid_job_result");let N=Number(W.firstCursor)-1,X=0;for(let F of W.output){if(!U(F)||!B(F,["cursor","stream","text"])||!Number.isSafeInteger(F.cursor)||Number(F.cursor)<=N||Number(F.cursor)>Number(W.nextCursor)||!["stdout","stderr"].includes(String(F.stream))||typeof F.text!=="string")throw new G("invalid_job_result");X+=F.text.length,N=Number(F.cursor)}if(X>d)throw new G("invalid_job_result");let V=W.state==="starting"||W.state==="running";if(V&&(W.finishedAtMs!==null||W.exitCode!==null)||!V&&W.finishedAtMs===null||W.state==="uncertain"&&W.exitCode!==null||W.state==="exited"&&W.exitCode===null||W.state==="cancelled"&&W.exitCode!==130||W.state==="expired"&&W.exitCode!==124)throw new G("invalid_job_result");if(W.process!==void 0){let F=W.process;if(!U(F)||!B(F,["pid","processGroupId","executorLaunchId"])||!Number.isSafeInteger(F.pid)||Number(F.pid)<1||F.processGroupId!==F.pid||!J(F.executorLaunchId)||!["starting","running"].includes(String(W.state)))throw new G("invalid_job_result")}if(W.pty!==void 0){let F=W.pty;if(!U(F)||!B(F,["version","cols","rows","output","cleanup"])||F.version!==H||!C(W.jobId)||!z(F)||W.output.length!==0||!Array.isArray(F.output)||F.output.length>y||(V?F.cleanup!=="pending":W.state==="uncertain"?F.cleanup!=="unconfirmed":F.cleanup!=="confirmed")||W.state==="running"&&(W.process===void 0||W.environmentRevision===void 0))throw new G("invalid_job_result");let T=Number(W.firstCursor)-1,P=0;for(let Q of F.output){if(!U(Q)||!B(Q,["cursor","dataBase64"])||!Number.isSafeInteger(Q.cursor)||Number(Q.cursor)<=T||Number(Q.cursor)>Number(W.nextCursor))throw new G("invalid_job_result");let q=E(Q.dataBase64);if(q<=0||(P+=q)>c)throw new G("invalid_job_result");T=Number(Q.cursor)}}return A}function qA(x){if(g(x)>s)throw new G("frame_too_large");let A=$(x);if(!U(A)||!B(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(J)||!Z(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||!U(A.workspace))throw new G("invalid_pty_receipt");if(!f(A.workspace))throw new G("invalid_pty_receipt");let W=MA(JSON.stringify({type:"job_result",version:I,generation:A.generation,id:A.operationId,ok:!0,job:A.job}));if(!W.ok||!W.job.pty||W.job.pty.output.length!==0||W.job.process&&W.job.process.executorLaunchId!==A.executorLaunchId)throw new G("invalid_pty_receipt");return A}function yA(x){let A=$(x);if(!U(A)||!B(A,["type","version","generation","id","targetId"])||A.type!=="cancel_request"||A.version!==I||!Z(A.generation)||!M(A.id)||!M(A.targetId))throw new G("invalid_cancel_request");return A}function mA(x){let A=$(x);if(!U(A)||!B(A,["type","version","generation","id","targetId","status"])||A.type!=="cancel_ack"||A.version!==I||!Z(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 BA(A),A}function hA(x){let A=JSON.stringify(x);return UA(A),A}function fA(x){let A=JSON.stringify(x);return FA(A),A}function kA(x){let A=JSON.stringify(x);return IA(A),A}function HA(x){let A=JSON.stringify(x);return XA(A),A}function O(x){return typeof x==="string"&&x.length>=1&&x.length<=AA&&!x.includes("\x00")}function VA(x){let A=["type","version","generation","id","jobRequestId","verb"];if(x.verb==="help")return B(x,A)?{verb:"help"}:null;if(x.verb==="describe"||x.verb==="namespace")return B(x,[...A,"name"])&&O(x.name)?{verb:x.verb,name:x.name}:null;if(x.verb==="search"){let W=x.args;if(!B(x,[...A,"query","args"])||typeof x.query!=="string"||x.query.trim().length<1||x.query.length>xA)return null;if(W===void 0)return{verb:"search",query:x.query};if(!U(W)||!B(W,["namespace","limit"])||W.namespace!==void 0&&!O(W.namespace)||W.limit!==void 0&&(!Number.isSafeInteger(W.limit)||Number(W.limit)<1||Number(W.limit)>50))return null;return{verb:"search",query:x.query,args:{...typeof W.namespace==="string"?{namespace:W.namespace}:{},...W.limit===void 0?{}:{limit:Number(W.limit)}}}}if(x.verb!=="call"||!B(x,[...A,"name","args"])||!O(x.name)||!U(x.args)||JSON.stringify(x.args).length>K)return null;return{verb:"call",name:x.name,args:x.args}}function gA(x){let A=$(x);if(!U(A)||A.type!=="sdk_request"||A.version!==I||!Z(A.generation)||!M(A.id)||!M(A.jobRequestId))throw new G("invalid_sdk_request");let W=VA(A);if(!W)throw new G("invalid_sdk_request");return{type:"sdk_request",version:I,generation:Number(A.generation),id:A.id,jobRequestId:A.jobRequestId,...W}}function ZA(x){let A=$(x);if(!U(A)||A.type!=="sdk_response"||A.version!==I||!Z(A.generation)||!M(A.id))throw new G("invalid_sdk_response");let W={type:"sdk_response",version:I,generation:Number(A.generation),id:A.id},N=["type","version","generation","id","ok"];if(A.ok===!0&&B(A,[...N,"result"])&&typeof A.result==="string"&&A.result.length<=_)return{...W,ok:!0,result:A.result};if(A.ok===!1&&B(A,[...N,"error"])&&typeof A.error==="string"&&A.error.length>=1&&A.error.length<=_)return{...W,ok:!1,error:A.error};throw new G("invalid_sdk_response")}function EA(x){let A=JSON.stringify(x);return ZA(A),A}
|
|
4
|
-
export{$A as
|
|
4
|
+
export{$A as rg,KA as sg,QA as tg,I as ug,b as vg,K as wg,D as xg,_ as yg,YA as zg,p as Ag,k as Bg,i as Cg,d as Dg,y as Eg,LA as Fg,s as Gg,H as Hg,m as Ig,c as Jg,OA as Kg,n as Lg,t as Mg,r as Ng,zA as Og,l as Pg,SA as Qg,a as Rg,w as Sg,AA as Tg,xA as Ug,WA as Vg,G as Wg,M as Xg,Z as Yg,J as Zg,C as _g,S as $g,BA as ah,UA as bh,FA as ch,IA as dh,XA as eh,TA as fh,MA as gh,qA as hh,yA as ih,mA as jh,wA as kh,hA as lh,fA as mh,kA as nh,HA as oh,gA as ph,ZA as qh,EA as rh};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{hc as h}from"./vm-hands-entry-lite-nvhzj5b0.js";import{Ag as Q,Cg as j,Dg as k,Eg as J,Fg as z,Gg as Z,Ig as K,Jg as $,Lg as _,Mg as G,Ng as S,Pg as M,Sg as X,sg as w,tg as m,ug as q,vg as B,wg as L,xg as W,yg as F}from"./vm-hands-entry-lite-mybm2kyz.js";import{$h as y,ai as p,bi as x,ci as b}from"./vm-hands-entry-lite-84d59wrf.js";var s=["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); } };
|
|
@@ -64,19 +64,7 @@ import{lc as i,mc as l,nc as g,oc as y}from"./vm-hands-entry-lite-k469tezz.js";i
|
|
|
64
64
|
if(!Number.isSafeInteger(limitBytes)||limitBytes<=0||!Number.isSafeInteger(available)||available>limitBytes) fail("memory_capacity", "memory_capacity_invalid");
|
|
65
65
|
return {bootId,oomKills:field(read("/proc/vmstat", "guest_vmstat_read_failed"),"oom_kill"),currentBytes:limitBytes-available,
|
|
66
66
|
limitBytes,inactiveFileBytes:0,capacitySource:"guest",memoryScope:"/proc"};
|
|
67
|
-
})`;var
|
|
68
|
-
return ['(version 1)','(deny default)','(import "system.sb")','(allow process-exec process-fork)',
|
|
69
|
-
'(allow file-read* (subpath "/bin") (subpath "/sbin") (subpath "/usr/bin") (subpath "/usr/sbin") (subpath "/usr/libexec") (subpath "/usr/share") (subpath "/private/var/select") (literal "/private/var/db/xcode_select_link"))',
|
|
70
|
-
'(allow file-read-metadata (path-ancestors "/opt/homebrew/bin") (path-ancestors "/usr/local/bin") (path-ancestors "/Library/Developer/CommandLineTools"))',
|
|
71
|
-
'(allow file-read* (subpath "/opt/homebrew/Cellar") (subpath "/opt/homebrew/opt") (subpath "/opt/homebrew/bin") (subpath "/opt/homebrew/lib") (subpath "/opt/homebrew/share") (subpath "/opt/homebrew/include") (subpath "/usr/local/Cellar") (subpath "/usr/local/opt") (subpath "/usr/local/bin") (subpath "/usr/local/lib") (subpath "/usr/local/share") (subpath "/usr/local/include") (subpath "/Library/Developer/CommandLineTools"))',
|
|
72
|
-
'(allow file-read* file-write* (subpath '+JSON.stringify(root)+') (subpath '+JSON.stringify(temporary)+'))',
|
|
73
|
-
'(allow file-read-metadata (path-ancestors '+JSON.stringify(root)+') (path-ancestors '+JSON.stringify(temporary)+'))',
|
|
74
|
-
'(deny file-read* file-write* (subpath "/opt/homebrew/etc") (subpath "/usr/local/etc") (literal "/private/etc/master.passwd"))',
|
|
75
|
-
'(deny file-write* (subpath "/opt/homebrew") (subpath "/usr/local") (subpath "/Library/Developer") (subpath "/cores"))',
|
|
76
|
-
...${JSON.stringify(N)}.map(pattern => '(deny file-read* file-write* (regex #"'+pattern+'"))'),
|
|
77
|
-
'(deny network*)','(deny mach-lookup)','(deny process-info*)','(allow process-info* (target same-sandbox))','(allow process-info-listpids)','(allow file-read-metadata (subpath "/dev"))','(deny signal)','(allow signal (target same-sandbox))'].join('\\n');
|
|
78
|
-
}`,h="/opt/homebrew/bin:/usr/local/bin:/Library/Developer/CommandLineTools/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin";function bt(t,e){return Function("return ("+n+")")()(t,e)+`
|
|
79
|
-
(allow network-bind network-inbound (local tcp "localhost:*"))`}var x=String.raw`import os,sys,json,stat,fcntl,time,ctypes
|
|
67
|
+
})`;var c=String.raw`import os,sys,json,stat,fcntl,time,ctypes
|
|
80
68
|
v=json.load(sys.stdin)
|
|
81
69
|
root=v['root']; paths=list(dict.fromkeys([v['source'],v['snapshot']]))
|
|
82
70
|
marker=('# reason-job-env-owner:'+v['runId']+'\n').encode()
|
|
@@ -118,7 +106,7 @@ try:
|
|
|
118
106
|
finally:
|
|
119
107
|
for _,fd in fds:os.close(fd)
|
|
120
108
|
for _,pfd in parents:os.close(pfd)
|
|
121
|
-
`;var
|
|
109
|
+
`;var e=String.raw`function workspaceTarget(requested) {
|
|
122
110
|
if (typeof requested !== "string" || requested.length < 1 || requested.includes("\0")) {
|
|
123
111
|
throw new Error("workspace_file_path_invalid");
|
|
124
112
|
}
|
|
@@ -321,7 +309,7 @@ function fileOperation(request) {
|
|
|
321
309
|
});
|
|
322
310
|
return { promise, cancel() {} };
|
|
323
311
|
}
|
|
324
|
-
`;var
|
|
312
|
+
`;var u="a3e39eb55160acfc116fa9871ccc594c68be7a642d2331b24baa707c8f601ec0";import{createHash as tt}from"crypto";var pt=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 d=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 r=/^[A-Za-z_][A-Za-z0-9_]*$/;var O=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"]),I=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"]),T=["INFISICAL_","NSC_"],A=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"]),D=["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 n="^(?!(?:"+[...O,...I,...A].join("|")+")$)(?!(?:"+[...T,...D].join("|")+"))"+r.source.slice(1),mt=new RegExp(n);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"],N=["ARA_HANDS_","ARA_DEVICE_","ARA_GIT_BROKER_","REASON_HANDS_","REASON_DEVICE_","REASON_GIT_BROKER_","BUN_"],U="^(?!(?:"+v.join("|")+")$)(?!(?:"+N.join("|")+"))"+n.slice(1),E="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",i="^(?:"+E+"|"+U.slice(1,-1)+")$",R=new RegExp(i);function Wt(t){return R.test(t)}var f=Object.freeze({tokenPath:"/identity/token",awsPath:"/identity/aws",tokenPattern:/^[A-Za-z0-9_.~-]+$/.source}),l=Object.freeze({variables:256,valueBytes:130816,snapshotBytes:1048576}),Ft=Object.freeze({valueChars:16384,snapshotBytes:65536});var g=["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 et=2,rt="ara-hands-worker.cjs",Y=["/usr/local/go/bin","/opt/node/bin","/usr/local/bin","/usr/sbin","/usr/bin","/sbin","/bin","/usr/local/cargo/bin"],nt=Y.join(":"),it=["/opt/homebrew/bin",...Y].join(":"),st='(platform, linuxPath, macosPath) => platform === "darwin" ? macosPath : linuxPath';function Ht(t,H,P){return t==="darwin"?P:H}var ot=String.raw`(function(anchor, pid, native) {
|
|
325
313
|
const token = native.identity(pid);
|
|
326
314
|
const session = native.session(pid);
|
|
327
315
|
if (!native.same(anchor)) throw new Error("pty_session_identity_lost");
|
|
@@ -329,7 +317,7 @@ function fileOperation(request) {
|
|
|
329
317
|
if (session.id !== anchor[5]) throw new Error("pty_member_session_changed");
|
|
330
318
|
if (!token) return { retry: true, token: null };
|
|
331
319
|
return { retry: false, token };
|
|
332
|
-
})`,
|
|
320
|
+
})`,ct=String.raw`(function(native) {
|
|
333
321
|
let probe;
|
|
334
322
|
try {
|
|
335
323
|
try {
|
|
@@ -339,7 +327,7 @@ function fileOperation(request) {
|
|
|
339
327
|
native.signal(probe);
|
|
340
328
|
} finally { if (probe) native.release(probe); }
|
|
341
329
|
} catch (error) { native.close(); throw error; }
|
|
342
|
-
})`,
|
|
330
|
+
})`,ut=String.raw`(function(bootstrap) {
|
|
343
331
|
const { dlopen, ptr } = require("bun:ffi");
|
|
344
332
|
const api = dlopen("libc.so.6", {
|
|
345
333
|
prctl: { args: ["i32", "u64", "u64", "u64", "u64"], returns: "i32" },
|
|
@@ -360,7 +348,7 @@ function fileOperation(request) {
|
|
|
360
348
|
require("node:fs").writeSync(3, "subreaper\n");
|
|
361
349
|
api.execve(ptr(args[0]), ptr(argv), ptr(envp));
|
|
362
350
|
throw new Error("pty_exec_failed");
|
|
363
|
-
})`,
|
|
351
|
+
})`,at=String.raw`
|
|
364
352
|
"use strict";
|
|
365
353
|
const crypto = require("node:crypto");
|
|
366
354
|
const fs = require("node:fs");
|
|
@@ -368,40 +356,40 @@ const net = require("node:net");
|
|
|
368
356
|
const path = require("node:path");
|
|
369
357
|
const { spawn, spawnSync } = require("node:child_process");
|
|
370
358
|
const { StringDecoder } = require("node:string_decoder");
|
|
371
|
-
const GIT_BROKER_HTTP_HEADER_POLICY = ${JSON.stringify(
|
|
372
|
-
const GIT_BROKER_CREDENTIAL_HELPER_POLICY = ${JSON.stringify(
|
|
373
|
-
const DEVICE_ENVIRONMENT_NAME_RE = new RegExp(${JSON.stringify(
|
|
374
|
-
const DEVICE_CLOUD_ACCESS_POLICY = ${JSON.stringify(
|
|
375
|
-
const DEVICE_ENVIRONMENT_LIMITS = ${JSON.stringify(
|
|
359
|
+
const GIT_BROKER_HTTP_HEADER_POLICY = ${JSON.stringify(a)};
|
|
360
|
+
const GIT_BROKER_CREDENTIAL_HELPER_POLICY = ${JSON.stringify(d)};
|
|
361
|
+
const DEVICE_ENVIRONMENT_NAME_RE = new RegExp(${JSON.stringify(i)});
|
|
362
|
+
const DEVICE_CLOUD_ACCESS_POLICY = ${JSON.stringify(f)};
|
|
363
|
+
const DEVICE_ENVIRONMENT_LIMITS = ${JSON.stringify(l)};
|
|
376
364
|
|
|
377
|
-
const VERSION = ${
|
|
378
|
-
const WORKER_VERSION = ${
|
|
379
|
-
const WORKER_ENTRYPOINT = ${JSON.stringify(
|
|
380
|
-
const GUEST_MEMORY_UNAVAILABLE_REASONS = ${JSON.stringify(
|
|
381
|
-
const sampleGuestMemory = ${
|
|
382
|
-
const inspectMacPtyMember = ${
|
|
383
|
-
const probeLinuxPtyLibrary = ${
|
|
384
|
-
const LINUX_PTY_EXEC_SOURCE = ${JSON.stringify(
|
|
385
|
-
const CLOSE_CODES = ${JSON.stringify(
|
|
365
|
+
const VERSION = ${q};
|
|
366
|
+
const WORKER_VERSION = ${et};
|
|
367
|
+
const WORKER_ENTRYPOINT = ${JSON.stringify(rt)};
|
|
368
|
+
const GUEST_MEMORY_UNAVAILABLE_REASONS = ${JSON.stringify(s)};
|
|
369
|
+
const sampleGuestMemory = ${o};
|
|
370
|
+
const inspectMacPtyMember = ${ot};
|
|
371
|
+
const probeLinuxPtyLibrary = ${ct};
|
|
372
|
+
const LINUX_PTY_EXEC_SOURCE = ${JSON.stringify(ut)};
|
|
373
|
+
const CLOSE_CODES = ${JSON.stringify(M)};
|
|
386
374
|
const SHA256_RE = /^[0-9a-f]{64}$/;
|
|
387
|
-
const MAX_FRAME_BYTES = ${
|
|
388
|
-
const MAX_INPUT_CHARS = ${
|
|
389
|
-
const MAX_STRUCTURED_INPUT_CHARS = ${
|
|
390
|
-
const MAX_OUTPUT_CHARS = ${
|
|
391
|
-
const WORKSPACE_BEFORE_MAX_OUTPUT_CHARS = ${
|
|
392
|
-
const MAX_ERROR_CHARS = ${
|
|
375
|
+
const MAX_FRAME_BYTES = ${B};
|
|
376
|
+
const MAX_INPUT_CHARS = ${L};
|
|
377
|
+
const MAX_STRUCTURED_INPUT_CHARS = ${W};
|
|
378
|
+
const MAX_OUTPUT_CHARS = ${F};
|
|
379
|
+
const WORKSPACE_BEFORE_MAX_OUTPUT_CHARS = ${X};
|
|
380
|
+
const MAX_ERROR_CHARS = ${Q};
|
|
393
381
|
const MAX_LEDGER_IDS = 16384;
|
|
394
382
|
const MAX_CACHED_RESULTS = 256;
|
|
395
|
-
const MAX_JOB_INPUT_CHARS = ${
|
|
396
|
-
const MAX_JOB_OUTPUT_CHARS = ${
|
|
397
|
-
const MAX_JOB_OUTPUT_CHUNKS = ${
|
|
398
|
-
const MAX_JOBS = ${
|
|
383
|
+
const MAX_JOB_INPUT_CHARS = ${j};
|
|
384
|
+
const MAX_JOB_OUTPUT_CHARS = ${k};
|
|
385
|
+
const MAX_JOB_OUTPUT_CHUNKS = ${J};
|
|
386
|
+
const MAX_JOBS = ${z};
|
|
399
387
|
const MAX_JOB_RECORD_BYTES = 262144;
|
|
400
388
|
const MAX_JOB_JOURNAL_BYTES = MAX_JOBS * MAX_JOB_RECORD_BYTES;
|
|
401
|
-
const MAX_JOB_CONTROL_FRAME_BYTES = ${
|
|
402
|
-
const MAX_PTY_INPUT_BYTES = ${
|
|
403
|
-
const MAX_PTY_OUTPUT_BYTES = ${
|
|
404
|
-
const MAX_PTY_DIMENSION = ${
|
|
389
|
+
const MAX_JOB_CONTROL_FRAME_BYTES = ${Z};
|
|
390
|
+
const MAX_PTY_INPUT_BYTES = ${K};
|
|
391
|
+
const MAX_PTY_OUTPUT_BYTES = ${$};
|
|
392
|
+
const MAX_PTY_DIMENSION = ${_};
|
|
405
393
|
const ID_RE = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,199}$/;
|
|
406
394
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
407
395
|
const FIXED_BASH = "/bin/bash";
|
|
@@ -437,18 +425,13 @@ function jobsUserPrefix(model) {
|
|
|
437
425
|
return user ? ["/usr/bin/setpriv", "--reuid=" + user.uid, "--regid=" + gid, "--clear-groups", "--no-new-privs", "--",
|
|
438
426
|
"/usr/bin/env", "HOME=" + user.home, "USER=" + user.username, "LOGNAME=" + user.username] : [];
|
|
439
427
|
}
|
|
440
|
-
const FIXED_CLOUD_CHILD_PATH = ${JSON.stringify(
|
|
441
|
-
const FIXED_MACOS_CLOUD_CHILD_PATH = ${JSON.stringify(
|
|
442
|
-
const selectCloudChildPath = ${
|
|
428
|
+
const FIXED_CLOUD_CHILD_PATH = ${JSON.stringify(nt)};
|
|
429
|
+
const FIXED_MACOS_CLOUD_CHILD_PATH = ${JSON.stringify(it)};
|
|
430
|
+
const selectCloudChildPath = ${st};
|
|
443
431
|
const config = JSON.parse(fs.readFileSync(process.argv[2], "utf8"));
|
|
444
432
|
const allowedTools = config.allowedTools === undefined
|
|
445
433
|
? ["bash", "repl", "read", "edit", "write"]
|
|
446
434
|
: config.allowedTools;
|
|
447
|
-
// Local GitHub authority confines a Session's Bash and file access under
|
|
448
|
-
// sandbox-exec on macOS. A personal Linux worker runs every Session's tools
|
|
449
|
-
// with the person's own permissions (host mode, which already reach their gh
|
|
450
|
-
// login and the network), so there it keeps the ordinary tool paths.
|
|
451
|
-
const localGithubSandbox = config.localGithubConfinement === true && process.platform === "darwin";
|
|
452
435
|
|
|
453
436
|
function validPath(value) {
|
|
454
437
|
return typeof value === "string" && path.isAbsolute(value) && !value.includes("\0");
|
|
@@ -526,12 +509,12 @@ function validJobEnvSourcePath() {
|
|
|
526
509
|
if (config.jobEnvSourcePath === undefined || config.jobEnvSourcePath === path.join(config.workRoot, "job.env")) return true;
|
|
527
510
|
// A cloud workspace's job.env is in its Session's root-only control
|
|
528
511
|
// directory (shared/device-workspace.ts), derived from the root alone.
|
|
529
|
-
const cloud = new RegExp(${JSON.stringify(
|
|
512
|
+
const cloud = new RegExp(${JSON.stringify(b.source)}).exec(config.workRoot);
|
|
530
513
|
if (process.platform === "linux" && cloud) {
|
|
531
514
|
const workspaceId = cloud[3];
|
|
532
|
-
const owner = (new RegExp(${JSON.stringify(
|
|
533
|
-
?? (new RegExp(${JSON.stringify(
|
|
534
|
-
return config.jobEnvSourcePath === ${JSON.stringify(
|
|
515
|
+
const owner = (new RegExp(${JSON.stringify(p.source)}).exec(workspaceId) || [])[1]
|
|
516
|
+
?? (new RegExp(${JSON.stringify(x.source)}).exec(workspaceId) || [])[1] ?? workspaceId;
|
|
517
|
+
return config.jobEnvSourcePath === ${JSON.stringify(y)} + "/" + owner + "/job.env";
|
|
535
518
|
}
|
|
536
519
|
// Personal Cloud controls are root-owned and outside the writable grant.
|
|
537
520
|
// Admit only the same canonical session, never a caller-selected private path.
|
|
@@ -569,8 +552,7 @@ if (
|
|
|
569
552
|
typeof config.launchId !== "string" || !/^[a-f0-9-]{36}$/.test(config.launchId) ||
|
|
570
553
|
!Number.isSafeInteger(config.expiresAtMs) || config.expiresAtMs <= Date.now() ||
|
|
571
554
|
!validTimeout(config.bashTimeoutMs) || !validTimeout(config.replTimeoutMs) ||
|
|
572
|
-
// An argument may be a whole sandbox-exec profile
|
|
573
|
-
// dev server's (shared/local-gh-confinement.ts) is about 7.5 KB.
|
|
555
|
+
// An argument may be a whole sandbox-exec profile.
|
|
574
556
|
(config.bashCommandPrefix !== undefined && (
|
|
575
557
|
!Array.isArray(config.bashCommandPrefix) || config.bashCommandPrefix.length < 1 ||
|
|
576
558
|
config.bashCommandPrefix.length > 32 || !validPath(config.bashCommandPrefix[0]) ||
|
|
@@ -976,7 +958,7 @@ function initializeJobs() {
|
|
|
976
958
|
// (shared/local-protected-paths.ts) that the file tools and every confinement
|
|
977
959
|
// refuse. A home-folder worker keeps it in ~/.config/reason, so its Session may
|
|
978
960
|
// work in the home folder itself, as a Mac's home grant does.
|
|
979
|
-
const PROTECTED_STATE_DIRECTORIES = ${JSON.stringify(
|
|
961
|
+
const PROTECTED_STATE_DIRECTORIES = ${JSON.stringify(h)};
|
|
980
962
|
function stateOverlapsWorkspace(state, root) {
|
|
981
963
|
if (state === root || root.startsWith(state + path.sep)) return true;
|
|
982
964
|
if (!state.startsWith(root + path.sep)) return false;
|
|
@@ -1323,7 +1305,7 @@ async function handleTerminalCleanup(target, claim, raw) {
|
|
|
1323
1305
|
let child, timer, killTimer;
|
|
1324
1306
|
const finish = ok => { clearTimeout(timer); clearTimeout(killTimer); if (!ok) cleanupUnconfirmed = true; resolve(ok); };
|
|
1325
1307
|
try {
|
|
1326
|
-
child = spawn("/usr/bin/python3", ["-I", "-c", ${JSON.stringify(
|
|
1308
|
+
child = spawn("/usr/bin/python3", ["-I", "-c", ${JSON.stringify(c)}],
|
|
1327
1309
|
{ stdio: ["pipe", "ignore", "ignore"], env: { PATH: "/usr/bin:/bin" }, detached: true });
|
|
1328
1310
|
let timedOut = false;
|
|
1329
1311
|
timer = setTimeout(() => { timedOut = true; try { process.kill(-child.pid, "SIGTERM"); } catch { cleanupUnconfirmed = true; }
|
|
@@ -1731,7 +1713,7 @@ function machineSdkShim(client) {
|
|
|
1731
1713
|
// and shim are created by the first machineSdk request (machineSdkBase).
|
|
1732
1714
|
function machineSdkAvailable() {
|
|
1733
1715
|
if (!allowedTools.includes("bash") || validPrivateJob || config.spawnPolicy || config.bashCommandPrefix
|
|
1734
|
-
||
|
|
1716
|
+
|| !machineSdkClientCommand()) return false;
|
|
1735
1717
|
return machineSdkTemporaryRoot() !== null;
|
|
1736
1718
|
}
|
|
1737
1719
|
// Where the private directory goes: the worker's temporary directory when a
|
|
@@ -2061,7 +2043,6 @@ function cloudAccessVariables(access, apiOrigin) {
|
|
|
2061
2043
|
...(access.aws_credentials_url !== null ? { AWS_CONTAINER_CREDENTIALS_FULL_URI: access.aws_credentials_url,
|
|
2062
2044
|
AWS_CONTAINER_AUTHORIZATION_TOKEN: access.request_token } : {}) };
|
|
2063
2045
|
}
|
|
2064
|
-
${n}
|
|
2065
2046
|
// Pi's shell's global Git config: a private file beside this worker's config,
|
|
2066
2047
|
// so git config --global works for the Hands session, as stock Pi's does. The
|
|
2067
2048
|
// path is in the shell's environment, where the person reads it, so the file
|
|
@@ -2108,7 +2089,7 @@ function environmentForSpawn(piShell = false, confined = false) {
|
|
|
2108
2089
|
// overridden.
|
|
2109
2090
|
const baseline = config.executionEnvironment;
|
|
2110
2091
|
const temporaryDirectory = baseline?.temporaryDirectory ?? config.workRoot;
|
|
2111
|
-
const hostVariables = piShell
|
|
2092
|
+
const hostVariables = piShell ? baseline?.variables : undefined;
|
|
2112
2093
|
const env = { ...hostVariables, ...snapshot.variables, PATH: baseline?.path ?? "/opt/homebrew/bin:" + FIXED_CLOUD_CHILD_PATH,
|
|
2113
2094
|
HOME: baseline?.home ?? config.workRoot, PWD: config.repoPath, TMPDIR: temporaryDirectory, TMP: temporaryDirectory, TEMP: temporaryDirectory,
|
|
2114
2095
|
SHELL: FIXED_BASH, BASH_ENV: "/dev/null", ENV: "/dev/null",
|
|
@@ -2120,21 +2101,10 @@ function environmentForSpawn(piShell = false, confined = false) {
|
|
|
2120
2101
|
GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_SYSTEM: "/dev/null", GIT_CONFIG_GLOBAL: "/dev/null", GIT_TERMINAL_PROMPT: "0",
|
|
2121
2102
|
};
|
|
2122
2103
|
const pairs = [["credential.helper", ""], ["http.extraheader", ""]];
|
|
2123
|
-
let confinementPrefix;
|
|
2124
2104
|
if (snapshot.github_auth === "local_gh" && config.localGithubConfinement !== true) throw new Error("local_device_gh_confinement_unavailable");
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
const temporary = path.join(workspace, ".ara-local-gh-tmp");
|
|
2129
|
-
fs.mkdirSync(temporary, { recursive: true, mode: 0o700 });
|
|
2130
|
-
if (fs.lstatSync(temporary).isSymbolicLink() || fs.realpathSync(temporary) !== temporary) throw new Error("local_device_gh_confinement_unavailable");
|
|
2131
|
-
env.HOME = workspace;
|
|
2132
|
-
env.OPENSSL_CONF = "/dev/null";
|
|
2133
|
-
env.TMPDIR = temporary; env.TMP = temporary; env.TEMP = temporary;
|
|
2134
|
-
env.PATH = ${JSON.stringify(h)};
|
|
2135
|
-
for (const name of Object.keys(env)) if (name.startsWith("GH_") || name.startsWith("GITHUB_") || name.startsWith("GIT_TRACE")) delete env[name];
|
|
2136
|
-
confinementPrefix = ["/usr/bin/sandbox-exec", "-p", localGithubSandboxProfile(workspace, temporary)];
|
|
2137
|
-
}
|
|
2105
|
+
// A local GitHub Session's shell runs as the person, with their network, so
|
|
2106
|
+
// its git reaches GitHub with their own gh login, as their terminal does.
|
|
2107
|
+
if (snapshot.github_auth === "local_gh") pairs.push(["credential.https://github.com.helper", "!gh auth git-credential"]);
|
|
2138
2108
|
if (config.localGithubConfinement === true && snapshot.github_auth !== "local_gh") throw new Error("local_device_gh_authority_changed");
|
|
2139
2109
|
if (snapshot.git && config.gitCredentialEnvironment === true) {
|
|
2140
2110
|
const helper = GIT_BROKER_CREDENTIAL_HELPER_POLICY;
|
|
@@ -2152,17 +2122,14 @@ function environmentForSpawn(piShell = false, confined = false) {
|
|
|
2152
2122
|
if (snapshot.cloud_access !== undefined) Object.assign(env, cloudAccessVariables(snapshot.cloud_access, config.environmentExpectedBinding.apiOrigin));
|
|
2153
2123
|
env.GIT_CONFIG_COUNT = String(pairs.length);
|
|
2154
2124
|
pairs.forEach(([key, value], index) => { env["GIT_CONFIG_KEY_" + index] = key; env["GIT_CONFIG_VALUE_" + index] = value; });
|
|
2155
|
-
// Local GitHub confinement denies files outside the workspace, so it keeps
|
|
2156
|
-
// the empty /dev/null config.
|
|
2157
2125
|
// A confined payload cannot read the worker's private files; it keeps the bash tool's empty config.
|
|
2158
|
-
if (piShell && !
|
|
2159
|
-
return { ...validated, env,
|
|
2160
|
-
}
|
|
2161
|
-
${
|
|
2162
|
-
// One workspace file call in a spawned child (
|
|
2163
|
-
//
|
|
2164
|
-
// repository root, with no symlink path component.
|
|
2165
|
-
// Pi's confined file operations share this boundary.
|
|
2126
|
+
if (piShell && !confined) env.GIT_CONFIG_GLOBAL = PI_GIT_CONFIG_GLOBAL;
|
|
2127
|
+
return { ...validated, env, fileSha256: privateFile.fileSha256 };
|
|
2128
|
+
}
|
|
2129
|
+
${e}const WORKSPACE_FILE_OPERATIONS_RUNTIME_SOURCE = ${JSON.stringify(e)};
|
|
2130
|
+
// One workspace file call in a spawned child (confined by a spawn policy or
|
|
2131
|
+
// command prefix), bounded by workspaceTarget: inside the canonical
|
|
2132
|
+
// repository root, with no symlink path component.
|
|
2166
2133
|
function workspaceFileScript(request, body, nodeRedirect = "") {
|
|
2167
2134
|
const encodedRequest = Buffer.from(JSON.stringify(request)).toString("base64");
|
|
2168
2135
|
const program = [
|
|
@@ -2185,61 +2152,6 @@ function payloadFileOperation(request) {
|
|
|
2185
2152
|
'fileOperation(request).promise.then(result => { process.stdout.write(result.stdout); process.stderr.write(result.stderr); process.exitCode = result.code; });'),
|
|
2186
2153
|
} }, null);
|
|
2187
2154
|
}
|
|
2188
|
-
// Pi's read/edit/write operations under local GitHub confinement. A read
|
|
2189
|
-
// returns raw bytes through the unclipped Pi shell stream (the child's stderr
|
|
2190
|
-
// is discarded so nothing interleaves) and is shared by access, image sniffing
|
|
2191
|
-
// and readFile within one tool call. writeFile is the typed tool's checked
|
|
2192
|
-
// atomic write, which creates parent directories after checking the target, so
|
|
2193
|
-
// mkdir defers to it rather than creating directories ahead of that check.
|
|
2194
|
-
// Cancelling the tool call stops the child like a cancelled typed file tool.
|
|
2195
|
-
function confinedPiFileOperations(id, state, writable, signal) {
|
|
2196
|
-
const run = (operation) => {
|
|
2197
|
-
const stop = () => { void operation.cancel().catch(() => {}); };
|
|
2198
|
-
if (signal.aborted) stop();
|
|
2199
|
-
else signal.addEventListener("abort", stop, { once: true });
|
|
2200
|
-
return operation.promise.then((result) => {
|
|
2201
|
-
signal.removeEventListener("abort", stop);
|
|
2202
|
-
if (result.error === "process_group_cleanup_unconfirmed") state.cleanupUnconfirmed = true;
|
|
2203
|
-
return result;
|
|
2204
|
-
});
|
|
2205
|
-
};
|
|
2206
|
-
const reads = new Map();
|
|
2207
|
-
const read = (file) => {
|
|
2208
|
-
if (!reads.has(file)) {
|
|
2209
|
-
const chunks = [];
|
|
2210
|
-
const script = workspaceFileScript({ path: file, writable }, [
|
|
2211
|
-
'let reply;',
|
|
2212
|
-
'try {',
|
|
2213
|
-
' const { target } = workspaceTarget(request.path);',
|
|
2214
|
-
' fs.accessSync(target, request.writable ? fs.constants.R_OK | fs.constants.W_OK : fs.constants.R_OK);',
|
|
2215
|
-
' reply = { data: fs.readFileSync(target).toString("base64") };',
|
|
2216
|
-
'} catch (error) {',
|
|
2217
|
-
' reply = { error: error instanceof Error ? error.message : "workspace_file_failed", code: typeof error?.code === "string" ? error.code : undefined };',
|
|
2218
|
-
'}',
|
|
2219
|
-
'process.stdout.write(JSON.stringify(reply));',
|
|
2220
|
-
].join("\n"), " 2>/dev/null");
|
|
2221
|
-
reads.set(file, run(bashOperation({ id, input: { script } }, null, null, { onData: (chunk) => chunks.push(chunk) }))
|
|
2222
|
-
.then((result) => {
|
|
2223
|
-
if (!result.ok) throw new Error(result.error || "workspace_file_failed");
|
|
2224
|
-
const reply = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
2225
|
-
if (typeof reply.error === "string") throw Object.assign(new Error(reply.error), reply.code ? { code: reply.code } : {});
|
|
2226
|
-
return Buffer.from(reply.data, "base64");
|
|
2227
|
-
}));
|
|
2228
|
-
}
|
|
2229
|
-
return reads.get(file);
|
|
2230
|
-
};
|
|
2231
|
-
return {
|
|
2232
|
-
access: (file) => read(file).then(() => undefined),
|
|
2233
|
-
readFile: read,
|
|
2234
|
-
// Pi's own sniffing over the leading bytes its file-based default reads.
|
|
2235
|
-
detectImageMimeType: (file) => read(file).then((bytes) => loadPiTools().detectSupportedImageMimeType(bytes.subarray(0, 4100))),
|
|
2236
|
-
writeFile: (file, content) => run(payloadFileOperation({ id, tool: "write", input: { path: file, content } })).then((result) => {
|
|
2237
|
-
reads.delete(file);
|
|
2238
|
-
if (!result.ok) throw new Error(result.stderr || result.error || "workspace_file_failed");
|
|
2239
|
-
}),
|
|
2240
|
-
mkdir: () => Promise.resolve(),
|
|
2241
|
-
};
|
|
2242
|
-
}
|
|
2243
2155
|
function prepareBashSpawn(argv, extraFileDescriptors, expiresAtMs, signal, onLost) {
|
|
2244
2156
|
const policy = config.spawnPolicy;
|
|
2245
2157
|
const claimedGeneration = targetGeneration;
|
|
@@ -2313,7 +2225,7 @@ function prepareBashSpawn(argv, extraFileDescriptors, expiresAtMs, signal, onLos
|
|
|
2313
2225
|
}
|
|
2314
2226
|
let nativePtyOwner = null;
|
|
2315
2227
|
function ptySupported() {
|
|
2316
|
-
if (
|
|
2228
|
+
if (!config.managedPty || config.environmentSnapshotPath === undefined || config.spawnPolicy || config.bashCommandPrefix
|
|
2317
2229
|
|| !["darwin", "linux"].includes(process.platform) || typeof Bun === "undefined" || typeof Bun.Terminal !== "function") return false;
|
|
2318
2230
|
if (process.platform === "linux" && !["x64", "arm64"].includes(process.arch)) return false;
|
|
2319
2231
|
try { platformPtyOwner(); return true; } catch { return false; }
|
|
@@ -2567,7 +2479,7 @@ function linuxPtyOwner() {
|
|
|
2567
2479
|
// user detaches from the shell (nohup, setsid, disown, or jobs left at exit)
|
|
2568
2480
|
// are not swept. At most TERMINAL_HOST_LIMIT shells per scope.
|
|
2569
2481
|
const TERMINAL_SHELL = "/bin/bash --noprofile --norc -i";
|
|
2570
|
-
const TERMINAL_TMUX_CONFIG = ${JSON.stringify([...
|
|
2482
|
+
const TERMINAL_TMUX_CONFIG = ${JSON.stringify([...g,"new-session -d -s main /bin/bash --noprofile --norc -i","set -g exit-empty on","run-shell -b -d 43200 -C kill-server",""].join(`
|
|
2571
2483
|
`))};
|
|
2572
2484
|
const TERMINAL_HOST_LIMIT = 4;
|
|
2573
2485
|
const terminalViewers = new Map();
|
|
@@ -2710,7 +2622,7 @@ function ptyOperation(request, managed, program = TERMINAL_SHELL) {
|
|
|
2710
2622
|
const { members, empty } = native.session(anchor, device);
|
|
2711
2623
|
try {
|
|
2712
2624
|
if (empty && exitCode !== null && subreaper) break;
|
|
2713
|
-
if (Date.now() - startedAt > ${
|
|
2625
|
+
if (Date.now() - startedAt > ${G}) throw new Error("pty_cleanup_timeout");
|
|
2714
2626
|
for (const token of members) {
|
|
2715
2627
|
if (!native.same(anchor)) throw new Error("pty_session_identity_lost");
|
|
2716
2628
|
const id = native.identityKey(token);
|
|
@@ -2726,7 +2638,7 @@ function ptyOperation(request, managed, program = TERMINAL_SHELL) {
|
|
|
2726
2638
|
controlReleased = true;
|
|
2727
2639
|
let exitTimer;
|
|
2728
2640
|
try { await Promise.race([child.exited, new Promise((_, reject) => {
|
|
2729
|
-
exitTimer = setTimeout(() => reject(new Error("pty_anchor_exit_unconfirmed")), ${
|
|
2641
|
+
exitTimer = setTimeout(() => reject(new Error("pty_anchor_exit_unconfirmed")), ${S});
|
|
2730
2642
|
})]); } finally { clearTimeout(exitTimer); }
|
|
2731
2643
|
if (timedOut) finish("timeout", 124);
|
|
2732
2644
|
else if (cancelled) finish("cancelled", 130);
|
|
@@ -2980,7 +2892,6 @@ function bashOperation(request, onProgress, managed, piShell) {
|
|
|
2980
2892
|
// This is deliberately after policy RPC awaits: a missing/revoked/stale
|
|
2981
2893
|
// snapshot cannot authorize a later asynchronous child spawn.
|
|
2982
2894
|
if (config.environmentSnapshotPath !== undefined) childEnvironment = environmentForSpawn(Boolean(piShell), Boolean(piShell && piShell.confined));
|
|
2983
|
-
if (childEnvironment?.confinementPrefix) command = [...childEnvironment.confinementPrefix, ...command];
|
|
2984
2895
|
if (managed && managed.asJobsUser) command = [...jobsUserPrefix(true), ...command];
|
|
2985
2896
|
if (preparation && childEnvironment && preparation.environmentSnapshotSha256 !== childEnvironment.fileSha256) throw new Error("environment_preparation_changed");
|
|
2986
2897
|
if (Date.now() >= initialDeadline || (preparation && !preparation.current())) throw new Error("spawn_lease_expired");
|
|
@@ -3232,8 +3143,7 @@ function replOperation(request) {
|
|
|
3232
3143
|
// araHandsPiToolsSource, and it is checked against the pinned digest and
|
|
3233
3144
|
// evaluated on first use, so worker starts never parse it. read/edit/write use
|
|
3234
3145
|
// Pi's local file operations in this process, which deliberately reach paths
|
|
3235
|
-
// outside the workspace
|
|
3236
|
-
// confinedPiFileOperations, the typed file tools' boundary, instead. pi_tool is
|
|
3146
|
+
// outside the workspace. pi_tool is
|
|
3237
3147
|
// refused where a spawn policy or command prefix confines file access to a
|
|
3238
3148
|
// child process this worker does not compose. Bash keeps Pi's
|
|
3239
3149
|
// output handling and full-output file; its spawn operation is the ordinary
|
|
@@ -3243,7 +3153,7 @@ function replOperation(request) {
|
|
|
3243
3153
|
// timeout and the lease, and background processes retained until the worker
|
|
3244
3154
|
// stops. One departure from stock: a command idle on a watcher's banner is
|
|
3245
3155
|
// stopped (PI_WATCH_BANNER). PI_* variables are not set here.
|
|
3246
|
-
const PI_TOOLS_SHA256 = "${
|
|
3156
|
+
const PI_TOOLS_SHA256 = "${u}";
|
|
3247
3157
|
const piToolsSource = typeof araHandsPiToolsSource === "function" ? araHandsPiToolsSource : null;
|
|
3248
3158
|
let piTools = null;
|
|
3249
3159
|
function loadPiTools() {
|
|
@@ -3272,10 +3182,10 @@ const PI_EXIT_STDIO_GRACE_MS = 100;
|
|
|
3272
3182
|
// the token once under quoteDepth layers of single quoting, so the confined
|
|
3273
3183
|
// script is byte-identical to what the Brain's confineBashPayload gives the
|
|
3274
3184
|
// bash tool: srt/bwrap, the payload uid, the network allowlist and allowWrite.
|
|
3275
|
-
const PI_TOOL_CONFINEMENT_TOKEN = "${
|
|
3185
|
+
const PI_TOOL_CONFINEMENT_TOKEN = "${w}";
|
|
3276
3186
|
function validPiToolConfinement(value) {
|
|
3277
3187
|
return hasOnlyKeys(value, ["template", "quoteDepth"]) && typeof value.template === "string"
|
|
3278
|
-
&& value.template.length <= ${
|
|
3188
|
+
&& value.template.length <= ${m} && !value.template.includes("\0")
|
|
3279
3189
|
&& value.template.split(PI_TOOL_CONFINEMENT_TOKEN).length === 2 && [1, 2, 3].includes(value.quoteDepth);
|
|
3280
3190
|
}
|
|
3281
3191
|
// The script T when this command is exactly this policy's confineBashPayload(T)
|
|
@@ -3463,12 +3373,6 @@ function piToolOperation(request, onProgress, confinement) {
|
|
|
3463
3373
|
const operations = piConfinedFileOperations(request.id, state, confinement, controller.signal, tool === "edit");
|
|
3464
3374
|
instance = tool === "read" ? tools.createReadTool(cwd, { operations })
|
|
3465
3375
|
: tool === "edit" ? tools.createEditTool(cwd, { operations }) : tools.createWriteTool(cwd, { operations });
|
|
3466
|
-
} else if (localGithubSandbox) {
|
|
3467
|
-
// Relative paths resolve against the canonical root workspaceTarget checks.
|
|
3468
|
-
const root = fs.realpathSync(cwd);
|
|
3469
|
-
const operations = confinedPiFileOperations(request.id, state, tool === "edit", controller.signal);
|
|
3470
|
-
instance = tool === "read" ? tools.createReadTool(root, { operations })
|
|
3471
|
-
: tool === "edit" ? tools.createEditTool(root, { operations }) : tools.createWriteTool(root, { operations });
|
|
3472
3376
|
} else {
|
|
3473
3377
|
instance = tool === "read" ? tools.createReadTool(cwd) : tool === "edit" ? tools.createEditTool(cwd) : tools.createWriteTool(cwd);
|
|
3474
3378
|
}
|
|
@@ -3772,8 +3676,8 @@ async function handleRequest(target, connectionGeneration, claim, raw) {
|
|
|
3772
3676
|
: request.tool === "pi_tool"
|
|
3773
3677
|
? piToolOperation(request, request.input.tool === "bash" ? progress : null, claim.piToolsConfinement)
|
|
3774
3678
|
: request.tool === "repl"
|
|
3775
|
-
?
|
|
3776
|
-
:
|
|
3679
|
+
? replOperation(request)
|
|
3680
|
+
: (config.spawnPolicy || config.bashCommandPrefix) && request.tool !== "read"
|
|
3777
3681
|
? payloadFileOperation(request)
|
|
3778
3682
|
: fileOperation(request);
|
|
3779
3683
|
const operation = request.workspaceBefore !== undefined
|
|
@@ -3888,10 +3792,9 @@ function handleClaim(target, connectionClaim, raw) {
|
|
|
3888
3792
|
connectionClaim.guestMemoryVersion = claim.guestMemoryVersion;
|
|
3889
3793
|
connectionClaim.guestMemoryDiagnosticsVersion = claim.guestMemoryDiagnosticsVersion;
|
|
3890
3794
|
connectionClaim.piToolsVersion = claim.piToolsVersion === 1 && piToolsAvailable() ? 1 : undefined;
|
|
3891
|
-
// The run's confinement for every pi_tool request on this connection.
|
|
3892
|
-
// GitHub confinement owns Pi's file and shell boundary there instead.
|
|
3795
|
+
// The run's confinement for every pi_tool request on this connection.
|
|
3893
3796
|
connectionClaim.piToolsConfinement = claim.piToolsConfinement !== undefined && connectionClaim.piToolsVersion === 1
|
|
3894
|
-
|
|
3797
|
+
? claim.piToolsConfinement : undefined;
|
|
3895
3798
|
// A spawn policy authorizes each Bash child only until its own deadline.
|
|
3896
3799
|
connectionClaim.backgroundBashVersion = claim.backgroundBashVersion === 1 && allowedTools.includes("bash")
|
|
3897
3800
|
&& !config.spawnPolicy ? 1 : undefined;
|
|
@@ -4091,5 +3994,5 @@ void startJobControl().then(() => {
|
|
|
4091
3994
|
try { loadJobs(); prepareRequestJournal(); } catch { process.exit(44); }
|
|
4092
3995
|
if (validPrivateJob) markReady(); else connect();
|
|
4093
3996
|
}, () => process.exit(45));
|
|
4094
|
-
`.trimStart(),
|
|
4095
|
-
export{
|
|
3997
|
+
`.trimStart(),Pt=tt("sha256").update(at,"utf8").digest("hex");
|
|
3998
|
+
export{r as Wb,Wt as Xb,f as Yb,l as Zb,et as _b,rt as $b,nt as ac,it as bc,Ht as cc,ot as dc,ct as ec,at as fc,Pt as gc};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var n=Object.create;var{getPrototypeOf:o,defineProperty:e,getOwnPropertyNames:k,getOwnPropertyDescriptor:p}=Object,l=Object.prototype.hasOwnProperty;function m(a){return this[a]}var q,r,u=(a,b,c)=>{var d=a!=null&&typeof a==="object";if(d){var h=b?q??=new WeakMap:r??=new WeakMap,i=h.get(a);if(i)return i}c=a!=null?n(o(a)):{};let f=b||!a||!a.__esModule?e(c,"default",{value:a,enumerable:!0}):c;for(let g of k(a))if(!l.call(f,g))e(f,g,{get:m.bind(a,g),enumerable:!0});if(d)h.set(a,f);return f},v=(a)=>{var b=(j??=new WeakMap).get(a),c;if(b)return b;if(b=e({},"__esModule",{value:!0}),a&&typeof a==="object"||typeof a==="function"){for(var d of k(a))if(!l.call(b,d))e(b,d,{get:m.bind(a,d),enumerable:!(c=p(a,d))||c.enumerable})}return j.set(a,b),b},j,w=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var s=(a)=>a;function t(a,b){this[a]=s.bind(null,b)}var x=(a,b)=>{for(var c in b)e(a,c,{get:b[c],enumerable:!0,configurable:!0,set:t.bind(b,c)})};var y=(a,b)=>()=>(a&&(b=a(a=0)),b);var z=import.meta.require;
|
|
3
|
-
export{u as
|
|
3
|
+
export{u as ri,v as si,w as ti,x as ui,y as vi,z as wi};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
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
|
|
3
|
+
export{c as hc,l as ic,f as jc,g as kc,d as lc};
|