@reason-machines/cli-linux-x64 0.2.558 → 0.2.560
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 +2 -2
- package/bin/vm-hands/agent-network-j5f603sy.js +2 -0
- package/bin/vm-hands/api-credentials-7rhpwe7n.js +2 -0
- package/bin/vm-hands/api-vkgf7wma.js +2 -0
- package/bin/vm-hands/ask-relay-2vf6fa2t.js +5 -0
- package/bin/vm-hands/connect-cli-06x1wfgv.js +2 -0
- package/bin/vm-hands/credentials-s7ps7y6s.js +2 -0
- package/bin/vm-hands/custom-endpoint-device-3xnrp33e.js +2 -0
- package/bin/vm-hands/desktop-account-eg8thn79.js +2 -0
- package/bin/vm-hands/device-workspace-h5rsecq8.js +2 -0
- package/bin/vm-hands/{fsevents-fev1pxw2.js → fsevents-vxv56sp5.js} +1 -1
- package/bin/vm-hands/hands-worker-source-vk664w8p.js +2 -0
- package/bin/vm-hands/{index-j6wffzfd.js → index-03p9c17x.js} +106 -106
- package/bin/vm-hands/install-receipt-j04hdw1k.js +2 -0
- package/bin/vm-hands/local-automation-8b1znx0p.js +2 -0
- package/bin/vm-hands/local-capabilities-m6pzcc94.js +2 -0
- package/bin/vm-hands/local-desktop-users-sq4trh07.js +2 -0
- package/bin/vm-hands/local-display-mac-yxcxvg2z.js +2 -0
- package/bin/vm-hands/local-display-session-zyd8s6n6.js +2 -0
- package/bin/vm-hands/local-display-video-rk680vwg.js +2 -0
- package/bin/vm-hands/local-managed-process-w26jhyfg.js +2 -0
- package/bin/vm-hands/local-pty-session-edd8ttf9.js +2 -0
- package/bin/vm-hands/managed-runtime-ykv5nyva.js +2 -0
- package/bin/vm-hands/network-auto-update-mrjz964a.js +3 -0
- package/bin/vm-hands/network-contract-8mxtma3w.js +2 -0
- package/bin/vm-hands/network-sign-in-8yvdx5rm.js +3 -0
- package/bin/vm-hands/package-vwvzjtn0.js +2 -0
- package/bin/vm-hands/permissions-nmxr8238.js +2 -0
- package/bin/vm-hands/reason-hands-protocol-1nkpw1v3.js +2 -0
- package/bin/vm-hands/serve-service-det934tz.js +2 -0
- package/bin/vm-hands/status-fr7192eh.js +96 -0
- package/bin/vm-hands/version-5d6gbmrd.js +2 -0
- package/bin/vm-hands/vm-hands-entry-lite-0as6nsks.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-0ex2twm5.js +4 -0
- package/bin/vm-hands/vm-hands-entry-lite-0wb1n769.js +9 -0
- package/bin/vm-hands/{vm-hands-entry-lite-a3p6xz53.js → vm-hands-entry-lite-2rgf8866.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-4jgykvd3.js +2 -0
- package/bin/vm-hands/vm-hands-entry-lite-52qz0n30.js +7 -0
- package/bin/vm-hands/vm-hands-entry-lite-57ajjwmh.js +2 -0
- package/bin/vm-hands/vm-hands-entry-lite-71ebge0c.js +42 -0
- package/bin/vm-hands/vm-hands-entry-lite-84mc1f7h.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-8pcs85ak.js +105 -0
- package/bin/vm-hands/vm-hands-entry-lite-8w0ah5j9.js +11 -0
- package/bin/vm-hands/vm-hands-entry-lite-8xv6c0rm.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-9g52kxyj.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-a6ss0ges.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-a7bf7xr7.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite-ab1pq3xg.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-bnpdn6fw.js +127 -0
- package/bin/vm-hands/vm-hands-entry-lite-cspd38hc.js +539 -0
- package/bin/vm-hands/{vm-hands-entry-lite-q1yvw4xz.js → vm-hands-entry-lite-e3fn8ys2.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-f8p11q6h.js +452 -0
- package/bin/vm-hands/{vm-hands-entry-lite-qzkxtymm.js → vm-hands-entry-lite-f95mg81d.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-fhx46jny.js +10 -0
- package/bin/vm-hands/{vm-hands-entry-lite-wptbvtg0.js → vm-hands-entry-lite-fk2s50nc.js} +5 -5
- package/bin/vm-hands/vm-hands-entry-lite-hjjbjpd7.js +4 -0
- package/bin/vm-hands/vm-hands-entry-lite-hs6sdn60.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-hxfxs7r9.js +3 -0
- package/bin/vm-hands/{vm-hands-entry-lite-2v4zh9ze.js → vm-hands-entry-lite-j10cw3d9.js} +9 -9
- package/bin/vm-hands/{vm-hands-entry-lite-rdnm87zp.js → vm-hands-entry-lite-jhsa4av7.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-jpvmkce5.js +2 -0
- package/bin/vm-hands/vm-hands-entry-lite-k5ytpgzz.js +65 -0
- package/bin/vm-hands/{vm-hands-entry-lite-s85p7tqp.js → vm-hands-entry-lite-krpqqx12.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-q2h781jg.js → vm-hands-entry-lite-ms99mzp0.js} +3 -3
- package/bin/vm-hands/vm-hands-entry-lite-nn6zcvmp.js +3 -0
- package/bin/vm-hands/{vm-hands-entry-lite-46pwqvpf.js → vm-hands-entry-lite-ptycjmkc.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-pxtycfdv.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite-q3er9m6y.js +9 -0
- package/bin/vm-hands/vm-hands-entry-lite-q9djb28r.js +4 -0
- package/bin/vm-hands/vm-hands-entry-lite-q9s1e2y1.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-qegwyvyz.js +3 -0
- package/bin/vm-hands/{vm-hands-entry-lite-pzj5s203.js → vm-hands-entry-lite-qf990rxw.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-rhx6adbr.js +52 -0
- package/bin/vm-hands/vm-hands-entry-lite-sy7dcccg.js +2 -0
- package/bin/vm-hands/vm-hands-entry-lite-tcmye5ny.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-tvnfm4xg.js +150 -0
- package/bin/vm-hands/{vm-hands-entry-lite-1yv5qqew.js → vm-hands-entry-lite-v4hr9x9h.js} +45 -45
- package/bin/vm-hands/vm-hands-entry-lite-vdv4nm5f.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-weqam12f.js +6 -0
- package/bin/vm-hands/vm-hands-entry-lite-y4df9n3f.js +345 -0
- package/bin/vm-hands/vm-hands-entry-lite-yvws5zpx.js +4 -0
- package/bin/vm-hands/{vm-hands-entry-lite-qd46yhvz.js → vm-hands-entry-lite-z0ht62s4.js} +3 -3
- package/bin/vm-hands/vm-hands-entry-lite-zawytz09.js +3 -0
- package/bin/vm-hands/{vm-hands-entry-lite-h2rq71rj.js → vm-hands-entry-lite-zh6ncdjn.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite.js +2 -2
- package/bin/vm-hands/{vm-hands-executor-a6c1j3gp.js → vm-hands-executor-qny3mx8f.js} +8 -8
- package/bin/vm-hands/vm-hands-op-runner-5q01rhkc.js +2 -0
- package/bin/vm-hands/{vm-hands-runtime-t5e8a0mn.js → vm-hands-runtime-gjjm5fzd.js} +3 -3
- package/bin/vm-hands/worker-preview-readiness-06tygyjs.js +2 -0
- package/bin/vm-hands/worker-sandbox-e1cpkzfz.js +2 -0
- package/package.json +1 -1
- package/bin/vm-hands/api-credentials-ds01769g.js +0 -2
- package/bin/vm-hands/api-tfq16a08.js +0 -2
- package/bin/vm-hands/connect-cli-ha9vbajx.js +0 -2
- package/bin/vm-hands/credentials-sbza33ac.js +0 -2
- package/bin/vm-hands/custom-endpoint-device-mydksbg8.js +0 -2
- package/bin/vm-hands/desktop-account-t0afsge2.js +0 -2
- package/bin/vm-hands/device-workspace-b534qy2c.js +0 -2
- package/bin/vm-hands/hands-worker-source-qj7s9dk5.js +0 -2
- package/bin/vm-hands/install-receipt-zv1bjbgh.js +0 -2
- package/bin/vm-hands/local-automation-29f2yk7r.js +0 -2
- package/bin/vm-hands/local-capabilities-1x36d69w.js +0 -2
- package/bin/vm-hands/local-desktop-users-5scb9930.js +0 -2
- package/bin/vm-hands/local-display-mac-pft73te9.js +0 -2
- package/bin/vm-hands/local-display-session-0sbtewn9.js +0 -2
- package/bin/vm-hands/local-display-video-vtd5xa7h.js +0 -2
- package/bin/vm-hands/local-managed-process-jz8h33nx.js +0 -2
- package/bin/vm-hands/local-pty-session-njd0tprg.js +0 -2
- package/bin/vm-hands/managed-runtime-c843ftzx.js +0 -2
- package/bin/vm-hands/network-contract-kx0hz3wt.js +0 -2
- package/bin/vm-hands/package-way7qesn.js +0 -2
- package/bin/vm-hands/permissions-qyfv0m6a.js +0 -2
- package/bin/vm-hands/reason-hands-protocol-g54rtrhd.js +0 -2
- package/bin/vm-hands/serve-service-fjr8vj0t.js +0 -2
- package/bin/vm-hands/status-yfp1ayay.js +0 -10
- package/bin/vm-hands/version-f3kptj80.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-04x5xjt6.js +0 -5
- package/bin/vm-hands/vm-hands-entry-lite-07apxfh8.js +0 -42
- package/bin/vm-hands/vm-hands-entry-lite-0wsr8edk.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-1bbt37sr.js +0 -452
- package/bin/vm-hands/vm-hands-entry-lite-3gbf905c.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-46zcjqas.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-48rphbjm.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-4anjdcth.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-4rystkgj.js +0 -14
- package/bin/vm-hands/vm-hands-entry-lite-6dk00ch5.js +0 -150
- package/bin/vm-hands/vm-hands-entry-lite-73f4cgkf.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-7cmf6428.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-8dfw96ym.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-97agw762.js +0 -5
- package/bin/vm-hands/vm-hands-entry-lite-ak0hd94p.js +0 -7
- package/bin/vm-hands/vm-hands-entry-lite-bpamn7ny.js +0 -9
- package/bin/vm-hands/vm-hands-entry-lite-cmfzxk3d.js +0 -126
- package/bin/vm-hands/vm-hands-entry-lite-dgfx0rbn.js +0 -5
- package/bin/vm-hands/vm-hands-entry-lite-efsp2wfz.js +0 -539
- package/bin/vm-hands/vm-hands-entry-lite-fs0bsr5q.js +0 -52
- package/bin/vm-hands/vm-hands-entry-lite-fxzadxz4.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-gje7xvy9.js +0 -6
- package/bin/vm-hands/vm-hands-entry-lite-h1qjggz0.js +0 -4
- package/bin/vm-hands/vm-hands-entry-lite-n7bd44rm.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-ny6w4vgq.js +0 -4
- package/bin/vm-hands/vm-hands-entry-lite-ravxhygk.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-tf0qzc0a.js +0 -9
- package/bin/vm-hands/vm-hands-entry-lite-tyem93c1.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-vj7xzb3y.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-wf26hjeh.js +0 -105
- package/bin/vm-hands/vm-hands-entry-lite-wghmyfba.js +0 -4
- package/bin/vm-hands/vm-hands-entry-lite-wzv13c8k.js +0 -65
- package/bin/vm-hands/vm-hands-entry-lite-yptpy066.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-yretc2th.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-z6znx10m.js +0 -2
- package/bin/vm-hands/vm-hands-op-runner-g81p656v.js +0 -2
- package/bin/vm-hands/worker-preview-readiness-gy36ejp9.js +0 -2
- package/bin/vm-hands/worker-sandbox-f1tfb3y0.js +0 -2
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{rr,Nr}from"./vm-hands-entry-lite-57ajjwmh.js";import{t,$r,V,o,_,d,h,A,$e,c,i}from"./vm-hands-entry-lite-k5ytpgzz.js";var I=t().max(201).regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/).refine((e)=>e.split("/").every((n)=>n!=="."&&n!=="..")),b=t().min(1).max(255).regex(/^[A-Za-z0-9_][A-Za-z0-9_./-]*$/).refine((e)=>!e.includes("..")&&!e.includes("//")&&!e.endsWith("/")&&!e.endsWith(".lock")),L=t().regex(/^[a-f0-9]{40}$/),O=o().int().positive(),T=t().min(1).max(256),k=t().max(60000),y={version:i(1),repoFullName:I},C=d(t().max(1024).regex(/^(?:Co-authored-by: [^<>\r\n\x00]+ <[^<>\s]+@[^<>\s]+>|Reason-Contributor-ID: rc_[a-f0-9]{32})$/)).max(1000),j=h({expectedTrailers:C,missingFromHead:C}),G=A("action",[h({action:i("edit"),title:T.optional(),body:k.optional(),base:b.optional()}),h({action:c(["ready","draft","close"])}),h({action:i("metadata"),field:c(["reviewer","assignee","label"]),change:c(["add","remove"]),value:t().min(1).max(100).refine((e)=>!/[\r\n\0]/.test(e))})]),xt=A("kind",[h({...y,kind:i("read"),path:t().min(1).max(2048),accept:c(["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"]).optional()}),h({...y,kind:i("pr_review_context"),number:O,after:t().min(1).max(1024).optional()}),h({...y,kind:i("prepare"),branch:b,baseSha:L,defaultBranch:b,diagnosticsVersion:i(1).optional()}),h({...y,kind:i("publish"),branch:b,defaultBranch:b,baseSha:L,remoteHeadSha:L.nullable(),contributorTrailers:C.optional()}),h({...y,kind:i("pr_create"),head:b,base:b,title:T,body:k,draft:_()}),h({...y,kind:i("pr_mutation"),number:O,mutation:G}),h({...y,kind:i("pr_merge"),number:O,expectedHeadSha:L,expectedBaseRef:b,method:c(["merge","squash","rebase"]),commitBody:t().max(65536).optional()})]),z=["local_device_gh_prepare_setup","local_device_gh_prepare_metadata","local_device_gh_prepare_private_init","local_device_gh_prepare_fetch","local_device_gh_prepare_base_mismatch","local_device_gh_prepare_checkout_validation","local_device_gh_prepare_checkout_init","local_device_gh_prepare_materialization"];function B(e){return z.some((n)=>n===e)}class Ln extends Error{code;constructor(e){super(e);this.code=e}}function ds(e,n,r){let p=xt.safeParse(e);return n==="failed"&&p.success&&p.data.kind==="prepare"&&p.data.diagnosticsVersion===1&&B(r)}var Ar=245760,Fc=A("kind",[h({kind:i("pr_review_context"),body:t().max(Ar)}),h({kind:i("prepare"),headSha:L}),h({kind:i("read"),status:o().int().min(200).max(599),headers:$e(t(),t().max(8192)).refine((e)=>Object.keys(e).every((n)=>n==="link"||n==="content-type")),body:t().max(Ar)}),h({kind:i("publish"),headSha:L,scannedObjectCount:o().int().min(0).max(5000),attribution:j.optional()}),h({kind:i("pr_create"),url:t().max(1024).regex(/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/pull\/[1-9][0-9]*$/)}),h({kind:i("pr_mutation"),number:O,applied:i(!0)}),h({kind:i("pr_merge"),number:O,merged:i(!0)})]).refine((e)=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=Ar,"local_device_gh_result_too_large"),F=h({source:c(["agent","human"]),operationId:V()}),Ke=h({version:i(1),userId:$r(),deviceId:$r(),rootId:$r(),runId:$r(),merge:F.optional(),contributorRefresh:$r().optional(),repoFullName:I.nullable(),rootRevision:t().regex(/^[1-9][0-9]*$/),readOnly:_(),generation:o().int().positive().nullable(),fenceId:$r().nullable()}).refine((e)=>e.generation===null===(e.fenceId===null));function w(e){return/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(e)&&e.split("/").every((n)=>n!=="."&&n!=="..")}function jc(e,n,r={},p="read"){if(w(e)&&(n==="/search/issues"||n.startsWith("/search/issues?")))return Y(e,n,r);if(!w(e)||!n.startsWith(`/repos/${e}/`)&&n!==`/repos/${e}`)throw Error("local_device_gh_repository_mismatch");if(/[\\#\u0000-\u001f]/.test(n)||/%(?:2e|5c|00)/i.test(n))throw Error("local_device_gh_path_denied");let m=new URL(n,"https://api.github.com");if(m.pathname!==n.split("?")[0]||m.username||m.password)throw Error("local_device_gh_path_denied");let R;try{R=decodeURIComponent(m.pathname.slice(`/repos/${e}`.length))}catch{throw Error("local_device_gh_path_denied")}if(R.includes("%")||R.split("/").some((s)=>s==="."||s===".."))throw Error("local_device_gh_path_denied");if((r.method??"GET").toUpperCase()!=="GET"||r.body!=null)throw Error("local_device_gh_mutation_not_admitted");if(![/^$/,/^\/commits$/,/^\/pulls$/,/^\/pulls\/[1-9][0-9]*(?:\/(?:commits|files|reviews|comments))?$/,/^\/issues\/[1-9][0-9]*(?:\/comments)?$/,/^\/issues\/comments\/[1-9][0-9]*\/reactions$/,/^\/commits\/[A-Za-z0-9_./-]+(?:\/(?:check-runs|status))?$/,/^\/check-runs\/[1-9][0-9]*(?:\/annotations)?$/,/^\/branches\/[A-Za-z0-9_./-]+$/,/^\/git\/ref\/heads\/[A-Za-z0-9_./-]+$/,/^\/compare\/[A-Za-z0-9_./-]+\.\.\.[A-Za-z0-9_./-]+$/].some((s)=>s.test(R)))throw Error("local_device_gh_path_denied");if(m.searchParams.forEach((s,f)=>{if(f==="per_page"&&/^[1-9][0-9]*$/.test(s)&&Number(s)<=100)return;if(f==="page"&&/^[1-9][0-9]*$/.test(s)&&Number(s)<=100)return;if(R==="/pulls"&&f==="state"&&["open","closed","all"].includes(s))return;if(R==="/pulls"&&f==="sort"&&s==="updated")return;if(R==="/pulls"&&f==="direction"&&s==="desc")return;if(R==="/pulls"&&["head","base"].includes(f)&&/^[A-Za-z0-9_./:-]{1,255}$/.test(s))return;throw Error("local_device_gh_query_denied")}),r.headers)new Headers(r.headers).forEach((f,q)=>{if(q!=="accept"||!["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"].includes(f))throw Error("local_device_gh_header_denied")})}function Y(e,n,r){if(/[\\#\u0000-\u001f]/.test(n))throw Error("local_device_gh_path_denied");let p=new URL(n,"https://api.github.com");if(p.pathname!=="/search/issues"||p.username||p.password)throw Error("local_device_gh_path_denied");if((r.method??"GET").toUpperCase()!=="GET"||r.body!=null)throw Error("local_device_gh_mutation_not_admitted");let m=null;p.searchParams.forEach((g,s)=>{if(s==="q"&&m===null){m=g;return}if(s==="per_page"&&/^[1-9][0-9]*$/.test(g)&&Number(g)<=100)return;if(s==="page"&&/^[1-9][0-9]*$/.test(g)&&Number(g)<=100)return;throw Error("local_device_gh_query_denied")});let R=`repo:${e.toLowerCase()} `,x=m?.toLowerCase()??"";if(x.length>512||!(x+" ").startsWith(R)||/(?:^|\s)(?:repo|org|user):/.test(x.slice(R.length)))throw Error("local_device_gh_query_denied");if(r.headers)new Headers(r.headers).forEach((g,s)=>{if(s!=="accept"||g!=="application/vnd.github+json")throw Error("local_device_gh_header_denied")})}var Hc=`query PullRequestReviewContext($owner: String!, $repo: String!, $number: Int!, $after: String) {
|
|
3
|
+
repository(owner: $owner, name: $repo) {
|
|
4
|
+
nameWithOwner
|
|
5
|
+
pullRequest(number: $number) {
|
|
6
|
+
number
|
|
7
|
+
reviewDecision
|
|
8
|
+
headRefOid
|
|
9
|
+
baseRefOid
|
|
10
|
+
baseRef {
|
|
11
|
+
branchProtectionRule {
|
|
12
|
+
requiresApprovingReviews
|
|
13
|
+
requiredApprovingReviewCount
|
|
14
|
+
requiresStatusChecks
|
|
15
|
+
requiredStatusCheckContexts
|
|
16
|
+
requiresConversationResolution
|
|
17
|
+
dismissesStaleReviews
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
reviewThreads(first: 100, after: $after) {
|
|
21
|
+
nodes {
|
|
22
|
+
id isResolved isOutdated viewerCanResolve viewerCanUnresolve
|
|
23
|
+
path line originalLine startLine originalStartLine diffSide startDiffSide
|
|
24
|
+
comments(first: 100) {
|
|
25
|
+
nodes {
|
|
26
|
+
id databaseId body createdAt updatedAt url
|
|
27
|
+
author { __typename login }
|
|
28
|
+
replyTo { databaseId }
|
|
29
|
+
}
|
|
30
|
+
pageInfo { hasNextPage }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
pageInfo { hasNextPage endCursor }
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}`;function Qt(e){return e.kind==="read"||e.kind==="pr_review_context"}var Pr=["inspect_project","fs.read","fs.write","fs.search","fs.watch","fs.upload","fs.export","fs.import","fs.download","exec.run","exec.full","process.run.v1","process.full.v1","pty.start","pty.input","pty.resize","pty.close","git.run","process.list","process.signal","ports.list","tunnel.open","tunnel.close","env.discover","setup.run","mcp.discover","mcp.start","mcp.proxy","browser.snapshot","browser.navigate","browser.act","computer.snapshot","computer.act","computer.use","browser.use","browser.recording.v1","browser.pr-proof.v1","hands.connect","jobs.control","environment.install","github.local.v1","inference.ollama.v1","inference.custom.v1","delegate.devin.copy.v1","delegate.cursor.copy.v1","display.stream.v1","automation.call.v1","preview.serve.v1","workspace.setup.v1","simulator.call.v1","simulator.stream.v1"];var er=2,v="/app/local-runtime",Je=262144,ps="x-reason-relay-host-alias",hs="v1";function l(e,n){return{path:`${v}${e}`,routerPath:e,auth:n}}function E(e,n){return{...l(e,"device_proof"),forOperation(r){return l(`/operations/${encodeURIComponent(r)}${n}`,"device_proof")}}}var M={register:l("/register","registration_bearer"),enroll:l("/enroll","none"),authChallenge:l("/auth/challenge","none"),identity:l("/identity","device_proof"),heartbeat:l("/heartbeat","device_proof"),rootsSync:l("/roots/sync","device_proof"),disconnect:l("/disconnect","device_proof"),lifecycle:l("/lifecycle","device_proof"),localSubscription:l("/local-subscription","device_proof"),ownerWorkspaces:l("/owner-workspaces","device_proof"),ownerWorkspaceEnrollment:l("/owner-workspaces/enrollment","device_proof"),sessionWorktrees:l("/session-worktrees","device_proof"),operationClaim:l("/operations/claim","device_proof"),operationHeartbeat:E("/operations/:operationId/heartbeat","/heartbeat"),operationEvents:E("/operations/:operationId/events","/events"),operationComplete:E("/operations/:operationId/complete","/complete"),operationEnvironment:E("/operations/:operationId/environment","/environment"),operationEnvironmentAck:E("/operations/:operationId/environment-ack","/environment-ack"),operationCustomEndpointCredential:E("/operations/:operationId/custom-endpoint-credential","/custom-endpoint-credential")},Ct=`${v}/session`;var J=[/^\/app\/local-runtime\/heartbeat$/,/^\/app\/local-runtime\/operations\/claim$/,/^\/app\/local-runtime\/operations\/[0-9a-fA-F-]{36}\/(?:heartbeat|events|complete|environment|environment-ack)$/];function fs(e){return J.some((n)=>n.test(e))}var $n=60000;var ms="hands_control_v1",Rr="environment.deliver",gs="vm_hands_workspace_deferred",_s="vm_hands.workspace_grant",ys="hands.unbind_unverified",bs="claim_v1",vs="environment_at_claim",Ss="ready_v1",Es="workspace_check",ks="rebind_v1",xs="resident_rebind",Cs="hands.rebind",As="snapshot_v1",Ps="cloud_access",Rs="playwright_v1",Ts="headless_browser",Is="v1",Ds="job_env_large_values",at="srt_root_v1",Le="hands_confinement",At="gid_v1",xe="model_jobs_egress",Os="setpriv_v1",Ns="jobs_user",Ls="spawning_attempt_v1",pe="hands_session_group";var $s="session_cap",Ms="none",Bs="same_launch_v1",Fs="exit_v1",js="start_wait",Tr="user_chrome",Hs="cloud_sessions";function N(e){if(!a(e)||Object.keys(e).length!==5||e.version!==1)return!1;let n=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return["boot_generation","recording_operation_id","recording_attempt_id"].every((r)=>typeof e[r]==="string"&&n.test(e[r]))&&typeof e.root_version==="string"&&/^[0-9]{1,20}(?:\.[0-9]{1,6})?$/.test(e.root_version)}function S(e){if(!a(e)||Object.keys(e).length!==6)return!1;let n=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return typeof e.device_id==="string"&&n.test(e.device_id)&&(e.binding==="workspace_source"||e.binding==="mcp_control")&&Number.isSafeInteger(e.target_revision)&&Number(e.target_revision)>=0&&Number.isSafeInteger(e.root_grant_revision)&&Number(e.root_grant_revision)>0&&Number.isSafeInteger(e.target_generation)&&Number(e.target_generation)>0&&typeof e.target_fence_id==="string"&&n.test(e.target_fence_id)}var Us=["lock_acquired","enrollment_started","enrollment_completed","readiness_started","readiness_completed","inventory_completed","control_ready"],tr=86400000;var W=["production","staging"];function D(e){if(!a(e)||Object.keys(e).length!==3)return!1;let n=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return["organization_id","user_id","device_id"].every((r)=>Object.hasOwn(e,r)&&typeof e[r]==="string"&&n.test(e[r])&&e[r]!=="00000000-0000-0000-0000-000000000000")}var K="DEVICE-PROOF-V2";function Ir(e,n=K){let r=e.method.toUpperCase();if(!/^[A-Z]+$/.test(r)||!e.pathAndQuery.startsWith(`${v}/`)||e.pathAndQuery.includes(`
|
|
38
|
+
`)||!/^[0-9]{1,20}$/.test(e.timestamp)||!/^[A-Za-z0-9_-]{22,43}$/.test(e.nonce)||e.challenge.length<16||e.challenge.length>1024||e.challenge.includes(`
|
|
39
|
+
`)||!/^[a-f0-9]{64}$/.test(e.bodySha256))throw Error("Invalid Reason Device proof input.");return Buffer.from([n,r,e.pathAndQuery,e.timestamp,e.nonce,e.challenge,e.bodySha256].join(`
|
|
40
|
+
`),"utf8")}function a(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function Z(e,n){return typeof e==="string"&&n.some((r)=>r===e)}function P(e){return a(e)&&typeof e.id==="string"&&typeof e.label==="string"&&typeof e.path_fingerprint==="string"}function X(e){return a(e)&&Number.isInteger(e.seq)&&Number(e.seq)>=0&&typeof e.kind==="string"&&/^[A-Za-z0-9._:-]{1,64}$/.test(e.kind)&&a(e.payload)}function u(e){throw Error(e)}function zs(e,n){let r=a(e)?e:{},p=typeof r.error==="string"?r.error:`http_${n}`,m=typeof r.detail==="string"?r.detail:typeof r.message==="string"?r.message:`Reason Device request failed (${n})`;return{code:p,message:m}}function zi(e){if(!a(e)||typeof e.challenge!=="string"||e.challenge.length<16||e.challenge.length>1024||e.challenge.includes(`
|
|
41
|
+
`)||typeof e.expires_at!=="string"||!Number.isFinite(Date.parse(e.expires_at)))u("Reason returned an invalid Device proof challenge.");return{challenge:e.challenge,expires_at:e.expires_at}}function H(e,n){if(!a(e)||typeof e.device_id!=="string"||e.auth_scheme!=="p256"||e.organization_id!==void 0&&typeof e.organization_id!=="string"||e.protocol_version!==er||!Array.isArray(e.roots)||!e.roots.every(P)||n&&typeof e.organization_id!=="string"||e.device_credential!==void 0)u(n?"Reason returned an invalid Device enrollment.":"Reason returned an invalid Device registration.");return{...{device_id:e.device_id,...typeof e.organization_id==="string"?{organization_id:e.organization_id}:{},protocol_version:er,roots:e.roots},auth_scheme:"p256"}}function qs(e){return H(e,!1)}function Ws(e){let n=H(e,!0);if(typeof n.organization_id!=="string")return u("Reason returned an invalid Device enrollment.");return{...n,organization_id:n.organization_id}}function Vs(e){if(!a(e)||typeof e.server_time!=="string"||typeof e.drain!=="boolean")return u("Reason returned an invalid Device heartbeat.");return{server_time:e.server_time,drain:e.drain,...U(e),...typeof e.update_policy==="string"||e.update_policy===null?{update_policy:e.update_policy}:{},...typeof e.supported_protocol_version==="number"?{supported_protocol_version:e.supported_protocol_version}:{},...ee(e.latest_cli_versions),...e.hands_prespawn===!0?{hands_prespawn:!0}:{}}}var Q=["account_root_metadata_supported","workspace_root_metadata_supported","account_root_path_supported","home_contained_roots_supported","root_paths_supported","startup_supported"];function U(e){return Object.fromEntries(Q.filter((n)=>e[n]===!0).map((n)=>[n,!0]))}function Mn(e){if(!a(e))return;try{return{...zi(e),...U(e)}}catch{return}}function ee(e){if(!a(e))return{};let n={};for(let r of W){let p=e[r];if(typeof p==="string"&&/^(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})$/.test(p))n[r]=p}return Object.keys(n).length>0?{latest_cli_versions:n}:{}}function Gs(e){if(!a(e)||!Array.isArray(e.roots)||!e.roots.every(P))return u("Reason returned an invalid Device root sync.");return{roots:e.roots}}function Ks(e){if(!a(e)||e.user_id!==void 0&&typeof e.user_id!=="string"||typeof e.organization_id!=="string"||typeof e.organization_name!=="string"||typeof e.organization_slug!=="string")return u("Reason returned an invalid Device identity.");return{...typeof e.user_id==="string"?{user_id:e.user_id}:{},organization_id:e.organization_id,organization_name:e.organization_name,organization_slug:e.organization_slug}}function Js(e){if(!a(e)||e.disconnected!==!0)return u("Reason did not disconnect this Device.");let n=e.sessions_moved;return typeof n==="number"&&Number.isSafeInteger(n)&&n>=0?{disconnected:!0,sessions_moved:n}:{disconnected:!0}}function Xs(e){if(a(e)&&e.ok===!0&&typeof e.expires==="number")return{ok:!0,expires:e.expires};if(a(e)&&e.ok===!1&&typeof e.error==="string")return{ok:!1,error:e.error};return u("Reason did not answer the local login hand-over.")}function Ys(e){if(!a(e)||e.accepted!==!0)return u("Reason did not accept the Device lifecycle event.");return{accepted:!0}}function te(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function Zs(e,n=Pr){if(!a(e)||typeof e.operation_id!=="string"||typeof e.attempt_id!=="string"||typeof e.attempt_token!=="string"||!/^(?:reason|ara)_attempt_/.test(e.attempt_token)||typeof e.lease_until!=="string"||typeof e.run_id!=="string"||typeof e.root_id!=="string"||e.owner!==void 0&&!D(e.owner)||!Z(e.capability,n)||!a(e.payload)||e.protocol_version!==er||te(e.payload)>(e.capability===rr?Nr:Je)||e.authority!==void 0&&!S(e.authority)||e.local_github_authority!==void 0&&!Ke.safeParse(e.local_github_authority).success||e.capability==="github.local.v1"&&!Ke.safeParse(e.local_github_authority).success||e.recording_authority!==void 0&&!N(e.recording_authority)||e.capability==="browser.recording.v1"&&(!N(e.recording_authority)||!D(e.owner))||e.capability!=="browser.recording.v1"&&e.recording_authority!==void 0)return u("Reason returned an invalid Device operation claim.");let r={operation_id:e.operation_id,attempt_id:e.attempt_id,attempt_token:e.attempt_token,lease_until:e.lease_until,run_id:e.run_id,root_id:e.root_id,capability:e.capability,payload:e.payload,...S(e.authority)?{authority:e.authority}:{},...N(e.recording_authority)?{recording_authority:Object.freeze({...e.recording_authority})}:{},...e.local_github_authority!==void 0?{local_github_authority:Ke.parse(e.local_github_authority)}:{},...e.capability==="hands.connect"&&a(e.environment)&&a(e.environment.payload)&&S(e.environment.authority)?{environment:{payload:e.environment.payload,authority:e.environment.authority}}:{},protocol_version:er};if(e.owner!==void 0)r.owner=Object.freeze({...e.owner});return r}function Qs(e){if(!a(e)||typeof e.lease_until!=="string"||!Array.isArray(e.controls)||!e.controls.every(X)||!Number.isInteger(e.next_control_seq)||Number(e.next_control_seq)<0)return u("Reason returned an invalid Device operation heartbeat.");return{lease_until:e.lease_until,controls:e.controls,next_control_seq:Number(e.next_control_seq)}}function ea(e){if(!a(e)||!Number.isInteger(e.next_event_seq)||Number(e.next_event_seq)<0||typeof e.duplicate!=="boolean"||!Number.isInteger(e.accepted_count)||Number(e.accepted_count)<0)return u("Reason returned an invalid Device operation event result.");return{next_event_seq:Number(e.next_event_seq),duplicate:e.duplicate,accepted_count:Number(e.accepted_count)}}function ta(e){if(!a(e)||!a(e.payload)||!S(e.authority))return u("Reason returned an invalid Device environment delivery.");return{payload:e.payload,authority:e.authority}}function oe(e){return e==="succeeded"||e==="failed"||e==="cancelled"||e==="expired"}function ra(e){if(!a(e)||!oe(e.status)||typeof e.idempotent!=="boolean")return u("Reason returned an invalid Device operation completion.");return{status:e.status,idempotent:e.idempotent}}
|
|
42
|
+
export{xt,Ln,ds,Ar,Fc,Ke,jc,Hc,Qt,Pr,er,Je,ps,hs,M,Ct,fs,$n,ms,Rr,gs,_s,ys,bs,vs,Ss,Es,ks,xs,Cs,As,Ps,Rs,Ts,Is,Ds,at,Le,At,xe,Os,Ns,Ls,pe,$s,Ms,Bs,Fs,js,Tr,Hs,Us,tr,Ir,zs,zi,qs,Ws,Vs,Mn,Gs,Ks,Js,Xs,Ys,Zs,Qs,ea,ta,ra};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{t,o,_,d,n,we,A,i}from"./vm-hands-entry-lite-k5ytpgzz.js";var zn=25,e=1e5,a=/^[0-9a-f]{64}$/,to=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(zn).optional(),message_counts:d(to).max(14).optional().catch(void 0),endpoint:t().regex(a).optional().catch(void 0),hosted:d(r).max(50).optional().catch(void 0)}),l=A("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()})]),ba=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=we([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
|
+
export{zn,to,ba};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{P}from"./vm-hands-entry-lite-2rgf8866.js";import{w}from"./vm-hands-entry-lite-q9s1e2y1.js";import{it,Qo,Oi,qe}from"./vm-hands-entry-lite-sy7dcccg.js";import{ss,Dn,Oc}from"./vm-hands-entry-lite-q3er9m6y.js";import{B}from"./vm-hands-entry-lite-8xv6c0rm.js";import{spawnSync as v}from"child_process";import{createHash as Se,randomUUID as we}from"crypto";import{chmodSync as $e,existsSync as T,mkdirSync as ye,readdirSync as Fe,readFileSync as p,renameSync as ve,rmSync as u,statSync as be,writeFileSync as We}from"fs";import{dirname as Ae,isAbsolute as q,join as g}from"path";import{spawnSync as ue}from"child_process";import{readFileSync as me}from"fs";import{userInfo as O}from"os";import{join as fe}from"path";var ge="REASON_SCHEDULED_TASK";function Ti(r){return fe(r,"AppData","Local","Reason","Tasks")}function S(r){if(/[\0-\x1f\x7f"%]/.test(r))throw Error(`A background task cannot use a value with a double quote, percent sign or control character: ${r}`);return`'${r.replace(/['\u2018\u2019\u201a\u201b]/g,"$&$&")}'`}function D(r){if(!/^[A-Za-z0-9._-]+$/.test(r))throw Error(`Invalid Windows Scheduled Task name: ${r}`);return`$env:${ge}=${S(r)};`}function H(r){let e=Object.entries(r.environment).map(([t,i])=>{if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(t))throw Error(`Invalid Windows Scheduled Task environment name: ${t}`);return`$env:${t}=${S(i)};`}),n=`$global:LASTEXITCODE=1; & ${[r.program,...r.args].map(S).join(" ")} 2>&1 | ForEach-Object { Add-Content -LiteralPath ${S(r.log)} -Value $_.ToString() -Encoding UTF8 }; $c=$LASTEXITCODE;`;return[D(r.name),...e,"$ErrorActionPreference='Continue';",r.keepAlive?`do { ${n} if ($c) { Start-Sleep -Seconds 10 } } while ($c)`:`${n} exit $c`].join(" ")}function I(r){return r.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function pe(){let r=process.env.USERDOMAIN?.trim();return r?`${r}\\${O().username}`:O().username}function M(r){let e=I(r.user??pe()),n=r.schedule==="logon",t=r.schedule==="logon"?`<LogonTrigger><Enabled>true</Enabled><UserId>${e}</UserId></LogonTrigger>`:`<TimeTrigger><Repetition><Interval>PT${r.schedule.everyMinutes}M</Interval><StopAtDurationEnd>false</StopAtDurationEnd></Repetition><StartBoundary>2026-01-01T00:00:00</StartBoundary><Enabled>true</Enabled></TimeTrigger>`,i=`-NoProfile -NonInteractive -ExecutionPolicy Bypass -WindowStyle Hidden -Command "${r.script}"`;return`<?xml version="1.0" encoding="UTF-16"?>
|
|
3
|
+
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
4
|
+
<RegistrationInfo>
|
|
5
|
+
<Description>${I(r.description)}</Description>
|
|
6
|
+
</RegistrationInfo>
|
|
7
|
+
<Triggers>
|
|
8
|
+
${t}
|
|
9
|
+
</Triggers>
|
|
10
|
+
<Principals>
|
|
11
|
+
<Principal id="Author">
|
|
12
|
+
<UserId>${e}</UserId>
|
|
13
|
+
<LogonType>InteractiveToken</LogonType>
|
|
14
|
+
<RunLevel>LeastPrivilege</RunLevel>
|
|
15
|
+
</Principal>
|
|
16
|
+
</Principals>
|
|
17
|
+
<Settings>
|
|
18
|
+
<MultipleInstancesPolicy>${n?"StopExisting":"IgnoreNew"}</MultipleInstancesPolicy>
|
|
19
|
+
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
|
|
20
|
+
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
|
|
21
|
+
<StartWhenAvailable>true</StartWhenAvailable>
|
|
22
|
+
<IdleSettings>
|
|
23
|
+
<StopOnIdleEnd>false</StopOnIdleEnd>
|
|
24
|
+
<RestartOnIdle>false</RestartOnIdle>
|
|
25
|
+
</IdleSettings>
|
|
26
|
+
<ExecutionTimeLimit>${n?"PT0S":"PT1H"}</ExecutionTimeLimit>
|
|
27
|
+
<Priority>${n?5:7}</Priority>
|
|
28
|
+
</Settings>
|
|
29
|
+
<Actions Context="Author">
|
|
30
|
+
<Exec>
|
|
31
|
+
<Command>%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe</Command>
|
|
32
|
+
<Arguments>${I(i)}</Arguments>
|
|
33
|
+
</Exec>
|
|
34
|
+
</Actions>
|
|
35
|
+
</Task>
|
|
36
|
+
`}function K(r){return Buffer.concat([Buffer.from([255,254]),Buffer.from(r.replaceAll(`\r
|
|
37
|
+
`,`
|
|
38
|
+
`).replaceAll(`
|
|
39
|
+
`,`\r
|
|
40
|
+
`),"utf16le")])}function U(r){let e=me(r);return(e[0]===255&&e[1]===254?e.subarray(2).toString("utf16le"):e.toString("utf8")).replaceAll(`\r
|
|
41
|
+
`,`
|
|
42
|
+
`)}function V(r,e){return["/Create","/TN",r,"/XML",e,"/F"]}function x(r){return["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",Buffer.from(r,"utf16le").toString("base64")]}function E(r){return`'*${D(r).replaceAll("'","''")}*'`}function _(r,e){return x(["$all = @(Get-CimInstance Win32_Process)",`$wrappers = @($all | ? { $_.ProcessId -ne $PID -and $_.CommandLine -like ${E(r)} })`,...e.keepWrapper?[]:["foreach ($w in $wrappers) { Stop-Process -Id $w.ProcessId -Force -ErrorAction SilentlyContinue }"],`foreach ($w in $wrappers) { $all | ? { $_.ParentProcessId -eq $w.ProcessId } | % { taskkill.exe /F ${e.tree?"/T ":""}/PID $_.ProcessId | Out-Null } }`].join(`
|
|
43
|
+
`))}function F(r){return x(["$all = @(Get-CimInstance Win32_Process)",`$wrappers = @($all | ? { $_.ProcessId -ne $PID -and $_.CommandLine -like ${E(r)} })`,"foreach ($w in $wrappers) { if ($all | ? { $_.ParentProcessId -eq $w.ProcessId -and $_.Name -ne 'conhost.exe' }) { 'running'; exit 0 } }","exit 1"].join(`
|
|
44
|
+
`))}function X(r,e=process.pid){let n=ue(B("powershell.exe"),x(["$all = @{}; Get-CimInstance Win32_Process | % { $all[[int]$_.ProcessId] = $_ }",`$p = $all[${Math.trunc(e)}]`,"for ($i = 0; $p -and $i -lt 64; $i++) {",` if ($p.CommandLine -like ${E(r)}) { exit 10 }`," $n = $all[[int]$p.ParentProcessId]"," if (-not $n -or $n.ProcessId -eq $p.ProcessId -or $n.CreationDate -gt $p.CreationDate) { exit 11 }"," $p = $n","}","exit 11"].join(`
|
|
45
|
+
`)),{stdio:"ignore",timeout:15000,windowsHide:!0});return n.status===10?!0:n.status===11?!1:null}var ke="REASON_WORKER_SERVICE",xe="worker_identity_unavailable";function de(r){return{platform:process.platform,home:r,uid:process.getuid?.(),command:(e,n)=>v(B(e),[...n],{stdio:"ignore"}).status??1,read:(e,n)=>{let t=v(B(e),[...n],{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4});return t.status===0?t.stdout:null},sleep:(e)=>Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e),workerIdentity:(e)=>Oc(r,e),insideService:(e,n)=>Ee(e,process.platform,process.getuid?.(),n)}}function Ee(r,e,n,t=!0){if(process.env[ke]===r||process.env.XPC_SERVICE_NAME===r)return!0;if(e==="linux")try{return p("/proc/self/cgroup","utf8").includes(`/${r}.service`)}catch{return!0}if(e==="win32")return X(r)??t;if(e!=="darwin")return!1;if(typeof n!=="number")return!0;let i=v("/bin/launchctl",["print",`gui/${n}/${r}`],{encoding:"utf8",timeout:5000});if(i.status===_e)return!1;if(i.error||i.status!==0)return!0;let s=Number(/^\s*pid = (\d+)$/m.exec(i.stdout??"")?.[1]??0);if(!s)return!1;let a=process.pid;for(let o=0;o<64&&a>1;o+=1){if(a===s)return!0;let l=v("/bin/ps",["-o","ppid=","-p",String(a)],{encoding:"utf8",timeout:5000}),c=Number(l.stdout?.trim());if(l.error||l.status!==0||!Number.isSafeInteger(c)||c<=0)return!0;if(c===a)return!1;a=c}return a>1}var _e=113;class j extends Error{code;constructor(r,e){super(r);this.code=e}}function Ue(r,e){if(!ee(r.home,r.platform))throw new j(Q);if(r.platform==="darwin")k(r);let n=qe(it(e,r.home)),t=w({env:e})==="staging",i=t?"ara-staging":"ara",s=[n?Qo(n):null,P(e,"REASON_CLI_LAUNCHER_PATH")?.trim(),r.platform==="win32"?g(r.home,"AppData","Local","Reason",...t?["staging"]:[],"bin",t?"reason-staging.exe":"reason.exe"):g(r.home,".local","bin",i)];for(let a of s)try{if(a&&q(a)&&be(a).isFile())return Oi(a)}catch{}throw new j(`A background service runs the installed Reason launcher, which was not found. Install Reason with: ${r.platform==="win32"?"irm https://reasonmachines.com/install.ps1 | iex":"curl -fsSL https://reasonmachines.com/install | sh"}`,"worker_launcher_missing")}var R=/(<key>ProgramArguments<\/key>\s*<array>\n)((?:\s*<string>[^<]*<\/string>\n)*)(\s*<\/array>)/,y=new RegExp(`(\\n\\s*<key>${Dn}</key>\\s*<string>)[^<]*(</string>)`),Te=/(<key>EnvironmentVariables<\/key>\s*<dict>[\s\S]*?)(\n\s*<\/dict>)/;function Pe(r){return r.replaceAll("<","<").replaceAll(">",">").replaceAll(""",'"').replaceAll("'","'").replaceAll("&","&")}function Y(r){let e=[...(R.exec(r)?.[2]??"").matchAll(/<string>([^<]*)<\/string>/g)].map((t)=>Pe(t[1])),n=e[1]==="--run-worker"?e.slice(2):e;return n[0]?{launcher:n[0],args:n.slice(1)}:null}function J(r,e,n){let t=n.workerIdentity?.(r)??null;return{program:t?[t.executable,"--run-worker",r,...e]:[r,...e],identity:t}}function C(r){return r.map((e)=>` <string>${d(e)}</string>`).join(`
|
|
46
|
+
`)}function z(r,e){let n;try{n=p(r,"utf8")}catch{return null}let t=Y(n);if(!t)return null;let i=q(t.launcher)?Oi(t.launcher):t.launcher,{program:s,identity:a}=J(i,t.args,e),o=n.replace(R,(l,c,m,L)=>`${c}${C(s)}
|
|
47
|
+
${L}`);if(!a)o=o.replace(y,"");else if(y.test(o))o=o.replace(y,(l,c,m)=>`${c}${d(a.app)}${m}`);else o=o.replace(Te,(l,c,m)=>`${c}
|
|
48
|
+
<key>${Dn}</key>
|
|
49
|
+
<string>${d(a.app)}</string>${m}`);return o===n?null:o}function Re(r,e){let n=z(r,e);if(n!==null)A(r,n)}function Jo(r,e,n){if(e.platform!=="darwin")return!1;let t=ze(r,e,n);return t!==null&&z(t.definition,e)!==null}var W="com.reasonmachines.worker.",h="so.reason.worker.",Z=[W,h];function bn(r,e=W){return`${e}connect${r==="production"?"":`.${r}`}`}function Xo(r,e){return Z.some((n)=>r===bn(e,n))}function Ce(r,e,n){if(e==="connect")return bn(r.channel,n);let t=Se("sha256").update(r.workspaceRoot).digest("hex").slice(0,8);return`${n}${r.name.toLowerCase()}.${t}`}var Q="A background service needs macOS (launchd), Linux (systemd --user) or Windows (Task Scheduler).";function ee(r,e){if(e==="darwin")return{directory:g(r,"Library","LaunchAgents"),suffix:".plist"};if(e==="linux")return{directory:g(r,".config","systemd","user"),suffix:".service"};if(e==="win32")return{directory:Ti(r),suffix:".xml"};return null}function f(r,e,n,t=W){let i=Ce(r,n,t),s=ee(e.home,e.platform);if(!s)return null;return{label:i,definition:g(s.directory,`${i}${s.suffix}`),logs:e.platform==="linux"?`journalctl --user -u ${i}.service`:g(r.stateDirectory,"service.log")}}function ze(r,e,n="serve"){return re(r,e,n)[0]??null}function re(r,e,n){return Z.map((t)=>f(r,e,n,t)).filter((t)=>t!==null&&T(t.definition))}function ne(r,e,n){let t=f(r,e,n,h);return t&&T(t.definition)?t:null}function Ii(r,e,n){let t=f(r,e,n),i=ne(r,e,n);if(!t||!i||!T(t.definition)||e.insideService?.(i.label))return null;if(!he(t,e))return"current_not_running";if(e.platform==="darwin"){if(typeof e.uid==="number"&&e.uid>0)e.command("/bin/launchctl",["bootout",`gui/${e.uid}/${i.label}`]);return u(i.definition,{force:!0}),"retired"}if(e.platform==="win32")return b(i,e,!0),"retired";return e.command("systemctl",["--user","disable","--now",`${i.label}.service`]),u(i.definition,{force:!0}),e.command("systemctl",["--user","daemon-reload"]),"retired"}function he(r,e){if(e.platform==="darwin")return typeof e.uid==="number"&&e.uid>0&&e.command("/bin/launchctl",["print",`gui/${e.uid}/${r.label}`])===0;if(e.platform==="win32")return e.command("schtasks",["/Query","/TN",r.label])===0;let n=`${r.label}.service`;return e.command("systemctl",["--user","is-enabled","--quiet",n])===0&&Ne.has(e.read("systemctl",["--user","show","--property=ActiveState","--value",n])?.trim()??"")}var Ne=new Set(["active","activating","reloading"]);function Di(r,e){if(e.platform==="darwin"){if(typeof e.uid!=="number"||e.uid<=0)return!1;let n=e.read("/bin/launchctl",["print",`gui/${e.uid}/${r.label}`]);return Number(/^\s*pid = (\d+)$/m.exec(n??"")?.[1]??0)>0}if(e.platform==="win32")return e.read("powershell.exe",F(r.label))?.trim()==="running";return Number(e.read("systemctl",["--user","show","--property=MainPID","--value",`${r.label}.service`])?.trim()??0)>0}function Yo(r){let{config:e,launcher:n,host:t,kind:i}=r,s=f(e,t,i);if(!s)return!1;let a;try{a=t.platform==="win32"?U(s.definition):p(s.definition,"utf8")}catch{return!1}if(t.platform==="win32")return a===oe(e,i,s,n);if(t.platform!=="darwin")return a===ie(e,i,s,n,t.home,r.path);let o=Y(a);return a.replace(y,"").replace(R,(c,m,L,ce)=>`${m}${o?`${C([o.launcher,...o.args])}
|
|
50
|
+
`:""}${ce}`)===te(e,i,s,n,{...t,workerIdentity:()=>null},r.path).plist}function N(r,e){if(e==="connect")return{args:["connect"],environment:{REASON_CLI_CHANNEL:r.channel},description:"Reason connection of this computer"};return{args:["serve",r.name,"--dir",r.workspaceRoot,...r.executionMode==="confined"?["--sandbox"]:[]],environment:{},description:`Reason machine ${r.name} worker`}}function d(r){return r.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function G(r,e=!1){if(/[\0-\x1f\x7f]/.test(r))throw new j("A background service cannot use a path with control characters.");let n=r.replaceAll("\\","\\\\").replaceAll('"',"\\\"").replaceAll("%","%%");return`"${e?n.replaceAll("$","$$$$"):n}"`}function te(r,e,n,t,i,s){let a=N(r,e),o=J(t,a.args,i),l={HOME:i.home,PATH:s,[ke]:n.label,...a.environment,...o.identity?{[Dn]:o.identity.app}:{}};return{identity:o.identity,plist:`<?xml version="1.0" encoding="UTF-8"?>
|
|
51
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
52
|
+
<plist version="1.0">
|
|
53
|
+
<dict>
|
|
54
|
+
<key>Label</key>
|
|
55
|
+
<string>${d(n.label)}</string>
|
|
56
|
+
<key>AssociatedBundleIdentifiers</key>
|
|
57
|
+
<array>
|
|
58
|
+
<string>${ss}</string>
|
|
59
|
+
</array>
|
|
60
|
+
<key>ProgramArguments</key>
|
|
61
|
+
<array>
|
|
62
|
+
${C(o.program)}
|
|
63
|
+
</array>
|
|
64
|
+
<key>EnvironmentVariables</key>
|
|
65
|
+
<dict>
|
|
66
|
+
${Object.entries(l).map(([c,m])=>` <key>${c}</key>
|
|
67
|
+
<string>${d(m)}</string>`).join(`
|
|
68
|
+
`)}
|
|
69
|
+
</dict>
|
|
70
|
+
<key>RunAtLoad</key>
|
|
71
|
+
<true/>
|
|
72
|
+
<key>KeepAlive</key>
|
|
73
|
+
<dict>
|
|
74
|
+
<key>SuccessfulExit</key>
|
|
75
|
+
<false/>
|
|
76
|
+
</dict>
|
|
77
|
+
<key>ThrottleInterval</key>
|
|
78
|
+
<integer>10</integer>
|
|
79
|
+
<key>ExitTimeOut</key>
|
|
80
|
+
<integer>${Math.ceil(r.shutdownGraceMs/1000)+10}</integer>
|
|
81
|
+
<key>ProcessType</key>
|
|
82
|
+
<string>Standard</string>
|
|
83
|
+
<key>Umask</key>
|
|
84
|
+
<integer>63</integer>
|
|
85
|
+
<key>StandardOutPath</key>
|
|
86
|
+
<string>${d(n.logs)}</string>
|
|
87
|
+
<key>StandardErrorPath</key>
|
|
88
|
+
<string>${d(n.logs)}</string>
|
|
89
|
+
</dict>
|
|
90
|
+
</plist>
|
|
91
|
+
`}}function ie(r,e,n,t,i,s){let a=N(r,e);return`[Unit]
|
|
92
|
+
Description=${a.description}
|
|
93
|
+
|
|
94
|
+
[Service]
|
|
95
|
+
ExecStart=${[t,...a.args].map((o)=>G(o,!0)).join(" ")}
|
|
96
|
+
Environment=${[`HOME=${i}`,`PATH=${s}`,`${ke}=${n.label}`,...Object.entries(a.environment).map(([o,l])=>`${o}=${l}`)].map((o)=>G(o)).join(" ")}
|
|
97
|
+
Restart=on-failure
|
|
98
|
+
RestartSec=10
|
|
99
|
+
TimeoutStopSec=${Math.ceil(r.shutdownGraceMs/1000)+10}
|
|
100
|
+
UMask=0077
|
|
101
|
+
|
|
102
|
+
[Install]
|
|
103
|
+
WantedBy=default.target
|
|
104
|
+
`}function oe(r,e,n,t){let i=N(r,e);return M({description:i.description,schedule:"logon",script:H({name:n.label,program:t,args:i.args,environment:{[ke]:n.label,...i.environment},log:n.logs,keepAlive:!0})})}function se(r,e,n){e.command("powershell.exe",_(r.label,{tree:n,keepWrapper:!n}))}function b(r,e,n){e.command("schtasks",["/Delete","/F","/TN",r.label]),e.command("powershell.exe",_(r.label,{tree:n,keepWrapper:!1})),u(r.definition,{force:!0})}function A(r,e){ye(Ae(r),{recursive:!0,mode:448});let n=`${r}.${we()}.tmp`;try{We(n,e,{mode:384,flag:"wx"}),$e(n,384),ve(n,r)}finally{u(n,{force:!0})}}function k(r){if(typeof r.uid!=="number"||!Number.isSafeInteger(r.uid)||r.uid<=0)throw new j("Set up a background service as your own user, not with sudo.","worker_service_root_user");return`gui/${r.uid}`}function vn(r){let{config:e,launcher:n,host:t}=r,i=r.kind??"serve",s=ne(e,t,i),a=s!==null&&t.insideService?.(s.label)===!0,o=f(e,t,i,a?h:W);if(!o)throw new j(Q);if(t.platform==="darwin")k(t);if(t.platform==="linux"&&t.command("systemctl",["--user","show-environment"])!==0)throw new j("No background service here: this computer has no systemd user session.","worker_service_manager_missing");let l=t.platform==="darwin"?te(e,i,o,n,t,r.path):null;if(A(o.definition,l?l.plist:t.platform==="win32"?K(oe(e,i,o,n)):ie(e,i,o,n,t.home,r.path)),ae(e,t,o,a?null:s),l)return l.identity?o:{...o,identityProblem:xe};if(t.platform==="win32")return o;return{...o,lingering:t.command("loginctl",["enable-linger"])===0}}function ae(r,e,n,t){if(e.platform==="darwin"){let a=k(e);if(t)e.command("/bin/launchctl",["bootout",`${a}/${t.label}`]);if(le(r,n,e)){if(t)u(t.definition,{force:!0});return}if(u(n.definition,{force:!0}),t)e.command("/bin/launchctl",["bootstrap",a,t.definition]);throw new j("Could not start the background service (launchctl bootstrap failed).","worker_service_start_failed")}if(e.platform==="win32"){if(t)b(t,e,!0);if(e.command("schtasks",V(n.label,n.definition))===0){if(se(n,e,e.insideService?.(n.label)!==!0),e.command("schtasks",["/Run","/TN",n.label])===0)return}throw b(n,e,!0),new j("Could not start the background service (schtasks failed).")}let i=`${n.label}.service`,s=t?`${t.label}.service`:null;if(e.command("systemctl",["--user","daemon-reload"])!==0||s!==null&&e.command("systemctl",["--user","disable","--now",s])!==0||e.command("systemctl",["--user","enable",i])!==0||e.command("systemctl",["--user","restart",i])!==0){if(e.command("systemctl",["--user","disable",i]),u(n.definition,{force:!0}),e.command("systemctl",["--user","daemon-reload"]),s)e.command("systemctl",["--user","enable","--now",s]);throw new j("Could not start the background service (systemctl --user failed).","worker_service_start_failed")}if(t)u(t.definition,{force:!0}),e.command("systemctl",["--user","daemon-reload"])}function le(r,e,n){let t=k(n);n.command("/bin/launchctl",["bootout",`${t}/${e.label}`]);let i=(Math.ceil(r.shutdownGraceMs/1000)+10)*1000;for(let s=0,a=100;;a=Math.min(a*2,2000)){if(n.command("/bin/launchctl",["bootstrap",t,e.definition])===0)return!0;if(s>=i)return!1;n.sleep(a),s+=a}}function Ie(r,e,n){let t=ze(r,e,n);if(!t)return null;let i=e.insideService?.(t.label)===!0;if(e.platform==="darwin"&&!i)Re(t.definition,e);let s=f(r,e,n);if(s&&t.label!==s.label&&!i)return A(s.definition,p(t.definition,"utf8").replaceAll(t.label,s.label)),ae(r,e,s,t),s;let a=e.platform==="darwin"&&i,o;if(e.platform==="win32")se(t,e,!i),o=e.command("schtasks",["/Run","/TN",t.label])===0;else if(a)o=e.command("/bin/launchctl",["kickstart","-k",`${k(e)}/${t.label}`])===0;else if(e.platform==="darwin")o=le(r,t,e);else e.command("systemctl",["--user","enable",`${t.label}.service`]),o=e.command("systemctl",["--user","restart",`${t.label}.service`])===0;if(!o)throw new j(`Could not restart the background service ${t.label}.`,"worker_service_restart_failed");if(s&&t.label===s.label)Ii(r,e,n);return t}function Zo(r,e,n,t){let i=ze(r,n,t),s=f(e,n,t);if(n.platform!=="darwin"||!i||!s)return;let a=`<string>${d(i.logs)}</string>`,o=p(i.definition,"utf8");if(o.includes(a))A(i.definition,o.replaceAll(a,`<string>${d(s.logs)}</string>`))}function Sn(r,e,n="serve"){let t=re(r,e,n);for(let i of t){if(e.platform==="win32"){b(i,e,e.insideService?.(i.label,!1)!==!0);continue}if(e.platform==="darwin"){if(typeof e.uid==="number"&&e.uid>0)e.command("/bin/launchctl",["bootout",`gui/${e.uid}/${i.label}`]);u(i.definition,{force:!0});continue}e.command("systemctl",["--user","disable","--now",`${i.label}.service`]),u(i.definition,{force:!0}),e.command("systemctl",["--user","daemon-reload"])}return t[0]??null}
|
|
105
|
+
export{Ti,ke,de,j,Ue,Jo,bn,Xo,ze,Ii,Di,Yo,vn,Ie,Zo,Sn};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{P}from"./vm-hands-entry-lite-2rgf8866.js";import{$i,Mi,vt,Yt,as,cs}from"./vm-hands-entry-lite-q3er9m6y.js";import{rc,nc}from"./vm-hands-entry-lite-tcmye5ny.js";import{Ai,Pi,mn,yr,l,ac,Ri,cc,gn,Vt,_n}from"./vm-hands-entry-lite-vdv4nm5f.js";import{s}from"./vm-hands-entry-lite-zawytz09.js";import{G}from"./vm-hands-entry-lite-8xv6c0rm.js";import{randomUUID as p}from"crypto";import{chmodSync as Z,closeSync as J,constants as C,existsSync as A,fstatSync as ke,lstatSync as h,mkdirSync as q,openSync as Ie,readFileSync as K,readdirSync as re,readlinkSync as w,realpathSync as T,renameSync as S,rmSync as I,statSync as V,symlinkSync as Q,unlinkSync as R,writeFileSync as U}from"fs";import{basename as H,dirname as E,isAbsolute as We,join as m,relative as Xe,resolve as M,sep as me}from"path";import{spawnSync as ee}from"child_process";import{createRequire as Te}from"module";var ae=1,xe=1,Ze=128,Qe=65536,Vc="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"],An=Mi(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 x(e){q(e,{recursive:!0,mode:448}),Z(e,448)}function Oe(e,t){x(E(e));let n=`${e}.${process.pid}.${p()}.tmp`;try{U(n,t,{mode:384,flag:"wx"}),Z(n,384),S(n,e)}finally{if(A(n))R(n)}}function Nt(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=P(n,"REASON_CLI_CHANNEL")==="staging",i=r?P(n,"REASON_MANAGED_RUNTIME_ROOT")?.trim():void 0,o=e.root!==void 0||Boolean(i&&We(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 hl(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 oe(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"?Pi:Ai)}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),L=/^\d+$/.test(y);if(v&&L)return Number(g)<Number(y)?-1:1;if(v!==L)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=${$i}`,n=Pe.map((a)=>`Identifier=${a}`),r=Re(e.brokerEntitlements),i=Re(e.credentialLibraryEntitlements);if(!e.brokerDetail.split(`
|
|
3
|
+
`).includes(t)||!e.brokerDetail.split(`
|
|
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
|
+
`).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 Wr(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 rc([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(!as(e.manifest.version,a))return{status:"current"};r=Yt(a);let o=await Wr({url:new URL(ac,e.manifest.artifacts[e.target].broker.url).toString(),maximumBytes:mn,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}=cc(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 Wr({url:d.url,maximumBytes:d.size_bytes,fetchImpl:e.fetchImpl,timeoutMs:e.timeoutMs,accept:"application/octet-stream",signal:e.signal});Vt(u,d),x(e.workDirectory),n=m(e.workDirectory,`.identity-${process.pid}-${p()}`),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 cs({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 vt?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)I(n,{recursive:!0,force:!0})}}async function fl(e){if(!b(e.currentVersion))throw new l("invalid_version","Invalid current managed runtime version.");let t=e.paths??Nt(),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 pt({paths:t,verifyCodeSignatures:c,healthCheck:o});let _=await Wr({url:e.manifestUrl??Vc,maximumBytes:mn,fetchImpl:r,timeoutMs:i,accept:"application/json",signal:e.signal}),g=Ri(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 L=await Wr({url:v.broker.url,maximumBytes:v.broker.size_bytes,fetchImpl:r,timeoutMs:a,accept:"application/octet-stream",signal:e.signal});Vt(L,v.broker),W(e.signal);let j=await Wr({url:v.credential_library.url,maximumBytes:v.credential_library.size_bytes,fetchImpl:r,timeoutMs:a,accept:"application/octet-stream",signal:e.signal});Vt(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:L,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 k=Et(t,u);if(!k.changed&&k.toVersion!==u)return N(t,{event:"update.not_available",runtime_version:k.toVersion,from_version:k.toVersion,to_version:u,duration_ms:Math.max(0,(e.now?.()??new Date).getTime()-d.getTime())},{now:e.now}),{status:"not_available",currentVersion:k.toVersion,offeredVersion:u};if(f=k.changed,!await o(t.current,u)){if(k.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 Je(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&&gn(K(e))===t.sha256&&gn(K(a))===n.sha256}catch{return!1}}function mt(e){let t=F(e.paths,e.version);Vt(e.bytes,e.artifact),Vt(e.credentialLibraryBytes,e.credentialLibraryArtifact);let n=e.verifyCodeSignatures??ye;if(x(e.paths.root),x(e.paths.versions),A(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,oe(e.paths,e.version)),{installed:!1,executablePath:t}}let r=m(e.paths.versions,`.install-${e.version}-${process.pid}-${p()}`),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{S(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{I(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){x(E(e));let n=`${e}.${process.pid}.${p()}.tmp`;try{Q(t,n),S(n,e)}finally{if(A(n))R(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(T(i))===T(n)&&h(r).isFile()&&h(_n(i)).isFile()}catch(o){if(o.code==="ENOENT")return!1;throw o}}function Be(e,t,n){try{if(w(e)!==t)return!1;R(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=Ye(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 ml(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 Ye(e){return se(e.current,e.executableName)}function ne(e,t,n){let i=Xe(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 gl(e,t=process.execPath){try{return ne(T(t),T(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 _l(e,t=process.execPath){try{return ne(T(t),T(e.versions),e.executableName)}catch{let n=M(t);if(n===M(e.current)||$e(e,n))return Ye(e);return ne(n,M(e.versions),e.executableName)}}function ht(e,t,n=!1){let r=Ye(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 bt(e,t,n,r=!1){let i=ht(e,t,r);if(i)return i;let a=Ye(e);if(n?.(a),a)te(e.previous,w(e.current));else if(A(e.previous))R(e.previous);return te(e.current,ft(e,t)),{changed:!0,fromVersion:a,toVersion:t}}function Et(e,t){let n=F(e,t),r=oe(e,t);if(!A(n)||!V(n).isFile()||!A(r)||!V(r).isFile())throw new l("runtime_not_installed","Managed Reason runtime version is not installed.");return ce(e,t,()=>bt(e,t,(i)=>{Rt(e,{schema_version:ae,from_version:i,to_version:t})}))}function Ge(e,t){return ce(e,t,()=>{if(Ye(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=oe(e,n);if(!A(r)||!V(r).isFile()||!A(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 ze(){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=[];Mt(e,t??s());try{let r=Ye(e);if(!r||de(e))return n;let i=re(e.versions).filter((o)=>b(o));if(i.length<=2)return n;let a=ze();if(a===null)return n;ce(e,r,()=>{let o=new Set([Ye(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{I(d,{recursive:!0,force:!0}),n.push(c)}catch{}}})}catch{}return n}function Mt(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=ze();if(o===null)return;for(let c of a){if(o.includes(`${c}${me}`))continue;try{I(c,{recursive:!0,force:!0})}catch{}}}catch{}}function le(e){try{return T(e)}catch{return null}}function Je(e,t){ce(e,t,()=>{if(Ye(e)!==t)throw new l("rollback_fence_failed","Managed runtime changed before rollback could be applied.");R(e.current)})}function ve(e){return e.activationState??m(e.root,"activation.json")}function wt(e){return fe(e)&&ge(e,["schema_version","from_version","to_version"])&&e.schema_version===ae&&(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(!wt(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 Rt(e,t){Oe(ve(e),JSON.stringify(t)+`
|
|
8
|
+
`)}function O(e){try{R(ve(e))}catch(t){if(t.code!=="ENOENT")throw t}}async function pt(e){let t=de(e.paths);if(!t)return"none";let n=Ye(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,oe(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 Je(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 Lt(e){return fe(e)&&ge(e,["schema_version","pid","nonce","started_at","runtime_version"])&&e.schema_version===ae&&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 Ke(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(Ke(e,"owner.json")??"null");return Lt(t)?t:null}catch{return null}}function He(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,St=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|St)===0)return{release:()=>J(n)};let i=t.errno();return J(n),i===t.wouldBlock?"busy":null}catch(r){throw J(n),r}}function ie(e){x(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??He,r=!1;for(let i=0;i<4;i+=1){let a={schema_version:ae,pid:e.pid??process.pid,nonce:e.nonce?.()??p(),started_at:(e.now?.()??new Date).toISOString(),runtime_version:e.runtimeVersion},o=`${e.path}.init-${process.pid}-${p()}`,c=!1;try{if(q(o,{mode:448}),U(m(o,"owner.json"),`${JSON.stringify(a)}
|
|
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}S(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)I(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&&Ke(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}-${p()}`;try{S(e.path,v),I(v,{recursive:!0,force:!0}),r=!0}catch(L){let j=L.code;if(!["ENOENT","EEXIST"].includes(j??""))throw L}}finally{if(!c)I(o,{recursive:!0,force:!0})}}throw new l("lock_unavailable","Could not acquire the managed Reason runtime lock.")}var Ut=20000;function ce(e,t,n){if(!b(t))throw new l("invalid_version","Invalid managed Reason runtime version.");let r=Date.now()+Ut,i=ie({path:e.transitionLock,runtimeVersion:t,staleAfterMs:60000});while(!i.acquired&&Date.now()<r)nc(100),i=ie({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 yl(e){if(!b(e.runtimeVersion))throw new l("invalid_version","Invalid managed Reason runtime version.");let t=e.paths??Nt();return ie({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 qe(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 Ft=/^(\d{22}-[0-9a-f-]{36}\.json)$/,Bt=/^(\d{22}-[0-9a-f-]{36}\.json)\.sending-(\d+)-[0-9a-f-]{36}$/,$t=300000,X=0n;function Gt(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 je(e){try{return re(e.lifecycleEvents).filter((t)=>Ft.test(t)).sort()}catch{return[]}}function Se(e){try{let t=JSON.parse(K(e,"utf8"));return qe(t)?t:null}catch{return null}}function zt(e,t=He,n=Date.now()){let r;try{r=re(e.lifecycleEvents)}catch{return}for(let i of r){let a=i.match(Bt);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>=$t}catch{continue}if(!d)continue;try{S(o,c)}catch(u){let f=u.code;if(f==="EEXIST")R(o);else if(f!=="ENOENT")throw u}}}function Jt(e){let n=je(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>Ze||r>Qe){let i=n.shift();if(!i)break;try{R(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?.()??p(),occurred_at:(n.now?.()??new Date).toISOString(),...t};if(!qe(r))throw new l("invalid_lifecycle_event","Managed runtime lifecycle event is invalid.");return x(e.lifecycleEvents),Oe(m(e.lifecycleEvents,Gt(r)),`${JSON.stringify(r)}
|
|
11
|
+
`),Jt(e),r}async function Qi(e,t,n){zt(e);let r=0;for(let i of je(e)){let a=m(e.lifecycleEvents,i);if(n){let d=Se(a);if(!d||!n(d))continue}let o=`${a}.sending-${process.pid}-${p()}`;try{S(a,o)}catch(d){if(d.code==="ENOENT")continue;throw d}let c=Se(o);if(!c){R(o);continue}try{await t(c),R(o),r+=1}catch{try{S(o,a)}catch(d){if(d.code!=="ENOENT")throw d}break}}return r}export{Vc,Nt,hl,Wr,fl,ml,Ye,gl,_l,ie,yl,N,Qi};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Fn}from"./vm-hands-entry-lite-krpqqx12.js";import{Dt}from"./vm-hands-entry-lite-ab1pq3xg.js";import{execFileSync as p}from"child_process";import{realpathSync as S,statSync as w}from"fs";import{tmpdir as P}from"os";import{createRequire as b}from"module";import{win32 as r}from"path";var h=["/bin/bash","/usr/bin/bash"],ha="Git Bash was not found. Install Git for Windows (https://git-scm.com/download/win), then run `reason connect`.";function c(o){try{return w(o).isFile()}catch{return!1}}var i=(o)=>[r.join(o,"bin","bash.exe"),r.join(o,"usr","bin","bash.exe")];function g(o,e){let t=r.normalize(o).toLowerCase(),s=(e.SystemRoot??e.SYSTEMROOT??"C:\\Windows").toLowerCase();return t.startsWith(r.join(s,"system32").toLowerCase()+"\\")||t.startsWith(r.join(s,"sysnative").toLowerCase()+"\\")||t.includes("\\windowsapps\\")}function f(o=process.env,e=c){let t=[];for(let s of(o.PATH??o.Path??"").split(";"))if(s&&r.isAbsolute(s))t.push(r.join(s,"git.exe"));for(let s of[o.ProgramW6432,o.ProgramFiles,o["ProgramFiles(x86)"]])if(s)t.push(r.join(s,"Git","cmd","git.exe"));if(o.LOCALAPPDATA)t.push(r.join(o.LOCALAPPDATA,"Programs","Git","cmd","git.exe"));return t.find(e)??null}var a;function Wc(o=process.platform){if(o!=="win32")return"git";return a??=f(),a}function x(o){let e=process.platform==="win32"?f(o):"git";if(!e)return null;try{return p(e,["--exec-path"],{encoding:"utf8",timeout:5000,windowsHide:!0,stdio:["ignore","pipe","ignore"],env:o}).trim()||null}catch{return null}}function J(o=process.env,e=x,t=c){let s=[],l=e(o);if(l)s.push(...i(r.resolve(l,"..","..","..")));for(let n of[o.ProgramW6432,o.ProgramFiles,o["ProgramFiles(x86)"]])if(n)s.push(...i(r.join(n,"Git")));if(o.LOCALAPPDATA)s.push(...i(r.join(o.LOCALAPPDATA,"Programs","Git")));for(let n of(o.PATH??o.Path??"").split(";"))if(n&&r.isAbsolute(n))s.push(r.join(n,"bash.exe"));return s.find((n)=>!g(n,o)&&t(n))??null}var d;function Y(o=process.platform){if(o!=="win32")return h.find(c)??null;return d??=J(),d}function Xe(o=process.platform){let e=Y(o);if(!e)throw Error(o==="win32"?ha:"bash_unavailable");return e}function fa(o=process.platform){return S(o==="win32"?P():"/tmp")}function Rt(o=process.platform,e=process.env){if(o!=="win32")return"/usr/bin:/bin";let t=e.SystemRoot??e.SYSTEMROOT??"C:\\Windows";return[r.join(t,"System32"),t,r.join(t,"System32","Wbem"),r.join(t,"System32","WindowsPowerShell","v1.0")].join(";")}function B(o,e=process.platform){if(e!=="win32"||/[\\/]/.test(o))return o;let t=/\.exe$/i.test(o)?o:`${o}.exe`,s=Rt(e).split(";");return r.join(t.toLowerCase()==="powershell.exe"?s[3]:s[0],t)}function Tt(o=process.platform,e=process.env){if(o!=="win32")return{PATH:Rt(o)};let t=e.SystemRoot??e.SYSTEMROOT??"C:\\Windows";return{PATH:Rt(o,e),SystemRoot:t,WINDIR:t}}function Me(o=process.platform){return o==="win32"?{windowsHide:!0}:{detached:!0}}var u;function m(){if(u===void 0)u=Dt(Fn)(b(import.meta.url));return u}function It(o,e=process.platform){let t=o.pid;if(e!=="win32"||t===void 0)return;let s=m();if(s?.track(t))o.once("close",()=>s.release(t))}function Be(o,e="SIGTERM",t=process.platform){if(t!=="win32"){process.kill(-o,e);return}if(e===0){process.kill(o,0);return}if(m()?.terminate(o))return;p(B("taskkill",t),["/PID",String(o),"/T","/F"],{stdio:"ignore",timeout:1e4,windowsHide:!0})}function G(o,e=63,t=process.platform){return t==="win32"||o.uid===process.getuid?.()&&(o.mode&e)===0}var y=/^(?:con|prn|aux|nul|com[0-9\u00b9\u00b2\u00b3]|lpt[0-9\u00b9\u00b2\u00b3]|conin\$|conout\$)(?:\..*)?$|:|[. ]$/i;function Ki(o){return o!=="."&&o!==".."&&y.test(o)}
|
|
3
|
+
export{ha,Wc,Y,Xe,fa,Rt,B,Tt,Me,It,Be,G,Ki};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var st=".reason/workspace",Et="workspace_base",Oe="sessions",kt="workspace_layout",Ge=".reason/workspace/sessions",Cr=/^[0-9a-f]{8}$/;function Zt(t){if(!Ne(t))return!1;let e=".reason/workspace/sessions/";if(!t.startsWith(e))return!1;let n=t.slice(e.length).split("/");return n.length===2&&Cr.test(n[0])}var i=4096,S="workspaces/pi";function Ne(t){if(typeof t!=="string"||!t||t.length>i)return!1;if(t.startsWith("/")||t.includes("\x00")||t.includes("\\"))return!1;return t.split("/").every((e)=>e!==""&&e!=="."&&e!=="..")}function X(t){if(t.kind==="root"){if(t.path===void 0)return".";if(!Ne(t.path))throw Error("invalid_device_workspace_identity");return t.path}if(!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,159}$/.test(t.workspaceId)||t.workspaceId==="."||t.workspaceId==="..")throw Error("invalid_device_workspace_identity");let e=t.layout==="sessions"?"sessions":S;return`${t.base?`${t.base}/`:""}${e}/${t.workspaceId}/repo`}function te(t){if(!t||typeof t!=="object"||Array.isArray(t))return null;let e=t;if(e.kind==="root"&&Object.keys(e).length===1)return{kind:"root"};if(e.kind==="root"&&Object.keys(e).length===2&&Ne(e.path))return{kind:"root",path:e.path};if(e.kind!=="managed"||typeof e.workspaceId!=="string"||Object.keys(e).length!==2+(e.base===void 0?0:1)+(e.layout===void 0?0:1)||e.base!==void 0&&e.base!==".reason/workspace"||e.layout!==void 0&&e.layout!=="sessions")return null;let n={kind:"managed",workspaceId:e.workspaceId,...e.base===".reason/workspace"?{base:".reason/workspace"}:{},...e.layout==="sessions"?{layout:"sessions"}:{}};try{return X(n),n}catch{return null}}var c="/home/runner";var Fi="/run/reason/sessions",O=/^(?:\/[A-Za-z0-9._-]+)+$/,ji=/-sidechat-([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/,Hi=/^(.+)-repository-[a-z0-9][a-z0-9._-]*-[0-9a-f]{12}$/;function a(t){return ji.exec(t)?.[1]??Hi.exec(t)?.[1]??t}var Nn=/^((?:\/[A-Za-z0-9._-]+)+)\/\.reason\/workspace\/(workspaces\/pi|sessions)\/([^/]+)$/;function _(t,e=c,n="sessions"){if(!O.test(e)||e.split("/").some((s)=>s==="."||s===".."))throw Error("invalid_cloud_payload_home");let r=`${e}/${X({kind:"managed",workspaceId:t,base:".reason/workspace",...n?{layout:n}:{}})}`,o=`${Fi}/${a(t)}`;return{home:e,root:r.slice(0,-5),checkout:r,control:o,jobEnv:`${o}/job.env`,cloudAccess:`${o}/cloud-access`,logs:`${o}/logs`,pin:`${o}/ws`}}function E(t){return Nn.exec(t.replace(/\/+$/,""))?.[2]==="sessions"?"sessions":null}function Ui(t){let e=Nn.exec(t.replace(/\/+$/,""));if(!e)return null;try{let n=_(e[3],e[1],E(t));return n.root===t.replace(/\/+$/,"")?n:null}catch{return null}}
|
|
3
|
+
export{st,Et,Oe,kt,Ge,Cr,Zt,Ne,X,te,Fi,ji,Hi,Nn,Ui};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{w,ye}from"./vm-hands-entry-lite-q9s1e2y1.js";import{yt}from"./vm-hands-entry-lite-hs6sdn60.js";import{randomBytes as f}from"crypto";import{chmodSync as c,existsSync as a,lstatSync as p,mkdirSync as u,readFileSync as g,renameSync as m,unlinkSync as l,writeFileSync as d}from"fs";import{homedir as y}from"os";import{dirname as S,join as o}from"path";function Q(r=process.env,n=y()){let e=r.XDG_CONFIG_HOME?.trim()||o(n,".config"),t=w({env:r})==="staging"?["staging"]:[];return o(yt(e,...t),"credentials.json")}function ro(r,n=Q()){return u(S(n),{recursive:!0,mode:448}),d(n,`${JSON.stringify(r,null,2)}
|
|
3
|
+
`,{mode:384}),c(n,384),n}function ve(r=Q()){if(!a(r))return null;try{let n=g(r,"utf8"),e=JSON.parse(n);if(typeof e.apiOrigin!=="string"||typeof e.clientId!=="string"||typeof e.accessToken!=="string"||typeof e.refreshToken!=="string"||typeof e.expiresAt!=="string"||typeof e.orgId!=="string"||!Array.isArray(e.scopes))return null;let i=new URL(e.apiOrigin).origin,t=ye(i);if(t!==i)k(r,n,t);return{apiOrigin:t,clientId:e.clientId,accessToken:e.accessToken,refreshToken:e.refreshToken,expiresAt:e.expiresAt,scopes:e.scopes.filter((s)=>typeof s==="string"),orgId:e.orgId}}catch{return null}}function k(r,n,e){let i=`${r}.${process.pid}.${f(6).toString("hex")}.tmp`;try{let t=p(r);if(!t.isFile()||process.platform!=="win32"&&t.uid!==process.geteuid?.())return;let s=JSON.parse(n);if(d(i,`${JSON.stringify({...s,apiOrigin:e},null,2)}
|
|
4
|
+
`,{mode:384,flag:"wx"}),c(i,384),g(r,"utf8")!==n)throw Error("credentials_changed");m(i,r)}catch{try{l(i)}catch{}}}function no(r=Q()){if(!a(r))return!1;return l(r),!0}
|
|
5
|
+
export{Q,ro,ve,no};
|