Lines 1-21javascript
2import{t as e}from"./chunk-C8PTHxhX.mjs";import{node as t}from"@elysiajs/node";import{Elysia as n,file as r,sse as i,t as a}from"elysia";import o,{createHash as s,randomUUID as c}from"node:crypto";import l from"node:path";import*as u from"node:stream/web";import{ReadableStream as d}from"node:stream/web";import f,{mkdir as p,open as m,readFile as h,readdir as g,rename as _,stat as v,unlink as y,writeFile as b}from"node:fs/promises";import x from"node:os";import{gguf as S}from"@huggingface/gguf";import{getBackendDevicesInfo as C,isLibVariantAvailable as w,loadModel as T}from"@fugood/llama.node"; ...
3`);this.buffer=t.pop();for(let e of t)if(e.trim())try{this.handleMessage(JSON.parse(e))}catch(t){console.error(`[mlx-llm] Failed to parse bridge message:`,e,t)}}),this.readyPromise=new Promise((e,t)=>{this.pendingRequests.set(`__init__`,{resolve:()=>e(),reject:t}),setTimeout(()=>t(Error(`Bridge startup timeout`)),3e4)}),this.readyPromise}handleMessage(e){let t=this.pendingRequests.get(e.id);t&&(e.error?(t.reject(Error(e.error.message)),this.pendingRequests.delete(e.id)):e.event?e.event===`result`?(t.resolve(e.data),this.pendingRequests.delete(e.id)):t.onEvent?.(e.event,e.data):e.result!==void ...
HighChild Process
Package source references child process execution.
lib/index.mjsView on unpkg · L1 HighSame File Env Network Execution
A single source file combines environment access, network access, and code or shell execution; review context before blocking.
lib/index.mjsView on unpkg · L1 HighCommand Output Exfiltration
Source combines command execution, command-output handling, and outbound requests; review data flow before blocking.
lib/index.mjsView on unpkg · L1 4`)}kill(){this.process&&=(this.process.kill(),null),this.pendingRequests.clear()}get alive(){return this.process!=null&&!this.process.killed}};function Fr(){let e=[];return process.platform!==`darwin`&&e.push(`MLX requires macOS (Apple Silicon)`),x.arch()!==
5from huggingface_hub import snapshot_download
6path = snapshot_download("${s}", revision="${o.model.revision||`main`}")
8`.trim(),a={...process.env};o.runtime.huggingface_token&&(a.HF_TOKEN=o.runtime.huggingface_token);let c=await G(t,[`-c`,n],{timeout:6e5,env:a});r?.(1);let u=c.stdout.trim().split(`
9`).pop();i?.({localPath:u,repoId:s,alreadyExists:!1})}catch(e){throw a?.(e),e}finally{t?.deleteDownload(u)}})();return t?.setDownload(u,d),{started:!0,localPath:null,repoId:s}}async function K(e,t=null,n={}){if(e===`ggml-llm`)return Cn(t,n);if(e===`ggml-stt`)return ur(t,n);if(e===`mlx-llm`)return Wr(t,n);throw Error(`Unknown backend type: ${e}`)}const Kr=(e={},t={})=>{let n=Array.isArray(e)?[...e]:{...e};return Object.entries(t||{}).forEach(([e,t])=>{t&&typeof t==`object`&&!Array.isArray(t)?n[e]=Kr(n[e]||{},t):n[e]=t}),n},q=(e=null,t)=>{let{server:n,generators:r=[],...i}=e||{},a=e=>Kr(structur ...
10`),n.push(`${J} v${Y}`),n.push(`## Model Capabilities Comparison
11`),(!e||e.length===0)&&(console.error(`Error: No model IDs provided`),process.exit(1));try{let{globalDefaults:r,resolveDefaultConfig:i}=q(t,`ggml-llm`),a=[];for(let t=0;t<e.length;t+=1){let n=e[t];console.log(`[${t+1}/${e.length}] Analyzing ${n}...`);let o=i(n);o={...o||{},model:{...
13### System Information`);let c=null;if(process.platform!==`win32`)try{c=O(`uname -a`,{encoding:`utf8`}).trim()}catch{}if(c?n.push(`- **System:** ${c}`):(n.push(`- **Hostname:** ${x.hostname()}`),n.push(`- **OS:** ${x.type()} ${x.release()}`)),n.push(`- **Platform:** ${process
14### Command Used`);let u=process.argv.slice(2).join(` `);if(n.push(`\`\`\`bash\n${process.argv[0]} ${process.argv[1]} ${u}\n\`\`\``),n.push(`
15### Package Information`),n.push(`- **Name:** ${J}`),n.push(`- **Version:** ${Y}`),qr.description&&n.push(`- **Description:** ${qr.description}`),t&&Object.keys(t).length>0){n.push(`
16### Configuration`),n.push(`<details>`),n.push(`<summary>Click to expand TOML configuration</summary>`),n.push("\n```toml");try{let e=A.stringify(t);n.push(e)}catch{n.push(`# Error serializing config`),n.push(JSON.stringify(t,null,2))}n.push("```"),n.push(`</details>`)}let d=`ggml-llm-model-capabilities-${new Date().toISOString().replace(/[.:]/g,`-`).split(`T`)[0]}.md`,f=l.join(process
17`),`utf8`),console.log(`\nModel capabilities table saved to: ${f}`),process.exit(0)}catch(e){console.error(`Failed to generate model table:`,e.message),process.exit(1)}}async function Xr({modelId:e=null,defaultConfig:t=null}={}){console.log(`${J} v${Y}`),console.log(`Testing capabilities for backend: ggml-llm`),e&&console.log(`Model: ${e}`),console.log(`--------------------------------`);try{let{resolveDefaultConfig:n}=q(t,`ggml-llm`),r=n(e);e&&(r={...r||{},model:{...r?.model||{},repo_id:e}});let i=await K(`ggml-llm`,null,{config:r,includeBreakdown:!0}),a=i.buttress?.selected||null,o=i.modelCo ...
18=== Model Information ===`);let t=e||o?.repoId;console.log(`Repository ID: ${t}`),o?.quantization&&console.log(`Quantization: ${o.quantization}`),o?.nCtx&&console.log(`Context Length: ${o.nCtx}`),a?.quantization?.name&&console.log(`Model Quantization: ${a.quantization.name.toUpperCase()}`);let n=o?.cache_type_k
19=== Hardware Information ===`);let t=null;if(process.platform!==`win32`)try{t=O(`uname -a`,{encoding:`utf8`}).trim()}catch{}t?console.log(`System: ${t}`):(console.log(`Hostname: ${x.hostname()}`),console.log(`OS: ${x.type()} ${x.release()}`)),console.log(`Platform: ${e.platform}`),console.log(`CPU Cores: $
20--- GPU Details ---`),e.devices.filter(e=>e.type===`gpu`).forEach(t=>{console.log(`GPU Backend: ${t.backend}`),console.log(`GPU Name: ${t.deviceName}`),console.log(`GPU Total Memory: ${(t.maxMemorySize/1024/1024/1024).
21--- Model Fit Analysis ---`),console.log(`Fits in GPU: ${e.fit.fitsInGpu?`Yes`:`No`}`),console.log(`Fits in CPU: ${e.fit.fitsInCpu?`Yes`:`No`}`),console.log(`Limiting Factor: ${e.fit.limiting}`),e.limitedFit&&(console.log(`
Long lines were clipped for display.