@pendral/connect 0.0.0-stage → 1.0.2

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/LICENSE ADDED
@@ -0,0 +1,39 @@
1
+ EvryAI Connector License
2
+
3
+ Copyright (c) 2026 Pendral, Inc. All rights reserved.
4
+
5
+ This license applies to the EvryAI Connector, including its compiled code, command line tool and documentation (the "Software").
6
+ "Pendral" means Pendral, Inc.
7
+
8
+ 1. Agreement. Use of EvryAI (the "Platform") is governed by a separate agreement between Pendral and you or your organization (the
9
+ "Agreement"). This license grants no right to use the Platform itself. If this license conflicts with the Agreement, the
10
+ Agreement controls.
11
+
12
+ 2. License grant. Subject to the Agreement and to this license, Pendral grants you a non-exclusive, non-transferable,
13
+ non-sublicensable, revocable license to install and run the Software, unmodified, solely to connect machines you control to the
14
+ Platform.
15
+
16
+ 3. Restrictions. You may not:
17
+ (a) copy, modify, distribute, sell or sublicense the Software, except as needed to install and run it under section 2;
18
+ (b) reverse engineer, decompile or disassemble the Software, except to the extent applicable law expressly permits;
19
+ (c) use the Software to access any service other than the Platform, or to build a product or service that competes with it;
20
+ (d) remove, alter or obscure any proprietary notice in the Software; or
21
+ (e) use the Software in breach of applicable law.
22
+
23
+ 4. Third-party components. The Software includes open source components under their own licenses. Their notices are kept at the end
24
+ of each file that includes them.
25
+
26
+ 5. Ownership. The Software is licensed, not sold. Pendral and its licensors keep all right, title and interest in the Software and the
27
+ Platform, including all intellectual property rights.
28
+
29
+ 6. Termination. This license ends automatically when the Agreement ends or if you breach this license. On termination you must stop
30
+ using the Software and delete all copies in your possession.
31
+
32
+ 7. Disclaimer. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF
33
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT, EXCEPT AS EXPRESSLY STATED IN THE AGREEMENT.
34
+
35
+ 8. Limitation of liability. TO THE MAXIMUM EXTENT PERMITTED BY LAW, AND EXCEPT AS EXPRESSLY STATED IN THE AGREEMENT, PENDRAL SHALL
36
+ NOT BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL OR PUNITIVE DAMAGES, OR ANY LOSS OF PROFITS, REVENUE OR DATA,
37
+ ARISING OUT OF OR RELATING TO THE SOFTWARE.
38
+
39
+ 9. Questions about this license: contact your EvryAI account team.
package/README.md CHANGED
@@ -1,3 +1,84 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <a href="https://evryai.app/download">
3
+ <img src="https://cdn.jsdelivr.net/npm/@pendral/connect@1.0.2/assets/banner.png" alt="EvryAI Connect" width="100%" />
4
+ </a>
5
+ </p>
2
6
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
7
+ <p align="center">
8
+ <a href="https://www.npmjs.com/package/@pendral/connect"><img src="https://img.shields.io/npm/v/@pendral/connect?color=02334e&label=npm" alt="npm version" /></a>
9
+ <img src="https://img.shields.io/node/v/@pendral/connect?color=02334e" alt="Node version" />
10
+ <img src="https://img.shields.io/badge/platforms-Linux%20%C2%B7%20macOS%20%C2%B7%20Windows-02334e" alt="Linux, macOS and Windows" />
11
+ <img src="https://img.shields.io/badge/license-commercial-02334e" alt="Commercial license" />
12
+ </p>
13
+
14
+ <p align="center">
15
+ <a href="https://evryai.app/download"><strong>Get EvryAI Desktop</strong></a> ·
16
+ <a href="https://evryai.app">EvryAI</a>
17
+ </p>
18
+
19
+ # EvryAI Connect
20
+
21
+ Connect any Linux, macOS or Windows machine to **EvryAI Desktop** with one command. The machine dials out to EvryAI, so
22
+ there are no SSH keys to set up, no open ports and no VPN. Once it's connected, your coding agents run on it just like
23
+ on your own computer: Claude Code, Codex and other agents, git, files, terminals, dev servers and live machine stats.
24
+
25
+ - **One command.** Paste it into the machine's terminal and choose Connect in the app.
26
+ - **No inbound access.** The machine connects out over HTTPS, so it works behind NAT and firewalls.
27
+ - **End-to-end encrypted.** Traffic between the machine and your computer is encrypted with keys only the two of them
28
+ hold, and every command is signed and checked before it runs.
29
+ - **Yours to revoke.** Remove the machine in the app and its access ends at once.
30
+
31
+ ## Connect a machine
32
+
33
+ 1. In EvryAI Desktop, open **Coding settings › Machines › Add machine**, then **Command**, then **npx**.
34
+ 2. Paste the command it shows into the machine's terminal. It looks like this:
35
+
36
+ ```sh
37
+ EVRYAI_CODE=<code> npx -y @pendral/connect@1.0.2 --origin <your EvryAI address> --service
38
+ ```
39
+
40
+ On Windows, in PowerShell:
41
+
42
+ ```powershell
43
+ $env:EVRYAI_CODE='<code>'; npx.cmd -y @pendral/connect@1.0.2 --origin <your EvryAI address> --service
44
+ ```
45
+
46
+ 3. Choose **Connect** in the app when it asks. The machine shows up in your machine list, ready to use.
47
+
48
+ The one-time code is read from the environment, never from the command line, so it doesn't show up in process lists.
49
+
50
+ ## Options
51
+
52
+ | Option | What it does |
53
+ | --- | --- |
54
+ | `--service` | Keeps the connector running after restarts (systemd on Linux, launchd on macOS, a scheduled task at sign-in on Windows). |
55
+ | `--name NAME` | The name the machine has in the app. Defaults to its host name. |
56
+ | `--origin URL` | Your EvryAI address. The app fills this in. |
57
+
58
+ ## Requirements
59
+
60
+ - Node.js 20.10 or newer. On a machine without Node, use the **curl** (or PowerShell) command from the same dialog
61
+ instead; it brings its own Node.
62
+ - EvryAI Desktop on your computer, signed in to an account with machines turned on.
63
+
64
+ ## After it's connected
65
+
66
+ The connector installs to `~/.evryai/connector` (Windows: `%LOCALAPPDATA%\EvryAI\connector`), the same place the curl
67
+ command uses.
68
+
69
+ ```sh
70
+ ~/.evryai/connector/bin/evryai-connect status # is it connected, and to which computer
71
+ ~/.evryai/connector/bin/evryai-connect update # move to the connector version the app expects
72
+ ~/.evryai/connector/bin/evryai-connect remove [--all] # disconnect from your computers
73
+ ```
74
+
75
+ ## Security
76
+
77
+ This package carries the exact connector the EvryAI app expects: the same version and sha256, checked again before it's
78
+ installed. The app only ever asks a machine to run that build. The server relays traffic but can't read it or run
79
+ anything on the machine.
80
+
81
+ ## License
82
+
83
+ Commercial. See [LICENSE](./LICENSE). Use of EvryAI is governed by your agreement with Pendral, Inc. Third-party
84
+ notices are at the end of the bundled files.
Binary file
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ // EvryAI connector. Copyright (c) 2026 Pendral, Inc. All rights reserved.
3
+ import Y from"fs";import v from"path";import{fileURLToPath as M}from"url";import{spawn as E}from"child_process";import{createHash as T}from"crypto";import i from"fs";import x from"os";import p from"path";var S=n=>`EvryAI connector ${n}
4
+
5
+ EVRYAI_CODE=CODE npx -y @pendral/connect@${n} --origin URL [--service] [--name NAME]
6
+
7
+ Make the command in EvryAI: Add machine, then Command.`;function C(n){if(!n)return null;try{let r=new URL(n);return r.protocol==="https:"||r.protocol==="http:"?r.origin:null}catch{return null}}function R(n){let r=n[0];if(r==="--help"||r==="-h"||r==="help")return{kind:"help"};if(r==="--version"||r==="version")return{kind:"version"};if(r&&!r.startsWith("-"))return{kind:"passthrough",args:n};let e,s,t=!1;for(let o=0;o<n.length;o++){let a=n[o],m=l=>a.startsWith(`${l}=`)?a.slice(l.length+1):o+1>=n.length?null:n[++o];if(a==="--service")t=!0;else if(a==="--name"||a.startsWith("--name=")){let l=m("--name");if(l===null)return{kind:"error",message:"--name needs a value."};s=l}else if(a==="--origin"||a.startsWith("--origin=")){let l=m("--origin");if(l===null)return{kind:"error",message:"--origin needs a value."};e=l}else return a.startsWith("-")?{kind:"error",message:`Unknown option: ${a}`}:{kind:"error",message:`Unexpected: ${a}`}}let c=C(e);return c?{kind:"install",opts:{origin:c,service:t,...s?{name:s}:{}}}:{kind:"error",message:e?`Not an EvryAI address: ${e}`:"--origin is missing."}}function P(n,r){let[e=0,s=0]=n.split(".").map(Number),[t=0,c=0]=r.split(".").map(Number);return e>t||e===t&&s>=c}function _(n=process.env,r=process.platform){if(n.EVRYAI_CONNECTOR_DIR)return n.EVRYAI_CONNECTOR_DIR;if(r==="win32")return n.LOCALAPPDATA?p.join(n.LOCALAPPDATA,"EvryAI","connector"):null;let e=n.HOME||x.homedir();return e&&i.existsSync(e)?p.join(e,".evryai","connector"):null}var N=n=>`'${n.replace(/'/g,"'\\''")}'`;function D(n,r,e,s=process.platform){return s==="win32"?`@echo off\r
8
+ rem Written by EvryAI. Runs the connector with the Node it was installed with.\r
9
+ "${n}"${e} "${r}" %*\r
10
+ `:`#!/bin/sh
11
+ # Written by EvryAI. Runs the connector with the Node it was installed with.
12
+ [ -n "\${HTTPS_PROXY:-}\${https_proxy:-}" ] && export NODE_USE_ENV_PROXY=1
13
+ exec ${N(n)}${e} ${N(r)} "$@"
14
+ `}var I=(n,r=process.platform)=>p.join(n,"bin",r==="win32"?"evryai-connect.cmd":"evryai-connect"),A=n=>T("sha256").update(n).digest("hex"),f=class extends Error{constructor(e,s){super(s);this.code=e}};function L(n){let r=p.join(n,"install.lock");try{i.mkdirSync(r)}catch{let e=!1;try{let s=Number(i.readFileSync(p.join(r,"pid"),"utf8").trim());s>1&&(process.kill(s,0),e=Date.now()-i.statSync(r).mtimeMs<10*6e4)}catch{e=!1}if(e)throw new f(1,"Another install is running on this machine. Try again in a minute.");i.rmSync(r,{recursive:!0,force:!0}),i.mkdirSync(r)}return i.writeFileSync(p.join(r,"pid"),`${process.pid}
15
+ `),()=>i.rmSync(r,{recursive:!0,force:!0})}function F(n,r,e,s=process.execPath,t=process.versions.node,c=process.platform){var a;if(A(r)!==n.sha256)throw new f(3,"This package's connector didn't match its checksum. Nothing was installed.");for(let m of["bin","lib","tmp"])i.mkdirSync(p.join(e,m),{recursive:!0,mode:448});if(c!=="win32")try{p.basename(p.dirname(e))===".evryai"&&i.chmodSync(p.dirname(e),448),i.chmodSync(e,448)}catch{}let o=L(e);try{let m=p.join(e,"lib",`connector-${n.version}.mjs`),l=i.existsSync(m)?i.readFileSync(m):null;if(!l||A(l)!==n.sha256){let h=p.join(e,"tmp",`connector.${process.pid}.mjs`);i.writeFileSync(h,r,{mode:384}),i.renameSync(h,m)}let u=I(e,c),d=i.existsSync(u)?i.readFileSync(u,"utf8"):"",g=c==="win32"?null:((a=/ '([^']*\/lib\/connector-[^']*\.mjs)' /.exec(d))==null?void 0:a[1])??null;for(let h of i.readdirSync(p.join(e,"lib"))){let w=p.join(e,"lib",h);/^connector-.*\.mjs$/.test(h)&&w!==m&&w!==g&&i.rmSync(w,{force:!0})}let j=P(t,"22.15")?" --use-system-ca":"";return i.writeFileSync(`${u}.tmp`,D(s,m,j,c),{mode:493}),i.chmodSync(`${u}.tmp`,493),i.renameSync(`${u}.tmp`,u),{wrapper:u,lib:m}}finally{o()}}function U(n,r=process.execPath){let e={};for(let[t,c]of Object.entries(n))/^npm_/i.test(t)||t==="INIT_CWD"||t==="NODE"&&c===r||(e[t]=c);let s=Object.keys(e).find(t=>t.toUpperCase()==="PATH");if(s&&e[s]){let t=e[s].split(p.delimiter),c=a=>/[\\/]node_modules[\\/]\.bin$|[\\/]node-gyp-bin$/.test(a),o=0;for(;o<t.length&&c(t[o]);)o++;e[s]=t.slice(o).join(p.delimiter)}return e}function J(n){return["pair",...n.service?["--service"]:[],...n.name?["--name",n.name]:[],"--origin",n.origin]}function $(n,r,e,s){let t=process.platform==="win32",c=t?/ (--use-system-ca) /.test(i.readFileSync(n,"utf8"))?["--use-system-ca"]:[]:[],o=t?E(process.execPath,[...c,r,...e],{stdio:["ignore","inherit","inherit"],env:s}):E(n,e,{stdio:["ignore","inherit","inherit"],env:s}),a=()=>{};for(let l of["SIGINT","SIGHUP","SIGQUIT"])(!t||l==="SIGINT")&&process.on(l,a);let m=()=>o.kill("SIGTERM");return process.on("SIGTERM",m),new Promise(l=>{o.once("error",u=>{process.stderr.write(`Couldn't start the connector: ${u.message}
16
+ `),l(1)}),o.once("exit",(u,d)=>l(u??(d?128+(x.constants.signals[d]??0):1)))})}function W(n){var r;try{let e=i.readFileSync(n,"utf8");return((r=/"([^"]*connector-[^"]*\.mjs)"|'([^']*connector-[^']*\.mjs)'/.exec(e))==null?void 0:r.slice(1).find(Boolean))??null}catch{return null}}async function b(n,r,e=process.argv.slice(2)){var u;let s=d=>process.stdout.write(`${d}
17
+ `),t=d=>process.stderr.write(`${d}
18
+ `);if(!P(process.versions.node,n.minNode))return t(`This needs Node ${n.minNode} or newer (this is ${process.versions.node}). Update Node, or use the curl command instead.`),2;let c=process.env.EVRYAI_CODE??"";delete process.env.EVRYAI_CODE;let o=R(e);if(o.kind==="help")return s(S(n.version)),0;if(o.kind==="version")return s(n.version),0;if(o.kind==="error")return t(o.message),t(S(n.version)),2;let a=_();if(!a)return t(process.platform==="win32"?"This needs LOCALAPPDATA to be set.":"This needs a home folder (HOME isn't set)."),2;let m=U(process.env);if(o.kind==="passthrough"){let d=I(a),g=W(d);return g?$(d,g,o.args,c?{...m,EVRYAI_CODE:c}:m):(t("The connector isn't installed on this machine. Make a command in EvryAI: Add machine, then Command."),2)}if(!c)return t(S(n.version)),2;if(process.platform!=="linux"&&process.platform!=="darwin"&&process.platform!=="win32")return t("This works on Linux, macOS and Windows."),2;s(`EvryAI connector ${n.version}`),s(`Installing from npm for ${o.opts.origin}`),process.platform!=="win32"&&((u=process.getuid)==null?void 0:u.call(process))===0&&s("Running as root. Coding agents on this machine will run as root."),s(`Using Node ${process.versions.node} (found on this machine)`);let l;try{l=F(n,i.readFileSync(r),a)}catch(d){return t(d instanceof f?d.message:`Couldn't install the connector: ${d.message}`),d instanceof f?d.code:1}return $(l.wrapper,l.lib,J(o.opts),{...m,EVRYAI_CODE:c})}var O=v.resolve(v.dirname(M(import.meta.url)),".."),y=JSON.parse(Y.readFileSync(v.join(O,"package.json"),"utf8")),k={version:y.evryai.connector??y.version,sha256:y.evryai.sha256,minNode:y.evryai.minNode};b(k,v.join(O,"lib",`connector-${k.version}.mjs`)).then(n=>process.exit(n),n=>{process.stderr.write(`Something went wrong: ${n.message}
19
+ `),process.exit(1)});
@@ -0,0 +1,171 @@
1
+ // EvryAI connector 1.0.1. Copyright (c) 2026 Pendral, Inc. All rights reserved. Third-party notices at the end of this file.
2
+ import { createRequire as __connectorRequire } from "node:module";
3
+ const require = __connectorRequire(import.meta.url);
4
+ import{createHash as Ys,randomBytes as Co}from"crypto";import W from"fs";import Xn from"os";import Kn from"path";import*as ut from"node:crypto";var Rt=ut&&typeof ut=="object"&&"webcrypto"in ut?ut.webcrypto:ut&&typeof ut=="object"&&"randomBytes"in ut?ut:void 0;function Mt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Bt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Y(e,...t){if(!Mt(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function oe(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Bt(e.outputLen),Bt(e.blockLen)}function Zt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Yn(e,t){Y(e);let n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Q(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function we(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function tt(e,t){return e<<32-t|e>>>t}var Gn=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Ho=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Nt(e){if(Y(e),Gn)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=Ho[e[n]];return t}var lt={_0:48,_9:57,A:65,F:70,a:97,f:102};function Wn(e){if(e>=lt._0&&e<=lt._9)return e-lt._0;if(e>=lt.A&&e<=lt.F)return e-(lt.A-10);if(e>=lt.a&&e<=lt.f)return e-(lt.a-10)}function Ee(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Gn)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let r=new Uint8Array(n);for(let o=0,i=0;o<n;o++,i+=2){let s=Wn(e.charCodeAt(i)),a=Wn(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}r[o]=s*16+a}return r}function et(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function xt(e){return typeof e=="string"&&(e=et(e)),Y(e),e}function G(...e){let t=0;for(let r=0;r<e.length;r++){let o=e[r];Y(o),t+=o.length}let n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){let i=e[r];n.set(i,o),o+=i.length}return n}var jt=class{};function Ve(e){let t=r=>e().update(xt(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function We(e=32){if(Rt&&typeof Rt.getRandomValues=="function")return Rt.getRandomValues(new Uint8Array(e));if(Rt&&typeof Rt.randomBytes=="function")return Uint8Array.from(Rt.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function qo(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);let o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),a=Number(n&i),c=r?4:0,u=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+u,a,r)}function jn(e,t,n){return e&t^~e&n}function Zn(e,t,n){return e&t^e&n^t&n}var ie=class extends jt{constructor(t,n,r,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(t),this.view=we(this.buffer)}update(t){Zt(this),t=xt(t),Y(t);let{view:n,buffer:r,blockLen:o}=this,i=t.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=we(t);for(;o<=i-s;s+=o)this.process(c,s);continue}r.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Zt(this),Yn(t,this),this.finished=!0;let{buffer:n,view:r,blockLen:o,isLE:i}=this,{pos:s}=this;n[s++]=128,Q(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(r,0),s=0);for(let d=s;d<o;d++)n[d]=0;qo(r,o-8,BigInt(this.length*8),i),this.process(r,0);let a=we(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=c/4,h=this.get();if(u>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<u;d++)a.setUint32(4*d,h[d],i)}digest(){let{buffer:t,outputLen:n}=this;this.digestInto(t);let r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:n,buffer:r,length:o,finished:i,destroyed:s,pos:a}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=a,o%n&&t.buffer.set(r),t}clone(){return this._cloneInto()}},dt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var U=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var ve=BigInt(4294967295),zn=BigInt(32);function Fo(e,t=!1){return t?{h:Number(e&ve),l:Number(e>>zn&ve)}:{h:Number(e>>zn&ve)|0,l:Number(e&ve)|0}}function Jn(e,t=!1){let n=e.length,r=new Uint32Array(n),o=new Uint32Array(n);for(let i=0;i<n;i++){let{h:s,l:a}=Fo(e[i],t);[r[i],o[i]]=[s,a]}return[r,o]}var Ye=(e,t,n)=>e>>>n,Ge=(e,t,n)=>e<<32-n|t>>>n,Ct=(e,t,n)=>e>>>n|t<<32-n,Ot=(e,t,n)=>e<<32-n|t>>>n,se=(e,t,n)=>e<<64-n|t>>>n-32,ce=(e,t,n)=>e>>>n-32|t<<64-n;function ot(e,t,n,r){let o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}var Qn=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),tr=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,er=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),nr=(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,rr=(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0),or=(e,t,n,r,o,i)=>t+n+r+o+i+(e/2**32|0)|0;var Xo=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),bt=new Uint32Array(64),je=class extends ie{constructor(t=32){super(64,t,8,!1),this.A=dt[0]|0,this.B=dt[1]|0,this.C=dt[2]|0,this.D=dt[3]|0,this.E=dt[4]|0,this.F=dt[5]|0,this.G=dt[6]|0,this.H=dt[7]|0}get(){let{A:t,B:n,C:r,D:o,E:i,F:s,G:a,H:c}=this;return[t,n,r,o,i,s,a,c]}set(t,n,r,o,i,s,a,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,n){for(let d=0;d<16;d++,n+=4)bt[d]=t.getUint32(n,!1);for(let d=16;d<64;d++){let l=bt[d-15],g=bt[d-2],y=tt(l,7)^tt(l,18)^l>>>3,x=tt(g,17)^tt(g,19)^g>>>10;bt[d]=x+bt[d-7]+y+bt[d-16]|0}let{A:r,B:o,C:i,D:s,E:a,F:c,G:u,H:h}=this;for(let d=0;d<64;d++){let l=tt(a,6)^tt(a,11)^tt(a,25),g=h+l+jn(a,c,u)+Xo[d]+bt[d]|0,x=(tt(r,2)^tt(r,13)^tt(r,22))+Zn(r,o,i)|0;h=u,u=c,c=a,a=s+g|0,s=i,i=o,o=r,r=g+x|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,h=h+this.H|0,this.set(r,o,i,s,a,c,u,h)}roundClean(){Q(bt)}destroy(){this.set(0,0,0,0,0,0,0,0),Q(this.buffer)}};var ir=Jn(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Vo=ir[0],Wo=ir[1],wt=new Uint32Array(80),Et=new Uint32Array(80),Ze=class extends ie{constructor(t=64){super(128,t,16,!1),this.Ah=U[0]|0,this.Al=U[1]|0,this.Bh=U[2]|0,this.Bl=U[3]|0,this.Ch=U[4]|0,this.Cl=U[5]|0,this.Dh=U[6]|0,this.Dl=U[7]|0,this.Eh=U[8]|0,this.El=U[9]|0,this.Fh=U[10]|0,this.Fl=U[11]|0,this.Gh=U[12]|0,this.Gl=U[13]|0,this.Hh=U[14]|0,this.Hl=U[15]|0}get(){let{Ah:t,Al:n,Bh:r,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:u,El:h,Fh:d,Fl:l,Gh:g,Gl:y,Hh:x,Hl:f}=this;return[t,n,r,o,i,s,a,c,u,h,d,l,g,y,x,f]}set(t,n,r,o,i,s,a,c,u,h,d,l,g,y,x,f){this.Ah=t|0,this.Al=n|0,this.Bh=r|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=h|0,this.Fh=d|0,this.Fl=l|0,this.Gh=g|0,this.Gl=y|0,this.Hh=x|0,this.Hl=f|0}process(t,n){for(let m=0;m<16;m++,n+=4)wt[m]=t.getUint32(n),Et[m]=t.getUint32(n+=4);for(let m=16;m<80;m++){let E=wt[m-15]|0,_=Et[m-15]|0,R=Ct(E,_,1)^Ct(E,_,8)^Ye(E,_,7),B=Ot(E,_,1)^Ot(E,_,8)^Ge(E,_,7),k=wt[m-2]|0,w=Et[m-2]|0,v=Ct(k,w,19)^se(k,w,61)^Ye(k,w,6),S=Ot(k,w,19)^ce(k,w,61)^Ge(k,w,6),$=er(B,S,Et[m-7],Et[m-16]),T=nr($,R,v,wt[m-7],wt[m-16]);wt[m]=T|0,Et[m]=$|0}let{Ah:r,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:u,Dl:h,Eh:d,El:l,Fh:g,Fl:y,Gh:x,Gl:f,Hh:p,Hl:b}=this;for(let m=0;m<80;m++){let E=Ct(d,l,14)^Ct(d,l,18)^se(d,l,41),_=Ot(d,l,14)^Ot(d,l,18)^ce(d,l,41),R=d&g^~d&x,B=l&y^~l&f,k=rr(b,_,B,Wo[m],Et[m]),w=or(k,p,E,R,Vo[m],wt[m]),v=k|0,S=Ct(r,o,28)^se(r,o,34)^se(r,o,39),$=Ot(r,o,28)^ce(r,o,34)^ce(r,o,39),T=r&i^r&a^i&a,I=o&s^o&c^s&c;p=x|0,b=f|0,x=g|0,f=y|0,g=d|0,y=l|0,{h:d,l}=ot(u|0,h|0,w|0,v|0),u=a|0,h=c|0,a=i|0,c=s|0,i=r|0,s=o|0;let D=Qn(v,$,I);r=tr(D,w,S,T),o=D|0}({h:r,l:o}=ot(this.Ah|0,this.Al|0,r|0,o|0)),{h:i,l:s}=ot(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=ot(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l:h}=ot(this.Dh|0,this.Dl|0,u|0,h|0),{h:d,l}=ot(this.Eh|0,this.El|0,d|0,l|0),{h:g,l:y}=ot(this.Fh|0,this.Fl|0,g|0,y|0),{h:x,l:f}=ot(this.Gh|0,this.Gl|0,x|0,f|0),{h:p,l:b}=ot(this.Hh|0,this.Hl|0,p|0,b|0),this.set(r,o,i,s,a,c,u,h,d,l,g,y,x,f,p,b)}roundClean(){Q(wt,Et)}destroy(){Q(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var ze=Ve(()=>new je);var it=Ve(()=>new Ze);var tn=BigInt(0),Qe=BigInt(1);function Ae(e,t=""){if(typeof e!="boolean"){let n=t&&`"${t}"`;throw new Error(n+"expected boolean, got type="+typeof e)}return e}function ae(e,t,n=""){let r=Mt(e),o=e?.length,i=t!==void 0;if(!r||i&&o!==t){let s=n&&`"${n}" `,a=i?` of length ${t}`:"",c=r?`length=${o}`:`type=${typeof e}`;throw new Error(s+"expected Uint8Array"+a+", got "+c)}return e}function sr(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?tn:BigInt("0x"+e)}function cr(e){return sr(Nt(e))}function vt(e){return Y(e),sr(Nt(Uint8Array.from(e).reverse()))}function en(e,t){return Ee(e.toString(16).padStart(t*2,"0"))}function ar(e,t){return en(e,t).reverse()}function J(e,t,n){let r;if(typeof t=="string")try{r=Ee(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(Mt(t))r=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");let o=r.length;if(typeof n=="number"&&o!==n)throw new Error(e+" of length "+n+" expected, got "+o);return r}function ur(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function nn(e){return Uint8Array.from(e)}var Je=e=>typeof e=="bigint"&&tn<=e;function Yo(e,t,n){return Je(e)&&Je(t)&&Je(n)&&t<=e&&e<n}function rn(e,t,n,r){if(!Yo(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function lr(e){let t;for(t=0;e>tn;e>>=Qe,t+=1);return t}var ue=e=>(Qe<<BigInt(e))-Qe;function le(e,t,n={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function r(o,i,s){let a=e[o];if(s&&a===void 0)return;let c=typeof a;if(c!==i||a===null)throw new Error(`param "${o}" is invalid: expected ${i}, got ${c}`)}Object.entries(t).forEach(([o,i])=>r(o,i,!1)),Object.entries(n).forEach(([o,i])=>r(o,i,!0))}var on=()=>{throw new Error("not implemented")};function sn(e){let t=new WeakMap;return(n,...r)=>{let o=t.get(n);if(o!==void 0)return o;let i=e(n,...r);return t.set(n,i),i}}var X=BigInt(0),H=BigInt(1),Pt=BigInt(2),hr=BigInt(3),pr=BigInt(4),mr=BigInt(5),Go=BigInt(7),gr=BigInt(8),jo=BigInt(9),yr=BigInt(16);function M(e,t){let n=e%t;return n>=X?n:t+n}function nt(e,t,n){let r=e;for(;t-- >X;)r*=r,r%=n;return r}function dr(e,t){if(e===X)throw new Error("invert: expected non-zero number");if(t<=X)throw new Error("invert: expected positive modulus, got "+t);let n=M(e,t),r=t,o=X,i=H,s=H,a=X;for(;n!==X;){let u=r/n,h=r%n,d=o-s*u,l=i-a*u;r=n,n=h,o=s,i=a,s=d,a=l}if(r!==H)throw new Error("invert: does not exist");return M(o,t)}function cn(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function xr(e,t){let n=(e.ORDER+H)/pr,r=e.pow(t,n);return cn(e,r,t),r}function Zo(e,t){let n=(e.ORDER-mr)/gr,r=e.mul(t,Pt),o=e.pow(r,n),i=e.mul(t,o),s=e.mul(e.mul(i,Pt),o),a=e.mul(i,e.sub(s,e.ONE));return cn(e,a,t),a}function zo(e){let t=ht(e),n=br(e),r=n(t,t.neg(t.ONE)),o=n(t,r),i=n(t,t.neg(r)),s=(e+Go)/yr;return(a,c)=>{let u=a.pow(c,s),h=a.mul(u,r),d=a.mul(u,o),l=a.mul(u,i),g=a.eql(a.sqr(h),c),y=a.eql(a.sqr(d),c);u=a.cmov(u,h,g),h=a.cmov(l,d,y);let x=a.eql(a.sqr(h),c),f=a.cmov(u,h,x);return cn(a,f,c),f}}function br(e){if(e<hr)throw new Error("sqrt is not defined for small field");let t=e-H,n=0;for(;t%Pt===X;)t/=Pt,n++;let r=Pt,o=ht(e);for(;fr(o,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return xr;let i=o.pow(r,t),s=(t+H)/Pt;return function(c,u){if(c.is0(u))return u;if(fr(c,u)!==1)throw new Error("Cannot find square root");let h=n,d=c.mul(c.ONE,i),l=c.pow(u,t),g=c.pow(u,s);for(;!c.eql(l,c.ONE);){if(c.is0(l))return c.ZERO;let y=1,x=c.sqr(l);for(;!c.eql(x,c.ONE);)if(y++,x=c.sqr(x),y===h)throw new Error("Cannot find square root");let f=H<<BigInt(h-y-1),p=c.pow(d,f);h=y,d=c.sqr(p),l=c.mul(l,d),g=c.mul(g,p)}return g}}function Jo(e){return e%pr===hr?xr:e%gr===mr?Zo:e%yr===jo?zo(e):br(e)}var ft=(e,t)=>(M(e,t)&H)===H,Qo=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function wr(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},n=Qo.reduce((r,o)=>(r[o]="function",r),t);return le(e,n),e}function ti(e,t,n){if(n<X)throw new Error("invalid exponent, negatives unsupported");if(n===X)return e.ONE;if(n===H)return t;let r=e.ONE,o=t;for(;n>X;)n&H&&(r=e.mul(r,o)),o=e.sqr(o),n>>=H;return r}function Se(e,t,n=!1){let r=new Array(t.length).fill(n?e.ZERO:void 0),o=t.reduce((s,a,c)=>e.is0(a)?s:(r[c]=s,e.mul(s,a)),e.ONE),i=e.inv(o);return t.reduceRight((s,a,c)=>e.is0(a)?s:(r[c]=e.mul(s,r[c]),e.mul(s,a)),i),r}function fr(e,t){let n=(e.ORDER-H)/Pt,r=e.pow(t,n),o=e.eql(r,e.ONE),i=e.eql(r,e.ZERO),s=e.eql(r,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function Er(e,t){t!==void 0&&Bt(t);let n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function ht(e,t,n=!1,r={}){if(e<=X)throw new Error("invalid field: expected ORDER > 0, got "+e);let o,i,s=!1,a;if(typeof t=="object"&&t!=null){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");let l=t;l.BITS&&(o=l.BITS),l.sqrt&&(i=l.sqrt),typeof l.isLE=="boolean"&&(n=l.isLE),typeof l.modFromBytes=="boolean"&&(s=l.modFromBytes),a=l.allowedLengths}else typeof t=="number"&&(o=t),r.sqrt&&(i=r.sqrt);let{nBitLength:c,nByteLength:u}=Er(e,o);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let h,d=Object.freeze({ORDER:e,isLE:n,BITS:c,BYTES:u,MASK:ue(c),ZERO:X,ONE:H,allowedLengths:a,create:l=>M(l,e),isValid:l=>{if(typeof l!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof l);return X<=l&&l<e},is0:l=>l===X,isValidNot0:l=>!d.is0(l)&&d.isValid(l),isOdd:l=>(l&H)===H,neg:l=>M(-l,e),eql:(l,g)=>l===g,sqr:l=>M(l*l,e),add:(l,g)=>M(l+g,e),sub:(l,g)=>M(l-g,e),mul:(l,g)=>M(l*g,e),pow:(l,g)=>ti(d,l,g),div:(l,g)=>M(l*dr(g,e),e),sqrN:l=>l*l,addN:(l,g)=>l+g,subN:(l,g)=>l-g,mulN:(l,g)=>l*g,inv:l=>dr(l,e),sqrt:i||(l=>(h||(h=Jo(e)),h(d,l))),toBytes:l=>n?ar(l,u):en(l,u),fromBytes:(l,g=!0)=>{if(a){if(!a.includes(l.length)||l.length>u)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+l.length);let x=new Uint8Array(u);x.set(l,n?0:x.length-l.length),l=x}if(l.length!==u)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+l.length);let y=n?vt(l):cr(l);if(s&&(y=M(y,e)),!g&&!d.isValid(y))throw new Error("invalid field element: outside of range 0..ORDER");return y},invertBatch:l=>Se(d,l),cmov:(l,g,y)=>y?g:l});return Object.freeze(d)}var _e=BigInt(0),dn=BigInt(1);function vr(e,t){let n=t.negate();return e?n:t}function de(e,t){let n=Se(e.Fp,t.map(r=>r.Z));return t.map((r,o)=>e.fromAffine(r.toAffine(n[o])))}function kr(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function an(e,t){kr(e,t);let n=Math.ceil(t/e)+1,r=2**(e-1),o=2**e,i=ue(e),s=BigInt(e);return{windows:n,windowSize:r,mask:i,maxNumber:o,shiftBy:s}}function Ar(e,t,n){let{windowSize:r,mask:o,maxNumber:i,shiftBy:s}=n,a=Number(e&o),c=e>>s;a>r&&(a-=i,c+=dn);let u=t*r,h=u+Math.abs(a)-1,d=a===0,l=a<0,g=t%2!==0;return{nextN:c,offset:h,isZero:d,isNeg:l,isNegF:g,offsetF:u}}function ei(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((n,r)=>{if(!(n instanceof t))throw new Error("invalid point at index "+r)})}function ni(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,r)=>{if(!t.isValid(n))throw new Error("invalid scalar at index "+r)})}var un=new WeakMap,$r=new WeakMap;function ln(e){return $r.get(e)||1}function Sr(e){if(e!==_e)throw new Error("invalid wNAF")}var ke=class{constructor(t,n){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=n}_unsafeLadder(t,n,r=this.ZERO){let o=t;for(;n>_e;)n&dn&&(r=r.add(o)),o=o.double(),n>>=dn;return r}precomputeWindow(t,n){let{windows:r,windowSize:o}=an(n,this.bits),i=[],s=t,a=s;for(let c=0;c<r;c++){a=s,i.push(a);for(let u=1;u<o;u++)a=a.add(s),i.push(a);s=a.double()}return i}wNAF(t,n,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=an(t,this.bits);for(let a=0;a<s.windows;a++){let{nextN:c,offset:u,isZero:h,isNeg:d,isNegF:l,offsetF:g}=Ar(r,a,s);r=c,h?i=i.add(vr(l,n[g])):o=o.add(vr(d,n[u]))}return Sr(r),{p:o,f:i}}wNAFUnsafe(t,n,r,o=this.ZERO){let i=an(t,this.bits);for(let s=0;s<i.windows&&r!==_e;s++){let{nextN:a,offset:c,isZero:u,isNeg:h}=Ar(r,s,i);if(r=a,!u){let d=n[c];o=o.add(h?d.negate():d)}}return Sr(r),o}getPrecomputes(t,n,r){let o=un.get(n);return o||(o=this.precomputeWindow(n,t),t!==1&&(typeof r=="function"&&(o=r(o)),un.set(n,o))),o}cached(t,n,r){let o=ln(t);return this.wNAF(o,this.getPrecomputes(o,t,r),n)}unsafe(t,n,r,o){let i=ln(t);return i===1?this._unsafeLadder(t,n,o):this.wNAFUnsafe(i,this.getPrecomputes(i,t,r),n,o)}createCache(t,n){kr(n,this.bits),$r.set(t,n),un.delete(t)}hasCache(t){return ln(t)!==1}};function $e(e,t,n,r){ei(n,e),ni(r,t);let o=n.length,i=r.length;if(o!==i)throw new Error("arrays of points and scalars must have equal length");let s=e.ZERO,a=lr(BigInt(o)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let u=ue(c),h=new Array(Number(u)+1).fill(s),d=Math.floor((t.BITS-1)/c)*c,l=s;for(let g=d;g>=0;g-=c){h.fill(s);for(let x=0;x<i;x++){let f=r[x],p=Number(f>>BigInt(g)&u);h[p]=h[p].add(n[x])}let y=s;for(let x=h.length-1,f=s;x>0;x--)f=f.add(h[x]),y=y.add(f);if(l=l.add(y),g!==0)for(let x=0;x<c;x++)l=l.double()}return l}function _r(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return wr(t),t}else return ht(e,{isLE:n})}function Ir(e,t,n={},r){if(r===void 0&&(r=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let u=t[c];if(!(typeof u=="bigint"&&u>_e))throw new Error(`CURVE.${c} must be positive bigint`)}let o=_r(t.p,n.Fp,r),i=_r(t.n,n.Fn,r),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:i}}var At=BigInt(0),L=BigInt(1),fn=BigInt(2),ri=BigInt(8);function oi(e,t,n,r){let o=e.sqr(n),i=e.sqr(r),s=e.add(e.mul(t.a,o),i),a=e.add(e.ONE,e.mul(t.d,e.mul(o,i)));return e.eql(s,a)}function ii(e,t={}){let n=Ir("edwards",e,t,t.FpFnLE),{Fp:r,Fn:o}=n,i=n.CURVE,{h:s}=i;le(t,{},{uvRatio:"function"});let a=fn<<BigInt(o.BYTES*8)-L,c=f=>r.create(f),u=t.uvRatio||((f,p)=>{try{return{isValid:!0,value:r.sqrt(r.div(f,p))}}catch{return{isValid:!1,value:At}}});if(!oi(r,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function h(f,p,b=!1){let m=b?L:At;return rn("coordinate "+f,p,m,a),p}function d(f){if(!(f instanceof y))throw new Error("ExtendedPoint expected")}let l=sn((f,p)=>{let{X:b,Y:m,Z:E}=f,_=f.is0();p==null&&(p=_?ri:r.inv(E));let R=c(b*p),B=c(m*p),k=r.mul(E,p);if(_)return{x:At,y:L};if(k!==L)throw new Error("invZ was invalid");return{x:R,y:B}}),g=sn(f=>{let{a:p,d:b}=i;if(f.is0())throw new Error("bad point: ZERO");let{X:m,Y:E,Z:_,T:R}=f,B=c(m*m),k=c(E*E),w=c(_*_),v=c(w*w),S=c(B*p),$=c(w*c(S+k)),T=c(v+c(b*c(B*k)));if($!==T)throw new Error("bad point: equation left != right (1)");let I=c(m*E),D=c(_*R);if(I!==D)throw new Error("bad point: equation left != right (2)");return!0});class y{constructor(p,b,m,E){this.X=h("x",p),this.Y=h("y",b),this.Z=h("z",m,!0),this.T=h("t",E),Object.freeze(this)}static CURVE(){return i}static fromAffine(p){if(p instanceof y)throw new Error("extended point not allowed");let{x:b,y:m}=p||{};return h("x",b),h("y",m),new y(b,m,L,c(b*m))}static fromBytes(p,b=!1){let m=r.BYTES,{a:E,d:_}=i;p=nn(ae(p,m,"point")),Ae(b,"zip215");let R=nn(p),B=p[m-1];R[m-1]=B&-129;let k=vt(R),w=b?a:r.ORDER;rn("point.y",k,At,w);let v=c(k*k),S=c(v-L),$=c(_*v-E),{isValid:T,value:I}=u(S,$);if(!T)throw new Error("bad point: invalid y coordinate");let D=(I&L)===L,z=(B&128)!==0;if(!b&&I===At&&z)throw new Error("bad point: x=0 and x_0=1");return z!==D&&(I=c(-I)),y.fromAffine({x:I,y:k})}static fromHex(p,b=!1){return y.fromBytes(J("point",p),b)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(p=8,b=!0){return x.createCache(this,p),b||this.multiply(fn),this}assertValidity(){g(this)}equals(p){d(p);let{X:b,Y:m,Z:E}=this,{X:_,Y:R,Z:B}=p,k=c(b*B),w=c(_*E),v=c(m*B),S=c(R*E);return k===w&&v===S}is0(){return this.equals(y.ZERO)}negate(){return new y(c(-this.X),this.Y,this.Z,c(-this.T))}double(){let{a:p}=i,{X:b,Y:m,Z:E}=this,_=c(b*b),R=c(m*m),B=c(fn*c(E*E)),k=c(p*_),w=b+m,v=c(c(w*w)-_-R),S=k+R,$=S-B,T=k-R,I=c(v*$),D=c(S*T),z=c(v*T),yt=c($*S);return new y(I,D,yt,z)}add(p){d(p);let{a:b,d:m}=i,{X:E,Y:_,Z:R,T:B}=this,{X:k,Y:w,Z:v,T:S}=p,$=c(E*k),T=c(_*w),I=c(B*m*S),D=c(R*v),z=c((E+_)*(k+w)-$-T),yt=D-I,Tt=D+I,at=c(T-b*$),re=c(z*yt),be=c(Tt*at),Xe=c(z*at),Vn=c(yt*Tt);return new y(re,be,Vn,Xe)}subtract(p){return this.add(p.negate())}multiply(p){if(!o.isValidNot0(p))throw new Error("invalid scalar: expected 1 <= sc < curve.n");let{p:b,f:m}=x.cached(this,p,E=>de(y,E));return de(y,[b,m])[0]}multiplyUnsafe(p,b=y.ZERO){if(!o.isValid(p))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return p===At?y.ZERO:this.is0()||p===L?this:x.unsafe(this,p,m=>de(y,m),b)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return x.unsafe(this,i.n).is0()}toAffine(p){return l(this,p)}clearCofactor(){return s===L?this:this.multiplyUnsafe(s)}toBytes(){let{x:p,y:b}=this.toAffine(),m=r.toBytes(b);return m[m.length-1]|=p&L?128:0,m}toHex(){return Nt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(p){return de(y,p)}static msm(p,b){return $e(y,o,p,b)}_setWindowSize(p){this.precompute(p)}toRawBytes(){return this.toBytes()}}y.BASE=new y(i.Gx,i.Gy,L,c(i.Gx*i.Gy)),y.ZERO=new y(At,L,L,At),y.Fp=r,y.Fn=o;let x=new ke(y,o.BITS);return y.BASE.precompute(8),y}var Ie=class{constructor(t){this.ep=t}static fromBytes(t){on()}static fromHex(t){on()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(t){return this.ep.toAffine(t)}toHex(){return Nt(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(t){return this.assertSame(t),this.init(this.ep.add(t.ep))}subtract(t){return this.assertSame(t),this.init(this.ep.subtract(t.ep))}multiply(t){return this.init(this.ep.multiply(t))}multiplyUnsafe(t){return this.init(this.ep.multiplyUnsafe(t))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(t,n){return this.init(this.ep.precompute(t,n))}toRawBytes(){return this.toBytes()}};function si(e,t,n={}){if(typeof t!="function")throw new Error('"hash" function param is required');le(n,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:r}=n,{BASE:o,Fp:i,Fn:s}=e,a=n.randomBytes||We,c=n.adjustScalarBytes||(w=>w),u=n.domain||((w,v,S)=>{if(Ae(S,"phflag"),v.length||S)throw new Error("Contexts/pre-hash are not supported");return w});function h(w){return s.create(vt(w))}function d(w){let v=m.secretKey;w=J("private key",w,v);let S=J("hashed private key",t(w),2*v),$=c(S.slice(0,v)),T=S.slice(v,2*v),I=h($);return{head:$,prefix:T,scalar:I}}function l(w){let{head:v,prefix:S,scalar:$}=d(w),T=o.multiply($),I=T.toBytes();return{head:v,prefix:S,scalar:$,point:T,pointBytes:I}}function g(w){return l(w).pointBytes}function y(w=Uint8Array.of(),...v){let S=G(...v);return h(t(u(S,J("context",w),!!r)))}function x(w,v,S={}){w=J("message",w),r&&(w=r(w));let{prefix:$,scalar:T,pointBytes:I}=l(v),D=y(S.context,$,w),z=o.multiply(D).toBytes(),yt=y(S.context,z,I,w),Tt=s.create(D+yt*T);if(!s.isValid(Tt))throw new Error("sign failed: invalid s");let at=G(z,s.toBytes(Tt));return ae(at,m.signature,"result")}let f={zip215:!0};function p(w,v,S,$=f){let{context:T,zip215:I}=$,D=m.signature;w=J("signature",w,D),v=J("message",v),S=J("publicKey",S,m.publicKey),I!==void 0&&Ae(I,"zip215"),r&&(v=r(v));let z=D/2,yt=w.subarray(0,z),Tt=vt(w.subarray(z,D)),at,re,be;try{at=e.fromBytes(S,I),re=e.fromBytes(yt,I),be=o.multiplyUnsafe(Tt)}catch{return!1}if(!I&&at.isSmallOrder())return!1;let Xe=y(T,re.toBytes(),at.toBytes(),v);return re.add(at.multiplyUnsafe(Xe)).subtract(be).clearCofactor().is0()}let b=i.BYTES,m={secretKey:b,publicKey:b,signature:2*b,seed:b};function E(w=a(m.seed)){return ae(w,m.seed,"seed")}function _(w){let v=k.randomSecretKey(w);return{secretKey:v,publicKey:g(v)}}function R(w){return Mt(w)&&w.length===s.BYTES}function B(w,v){try{return!!e.fromBytes(w,v)}catch{return!1}}let k={getExtendedPublicKey:l,randomSecretKey:E,isValidSecretKey:R,isValidPublicKey:B,toMontgomery(w){let{y:v}=e.fromBytes(w),S=m.publicKey,$=S===32;if(!$&&S!==57)throw new Error("only defined for 25519 and 448");let T=$?i.div(L+v,L-v):i.div(v-L,v+L);return i.toBytes(T)},toMontgomerySecret(w){let v=m.secretKey;ae(w,v);let S=t(w.subarray(0,v));return c(S).subarray(0,v)},randomPrivateKey:E,precompute(w=8,v=e.BASE){return v.precompute(w,!1)}};return Object.freeze({keygen:_,getPublicKey:g,sign:x,verify:p,utils:k,Point:e,lengths:m})}function ci(e){let t={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp,r=ht(t.n,e.nBitLength,!0),o={Fp:n,Fn:r,uvRatio:e.uvRatio},i={randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve};return{CURVE:t,curveOpts:o,hash:e.hash,eddsaOpts:i}}function ai(e,t){let n=t.Point;return Object.assign({},t,{ExtendedPoint:n,CURVE:e,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}function Tr(e){let{CURVE:t,curveOpts:n,hash:r,eddsaOpts:o}=ci(e),i=ii(t,n),s=si(i,r,o);return ai(e,s)}var ui=BigInt(0),pt=BigInt(1),Rr=BigInt(2),Lc=BigInt(3),li=BigInt(5),di=BigInt(8),zt=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),fe={p:zt,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:di,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function fi(e){let t=BigInt(10),n=BigInt(20),r=BigInt(40),o=BigInt(80),i=zt,a=e*e%i*e%i,c=nt(a,Rr,i)*a%i,u=nt(c,pt,i)*e%i,h=nt(u,li,i)*u%i,d=nt(h,t,i)*h%i,l=nt(d,n,i)*d%i,g=nt(l,r,i)*l%i,y=nt(g,o,i)*g%i,x=nt(y,o,i)*g%i,f=nt(x,t,i)*h%i;return{pow_p_5_8:nt(f,Rr,i)*e%i,b2:a}}function hi(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var hn=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function gn(e,t){let n=zt,r=M(t*t*t,n),o=M(r*r*t,n),i=fi(e*o).pow_p_5_8,s=M(e*r*i,n),a=M(t*s*s,n),c=s,u=M(s*hn,n),h=a===e,d=a===M(-e,n),l=a===M(-e*hn,n);return h&&(s=c),(d||l)&&(s=u),ft(s,n)&&(s=M(-s,n)),{isValid:h||d,value:s}}var St=ht(fe.p,{isLE:!0}),pi=ht(fe.n,{isLE:!0}),mi={...fe,Fp:St,hash:it,adjustScalarBytes:hi,uvRatio:gn},Dt=Tr(mi);var pn=hn,gi=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),yi=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),xi=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),bi=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Br=e=>gn(pt,e),wi=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),mn=e=>Dt.Point.Fp.create(vt(e)&wi);function Mr(e){let{d:t}=fe,n=zt,r=p=>St.create(p),o=r(pn*e*e),i=r((o+pt)*xi),s=BigInt(-1),a=r((s-t*o)*r(o+t)),{isValid:c,value:u}=gn(i,a),h=r(u*e);ft(h,n)||(h=r(-h)),c||(u=h),c||(s=o);let d=r(s*(o-pt)*bi-a),l=u*u,g=r((u+u)*a),y=r(d*gi),x=r(pt-l),f=r(pt+l);return new Dt.Point(r(g*f),r(x*y),r(y*f),r(g*x))}function Ei(e){Y(e,64);let t=mn(e.subarray(0,32)),n=Mr(t),r=mn(e.subarray(32,64)),o=Mr(r);return new st(n.add(o))}var st=class e extends Ie{constructor(t){super(t)}static fromAffine(t){return new e(Dt.Point.fromAffine(t))}assertSame(t){if(!(t instanceof e))throw new Error("RistrettoPoint expected")}init(t){return new e(t)}static hashToCurve(t){return Ei(J("ristrettoHash",t,64))}static fromBytes(t){Y(t,32);let{a:n,d:r}=fe,o=zt,i=E=>St.create(E),s=mn(t);if(!ur(St.toBytes(s),t)||ft(s,o))throw new Error("invalid ristretto255 encoding 1");let a=i(s*s),c=i(pt+n*a),u=i(pt-n*a),h=i(c*c),d=i(u*u),l=i(n*r*h-d),{isValid:g,value:y}=Br(i(l*d)),x=i(y*u),f=i(y*x*l),p=i((s+s)*x);ft(p,o)&&(p=i(-p));let b=i(c*f),m=i(p*b);if(!g||ft(m,o)||b===ui)throw new Error("invalid ristretto255 encoding 2");return new e(new Dt.Point(p,b,pt,m))}static fromHex(t){return e.fromBytes(J("ristrettoHex",t,32))}static msm(t,n){return $e(e,Dt.Point.Fn,t,n)}toBytes(){let{X:t,Y:n,Z:r,T:o}=this.ep,i=zt,s=f=>St.create(f),a=s(s(r+n)*s(r-n)),c=s(t*n),u=s(c*c),{value:h}=Br(s(a*u)),d=s(h*a),l=s(h*c),g=s(d*l*o),y;if(ft(o*g,i)){let f=s(n*pn),p=s(t*pn);t=f,n=p,y=s(d*yi)}else y=l;ft(t*g,i)&&(n=s(-n));let x=s((r-n)*y);return ft(x,i)&&(x=s(-x)),St.toBytes(x)}equals(t){this.assertSame(t);let{X:n,Y:r}=this.ep,{X:o,Y:i}=t.ep,s=u=>St.create(u),a=s(n*i)===s(r*o),c=s(r*i)===s(n*o);return a||c}is0(){return this.equals(e.ZERO)}};st.BASE=new st(Dt.Point.BASE);st.ZERO=new st(Dt.Point.ZERO);st.Fp=St;st.Fn=pi;var Te={Point:st};var Re=class extends jt{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,oe(t);let r=xt(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(r.length>o?t.create().update(r).digest():r);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),Q(i)}update(t){return Zt(this),this.iHash.update(t),this}digestInto(t){Zt(this),Y(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:n,iHash:r,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=a,t.oHash=n._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},_t=(e,t,n)=>new Re(e,t).update(n).digest();_t.create=(e,t)=>new Re(e,t);function vi(e,t,n){return oe(e),n===void 0&&(n=new Uint8Array(e.outputLen)),_t(e,xt(n),xt(t))}var yn=Uint8Array.from([0]),Nr=Uint8Array.of();function Ai(e,t,n,r=32){oe(e),Bt(r);let o=e.outputLen;if(r>255*o)throw new Error("Length should be <= 255*HashLen");let i=Math.ceil(r/o);n===void 0&&(n=Nr);let s=new Uint8Array(i*o),a=_t.create(e,t),c=a._cloneInto(),u=new Uint8Array(a.outputLen);for(let h=0;h<i;h++)yn[0]=h+1,c.update(h===0?Nr:u).update(n).update(yn).digestInto(u),s.set(u,o*h),a._cloneInto(c);return a.destroy(),c.destroy(),Q(u,yn),s.slice(0,r)}var xn=(e,t,n,r,o)=>Ai(e,vi(e,t,n),r,o);var Gc=2*1024*1024;var jc=4*1024*1024,Zc=256*1024;var j=e=>et(e),he="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function Si(e){let t="";for(let n=0;n<e.length;n+=3){let r=e[n]<<16|(e[n+1]??0)<<8|(e[n+2]??0);t+=he[r>>18&63]+he[r>>12&63],n+1<e.length&&(t+=he[r>>6&63]),n+2<e.length&&(t+=he[r&63])}return t}function Cr(e){if(e.length%4===1)throw new Error("Invalid base64url");let t=new Uint8Array(Math.floor(e.length*6/8)),n=0,r=0,o=0;for(let i=0;i<e.length;i++){let s=he.indexOf(e[i]);if(s<0)throw new Error("Invalid base64url");n=(n<<6|s)&65535,r+=6,r>=8&&(r-=8,t[o++]=n>>r&255)}if(n&(1<<r)-1)throw new Error("Invalid base64url");return t}function Or(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}var En=Te.Point,bn=j("CPaceRistretto255"),_i=128,Dr=new Uint8Array(32);function wn(e){let t=[],n=e.length;do t.push(n<128?n:n&127|128),n>>>=7;while(n>0);return G(Uint8Array.from(t),e)}var Lt=(...e)=>G(...e.map(wn));function ki(e,t,n){let r=Math.max(0,_i-1-wn(e).length-wn(bn).length);return Lt(bn,e,new Uint8Array(r),t,n)}function $i(e,t,n){return En.hashToCurve(it(ki(e,t,n)))}function Ii(e){for(;;){let t=e(32);t[31]=t[31]&15;let n=En.Fn.fromBytes(t);if(t.fill(0),n!==0n)return n}}var Ti=(e,t)=>t.multiply(e).toBytes();function Ri(e,t){let n;try{n=En.fromBytes(t)}catch{return Dr}return n.multiply(e).toBytes()}var Bi=(e,t,n,r)=>G(Lt(e,t),Lt(n,r));function Mi(e,t,n,r,o,i){return it(G(Lt(G(bn,j("_ISK")),e,t),Bi(n,r,o,i)))}function Ni(e,t,n,r){let o=it(G(j("CPaceMac"),e,t)),i=_t(it,o,Lt(n,r));return o.fill(0),i}var ia=j("device"),Pr=j("computer");var Ci="evryai-machine/v1",Oi=j("machine");function Pi(e,t){return{prs:Lt(j(e.secret)),ci:Lt(j(Ci),j(e.routingId),j("initiator:machine"),j("responder:computer")),sid:j(t)}}function Di(e){let t=xn(it,e,void 0,j("evryai machine check code"),4),n=((t[0]<<24>>>0)+(t[1]<<16)+(t[2]<<8)+t[3])%1e6,r=String(n).padStart(6,"0");return`${r.slice(0,3)} ${r.slice(3)}`}function Lr(e,t,n){let{prs:r,ci:o,sid:i}=Pi(e,t),s=Ii(n),a=Ti(s,$i(r,o,i));return r.fill(0),{linkId:t,boxKey:Si(a),finish({hostKey:c,confirmation:u}){let h=new Error("Couldn't verify your computer."),d,l;try{d=Cr(c),l=Cr(u)}catch{throw h}let g=Ri(s,d);if(Or(g,Dr))throw h;let y=Mi(i,g,a,Oi,d,Pr);g.fill(0);let x=Or(Ni(i,y,d,Pr),l),f=xn(it,y,void 0,j("evryai machine link key"),32),p=Di(y);if(y.fill(0),!x)throw f.fill(0),h;return{key:f,checkCode:p}}}}var Li=/^([23456789A-HJ-NP-Z]{8})\.([A-Za-z0-9_-]{22})$/;function Ur(e){let t=e.trim(),n=t.indexOf(".");if(n<0)return null;let r=Li.exec(`${t.slice(0,n).toUpperCase()}${t.slice(n)}`);return r?{routingId:r[1],secret:r[2]}:null}var Z="1.0.1";var Hr=e=>`/connector/connector-${e}.mjs`,vn="~/.evryai/connector/bin/evryai-connect",ca=`${vn} run`,aa=`${vn} update`,An=`${vn} remove --all`,pe="evryai-connector",Ut="com.evryai.connector",Be="EvryAI connector";import{createCipheriv as Fi,createDecipheriv as Ki,createHmac as Xi,hkdfSync as Vi,randomBytes as Ma,timingSafeEqual as Wi}from"crypto";import{randomBytes as ya,randomInt as xa,timingSafeEqual as Hi}from"crypto";var qr=/^rl_[A-Za-z0-9_-]{22}$/;var Fr=/^[A-Za-z0-9_-]{8,64}$/;var Kr="x-evry-remote-machine";var Ui="~/.evryai/connector/bin/evryai-connect",la=`${Ui} update`;var qi=e=>Buffer.from(e).toString("base64url"),Sa=Te.Point,_a=et("CPaceRistretto255");var ka=new Uint8Array(32);var $a=et("device"),Ia=et("computer");var Ta=et("machine");function Me(e){return Array.isArray(e)?`[${e.map(t=>t===void 0?"null":Me(t)).join(",")}]`:e&&typeof e=="object"?`{${Object.entries(e).filter(([,n])=>n!==void 0).sort(([n],[r])=>n<r?-1:n>r?1:0).map(([n,r])=>`${JSON.stringify(n)}:${Me(r)}`).join(",")}}`:JSON.stringify(e??null)}function Sn(e,t){return qi(_t(ze,e,et(`${t.linkId}.${t.id}.${t.ts}.${t.body}`)))}function Xr(e,t){let n=Buffer.from(e),r=Buffer.from(t);return n.length===r.length&&Hi(n,r)}var Wr=1;function kn(e,t){let n=i=>/^(\d+)\.(\d+)\.(\d+)$/.exec(i)?.slice(1).map(Number)??null,r=n(e),o=n(t);if(!r||!o)return!1;for(let i=0;i<3;i++)if(r[i]!==o[i])return r[i]<o[i];return!1}var A={READY:1,OPEN:2,OPENED:3,REFUSED:4,DATA:5,ERR:6,EOF:7,CREDIT:8,RESIZE:9,SIGNAL:10,EXIT:11,CLOSE:12,PING:13,PONG:14,CONTROL:15},Yi=new Set(Object.values(A)),Jt=5,_n=16;function Yr(e){let t=Buffer.allocUnsafe(Jt+e.body.length);return t.writeUInt8(e.kind,0),t.writeUInt32BE(e.ch>>>0,1),e.body.copy(t,Jt),t}function Gr(e){if(e.length<Jt)return null;let t=e.readUInt8(0);return Yi.has(t)?{kind:t,ch:e.readUInt32BE(1),body:e.subarray(Jt)}:null}function jr(e,t,n,r){let o=Buffer.from(Vi("sha256",e,Buffer.concat([t,n]),`evryai mx v1 ${r}`,64));return{d2b:o.subarray(0,32),b2d:o.subarray(32,64)}}function Zr(e){let t=Buffer.alloc(12);return t.writeBigUInt64BE(BigInt(e),4),t}var zr=(e,t,n,r)=>Buffer.from(`${e}|${t}|${n}|${r}`,"utf8");function Jr(e,t,n){let r=Fi("aes-256-gcm",e.key,Zr(t));return r.setAAD(zr(e.linkId,e.dir,e.sid,t)),Buffer.concat([r.update(n),r.final(),r.getAuthTag()]).toString("base64url")}function Qr(e,t,n){try{let r=Buffer.from(n,"base64url");if(r.length<_n)return null;let o=Ki("aes-256-gcm",e.key,Zr(t));return o.setAAD(zr(e.linkId,e.dir,e.sid,t)),o.setAuthTag(r.subarray(r.length-_n)),Buffer.concat([o.update(r.subarray(0,r.length-_n)),o.final()])}catch{return null}}function to(e,t){return Xi("sha256",e).update(`evryai-mx/v1|${t.k}|${Me(t)}`,"utf8").digest("base64url")}function eo(e,t){return Buffer.from(JSON.stringify({...t,mac:to(e,t)}),"utf8").toString("base64url")}var Gi=/^[0-9a-f]{32}$/,Vr=/^[A-Za-z0-9_-]{43}$/,mt=(e,t)=>typeof e=="string"&&e.length<=t;function no(e,t){let n;try{n=JSON.parse(Buffer.from(t,"base64url").toString("utf8"))}catch{return null}if(!n||typeof n!="object")return null;let{mac:r,...o}=n;if(typeof r!="string"||!mt(o.sid,32)||!Gi.test(o.sid)||!mt(o.bn,43)||!Vr.test(o.bn))return null;let i;if(o.k==="hello"){let c=o.caps;if(o.v!==1||!mt(o.ver,32)||typeof o.proto!="number"||!c||typeof c!="object"||!mt(c.os,16)||!mt(c.arch,16)||!mt(c.node,32)||!["script","python","none"].includes(c.pty)||c.svc!==void 0&&!["systemd","launchd","cron","schtasks"].includes(c.svc))return null;i={k:"hello",v:1,sid:o.sid,bn:o.bn,ver:o.ver,proto:o.proto,caps:{os:c.os,arch:c.arch,pty:c.pty,node:c.node,...c.svc?{svc:c.svc}:{}}}}else if(o.k==="hello-ack"){if(!mt(o.dn,43)||!Vr.test(o.dn)||typeof o.now!="number"||!mt(o.client,64)||!mt(o.name,128))return null;i={k:"hello-ack",sid:o.sid,bn:o.bn,dn:o.dn,now:o.now,client:o.client,name:o.name}}else return null;let s=Buffer.from(to(e,i)),a=Buffer.from(r);return s.length===a.length&&Wi(s,a)?i:null}function ro(e){let t=Buffer.alloc(4);return t.writeUInt32BE(e>>>0,0),t}function oo(e){let t=Buffer.alloc(8);return t.writeBigUInt64BE(BigInt(Math.max(0,Math.floor(e))),0),t}var io=e=>e.length>=8?Number(e.readBigUInt64BE(0)):0;function Qt(e){return Buffer.from(JSON.stringify(e),"utf8")}var Ji=6e4,Qi=6e4,ts=2e4;function es(e,t=Math.random){return Math.floor(t()*Math.min(Ji,1e3*2**Math.min(e,16)))}function ao(e){let t=Number(e.headers.get("retry-after"));return Number.isFinite(t)&&t>0?t*1e3:void 0}var me=class{o;abort=null;stopped=!0;inFlight=!1;again=!1;timer=null;timerAt=0;keepalive=null;lastSentAt=0;sendBackoffUntil=0;open=!1;idleWaiters=[];constructor(t){this.o=t}get running(){return!this.stopped}get streamOpen(){return this.open}start(){this.stopped&&(this.stopped=!1,this.abort=new AbortController,this.keepalive=setInterval(()=>this.wake(!1),2e4/2),this.keepalive.unref?.(),this.run(this.abort.signal))}stop(){this.stopped=!0;for(let t of[...this.idleWaiters])t();this.open=!1,this.abort?.abort(),this.abort=null,this.timer&&clearTimeout(this.timer),this.keepalive&&clearInterval(this.keepalive),this.timer=null,this.keepalive=null}redial(){this.stopped||(this.abort?.abort(),this.abort=new AbortController,this.run(this.abort.signal))}idle(t){return this.stopped||!this.inFlight&&!this.o.links().some(n=>n.hasOutput())?Promise.resolve():new Promise(n=>{let r=()=>{clearTimeout(o),this.idleWaiters=this.idleWaiters.filter(i=>i!==r),n()},o=setTimeout(r,t);this.idleWaiters.push(r),this.wake(!0)})}wake(t){if(this.stopped)return;if(this.inFlight){this.again=!0;return}let n=Date.now()+Math.max(t?0:5,this.sendBackoffUntil-Date.now());this.timer&&this.timerAt<=n||(this.timer&&clearTimeout(this.timer),this.timerAt=n,this.timer=setTimeout(()=>{this.timer=null,this.flush()},Math.max(0,n-Date.now())))}async flush(){if(this.inFlight||this.stopped)return;this.inFlight=!0;let t=0;try{for(;;){let n=[],r=0;for(let s of this.o.links()){if(n.length>=16||r>=1048576)break;let{frames:a,hr:c}=s.take({bytes:1048576-r,frames:64});if(!(!a.length&&!c)){n.push({link:s,frames:a,hr:!!c});for(let u of a)r+=u.t==="a"?16:u.d.length}}if(n.length===0&&Date.now()-this.lastSentAt<2e4)return;let o={links:n.map(s=>({l:s.link.l,...s.frames.length?{f:s.frames}:{},...s.hr?{hr:!0}:{}}))},i=null;try{i=await this.o.request(this.o.sendPath,{method:"POST",body:o,timeoutMs:ts})}catch(s){this.o.log?.(`send failed: ${s.message}`)}if(i?.ok){this.lastSentAt=Date.now(),this.sendBackoffUntil=0;let s=await i.json().catch(()=>null);s?.peers&&this.o.onPeers?.(s.peers);let a=new Set(s?.refused??[]);for(let c of n)a.has(c.link.l)&&c.link.refused();if(this.stopped||!this.o.links().some(c=>c.hasOutput()))return;continue}for(let s of n)s.link.failed(s.frames,s.hr);if(i&&i.status===403){let s=(await i.json().catch(()=>null))?.error;this.o.onSendRefused?.(i.status,s,n.map(a=>a.link.l)),t=1e3}else t=(i&&ao(i))??1e3;this.sendBackoffUntil=Date.now()+t;return}}finally{if(this.inFlight=!1,t)this.wake(!1);else if(this.again)this.again=!1,this.wake(!0);else if(!this.o.links().some(n=>n.hasOutput()))for(let n of[...this.idleWaiters])n()}}async run(t){let n=0;for(;!t.aborted;){let r=await this.streamOnce(t);if(this.open=!1,t.aborted)return;r.kind==="closed"&&r.healthy&&(n=0);let o=this.o.onDown(r);if(o===null){this.stop();return}let i=o==="backoff"?es(n++,this.o.random):o;r.kind==="status"&&r.retryAfterMs&&(i=Math.max(i,r.retryAfterMs)),await ns(i,t)}}async streamOnce(t){let n=new AbortController,r=()=>n.abort();t.addEventListener("abort",r);let o=null,i=()=>{o&&clearTimeout(o),o=setTimeout(r,45e3)},s=Date.now(),a=()=>Date.now()-s>=Qi;try{let c=await this.o.request(this.o.streamPath,{signal:n.signal,timeoutMs:0});if(!c.ok||!c.body){let l=(await c.json().catch(()=>null))?.error;return{kind:"status",status:c.status,error:l,retryAfterMs:ao(c)}}this.open=!0,this.o.onOpen?.(),i();let u=c.body.getReader(),h=new TextDecoder,d="";for(;;){let{value:l,done:g}=await u.read();if(g)return{kind:"closed",healthy:a()};i(),d+=h.decode(l,{stream:!0});let y;for(;(y=d.indexOf(`
5
+
6
+ `))>=0;){let x=d.slice(0,y);d=d.slice(y+2),this.dispatch(x)}}}catch(c){return t.aborted||this.o.log?.(`stream dropped: ${c.message}`),{kind:"closed",healthy:a()}}finally{o&&clearTimeout(o),t.removeEventListener("abort",r)}}dispatch(t){let n="",r=[];for(let o of t.split(`
7
+ `))o.startsWith("event: ")?n=o.slice(7):o.startsWith("data: ")&&r.push(o.slice(6));if(!(!n||r.length===0))try{let o=JSON.parse(r.join(`
8
+ `));n==="f"?this.o.onDelivery(o):n==="c"&&this.o.onControl(o)}catch(o){this.o.log?.(`bad event: ${o.message}`)}}};function ns(e,t){return new Promise(n=>{let r=()=>{clearTimeout(o),t?.removeEventListener("abort",r),n()},o=setTimeout(r,e);t?.addEventListener("abort",r,{once:!0})})}import{randomBytes as Io}from"crypto";import To from"fs";import Ps from"os";import Dn from"path";var as={now:()=>Date.now(),setTimeout(e,t){let n=setTimeout(e,t);return n.unref?.(),n},clearTimeout:e=>clearTimeout(e)},us={window:4194304,channelWindow:262144,retransmitMs:2e3,sessionIdleMs:12e4,idleCloseMs:6e5,pingMs:15e3,ackBytes:65536,ackDelayMs:200,perChannelBatch:65536},uo=65536-Jt,ge=e=>e===A.DATA||e===A.ERR,ls=new Set([A.CREDIT,A.RESIZE,A.SIGNAL,A.CLOSE,A.PING,A.PONG,A.CONTROL]),ds=e=>Math.ceil((e+16)*4/3),Ne=class{sid;linkId;o;clock;lim;sendCtx;recvCtx;peerDir;ended=!1;nextQ=1;highestSent=0;acked=0;window=[];windowBytes=0;queues=new Map;queuedData=new Map;credit=new Map;interactive=new Set;finishing=new Set;rr=0;noProgress=0;lastProgressAt;lastGoBackAt=0;rtoMs;peerUp=!0;opensSent=new Set;expected=1;ackOwed=!1;sinceAck=0;ackTimer=null;lastHeardAt;lastBusyAt;lastPingAt=0;tickTimer=null;rttMs=null;constructor(t){this.o=t,this.sid=t.sid,this.linkId=t.linkId,this.clock=t.clock??as,this.lim={...us,...t.limits},this.rtoMs=this.lim.retransmitMs,this.peerDir=t.dir==="d2b"?"b2d":"d2b",this.sendCtx={linkId:t.linkId,sid:t.sid,dir:t.dir,key:t.sendKey},this.recvCtx={linkId:t.linkId,sid:t.sid,dir:this.peerDir,key:t.recvKey};let n=this.clock.now();this.lastProgressAt=n,this.lastHeardAt=n,this.lastBusyAt=n,this.queues.set(0,[]),this.schedule()}get isEnded(){return this.ended}get channels(){return this.credit.size}get unackedBytes(){return this.windowBytes}openChannel(t,n={}){this.credit.set(t,this.lim.channelWindow),this.finishing.delete(t),n.interactive&&this.interactive.add(t),this.queues.has(t)||this.queues.set(t,[]),this.lastBusyAt=this.clock.now()}hasChannel(t){return this.credit.has(t)}openSent(t){return this.opensSent.has(t)}finishChannel(t){this.credit.has(t)&&((this.queues.get(t)?.length??0)===0?this.forget(t):this.finishing.add(t))}dropChannel(t){let n=this.queues.get(t);if(n){let r=n.filter(o=>!ge(o.kind));r.length?this.queues.set(t,r):this.queues.delete(t)}this.queuedData.delete(t),this.forget(t),this.queues.has(t)&&this.finishing.add(t)}forget(t){this.opensSent.delete(t),this.credit.delete(t),this.interactive.delete(t),this.finishing.delete(t),this.queuedData.delete(t),t!==0&&(this.queues.get(t)?.length??0)===0&&this.queues.delete(t),this.credit.size===0&&(this.lastBusyAt=this.clock.now())}pending(t){return this.queuedData.get(t)??0}grant(t,n){n>0&&this.send(t,A.CREDIT,ro(n))}send(t,n,r=Buffer.alloc(0)){if(this.ended)return;let o=this.queues.get(t);if(o||(o=[],this.queues.set(t,o)),ge(n)){if(r.length===0)return;for(let i=0;i<r.length;i+=uo)o.push({kind:n,body:r.subarray(i,i+uo)});this.queuedData.set(t,(this.queuedData.get(t)??0)+r.length)}else o.push({kind:n,body:r});this.o.wake(t===0||this.interactive.has(t)||n===A.SIGNAL||n===A.RESIZE||n===A.CLOSE)}take(t){let n=[];if(this.ended)return n;let r=0;for(let i of this.window)if(!i.sent){if(n.length>=t.frames||n.length>0&&r+i.d.length>t.bytes)return this.withAck(n);i.sent=!0,i.opens!==void 0&&this.opensSent.add(i.opens),this.highestSent=Math.max(this.highestSent,i.q),n.push({t:"x",s:this.sid,q:i.q,d:i.d}),r+=i.d.length}let o=new Map;for(;n.length<t.frames&&this.windowBytes<this.lim.window;){let i=this.pick(o);if(!i)break;let s=Yr(i),a=ds(s.length),c=this.nextQ++,u=Jr(this.sendCtx,c,s);this.window.length===0&&(this.lastProgressAt=this.clock.now());let h=n.length===0||r+a<=t.bytes,d=i.kind===A.OPEN?i.ch:void 0;if(this.window.push({q:c,d:u,sent:h,...d!==void 0?{opens:d}:{}}),this.windowBytes+=u.length,!h)break;d!==void 0&&this.opensSent.add(d),this.highestSent=c,n.push({t:"x",s:this.sid,q:c,d:u}),r+=u.length}return this.withAck(n)}withAck(t){if(!this.ackOwed)return t;this.ackOwed=!1,this.sinceAck=0,this.ackTimer&&this.clock.clearTimeout(this.ackTimer),this.ackTimer=null;let n=this.expected-1,r=t.find(o=>o.t==="x");return r&&r.t==="x"?r.a=n:t.push({t:"a",s:this.sid,a:n}),t}get hasOutput(){if(this.ended)return!1;if(this.ackOwed||this.window.some(t=>!t.sent))return!0;if(this.windowBytes>=this.lim.window)return!1;for(let[t,n]of this.queues)if(n.length&&this.sendable(t,n)!==null)return!0;return!1}unsend(t){let n=new Set;for(let r of t)r.t==="x"&&n.add(r.q),r.t!=="h"&&r.a!==void 0&&(this.ackOwed=!0);for(let r of this.window)n.has(r.q)&&(r.sent=!1);(n.size||this.ackOwed)&&this.o.wake(!1)}sendable(t,n){let r=n[0];if(!r)return null;if(!ge(r.kind)||(this.credit.get(t)??0)>0)return 0;let o=n.findIndex(i=>ls.has(i.kind));return o>=0?o:null}pick(t){let n=[...this.queues.keys()].filter(o=>o!==0&&!this.interactive.has(o)),r=[0,...this.interactive];for(let o=0;o<n.length;o++)r.push(n[(this.rr+o)%n.length]);for(let o of r){let i=this.queues.get(o);if(!i?.length)continue;let s=o!==0&&!this.interactive.has(o),a=this.sendable(o,i);if(a===null)continue;let c=i[a];if(s&&ge(c.kind)&&(t.get(o)??0)>=this.lim.perChannelBatch)continue;let u=c.body;if(ge(c.kind)){let h=this.credit.get(o)??0;u.length>h?(c.body=u.subarray(h),u=u.subarray(0,h)):i.splice(a,1),this.credit.set(o,h-u.length),t.set(o,(t.get(o)??0)+u.length);let d=this.queuedData.get(o)??0,l=d-u.length;this.queuedData.set(o,l),d>=this.lim.channelWindow/2&&l<this.lim.channelWindow/2&&this.o.onDrained?.(o)}else i.splice(a,1);return s&&(this.rr=(n.indexOf(o)+1)%Math.max(1,n.length)),i.length===0&&this.finishing.has(o)?this.forget(o):i.length===0&&o!==0&&!this.credit.has(o)&&this.queues.delete(o),{kind:c.kind,ch:o,body:u}}return null}receive(t){if(this.ended||t.t==="h"||t.s!==this.sid||(this.lastHeardAt=this.clock.now(),t.a!==void 0&&!this.onAck(t.a))||t.t!=="x")return;if(t.q!==this.expected){this.oweAck(!0);return}let n=Qr(this.recvCtx,t.q,t.d);if(!n)return;let r=Gr(n);if(!r)return this.end("reset");this.expected++,this.sinceAck+=n.length,this.oweAck(this.sinceAck>=this.lim.ackBytes),this.handle(r)}onAck(t){if(t>this.highestSent)return this.end("reset"),!1;if(t>this.acked){let n=this.windowBytes>=this.lim.window;for(;this.window.length&&this.window[0].q<=t;)this.windowBytes-=this.window.shift().d.length;return this.acked=t,this.noProgress=0,this.rtoMs=this.lim.retransmitMs,this.lastProgressAt=this.clock.now(),n&&this.windowBytes<this.lim.window&&this.o.wake(!1),!0}return t<this.highestSent&&this.window.length&&(this.noProgress++,this.noProgress>=2&&this.clock.now()-this.lastGoBackAt>=1e3&&this.goBack()),!0}goBack(){if(this.window.length!==0){for(let t of this.window)t.sent=!1;this.noProgress=0,this.lastGoBackAt=this.clock.now(),this.lastProgressAt=this.clock.now(),this.o.wake(!0)}}oweAck(t){if(this.ackOwed=!0,t){this.ackTimer&&this.clock.clearTimeout(this.ackTimer),this.ackTimer=null,this.o.wake(!0);return}this.ackTimer||(this.ackTimer=this.clock.setTimeout(()=>{this.ackTimer=null,this.ackOwed&&this.o.wake(!0)},this.lim.ackDelayMs))}handle(t){switch(t.kind){case A.CREDIT:this.credit.has(t.ch)&&t.body.length>=4&&(this.credit.set(t.ch,Math.min(2**31,(this.credit.get(t.ch)??0)+t.body.readUInt32BE(0))),this.queues.get(t.ch)?.length&&this.o.wake(this.interactive.has(t.ch)));return;case A.PING:this.send(0,A.PONG,t.body);return;case A.PONG:this.rttMs=Math.max(0,this.clock.now()-io(t.body));return;default:this.o.onMessage(t)}}setPeerOnline(t){this.peerUp=t,t&&(this.rtoMs=this.lim.retransmitMs,this.goBack())}streamReopened(){this.oweAck(!0)}ping(){this.lastPingAt=this.clock.now(),this.send(0,A.PING,oo(this.clock.now()))}schedule(){this.tickTimer=this.clock.setTimeout(()=>this.tick(),1e3)}tick(){if(this.ended)return;let t=this.clock.now();if(this.window.some(n=>n.sent)&&this.peerUp&&t-this.lastProgressAt>=this.rtoMs&&(this.goBack(),this.rtoMs=Math.min(this.rtoMs*2,8*this.lim.retransmitMs)),this.credit.size>0){if(t-this.lastHeardAt>=this.lim.sessionIdleMs)return this.end("lost");t-this.lastPingAt>=this.lim.pingMs&&this.ping(),this.lastBusyAt=t}else if(t-this.lastBusyAt>=this.lim.idleCloseMs)return this.end("idle");this.schedule()}end(t){this.ended||(this.ended=!0,this.tickTimer&&this.clock.clearTimeout(this.tickTimer),this.ackTimer&&this.clock.clearTimeout(this.ackTimer),this.window=[],this.windowBytes=0,this.queues.clear(),this.queuedData.clear(),this.o.onEnd(t))}};function Ce(e){return`'${e.replace(/'/g,"'\\''")}'`}function lo(e){return`exec env EVRYAI_SCRIPT=${Buffer.from(e,"utf8").toString("base64")} /bin/sh -c 'eval "$(printf %s "$EVRYAI_SCRIPT" | base64 -d 2>/dev/null || printf %s "$EVRYAI_SCRIPT" | base64 -D)"'`}var Ha=process.platform==="win32"?24*1024:96*1024;var fs="EVRYAI-NOTE ";var fo=`t = index($0, "\\t"); if (!t) next; s = substr($0, 1, t - 1); r = substr($0, t + 1)
9
+ t = index(r, "\\t"); if (!t) next; l = substr(r, 1, t - 1); b = substr(r, t + 1)
10
+ if (s !~ /^[0-9]+$/) next
11
+ if (l != "-" && (l !~ /^[0-9]+[+]?$/ || length(b) != l + 0)) next`,Ka=`BEGIN { n = 1; f = ENVIRON["SEQ_FILE"] }
12
+ {
13
+ ${fo}
14
+ if (s + 0 != n) next
15
+ if (l == "-") exit
16
+ if (l ~ /[+]$/) printf "%s", b; else print b
17
+ fflush()
18
+ print n > f; close(f)
19
+ n++
20
+ }`,Xa=`BEGIN { a = ENVIRON["ALIVE_FILE"] }
21
+ {
22
+ ${fo}
23
+ if (s == "0") { printf "" > a; close(a); next }
24
+ print; fflush()
25
+ }`;var hs=`started() { if [ -r "/proc/$1/stat" ]; then sed 's/.*) //' "/proc/$1/stat" | cut -d' ' -f20; else LC_ALL=C ps -o lstart= -p "$1" 2>/dev/null | sed 's/ *$//'; fi; }`,ps=`${hs}
26
+ alive() {
27
+ [ ! -f "$1/rc" ] && P=$(cat "$1/pid" 2>/dev/null) && [ -n "$P" ] && kill -0 "$P" 2>/dev/null || return 1
28
+ S=$(cat "$1/started" 2>/dev/null)
29
+ if [ -n "$S" ]; then [ "$(started "$P")" = "$S" ]; else [ -n "$(find "$1/beat" -mmin -15 2>/dev/null)" ]; fi
30
+ }`;var ms=`stop_run() {
31
+ if alive "$1"; then
32
+ # Windows: the engine is a native process; its whole tree goes by its Windows pid.
33
+ [ -r "/proc/$P/winpid" ] && command -v taskkill >/dev/null 2>&1 && taskkill //T //F //PID "$(cat "/proc/$P/winpid")" >/dev/null 2>&1
34
+ K=$(pgrep -P "$P" 2>/dev/null)
35
+ kill $(cat "$1/pumps" 2>/dev/null) 2>/dev/null
36
+ kill -TERM "$P" $K 2>/dev/null
37
+ i=0; while kill -0 "$P" 2>/dev/null && [ $i -lt 20 ]; do sleep 0.1; i=$((i+1)); done
38
+ kill -KILL "$P" $K 2>/dev/null
39
+ fi
40
+ rm -rf "$1"
41
+ }`;var gs="This machine doesn't allow background processes over SSH. The session ends if the connection drops.",Va=`export -p | grep -Ev '^declare -x (BASHOPTS|SHELLOPTS|BASH_[A-Z_]*|PPID|UID|EUID|_)=' > "$R/s/env.sh"
42
+ W_SH=$(cygpath -w /usr/bin/sh.exe); W_SUP=$(cygpath -w "$R/sup"); W_DIR=$(pwd -W 2>/dev/null)
43
+ case "$W_SH$W_SUP$W_DIR" in *"'"*) W_OK= ;; *) W_OK=1 ;; esac
44
+ if [ -n "$W_OK" ]; then
45
+ printf '%s\\n' "\\$r = Invoke-CimMethod -ClassName Win32_Process -MethodName Create -Arguments @{ CommandLine = '\\"$W_SH\\" \\"$W_SUP\\"'; CurrentDirectory = '$W_DIR' }" 'exit $r.ReturnValue' > "$R/start.ps1"
46
+ powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "$(cygpath -w "$R/start.ps1")" </dev/null >/dev/null 2>&1 || W_OK=
47
+ fi
48
+ if [ -z "$W_OK" ]; then
49
+ echo "${fs}${gs}" >&2
50
+ /bin/sh "$R/sup" </dev/null >/dev/null 2>&1 &
51
+ fi`;var Wa=32*1024*1024;function ho(e){return`R=${Ce(e)}
52
+ ${ps}
53
+ ${ms}
54
+ [ -d "$R" ] || exit 0
55
+ [ "$(cat "$R/host" 2>/dev/null)" = "$(uname -n)" ] || exit 0
56
+ stop_run "$R"
57
+ `}var Ya=Buffer.from("EVRYAI-DRAIN ");var Ga=3*1024;var ja=Buffer.from(`0 0
58
+ `);import{spawn as Oe,spawnSync as bs}from"child_process";import Ft from"fs";import ye from"os";import gt from"path";import{execFile as mo,spawnSync as po}from"child_process";import $n from"fs";var go="This machine has no script(1), so the terminal has no TTY. Install util-linux to fix it.";function yo(){if(process.platform==="win32")return{mode:"none",echoFlag:!1};if(process.platform==="darwin"&&$n.existsSync("/usr/bin/script"))return{mode:"script",echoFlag:!1};let e=po("script",["--help"],{encoding:"utf8",timeout:3e3});if(!e.error&&/--command|-c,/.test(`${e.stdout}${e.stderr}`))return{mode:"script",echoFlag:/--echo/.test(`${e.stdout}${e.stderr}`)};let t=po("python3",["-c","import pty"],{timeout:3e3});return!t.error&&t.status===0?{mode:"python",echoFlag:!1}:{mode:"none",echoFlag:!1}}var ys=`import os,pty,sys,select,struct,fcntl,termios
59
+ pid,fd=pty.fork()
60
+ if pid==0:
61
+ os.execvp(sys.argv[1],sys.argv[1:])
62
+ def size(r,c):
63
+ try: fcntl.ioctl(fd,termios.TIOCSWINSZ,struct.pack("HHHH",r,c,0,0))
64
+ except Exception: pass
65
+ size(int(os.environ.get("EVRYAI_ROWS","24")),int(os.environ.get("EVRYAI_COLS","80")))
66
+ ins=[0,fd,3]
67
+ buf=b""
68
+ while True:
69
+ try: r,_,_=select.select(ins,[],[])
70
+ except InterruptedError: continue
71
+ if fd in r:
72
+ try: d=os.read(fd,65536)
73
+ except OSError: d=b""
74
+ if not d: break
75
+ os.write(1,d)
76
+ if 0 in r:
77
+ d=os.read(0,65536)
78
+ if not d: ins.remove(0)
79
+ else: os.write(fd,d)
80
+ if 3 in r:
81
+ d=os.read(3,1024)
82
+ if not d: ins.remove(3)
83
+ buf+=d
84
+ while b"\\n" in buf:
85
+ line,buf=buf.split(b"\\n",1)
86
+ p=line.split()
87
+ if len(p)==2: size(int(p[0]),int(p[1]))
88
+ _,st=os.waitpid(pid,0)
89
+ sys.exit(os.waitstatus_to_exitcode(st) if hasattr(os,"waitstatus_to_exitcode") else (st>>8))
90
+ `;function xo(e,t,n,r,o){let i=`stty rows ${o} cols ${r} 2>/dev/null; ${n}`;return e.mode==="script"?process.platform==="darwin"?["/bin/sh","-c",'cat | { /usr/bin/script -q /dev/null "$0" -c "$1"; rc=$?; pkill -P $$ -x cat 2>/dev/null; exit $rc; }',t,i]:["script","-qfec",i,...e.echoFlag?["-E","never"]:[],"/dev/null"]:e.mode==="python"?["python3","-c",ys,t,"-c",n]:[t,"-c",n]}function xs(e){if(process.platform==="linux"){let t=[e];for(let n=0;n<t.length&&n<64;n++){let r=t[n];try{let o=$n.readlinkSync(`/proc/${r}/fd/0`);if(o.startsWith("/dev/pts/"))return Promise.resolve(o)}catch{}try{t.push(...$n.readFileSync(`/proc/${r}/task/${r}/children`,"utf8").trim().split(/\s+/).map(Number).filter(o=>o>0))}catch{}}return Promise.resolve(null)}return new Promise(t=>{mo("ps",["-A","-o","pid=,ppid=,tty="],{timeout:3e3},(n,r)=>{if(n)return t(null);let o=r.trim().split(`
91
+ `).map(a=>a.trim().split(/\s+/)),i=new Map;for(let[a,c,u]of o){let h=i.get(Number(c))??[];h.push({pid:Number(a),tty:u??"??"}),i.set(Number(c),h)}let s=[e];for(let a=0;a<s.length&&a<64;a++)for(let c of i.get(s[a])??[]){if(c.tty&&c.tty!=="??")return t(`/dev/${c.tty.startsWith("tty")?c.tty:`tty${c.tty}`}`);s.push(c.pid)}t(null)})})}async function bo(e,t,n){let r=await xs(e);if(!r)return;let o=process.platform==="darwin"?"-f":"-F";await new Promise(i=>{mo("/bin/sh",["-c",`stty ${o} ${Ce(r)} rows ${n} cols ${t}`],{timeout:3e3},()=>i())})}var ws=new Set(["SIGINT","SIGTERM","SIGHUP","SIGKILL"]),qt=process.platform==="win32";function Tn(e=process.env,t=Ft.existsSync){let r=[e.ProgramFiles,e["ProgramFiles(x86)"],e.LOCALAPPDATA&&gt.win32.join(e.LOCALAPPDATA,"Programs")].filter(i=>!!i).map(i=>gt.win32.join(i,"Git","bin","sh.exe")),o=t===Ft.existsSync?bs("where.exe",["git"],{encoding:"utf8",timeout:5e3,windowsHide:!0}).stdout??"":"";for(let i of o.split(/\r?\n/)){let s=/^(.+?)\\(?:cmd|mingw64\\bin|clangarm64\\bin)\\git\.exe$/i.exec(i.trim());s?.[1]&&r.unshift(gt.win32.join(s[1],"bin","sh.exe"))}return r.find(i=>t(i))??null}var wo="Install Git for Windows on this machine to run coding agents there.";function Es(e,t=Ft.existsSync){let n=gt.win32.dirname(gt.win32.dirname(e)),r=t(gt.win32.join(n,"clangarm64","bin"))?"CLANGARM64":"MINGW64";return{sh:gt.win32.join(n,"usr","bin","sh.exe"),path:[gt.win32.join(n,r.toLowerCase(),"bin"),gt.win32.join(n,"usr","bin")],msystem:r}}var Rn=(()=>{let e;return()=>{if(e===void 0){let t=qt?Tn():null;e=t?Es(t):null}return e}})();function Bn(){if(qt)return Rn()?.sh??"sh.exe";try{let e=ye.userInfo().shell;if(e&&Ft.existsSync(e))return e}catch{}return"/bin/sh"}var vs=["USERPROFILE","USERNAME","USERDOMAIN","HOMEDRIVE","HOMEPATH","APPDATA","LOCALAPPDATA","PATH","PATHEXT","SystemRoot","SystemDrive","windir","ComSpec","TEMP","TMP","ProgramFiles","ProgramFiles(x86)","ProgramData","ProgramW6432","CommonProgramFiles","NUMBER_OF_PROCESSORS","PROCESSOR_ARCHITECTURE","OS","LANG","TZ"];function Mn(e){if(qt){let o={};for(let[s,a]of Object.entries(process.env))a!==void 0&&vs.some(c=>c.toLowerCase()===s.toLowerCase())&&(o[s]=a);let i=Rn();if(i){let s=Object.keys(o).find(a=>a.toLowerCase()==="path")??"Path";o[s]=[...i.path,o[s]??""].filter(Boolean).join(";"),o.MSYSTEM=i.msystem}return e&&(o.TERM=e),o}let t=ye.userInfo(),n={HOME:t.homedir,USER:t.username,LOGNAME:t.username,SHELL:Bn(),PATH:"/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"};for(let o of["LANG","LC_ALL","TZ","TMPDIR","DBUS_SESSION_BUS_ADDRESS"])process.env[o]&&(n[o]=process.env[o]);let r=process.env.XDG_RUNTIME_DIR||`/run/user/${t.uid}`;return Ft.existsSync(r)&&(n.XDG_RUNTIME_DIR=r),!n.DBUS_SESSION_BUS_ADDRESS&&Ft.existsSync(`${r}/bus`)&&(n.DBUS_SESSION_BUS_ADDRESS=`unix:path=${r}/bus`),e&&(n.TERM=e),n}var As=`for p in /proc/[0-9]*; do
92
+ [ "$(cat "$p/winpid" 2>/dev/null)" = "$1" ] || continue
93
+ kill -"$2" -- -"$(cat "$p/pgid")" "\${p#/proc/}" 2>/dev/null
94
+ done
95
+ [ "$2" = KILL ] && taskkill //T //F //PID "$1" >/dev/null 2>&1
96
+ exit 0`;function In(e,t){if(qt){let n=Rn()?.sh;n?Oe(n,["-c",As,"sh",String(e),t.replace(/^SIG/,"")],{env:Mn(),stdio:"ignore",windowsHide:!0}).on("error",()=>{}):Oe("taskkill",["/T","/F","/PID",String(e)],{stdio:"ignore",windowsHide:!0}).on("error",()=>{});return}try{process.kill(-e,t)}catch{try{process.kill(e,t)}catch{}}}function Ss(e){In(e,"SIGHUP"),setTimeout(()=>In(e,"SIGKILL"),5e3).unref()}var _s=262144/4;function Eo(e,t,n){let r=Bn(),o=ye.homedir(),i=t.pty,s=i?xo(t.caps,r,e,i.cols,i.rows):[r,"-c",qt?`trap : EXIT
97
+ ${e}`:e],a=i&&t.caps.mode==="python",c=Mn(i?.term);a&&(c.EVRYAI_COLS=String(i.cols),c.EVRYAI_ROWS=String(i.rows));let u=Oe(s[0],s.slice(1),{cwd:Ft.existsSync(o)?o:qt?void 0:"/",env:c,detached:!qt,windowsHide:!0,stdio:a?["pipe","pipe","pipe","pipe"]:["pipe","pipe","pipe"]}),h=!!i&&t.caps.mode==="none";h&&n.err(Buffer.from(`${go}
98
+ `.replace(/\n/g,`\r
99
+ `)));let d=m=>h?Buffer.from(m.toString("latin1").replace(/\r?\n/g,`\r
100
+ `),"latin1"):m,l=0,g=null,y=0,x=!1,f=()=>{++l===2&&(n.eof(),g&&n.exit(g.code,g.signal))},p=()=>{n.pending()>=262144&&(u.stdout?.pause(),u.stderr?.pause())};u.stdout?.on("data",m=>{n.data(d(m)),p()}),u.stderr?.on("data",m=>{n.err(d(m)),p()}),u.stdout?.once("close",f),u.stderr?.once("close",f),u.stdin?.on("error",()=>{}),u.on("error",m=>{g||(n.err(Buffer.from(`${m.message}
101
+ `)),g={code:127},l<2&&(l=1,f()))}),u.on("exit",(m,E)=>{let _=E?ye.constants.signals[E]??1:0;g=E?{code:128+_,signal:E}:{code:m??0},l===2&&n.exit(g.code,g.signal)});let b=a?u.stdio[3]:null;return b?.on("error",()=>{}),{get pid(){return u.pid??0},write(m){if(!u.stdin||u.stdin.destroyed)return void n.took(m.length);let E=h?Buffer.from(m.toString("latin1").replace(/\r\n?/g,`
102
+ `),"latin1"):m;h&&n.data(d(E)),u.stdin.write(E,()=>{y+=m.length,y>=_s&&(n.took(y),y=0)})},end(){u.stdin?.end()},signal(m){ws.has(m)&&u.pid&&In(u.pid,m)},resize(m,E){!i||!u.pid||(a?b?.write(`${E} ${m}
103
+ `):t.caps.mode==="script"&&bo(u.pid,m,E))},close(){x||(x=!0,u.pid&&g===null&&Ss(u.pid),u.stdout?.destroy(),u.stderr?.destroy(),u.stdin?.destroy())},drained(){u.stdout?.resume(),u.stderr?.resume()}}}function Nn(e){let t=Oe(Bn(),["-c",e],{cwd:ye.homedir(),env:Mn(),detached:!0,stdio:"ignore",windowsHide:!0});return t.on("error",()=>{}),t.unref(),t.pid??0}import Yt from"fs";import So from"path";import{execFileSync as vo}from"child_process";import O from"fs";import ks from"os";import Kt from"path";function V(){return process.env.EVRYAI_CONNECTOR_DIR?process.env.EVRYAI_CONNECTOR_DIR:process.platform==="win32"&&process.env.LOCALAPPDATA?Kt.join(process.env.LOCALAPPDATA,"EvryAI","connector"):Kt.join(ks.homedir(),".evryai","connector")}var Pe=()=>Kt.join(V(),"state.json"),Xt=()=>Kt.join(V(),"run.pid"),xe=()=>Kt.join(V(),"signal"),Vt=()=>Kt.join(V(),"bin",process.platform==="win32"?"evryai-connect.cmd":"evryai-connect");function Cn(){O.mkdirSync(V(),{recursive:!0,mode:448}),O.chmodSync(V(),448)}function q(){try{let e=JSON.parse(O.readFileSync(Pe(),"utf8"));return e.v!==1||typeof e.hostId!="string"||typeof e.token!="string"||!Array.isArray(e.links)?null:e}catch{return null}}function kt(e){Cn();let t=`${Pe()}.${process.pid}.tmp`;O.writeFileSync(t,JSON.stringify(e,null,2),{mode:384}),O.renameSync(t,Pe())}function De(){O.rmSync(Pe(),{force:!0})}var $s=3e4;async function $t(e){Cn();let t=Kt.join(V(),"state.lock"),n=Date.now()+1e4;for(;;)try{O.mkdirSync(t);break}catch{try{Date.now()-O.statSync(t).mtimeMs>$s&&O.rmSync(t,{recursive:!0,force:!0})}catch{}if(Date.now()>n)throw new Error("Another connector command is busy. Try again in a moment.");await new Promise(r=>setTimeout(r,100))}try{return await e()}finally{O.rmSync(t,{recursive:!0,force:!0})}}function Wt(){try{let e=Number(O.readFileSync(Xt(),"utf8").trim());if(!Number.isInteger(e)||e<=1)return null;process.kill(e,0);let t=process.platform==="linux"?O.readFileSync(`/proc/${e}/cmdline`,"utf8"):process.platform==="win32"?vo("powershell.exe",["-NoProfile","-Command",`(Get-CimInstance Win32_Process -Filter "ProcessId=${e}").CommandLine`],{encoding:"utf8",timeout:1e4,windowsHide:!0}):vo("ps",["-p",String(e),"-o","command="],{encoding:"utf8",timeout:5e3});return/connector-[^/\s]*\.mjs|evryai-connect/.test(t)?e:null}catch{return null}}function te(e,t){if(process.platform!=="win32")return void process.kill(e,t==="reload"?"SIGHUP":"SIGUSR2");Cn();let n=`${xe()}.${process.pid}.tmp`;O.writeFileSync(n,t,{mode:384}),O.renameSync(n,xe())}function Ao(e){if(process.platform!=="win32"){process.on("SIGHUP",()=>e("reload")),process.on("SIGUSR2",()=>e("restart"));return}let t=()=>{let n="";try{n=O.readFileSync(xe(),"utf8").trim(),O.rmSync(xe(),{force:!0})}catch{return}(n==="reload"||n==="restart")&&e(n)};O.rmSync(xe(),{force:!0}),O.watch(O.realpathSync.native(V()),(n,r)=>{(!r||r==="signal")&&t()}).on("error",()=>{})}var Is=5*1024*1024;function Ts(){return So.join(V(),"log","connector.log")}function Rs(e){try{if(Yt.statSync(e).size<Is)return;Yt.rmSync(`${e}.2`,{force:!0}),Yt.existsSync(`${e}.1`)&&Yt.renameSync(`${e}.1`,`${e}.2`),Yt.renameSync(e,`${e}.1`)}catch{}}function F(e){try{let t=Ts();Yt.mkdirSync(So.dirname(t),{recursive:!0,mode:448}),Rs(t),Yt.appendFileSync(t,`${new Date().toISOString()} [${process.pid}] ${e}
104
+ `,{mode:384})}catch{}}function N(e){process.stdout.write(`${e}
105
+ `),F(e)}function K(e){process.stderr.write(`${e}
106
+ `),F(e)}import _o from"net";function ko(e,t,n){let r=e.path?_o.connect({path:e.path}):_o.connect({port:e.port,host:"127.0.0.1"}),o=!1,i=!1,s=0;return r.once("connect",()=>{o=!0,n.opened()}),r.on("data",a=>{t.data(a),t.pending()>=262144&&r.pause()}),r.on("end",()=>t.eof()),r.on("error",a=>{!o&&!i&&(i=!0,n.refused(a.message))}),r.on("close",()=>{o&&!i&&(i=!0,n.closed())}),{get pid(){return 0},write(a){if(r.destroyed)return void t.took(a.length);r.write(a,()=>{s+=a.length,s>=262144/4&&(t.took(s),s=0)})},end:()=>void r.end(),signal:()=>{},resize:()=>{},close(){i=!0,r.destroy()},drained:()=>void r.resume()}}var Ns=100*1024,Cs=/^[A-Za-z0-9._+-]{1,64}$/,Pn=/^[0-9a-f]{64}$/,Ue=/^\d{1,4}\.\d{1,4}\.\d{1,6}$/,rt=(e,t)=>({ok:!1,code:e,error:t}),On=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Le=(e,t,n)=>typeof e=="number"&&Number.isInteger(e)&&e>=t&&e<=n;function Os(e,t,n){if(!On(e)||typeof e.type!="string")return"Not a command.";if(t==="open"){if(!Le(e.ch,1,4294967295))return"Bad channel.";if(n.inUse(e.ch))return"That channel is in use.";if(e.type==="exec"){if(typeof e.cmd!="string"||e.cmd.length===0||e.cmd.length>Ns||e.cmd.includes("\0")||e.detached!==void 0&&e.detached!==!0)return"Bad command.";let r;if(e.pty!==void 0){let o=e.pty;if(!On(o)||!Le(o.cols,1,1e3)||!Le(o.rows,1,1e3)||typeof o.term!="string"||!Cs.test(o.term))return"Bad terminal size.";r={cols:o.cols,rows:o.rows,term:o.term}}return{type:"exec",ch:e.ch,cmd:e.cmd,...r?{pty:r}:{},...e.detached?{detached:!0}:{}}}return e.type==="tcp"?e.port!==void 0&&e.path===void 0&&Le(e.port,1,65535)?{type:"tcp",ch:e.ch,port:e.port}:e.path!==void 0&&e.port===void 0&&typeof e.path=="string"&&e.path.startsWith("/")&&e.path.length<=1024&&!e.path.includes("\0")?{type:"tcp",ch:e.ch,path:e.path}:"Bad address.":"Not a channel command."}return e.type==="revoke"?{type:"revoke"}:e.type==="stop-owned"?typeof e.client=="string"&&/^[a-f0-9]{16,64}$/.test(e.client)?{type:"stop-owned",client:e.client}:"Bad client.":e.type==="upgrade"?typeof e.version!="string"||!Ue.test(e.version)||typeof e.url!="string"||typeof e.sha256!="string"||!Pn.test(e.sha256)?"Bad update.":{type:"upgrade",version:e.version,url:e.url,sha256:e.sha256}:"Not a control command."}function $o(e,t,n){let r;try{r=JSON.parse(e.toString("utf8"))}catch{return rt("shape","Not a command.")}if(!On(r))return rt("shape","Not a command.");let{linkId:o,id:i,ts:s,body:a,sig:c}=r;if(typeof o!="string"||!qr.test(o)||typeof i!="string"||!Fr.test(i)||typeof s!="number"||!Number.isFinite(s)||typeof a!="string"||typeof c!="string")return rt("shape","Not a command.");if(o!==n.linkId||!Xr(Sn(n.key,{linkId:o,id:i,ts:s,body:a}),c))return rt("unpaired","Not paired with this machine.");let u=(n.now??Date.now)()+n.skewMs;if(Math.abs(s-u)>12e4)return rt("skew","This machine's clock is far off.");if(n.seen.has(i))return rt("replay","Already run.");let h;try{h=JSON.parse(a)}catch{return rt("shape","Not a command.")}let d=Os(h,t,n);return typeof d=="string"?rt("shape",d):t==="open"&&n.channels>=64?rt("busy","Too many open channels."):(n.seen.add(i),{ok:!0,cmd:d,id:i})}var Ds=2e3,Ls=5e3,He=class{l;desktopName;key;session=null;pending=null;out=[];helloAt=0;openedAt=0;skewMs=0;client="";seen=new Set;channels=new Map;hooks;peerOnline=null;approved;constructor(t,n){this.l=t.linkId,this.desktopName=t.desktopName,this.key=Buffer.from(t.key,"base64url"),this.approved=!!t.confirmed,this.hooks=n}get up(){return!!this.session&&!this.session.isEnded}approve(){this.approved=!0}hello(){if(!this.approved)return;let t=Date.now();if(this.pending&&t-this.helloAt<Ds)return;this.helloAt=t;let n=Io(16).toString("hex"),r=Io(32),o=this.hooks.service(),i={os:process.platform,arch:process.arch,pty:this.hooks.caps.mode,node:process.versions.node,...o?{svc:o}:{}},s=eo(this.key,{k:"hello",v:1,sid:n,bn:r.toString("base64url"),ver:Z,proto:Wr,caps:i});this.pending={sid:n,bn:r,frame:{t:"h",s:n,d:s}},this.out=this.out.filter(a=>a.t!=="h"),this.out.push(this.pending.frame),this.hooks.wake(!0)}helloRequested(){this.up&&Date.now()-this.openedAt<Ls||this.hello()}take(t){let n=this.out.splice(0,t.frames);return this.session&&!this.session.isEnded&&n.length<t.frames&&n.push(...this.session.take({bytes:t.bytes,frames:t.frames-n.length})),{frames:n}}failed(t){let n=t.filter(r=>r.t==="h"&&r.s===this.pending?.sid);this.out.unshift(...n),this.session?.unsend(t.filter(r=>r.t!=="h"))}refused(){this.out=[],this.pending=null,this.approved&&this.hooks.revoked(this)}hasOutput(){return this.out.length>0||!!this.session?.hasOutput}receive(t){for(let n of t)n.t==="h"?this.onAck(n):this.session&&n.s===this.session.sid?this.session.receive(n):n.t==="x"&&(!this.pending||n.s!==this.pending.sid)&&this.hello()}setPeer(t){this.peerOnline=t,this.session?.setPeerOnline(t),t&&this.session?.streamReopened()}onAck(t){let n=this.pending;if(!n||t.s!==n.sid)return;let r=no(this.key,t.d);!r||r.k!=="hello-ack"||r.sid!==n.sid||r.bn!==n.bn.toString("base64url")||(this.pending=null,this.open(r,n.bn))}open(t,n){let r=jr(this.key,n,Buffer.from(t.dn,"base64url"),t.sid),o=this.session;this.skewMs=t.now-Date.now(),this.client=t.client,this.seen=new Set;let i=new Ne({linkId:this.l,sid:t.sid,dir:"b2d",sendKey:r.b2d,recvKey:r.d2b,wake:this.hooks.wake,onDrained:a=>this.channels.get(a)?.drained(),onMessage:a=>this.onMessage(i,a),onEnd:a=>this.ended(i,a)});this.session=i,this.openedAt=Date.now();let s=this.channels;if(this.channels=new Map,o){for(let a of s.values())a.close();o.end("replaced")}i.send(0,A.READY),F(`session up with "${this.desktopName}" (skew ${Math.round(this.skewMs/1e3)} s)`)}ended(t,n){if(this.session===t){for(let r of this.channels.values())r.close();this.channels.clear(),this.session=null,n!=="replaced"&&F(`session with "${this.desktopName}" ended: ${n}`)}}refuse(t,n,r,o){t.send(n,A.REFUSED,Qt({error:o,code:r}))}sink(t,n){let r=this.channels;return{data:o=>t.send(n,A.DATA,o),err:o=>t.send(n,A.ERR,o),eof:()=>t.send(n,A.EOF),exit:(o,i)=>{t.send(n,A.EXIT,Qt({code:o,...i?{signal:i}:{}})),r.delete(n),t.finishChannel(n)},took:o=>t.grant(n,o),pending:()=>t.pending(n)}}onMessage(t,n){if(n.kind===A.OPEN)return this.onOpen(t,n);if(n.kind===A.CONTROL)return void this.onControl(t,n);let r=this.channels.get(n.ch);if(r)switch(n.kind){case A.DATA:r.write(n.body);return;case A.EOF:r.end();return;case A.SIGNAL:r.signal(n.body.toString("utf8"));return;case A.RESIZE:n.body.length>=4&&r.resize(n.body.readUInt16BE(0),n.body.readUInt16BE(2));return;case A.CLOSE:r.close(),this.channels.delete(n.ch),t.dropChannel(n.ch);return;default:return}}verify(t,n,r){return $o(n,r,{linkId:this.l,key:this.key,skewMs:this.skewMs,seen:this.seen,channels:this.channels.size,inUse:o=>this.channels.has(o)||t.hasChannel(o)})}onOpen(t,n){let r=this.verify(t,n.body,"open");if(!r.ok)return F(`refused a command: ${r.code}`),this.refuse(t,n.ch,r.code,r.error);let o=r.cmd;if(o.ch!==n.ch)return this.refuse(t,n.ch,"shape","Bad channel.");if(o.type==="exec"&&o.detached){let c=Nn(o.cmd);t.send(n.ch,A.OPENED,Qt({pid:c}));return}t.openChannel(n.ch,{interactive:o.type==="exec"&&!!o.pty});let i=this.sink(t,n.ch),s=this.channels;if(o.type==="tcp"){let c=ko(o,i,{opened:()=>t.send(n.ch,A.OPENED,Qt({pid:0})),refused:u=>{s.delete(n.ch),this.refuse(t,n.ch,"connect",u),t.finishChannel(n.ch)},closed:()=>{s.delete(n.ch),t.send(n.ch,A.CLOSE),t.finishChannel(n.ch)}});s.set(n.ch,c);return}let a=Eo(o.cmd,{pty:o.pty,caps:this.hooks.caps},i);s.set(n.ch,a),t.send(n.ch,A.OPENED,Qt({pid:a.pid}))}async onControl(t,n){let r=this.verify(t,n.body,"control");if(!r.ok)return F(`refused a control: ${r.code}`);let o=r.cmd;if(o.type==="stop-owned")return Ro(o.client);if(o.type==="revoke")return F(`"${this.desktopName}" removed this machine`),Ro(this.client),this.hooks.revoked(this);if(o.type==="upgrade"){let i=await this.hooks.upgrade(o.version,o.url,o.sha256);i&&F(`update to ${o.version} failed: ${i}`)}}close(t){this.session?.end(t),this.session=null,this.pending=null,this.out=[]}get rttMs(){return this.session?.rttMs??null}};function Ro(e){if(!/^[a-f0-9]{16,64}$/.test(e))return;let t=Dn.join(Ps.homedir(),".evryai","run"),n=[];try{n=To.readdirSync(t)}catch{return}for(let r of n){let o=Dn.join(t,r);try{let[i]=To.readFileSync(Dn.join(o,"owner"),"utf8").trim().split(/\s+/);i===e&&Nn(lo(ho(o)))}catch{}}}function It(e,t){return async(n,r)=>{let o={"user-agent":`evryai-connector/${Z}`,accept:"application/json"};t&&(o[Kr]=`${t.hostId}.${t.token}`),r.body!==void 0&&(o["content-type"]="application/json");let i=r.timeoutMs??15e3,s=[...r.signal?[r.signal]:[],...i>0?[AbortSignal.timeout(i)]:[]];return fetch(`${e}${n}`,{method:r.method??"GET",headers:o,body:r.body===void 0?void 0:JSON.stringify(r.body),redirect:"error",signal:s.length?AbortSignal.any(s):void 0})}}import{execFile as Hs,spawn as Bo}from"child_process";import Gt from"fs";import ne from"os";import ee from"path";var Mo="# evryai-connector";function qs(){return`[Unit]
107
+ Description=EvryAI connector
108
+ StartLimitIntervalSec=300
109
+ StartLimitBurst=5
110
+
111
+ [Service]
112
+ Type=simple
113
+ WorkingDirectory=%h
114
+ ExecStart=%h/.evryai/connector/bin/evryai-connect run
115
+ Restart=always
116
+ RestartSec=5
117
+ # Engines are detached and must outlive a connector restart or update.
118
+ KillMode=process
119
+ OOMPolicy=continue
120
+
121
+ [Install]
122
+ WantedBy=default.target
123
+ `}var Ln=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");function Fs(e,t){return`<?xml version="1.0" encoding="UTF-8"?>
124
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
125
+ <plist version="1.0">
126
+ <dict>
127
+ <key>Label</key><string>${Ut}</string>
128
+ <key>ProgramArguments</key>
129
+ <array><string>${Ln(e)}</string><string>run</string></array>
130
+ <key>RunAtLoad</key><true/>
131
+ <key>KeepAlive</key><true/>
132
+ <key>ThrottleInterval</key><integer>5</integer>
133
+ <key>AbandonProcessGroup</key><true/>
134
+ <key>ProcessType</key><string>Standard</string>
135
+ <key>StandardOutPath</key><string>${Ln(t)}</string>
136
+ <key>StandardErrorPath</key><string>${Ln(t)}</string>
137
+ </dict>
138
+ </plist>
139
+ `}var Ks=e=>`'${e.replace(/'/g,"'\\''")}'`;function Xs(e){return`@reboot ${Ks(e)} run >/dev/null 2>&1 ${Mo}`}function No(e,t,n){let r=e.split(`
140
+ `).filter(o=>o.trim()&&!o.includes(Mo));return n&&r.push(Xs(t)),r.length?`${r.join(`
141
+ `)}
142
+ `:""}function P(e,t,n){return new Promise(r=>{let o=Hs(e,t,{timeout:2e4,encoding:"utf8"},(i,s,a)=>{let c=i?typeof i.code=="number"?i.code:1:0;r({code:c,out:`${s}${a}`})});n!==void 0&&o.stdin?.end(n)})}var Un=()=>ee.join(ne.homedir(),".config","systemd","user",`${pe}.service`),qe=()=>ee.join(ne.homedir(),"Library","LaunchAgents",`${Ut}.plist`);function Vs(e){return["/Create","/F","/SC","ONLOGON","/RL","LIMITED","/TN",Be,"/TR",`"${e}" run`]}async function Hn(){let e=Vt();if(process.platform==="win32")return(await P("schtasks",Vs(e))).code!==0?{kind:null,note:`Couldn't set it up to start at logon. Keep it running with: "${e}" run`}:(await P("schtasks",["/Run","/TN",Be]),{kind:"schtasks",note:"Runs while you're logged in, and starts again when you log in."});if(process.platform==="darwin"){let n=ne.userInfo().uid,r=ee.join(V(),"log","launchd.log");Gt.mkdirSync(ee.dirname(qe()),{recursive:!0}),Gt.mkdirSync(ee.dirname(r),{recursive:!0,mode:448}),Gt.writeFileSync(qe(),Fs(e,r)),await P("launchctl",["bootout",`gui/${n}/${Ut}`]),await P("launchctl",["enable",`gui/${n}/${Ut}`]);let o=await P("launchctl",["bootstrap",`gui/${n}`,qe()]);return o.code!==0?{kind:null,note:`Couldn't start it in the background: ${o.out.trim()}`}:{kind:"launchd",note:"Runs while you're logged in. For a Mac that restarts unattended, turn on automatic login."}}if((await P("systemctl",["--user","show-environment"])).code===0){Gt.mkdirSync(ee.dirname(Un()),{recursive:!0}),Gt.writeFileSync(Un(),qs()),await P("systemctl",["--user","daemon-reload"]);let n=await P("systemctl",["--user","enable","--now",pe]);if(n.code!==0)return{kind:null,note:`Couldn't start it in the background: ${n.out.trim()}`};let r=ne.userInfo().username;return{kind:"systemd",...(await P("loginctl",["enable-linger",r])).code===0||(await P("loginctl",["show-user",r,"--property=Linger"])).out.includes("Linger=yes")?{}:{note:`It stops when you log out and won't start after a restart until you run: sudo loginctl enable-linger ${r}`}}}let t=await P("crontab",["-l"]);if(t.code===0||/no crontab/i.test(t.out)){let n=No(t.code===0?t.out:"",e,!0);if((await P("crontab",["-"],n)).code===0)return qn(),{kind:"cron",note:"Started in the background. It starts again after a restart."}}return{kind:null,note:`Couldn't set up a background service here. Keep it running with: nohup ${e} run >/dev/null 2>&1 &`}}var Ws=e=>`""${e}" run"`;function qn(){let e={detached:!0,stdio:"ignore",cwd:ne.homedir(),windowsHide:!0},t=process.platform==="win32"?Bo("cmd.exe",["/d","/s","/c",Ws(Vt())],{...e,windowsVerbatimArguments:!0}):Bo(Vt(),["run"],e);t.on("error",()=>{}),t.unref()}async function Fe(e){if(e==="systemd")await P("systemctl",["--user","disable",pe]),Gt.rmSync(Un(),{force:!0}),await P("systemctl",["--user","daemon-reload"]),await P("systemctl",["--user","stop","--no-block",pe]);else if(e==="launchd"){let t=ne.userInfo().uid;Gt.rmSync(qe(),{force:!0}),await P("launchctl",["bootout",`gui/${t}/${Ut}`])}else if(e==="schtasks")await P("schtasks",["/Delete","/F","/TN",Be]);else if(e==="cron"){let t=await P("crontab",["-l"]);t.code===0&&await P("crontab",["-"],No(t.out,Vt(),!1))}}function Fn(){return!!process.env.INVOCATION_ID||!!process.env.XPC_SERVICE_NAME?.includes(Ut)}var Gs=`EvryAI connector ${Z}
143
+
144
+ EVRYAI_CODE=CODE evryai-connect pair [--service] [--name NAME] --origin URL
145
+ evryai-connect run keep this machine connected (what the service runs)
146
+ evryai-connect status
147
+ evryai-connect remove [--all] disconnect from your computers
148
+ evryai-connect update
149
+ evryai-connect service install|uninstall
150
+ evryai-connect --version`,ct=process.argv.slice(2),js=process.env.EVRYAI_CODE??"";delete process.env.EVRYAI_CODE;var Po=e=>ct.includes(e);function Oo(e){let t=ct.indexOf(e);return t>=0?ct[t+1]:void 0}function C(e){process.exit(e)}function Zs(e){if(!e)return null;try{let t=new URL(e);return t.protocol==="https:"||t.protocol==="http:"?t.origin:null}catch{return null}}function zs(){try{return process.platform==="darwin"?`macOS ${Xn.release()}`:process.platform==="win32"?`Windows ${Xn.release()}`:/^PRETTY_NAME="?([^"\n]+)"?$/m.exec(W.readFileSync("/etc/os-release","utf8"))?.[1]?.slice(0,64)}catch{return}}var Js=()=>process.arch==="x64"?"x64":process.arch==="arm64"?"arm64":null,Ke=e=>({hostId:e.hostId,token:e.token});function Qs(e,t){return e===404?{text:"This command expired or was already used. Make a new one in EvryAI.",code:4}:e===409?{text:`This machine is connected to another EvryAI account. Remove it first: ${An}`,code:4}:e===504?{text:"Your computer didn't answer. Keep EvryAI open there and try again.",code:5}:e===429?{text:"Too many tries. Wait a minute and try again.",code:4}:e===403&&t==="limit"?{text:"Your account has as many machines as it can have. Remove one in EvryAI first.",code:4}:e===403&&t==="access"?{text:"Your EvryAI account can't use this right now.",code:4}:e===403?{text:"Your computer didn't accept this machine. Make a new command and try again.",code:5}:{text:"Couldn't reach EvryAI. Check this machine's connection and try again.",code:5}}function tc(e,t,n,r){return new Promise(o=>{let i=!1,s=u=>{i||(i=!0,clearTimeout(a),c.stop(),o(u))},a=setTimeout(()=>s("timeout"),r),c=new me({request:It(e,t),streamPath:"/api/remote/box/stream",sendPath:"/api/remote/box/send",links:()=>[],onDelivery:()=>{},onControl:u=>{(u.type==="approved"||u.type==="peer")&&u.l===n&&s("approved"),u.type==="revoked"&&u.l===n&&s("revoked")},onDown:u=>u.kind==="status"&&u.status===403?(s("revoked"),null):"backoff",log:u=>F(`pair: ${u}`)});c.start()})}async function ec(){let e=Ur(js),t=Zs(Oo("--origin"));(!e||!t)&&(K("That command doesn't look right. Make a new one in EvryAI."),C(4));let n=Js();(process.platform!=="linux"&&process.platform!=="darwin"&&process.platform!=="win32"||!n)&&(K("This works on Linux, macOS and Windows."),C(2)),process.platform==="win32"&&!Tn()&&(K(wo),C(2));let r=(Oo("--name")??Xn.hostname()).replace(/[\x00-\x1f\x7f]/g,"").trim().slice(0,64)||"machine",o=q();o&&o.links.length&&o.origin!==t&&(K(`This machine is connected to ${o.origin}. Remove it first: ${An}`),C(4));let i=o&&o.links.length?o:null;N("Pairing with your computer...");let s=`rl_${Co(16).toString("base64url")}`,a=Lr(e,s,x=>new Uint8Array(Co(x))),c=await It(t,null)("/api/remote/box/claim",{method:"POST",body:{routingId:e.routingId,linkId:s,boxKey:a.boxKey,name:r,platform:process.platform,arch:n,osRelease:zs(),version:Z,...i?{credential:`${i.hostId}.${i.token}`}:{}},timeoutMs:3e4}).catch(()=>null);if(!c?.ok){let x=c?(await c.json().catch(()=>null))?.error:void 0,f=Qs(c?.status??0,x);K(f.text),C(f.code)}let u=await c.json(),h=u.hostToken?{hostId:u.hostId,token:u.hostToken}:Ke(i),d,l;try{({key:d,checkCode:l}=a.finish(u))}catch{await It(t,h)(`/api/remote/box/links/${s}`,{method:"DELETE"}).catch(()=>null),K("Couldn't verify your computer. Make a new command and try again."),C(5)}await $t(()=>{let x=q(),f=x&&x.links.length&&x.hostId===h.hostId?x:{v:1,origin:t,hostId:h.hostId,token:h.token,links:[]};kt({...f,origin:t,links:[...f.links,{linkId:s,desktopHostId:u.desktopHostId,desktopName:u.desktopName,key:Buffer.from(d).toString("base64url"),addedAt:new Date().toISOString()}]})});let g=Wt();g&&te(g,"reload"),N(`Check code: ${l}`),N(`Choose Connect on "${u.desktopName}" to finish.`);let y=await tc(t,h,s,5*6e4);if(y!=="approved"&&(await $t(()=>{let x=q();if(!x)return;let f=x.links.filter(p=>p.linkId!==s);f.length?kt({...x,links:f}):De()}),y==="timeout"&&await It(t,h)(`/api/remote/box/links/${s}`,{method:"DELETE"}).catch(()=>null),g&&te(g,"reload"),K("Not allowed on your computer. Nothing was changed."),C(6)),await $t(()=>{let x=q();x&&kt({...x,links:x.links.map(f=>f.linkId===s?{...f,confirmed:!0}:f)})}),g&&te(g,"reload"),Po("--service")){let x=await Hn();x.kind&&(await $t(()=>{let f=q();f&&kt({...f,service:x.kind})}),x.note&&x.kind!=="cron"&&N(x.note),N(x.kind==="cron"?`Connected. ${x.note}`:"Connected. It runs in the background and starts again after a restart."),C(0)),x.note&&K(x.note)}g&&(N("Connected."),C(0)),N("Connected. Keep this terminal open, or run the command again with --service."),await Do()}async function Do(){let e=Wt();e&&e!==process.pid&&(N(`Already running (pid ${e}).`),C(0));let t=q();t?.links.length||(K("This machine isn't connected to a computer. Run the command from EvryAI to connect it."),C(0)),W.mkdirSync(V(),{recursive:!0,mode:448}),W.writeFileSync(Xt(),String(process.pid),{mode:384}),Fn()&&await new Promise(f=>setTimeout(f,Math.random()*5e3));let n=yo(),r=new Map,o=Ke(t),i=t.origin,s=!1,a=f=>c.wake(f),c=new me({request:It(i,o),streamPath:"/api/remote/box/stream",sendPath:"/api/remote/box/send",links:()=>[...r.values()],onDelivery:f=>r.get(f.l)?.receive(f.f),onControl:f=>{if(f.type==="approved")r.get(f.l)?.approve(),r.get(f.l)?.hello();else if(f.type==="hello-request")r.get(f.l)?.helloRequested();else if(f.type==="revoked")d(f.l);else if(f.type==="peer"){let p=r.get(f.l);p?.approve(),p?.setPeer(f.online),f.online&&p&&!p.up&&p.hello()}},onOpen:()=>{s=!1;for(let f of r.values())f.up||f.hello()},onDown:f=>f.kind!=="status"?"backoff":f.status===403&&f.error==="revoked"?(l("This machine was disconnected from EvryAI. The connector stopped."),null):f.status===403||f.status===401?(s||K("Your EvryAI account can't use this right now. Trying again in 10 minutes."),s=!0,10*6e4):"backoff",log:F}),u={wake:a,caps:n,revoked:f=>void d(f.l,`Removed from "${f.desktopName}". The connector stopped.`),upgrade:y,service:()=>t?.service};function h(f){for(let p of f.links){let b=r.get(p.linkId);if(b){p.confirmed&&!b.approved&&(b.approve(),c.streamOpen&&b.hello());continue}let m=new He(p,u);r.set(p.linkId,m),c.streamOpen&&m.hello()}for(let[p,b]of r)f.links.some(m=>m.linkId===p)||(b.close("revoked"),r.delete(p))}async function d(f,p){let b=r.get(f);if(!b)return;b.close("revoked"),r.delete(f);let m=await $t(()=>{let E=q();if(!E)return 0;let _=E.links.filter(R=>R.linkId!==f);return _.length&&kt({...E,links:_}),_.length});F(p??`link ${f.slice(0,8)} removed`),m===0&&await l(p??`Removed from "${b.desktopName}". The connector stopped.`)}async function l(f){for(let b of r.values())b.close("revoked");r.clear(),c.stop();let p=q()?.service;await $t(()=>De()).catch(()=>{}),W.rmSync(Xt(),{force:!0}),N(f),await Fe(p),C(0)}async function g(){c.stop();for(let f of r.values())f.close("closed");await new Promise(f=>setTimeout(f,300)),Wt()===process.pid&&W.rmSync(Xt(),{force:!0}),C(0)}async function y(f,p,b){let m=Lo(i,{version:f,url:p,sha256:b});if(m)return m;let E=await Uo(p,b,f);return E||(F(`updated to ${f}; restarting`),x(),null)}function x(){Fn()||(W.rmSync(Xt(),{force:!0}),qn()),g()}Ao(f=>{if(f==="restart")return x();let p=q();p&&(t=p,h(p))}),process.on("SIGTERM",()=>void g()),process.on("SIGINT",()=>void g()),h(t),F(`running ${Z} for ${r.size} computer(s), terminal: ${n.mode}`),c.start(),setInterval(()=>{},6e4)}function Lo(e,t){return!Ue.test(t.version)||!Pn.test(t.sha256)?"the update doesn't look right":t.url!==`${e}${Hr(t.version)}`?"the update isn't from this machine's EvryAI":kn(Z,t.version)?null:`it isn't newer than ${Z}`}async function Uo(e,t,n){let r=await fetch(e,{redirect:"error"}).catch(()=>null);if(!r?.ok)return"couldn't download it";let o=Buffer.from(await r.arrayBuffer());if(Ys("sha256").update(o).digest("hex")!==t)return"the download didn't match its checksum";let i=Kn.join(V(),"lib");W.mkdirSync(i,{recursive:!0,mode:448});let s=Kn.join(i,`connector-${n}.mjs`);W.writeFileSync(`${s}.tmp`,o,{mode:384}),W.renameSync(`${s}.tmp`,s);let a=l=>`'${l.replace(/'/g,"'\\''")}'`,c=Vt(),h=(W.existsSync(c)?W.readFileSync(c,"utf8"):"").match(/ (--use-system-ca) /)?.[1],d=process.platform==="win32"?`@echo off\r
151
+ rem Written by EvryAI. Runs the connector with the Node it was installed with.\r
152
+ "${process.execPath}"${h?` ${h}`:""} "${s}" %*\r
153
+ `:`#!/bin/sh
154
+ # Written by EvryAI. Runs the connector with the Node it was installed with.
155
+ [ -n "\${HTTPS_PROXY:-}\${https_proxy:-}" ] && export NODE_USE_ENV_PROXY=1
156
+ exec ${a(process.execPath)}${h?` ${h}`:""} ${a(s)} "$@"
157
+ `;return W.mkdirSync(Kn.dirname(c),{recursive:!0,mode:448}),W.writeFileSync(`${c}.tmp`,d,{mode:493}),W.renameSync(`${c}.tmp`,c),null}async function nc(){let e=q();e||(K("This machine isn't connected to a computer."),C(1));let t=await It(e.origin,Ke(e))("/api/remote/box/connector",{}).catch(()=>null),n=t?.ok?await t.json().catch(()=>null):null;if((typeof n?.version!="string"||typeof n.sha256!="string"||typeof n.url!="string")&&(K("Couldn't reach EvryAI. Check this machine's connection and try again."),C(5)),Ue.test(n.version)&&!kn(Z,n.version)){N(`Up to date (${Z}).`);return}let r;try{r=new URL(n.url,e.origin).toString()}catch{r=""}let o={version:n.version,url:r,sha256:n.sha256},i=Lo(e.origin,o)??await Uo(o.url,o.sha256,o.version);i&&(K(`Couldn't update: ${i}.`),C(3));let s=Wt();s&&te(s,"restart"),N(`Updated to ${n.version}.`)}async function rc(){let e=q();if(!e){N("This machine isn't connected to a computer.");return}let t=It(e.origin,Ke(e)),n=ct[1]&&ct[1]!=="--all"?ct[1]:null,r=Po("--all")||e.links.length<=1||!n,o=await(r?t("/api/remote/box/self",{method:"DELETE"}):t(`/api/remote/box/links/${n}`,{method:"DELETE"})).catch(()=>null);!o?.ok&&o?.status!==401&&o?.status!==403&&(K("Couldn't reach EvryAI, so nothing was removed. Try again when this machine is online."),C(5));let i=await $t(()=>{let a=q(),c=r?[]:(a?.links??[]).filter(u=>u.linkId!==n);return c.length&&a?kt({...a,links:c}):De(),c.length}),s=Wt();i===0?(s&&process.kill(s,"SIGTERM"),await Fe(e.service),W.rmSync(Xt(),{force:!0}),N("Removed. The connector stopped.")):(s&&te(s,"reload"),N("Removed."))}function oc(){let e=q();if(N(`EvryAI connector ${Z}`),!e?.links.length)return N("Not connected to a computer.");let t=Wt();N(t?`Running (pid ${t})${e.service?`, as a ${e.service} service`:", in a terminal"}.`:"Not running.");for(let n of e.links)N(` ${n.desktopName} since ${n.addedAt.slice(0,10)}`)}async function ic(){switch(ct[0]){case"--version":case"version":process.stdout.write(`${Z}
158
+ `);return;case"pair":return ec();case"run":return Do();case"status":return oc();case"remove":return rc();case"update":return nc();case"service":if(ct[1]==="install"){let e=await Hn();if(e.kind){let t=q();t&&kt({...t,service:e.kind})}return e.note&&N(e.note),C(e.kind?0:1)}if(ct[1]==="uninstall")return Fe(q()?.service);break}process.stdout.write(`${Gs}
159
+ `),C(ct.length?2:0)}ic().catch(e=>{K(`Something went wrong: ${e.message}`),F(e.stack??e.message),C(1)});
160
+ /*! Bundled license information:
161
+
162
+ @noble/hashes/esm/utils.js:
163
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
164
+
165
+ @noble/curves/esm/utils.js:
166
+ @noble/curves/esm/abstract/modular.js:
167
+ @noble/curves/esm/abstract/curve.js:
168
+ @noble/curves/esm/abstract/edwards.js:
169
+ @noble/curves/esm/ed25519.js:
170
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
171
+ */
package/package.json CHANGED
@@ -1,6 +1,37 @@
1
1
  {
2
2
  "name": "@pendral/connect",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.2",
4
+ "description": "Connect any Linux, macOS or Windows machine to EvryAI without SSH: one command, no open ports, end-to-end encrypted.",
5
+ "keywords": [
6
+ "evryai",
7
+ "pendral",
8
+ "remote development",
9
+ "coding agents",
10
+ "connector",
11
+ "ssh alternative",
12
+ "claude code",
13
+ "codex"
14
+ ],
15
+ "homepage": "https://evryai.app/download",
16
+ "license": "SEE LICENSE IN LICENSE",
17
+ "author": "Pendral, Inc.",
18
+ "type": "module",
19
+ "bin": {
20
+ "evryai-connect": "bin/evryai-connect.mjs"
21
+ },
22
+ "files": [
23
+ "bin",
24
+ "lib",
25
+ "assets",
26
+ "README.md",
27
+ "LICENSE"
28
+ ],
29
+ "engines": {
30
+ "node": ">=20.10.0"
31
+ },
32
+ "evryai": {
33
+ "connector": "1.0.1",
34
+ "sha256": "0a8982f0eac947e74599f98195d9bbde431a19aa43ceaf29005f9c86de9598d0",
35
+ "minNode": "20.10"
36
+ }
37
+ }