bitsrun 0.5.42 → 0.5.45

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/dist/npm.js ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ import{spawn as q,spawnSync as F}from"node:child_process";import{existsSync as K,mkdirSync as v,statSync as j,utimesSync as W,writeFileSync as J}from"node:fs";import{homedir as m}from"node:os";import{join as a}from"node:path";var P=n=>n.replace("://api.","://"),B=n=>n.replace("://api.","://get."),L=n=>`${n.replace("https://api.","wss://relay.")}/`;function y(n=process.env){let e=n.BITSRUN_API_URL||"https://api.bitsrun.com";if(/^https:\/\/api\.[a-z0-9.-]+$/.test(e))return{apiUrl:e,webUrl:P(e),getUrl:B(e),relayUrl:L(e)}}import{createHash as R,verify as C}from"node:crypto";import{chmodSync as D,existsSync as f,readdirSync as M,renameSync as b,rmSync as _,writeFileSync as $}from"node:fs";import{dirname as G,join as N}from"node:path";import{gunzipSync as O}from"node:zlib";var o=class extends Error{code;requestId;exitCode;constructor(e,t,i,r=1){super(t),this.code=e,this.requestId=i,this.exitCode=r}};var h=`-----BEGIN PUBLIC KEY-----
3
+ MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAu2TYAyWQW/cQhmG1AQSQ
4
+ KD9z21RFM7anRsUAlqPhcUe43UgDqEmS8qwWfVjd7OdjuvV5awWxzdAKSj/GVbgO
5
+ 9v4NlMdH67sLu21vFqaDvWfhVHLjs/Hi+uV2I0wf13A66xAizW7WsmWKF+VUc+ym
6
+ dIxFdnJgIqJ3Mi6qN/KxmPaVxFM/5KUCZ9pHKox4pkBLuq77hnWCN3V9I0Eyxy7j
7
+ pab8IteqRiRuz3C7O+WPa0erXAyD0yJCy8AmMpATSSswc6MPT0vvppy3atdnbVgT
8
+ 0oe/zzIrLe1jR5Z28LKTpp7coMELTfSqSfCSnyNcMM4N5E9M+hJWpLDzAvVrdEOK
9
+ SpbTE14XKyVHd7Mx3co5fPoQ0+PheSrQMhmJvDKgG/hGRcyVFlMvVpPZU8JPHS+V
10
+ E6W4GcnFnsNvkhlzWfsqJ/Zo945xDszsngPaaT8HxcQRgaEmGqgUhR7ddfM/STif
11
+ ++wvSDIsGOMVr3BCJMjDdT0ymZuDDOPgLyiJja5jV/gLAgMBAAE=
12
+ -----END PUBLIC KEY-----
13
+ `;function w(n=process.platform,e=process.arch,t=z()){if(!(e!=="x64"&&e!=="arm64")){if(n==="darwin")return`bitsrun-darwin-${e}.gz`;if(n==="win32")return e==="x64"?"bitsrun-windows-x64.exe.gz":void 0;if(n==="linux")return`bitsrun-linux-${e}${t?"-musl":""}.gz`}}function z(){if(process.platform!=="linux")return!1;try{return M("/lib").some(n=>n.startsWith("ld-musl-"))}catch{return!1}}function S(n,e){let t=n.split(".").map(Number),i=e.split(".").map(Number);for(let r=0;r<3;r++)if((t[r]??0)!==(i[r]??0))return(t[r]??0)>(i[r]??0);return!1}var H=(n,e)=>n.split(`
14
+ `).map(t=>t.trim().split(/\s+/)).find(t=>t[1]===e)?.[0];function V(n,e,t=h){try{return C("sha256",n,t,e)}catch{return!1}}async function E(n,e=12e4){let t;try{t=await fetch(n,{signal:AbortSignal.timeout(e)})}catch{throw new o("offline","We could not reach bitsrun.com to check for updates. Check your connection and try again.")}if(!t.ok)throw new o("update_unavailable","The update is not available right now. Try again in a few minutes.");return t}async function T(n,e){let t=await(await E(`${n}/latest.json`,e)).json();if(typeof t.version!="string"||!/^\d+\.\d+\.\d+$/.test(t.version))throw new o("update_unavailable","The update is not available right now. Try again in a few minutes.");return t.version}async function x(n,e,t){let i=l=>E(`${n}/${e}/${l}`).then(async d=>Buffer.from(await d.arrayBuffer())),[r,s,c]=await Promise.all([i(t),i("SHA256SUMS.txt"),i("SHA256SUMS.txt.sig")]);if(!V(s,c))throw new o("signature_mismatch","We could not confirm this update came from BitsRun, so nothing was changed. Try again later, or write to support@bitsrun.com.");let u=H(s.toString("utf8"),t),p=R("sha256").update(r).digest("hex");if(!u||u!==p)throw new o("checksum_mismatch","The download did not match its checksum, so nothing was changed. Try again, or write to support@bitsrun.com.");return O(r)}function I(n,e){let t=N(G(e),`.bitsrun-${process.pid}.new`);$(t,n,{mode:493});try{D(t,493)}catch{}if(process.platform==="win32"&&f(e)){let i=`${e}.old`;try{f(i)&&_(i,{force:!0})}catch{}b(e,f(i)?`${e}.${process.pid}.old`:i)}b(t,e)}var Q=24*36e5,Y=3e3;function Z(n=process.env,e=process.platform){return n.BITSRUN_CACHE_DIR?n.BITSRUN_CACHE_DIR:e==="win32"?a(n.LOCALAPPDATA||a(m(),"AppData","Local"),"bitsrun"):e==="darwin"?a(m(),"Library","Caches","bitsrun"):a(n.XDG_CACHE_HOME||a(m(),".cache"),"bitsrun")}var X=n=>{let e=F(n,["--version"],{encoding:"utf8",timeout:1e4,windowsHide:!0});return e.status===0?e.stdout.trim():void 0};async function U(n,e=Date.now()){let t=w();if(!t||process.env.BITSRUN_NPM_JS==="1")return;let i=a(Z(),"bin"),r=a(i,process.platform==="win32"?"bitsrun.exe":"bitsrun"),s=a(i,"checked"),c=K(r),u=(()=>{try{return j(s).mtimeMs}catch{return 0}})();if(c&&e-u<Q)return r;let p=y(process.env);if(!p)return c?r:void 0;let l=`${p.getUrl}/download/cli`;try{let d=await T(l,c?Y:void 0),g=c?X(r):void 0;return(!g||S(d,g))&&(n.err(g?`Updating bitsrun ${g} to ${d}...`:`Downloading bitsrun ${d} for this computer (first run only)...`),v(i,{recursive:!0,mode:448}),I(await x(l,d,t),r)),v(i,{recursive:!0,mode:448}),J(s,d),W(s,new Date(e),new Date(e)),r}catch{if(c)return r;n.err("Could not download the bitsrun app for this computer, so the npm copy runs this time. It tries again next time.");return}}function A(n,e){let t=q(n,e,{stdio:"inherit",windowsHide:!1}),i=r=>()=>{t.exitCode===null&&t.kill(r)};process.on("SIGINT",()=>{}),process.on("SIGTERM",i("SIGTERM")),process.on("SIGHUP",i("SIGHUP")),t.on("error",()=>{process.stderr.write(`Could not start ${n}. Delete it and run bitsrun again, or write to support@bitsrun.com.
15
+ `),process.exit(1)}),t.on("exit",(r,s)=>{process.exit(r??(s?128+({SIGINT:2,SIGTERM:15,SIGHUP:1}[s]??1):1))})}var k=await U({err:n=>process.stderr.write(`${n}
16
+ `)});k?A(k,process.argv.slice(2)):await import(new URL("./bitsrun.js",import.meta.url).href);
package/package.json CHANGED
@@ -1,16 +1,22 @@
1
1
  {
2
2
  "name": "bitsrun",
3
- "version": "0.5.42",
3
+ "version": "0.5.45",
4
4
  "description": "Deploy open AI models as private, scale-to-zero APIs billed per second.",
5
- "license": "UNLICENSED",
5
+ "license": "SEE LICENSE IN LICENSE.md",
6
6
  "homepage": "https://bitsrun.com",
7
+ "bugs": {
8
+ "email": "support@bitsrun.com"
9
+ },
10
+ "author": "Web Bits",
7
11
  "type": "module",
8
12
  "bin": {
9
- "bitsrun": "dist/bitsrun.js"
13
+ "bitsrun": "dist/npm.js"
10
14
  },
11
15
  "files": [
16
+ "dist/npm.js",
12
17
  "dist/bitsrun.js",
13
- "README.md"
18
+ "README.md",
19
+ "LICENSE.md"
14
20
  ],
15
21
  "engines": {
16
22
  "node": ">=22"