@reason-machines/cli-linux-arm64 0.2.568 → 0.2.570
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/reason +1 -1
- package/bin/vm-hands/agent-network-nswyx8m2.js +2 -0
- package/bin/vm-hands/{api-credentials-ntpwt7rg.js → api-credentials-kp2sjeds.js} +1 -1
- package/bin/vm-hands/api-h2pwjbr1.js +2 -0
- package/bin/vm-hands/{ask-relay-hfa5kzxn.js → ask-relay-eqv9sq9m.js} +2 -2
- package/bin/vm-hands/connect-cli-gc79h47t.js +2 -0
- package/bin/vm-hands/{credentials-nfx99zxr.js → credentials-gwh93z0q.js} +1 -1
- package/bin/vm-hands/{custom-endpoint-device-5047vdn3.js → custom-endpoint-device-fdemgypq.js} +1 -1
- package/bin/vm-hands/desktop-account-15zym6ze.js +2 -0
- package/bin/vm-hands/desktop-components-py12mt6g.js +2 -0
- package/bin/vm-hands/{hands-worker-source-8a4kh44t.js → hands-worker-source-vd87swg4.js} +1 -1
- package/bin/vm-hands/{install-receipt-rckwjqmt.js → install-receipt-7hvy0181.js} +1 -1
- package/bin/vm-hands/local-automation-bt51qn3g.js +2 -0
- package/bin/vm-hands/local-capabilities-q9jvmztz.js +2 -0
- package/bin/vm-hands/local-display-session-j807vr40.js +2 -0
- package/bin/vm-hands/local-display-video-3b5qegyk.js +2 -0
- package/bin/vm-hands/local-managed-process-48t1899b.js +2 -0
- package/bin/vm-hands/{local-pty-session-w0yhjdvz.js → local-pty-session-bk7pp5nb.js} +1 -1
- package/bin/vm-hands/{managed-runtime-e4cj6r2s.js → managed-runtime-v7fz5zzh.js} +1 -1
- package/bin/vm-hands/{network-auto-update-8f2745gk.js → network-auto-update-1pfqzgd6.js} +2 -2
- package/bin/vm-hands/{network-contract-ht0psj5j.js → network-contract-8fjtkgma.js} +1 -1
- package/bin/vm-hands/{network-sign-in-s00679q9.js → network-sign-in-xdx20n1p.js} +1 -1
- package/bin/vm-hands/{permissions-74rj58e1.js → permissions-19yptfxx.js} +1 -1
- package/bin/vm-hands/{reason-hands-protocol-9r62swp0.js → reason-hands-protocol-yga8dh1m.js} +1 -1
- package/bin/vm-hands/{serve-service-19s965ze.js → serve-service-1sp5n0cm.js} +1 -1
- package/bin/vm-hands/{status-099b2ec1.js → status-pbv2pezp.js} +6 -6
- package/bin/vm-hands/{version-avq09c5d.js → version-w7r1n5k3.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-ksfd234v.js → vm-hands-entry-lite-10fwwbwj.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-bbjsnjct.js → vm-hands-entry-lite-13pzgnj9.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-fp3gaa2c.js → vm-hands-entry-lite-43ja1g10.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-8s5n4wps.js → vm-hands-entry-lite-4x9p79j4.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-vvhfaxpd.js → vm-hands-entry-lite-6dkjbe2b.js} +3 -3
- package/bin/vm-hands/{vm-hands-entry-lite-ezkb7f6j.js → vm-hands-entry-lite-7pj0tvht.js} +8 -8
- package/bin/vm-hands/{vm-hands-entry-lite-mktndd2r.js → vm-hands-entry-lite-7x2dnf35.js} +14 -14
- package/bin/vm-hands/{vm-hands-entry-lite-jm9jpj77.js → vm-hands-entry-lite-7z05qb3m.js} +11 -11
- package/bin/vm-hands/{vm-hands-entry-lite-bcz4qpp6.js → vm-hands-entry-lite-92qqzeas.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-0xfme8gg.js → vm-hands-entry-lite-a4fn6ye1.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-a8pm6cqb.js +10 -0
- package/bin/vm-hands/{vm-hands-entry-lite-7jmt3q38.js → vm-hands-entry-lite-asyv9pk8.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-t2rhwchw.js → vm-hands-entry-lite-cg84jcgd.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-7aeqbfc8.js → vm-hands-entry-lite-ck130wm6.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-vha0pf8k.js → vm-hands-entry-lite-ea3cts1t.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-bt6skt4h.js → vm-hands-entry-lite-ef0ergar.js} +3 -3
- package/bin/vm-hands/{vm-hands-entry-lite-9meg54bs.js → vm-hands-entry-lite-epzkdacr.js} +4 -4
- package/bin/vm-hands/{vm-hands-entry-lite-3594pdj0.js → vm-hands-entry-lite-f6np7g11.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-dhn0fs5e.js → vm-hands-entry-lite-g4e21m1g.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-4kb5rq3d.js → vm-hands-entry-lite-hnsdwskm.js} +3 -3
- package/bin/vm-hands/{vm-hands-entry-lite-rpf4t8r4.js → vm-hands-entry-lite-m4zkvq9s.js} +15 -15
- package/bin/vm-hands/{vm-hands-entry-lite-kzygj0q8.js → vm-hands-entry-lite-mayj6bpv.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-mzw2vcah.js → vm-hands-entry-lite-mkha0rqp.js} +96 -96
- package/bin/vm-hands/{vm-hands-entry-lite-1cdtev4n.js → vm-hands-entry-lite-pnx4zgd6.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-bc9zq8gx.js → vm-hands-entry-lite-sk4qxvzq.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-1as6h9ed.js → vm-hands-entry-lite-ttemn34n.js} +4 -4
- package/bin/vm-hands/{vm-hands-entry-lite-y2vqwds4.js → vm-hands-entry-lite-vgwm0t9m.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-h5x725z8.js → vm-hands-entry-lite-w4vnk4tg.js} +6 -6
- package/bin/vm-hands/{vm-hands-entry-lite-8twdd0ff.js → vm-hands-entry-lite-yqzy5wp8.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-2qh3rat2.js → vm-hands-entry-lite-ysmjfpef.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-r131db1f.js → vm-hands-entry-lite-zhxpfb3n.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-n9277v11.js → vm-hands-entry-lite-zm0707rq.js} +1 -1
- package/bin/vm-hands/vm-hands-entry-lite.js +2 -2
- package/bin/vm-hands/{vm-hands-executor-xd8v5v0e.js → vm-hands-executor-e75we703.js} +1 -1
- package/bin/vm-hands/{vm-hands-op-runner-nr4ncs4p.js → vm-hands-op-runner-86zndw34.js} +1 -1
- package/bin/vm-hands/{vm-hands-runtime-qvy5s122.js → vm-hands-runtime-ad8q3cjr.js} +3 -3
- package/bin/vm-hands/{worker-sandbox-2trfs79b.js → worker-sandbox-6aepsk73.js} +1 -1
- package/package.json +1 -1
- package/bin/vm-hands/agent-network-dw7yrrwt.js +0 -2
- package/bin/vm-hands/api-xvjq0bka.js +0 -2
- package/bin/vm-hands/connect-cli-2ja7aj4w.js +0 -2
- package/bin/vm-hands/desktop-account-d1g1m6yb.js +0 -2
- package/bin/vm-hands/desktop-components-577haqrs.js +0 -2
- package/bin/vm-hands/local-automation-fxdb4ynz.js +0 -2
- package/bin/vm-hands/local-capabilities-8fgrfpj4.js +0 -2
- package/bin/vm-hands/local-display-session-8b2hx1k6.js +0 -2
- package/bin/vm-hands/local-display-video-511qjgmq.js +0 -2
- package/bin/vm-hands/local-managed-process-h0fypn67.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-rd7bm9we.js +0 -10
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t,o,n,
|
|
2
|
+
import{t,o,n,be,$e,c,i}from"./vm-hands-entry-lite-ef0ergar.js";var rr="inference.custom.v1",Br=32768,Un=67108864,Ki=16384,Fr=4194304,h=204800,jr=2*Fr+65536,pa=600000,E=["content-type","anthropic-version","user-agent"],m=c(["openai-completions","openai-responses","anthropic-messages"]),f=new Set(E),C=$e(t(),t().max(2048)).refine((e)=>Object.keys(e).every((s)=>f.has(s))&&Object.values(e).every((s)=>!/[\r\n\0]/.test(s)),"Only non-secret custom endpoint request headers are permitted");function u(e){try{let s=new URL(e);return["http:","https:"].includes(s.protocol)&&!s.username&&!s.password&&!s.search&&!s.hash?s:null}catch{return null}}function Ji(e,s){let r=u(e.baseUrl),d=u(s.baseUrl),a=u(e.url);if(!r||!d||!a||e.method!=="POST"||s.execution!=="device")return!1;let l=(p)=>p.origin+p.pathname.replace(/\/+$/,"");if(l(r)!==l(d)||a.origin!==r.origin)return!1;let _=s.api==="openai-completions"?"/chat/completions":s.api==="openai-responses"?"/responses":"/v1/messages";return a.pathname===r.pathname.replace(/\/+$/,"")+_}var ha=n({baseUrl:t().max(2048),url:t().max(4096),method:i("POST"),body:t().refine((e)=>new TextEncoder().encode(e).byteLength<=Fr).optional(),headers:C,credentialOrganizationId:t().uuid(),accountKey:t().min(1).max(256).optional()}).strict().refine((e)=>m.options.some((s)=>Ji(e,{baseUrl:e.baseUrl,api:s,execution:"device"})),"Invalid custom endpoint inference URL"),D=n({status:o().int().min(200).max(599),statusText:t().max(256).refine((e)=>!/[\r\n\0]/.test(e)),headers:$e(t(),t().max(4096)).refine((e)=>Object.keys(e).every((s)=>["content-type","retry-after","x-request-id","request-id"].includes(s))&&Object.values(e).every((s)=>!/[\r\n\0]/.test(s)))}).strict(),y=be([n({eof:i(!0)}).strict(),n({eof:i(!1),data:t().max(Math.ceil(Br/3)*4).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/).refine((e)=>e.length>0&&e.length*3/4-(e.endsWith("==")?2:e.endsWith("=")?1:0)<=Br)}).strict()]),x=n({bytes:o().int().min(0).max(Un),chunks:o().int().min(0).max(Ki)}).strict(),fa=n({apiKey:t().min(1).max(16384).refine((e)=>!/[\r\n\0]/.test(e)),api:m}).strict(),S=["custom_endpoint_host_not_found","custom_endpoint_connection_failed","custom_endpoint_tls_failed","custom_endpoint_request_too_large","custom_endpoint_device_update_required"];function Hr(e){return typeof e==="string"&&S.includes(e)}var O="Ollama listens only on 127.0.0.1 unless it is started with OLLAMA_HOST=0.0.0.0.",T={custom_endpoint_host_not_found:"Your computer couldn't resolve your model server's hostname. Check the hostname in the Base URL, and that this computer is on the network or tailnet that resolves it.",custom_endpoint_connection_failed:`Your computer's connection to your model server was refused or timed out. Check that the server is running and listening on the Base URL's address and port. ${O}`,custom_endpoint_tls_failed:"Your computer couldn't make a secure (TLS) connection to your model server. Check the server's https certificate, or use an http:// Base URL for a server on your computer or private network.",custom_endpoint_request_too_large:`This conversation is too long for your computer to send to your model server: the request is over ${Fr/1024/1024} MB, the most it relays. Start a new session to continue, or choose another model.`,custom_endpoint_device_update_required:`Reason on your computer is too old to send this conversation to your model server: it relays requests of at most ${h/1024} KB. Update Reason on that computer (reason update), then send your message again.`,401:"Your model server refused the request (HTTP 401). Check the API key saved for it in Models.",403:"Your model server refused the request (HTTP 403). Ollama refuses requests addressed to a hostname other than localhost, such as a *.ts.net name from tailscale serve or funnel: restart it with OLLAMA_HOST=0.0.0.0, or use http://localhost:11434/v1 when it runs on the session's computer. For another server, check the API key and its access rules.",404:"Your model server answered HTTP 404 (not found). Check that the Base URL is the API root (for Ollama, http://localhost:11434/v1) and that each model ID is one the server lists."};var I=new Set(Object.values(T));export{rr,Br,Un,Ki,Fr,jr,pa,Ji,ha,fa,Hr};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{te}from"./vm-hands-entry-lite-hpw27zfb.js";var pc=32;var hc="__ARA_PI_TOOL_CONFINED_SCRIPT_5f0c9e2a__",fc=262144;var F=2,ki=33554432,xi=200000,Ho=4000000,_r=240000;var Uo=2000;var Ci=16384,qt=32768,_t=128,zo=64,Wt=2097152,yn=1,He=16384,Vt=32768,qo=8388608,yt=1000,wn=2500,Ai=2000,bn=wn+Ai,R=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,199}$/,h=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,Pi={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(Pi).map(([t,n])=>[n,t]));var N=["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"],I=new Set(N),Wo=16384,y=["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 r extends Error{code;constructor(t){super(t);this.name="HandsProtocolError",this.code=t}}function m(t){return new TextEncoder().encode(t).byteLength}function a(t){return typeof t==="object"&&t!==null&&!Array.isArray(t)}function i(t,n){let e=new Set(n);return Object.keys(t).every((s)=>e.has(s))}function nt(t){return typeof t==="string"&&R.test(t)}function
|
|
2
|
+
import{te}from"./vm-hands-entry-lite-hpw27zfb.js";var pc=32;var hc="__ARA_PI_TOOL_CONFINED_SCRIPT_5f0c9e2a__",fc=262144;var F=2,ki=33554432,xi=200000,Ho=4000000,_r=240000;var Uo=2000;var Ci=16384,qt=32768,_t=128,zo=64,Wt=2097152,yn=1,He=16384,Vt=32768,qo=8388608,yt=1000,wn=2500,Ai=2000,bn=wn+Ai,R=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,199}$/,h=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,Pi={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(Pi).map(([t,n])=>[n,t]));var N=["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"],I=new Set(N),Wo=16384,y=["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 r extends Error{code;constructor(t){super(t);this.name="HandsProtocolError",this.code=t}}function m(t){return new TextEncoder().encode(t).byteLength}function a(t){return typeof t==="object"&&t!==null&&!Array.isArray(t)}function i(t,n){let e=new Set(n);return Object.keys(t).every((s)=>e.has(s))}function nt(t){return typeof t==="string"&&R.test(t)}function ke(t){return Number.isSafeInteger(t)&&Number(t)>=1}function le(t){return typeof t==="string"&&h.test(t)}function it(t){return typeof t==="string"&&t.startsWith("pty-")&&le(t.slice(4))}function p(t){return[t.cols,t.rows].every((n)=>Number.isSafeInteger(n)&&Number(n)>=1&&Number(n)<=yt)}function _(t){if(typeof t!=="string"||t.length>Math.ceil(He/3)*4||t.length%4!==0||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t))return-1;let n=t.endsWith("==")?2:t.endsWith("=")?1:0;if(n&&"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(t[t.length-n-1])&(n===2?15:3))return-1;let s=t.length/4*3-n;return s<=He?s:-1}function l(t){if(m(t)>ki)throw new r("frame_too_large");try{return JSON.parse(t)}catch{throw new r("invalid_json")}}function Ri(t){let n=l(t);if(!a(n)||!i(n,["type","version","generation","id","jobId","action","input"])||n.type!=="job"||n.version!==F||!ke(n.generation)||!nt(n.id)||!nt(n.jobId)||!a(n.input))throw new r("invalid_job_request");let e=n.input,s=Number.isSafeInteger(e.leaseExpiresAtMs)&&Number(e.leaseExpiresAtMs)>0,d=Number.isSafeInteger(e.sequence)&&Number(e.sequence)>=1;if(!(n.action==="start"?e.mode==="pty"?i(e,["mode","cols","rows","leaseExpiresAtMs"])&&it(n.jobId)&&p(e)&&s:i(e,["script","leaseExpiresAtMs"])&&typeof e.script==="string"&&e.script.length<=xi&&s:n.action==="inspect"?i(e,["after"])&&Number.isSafeInteger(e.after)&&Number(e.after)>=0:n.action==="input"?"dataBase64"in e?i(e,["sequence","dataBase64"])&&it(n.jobId)&&d&&_(e.dataBase64)>0:i(e,["sequence","data","eof"])&&d&&typeof e.data==="string"&&e.data.length<=Ci&&typeof e.eof==="boolean":n.action==="resize"?i(e,["sequence","cols","rows"])&&it(n.jobId)&&d&&p(e):n.action==="renew"?i(e,["leaseExpiresAtMs"])&&s:n.action==="cancel"&&i(e,[])))throw new r("invalid_job_request");return n}function Ti(t){let n=l(t);if(!a(n)||!i(n,["type","version","generation","id","ok","job","error"])||n.type!=="job_result"||n.version!==F||!ke(n.generation)||!nt(n.id))throw new r("invalid_job_result");if(n.ok===!1&&n.job===void 0&&typeof n.error==="string"&&y.some((o)=>o===n.error))return n;let e=n.job;if(n.ok!==!0||n.error!==void 0||!a(e)||!i(e,["jobId","state","startedAtMs","finishedAtMs","leaseExpiresAtMs","exitCode","inputSequence","output","firstCursor","nextCursor","truncated","process","environmentRevision","environmentSnapshotId","pty"])||!nt(e.jobId)||!["starting","running","exited","cancelled","expired","uncertain"].includes(String(e.state))||!Number.isSafeInteger(e.startedAtMs)||Number(e.startedAtMs)<1||!Number.isSafeInteger(e.leaseExpiresAtMs)||Number(e.leaseExpiresAtMs)<1||e.finishedAtMs!==null&&(!Number.isSafeInteger(e.finishedAtMs)||Number(e.finishedAtMs)<Number(e.startedAtMs))||e.exitCode!==null&&(!Number.isSafeInteger(e.exitCode)||Number(e.exitCode)<0||Number(e.exitCode)>255)||!Number.isSafeInteger(e.inputSequence)||Number(e.inputSequence)<0||!Number.isSafeInteger(e.firstCursor)||Number(e.firstCursor)<1||!Number.isSafeInteger(e.nextCursor)||Number(e.nextCursor)<Number(e.firstCursor)-1||typeof e.truncated!=="boolean"||!Array.isArray(e.output)||e.output.length>_t)throw new r("invalid_job_result");if(e.environmentRevision===void 0!==(e.environmentSnapshotId===void 0)||e.environmentRevision!==void 0&&(!Number.isSafeInteger(e.environmentRevision)||Number(e.environmentRevision)<1||!le(e.environmentSnapshotId)))throw new r("invalid_job_result");let s=Number(e.firstCursor)-1,d=0;for(let o of e.output){if(!a(o)||!i(o,["cursor","stream","text"])||!Number.isSafeInteger(o.cursor)||Number(o.cursor)<=s||Number(o.cursor)>Number(e.nextCursor)||!["stdout","stderr"].includes(String(o.stream))||typeof o.text!=="string")throw new r("invalid_job_result");d+=o.text.length,s=Number(o.cursor)}if(d>qt)throw new r("invalid_job_result");let c=e.state==="starting"||e.state==="running";if(c&&(e.finishedAtMs!==null||e.exitCode!==null)||!c&&e.finishedAtMs===null||e.state==="uncertain"&&e.exitCode!==null||e.state==="exited"&&e.exitCode===null||e.state==="cancelled"&&e.exitCode!==130||e.state==="expired"&&e.exitCode!==124)throw new r("invalid_job_result");if(e.process!==void 0){let o=e.process;if(!a(o)||!i(o,["pid","processGroupId","executorLaunchId"])||!Number.isSafeInteger(o.pid)||Number(o.pid)<1||o.processGroupId!==o.pid||!le(o.executorLaunchId)||!["starting","running"].includes(String(e.state)))throw new r("invalid_job_result")}if(e.pty!==void 0){let o=e.pty;if(!a(o)||!i(o,["version","cols","rows","output","cleanup"])||o.version!==yn||!it(e.jobId)||!p(o)||e.output.length!==0||!Array.isArray(o.output)||o.output.length>_t||(c?o.cleanup!=="pending":e.state==="uncertain"?o.cleanup!=="unconfirmed":o.cleanup!=="confirmed")||e.state==="running"&&(e.process===void 0||e.environmentRevision===void 0))throw new r("invalid_job_result");let g=Number(e.firstCursor)-1,b=0;for(let u of o.output){if(!a(u)||!i(u,["cursor","dataBase64"])||!Number.isSafeInteger(u.cursor)||Number(u.cursor)<=g||Number(u.cursor)>Number(e.nextCursor))throw new r("invalid_job_result");let f=_(u.dataBase64);if(f<=0||(b+=f)>Vt)throw new r("invalid_job_result");g=Number(u.cursor)}}return n}function Vo(t){if(m(t)>Wt)throw new r("frame_too_large");let n=l(t);if(!a(n)||!i(n,["version","sessionId","operationId","runId","deviceId","rootId","workspace","binding","targetRevision","rootGrantRevision","generation","fenceId","executorLaunchId","job"])||n.version!==yn||![n.sessionId,n.operationId,n.runId].every(nt)||![n.deviceId,n.rootId,n.fenceId,n.executorLaunchId].every(le)||!ke(n.generation)||!Number.isSafeInteger(n.rootGrantRevision)||Number(n.rootGrantRevision)<1||!["workspace_source","mcp_control"].includes(String(n.binding))||!Number.isSafeInteger(n.targetRevision)||Number(n.targetRevision)<0||n.binding==="workspace_source"&&n.targetRevision!==0||!a(n.workspace))throw new r("invalid_pty_receipt");if(!te(n.workspace))throw new r("invalid_pty_receipt");let e=Ti(JSON.stringify({type:"job_result",version:F,generation:n.generation,id:n.operationId,ok:!0,job:n.job}));if(!e.ok||!e.job.pty||e.job.pty.output.length!==0||e.job.process&&e.job.process.executorLaunchId!==n.executorLaunchId)throw new r("invalid_pty_receipt");return n}export{pc,hc,fc,F,ki,xi,Ho,_r,Uo,Ci,qt,_t,zo,Wt,yn,He,Vt,qo,yt,wn,Ai,bn,Pi,Wo,nt,ke,le,it,Ri,Ti,Vo};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{w,An}from"./vm-hands-entry-lite-0xfme8gg.js";import{En}from"./vm-hands-entry-lite-sb1xtqxr.js";import{Bi,De,wt}from"./vm-hands-entry-lite-peyr9y6z.js";import{s}from"./vm-hands-entry-lite-tzv8s0e7.js";import{t,n,c,i}from"./vm-hands-entry-lite-bt6skt4h.js";import{createHmac as Le,createPublicKey as we,randomBytes as Ae,randomUUID as G,verify as Pe}from"crypto";import{chmodSync as P,existsSync as H,mkdirSync as Ee,readFileSync as Re,realpathSync as xe,renameSync as Ne,statSync as Oe,unlinkSync as Ke,writeFileSync as Ce}from"fs";import{basename as Te,dirname as R,isAbsolute as J,join as h,resolve as Ue}from"path";var We=[Object.freeze({family:"ara",channel:"stable",applicationId:"so.ara.desktop"}),Object.freeze({family:"ara",channel:"staging",applicationId:"so.ara.desktop.staging"}),Object.freeze({family:"reason",channel:"stable",applicationId:"com.reasonmachines.desktop"}),Object.freeze({family:"reason",channel:"staging",applicationId:"com.reasonmachines.desktop.staging"})];var te="REASON_DESKTOP_RUNTIME",ne="REASON_DESKTOP_RUNTIME_CHANNEL",ie="REASON_DESKTOP_RUNTIME_INSTANCE_ID",re="REASON_DESKTOP_RUNTIME_WORKSPACE_SCOPE",it={[te]:"ARA_DESKTOP_RUNTIME",[ne]:"ARA_DESKTOP_RUNTIME_CHANNEL",[ie]:"ARA_DESKTOP_RUNTIME_INSTANCE_ID",[re]:"ARA_DESKTOP_RUNTIME_WORKSPACE_SCOPE"};function K(e){if(e===void 0)return;if(!/^[a-f0-9]{64}$/.test(e))throw Error("Invalid desktop workspace scope.");return e}import{chmodSync as S,existsSync as y,mkdirSync as I,readFileSync as C,realpathSync as oe,renameSync as se,unlinkSync as k,writeFileSync as D}from"fs";import{createPrivateKey as ce,createPublicKey as le,generateKeyPairSync as de,randomUUID as ue,sign as pe}from"crypto";import{createRequire as ge}from"module";import{homedir as fe,platform as M}from"os";import{dirname as ye,join as v}from"path";var T=1,ve=16384,_=65536,_e=128,be=128,j=65536;class a extends Error{code;nativeStatus;constructor(e,r){super(`Reason Device proof boundary failed (${e}).${r===void 0?"":` Native status: ${r}.`}`);this.code=e;this.nativeStatus=r;this.name="LocalCredentialBoundaryError"}}function V(e){if(e.code==="proof_key_read_failed"&&e.nativeStatus===-25300)return"proof_key_missing";switch(e.nativeStatus){case-25308:return"keychain_interaction_required";case-25293:return"keychain_access_denied";case-25291:return"keychain_unavailable";default:return e.code}}var L=null;function B(){if(!L)try{L=ge(import.meta.url)("bun:ffi")}catch{throw new a("native_boundary_unavailable")}return L}function me(e){if(typeof e!=="string")return null;try{let r=new URL(e);if(r.protocol!=="https:"&&r.hostname!=="127.0.0.1"&&r.hostname!=="localhost"&&r.hostname!=="[::1]"&&r.hostname!=="::1")return null;return r.origin}catch{return null}}function he(e){if(!e||typeof e!=="object"||Array.isArray(e))throw new a("invalid_credential_record");let r=e,o=me(r.apiOrigin);if(r.version!==T||!o||typeof r.orgId!=="string"||r.orgId.length<1||r.orgId.length>160||typeof r.deviceId!=="string"||r.deviceId.length<1||r.deviceId.length>160||typeof r.credential!=="string"||!/^(?:reason|ara)_dev_/.test(r.credential)||r.credential.length>4096)throw new a("invalid_credential_record");return{version:T,apiOrigin:o,orgId:r.orgId,deviceId:r.deviceId,credential:r.credential}}function fn(e=process.execPath){let r=e;try{r=oe(e)}catch{}return En(ye(r))}function p(e){return B().ptr(e)}function Ie(e){if(!y(e))throw new a("native_boundary_unavailable");let{dlopen:r,FFIType:o}=B();try{return r(e,{ara_device_configure_scope:{args:[o.ptr,o.u64],returns:o.i32},ara_device_key_load_public:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_create_fresh_public:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_sign:{args:[o.ptr,o.u64,o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_is_non_extractable:{args:[o.ptr],returns:o.i32},ara_device_key_delete:{args:[o.ptr],returns:o.i32},ara_device_binding_read:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_binding_create:{args:[o.ptr,o.u64],returns:o.i32},ara_device_binding_update:{args:[o.ptr,o.u64],returns:o.i32},ara_device_binding_delete:{args:[o.ptr],returns:o.i32},ara_device_keychain_read:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_keychain_delete:{args:[o.ptr],returns:o.i32}})}catch(l){if(l instanceof a)throw l;throw new a("native_boundary_unavailable")}}function U(e){return Buffer.from(e).toString("base64url")}function Ht(e){if(typeof e!=="string"||!/^[A-Za-z0-9_-]{87}$/.test(e))return!1;try{let r=Buffer.from(e,"base64url");return r.byteLength===65&&r[0]===4}catch{return!1}}function Si(e){if(e.byteLength<8||e.byteLength>72||e[0]!==48)return!1;let r=e[1];return r!==void 0&&r<128&&r+2===e.byteLength}class mt{libraryPath;runtimePlatform;workspaceScope;library=null;constructor(e=fn(),r=M(),o){this.libraryPath=e;this.runtimePlatform=r;this.workspaceScope=o;K(o)}symbols(){if(this.runtimePlatform!=="darwin")throw new a("unsupported_platform");this.library??=Ie(this.libraryPath);let e=new TextEncoder().encode(this.workspaceScope??""),r=this.library.symbols.ara_device_configure_scope(p(e.length?e:new Uint8Array(1)),BigInt(e.length));if(r!==0)throw new a("native_boundary_unavailable",r);return this.library.symbols}publicKey(e){let r=new Uint8Array(_e),o=new BigUint64Array(1),l=e==="load"?this.symbols().ara_device_key_load_public(p(r),BigInt(r.byteLength),p(o)):this.symbols().ara_device_key_create_fresh_public(p(r),BigInt(r.byteLength),p(o));if(l!==0)throw new a(e==="load"?"proof_key_read_failed":"proof_key_generation_failed",l);let d=Number(o[0]);if(!Number.isSafeInteger(d)||d!==65)throw new a("invalid_public_key");let u=U(r.subarray(0,d));if(!Ht(u))throw new a("invalid_public_key");return u}loadPublicKey(){return this.publicKey("load")}createFreshPublicKey(){return this.publicKey("create_fresh")}sign(e){if(e.byteLength<1||e.byteLength>j)throw new a("proof_sign_failed");let r=new Uint8Array(be),o=new BigUint64Array(1),l=this.symbols().ara_device_key_sign(p(e),BigInt(e.byteLength),p(r),BigInt(r.byteLength),p(o));if(l!==0)throw new a("proof_sign_failed",l);let d=Number(o[0]);if(!Number.isSafeInteger(d)||d<1||d>r.byteLength)throw new a("invalid_signature");let u=r.subarray(0,d);if(!Si(u))throw new a("invalid_signature");return U(u)}privateKeyIsNonExtractable(){let e=new Uint8Array(1),r=this.symbols().ara_device_key_is_non_extractable(p(e));if(r!==0||e[0]!==1)throw new a("proof_key_read_failed",r);return!0}deleteKey(){let e=new Uint8Array(1),r=this.symbols().ara_device_key_delete(p(e));if(r!==0)throw new a("proof_key_delete_failed",r);return e[0]===1}loadBinding(){let e=new Uint8Array(_),r=new BigUint64Array(1),o=this.symbols().ara_device_binding_read(p(e),BigInt(e.byteLength),p(r));if(o===1)return null;if(o!==0)throw new a("binding_read_failed",o);let l=Number(r[0]);if(!Number.isSafeInteger(l)||l<1||l>e.byteLength)throw new a("invalid_binding");return e.slice(0,l)}createBinding(e){if(e.byteLength<1||e.byteLength>_)throw new a("invalid_binding");let r=this.symbols().ara_device_binding_create(p(e),BigInt(e.byteLength));if(r!==0)throw new a("binding_create_failed",r)}updateBinding(e){if(e.byteLength<1||e.byteLength>_)throw new a("invalid_binding");let r=this.symbols().ara_device_binding_update(p(e),BigInt(e.byteLength));if(r!==0)throw new a("binding_update_failed",r)}deleteBinding(){let e=new Uint8Array(1),r=this.symbols().ara_device_binding_delete(p(e));if(r!==0)throw new a("binding_delete_failed",r);return e[0]===1}loadLegacyCredential(){let e=new Uint8Array(ve),r=new BigUint64Array(1),o=this.symbols().ara_device_keychain_read(p(e),BigInt(e.byteLength),p(r));if(o===1)return null;if(o!==0)throw new a("legacy_credential_read_failed",o);let l=Number(r[0]);if(!Number.isSafeInteger(l)||l<1||l>e.byteLength)throw new a("invalid_credential_record");try{let d=new TextDecoder("utf-8",{fatal:!0}).decode(e.subarray(0,l));return he(JSON.parse(d))}catch(d){if(d instanceof a)throw d;throw new a("invalid_credential_record")}}deleteLegacyCredential(){let e=new Uint8Array(1),r=this.symbols().ara_device_keychain_delete(p(e));if(r!==0)throw new a("legacy_credential_delete_failed",r);return e[0]===1}}function F(e){let r=e.export({format:"jwk"});if(r.crv!=="P-256"||typeof r.x!=="string"||typeof r.y!=="string")throw new a("invalid_public_key");let o=Buffer.from(r.x,"base64url"),l=Buffer.from(r.y,"base64url");if(o.byteLength!==32||l.byteLength!==32)throw new a("invalid_public_key");let d=Buffer.concat([Buffer.of(4),o,l]).toString("base64url");if(!Ht(d))throw new a("invalid_public_key");return d}function ke(){let e=process.env.XDG_CONFIG_HOME?.trim()||v(fe(),".config");De(e);let r=v(e,"ara");return Bi(r)?r:v(e,"reason")}class mn{directory;constructor(e=ke()){this.directory=e}keyPath(){return v(this.directory,"local-device.key")}bindingPath(){return v(this.directory,"local-device.binding")}loadPrivateKeyObject(){let e=this.keyPath();if(!y(e))throw new a("proof_key_read_failed");try{let r=C(e,"utf8");return ce({key:r,format:"pem"})}catch{throw new a("proof_key_read_failed")}}loadPublicKey(){let e=this.loadPrivateKeyObject(),r=le(e);return F(r)}createFreshPublicKey(){I(this.directory,{recursive:!0,mode:448});let{privateKey:e,publicKey:r}=de("ec",{namedCurve:"P-256"}),o=e.export({type:"pkcs8",format:"pem"}),l=this.keyPath();return D(l,o,{mode:384}),S(l,384),F(r)}sign(e){if(e.byteLength<1||e.byteLength>j)throw new a("proof_sign_failed");let r=this.loadPrivateKeyObject(),o;try{o=pe("sha256",e,r)}catch{throw new a("proof_sign_failed")}if(!Si(o))throw new a("invalid_signature");return o.toString("base64url")}privateKeyIsNonExtractable(){return!1}deleteKey(){let e=this.keyPath();if(!y(e))return!1;return k(e),!0}loadBinding(){let e=this.bindingPath();if(!y(e))return null;try{return new Uint8Array(C(e))}catch{return null}}createBinding(e){if(e.byteLength<1||e.byteLength>_)throw new a("invalid_binding");I(this.directory,{recursive:!0,mode:448});let r=this.bindingPath();if(y(r))throw new a("binding_create_failed");D(r,e,{mode:384}),S(r,384)}updateBinding(e){if(e.byteLength<1||e.byteLength>_)throw new a("invalid_binding");I(this.directory,{recursive:!0,mode:448});let r=this.bindingPath();if(!y(r))throw new a("binding_update_failed");let o=`${r}.${ue()}`;try{D(o,e,{mode:384,flag:"wx"}),S(o,384),se(o,r)}finally{if(y(o))k(o)}}deleteBinding(){let e=this.bindingPath();if(!y(e))return!1;return k(e),!0}loadLegacyCredential(){return null}deleteLegacyCredential(){return!1}}function A(){return M()==="darwin"?new mt:new mn}var b=t().min(1).max(160).regex(/^[A-Za-z0-9._:-]+$/),z=n({id:b,kind:i("permission_denied"),operation:c(["bash","read","write","edit"]),provenance:c(["sandbox_policy","os_permission_unknown"]),occurredAt:t().datetime(),expiresAt:t().datetime(),sessionId:b,deviceId:b,organizationId:b}).strict();var x=4;var m="macos-keychain-p256-v1",Y=1,Fe=`ARA-DEVICE-BINDING-V1
|
|
3
|
-
`;function Me(e){return e===void 0||typeof e==="number"&&Number.isInteger(e)&&e>=1&&e<=4}function fr(e,r=Date.now()){let o=z.safeParse(e);if(!o.success)return!1;let l=o.data,d=typeof l.occurredAt==="string"?Date.parse(l.occurredAt):NaN,u=typeof l.expiresAt==="string"?Date.parse(l.expiresAt):NaN;return l.kind==="permission_denied"&&["bash","read","write","edit"].includes(l.operation)&&["sandbox_policy","os_permission_unknown"].includes(l.provenance)&&Number.isFinite(d)&&d<=r&&u>r&&u>d&&u-d<=600000}function gn(e,r,o=Date.now()){if(!e||!r||e.state!=="connected"||e.deviceId!==r.deviceId)return null;let l=Date.parse(e.lastHeartbeatAt??""),d=e.permissionRecovery;if(!(o-l>=0&&o-l<30000)||!fr(d,o)||d.deviceId!==r.deviceId||d.organizationId!==r.orgId)return null;try{process.kill(e.pid,0)}catch{return null}return d}function X(e={},r=s()){let o=w({env:{...process.env,...e}}),l=e.XDG_CONFIG_HOME?.trim()||h(r,".config");return wt(l,...o==="staging"?["staging"]:[])}function gt(e={},r=s()){return h(X(e,r),"local-device.json")}function mr(e={},r=s()){return h(X(e,r),"local-daemon.json")}function N(e,r){
|
|
4
|
-
`,{mode:384,flag:"wx"}),P(o,384),Ne(o,e),P(e,384)}finally{if(H(o))Ke(o)}return e}function O(e){if(!H(e))return null;try{return JSON.parse(Re(e,"utf8"))}catch{return null}}function E(e,r,o){try{e.onCredentialLifecycle?.({event:r,...o?{reasonCode:o}:{}})}catch{}}function je(e){if(!Array.isArray(e))return null;let r=[];for(let o of e){if(!o||typeof o!=="object")return null;let l=o;if(typeof l.id!=="string"||typeof l.label!=="string"||typeof l.path!=="string"||typeof l.pathFingerprint!=="string"||!l.permissions||typeof l.permissions.read!=="boolean"||typeof l.permissions.write!=="boolean"||typeof l.permissions.execute!=="boolean"||typeof l.permissions.discover_environment!=="boolean"||typeof l.permissions.expose_mcp!=="boolean")return null;r.push({id:l.id,label:l.label,path:l.path,pathFingerprint:l.pathFingerprint,permissions:l.permissions})}return r}function W(e,r,o=[]){let l=Object.keys(e);return r.every((d)=>Object.hasOwn(e,d))&&l.every((d)=>r.includes(d)||o.includes(d))}function Ve(e){if(typeof e!=="string")return null;try{let r=new URL(e);if(r.protocol!=="https:"&&r.hostname!=="127.0.0.1"&&r.hostname!=="localhost")return null;return r.origin}catch{return null}}function Z(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let r=e,o=je(r.roots),l=Ve(r.apiOrigin);if(!l||typeof r.orgId!=="string"||typeof r.deviceId!=="string"||typeof r.displayName!=="string"||typeof r.registeredAt!=="string"||!Me(r.handsSlots)||r.worker!==void 0&&(!r.worker||!/^[a-f0-9]{64}$/.test(r.worker.configDigest)||!["persistent","ephemeral"].includes(r.worker.lifetime)||!Number.isFinite(Date.parse(r.worker.expiresAt)))||!o)return null;return{apiOrigin:l,orgId:r.orgId,deviceId:r.deviceId,displayName:r.displayName,registeredAt:r.registeredAt,...r.handsSlots!==void 0?{handsSlots:r.handsSlots}:{},...r.worker!==void 0?{worker:r.worker}:{},roots:o}}function Be(e){return{...e,credentialStorage:m}}function $e(e){return{version:x,apiOrigin:e.apiOrigin,orgId:e.orgId,deviceId:e.deviceId,devicePublicKey:e.devicePublicKey,displayName:e.displayName,registeredAt:e.registeredAt,...e.handsSlots!==void 0?{handsSlots:e.handsSlots}:{},...e.worker!==void 0?{worker:e.worker}:{},roots:e.roots.map((r)=>({id:r.id,label:r.label,path:r.path,pathFingerprint:r.pathFingerprint,permissions:{read:r.permissions.read,write:r.permissions.write,execute:r.permissions.execute,discover_environment:r.permissions.discover_environment,expose_mcp:r.permissions.expose_mcp}})),credentialStorage:m}}function q(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let r=e;if(!W(r,["version","apiOrigin","orgId","deviceId","devicePublicKey","displayName","registeredAt","roots","credentialStorage"],["handsSlots","worker"]))return null;let o=Z(r);if(!o||r.version!==x||r.credentialStorage!==m||!Ht(r.devicePublicKey))return null;return{version:x,...o,devicePublicKey:r.devicePublicKey,credentialStorage:m}}function Q(e){return new TextEncoder().encode(`${Fe}${JSON.stringify($e(e))}`)}function ze(e){let r=Buffer.from(e,"base64url");return
|
|
5
|
-
export{a,fn,Ht,Si,mt,mn,fr,gn,gt,mr,Ut,
|
|
2
|
+
import{w,An}from"./vm-hands-entry-lite-a4fn6ye1.js";import{En}from"./vm-hands-entry-lite-sb1xtqxr.js";import{Bi,De,wt}from"./vm-hands-entry-lite-peyr9y6z.js";import{s}from"./vm-hands-entry-lite-tzv8s0e7.js";import{t,n,c,i}from"./vm-hands-entry-lite-ef0ergar.js";import{createHmac as ke,createPublicKey as Le,randomBytes as we,randomUUID as G,verify as Ae}from"crypto";import{chmodSync as P,existsSync as H,mkdirSync as Pe,readFileSync as Re,realpathSync as xe,renameSync as Ne,statSync as Oe,unlinkSync as Ke,writeFileSync as Ce}from"fs";import{basename as Te,dirname as R,isAbsolute as J,join as h,resolve as Ue}from"path";var We=[Object.freeze({family:"ara",channel:"stable",applicationId:"so.ara.desktop"}),Object.freeze({family:"ara",channel:"staging",applicationId:"so.ara.desktop.staging"}),Object.freeze({family:"reason",channel:"stable",applicationId:"com.reasonmachines.desktop"}),Object.freeze({family:"reason",channel:"staging",applicationId:"com.reasonmachines.desktop.staging"})];var te="REASON_DESKTOP_RUNTIME",ne="REASON_DESKTOP_RUNTIME_CHANNEL",ie="REASON_DESKTOP_RUNTIME_INSTANCE_ID",re="REASON_DESKTOP_RUNTIME_WORKSPACE_SCOPE",it={[te]:"ARA_DESKTOP_RUNTIME",[ne]:"ARA_DESKTOP_RUNTIME_CHANNEL",[ie]:"ARA_DESKTOP_RUNTIME_INSTANCE_ID",[re]:"ARA_DESKTOP_RUNTIME_WORKSPACE_SCOPE"};function K(e){if(e===void 0)return;if(!/^[a-f0-9]{64}$/.test(e))throw Error("Invalid desktop workspace scope.");return e}import{chmodSync as S,existsSync as y,mkdirSync as I,readFileSync as C,realpathSync as oe,renameSync as ae,unlinkSync as k,writeFileSync as D}from"fs";import{createPrivateKey as se,createPublicKey as le,generateKeyPairSync as de,randomUUID as ue,sign as pe}from"crypto";import{createRequire as ge}from"module";import{homedir as fe,platform as M}from"os";import{dirname as ye,join as v}from"path";var T=1,ve=16384,_=65536,_e=128,be=128,j=65536;class a extends Error{code;nativeStatus;constructor(e,r){super(`Reason Device proof boundary failed (${e}).${r===void 0?"":` Native status: ${r}.`}`);this.code=e;this.nativeStatus=r;this.name="LocalCredentialBoundaryError"}}function V(e){if(e.code==="proof_key_read_failed"&&e.nativeStatus===-25300)return"proof_key_missing";switch(e.nativeStatus){case-25308:return"keychain_interaction_required";case-25293:return"keychain_access_denied";case-25291:return"keychain_unavailable";default:return e.code}}var L=null;function B(){if(!L)try{L=ge(import.meta.url)("bun:ffi")}catch{throw new a("native_boundary_unavailable")}return L}function me(e){if(typeof e!=="string")return null;try{let r=new URL(e);if(r.protocol!=="https:"&&r.hostname!=="127.0.0.1"&&r.hostname!=="localhost"&&r.hostname!=="[::1]"&&r.hostname!=="::1")return null;return r.origin}catch{return null}}function he(e){if(!e||typeof e!=="object"||Array.isArray(e))throw new a("invalid_credential_record");let r=e,o=me(r.apiOrigin);if(r.version!==T||!o||typeof r.orgId!=="string"||r.orgId.length<1||r.orgId.length>160||typeof r.deviceId!=="string"||r.deviceId.length<1||r.deviceId.length>160||typeof r.credential!=="string"||!/^(?:reason|ara)_dev_/.test(r.credential)||r.credential.length>4096)throw new a("invalid_credential_record");return{version:T,apiOrigin:o,orgId:r.orgId,deviceId:r.deviceId,credential:r.credential}}function fn(e=process.execPath){let r=e;try{r=oe(e)}catch{}return En(ye(r))}function p(e){return B().ptr(e)}function Se(e){if(!y(e))throw new a("native_boundary_unavailable");let{dlopen:r,FFIType:o}=B();try{return r(e,{ara_device_configure_scope:{args:[o.ptr,o.u64],returns:o.i32},ara_device_key_load_public:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_create_fresh_public:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_sign:{args:[o.ptr,o.u64,o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_key_is_non_extractable:{args:[o.ptr],returns:o.i32},ara_device_key_delete:{args:[o.ptr],returns:o.i32},ara_device_binding_read:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_binding_create:{args:[o.ptr,o.u64],returns:o.i32},ara_device_binding_update:{args:[o.ptr,o.u64],returns:o.i32},ara_device_binding_delete:{args:[o.ptr],returns:o.i32},ara_device_keychain_read:{args:[o.ptr,o.u64,o.ptr],returns:o.i32},ara_device_keychain_delete:{args:[o.ptr],returns:o.i32}})}catch(l){if(l instanceof a)throw l;throw new a("native_boundary_unavailable")}}function U(e){return Buffer.from(e).toString("base64url")}function Ht(e){if(typeof e!=="string"||!/^[A-Za-z0-9_-]{87}$/.test(e))return!1;try{let r=Buffer.from(e,"base64url");return r.byteLength===65&&r[0]===4}catch{return!1}}function Si(e){if(e.byteLength<8||e.byteLength>72||e[0]!==48)return!1;let r=e[1];return r!==void 0&&r<128&&r+2===e.byteLength}class mt{libraryPath;runtimePlatform;workspaceScope;library=null;constructor(e=fn(),r=M(),o){this.libraryPath=e;this.runtimePlatform=r;this.workspaceScope=o;K(o)}symbols(){if(this.runtimePlatform!=="darwin")throw new a("unsupported_platform");this.library??=Se(this.libraryPath);let e=new TextEncoder().encode(this.workspaceScope??""),r=this.library.symbols.ara_device_configure_scope(p(e.length?e:new Uint8Array(1)),BigInt(e.length));if(r!==0)throw new a("native_boundary_unavailable",r);return this.library.symbols}publicKey(e){let r=new Uint8Array(_e),o=new BigUint64Array(1),l=e==="load"?this.symbols().ara_device_key_load_public(p(r),BigInt(r.byteLength),p(o)):this.symbols().ara_device_key_create_fresh_public(p(r),BigInt(r.byteLength),p(o));if(l!==0)throw new a(e==="load"?"proof_key_read_failed":"proof_key_generation_failed",l);let d=Number(o[0]);if(!Number.isSafeInteger(d)||d!==65)throw new a("invalid_public_key");let u=U(r.subarray(0,d));if(!Ht(u))throw new a("invalid_public_key");return u}loadPublicKey(){return this.publicKey("load")}createFreshPublicKey(){return this.publicKey("create_fresh")}sign(e){if(e.byteLength<1||e.byteLength>j)throw new a("proof_sign_failed");let r=new Uint8Array(be),o=new BigUint64Array(1),l=this.symbols().ara_device_key_sign(p(e),BigInt(e.byteLength),p(r),BigInt(r.byteLength),p(o));if(l!==0)throw new a("proof_sign_failed",l);let d=Number(o[0]);if(!Number.isSafeInteger(d)||d<1||d>r.byteLength)throw new a("invalid_signature");let u=r.subarray(0,d);if(!Si(u))throw new a("invalid_signature");return U(u)}privateKeyIsNonExtractable(){let e=new Uint8Array(1),r=this.symbols().ara_device_key_is_non_extractable(p(e));if(r!==0||e[0]!==1)throw new a("proof_key_read_failed",r);return!0}deleteKey(){let e=new Uint8Array(1),r=this.symbols().ara_device_key_delete(p(e));if(r!==0)throw new a("proof_key_delete_failed",r);return e[0]===1}loadBinding(){let e=new Uint8Array(_),r=new BigUint64Array(1),o=this.symbols().ara_device_binding_read(p(e),BigInt(e.byteLength),p(r));if(o===1)return null;if(o!==0)throw new a("binding_read_failed",o);let l=Number(r[0]);if(!Number.isSafeInteger(l)||l<1||l>e.byteLength)throw new a("invalid_binding");return e.slice(0,l)}createBinding(e){if(e.byteLength<1||e.byteLength>_)throw new a("invalid_binding");let r=this.symbols().ara_device_binding_create(p(e),BigInt(e.byteLength));if(r!==0)throw new a("binding_create_failed",r)}updateBinding(e){if(e.byteLength<1||e.byteLength>_)throw new a("invalid_binding");let r=this.symbols().ara_device_binding_update(p(e),BigInt(e.byteLength));if(r!==0)throw new a("binding_update_failed",r)}deleteBinding(){let e=new Uint8Array(1),r=this.symbols().ara_device_binding_delete(p(e));if(r!==0)throw new a("binding_delete_failed",r);return e[0]===1}loadLegacyCredential(){let e=new Uint8Array(ve),r=new BigUint64Array(1),o=this.symbols().ara_device_keychain_read(p(e),BigInt(e.byteLength),p(r));if(o===1)return null;if(o!==0)throw new a("legacy_credential_read_failed",o);let l=Number(r[0]);if(!Number.isSafeInteger(l)||l<1||l>e.byteLength)throw new a("invalid_credential_record");try{let d=new TextDecoder("utf-8",{fatal:!0}).decode(e.subarray(0,l));return he(JSON.parse(d))}catch(d){if(d instanceof a)throw d;throw new a("invalid_credential_record")}}deleteLegacyCredential(){let e=new Uint8Array(1),r=this.symbols().ara_device_keychain_delete(p(e));if(r!==0)throw new a("legacy_credential_delete_failed",r);return e[0]===1}}function F(e){let r=e.export({format:"jwk"});if(r.crv!=="P-256"||typeof r.x!=="string"||typeof r.y!=="string")throw new a("invalid_public_key");let o=Buffer.from(r.x,"base64url"),l=Buffer.from(r.y,"base64url");if(o.byteLength!==32||l.byteLength!==32)throw new a("invalid_public_key");let d=Buffer.concat([Buffer.of(4),o,l]).toString("base64url");if(!Ht(d))throw new a("invalid_public_key");return d}function Ie(){let e=process.env.XDG_CONFIG_HOME?.trim()||v(fe(),".config");De(e);let r=v(e,"ara");return Bi(r)?r:v(e,"reason")}class mn{directory;constructor(e=Ie()){this.directory=e}keyPath(){return v(this.directory,"local-device.key")}bindingPath(){return v(this.directory,"local-device.binding")}loadPrivateKeyObject(){let e=this.keyPath();if(!y(e))throw new a("proof_key_read_failed");try{let r=C(e,"utf8");return se({key:r,format:"pem"})}catch{throw new a("proof_key_read_failed")}}loadPublicKey(){let e=this.loadPrivateKeyObject(),r=le(e);return F(r)}createFreshPublicKey(){I(this.directory,{recursive:!0,mode:448});let{privateKey:e,publicKey:r}=de("ec",{namedCurve:"P-256"}),o=e.export({type:"pkcs8",format:"pem"}),l=this.keyPath();return D(l,o,{mode:384}),S(l,384),F(r)}sign(e){if(e.byteLength<1||e.byteLength>j)throw new a("proof_sign_failed");let r=this.loadPrivateKeyObject(),o;try{o=pe("sha256",e,r)}catch{throw new a("proof_sign_failed")}if(!Si(o))throw new a("invalid_signature");return o.toString("base64url")}privateKeyIsNonExtractable(){return!1}deleteKey(){let e=this.keyPath();if(!y(e))return!1;return k(e),!0}loadBinding(){let e=this.bindingPath();if(!y(e))return null;try{return new Uint8Array(C(e))}catch{return null}}createBinding(e){if(e.byteLength<1||e.byteLength>_)throw new a("invalid_binding");I(this.directory,{recursive:!0,mode:448});let r=this.bindingPath();if(y(r))throw new a("binding_create_failed");D(r,e,{mode:384}),S(r,384)}updateBinding(e){if(e.byteLength<1||e.byteLength>_)throw new a("invalid_binding");I(this.directory,{recursive:!0,mode:448});let r=this.bindingPath();if(!y(r))throw new a("binding_update_failed");let o=`${r}.${ue()}`;try{D(o,e,{mode:384,flag:"wx"}),S(o,384),ae(o,r)}finally{if(y(o))k(o)}}deleteBinding(){let e=this.bindingPath();if(!y(e))return!1;return k(e),!0}loadLegacyCredential(){return null}deleteLegacyCredential(){return!1}}function A(){return M()==="darwin"?new mt:new mn}var b=t().min(1).max(160).regex(/^[A-Za-z0-9._:-]+$/),z=n({id:b,kind:i("permission_denied"),operation:c(["bash","read","write","edit"]),provenance:c(["sandbox_policy","os_permission_unknown"]),occurredAt:t().datetime(),expiresAt:t().datetime(),sessionId:b,deviceId:b,organizationId:b}).strict();var x=4;var m="macos-keychain-p256-v1",Y=1,Fe=`ARA-DEVICE-BINDING-V1
|
|
3
|
+
`;function Me(e){return e===void 0||typeof e==="number"&&Number.isInteger(e)&&e>=1&&e<=4}function fr(e,r=Date.now()){let o=z.safeParse(e);if(!o.success)return!1;let l=o.data,d=typeof l.occurredAt==="string"?Date.parse(l.occurredAt):NaN,u=typeof l.expiresAt==="string"?Date.parse(l.expiresAt):NaN;return l.kind==="permission_denied"&&["bash","read","write","edit"].includes(l.operation)&&["sandbox_policy","os_permission_unknown"].includes(l.provenance)&&Number.isFinite(d)&&d<=r&&u>r&&u>d&&u-d<=600000}function gn(e,r,o=Date.now()){if(!e||!r||e.state!=="connected"||e.deviceId!==r.deviceId)return null;let l=Date.parse(e.lastHeartbeatAt??""),d=e.permissionRecovery;if(!(o-l>=0&&o-l<30000)||!fr(d,o)||d.deviceId!==r.deviceId||d.organizationId!==r.orgId)return null;try{process.kill(e.pid,0)}catch{return null}return d}function X(e={},r=s()){let o=w({env:{...process.env,...e}}),l=e.XDG_CONFIG_HOME?.trim()||h(r,".config");return wt(l,...o==="staging"?["staging"]:[])}function gt(e={},r=s()){return h(X(e,r),"local-device.json")}function mr(e={},r=s()){return h(X(e,r),"local-daemon.json")}function N(e,r){Pe(R(e),{recursive:!0,mode:448}),P(R(e),448);let o=`${e}.${process.pid}.${G()}.tmp`;try{Ce(o,`${JSON.stringify(r,null,2)}
|
|
4
|
+
`,{mode:384,flag:"wx"}),P(o,384),Ne(o,e),P(e,384)}finally{if(H(o))Ke(o)}return e}function O(e){if(!H(e))return null;try{return JSON.parse(Re(e,"utf8"))}catch{return null}}function E(e,r,o){try{e.onCredentialLifecycle?.({event:r,...o?{reasonCode:o}:{}})}catch{}}function je(e){if(!Array.isArray(e))return null;let r=[];for(let o of e){if(!o||typeof o!=="object")return null;let l=o;if(typeof l.id!=="string"||typeof l.label!=="string"||typeof l.path!=="string"||typeof l.pathFingerprint!=="string"||!l.permissions||typeof l.permissions.read!=="boolean"||typeof l.permissions.write!=="boolean"||typeof l.permissions.execute!=="boolean"||typeof l.permissions.discover_environment!=="boolean"||typeof l.permissions.expose_mcp!=="boolean")return null;r.push({id:l.id,label:l.label,path:l.path,pathFingerprint:l.pathFingerprint,permissions:l.permissions})}return r}function W(e,r,o=[]){let l=Object.keys(e);return r.every((d)=>Object.hasOwn(e,d))&&l.every((d)=>r.includes(d)||o.includes(d))}function Ve(e){if(typeof e!=="string")return null;try{let r=new URL(e);if(r.protocol!=="https:"&&r.hostname!=="127.0.0.1"&&r.hostname!=="localhost")return null;return r.origin}catch{return null}}function Z(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let r=e,o=je(r.roots),l=Ve(r.apiOrigin);if(!l||typeof r.orgId!=="string"||typeof r.deviceId!=="string"||typeof r.displayName!=="string"||typeof r.registeredAt!=="string"||!Me(r.handsSlots)||r.worker!==void 0&&(!r.worker||!/^[a-f0-9]{64}$/.test(r.worker.configDigest)||!["persistent","ephemeral"].includes(r.worker.lifetime)||!Number.isFinite(Date.parse(r.worker.expiresAt)))||!o)return null;return{apiOrigin:l,orgId:r.orgId,deviceId:r.deviceId,displayName:r.displayName,registeredAt:r.registeredAt,...r.handsSlots!==void 0?{handsSlots:r.handsSlots}:{},...r.worker!==void 0?{worker:r.worker}:{},roots:o}}function Be(e){return{...e,credentialStorage:m}}function $e(e){return{version:x,apiOrigin:e.apiOrigin,orgId:e.orgId,deviceId:e.deviceId,devicePublicKey:e.devicePublicKey,displayName:e.displayName,registeredAt:e.registeredAt,...e.handsSlots!==void 0?{handsSlots:e.handsSlots}:{},...e.worker!==void 0?{worker:e.worker}:{},roots:e.roots.map((r)=>({id:r.id,label:r.label,path:r.path,pathFingerprint:r.pathFingerprint,permissions:{read:r.permissions.read,write:r.permissions.write,execute:r.permissions.execute,discover_environment:r.permissions.discover_environment,expose_mcp:r.permissions.expose_mcp}})),credentialStorage:m}}function q(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let r=e;if(!W(r,["version","apiOrigin","orgId","deviceId","devicePublicKey","displayName","registeredAt","roots","credentialStorage"],["handsSlots","worker"]))return null;let o=Z(r);if(!o||r.version!==x||r.credentialStorage!==m||!Ht(r.devicePublicKey))return null;return{version:x,...o,devicePublicKey:r.devicePublicKey,credentialStorage:m}}function Q(e){return new TextEncoder().encode(`${Fe}${JSON.stringify($e(e))}`)}function ze(e){let r=Buffer.from(e,"base64url");return Le({format:"jwk",key:{kty:"EC",crv:"P-256",x:r.subarray(1,33).toString("base64url"),y:r.subarray(33,65).toString("base64url")}})}function Ge(e,r){let o={version:Y,state:e,signature:r.sign(Q(e))};return new TextEncoder().encode(JSON.stringify(o))}function ee(e){let r;try{r=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e))}catch{throw new a("invalid_binding")}if(!r||typeof r!=="object"||Array.isArray(r))throw new a("invalid_binding");let o=r;if(!W(o,["version","state","signature"])||o.version!==Y||typeof o.signature!=="string"||!/^[A-Za-z0-9_-]{10,128}$/.test(o.signature))throw new a("invalid_binding");let l=q(o.state);if(!l)throw new a("invalid_binding");let d=!1;try{d=Ae("sha256",Q(l),ze(l.devicePublicKey),Buffer.from(o.signature,"base64url"))}catch{d=!1}if(!d)throw new a("invalid_binding");return l}function He(e){let{credentialStorage:r,...o}=e;return o}function Je(e){return e instanceof a?V(e):"credential_boundary_failed"}function Ut(e=gt(),r={}){let o=O(e),l=r.proofStore??r.credentialStore??A(),d=l.loadBinding();if(!d){if(o&&typeof o==="object"&&!Array.isArray(o)&&Ye(o))return null;if(o!==null)throw new a("invalid_binding");return null}let u=ee(d),g=l.loadPublicKey();if(l.privateKeyIsNonExtractable(),g!==u.devicePublicKey)throw new a("invalid_public_key");let f=q(o);if(r.repair!==!1&&(!f||JSON.stringify(f)!==JSON.stringify(u)))N(e,u);return He(u)}function Ye(e){let r=e,o=Z(e);if(!o)return null;if(r.version===2){if(typeof r.deviceCredential!=="string"||!/^(?:reason|ara)_dev_/.test(r.deviceCredential)||r.deviceCredential.length>4096)return null;return{state:o,credentialSource:"plaintext-v2"}}if(r.version!==3||r.credentialStorage!=="macos-keychain-v1"||"deviceCredential"in r)return null;return{state:o,credentialSource:"keychain-v3"}}function ce(e,r=gt(),o={}){let l=o.proofStore??o.credentialStore??A();E(o,"credential.store_started");try{if(!Ht(e.devicePublicKey)||l.loadPublicKey()!==e.devicePublicKey)throw new a("invalid_public_key");l.privateKeyIsNonExtractable();let d=Be(e),u=l.loadBinding();if(u){let f=ee(u);if(f.devicePublicKey!==e.devicePublicKey||f.orgId!==e.orgId||f.deviceId!==e.deviceId||f.apiOrigin!==e.apiOrigin&&!An(f.apiOrigin,e.apiOrigin))throw new a("invalid_binding")}let g=Ge(d,l);if(u)l.updateBinding(g);else l.createBinding(g);return N(r,d),E(o,"credential.store_completed"),r}catch(d){throw E(o,"credential.store_failed",Je(d)),d}}function rt(e=mr()){let r=O(e);if(!r||typeof r!=="object")return null;let o=r;if(o.version!==1||typeof o.pid!=="number"||!Number.isInteger(o.pid)||!["starting","connected","stopped","error"].includes(o.state??"")||typeof o.startedAt!=="string"||o.lastHeartbeatAt!==void 0&&typeof o.lastHeartbeatAt!=="string"||o.lastUsedAt!==void 0&&typeof o.lastUsedAt!=="string"||o.organizationId!==void 0&&typeof o.organizationId!=="string"||o.organizationName!==void 0&&typeof o.organizationName!=="string"||o.organizationSlug!==void 0&&typeof o.organizationSlug!=="string"||o.error!==void 0&&typeof o.error!=="string"||o.reconnectingSince!==void 0&&typeof o.reconnectingSince!=="string"||o.workspace!==void 0&&typeof o.workspace!=="string")return null;if(o.permissionRecovery!==void 0&&!fr(o.permissionRecovery))delete o.permissionRecovery;return o}function Ei(e,r=mr()){return N(r,e)}var gr=1;function Xe(e=gt()){return h(R(e),"local-device.proxy.json")}function Ee(e=Xe()){let r=O(e);if(!r||typeof r!=="object"||Array.isArray(r))return null;let o=r;if(o.version!==gr||typeof o.url!=="string"||o.url.length===0||o.caFile!==void 0&&(typeof o.caFile!=="string"||!J(o.caFile)))return null;return{version:gr,url:o.url,...o.caFile?{caFile:o.caFile}:{}}}function zt(e,r={read:!0,write:!1,execute:!1,discover_environment:!1,expose_mcp:!1},o=we(32)){let l=new Set,d=[];for(let u of e){let g=xe(J(u)?u:Ue(u));if(!Oe(g).isDirectory())throw Error(`Local execution root is not a directory: ${u}`);if(l.has(g))continue;l.add(g),d.push({id:G(),label:Te(g)||g,path:g,pathFingerprint:ke("sha256",o).update(g).digest("hex"),permissions:{...r}})}if(d.length===0)throw Error("At least one explicit local execution root is required.");return d}
|
|
5
|
+
export{a,fn,Ht,Si,mt,mn,fr,gn,gt,mr,Ut,ce,rt,Ei,gr,Ee,zt};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{mkdirSync as R,readdirSync as A,readFileSync as k,realpathSync as x}from"fs";import{userInfo as E}from"os";var qn="--vm-hands-op-runner-kind=person",Wn="--vm-hands-op-runner-kind=surface",Wr="--vm-hands-surface-uid=",Vr="--vm-hands-surface-dir=",C="/sys/fs/cgroup/reason-person/desktop",Gr=new Set(["automation.call.v1","display.stream.v1","preview.serve.v1"]);function D(t){let a=new Set([t]),l=[];try{l=A("/proc")}catch{}for(let n of l){if(!/^\d+$/.test(n))continue;try{let o=k(`/proc/${n}/stat`,"utf8");if(Number(o.slice(o.lastIndexOf(")")+2).split(" ")[3])===t)a.add(Number(n))}catch{}}for(let n of a)try{process.kill(n,"SIGKILL")}catch{}}var H=(t)=>{let a=globalThis.Bun;if(!a)throw new r("pty_unavailable","Reason terminals require the Bun runtime.");let l=a.spawn({cmd:[t.shell,...t.args],cwd:t.cwd,env:{...t.environment,TERM:"xterm-256color"},terminal:{cols:t.cols,rows:t.rows,data:(c,d)=>t.onData(d)}}),n=l.terminal,o=()=>{D(l.pid);try{n?.close()}catch{}};if(!n)throw o(),new r("pty_unavailable","Reason could not allocate a pseudo-terminal.");return{write:(c)=>n.write(c),resize:(c,d)=>n.resize(c,d),kill:o,exited:l.exited.then((c)=>typeof c==="number"?c:null,()=>null)}};function O(){let t=(()=>{try{return E().username}catch{return}})();return{PATH:process.env.PATH,HOME:process.env.HOME,SHELL:process.env.SHELL,LANG:"C.UTF-8",...t?{USER:t,LOGNAME:t}:{}}}async function L(t){let[{localAutomationAvailable:a},{localDisplayReady:l},{localDisplayVideoAvailable:n},{probeWorkerPreview:o},m]=await Promise.all([import("./local-automation-
|
|
3
|
-
`).find((o)=>o.startsWith("0::"))?.slice(3)??""}catch{return null}if(!/^\/reason-person\/vm-hands\/[A-Za-z0-9._-]+$/.test(a))return null;if(!t)return null;let l=[t.xvnc,t.xvfb,t.openbox,t.x11vnc,t.pulseaudio,t.browser,"/usr/bin/dbus-daemon","/bin/dbus-daemon"].flatMap((o)=>{try{return o?[x(o)]:[]}catch{return[]}}),n={join:`/sys/fs/cgroup${a}/desktop`,keep:C,programs:[...new Set(l)]};for(let o of[n.join,n.keep])try{R(o,{mode:493})}catch(m){if(m.code!=="EEXIST")return null}return n}async function hl(){let[{executeLocalOperation:t,spawnCaptured:a},{runLocalPtySession:l},{configureDesktopAccount:n,desktopAccount:o},{configureWorkerSandbox:m},{configureDesktopPlacement:c},{readDesktopComponents:d}]=await Promise.all([import("./local-capabilities-
|
|
2
|
+
import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{mkdirSync as R,readdirSync as A,readFileSync as k,realpathSync as x}from"fs";import{userInfo as E}from"os";var qn="--vm-hands-op-runner-kind=person",Wn="--vm-hands-op-runner-kind=surface",Wr="--vm-hands-surface-uid=",Vr="--vm-hands-surface-dir=",C="/sys/fs/cgroup/reason-person/desktop",Gr=new Set(["automation.call.v1","display.stream.v1","preview.serve.v1"]);function D(t){let a=new Set([t]),l=[];try{l=A("/proc")}catch{}for(let n of l){if(!/^\d+$/.test(n))continue;try{let o=k(`/proc/${n}/stat`,"utf8");if(Number(o.slice(o.lastIndexOf(")")+2).split(" ")[3])===t)a.add(Number(n))}catch{}}for(let n of a)try{process.kill(n,"SIGKILL")}catch{}}var H=(t)=>{let a=globalThis.Bun;if(!a)throw new r("pty_unavailable","Reason terminals require the Bun runtime.");let l=a.spawn({cmd:[t.shell,...t.args],cwd:t.cwd,env:{...t.environment,TERM:"xterm-256color"},terminal:{cols:t.cols,rows:t.rows,data:(c,d)=>t.onData(d)}}),n=l.terminal,o=()=>{D(l.pid);try{n?.close()}catch{}};if(!n)throw o(),new r("pty_unavailable","Reason could not allocate a pseudo-terminal.");return{write:(c)=>n.write(c),resize:(c,d)=>n.resize(c,d),kill:o,exited:l.exited.then((c)=>typeof c==="number"?c:null,()=>null)}};function O(){let t=(()=>{try{return E().username}catch{return}})();return{PATH:process.env.PATH,HOME:process.env.HOME,SHELL:process.env.SHELL,LANG:"C.UTF-8",...t?{USER:t,LOGNAME:t}:{}}}async function L(t){let[{localAutomationAvailable:a},{localDisplayReady:l},{localDisplayVideoAvailable:n},{probeWorkerPreview:o},m]=await Promise.all([import("./local-automation-bt51qn3g.js"),import("./local-display-session-j807vr40.js"),import("./local-display-video-3b5qegyk.js"),import("./worker-preview-readiness-w4zy5g2p.js"),import("fs")]),c=AbortSignal.timeout(15000),d=null;try{m.mkdirSync(t,{recursive:!0,mode:448}),d=m.mkdtempSync(`${t}/probe-`);let[w,u,v]=await Promise.all([Promise.resolve().then(()=>a()).catch(()=>!1),l().catch(()=>!1),o(d,c).catch(()=>!1)]);return{t:"readiness",display_video:u&&await n().catch(()=>!1),lanes:{"automation.call.v1":w,"display.stream.v1":u,"preview.serve.v1":v,"tunnel.open":v,"tunnel.close":v}}}finally{if(d)m.rmSync(d,{recursive:!0,force:!0})}}function N(t){let a="";try{a=k("/proc/self/cgroup","utf8").split(`
|
|
3
|
+
`).find((o)=>o.startsWith("0::"))?.slice(3)??""}catch{return null}if(!/^\/reason-person\/vm-hands\/[A-Za-z0-9._-]+$/.test(a))return null;if(!t)return null;let l=[t.xvnc,t.xvfb,t.openbox,t.x11vnc,t.pulseaudio,t.browser,"/usr/bin/dbus-daemon","/bin/dbus-daemon"].flatMap((o)=>{try{return o?[x(o)]:[]}catch{return[]}}),n={join:`/sys/fs/cgroup${a}/desktop`,keep:C,programs:[...new Set(l)]};for(let o of[n.join,n.keep])try{R(o,{mode:493})}catch(m){if(m.code!=="EEXIST")return null}return n}async function hl(){let[{executeLocalOperation:t,spawnCaptured:a},{runLocalPtySession:l},{configureDesktopAccount:n,desktopAccount:o},{configureWorkerSandbox:m},{configureDesktopPlacement:c},{readDesktopComponents:d}]=await Promise.all([import("./local-capabilities-q9jvmztz.js"),import("./local-pty-session-bk7pp5nb.js"),import("./desktop-account-15zym6ze.js"),import("./worker-sandbox-6aepsk73.js"),import("./desktop-delegate-4hb0163k.js"),import("./desktop-components-py12mt6g.js")]);m();let w=process.argv.includes(qn),u=process.argv.includes(Wn),v=(i,e,p)=>a(i,e[0]==="-lic"?["-lc",...e.slice(1)]:e,p),y=(process.geteuid?.()??0)!==0;if(u){y=!1;let i=process.argv.find((e)=>e.startsWith(Wr))?.slice(Wr.length);if((process.geteuid?.()??-1)===0&&i)try{y=n({value:i})!==null&&o()!==null}catch{y=!1}}let S=new Map,_=new Map,f=(i)=>{try{process.send?.(i)}catch{}};if(u&&y){let i=o()?.home,e=i?N(d({home:i})):null;c(e&&{...e,log:(p,g)=>f({t:"log",event:p,fields:g})})}if(process.on("message",(i)=>{let e=i;if(e?.t==="cancel"){S.get(e.id)?.abort();return}if(e?.t==="control"){let s=_.get(e.id);if(u&&s&&e.control&&typeof e.control.kind==="string")import("./local-managed-process-48t1899b.js").then(({controlManagedDeviceProcess:h})=>h(s,{kind:e.control.kind,payload:e.control.payload??{}})).catch(()=>!1);return}if(e?.t==="retire"){if(u&&typeof e.operation_id==="string"&&typeof e.status==="string")import("./local-managed-process-48t1899b.js").then(({retireManagedDeviceProcess:s})=>s(e.operation_id,e.status)).catch(()=>!1);return}if(e?.t!=="op")return;if(!y){f({t:"done",id:e.id,completion:{status:"failed",error_code:"vm_hands_payload_account_unavailable"}});return}let p=e.claim.capability;if(p==="pty.start"&&!w){f({t:"done",id:e.id,completion:{status:"failed",error_code:"capability_not_granted"}});return}if(Gr.has(p)!==u){f({t:"done",id:e.id,completion:{status:"failed",error_code:"capability_not_granted"}});return}let g=new AbortController;S.set(e.id,g),_.set(e.id,e.claim);let b=p==="pty.start"?{runPtySession:(s)=>l(s,{spawnPty:H,environment:O(),loadProxy:()=>null})}:{worker:e.worker,...p==="exec.full"?{spawnFullControl:v}:{}};t(e.state,e.claim,{...b,signal:g.signal,emit:(s)=>{let{deliverySignal:h,...P}=s;f({t:"event",id:e.id,event:P})}}).then((s)=>f({t:"done",id:e.id,completion:s}),(s)=>f({t:"done",id:e.id,completion:{status:"failed",error_code:s&&typeof s==="object"&&"code"in s&&typeof s.code==="string"?s.code:"vm_hands_op_failed"}})).finally(()=>{S.delete(e.id),_.delete(e.id)})}),process.on("disconnect",()=>process.exit(0)),u){let i=process.argv.find((p)=>p.startsWith(Vr))?.slice(Vr.length),e={t:"readiness",display_video:!1,lanes:{}};f(y&&i?await L(i).catch(()=>e):e)}await new Promise(()=>{})}
|
|
4
4
|
export{qn,Wn,Wr,Vr,Gr,hl};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{R}from"./vm-hands-entry-lite-ys4jhf7n.js";import{ji,Hi,St,Yt,gs,_s}from"./vm-hands-entry-lite-
|
|
2
|
+
import{R}from"./vm-hands-entry-lite-ys4jhf7n.js";import{ji,Hi,St,Yt,gs,_s}from"./vm-hands-entry-lite-ysmjfpef.js";import{uc,dc}from"./vm-hands-entry-lite-chve4vmh.js";import{Ii,Di,vn,yr,l,mc,Oi,gc,Sn,Gt,En}from"./vm-hands-entry-lite-sb1xtqxr.js";import{s}from"./vm-hands-entry-lite-tzv8s0e7.js";import{G}from"./vm-hands-entry-lite-04nx5y4f.js";import{randomUUID as L}from"crypto";import{chmodSync as Z,closeSync as J,constants as C,existsSync as S,fstatSync as ke,lstatSync as h,mkdirSync as q,openSync as Ie,readFileSync as K,readdirSync as re,readlinkSync as w,realpathSync as x,renameSync as k,rmSync as T,statSync as V,symlinkSync as Q,unlinkSync as p,writeFileSync as U}from"fs";import{basename as H,dirname as E,isAbsolute as je,join as m,relative as We,resolve as M,sep as me}from"path";import{spawnSync as ee}from"child_process";import{createRequire as Te}from"module";var ie=1,xe=1,Xe=128,Qe=65536,Qc="https://reasonmachines.com/api/runtime-manifest-v2",et=30000,tt=600000,Ee=1e4,nt=60000,rt=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;var Me=/^[a-z0-9_.-]{1,80}$/,it=64,at="so.ara.device-broker",Pe=[at,"com.reasonmachines.device-broker"],Ln=Hi(Pe),we=["com.apple.security.cs.allow-jit","com.apple.security.cs.allow-unsigned-executable-memory"],ot=["service.install_started","service.install_completed","service.install_failed","service.launcher_adopted","service.launcher_conflict","service.started","service.reconnecting","service.reconnected","service.idle_sleep_held","service.idle_sleep_released","service.idle_sleep_failed","service.start_failed","service.stopped","service.exit_failed","service.singleton_rejected","credential.migration_started","credential.migration_completed","credential.migration_failed","credential.store_started","credential.store_completed","credential.store_failed","credential.delete_started","credential.delete_completed","credential.delete_failed","update.check_started","update.not_available","update.download_started","update.downloaded","update.verified","update.activated","update.rollback","update.failed","executor.update.check_started","executor.update.not_available","executor.update.download_started","executor.update.downloaded","executor.update.verified","executor.update.activated","executor.update.rollback","executor.update.failed","identity.refresh_completed","identity.refresh_failed","update.device_moved","update.components_installed","update.deferred","update.deferral_expired","worker.previous_exit","worker.capabilities_withheld","identity.computer_use_unavailable"];function W(e){if(e?.aborted)throw new l("update_cancelled","Managed runtime update request was cancelled.")}function fe(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function ge(e,t,n=[]){let r=new Set([...t,...n]);return t.every((i)=>(i in e))&&Object.keys(e).every((i)=>r.has(i))}function b(e){return typeof e==="string"&&rt.test(e)}function De(e){return typeof e==="string"&&!Number.isNaN(Date.parse(e))&&new Date(e).toISOString()===e}function st(e){return yr.includes(e)}function P(e){q(e,{recursive:!0,mode:448}),Z(e,448)}function Oe(e,t){P(E(e));let n=`${e}.${process.pid}.${L()}.tmp`;try{U(n,t,{mode:384,flag:"wx"}),Z(n,384),k(n,e)}finally{if(S(n))p(n)}}function Lt(e={}){if((e.platform??process.platform)!=="darwin")throw new l("unsupported_platform","The managed Reason runtime is currently available only on macOS.");let n=e.environment??process.env,r=R(n,"REASON_CLI_CHANNEL")==="staging",i=r?R(n,"REASON_MANAGED_RUNTIME_ROOT")?.trim():void 0,o=e.root!==void 0||Boolean(i&&je(i))?null:m(e.home??s(),"Library","Application Support"),c=e.root??(o?m(o,r?"Reason Staging":"Reason","CLI"):i);return{executableName:"reason",root:c,...o?{legacyRoot:m(o,"Ara",...r?["staging","runtime"]:["runtime"])}:{},versions:m(c,"versions"),current:m(c,"current"),previous:m(c,"previous"),brokerLock:m(c,"broker.lock"),transitionLock:m(c,"transition.lock"),lifecycleEvents:m(c,"lifecycle-events")}}function bl(e){let t=e.legacyRoot;if(!t)return null;return{root:t,versions:m(t,"versions"),current:m(t,"current"),previous:m(t,"previous"),brokerLock:m(t,"broker.lock"),transitionLock:m(t,"transition.lock"),lifecycleEvents:m(t,"lifecycle-events")}}function F(e,t){if(!b(t))throw new l("invalid_version","Invalid managed Reason runtime version.");let n=m(e.versions,t,"ara");if(!e.executableName)return n;let r=m(e.versions,t,e.executableName),i=(c)=>{try{return h(c),!0}catch(d){if(d.code==="ENOENT")return!1;throw d}},a=i(n),o=i(r);if(a&&o)throw new l("installed_artifact_mismatch","Ambiguous managed runtime executable layout.");return a?n:r}function ae(e,t){if(!b(t))throw new l("invalid_version","Invalid managed Reason runtime version.");return _e(F(e,t))}function _e(e){return m(E(e),H(e)==="reason"?Di:Ii)}function Ce(e,t){if(!b(e)||!b(t))throw new l("invalid_version","Invalid managed Reason runtime version.");let[n,r]=e.split("-",2),[i,a]=t.split("-",2),o=n.split(".").map(Number),c=i.split(".").map(Number);for(let _=0;_<3;_+=1){let g=o[_]-c[_];if(g!==0)return g<0?-1:1}if(r===void 0||a===void 0){if(r===a)return 0;return r===void 0?1:-1}let d=r.split("."),u=a.split("."),f=Math.max(d.length,u.length);for(let _=0;_<f;_+=1){let g=d[_],y=u[_];if(g===void 0||y===void 0){if(g===y)return 0;return g===void 0?-1:1}if(g===y)continue;let v=/^\d+$/.test(g),A=/^\d+$/.test(y);if(v&&A)return Number(g)<Number(y)?-1:1;if(v!==A)return v?-1:1;return g<y?-1:1}return 0}function ct(e=process.arch){let t=`darwin-${e}`;if(!st(t))throw new l("unsupported_architecture","The managed Reason runtime supports only Apple Silicon and Intel Macs.");return t}function Re(e){return[...e.matchAll(/<key>\s*([^<]+?)\s*<\/key>/g)].map((t)=>t[1].trim())}function pe(e){let t=e.match(/^CodeDirectory .*$/gm)??[];return t.length>0&&t.every((n)=>(/ flags=0x[0-9a-f]+\(([^)]*)\)(?: |$)/.exec(n)?.[1]?.split(/[ ,]+/).filter(Boolean)??[]).includes("runtime"))}function lt(e){let t=`TeamIdentifier=${ji}`,n=Pe.map((a)=>`Identifier=${a}`),r=Re(e.brokerEntitlements),i=Re(e.credentialLibraryEntitlements);if(!e.brokerDetail.split(`
|
|
3
3
|
`).includes(t)||!e.brokerDetail.split(`
|
|
4
4
|
`).some((a)=>n.includes(a))||!pe(e.brokerDetail)||r.length!==we.length||we.some((a)=>!new RegExp(`<key>\\s*${a.replaceAll(".","\\.")}\\s*</key>\\s*<true\\s*/>`).test(e.brokerEntitlements)))throw new l("invalid_code_signature","Managed runtime broker has an invalid Reason signature, identifier, or entitlement set.");if(!e.credentialLibraryDetail.split(`
|
|
5
5
|
`).includes(t)||!pe(e.credentialLibraryDetail)||i.length!==0)throw new l("invalid_code_signature","Managed runtime credential library has an invalid signature or entitlement.")}function D(e,t){let n=ee("/usr/bin/codesign",e,{stdio:["ignore","pipe","pipe"]});if(n.status!==0)throw new l("invalid_code_signature",t);return[new TextDecoder().decode(n.stdout??new Uint8Array),new TextDecoder().decode(n.stderr??new Uint8Array)].join("")}var ye=(e,t)=>{D(["--verify","--strict","--verbose=2",e],"Managed runtime broker code signature is invalid."),D(["--verify","--strict","--verbose=2",t],"Managed runtime credential library code signature is invalid."),lt({brokerDetail:D(["-d","--verbose=4",e],"Managed runtime broker signer could not be inspected."),brokerEntitlements:D(["-d","--entitlements",":-",e],"Managed runtime broker entitlements could not be inspected."),credentialLibraryDetail:D(["-d","--verbose=4",t],"Managed runtime credential library signer could not be inspected."),credentialLibraryEntitlements:D(["-d","--entitlements",":-",t],"Managed runtime credential library entitlements could not be inspected.")})};async function dt(e,t,n){let r=e.headers.get("content-length");if(r!==null){let f=Number(r);if(!Number.isSafeInteger(f)||f<0||f>t)throw new l("response_too_large","Managed runtime response exceeded its size limit.")}if(!e.body){let f=new Uint8Array(await e.arrayBuffer());if(f.byteLength>t)throw new l("response_too_large","Managed runtime response exceeded its size limit.");return f}let i=e.body.getReader(),a=[],o=0,c=()=>{if(!n)return i.read();return new Promise((f,_)=>{let g=()=>{n.removeEventListener("abort",g),i.cancel(n.reason).catch(()=>{}),_(n.reason??new DOMException("Aborted","AbortError"))};if(n.aborted){g();return}n.addEventListener("abort",g,{once:!0}),i.read().then((y)=>{n.removeEventListener("abort",g),f(y)},(y)=>{n.removeEventListener("abort",g),_(y)})})};try{while(!0){let f=await c();if(f.done)break;if(o+=f.value.byteLength,o>t)throw await i.cancel(),new l("response_too_large","Managed runtime response exceeded its size limit.");a.push(f.value)}}finally{try{i.releaseLock()}catch{}}let d=new Uint8Array(o),u=0;for(let f of a)d.set(f,u),u+=f.byteLength;return d}async function Yr(e){let t;try{t=new URL(e.url)}catch{throw new l("invalid_update_url","Managed runtime update URL is invalid.")}if(t.protocol!=="https:"||t.username||t.password||t.hash)throw new l("invalid_update_url","Managed runtime update URL must use HTTPS.");let n=new AbortController,r,i=()=>{r??="caller",n.abort(e.signal?.reason)};if(e.signal?.aborted)i();else e.signal?.addEventListener("abort",i,{once:!0});let a=setTimeout(()=>{r??="timeout",n.abort(Error("managed runtime fetch timed out"))},e.timeoutMs),o=(c,d)=>{if(c instanceof l)return c;if(r==="caller")return new l("update_cancelled","Managed runtime update request was cancelled.");if(r==="timeout")return new l("update_fetch_timeout","Managed runtime update request timed out.");return new l("update_fetch_failed",d)};try{let c;try{if(c=await e.fetchImpl(t,{headers:{accept:e.accept},signal:n.signal}),n.signal.aborted)throw o(n.signal.reason,"Managed runtime update request was cancelled.")}catch(d){throw o(d,"Managed runtime update request failed.")}if(!c.ok)throw new l("update_http_error","Managed runtime update request was rejected.");if(c.url&&new URL(c.url).protocol!=="https:")throw new l("insecure_redirect","Managed runtime update redirected to an insecure URL.");try{let d=await dt(c,e.maximumBytes,n.signal);if(n.signal.aborted)throw o(n.signal.reason,"Managed runtime update response was cancelled.");return d}catch(d){throw o(d,"Managed runtime update response failed.")}}finally{clearTimeout(a),e.signal?.removeEventListener("abort",i)}}async function Ve(e,t,n=Ee,r){let i=typeof n==="number"?n:Ee,a=typeof n==="number"?r:n;if(a?.aborted)return!1;let o=await uc([e,"--version"],{timeoutMs:i,...a?{signal:a}:{}});return o.exitCode===0&&o.stdout.trim().replace(/^v/,"")===t}async function ut(e){let t=!1,n=null,r=null,i=(a)=>{try{N(e.paths,a,{now:e.now})}catch{}};try{let a=e.home??s();if(!gs(e.manifest.version,a))return{status:"current"};r=Yt(a);let o=await Yr({url:new URL(mc,e.manifest.artifacts[e.target].broker.url).toString(),maximumBytes:vn,fetchImpl:async(g,y)=>{let v=await e.fetchImpl(g,y);return t=v.status===404,v},timeoutMs:e.timeoutMs,accept:"application/json",signal:e.signal}),{manifest:c}=gc(new TextDecoder().decode(o),e.trustedKeys);if(c.version!==e.manifest.version||c.published_at!==e.manifest.published_at)throw new l("identity_manifest_mismatch","Background identity manifest names another release.");let d=c.artifacts[e.target],u=await Yr({url:d.url,maximumBytes:d.size_bytes,fetchImpl:e.fetchImpl,timeoutMs:e.timeoutMs,accept:"application/octet-stream",signal:e.signal});Gt(u,d),P(e.workDirectory),n=m(e.workDirectory,`.identity-${process.pid}-${L()}`),q(n,{mode:448});let f=m(n,"identity.tgz");if(U(f,u,{mode:384,flag:"wx"}),ee("/usr/bin/tar",["-xzf",f,"-C",n],{stdio:"ignore",timeout:60000}).status!==0)throw new l("identity_extract_failed","Background identity archive could not be extracted.");return _s({sourceApp:m(n,"Reason.app"),home:a,releaseSigned:!0,...e.command?{command:e.command}:{}}),i({event:"identity.refresh_completed",runtime_version:e.manifest.version,...r?{from_version:r}:{},to_version:e.manifest.version}),{status:"installed"}}catch(a){if(t)return{status:"unpublished"};let o=a instanceof l||a instanceof St?a.code:"identity_install_failed";return process.stderr.write(`Reason background identity: identity_update_failed (${o})
|
|
6
|
-
`),i({event:"identity.refresh_failed",runtime_version:e.manifest.version,...r?{from_version:r}:{},to_version:e.manifest.version,reason_code:o}),{status:"failed",code:o}}finally{if(n)T(n,{recursive:!0,force:!0})}}async function vl(e){if(!b(e.currentVersion))throw new l("invalid_version","Invalid current managed runtime version.");let t=e.paths??Lt(),n=e.target??ct(),r=e.fetchImpl??fetch,i=e.timeoutMs??et,a=e.timeoutMs??tt,o=e.healthCheck??((_,g,y)=>Ve(_,g,nt,y)),c=e.verifyCodeSignatures??ye,d=e.now?.()??new Date,u,f=!1;N(t,{event:"update.check_started",runtime_version:e.currentVersion,from_version:e.currentVersion},{now:()=>d});try{await Rt({paths:t,verifyCodeSignatures:c,healthCheck:o});let _=await Yr({url:e.manifestUrl??Qc,maximumBytes:vn,fetchImpl:r,timeoutMs:i,accept:"application/json",signal:e.signal}),g=Oi(new TextDecoder().decode(_),e.trustedKeys);u=g.manifest.version;let y=()=>ut({paths:t,...e.now?{now:e.now}:{},manifest:g.manifest,target:n,trustedKeys:e.trustedKeys,fetchImpl:r,timeoutMs:a,workDirectory:t.versions,...e.home?{home:e.home}:{},...e.identityCommand?{command:e.identityCommand}:{},...e.signal?{signal:e.signal}:{}});if(Ce(u,e.currentVersion)<=0)return N(t,{event:"update.not_available",runtime_version:e.currentVersion,from_version:e.currentVersion,to_version:u,duration_ms:Math.max(0,(e.now?.()??new Date).getTime()-d.getTime())},{now:e.now}),Ae(t,e.home),{status:"not_available",currentVersion:e.currentVersion,offeredVersion:u,...u===e.currentVersion?{identity:await y()}:{}};let v=g.manifest.artifacts[n];N(t,{event:"update.download_started",runtime_version:e.currentVersion,from_version:e.currentVersion,to_version:u},{now:e.now});let A=await Yr({url:v.broker.url,maximumBytes:v.broker.size_bytes,fetchImpl:r,timeoutMs:a,accept:"application/octet-stream",signal:e.signal});Gt(A,v.broker),W(e.signal);let j=await Yr({url:v.credential_library.url,maximumBytes:v.credential_library.size_bytes,fetchImpl:r,timeoutMs:a,accept:"application/octet-stream",signal:e.signal});Gt(j,v.credential_library),N(t,{event:"update.downloaded",runtime_version:e.currentVersion,from_version:e.currentVersion,to_version:u},{now:e.now}),N(t,{event:"update.verified",runtime_version:e.currentVersion,from_version:e.currentVersion,to_version:u},{now:e.now}),W(e.signal);let he=mt({paths:t,version:u,artifact:v.broker,bytes:A,credentialLibraryArtifact:v.credential_library,credentialLibraryBytes:j,verifyCodeSignatures:c}),be;try{be=await o(he.executablePath,u,e.signal)}catch(B){throw W(e.signal),B}if(W(e.signal),!be)throw new l("pre_activation_health_failed","Managed runtime preflight failed.");let I=bt(t,u);if(!I.changed&&I.toVersion!==u)return N(t,{event:"update.not_available",runtime_version:I.toVersion,from_version:I.toVersion,to_version:u,duration_ms:Math.max(0,(e.now?.()??new Date).getTime()-d.getTime())},{now:e.now}),{status:"not_available",currentVersion:I.toVersion,offeredVersion:u};if(f=I.changed,!await o(t.current,u)){if(I.fromVersion){let B=Ge(t,u);N(t,{event:"update.rollback",runtime_version:B.toVersion,from_version:B.fromVersion,to_version:B.toVersion,reason_code:"post_activation_health_failed"},{now:e.now})}else ze(t,u);throw O(t),f=!1,new l("post_activation_health_failed","Managed runtime activation failed.")}return O(t),Ae(t,e.home),N(t,{event:"update.activated",runtime_version:u,from_version:e.currentVersion,to_version:u,duration_ms:Math.max(0,(e.now?.()??new Date).getTime()-d.getTime())},{now:e.now}),{status:"activated",fromVersion:e.currentVersion,toVersion:u,installed:he.installed,identity:await y()}}catch(_){throw N(t,{event:"update.failed",runtime_version:f?u??e.currentVersion:e.currentVersion,from_version:e.currentVersion,...u?{to_version:u}:{},reason_code:_ instanceof l?_.code:"update_failed",duration_ms:Math.max(0,(e.now?.()??new Date).getTime()-d.getTime())},{now:e.now}),_}}function Le(e,t,n){try{let r=h(E(e));if(!r.isDirectory()||r.isSymbolicLink())return!1;let i=h(e);if(!i.isFile()||i.isSymbolicLink()||i.size!==t.size_bytes)return!1;let a=_e(e),o=h(a);return o.isFile()&&!o.isSymbolicLink()&&o.size===n.size_bytes&&Sn(K(e))===t.sha256&&Sn(K(a))===n.sha256}catch{return!1}}function mt(e){let t=F(e.paths,e.version);Gt(e.bytes,e.artifact),Gt(e.credentialLibraryBytes,e.credentialLibraryArtifact);let n=e.verifyCodeSignatures??ye;if(P(e.paths.root),P(e.paths.versions),S(E(t))){if(!Le(t,e.artifact,e.credentialLibraryArtifact))throw new l("installed_artifact_mismatch","The installed runtime version does not match the verified artifact.");return n(t,
|
|
7
|
-
${t.stdout}`}function Ae(e,t){let n=[];Et(e,t??s());try{let r=Ze(e);if(!r||de(e))return n;let i=re(e.versions).filter((o)=>b(o));if(i.length<=2)return n;let a=Ye();if(a===null)return n;ce(e,r,()=>{let o=new Set([Ze(e),se(e.previous,e.executableName)]);if(de(e))return;for(let c of i){if(o.has(c))continue;let d=m(e.versions,c);if(a.includes(`${d}${me}`))continue;try{T(d,{recursive:!0,force:!0}),n.push(c)}catch{}}})}catch{}return n}function Et(e,t){try{let n=le(m(t,".local","bin"));if(!n)return;let r=["reason","ara"].flatMap((c)=>{try{return[M(n,w(m(n,c)))]}catch{return[]}}),i=le(e.current);if(!i||!r.some((c)=>le(c)===i))return;let a=re(n).filter((c)=>Ue.test(c)).map((c)=>m(n,c)).filter((c)=>!r.some((d)=>E(d)===c)).filter((c)=>Date.now()-h(c).mtimeMs>3600000);if(a.length===0)return;let o=Ye();if(o===null)return;for(let c of a){if(o.includes(`${c}${me}`))continue;try{T(c,{recursive:!0,force:!0})}catch{}}}catch{}}function le(e){try{return x(e)}catch{return null}}function ze(e,t){ce(e,t,()=>{if(Ze(e)!==t)throw new l("rollback_fence_failed","Managed runtime changed before rollback could be applied.");p(e.current)})}function ve(e){return e.activationState??m(e.root,"activation.json")}function Mt(e){return fe(e)&&ge(e,["schema_version","from_version","to_version"])&&e.schema_version===
|
|
8
|
-
`)}function O(e){try{p(ve(e))}catch(t){if(t.code!=="ENOENT")throw t}}async function Rt(e){let t=de(e.paths);if(!t)return"none";let n=Ze(e.paths);if(n===t.from_version)return O(e.paths),"cleared";if(n!==t.to_version)throw new l("rollback_fence_failed","Managed runtime changed before activation recovery could be applied.");let r=e.verifyCodeSignatures??ye,i=e.healthCheck??Ve,a=!1;try{let o=F(e.paths,t.to_version);r(o,
|
|
6
|
+
`),i({event:"identity.refresh_failed",runtime_version:e.manifest.version,...r?{from_version:r}:{},to_version:e.manifest.version,reason_code:o}),{status:"failed",code:o}}finally{if(n)T(n,{recursive:!0,force:!0})}}async function vl(e){if(!b(e.currentVersion))throw new l("invalid_version","Invalid current managed runtime version.");let t=e.paths??Lt(),n=e.target??ct(),r=e.fetchImpl??fetch,i=e.timeoutMs??et,a=e.timeoutMs??tt,o=e.healthCheck??((_,g,y)=>Ve(_,g,nt,y)),c=e.verifyCodeSignatures??ye,d=e.now?.()??new Date,u,f=!1;N(t,{event:"update.check_started",runtime_version:e.currentVersion,from_version:e.currentVersion},{now:()=>d});try{await Rt({paths:t,verifyCodeSignatures:c,healthCheck:o});let _=await Yr({url:e.manifestUrl??Qc,maximumBytes:vn,fetchImpl:r,timeoutMs:i,accept:"application/json",signal:e.signal}),g=Oi(new TextDecoder().decode(_),e.trustedKeys);u=g.manifest.version;let y=()=>ut({paths:t,...e.now?{now:e.now}:{},manifest:g.manifest,target:n,trustedKeys:e.trustedKeys,fetchImpl:r,timeoutMs:a,workDirectory:t.versions,...e.home?{home:e.home}:{},...e.identityCommand?{command:e.identityCommand}:{},...e.signal?{signal:e.signal}:{}});if(Ce(u,e.currentVersion)<=0)return N(t,{event:"update.not_available",runtime_version:e.currentVersion,from_version:e.currentVersion,to_version:u,duration_ms:Math.max(0,(e.now?.()??new Date).getTime()-d.getTime())},{now:e.now}),Ae(t,e.home),{status:"not_available",currentVersion:e.currentVersion,offeredVersion:u,...u===e.currentVersion?{identity:await y()}:{}};let v=g.manifest.artifacts[n];N(t,{event:"update.download_started",runtime_version:e.currentVersion,from_version:e.currentVersion,to_version:u},{now:e.now});let A=await Yr({url:v.broker.url,maximumBytes:v.broker.size_bytes,fetchImpl:r,timeoutMs:a,accept:"application/octet-stream",signal:e.signal});Gt(A,v.broker),W(e.signal);let j=await Yr({url:v.credential_library.url,maximumBytes:v.credential_library.size_bytes,fetchImpl:r,timeoutMs:a,accept:"application/octet-stream",signal:e.signal});Gt(j,v.credential_library),N(t,{event:"update.downloaded",runtime_version:e.currentVersion,from_version:e.currentVersion,to_version:u},{now:e.now}),N(t,{event:"update.verified",runtime_version:e.currentVersion,from_version:e.currentVersion,to_version:u},{now:e.now}),W(e.signal);let he=mt({paths:t,version:u,artifact:v.broker,bytes:A,credentialLibraryArtifact:v.credential_library,credentialLibraryBytes:j,verifyCodeSignatures:c}),be;try{be=await o(he.executablePath,u,e.signal)}catch(B){throw W(e.signal),B}if(W(e.signal),!be)throw new l("pre_activation_health_failed","Managed runtime preflight failed.");let I=bt(t,u);if(!I.changed&&I.toVersion!==u)return N(t,{event:"update.not_available",runtime_version:I.toVersion,from_version:I.toVersion,to_version:u,duration_ms:Math.max(0,(e.now?.()??new Date).getTime()-d.getTime())},{now:e.now}),{status:"not_available",currentVersion:I.toVersion,offeredVersion:u};if(f=I.changed,!await o(t.current,u)){if(I.fromVersion){let B=Ge(t,u);N(t,{event:"update.rollback",runtime_version:B.toVersion,from_version:B.fromVersion,to_version:B.toVersion,reason_code:"post_activation_health_failed"},{now:e.now})}else ze(t,u);throw O(t),f=!1,new l("post_activation_health_failed","Managed runtime activation failed.")}return O(t),Ae(t,e.home),N(t,{event:"update.activated",runtime_version:u,from_version:e.currentVersion,to_version:u,duration_ms:Math.max(0,(e.now?.()??new Date).getTime()-d.getTime())},{now:e.now}),{status:"activated",fromVersion:e.currentVersion,toVersion:u,installed:he.installed,identity:await y()}}catch(_){throw N(t,{event:"update.failed",runtime_version:f?u??e.currentVersion:e.currentVersion,from_version:e.currentVersion,...u?{to_version:u}:{},reason_code:_ instanceof l?_.code:"update_failed",duration_ms:Math.max(0,(e.now?.()??new Date).getTime()-d.getTime())},{now:e.now}),_}}function Le(e,t,n){try{let r=h(E(e));if(!r.isDirectory()||r.isSymbolicLink())return!1;let i=h(e);if(!i.isFile()||i.isSymbolicLink()||i.size!==t.size_bytes)return!1;let a=_e(e),o=h(a);return o.isFile()&&!o.isSymbolicLink()&&o.size===n.size_bytes&&Sn(K(e))===t.sha256&&Sn(K(a))===n.sha256}catch{return!1}}function mt(e){let t=F(e.paths,e.version);Gt(e.bytes,e.artifact),Gt(e.credentialLibraryBytes,e.credentialLibraryArtifact);let n=e.verifyCodeSignatures??ye;if(P(e.paths.root),P(e.paths.versions),S(E(t))){if(!Le(t,e.artifact,e.credentialLibraryArtifact))throw new l("installed_artifact_mismatch","The installed runtime version does not match the verified artifact.");return n(t,ae(e.paths,e.version)),{installed:!1,executablePath:t}}let r=m(e.paths.versions,`.install-${e.version}-${process.pid}-${L()}`),i=m(r,H(t)),a=_e(i);q(r,{mode:448});try{U(i,e.bytes,{mode:448,flag:"wx"}),Z(i,448),U(a,e.credentialLibraryBytes,{mode:448,flag:"wx"}),Z(a,448),n(i,a);try{k(r,E(t))}catch(o){if(!Le(t,e.artifact,e.credentialLibraryArtifact))throw o;return{installed:!1,executablePath:t}}return{installed:!0,executablePath:t}}finally{T(r,{recursive:!0,force:!0})}}function ft(e,t){if(!b(t))throw new l("invalid_version","Invalid managed Reason runtime version.");return`versions/${t}/${H(F(e,t))}`}function te(e,t){P(E(e));let n=`${e}.${process.pid}.${L()}.tmp`;try{Q(t,n),k(n,e)}finally{if(S(n))p(n)}}var Ue=/^\.(?:ara|reason)-worker-(\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?)-(darwin-(?:arm64|x64))\.([0-9A-Za-z]{6})$/,gt=new Set(["reason","ara"]);function Fe(e,t){let n=E(e),r=M(n,t),i=E(r),a=Ue.exec(H(i));if(!gt.has(H(r))||E(i)!==n||!a||!b(a[1])||!yr.includes(a[2]))return!1;try{return h(i).isDirectory()&&E(x(i))===x(n)&&h(r).isFile()&&h(En(i)).isFile()}catch(o){if(o.code==="ENOENT")return!1;throw o}}function Be(e,t,n){try{if(w(e)!==t)return!1;p(e)}catch(r){if(r.code==="ENOENT")return!1;throw r}try{return Q(n,e),!0}catch(r){if(r.code==="EEXIST")return!1;try{Q(t,e)}catch(i){if(i.code!=="EEXIST")throw i}throw r}}function _t(e,t){if(!e.legacyRoot)return!1;let n;try{if(!h(t).isSymbolicLink())return!1;n=w(t)}catch(i){if(i.code==="ENOENT")return!1;throw i}if(M(E(t),n)!==m(e.legacyRoot,"current"))return!1;if(!Be(t,n,e.current))return!1;let r=Ze(e);if(r)N(e,{event:"service.launcher_adopted",runtime_version:r,to_version:r,reason_code:"legacy_runtime_root"});return!0}function yt(e,t){let n=m(e,".local","bin"),r=m(n,"ara"),i=m(n,"reason"),a=h(r,{throwIfNoEntry:!1});if(a?.isSymbolicLink()&&w(r)==="reason")return i;if(a||!h(i,{throwIfNoEntry:!1})?.isSymbolicLink())return r;let o=w(i);return o===t.current||Fe(i,o)?i:r}function Sl(e){let t=e.launcherPath??yt(e.home??s(),e.paths);try{if(h(t).isSymbolicLink()){let r=w(t);if(r===e.paths.current)return"managed";if(Fe(t,r)&&Be(t,r,e.paths.current)){let i=se(e.paths.current,e.paths.executableName)??"unknown";return N(e.paths,{event:"service.launcher_adopted",runtime_version:i,to_version:i,reason_code:"legacy_curl_entrypoint"}),"adopted"}if(_t(e.paths,t))return"adopted"}return"conflict"}catch(n){if(n.code!=="ENOENT")throw n}q(E(t),{recursive:!0,mode:448});for(let n=0;n<4;n+=1)try{return Q(e.paths.current,t),"created"}catch(r){if(r.code!=="EEXIST")throw r;try{return h(t).isSymbolicLink()&&w(t)===e.paths.current?"managed":"conflict"}catch(i){if(i.code!=="ENOENT")throw i}}return"conflict"}function se(e,t){let n;try{if(!h(e).isSymbolicLink())return null;n=w(e)}catch{return null}let r=n.match(/^versions\/(\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?)\/(ara|Reason|reason)$/);return r&&(r[2]==="ara"||r[2]===t)?r[1]:null}function Ze(e){return se(e.current,e.executableName)}function ne(e,t,n){let i=We(t,e).split(me);return i.length===2&&b(i[0])&&(i[1]==="ara"||n!==void 0&&i[1]===n)?i[0]:null}function $e(e,t){try{return h(t).isSymbolicLink()&&M(E(t),w(t))===M(e.current)}catch{return!1}}function El(e,t=process.execPath){try{return ne(x(t),x(e.versions),e.executableName)!==null}catch{let n=M(t);return n===M(e.current)||$e(e,n)||ne(n,M(e.versions),e.executableName)!==null}}function kl(e,t=process.execPath){try{return ne(x(t),x(e.versions),e.executableName)}catch{let n=M(t);if(n===M(e.current)||$e(e,n))return Ze(e);return ne(n,M(e.versions),e.executableName)}}function vt(e,t,n=!1){let r=Ze(e);if(!r)return null;if(r===t)return{changed:!1,fromVersion:r,toVersion:r};if(!n&&Ce(t,r)<=0&&!(/^\d+\.\d+\.\d+-desktop\.v1\.\d+\.\d+\.\d+$/.test(t)&&/^\d+\.\d+\.\d+-desktopdev\./.test(r)))return{changed:!1,fromVersion:r,toVersion:r};return null}function ht(e,t,n,r=!1){let i=vt(e,t,r);if(i)return i;let a=Ze(e);if(n?.(a),a)te(e.previous,w(e.current));else if(S(e.previous))p(e.previous);return te(e.current,ft(e,t)),{changed:!0,fromVersion:a,toVersion:t}}function bt(e,t){let n=F(e,t),r=ae(e,t);if(!S(n)||!V(n).isFile()||!S(r)||!V(r).isFile())throw new l("runtime_not_installed","Managed Reason runtime version is not installed.");return ce(e,t,()=>ht(e,t,(i)=>{wt(e,{schema_version:ie,from_version:i,to_version:t})}))}function Ge(e,t){return ce(e,t,()=>{if(Ze(e)!==t)throw new l("rollback_fence_failed","Managed runtime changed before rollback could be applied.");let n=se(e.previous,e.executableName);if(!n||n===t)throw new l("rollback_unavailable","No previous managed runtime is available.");let r=F(e,n),i=ae(e,n);if(!S(r)||!V(r).isFile()||!S(i)||!V(i).isFile())throw new l("rollback_unavailable","Previous managed runtime is not installed.");let a=w(e.previous),o=w(e.current);if(M(E(e.previous),a)!==M(r))throw new l("rollback_fence_failed","Previous runtime pointer does not match its installed layout.");return te(e.current,a),te(e.previous,o),{fromVersion:t,toVersion:n}})}function Ye(){let e=ee("/bin/ps",["-axww","-o","args="],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:5000,maxBuffer:16777216});if(e.status!==0||typeof e.stdout!=="string")return null;let t=ee("/usr/sbin/lsof",["-nP","-w","-d","txt","-Fn"],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:20000,maxBuffer:67108864});if(t.error||t.status!==0&&t.status!==1||!t.stdout)return null;return`${e.stdout}
|
|
7
|
+
${t.stdout}`}function Ae(e,t){let n=[];Et(e,t??s());try{let r=Ze(e);if(!r||de(e))return n;let i=re(e.versions).filter((o)=>b(o));if(i.length<=2)return n;let a=Ye();if(a===null)return n;ce(e,r,()=>{let o=new Set([Ze(e),se(e.previous,e.executableName)]);if(de(e))return;for(let c of i){if(o.has(c))continue;let d=m(e.versions,c);if(a.includes(`${d}${me}`))continue;try{T(d,{recursive:!0,force:!0}),n.push(c)}catch{}}})}catch{}return n}function Et(e,t){try{let n=le(m(t,".local","bin"));if(!n)return;let r=["reason","ara"].flatMap((c)=>{try{return[M(n,w(m(n,c)))]}catch{return[]}}),i=le(e.current);if(!i||!r.some((c)=>le(c)===i))return;let a=re(n).filter((c)=>Ue.test(c)).map((c)=>m(n,c)).filter((c)=>!r.some((d)=>E(d)===c)).filter((c)=>Date.now()-h(c).mtimeMs>3600000);if(a.length===0)return;let o=Ye();if(o===null)return;for(let c of a){if(o.includes(`${c}${me}`))continue;try{T(c,{recursive:!0,force:!0})}catch{}}}catch{}}function le(e){try{return x(e)}catch{return null}}function ze(e,t){ce(e,t,()=>{if(Ze(e)!==t)throw new l("rollback_fence_failed","Managed runtime changed before rollback could be applied.");p(e.current)})}function ve(e){return e.activationState??m(e.root,"activation.json")}function Mt(e){return fe(e)&&ge(e,["schema_version","from_version","to_version"])&&e.schema_version===ie&&(e.from_version===null||b(e.from_version))&&b(e.to_version)}function de(e){try{let t=ve(e),n=h(t);if(!n.isFile()||n.isSymbolicLink()||n.nlink!==1||(n.mode&63)!==0||n.size>4096)throw new l("invalid_activation_state","Managed runtime activation state is invalid.");let r=JSON.parse(K(t,"utf8"));if(!Mt(r))throw new l("invalid_activation_state","Managed runtime activation state is invalid.");return r}catch(t){if(t instanceof l)throw t;if(t.code==="ENOENT")return null;throw new l("invalid_activation_state","Managed runtime activation state is invalid.")}}function wt(e,t){Oe(ve(e),JSON.stringify(t)+`
|
|
8
|
+
`)}function O(e){try{p(ve(e))}catch(t){if(t.code!=="ENOENT")throw t}}async function Rt(e){let t=de(e.paths);if(!t)return"none";let n=Ze(e.paths);if(n===t.from_version)return O(e.paths),"cleared";if(n!==t.to_version)throw new l("rollback_fence_failed","Managed runtime changed before activation recovery could be applied.");let r=e.verifyCodeSignatures??ye,i=e.healthCheck??Ve,a=!1;try{let o=F(e.paths,t.to_version);r(o,ae(e.paths,t.to_version)),a=await i(o,t.to_version)}catch{a=!1}if(a)return O(e.paths),N(e.paths,{event:"update.activated",runtime_version:t.to_version,...t.from_version?{from_version:t.from_version}:{},to_version:t.to_version,reason_code:"restart_recovery"}),"committed";if(t.from_version){let o=Ge(e.paths,t.to_version);return O(e.paths),N(e.paths,{event:"update.rollback",runtime_version:o.toVersion,from_version:o.fromVersion,to_version:o.toVersion,reason_code:"restart_recovery"}),"rolled_back"}return ze(e.paths,t.to_version),O(e.paths),N(e.paths,{event:"update.rollback",runtime_version:t.to_version,from_version:t.to_version,reason_code:"restart_recovery"}),"rolled_back"}function pt(e){return fe(e)&&ge(e,["schema_version","pid","nonce","started_at","runtime_version"])&&e.schema_version===ie&&typeof e.pid==="number"&&Number.isSafeInteger(e.pid)&&e.pid>0&&typeof e.nonce==="string"&&/^[0-9a-f-]{36}$/.test(e.nonce)&&De(e.started_at)&&b(e.runtime_version)}function Je(e,t){try{let n=h(e);if(!n.isDirectory()||!G(n))return null;let r=Ie(m(e,t),C.O_RDONLY|C.O_NOFOLLOW|C.O_NONBLOCK);try{let i=ke(r);if(!i.isFile()||i.nlink!==1||!G(i)||i.size>4096)return null;return K(r,"utf8")}finally{J(r)}}catch{return null}}function ue(e){try{let t=JSON.parse(Je(e,"owner.json")??"null");return pt(t)?t:null}catch{return null}}function Ke(e){try{return process.kill(e,0),!0}catch(t){return!(t instanceof Error&&("code"in t)&&t.code==="ESRCH")}}var Ne="lease",At=2,Nt=4,Y;function kt(){if(Y!==void 0)return Y;if(Y=null,process.platform!=="linux"&&process.platform!=="darwin")return null;let e;try{e=Te(import.meta.url)("bun:ffi")}catch{return null}let t=process.platform==="darwin"?"__error":"__errno_location",n=process.platform==="darwin"?["/usr/lib/libSystem.B.dylib"]:["libc.so.6",`libc.musl-${process.arch==="arm64"?"aarch64":"x86_64"}.so.1`];for(let r of n)try{let i=e.dlopen(r,{flock:{args:[e.FFIType.i32,e.FFIType.i32],returns:e.FFIType.i32},[t]:{args:[],returns:e.FFIType.ptr}}),a=i.symbols[t]();if(a===null)continue;return Y={flock:(o,c)=>i.symbols.flock(o,c),errno:()=>e.read.i32(a),wouldBlock:process.platform==="darwin"?35:11},Y}catch{}return null}var z,It=3221225472,Tt=4,xt=128,Pt=32;function Dt(e){if(z===void 0){z=null;try{let a=Te(import.meta.url)("bun:ffi"),{FFIType:o}=a;z={kernel:a.dlopen("kernel32.dll",{CreateFileW:{args:[o.ptr,o.u32,o.u32,o.ptr,o.u32,o.u32,o.ptr],returns:o.i64_fast},CloseHandle:{args:[o.i64_fast],returns:o.i32},GetLastError:{args:[],returns:o.u32}}).symbols,ptr:(d)=>a.ptr(d)}}catch{return null}}if(!z)return null;let{kernel:t,ptr:n}=z,r=Buffer.from(`${e}\x00`,"utf16le"),i=t.CreateFileW(n(r),It,0,null,Tt,xt,null);if(Number(i)===-1)return t.GetLastError()===Pt?"busy":null;return{release:()=>{t.CloseHandle(i)}}}function Ot(e){if(process.platform==="win32")return Dt(`${e}.lease`);let t=kt();if(!t)return null;let n=Ie(`${e}.lease`,C.O_RDWR|C.O_CREAT|C.O_NOFOLLOW,384);try{let r=ke(n);if(!r.isFile()||r.nlink!==1||!G(r))return J(n),"busy";if(t.flock(n,At|Nt)===0)return{release:()=>J(n)};let i=t.errno();return J(n),i===t.wouldBlock?"busy":null}catch(r){throw J(n),r}}function oe(e){P(E(e.path));let t=Ot(e.path);if(t==="busy")return{acquired:!1,owner:ue(e.path),recoveredStaleOwner:!1};let n=t!==null;try{let r=Ct(e,t);if(r.acquired)n=!1;return r}finally{if(n)t.release()}}function Ct(e,t){let n=e.alive??Ke,r=!1;for(let i=0;i<4;i+=1){let a={schema_version:ie,pid:e.pid??process.pid,nonce:e.nonce?.()??L(),started_at:(e.now?.()??new Date).toISOString(),runtime_version:e.runtimeVersion},o=`${e.path}.init-${process.pid}-${L()}`,c=!1;try{if(q(o,{mode:448}),U(m(o,"owner.json"),`${JSON.stringify(a)}
|
|
9
9
|
`,{mode:384,flag:"wx"}),t!==null)U(m(o,Ne),`flock
|
|
10
|
-
`,{mode:384,flag:"wx"});e.beforePublish?.();try{throw h(e.path),Object.assign(Error("Managed runtime lock exists."),{code:"EEXIST"})}catch(u){if(u.code!=="ENOENT")throw u}k(o,e.path),c=!0;let d=!1;return{acquired:!0,owner:a,recoveredStaleOwner:r,release(){if(d)return;if(d=!0,ue(e.path)?.nonce===a.nonce)T(e.path,{recursive:!0,force:!0});t?.release()}}}catch(d){let u=d.code;if(!["EEXIST","ENOTEMPTY"].includes(u??""))throw d;let f=ue(e.path),_=(e.now?.()??new Date).getTime(),g=f&&e.staleAfterMs!==void 0?_-Date.parse(f.started_at)<e.staleAfterMs:!1,y=f!==null&&!(t!==null&&Je(e.path,Ne)!==null)&&n(f.pid);if(!f||y||g)return{acquired:!1,owner:f,recoveredStaleOwner:!1};let v=`${e.path}.stale-${process.pid}-${L()}`;try{k(e.path,v),T(v,{recursive:!0,force:!0}),r=!0}catch(A){let j=A.code;if(!["ENOENT","EEXIST"].includes(j??""))throw A}}finally{if(!c)T(o,{recursive:!0,force:!0})}}throw new l("lock_unavailable","Could not acquire the managed Reason runtime lock.")}var Vt=20000;function ce(e,t,n){if(!b(t))throw new l("invalid_version","Invalid managed Reason runtime version.");let r=Date.now()+Vt,i=
|
|
11
|
-
`),Jt(e),r}async function no(e,t,n){zt(e);let r=0;for(let i of qe(e)){let a=m(e.lifecycleEvents,i);if(n){let d=Se(a);if(!d||!n(d))continue}let o=`${a}.sending-${process.pid}-${L()}`;try{k(a,o)}catch(d){if(d.code==="ENOENT")continue;throw d}let c=Se(o);if(!c){p(o);continue}try{await t(c),p(o),r+=1}catch{try{k(o,a)}catch(d){if(d.code!=="ENOENT")throw d}break}}return r}export{Qc,Lt,bl,Yr,vl,Sl,Ze,El,kl,
|
|
10
|
+
`,{mode:384,flag:"wx"});e.beforePublish?.();try{throw h(e.path),Object.assign(Error("Managed runtime lock exists."),{code:"EEXIST"})}catch(u){if(u.code!=="ENOENT")throw u}k(o,e.path),c=!0;let d=!1;return{acquired:!0,owner:a,recoveredStaleOwner:r,release(){if(d)return;if(d=!0,ue(e.path)?.nonce===a.nonce)T(e.path,{recursive:!0,force:!0});t?.release()}}}catch(d){let u=d.code;if(!["EEXIST","ENOTEMPTY"].includes(u??""))throw d;let f=ue(e.path),_=(e.now?.()??new Date).getTime(),g=f&&e.staleAfterMs!==void 0?_-Date.parse(f.started_at)<e.staleAfterMs:!1,y=f!==null&&!(t!==null&&Je(e.path,Ne)!==null)&&n(f.pid);if(!f||y||g)return{acquired:!1,owner:f,recoveredStaleOwner:!1};let v=`${e.path}.stale-${process.pid}-${L()}`;try{k(e.path,v),T(v,{recursive:!0,force:!0}),r=!0}catch(A){let j=A.code;if(!["ENOENT","EEXIST"].includes(j??""))throw A}}finally{if(!c)T(o,{recursive:!0,force:!0})}}throw new l("lock_unavailable","Could not acquire the managed Reason runtime lock.")}var Vt=20000;function ce(e,t,n){if(!b(t))throw new l("invalid_version","Invalid managed Reason runtime version.");let r=Date.now()+Vt,i=oe({path:e.transitionLock,runtimeVersion:t,staleAfterMs:60000});while(!i.acquired&&Date.now()<r)dc(100),i=oe({path:e.transitionLock,runtimeVersion:t,staleAfterMs:60000});if(!i.acquired)throw new l("transition_busy","Another managed Reason runtime transition is in progress.");try{return n()}finally{i.release()}}function xl(e){if(!b(e.runtimeVersion))throw new l("invalid_version","Invalid managed Reason runtime version.");let t=e.paths??Lt();return oe({path:t.brokerLock,runtimeVersion:e.runtimeVersion,...e.pid===void 0?{}:{pid:e.pid},...e.now===void 0?{}:{now:e.now},...e.nonce===void 0?{}:{nonce:e.nonce},...e.alive===void 0?{}:{alive:e.alive},...e.beforePublish===void 0?{}:{beforePublish:e.beforePublish}})}function He(e){return fe(e)&&ge(e,["schema_version","event_id","occurred_at","event","runtime_version"],["from_version","to_version","reason_code","duration_ms","attempt_count","retry_in_ms","capabilities"])&&e.schema_version===xe&&typeof e.event_id==="string"&&/^[0-9a-f-]{36}$/.test(e.event_id)&&De(e.occurred_at)&&typeof e.event==="string"&&ot.includes(e.event)&&b(e.runtime_version)&&(e.from_version===void 0||b(e.from_version))&&(e.to_version===void 0||b(e.to_version))&&(e.reason_code===void 0||typeof e.reason_code==="string"&&Me.test(e.reason_code))&&(e.duration_ms===void 0||typeof e.duration_ms==="number"&&Number.isSafeInteger(e.duration_ms)&&e.duration_ms>=0&&e.duration_ms<=86400000)&&(e.attempt_count===void 0||typeof e.attempt_count==="number"&&Number.isSafeInteger(e.attempt_count)&&e.attempt_count>=1&&e.attempt_count<=1e5)&&(e.retry_in_ms===void 0||typeof e.retry_in_ms==="number"&&Number.isSafeInteger(e.retry_in_ms)&&e.retry_in_ms>=0&&e.retry_in_ms<=30000)&&(e.capabilities===void 0||Array.isArray(e.capabilities)&&e.capabilities.length<=it&&e.capabilities.every((t)=>typeof t==="string"&&Me.test(t)))}var Ut=/^(\d{22}-[0-9a-f-]{36}\.json)$/,Ft=/^(\d{22}-[0-9a-f-]{36}\.json)\.sending-(\d+)-[0-9a-f-]{36}$/,Bt=300000,X=0n;function $t(e){let t=BigInt(new Date(e.occurred_at).getTime())*1000000n;return X=t>X?t:X+1n,`${String(X).padStart(22,"0")}-${e.event_id}.json`}function qe(e){try{return re(e.lifecycleEvents).filter((t)=>Ut.test(t)).sort()}catch{return[]}}function Se(e){try{let t=JSON.parse(K(e,"utf8"));return He(t)?t:null}catch{return null}}function zt(e,t=Ke,n=Date.now()){let r;try{r=re(e.lifecycleEvents)}catch{return}for(let i of r){let a=i.match(Ft);if(!a)continue;let o=m(e.lifecycleEvents,i),c=m(e.lifecycleEvents,a[1]),d=!t(Number(a[2]));if(!d)try{d=n-V(o).mtimeMs>=Bt}catch{continue}if(!d)continue;try{k(o,c)}catch(u){let f=u.code;if(f==="EEXIST")p(o);else if(f!=="ENOENT")throw u}}}function Jt(e){let n=qe(e).flatMap((i)=>{try{return[{name:i,size:V(m(e.lifecycleEvents,i)).size}]}catch{return[]}}),r=n.reduce((i,a)=>i+a.size,0);while(n.length>Xe||r>Qe){let i=n.shift();if(!i)break;try{p(m(e.lifecycleEvents,i.name)),r-=i.size}catch(a){if(a.code!=="ENOENT")throw a}}}function N(e,t,n={}){let r={schema_version:xe,event_id:n.eventId?.()??L(),occurred_at:(n.now?.()??new Date).toISOString(),...t};if(!He(r))throw new l("invalid_lifecycle_event","Managed runtime lifecycle event is invalid.");return P(e.lifecycleEvents),Oe(m(e.lifecycleEvents,$t(r)),`${JSON.stringify(r)}
|
|
11
|
+
`),Jt(e),r}async function no(e,t,n){zt(e);let r=0;for(let i of qe(e)){let a=m(e.lifecycleEvents,i);if(n){let d=Se(a);if(!d||!n(d))continue}let o=`${a}.sending-${process.pid}-${L()}`;try{k(a,o)}catch(d){if(d.code==="ENOENT")continue;throw d}let c=Se(o);if(!c){p(o);continue}try{await t(c),p(o),r+=1}catch{try{k(o,a)}catch(d){if(d.code!=="ENOENT")throw d}break}}return r}export{Qc,Lt,bl,Yr,vl,Sl,Ze,El,kl,oe,xl,N,no};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{xr,w}from"./vm-hands-entry-lite-
|
|
2
|
+
import{xr,w}from"./vm-hands-entry-lite-a4fn6ye1.js";import{De}from"./vm-hands-entry-lite-peyr9y6z.js";import{chmodSync as Y,existsSync as R,mkdirSync as X,readlinkSync as C,readFileSync as S,renameSync as Q,unlinkSync as Z,writeFileSync as nn}from"fs";import{homedir as u}from"os";import{basename as _,dirname as h,isAbsolute as p,join as o,normalize as b,relative as A,resolve as O}from"path";var c=3,N=1,P=2,D=1,x=1,T="Reason may read and write files and run commands in this signed-in OS account, subject to saved restrictions and operating system permissions.",ol="Reason may later execute on this computer inside a Reason sandbox, limited to folders explicitly attached by the user.",L=[ol,"Ara may later execute on this computer inside an Ara sandbox, limited to folders explicitly attached by the user."];function M(n){return typeof n==="string"&&L.includes(n)}var F=["future_device","updates_only","cli_only"];function f(n){return typeof n==="string"&&F.some((t)=>t===n)}function B(n=process.env,t=u()){return n.XDG_CONFIG_HOME?.trim()||o(t,".config")}function ot(n=process.env,t=u()){let r=w({env:n}),e=B(n,t);return o(e,De(e).state==="kept"?"ara":"reason",...r==="staging"?["staging"]:[],"installation.json")}function a(n){return typeof n==="string"&&n.trim().length>0}var U=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function V(n){return typeof n==="string"&&U.test(n)}function l(n){return a(n)&&p(n)&&b(n)===n}function y(n){if(!n||typeof n!=="object"||Array.isArray(n))return!1;let t=n;return l(t.path)&&(t.role==="launcher"&&(t.kind==="file"||t.kind==="symlink")||t.role==="worker_root"&&t.kind==="directory"||t.role==="alias"&&t.kind==="symlink"&&l(t.target))}function vc(n){return n==="staging"?["reason-staging","ara-staging"]:["reason","ara"]}var Pl=["reason","ara"];function cs(n){let t=n.owned_paths.filter((e)=>e.role==="launcher").map((e)=>e.path),[r]=vc(n.channel);return t.find((e)=>_(e)===r)??t[0]??null}function g(n){let[t,r]=vc(n.channel==="staging"?"staging":"production"),e=[[t,r],[r,t]];return n.owned_paths?.every((i)=>i.role!=="alias"||n.installer==="shell"&&e.some(([s,v])=>i.path===o(n.install_dir,s)&&i.target===o(n.install_dir,v))&&n.owned_paths?.some((s)=>s.role==="launcher"&&s.path===i.target))??!1}function d(n,t){try{return O(h(n),C(n))===t}catch{return!1}}function Mi(n){let t=_(n),r=t==="ara"?"reason":t==="ara-staging"?"reason-staging":null;if(!r)return n;let e=o(h(n),r);return d(e,n)||d(n,e)?e:n}function m(n,t){let r=A(n,t);return r.length>0&&!r.startsWith("..")&&!p(r)}function I(n){if(n===null)return!0;if(!n||typeof n!=="object"||Array.isArray(n))return!1;let t=n;return(t.kind==="shell_profile"||t.kind==="windows_user_path")&&a(t.location)&&a(t.value)&&(typeof t.added_by_installer==="boolean"||typeof t.added_by_ara==="boolean")&&(t.added_by_installer===void 0||typeof t.added_by_installer==="boolean")&&(t.added_by_ara===void 0||typeof t.added_by_ara==="boolean")}function E(n,t){if(t===null)return n==="cli_only";if(!t||typeof t!=="object"||Array.isArray(t))return!1;let r=t;if(r.version!==D||!a(r.recorded_at))return!1;if(n==="future_device")return r.decision==="authorized"&&M(r.scope);return r.scope===null&&r.decision===(n==="updates_only"?"ask":"disabled")}function K(n){if(!n||typeof n!=="object"||Array.isArray(n))return null;let t=n;if(t.schema_version!==N||!xr.includes(t.channel)||t.install_method!=="curl"||t.installer!=="shell"&&t.installer!=="powershell"||!a(t.installed_at)||!a(t.version)||!a(t.target)||!l(t.install_dir)||!Array.isArray(t.owned_paths)||!t.owned_paths.every(y)||!t.owned_paths.every((r)=>m(t.install_dir,r.path))||!g(t)||!I(t.path_entry))return null;return{...t,schema_version:c,installation_id:null,background_mode:"cli_only",device_consent:null}}function z(n){if(!n||typeof n!=="object"||Array.isArray(n))return null;let t=n;if(t.schema_version!==P||!k(t)||!f(t.background_mode)||!E(t.background_mode,t.device_consent))return null;return{...t,schema_version:c,installation_id:null}}function k(n){return xr.includes(n.channel)&&(n.install_method==="curl"&&(n.installer==="shell"||n.installer==="powershell")||n.install_method==="desktop"&&n.installer==="desktop"&&Array.isArray(n.owned_paths)&&n.owned_paths.length===0&&n.path_entry===null)&&a(n.installed_at)&&a(n.version)&&a(n.target)&&l(n.install_dir)&&Array.isArray(n.owned_paths)&&n.owned_paths.every(y)&&n.owned_paths.every((t)=>m(n.install_dir,t.path))&&g(n)&&I(n.path_entry)}function G(n){let t=K(n);if(t)return t;let r=z(n);if(r)return r;if(!n||typeof n!=="object"||Array.isArray(n))return null;let e=n;if(e.schema_version!==c||!V(e.installation_id)||!k(e)||!f(e.background_mode)||!E(e.background_mode,e.device_consent)||e.desktop_account_access!==void 0&&(e.desktop_account_access===null||typeof e.desktop_account_access!=="object"||Array.isArray(e.desktop_account_access)||e.desktop_account_access.version!==x||e.desktop_account_access.scope!==T||!a(e.desktop_account_access.recorded_at)||!Number.isFinite(Date.parse(e.desktop_account_access.recorded_at))))return null;return e}function We(n=ot()){if(!R(n))return null;try{return G(JSON.parse(S(n,"utf8")))}catch{return null}}export{ol,ot,vc,Pl,cs,Mi,We};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{g}from"./vm-hands-entry-lite-
|
|
2
|
+
import{g}from"./vm-hands-entry-lite-zm0707rq.js";import{s}from"./vm-hands-entry-lite-tzv8s0e7.js";import{randomUUID as P}from"crypto";import{spawnSync as b}from"child_process";import{chmodSync as z,cpSync as Z,existsSync as x,lstatSync as A,mkdirSync as L,readdirSync as ee,readFileSync as C,readlinkSync as te,realpathSync as T,renameSync as _,rmdirSync as ne,rmSync as y,symlinkSync as D,writeFileSync as re}from"fs";import{dirname as h,join as u,relative as ie,resolve as oe}from"path";var ms="so.ara.cli",w=[ms,"com.reasonmachines.cli"],ji="5LJFSBRY2F";function Hi(e){return`(${e.map((t)=>`identifier "${t}"`).join(" or ")}) and anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] exists and certificate leaf[field.1.2.840.113635.100.6.1.13] exists and certificate leaf[subject.OU] = "${ji}"`}var Y="ReasonBackgroundIdentity",Bc="Contents/Helpers/ReasonPermissionTile",se="so.ara.cli.permission-tile",be=Hi([se,"com.reasonmachines.cli.permission-tile"]),k="AraBackgroundIdentity",ce="Reason",Ae=Hi(w),ae=`anchor apple generic and (${w.map((e)=>`identifier "${e}"`).join(" or ")}) and certificate leaf[subject.OU] = "${ji}"`;class St extends Error{code;constructor(e,t){super(t);this.code=e;this.name="MacOSBackgroundIdentityError"}}var Nn="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";function st(e=s()){return u(e,"Library","Application Support","Reason","Background","Reason.app")}function O(e=s()){return u(e,"Library","Application Support","Ara","Background","Ara.app")}function ue(e){try{return A(e).isFile()}catch{return!1}}function v(e){return[Y,k].map((t)=>u(e,"Contents","MacOS",t)).find(ue)??null}function d(e){try{if(!A(e).isDirectory())return!1;let t=C(u(e,"Contents","Info.plist"),"utf8");return w.some((n)=>t.includes(`<string>${n}</string>`))&&(t.includes(`<string>${ce}</string>`)||t.includes("<string>Ara</string>"))&&v(e)!==null}catch{return!1}}function Yt(e=s()){let t=st(e);if(!d(t))return null;try{let n=C(u(t,"Contents","Info.plist"),"utf8");return/<key>CFBundleVersion<\/key>\s*<string>(\d+\.\d+\.\d+)<\/string>/.exec(n)?.[1]??null}catch{return null}}function gs(e,t=s()){let n=Yt(t);return n===null||V(R(n.split(".")),R(e.split(/[.-]/).slice(0,3)))}var le=1e4;function F(e,t){return b(e,[...t],{stdio:"ignore",timeout:le}).status??1}var G=new Set;function K(e){if(process.env.REASON_TEST_REFUSE_REAL_IDENTITY!=="1")return;let t=(n)=>{try{return T(n)}catch{return oe(n)}};if(e!==void 0&&t(e)!==t(s()))return;throw Error("A test tried to change this computer's real Reason background identity; pass a temporary home. Refused by scripts/test-env.ts.")}var W=/\/(?:runtime|CLI)\/versions\/(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$|\/\.(?:ara|reason)(?:-staging)?-worker-(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$/,H=new Set(["ara","ara.exe","reason","reason.exe"]);function R(e){return e.map((t)=>Number(t))}function V(e,t){for(let n=0;n<3;n+=1)if(e[n]!==t[n])return e[n]<t[n];return!1}var de=[0,2,161];function fe(e){if(e===null)return!0;let t=de,n=null;try{n=T(process.execPath)}catch{}return e.some((r)=>{let i=W.exec(r);if(i){let f=i[1]===void 0?i.slice(4,7):i.slice(1,4);return V(R(f),t)}let o=r.slice(r.lastIndexOf("/")+1);return H.has(o)&&r!==n&&r!==process.execPath})}function pe(){let e=b("/bin/ps",["-xo","pid=,comm="],{encoding:"utf8",timeout:5000});if(e.status!==0)return null;let t=[];for(let n of e.stdout.split(`
|
|
3
3
|
`)){let r=/^\s*(\d+)\s+(\S.*)$/.exec(n);if(!r||Number(r[1])===process.pid)continue;let i=r[2].trimEnd(),o=i.slice(i.lastIndexOf("/")+1);if(!W.test(i)&&H.has(o)){let a=b("/usr/sbin/lsof",["-a","-p",r[1],"-d","txt","-Fn"],{encoding:"utf8",timeout:5000}).stdout?.split(`
|
|
4
4
|
`).find((l)=>l.startsWith("n/"));if(a)i=a.slice(1)}t.push(i)}return t}function _s(e){if(K(e.home),!d(e.sourceApp))throw new St("identity_invalid","The packaged Reason background identity is missing or invalid.");let t=e.command??F,n=st(e.home),r=h(n);L(r,{recursive:!0,mode:448}),z(r,448);let i=T(e.sourceApp),o=null;try{o=T(n)}catch{}if(i!==o){let f=`${process.pid}.${P()}`,a=u(r,`.Reason.app.${f}.tmp`),l=u(r,`.Reason.app.${f}.old`),m=!1;try{if(Z(i,a,{recursive:!0,errorOnExist:!0,preserveTimestamps:!0}),!d(a))throw new St("identity_invalid","The copied Reason background identity is invalid.");let S=e.releaseSigned?["--test-requirement",`=${ae}`]:[];if(t("/usr/bin/codesign",["--verify","--strict",...S,a])!==0)throw new St("identity_invalid_signature","The installed Reason background identity has an invalid signature.");let I=!1;for(let p=0;p<4;p+=1){let E=!1;try{_(n,l),E=!0,m=!0}catch(c){if(c.code!=="ENOENT")throw c}if(p===0)e.beforePublish?.();try{_(a,n),I=!0}catch(c){let Q=c.code;if(!["EEXIST","ENOTEMPTY"].includes(Q??""))throw c;if(E)y(l,{recursive:!0,force:!0}),m=!1;if(p===3)throw c;continue}if(E)y(l,{recursive:!0,force:!0}),m=!1;break}if(!I)throw Error("Could not publish Reason's background identity.")}catch(S){if(m&&!x(n)&&x(l))_(l,n);throw S}finally{y(a,{recursive:!0,force:!0}),y(l,{recursive:!0,force:!0})}}return q(n,e,{verified:i!==o}),n}function J(e){return u(h(e),".Reason.app.registered")}function j(e){try{let t=A(e);return t.isDirectory()?`${t.ino}:${t.birthtimeMs}`:null}catch{return null}}function N(e){let t=j(e);try{return t!==null&&C(J(e),"utf8")===t}catch{return!1}}function X(e){if(d(e))return"bundle";try{if(A(u(e,"Contents","Info.plist"),{throwIfNoEntry:!1}))return null;return A(u(e,"Contents","MacOS",k)).isSymbolicLink()?"retired":null}catch{return null}}function q(e,t,n={}){let r=t.command??F;if(!n.verified&&r("/usr/bin/codesign",["--verify","--strict",e])!==0)throw new St("identity_invalid_signature","The installed Reason background identity has an invalid signature.");if(r(Nn,["-f",e])!==0)throw new St("identity_register_failed","Could not register Reason's macOS background identity.");let i=j(e);try{if(i)re(J(e),i,{mode:384})}catch{}try{ge(e,t.home,r,t.runningExecutables??pe)}catch(o){let f=o.code??"unknown";process.stderr.write(`Reason background identity: legacy_identity_retire_failed (${f})
|
|
5
5
|
`)}}function ge(e,t,n,r){let i=v(e);if(!i)return;let o=O(t),f=h(o),a=(c)=>u(c,"Contents","MacOS",k),l=ie(h(a(o)),i),m=`${process.pid}.${P()}`,S=X(o);if(S===null)return;let I=S==="bundle";if(I)n(Nn,["-u",o]);let p=u(f,`.Ara.app.${m}.old`);if(!G.has(o)&&!fe(r())){if(!I)n(Nn,["-u",o]);try{_(o,p)}catch(c){if(c.code==="ENOENT")return;throw c}y(p,{recursive:!0,force:!0}),ye(f);return}if(!I){if(te(a(o))===l)return;let c=`${a(o)}.${m}`;D(l,c);try{_(c,a(o))}finally{y(c,{force:!0})}return}let E=u(f,`.Ara.app.${m}.shim`);L(h(a(E)),{recursive:!0}),D(l,a(E));try{try{_(o,p)}catch(c){if(c.code==="ENOENT")return;throw c}try{_(E,o)}catch(c){if(x(o))return;throw _(p,o),c}}finally{y(E,{recursive:!0,force:!0}),y(p,{recursive:!0,force:!0})}}function ye(e){try{if(ee(e).some((n)=>n!==".DS_Store"))return;y(u(e,".DS_Store"),{force:!0}),ne(e)}catch{}}var M=new Map;function ys(e=s()){let t=M.get(e);if(t)return t;if(process.platform!=="darwin")return[];let n=B(e);if(n===null&&x(h(st(e))))Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,100),n=B(e);if(n===null)return[];return M.set(e,n),n}function B(e){let t=st(e),n=O(e);if(!d(t)||!N(t))try{Ui({home:e,skipWhenSettled:!0})}catch{}let r=d(t)&&(N(t)||!d(n))?t:d(n)?n:null,i=r?v(r):null;if(!i)return null;if(r===n)G.add(n);let o=b(i,["--can-spawn"],{env:{},timeout:2000,encoding:"utf8"});return o.status===0&&o.stdout===`spawn
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t,o,_,d,n,
|
|
2
|
+
import{t,o,_,d,n,be,P,i}from"./vm-hands-entry-lite-ef0ergar.js";var Gn=25,e=1e5,a=/^[0-9a-f]{64}$/,oo=n({day:t().regex(/^\d{4}-\d{2}-\d{2}$/),sent:o().int().min(0).max(e),received:o().int().min(0).max(e)}),s=20,r=n({name:t().min(1).max(100),address:t().min(1).max(300).optional()}),m=n({name:t().min(1).max(100),agent:t().min(1).max(100)}),h=n({machine:t().min(1).max(200),person:t().min(1).max(200),team:t().min(1).max(200),team_id:t().min(1).max(200).optional(),workspace:_().optional(),version:t().max(64).optional(),wait_seconds:o().int().min(0).max(Gn).optional(),message_counts:d(oo).max(14).optional().catch(void 0),endpoint:t().regex(a).optional().catch(void 0),hosted:d(r).max(50).optional().catch(void 0)}),l=P("kind",[n({id:t(),kind:i("who"),all:_().optional()}),n({id:t(),kind:i("send"),to:t(),body:t(),from_name:t(),from_agent:t(),wake:_(),reply_to:t().max(100).optional(),notify:_().optional()})]),Ra=n({job:l.nullable(),retry_after_seconds:o().optional(),hosted:d(m).max(s).optional().catch(void 0)}),p=n({address:t(),person:t(),machine:t(),agent:t(),repo:t().nullable(),branch:t().nullable(),status:t(),since:o().nullable(),doing:t().nullable(),worker:_(),tier:t().max(10).optional()}),c=n({person:t(),machine:t(),online:_()}),y=n({team:t().nullable(),sessions:d(p).max(2000),machines:d(c).max(500),all:_().optional()}),x=n({address:t().max(300),state:t().max(40),note:t().max(500)}),S=be([n({who:y}),n({sent:n({ids:d(t().max(100)).max(500),recipients:d(t().max(300)).max(500),from:t().max(300),deliveries:d(x).max(500).optional()})}),n({error:t().min(1).max(2000)})]),g=n({id:t().max(100),from:t().max(300),from_agent:t().max(100).nullable(),to:t().max(300),reply_to:t().max(100).nullable(),body:t().max(64000),sent_at:o()}),f=n({messages:d(g).max(100),team:t().min(1).max(200).optional(),team_id:t().min(1).max(200).optional(),workspace:_().optional(),session:t().min(1).max(100).optional().catch(void 0),machine:t().min(1).max(200).optional().catch(void 0)});
|
|
3
3
|
export{Gn,oo,Ra};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Mn}from"./vm-hands-entry-lite-
|
|
2
|
+
import{Mn}from"./vm-hands-entry-lite-43ja1g10.js";var g=Mn.version,Ir=`reason-cli/${g}`,Hc=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;function Il(r,c){if(!Hc.test(r)||!Hc.test(c))throw Error("cannot compare invalid CLI versions");let f=(t)=>{let e=t.indexOf("-");return e===-1?[t,void 0]:[t.slice(0,e),t.slice(e+1)]},[h,i]=f(r),[x,s]=f(c),u=h.split(".").map(BigInt),d=x.split(".").map(BigInt);for(let t=0;t<3;t+=1){if(u[t]===d[t])continue;return u[t]<d[t]?-1:1}if(i===void 0||s===void 0){if(i===s)return 0;return i===void 0?1:-1}let l=i.split("."),a=s.split("."),C=Math.max(l.length,a.length);for(let t=0;t<C;t+=1){let e=l[t],n=a[t];if(e===void 0||n===void 0){if(e===n)return 0;return e===void 0?-1:1}if(e===n)continue;let o=/^\d+$/.test(e),p=/^\d+$/.test(n);if(o&&p){let I=BigInt(e),m=BigInt(n);if(I===m)continue;return I<m?-1:1}if(o!==p)return o?-1:1;return e<n?-1:1}return 0}function bs(r=Bun.main){return r.startsWith("/$bunfs/")||/^B:[\\/]~BUN[\\/]/i.test(r)}
|
|
3
3
|
export{g,Ir,Hc,Il,bs};
|