glance-cli 0.10.9 → 0.10.10

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.
Files changed (2) hide show
  1. package/dist/cli.js +2 -2
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -894,7 +894,7 @@ ${E.message}`:x,K1=[D1,Q,A].filter(Boolean).join(`
894
894
  `:`
895
895
  `)+B,C=E+1,E=A.indexOf(`
896
896
  `,C)}while(E!==-1);return U+=A.slice(C),U}var{stdout:xkA,stderr:hkA}=vkA,J1A=Symbol("GENERATOR"),y11=Symbol("STYLER"),lB1=Symbol("IS_EMPTY"),fkA=["ansi","ansi","ansi256","ansi16m"],x11=Object.create(null),Fx2=(A,Q={})=>{if(Q.level&&!(Number.isInteger(Q.level)&&Q.level>=0&&Q.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let B=xkA?xkA.level:0;A.level=Q.level===void 0?B:Q.level};var Ex2=(A)=>{let Q=(...B)=>B.join(" ");return Fx2(Q,A),Object.setPrototypeOf(Q,iB1.prototype),Q};function iB1(A){return Ex2(A)}Object.setPrototypeOf(iB1.prototype,Function.prototype);for(let[A,Q]of Object.entries(Ij))x11[A]={get(){let B=kw1(this,U1A(Q.open,Q.close,this[y11]),this[lB1]);return Object.defineProperty(this,A,{value:B}),B}};x11.visible={get(){let A=kw1(this,this[y11],!0);return Object.defineProperty(this,"visible",{value:A}),A}};var I1A=(A,Q,B,...E)=>{if(A==="rgb"){if(Q==="ansi16m")return Ij[B].ansi16m(...E);if(Q==="ansi256")return Ij[B].ansi256(Ij.rgbToAnsi256(...E));return Ij[B].ansi(Ij.rgbToAnsi(...E))}if(A==="hex")return I1A("rgb",Q,B,...Ij.hexToRgb(...E));return Ij[B][A](...E)},Cx2=["rgb","hex","ansi256"];for(let A of Cx2){x11[A]={get(){let{level:B}=this;return function(...E){let C=U1A(I1A(A,fkA[B],"color",...E),Ij.color.close,this[y11]);return kw1(this,C,this[lB1])}}};let Q="bg"+A[0].toUpperCase()+A.slice(1);x11[Q]={get(){let{level:B}=this;return function(...E){let C=U1A(I1A(A,fkA[B],"bgColor",...E),Ij.bgColor.close,this[y11]);return kw1(this,C,this[lB1])}}}}var Yx2=Object.defineProperties(()=>{},{...x11,level:{enumerable:!0,get(){return this[J1A].level},set(A){this[J1A].level=A}}}),U1A=(A,Q,B)=>{let E,C;if(B===void 0)E=A,C=Q;else E=B.openAll+A,C=Q+B.closeAll;return{open:A,close:Q,openAll:E,closeAll:C,parent:B}},kw1=(A,Q,B)=>{let E=(...C)=>Jx2(E,C.length===1?""+C[0]:C.join(" "));return Object.setPrototypeOf(E,Yx2),E[J1A]=A,E[y11]=Q,E[lB1]=B,E},Jx2=(A,Q)=>{if(A.level<=0||!Q)return A[lB1]?"":Q;let B=A[y11];if(B===void 0)return Q;let{openAll:E,closeAll:C}=B;if(Q.includes("\x1B"))while(B!==void 0)Q=gkA(Q,B.close,B.open),B=B.parent;let U=Q.indexOf(`
897
- `);if(U!==-1)Q=ykA(Q,C,E,U);return E+Q+C};Object.defineProperties(iB1.prototype,x11);var Ix2=iB1(),H74=iB1({level:hkA?hkA.level:0});var c6=Ix2;class Uj extends Error{code;userMessage;recoverable;hint;constructor(A,Q,B,E=!1,C){super(A);this.code=Q;this.userMessage=B;this.recoverable=E;this.hint=C;this.name="GlanceError"}}var h11={INVALID_URL:"INVALID_URL",INVALID_LANGUAGE:"INVALID_LANGUAGE",INVALID_MAX_TOKENS:"INVALID_MAX_TOKENS",API_KEY_MISSING:"API_KEY_MISSING",API_KEY_INVALID:"API_KEY_INVALID",FETCH_FAILED:"FETCH_FAILED",CONTENT_TOO_LARGE:"CONTENT_TOO_LARGE",SUMMARIZE_FAILED:"SUMMARIZE_FAILED",CACHE_ERROR:"CACHE_ERROR",VOICE_SYNTHESIS_FAILED:"VOICE_SYNTHESIS_FAILED",SCREENSHOT_FAILED:"SCREENSHOT_FAILED",EXPORT_FAILED:"EXPORT_FAILED"};class kkA{level="info";setLevel(A){this.level=A}getLevel(){return this.level}debug(...A){if(this.level==="debug")console.log(c6.gray("[DEBUG]"),...A)}info(...A){if(["debug","info"].includes(this.level))console.log(c6.blue("[INFO]"),...A)}warn(...A){if(["debug","info","warn"].includes(this.level))console.warn(c6.yellow("[WARN]"),...A)}error(...A){console.error(c6.red("[ERROR]"),...A)}}var bX=new kkA;var jO={VERSION:"0.10.9",MAX_CONTENT_SIZE:10485760,FETCH_TIMEOUT:30000,RETRY_ATTEMPTS:3,RETRY_DELAY:1000,OLLAMA_ENDPOINT:process.env.OLLAMA_ENDPOINT||"http://localhost:11434"},f11={en:"English",fr:"French",es:"Spanish",ht:"Haitian Creole"},$74=Object.keys(f11);function _kA(){console.log(`
897
+ `);if(U!==-1)Q=ykA(Q,C,E,U);return E+Q+C};Object.defineProperties(iB1.prototype,x11);var Ix2=iB1(),H74=iB1({level:hkA?hkA.level:0});var c6=Ix2;class Uj extends Error{code;userMessage;recoverable;hint;constructor(A,Q,B,E=!1,C){super(A);this.code=Q;this.userMessage=B;this.recoverable=E;this.hint=C;this.name="GlanceError"}}var h11={INVALID_URL:"INVALID_URL",INVALID_LANGUAGE:"INVALID_LANGUAGE",INVALID_MAX_TOKENS:"INVALID_MAX_TOKENS",API_KEY_MISSING:"API_KEY_MISSING",API_KEY_INVALID:"API_KEY_INVALID",FETCH_FAILED:"FETCH_FAILED",CONTENT_TOO_LARGE:"CONTENT_TOO_LARGE",SUMMARIZE_FAILED:"SUMMARIZE_FAILED",CACHE_ERROR:"CACHE_ERROR",VOICE_SYNTHESIS_FAILED:"VOICE_SYNTHESIS_FAILED",SCREENSHOT_FAILED:"SCREENSHOT_FAILED",EXPORT_FAILED:"EXPORT_FAILED"};class kkA{level="info";setLevel(A){this.level=A}getLevel(){return this.level}debug(...A){if(this.level==="debug")console.log(c6.gray("[DEBUG]"),...A)}info(...A){if(["debug","info"].includes(this.level))console.log(c6.blue("[INFO]"),...A)}warn(...A){if(["debug","info","warn"].includes(this.level))console.warn(c6.yellow("[WARN]"),...A)}error(...A){console.error(c6.red("[ERROR]"),...A)}}var bX=new kkA;var jO={VERSION:"0.10.10",MAX_CONTENT_SIZE:10485760,FETCH_TIMEOUT:30000,RETRY_ATTEMPTS:3,RETRY_DELAY:1000,OLLAMA_ENDPOINT:process.env.OLLAMA_ENDPOINT||"http://localhost:11434"},f11={en:"English",fr:"French",es:"Spanish",ht:"Haitian Creole"},$74=Object.keys(f11);function _kA(){console.log(`
898
898
  ${c6.bold("glance")} v${jO.VERSION} – AI-powered web reader
899
899
 
900
900
  ${c6.bold("Usage:")}
@@ -1267,7 +1267,7 @@ ${U}`,E}async function YJA(A,Q){Cd6(Q.language);let B=CJA(Q.model),E=Yd6(A,Q);sw
1267
1267
 
1268
1268
  `).forEach((H)=>{if(H.trim())U.push(` <p>${C(H).replace(/\n/g,"<br>")}</p>`)}),U.push(" </div>"),Q.includeTimestamp)U.push(' <div class="footer">'),U.push(` <p>Generated: ${new Date().toLocaleString()}</p>`),U.push(" </div>");return U.push("</body>"),U.push("</html>"),U.join(`
1269
1269
  `)}function Nd6(A,Q){let B=[],E=Q.customQuestion?"ANSWER":(Q.customTitle||"SUMMARY").toUpperCase();if(B.push(E),B.push("=".repeat(E.length)),B.push(""),Q.customQuestion)B.push(`Question: ${Q.customQuestion}`),B.push("");B.push(`Source: ${Q.url}`);let C=Q.metadata;if(C.title)B.push(`Title: ${C.title}`);if(Q.includeMetadata){if(C.author)B.push(`Author: ${C.author}`);if(C.publishDate)B.push(`Published: ${C.publishDate}`)}if(B.push(""),B.push("-".repeat(60)),B.push(""),B.push(A),Q.includeTimestamp)B.push(""),B.push("-".repeat(60)),B.push(`Generated: ${new Date().toISOString()}`);return B.join(`
1270
- `)}function lg1(A,Q){if(!A||typeof A!=="string")throw new Error("Summary must be a non-empty string");if(!Q||typeof Q!=="object")throw new Error("Options must be an object");if(!Q.url)throw new Error("URL is required in options");let B=A.trim();if($b(B))console.error("⚠️ Binary artifacts detected in summary, applying nuclear cleaning..."),B=zb(B);else B=B.replace(/\b(console|warn|error|log|TextDecoder|Buffer|ArrayBuffer)\b/gi,"").replace(/\b(cache|hits|lastAccessed|accessCount|Decompression)\b/gi,"").replace(/\b0x[0-9A-Fa-f]+/g,"").replace(/ {2,}/g," ").replace(/\t/g," ").trim();let E=Xd6(Q.url),C=Vd6(Q.metadata),U="terminal";if(Q.format)U=Q.format;else if(Q.json)U="json";else if(Q.markdown)U="markdown";let X={format:U,markdown:Q.markdown??!1,json:Q.json??!1,metadata:C,url:E,customQuestion:Q.customQuestion||"",includeMetadata:Q.includeMetadata??!1,includeTimestamp:Q.includeTimestamp??!1,model:Q.model||"",processingTime:Q.processingTime||0,fromCache:Q.fromCache||!1,compact:Q.compact??!1,customTitle:Q.customTitle||"",isFullContent:Q.isFullContent??!1},H;switch(U){case"markdown":H=Gd6(B,X);break;case"json":H=Hd6(B,X);break;case"html":H=Kd6(B,X);break;case"plain":H=Nd6(B,X);break;case"terminal":default:H=Wd6(B,X);break}return H}import Vj0 from"node:path";var Lb={DEFAULT_TIMEOUT:30000,PAGE_LOAD_TIMEOUT:20000,VIEWPORT_WIDTH:1920,VIEWPORT_HEIGHT:1080,DEFAULT_FORMAT:"png",JPEG_QUALITY:90,MAX_RETRIES:2,RETRY_DELAY:1000};class sG extends Error{code;userMessage;hint;constructor(A,Q,B,E){super(A);this.code=Q;this.userMessage=B;this.hint=E;this.name="ScreenshotError"}}function Wj0(A){switch(Vj0.extname(A).toLowerCase()){case".jpg":case".jpeg":return"jpeg";case".webp":return"webp";case".png":default:return"png"}}function Md6(A){try{let Q=new URL(A);if(!["http:","https:"].includes(Q.protocol))throw new Error("Invalid protocol")}catch{throw new sG(`Invalid URL: ${A}`,"INVALID_URL","Invalid URL format","URL must start with http:// or https://")}}function zd6(A){let Q=Vj0.extname(A).toLowerCase(),B=[".png",".jpg",".jpeg",".webp"];if(!B.includes(Q))throw new sG(`Invalid file extension: ${Q}`,"INVALID_EXTENSION","Unsupported image format",`Supported formats: ${B.join(", ")}`)}async function $d6(A){try{return await A.default.launch({headless:!0,args:["--no-sandbox","--disable-setuid-sandbox","--disable-dev-shm-usage","--disable-accelerated-2d-canvas","--no-first-run","--no-zygote","--disable-gpu"],timeout:1e4})}catch(Q){if(Q.message?.includes("Could not find")||Q.message?.includes("Chromium"))throw new sG(Q.message,"BROWSER_NOT_FOUND","Chromium browser not found","Puppeteer's Chromium is missing. Reinstall: bun install puppeteer");throw new sG(Q.message,"BROWSER_LAUNCH_FAILED","Failed to launch browser","Check if you have enough system resources (memory, disk space)")}}async function Gj0(A,Q,B,E=1){let C,U;try{C=await $d6(B),U=await C.newPage(),await U.setViewport({width:Q.width,height:Q.height,deviceScaleFactor:1}),U.setDefaultTimeout(Q.timeout),U.setDefaultNavigationTimeout(Lb.PAGE_LOAD_TIMEOUT);try{await U.goto(A,{waitUntil:Q.waitUntil,timeout:Lb.PAGE_LOAD_TIMEOUT})}catch(N){if(N.message?.includes("net::ERR_NAME_NOT_RESOLVED"))throw new sG(N.message,"DNS_ERROR","Cannot resolve domain name",`Check if ${new URL(A).hostname} is accessible`);if(N.message?.includes("net::ERR_CONNECTION_REFUSED"))throw new sG(N.message,"CONNECTION_REFUSED","Connection refused","The server is not accepting connections. Check if the URL is correct.");if(N.message?.includes("Timeout")||N.message?.includes("timeout"))throw new sG(N.message,"PAGE_TIMEOUT","Page took too long to load","The page is slow or unresponsive. Try again or check your connection.");throw new sG(N.message,"NAVIGATION_ERROR","Failed to load page","The page may be blocking automated access or has loading issues.")}let X=Wj0(Q.filePath),H={path:Q.filePath,fullPage:Q.fullPage,type:X};if(X==="jpeg"||X==="webp")H.quality=Q.quality;await U.screenshot(H),await U.close(),await C.close()}catch(X){if(U)try{await U.close()}catch{}if(C)try{await C.close()}catch{}if(X instanceof sG&&X.code==="PAGE_TIMEOUT"){if(E<Lb.MAX_RETRIES){let H=Lb.RETRY_DELAY*Math.pow(2,E-1);return await new Promise((N)=>setTimeout(N,H)),Gj0(A,Q,B,E+1)}}if(X instanceof sG)throw X;throw new sG(X.message||"Unknown error","SCREENSHOT_FAILED","Screenshot capture failed","An unexpected error occurred. Try again or check the URL.")}}async function Hj0(A,Q={}){let B=typeof Q==="string"?{filePath:Q}:Q,E={filePath:B.filePath||"screenshot.png",fullPage:B.fullPage??!0,width:B.width||Lb.VIEWPORT_WIDTH,height:B.height||Lb.VIEWPORT_HEIGHT,quality:B.quality||Lb.JPEG_QUALITY,timeout:B.timeout||Lb.DEFAULT_TIMEOUT,waitUntil:B.waitUntil||"networkidle2"};if(Md6(A),zd6(E.filePath),E.width<=0||E.height<=0)throw new sG("Invalid dimensions","INVALID_DIMENSIONS","Width and height must be positive","Use values like width: 1920, height: 1080");let C=Wj0(E.filePath);if((C==="jpeg"||C==="webp")&&(E.quality<0||E.quality>100))throw new sG("Invalid quality","INVALID_QUALITY","Quality must be between 0-100","Use values like quality: 90");try{let U=await Promise.resolve().then(() => (w5A(),$5A));await Gj0(A,E,U)}catch(U){throw new sG(`Puppeteer not available: ${U.message}`,"PUPPETEER_MISSING","Screenshot functionality unavailable","Install Puppeteer: npm install puppeteer")}}var _52=u7(f52(),1);import{spawn as Vm}from"child_process";import{writeFile as H54,unlink as K54}from"fs/promises";import{tmpdir as N54}from"os";import{join as M54}from"path";var Wm={en:{alloy:"21m00Tcm4TlvDq8ikWAM",echo:"jsCqWAovK2LkecY7zXl4",nova:"IKne3meq5aSn9XLyUdCD",shimmer:"LcfcDJNUP1GQjkzn1xUU",onyx:"N2lVS1w4EtoT3dr4eOWO",fable:"jBpfuIE2acCO8z3wKNLl",default:"21m00Tcm4TlvDq8ikWAM"},fr:{antoine:"ErXwobaYiN019PkySvjV",charlotte:"XB0fDUnXU5powFXDhCwa",henri:"qhFERWI2CUBNq3XOLfRE",marie:"VR6AewLTigWG4xSOukaG",default:"XB0fDUnXU5powFXDhCwa"},es:{antonio:"gcLjJkVW4MZ7xQjpwQrO",isabella:"TxGEqnHWrfWFTfGW9XjX",pablo:"flq6f7yk4E4fJM5XTYuZ",sofia:"pMsXgVXv3BLzUgSXRplE",default:"TxGEqnHWrfWFTfGW9XjX"},ht:{default:"21m00Tcm4TlvDq8ikWAM"}},pU1={alloy:"21m00Tcm4TlvDq8ikWAM",echo:"jsCqWAovK2LkecY7zXl4",nova:"IKne3meq5aSn9XLyUdCD",shimmer:"LcfcDJNUP1GQjkzn1xUU",onyx:"N2lVS1w4EtoT3dr4eOWO",fable:"jBpfuIE2acCO8z3wKNLl"},k52={en:"eleven_monolingual_v1",fr:"eleven_multilingual_v2",es:"eleven_multilingual_v2",ht:"eleven_multilingual_v2",default:"eleven_monolingual_v1"};class b52{client;apiKey;constructor(A){if(this.apiKey=A||process.env.ELEVENLABS_API_KEY,this.apiKey)this.client=new _52.ElevenLabsClient({apiKey:this.apiKey})}async synthesize(A,Q={}){let B=this.cleanTextForSpeech(A);if(this.client&&this.apiKey)try{return await this.synthesizeWithElevenLabs(B,Q)}catch(E){console.warn(c6.yellow("⚠️ ElevenLabs failed, falling back to local TTS")),console.error(E)}return await this.synthesizeWithLocalTTS(B,Q)}async synthesizeCleanedText(A,Q={}){if(this.client&&this.apiKey)try{return await this.synthesizeWithElevenLabs(A,Q)}catch(B){console.warn(c6.yellow("⚠️ ElevenLabs failed, falling back to local TTS")),console.error(B)}return await this.synthesizeWithLocalTTS(A,Q)}async synthesizeWithElevenLabs(A,Q){if(!this.client)throw new Error("ElevenLabs client not initialized");try{let{voiceId:B,model:E,voiceSettings:C}=this.getOptimalVoiceConfig(Q),U=await this.client.generate({voice:B,text:A,model_id:E,voice_settings:C}),X=[];for await(let w of U)X.push(Buffer.from(w));let H=Buffer.concat(X),N=Q.outputFile||M54(N54(),`glance-audio-${Date.now()}.mp3`);if(await H54(N,H),!Q.outputFile)await this.playAudio(N),setTimeout(()=>K54(N).catch(()=>{}),5000);return{success:!0,outputFile:N}}catch(B){return{success:!1,error:B instanceof Error?B.message:"Unknown error"}}}async synthesizeWithLocalTTS(A,Q){let B=process.platform;try{if(B==="darwin")return await this.useMacOSSay(A,Q);else if(B==="win32")return await this.useWindowsTTS(A,Q);else return await this.useLinuxTTS(A,Q)}catch(E){return{success:!1,error:`Local TTS failed: ${E instanceof Error?E.message:"Unknown error"}`}}}async useMacOSSay(A,Q){return new Promise((B)=>{let E=[];if(Q.voice)E.push("-v",Q.voice);if(Q.outputFile)E.push("-o",Q.outputFile);E.push(A);let C=Vm("say",E);C.on("error",(U)=>{B({success:!1,error:`macOS say command failed: ${U.message}`})}),C.on("close",(U)=>{if(U===0)B({success:!0,outputFile:Q.outputFile});else B({success:!1,error:`macOS say command exited with code ${U}`})})})}async useWindowsTTS(A,Q){return new Promise((B)=>{let E=`
1270
+ `)}function lg1(A,Q){if(!A||typeof A!=="string")throw new Error("Summary must be a non-empty string");if(!Q||typeof Q!=="object")throw new Error("Options must be an object");if(!Q.url)throw new Error("URL is required in options");let B=A.trim();if($b(B))console.error("⚠️ Binary artifacts detected in summary, applying nuclear cleaning..."),B=zb(B);else B=B.replace(/\b(console|warn|error|log|TextDecoder|Buffer|ArrayBuffer)\b/gi,"").replace(/\b(cache|hits|lastAccessed|accessCount|Decompression)\b/gi,"").replace(/\b0x[0-9A-Fa-f]+/g,"").replace(/ {2,}/g," ").replace(/\t/g," ").trim();let E=Xd6(Q.url),C=Vd6(Q.metadata),U="terminal";if(Q.format)U=Q.format;else if(Q.json)U="json";else if(Q.markdown)U="markdown";let X={format:U,markdown:Q.markdown??!1,json:Q.json??!1,metadata:C,url:E,customQuestion:Q.customQuestion||"",includeMetadata:Q.includeMetadata??!1,includeTimestamp:Q.includeTimestamp??!1,model:Q.model||"",processingTime:Q.processingTime||0,fromCache:Q.fromCache||!1,compact:Q.compact??!1,customTitle:Q.customTitle||"",isFullContent:Q.isFullContent??!1},H;switch(U){case"markdown":H=Gd6(B,X);break;case"json":H=Hd6(B,X);break;case"html":H=Kd6(B,X);break;case"plain":H=Nd6(B,X);break;case"terminal":default:H=Wd6(B,X);break}return H}import Vj0 from"node:path";var Lb={DEFAULT_TIMEOUT:30000,PAGE_LOAD_TIMEOUT:20000,VIEWPORT_WIDTH:1920,VIEWPORT_HEIGHT:1080,DEFAULT_FORMAT:"png",JPEG_QUALITY:90,MAX_RETRIES:2,RETRY_DELAY:1000};class sG extends Error{code;userMessage;hint;constructor(A,Q,B,E){super(A);this.code=Q;this.userMessage=B;this.hint=E;this.name="ScreenshotError"}}function Wj0(A){switch(Vj0.extname(A).toLowerCase()){case".jpg":case".jpeg":return"jpeg";case".webp":return"webp";case".png":default:return"png"}}function Md6(A){try{let Q=new URL(A);if(!["http:","https:"].includes(Q.protocol))throw new Error("Invalid protocol")}catch{throw new sG(`Invalid URL: ${A}`,"INVALID_URL","Invalid URL format","URL must start with http:// or https://")}}function zd6(A){let Q=Vj0.extname(A).toLowerCase(),B=[".png",".jpg",".jpeg",".webp"];if(!B.includes(Q))throw new sG(`Invalid file extension: ${Q}`,"INVALID_EXTENSION","Unsupported image format",`Supported formats: ${B.join(", ")}`)}async function $d6(A){try{return await A.default.launch({headless:!0,args:["--no-sandbox","--disable-setuid-sandbox","--disable-dev-shm-usage","--disable-accelerated-2d-canvas","--no-first-run","--no-zygote","--disable-gpu"],timeout:1e4})}catch(Q){if(Q.message?.includes("Could not find")||Q.message?.includes("Chromium"))throw new sG(Q.message,"BROWSER_NOT_FOUND","Chromium browser not found","Puppeteer's Chromium is missing. Reinstall: bun install puppeteer");throw new sG(Q.message,"BROWSER_LAUNCH_FAILED","Failed to launch browser","Check if you have enough system resources (memory, disk space)")}}async function Gj0(A,Q,B,E=1){let C,U;try{C=await $d6(B),U=await C.newPage(),await U.setViewport({width:Q.width,height:Q.height,deviceScaleFactor:1}),U.setDefaultTimeout(Q.timeout),U.setDefaultNavigationTimeout(Lb.PAGE_LOAD_TIMEOUT);try{await U.goto(A,{waitUntil:Q.waitUntil,timeout:Lb.PAGE_LOAD_TIMEOUT})}catch(N){if(N.message?.includes("net::ERR_NAME_NOT_RESOLVED"))throw new sG(N.message,"DNS_ERROR","Cannot resolve domain name",`Check if ${new URL(A).hostname} is accessible`);if(N.message?.includes("net::ERR_CONNECTION_REFUSED"))throw new sG(N.message,"CONNECTION_REFUSED","Connection refused","The server is not accepting connections. Check if the URL is correct.");if(N.message?.includes("Timeout")||N.message?.includes("timeout"))throw new sG(N.message,"PAGE_TIMEOUT","Page took too long to load","The page is slow or unresponsive. Try again or check your connection.");throw new sG(N.message,"NAVIGATION_ERROR","Failed to load page","The page may be blocking automated access or has loading issues.")}let X=Wj0(Q.filePath),H={path:Q.filePath,fullPage:Q.fullPage,type:X};if(X==="jpeg"||X==="webp")H.quality=Q.quality;await U.screenshot(H),await U.close(),await C.close()}catch(X){if(U)try{await U.close()}catch{}if(C)try{await C.close()}catch{}if(X instanceof sG&&X.code==="PAGE_TIMEOUT"){if(E<Lb.MAX_RETRIES){let H=Lb.RETRY_DELAY*Math.pow(2,E-1);return await new Promise((N)=>setTimeout(N,H)),Gj0(A,Q,B,E+1)}}if(X instanceof sG)throw X;throw new sG(X.message||"Unknown error","SCREENSHOT_FAILED","Screenshot capture failed","An unexpected error occurred. Try again or check the URL.")}}async function Hj0(A,Q={}){let B=typeof Q==="string"?{filePath:Q}:Q,E={filePath:B.filePath||"screenshot.png",fullPage:B.fullPage??!0,width:B.width||Lb.VIEWPORT_WIDTH,height:B.height||Lb.VIEWPORT_HEIGHT,quality:B.quality||Lb.JPEG_QUALITY,timeout:B.timeout||Lb.DEFAULT_TIMEOUT,waitUntil:B.waitUntil||"networkidle2"};if(Md6(A),zd6(E.filePath),E.width<=0||E.height<=0)throw new sG("Invalid dimensions","INVALID_DIMENSIONS","Width and height must be positive","Use values like width: 1920, height: 1080");let C=Wj0(E.filePath);if((C==="jpeg"||C==="webp")&&(E.quality<0||E.quality>100))throw new sG("Invalid quality","INVALID_QUALITY","Quality must be between 0-100","Use values like quality: 90");try{let U=await Promise.resolve().then(() => (w5A(),$5A));await Gj0(A,E,U)}catch(U){throw new sG(`Puppeteer not available: ${U.message}`,"PUPPETEER_MISSING","Screenshot functionality unavailable","Install Puppeteer: npm install puppeteer")}}var _52=u7(f52(),1);import{spawn as Vm}from"child_process";import{writeFile as H54,unlink as K54}from"fs/promises";import{tmpdir as N54}from"os";import{join as M54}from"path";var Wm={en:{alloy:"21m00Tcm4TlvDq8ikWAM",echo:"jsCqWAovK2LkecY7zXl4",nova:"IKne3meq5aSn9XLyUdCD",shimmer:"LcfcDJNUP1GQjkzn1xUU",onyx:"N2lVS1w4EtoT3dr4eOWO",fable:"jBpfuIE2acCO8z3wKNLl",default:"21m00Tcm4TlvDq8ikWAM"},fr:{antoine:"ErXwobaYiN019PkySvjV",charlotte:"XB0fDUnXU5powFXDhCwa",henri:"qhFERWI2CUBNq3XOLfRE",marie:"VR6AewLTigWG4xSOukaG",default:"XB0fDUnXU5powFXDhCwa"},es:{antonio:"gcLjJkVW4MZ7xQjpwQrO",isabella:"TxGEqnHWrfWFTfGW9XjX",pablo:"flq6f7yk4E4fJM5XTYuZ",sofia:"pMsXgVXv3BLzUgSXRplE",default:"TxGEqnHWrfWFTfGW9XjX"},ht:{default:"21m00Tcm4TlvDq8ikWAM"}},pU1={alloy:"21m00Tcm4TlvDq8ikWAM",echo:"jsCqWAovK2LkecY7zXl4",nova:"IKne3meq5aSn9XLyUdCD",shimmer:"LcfcDJNUP1GQjkzn1xUU",onyx:"N2lVS1w4EtoT3dr4eOWO",fable:"jBpfuIE2acCO8z3wKNLl"},k52={en:"eleven_monolingual_v1",fr:"eleven_multilingual_v2",es:"eleven_multilingual_v2",ht:"eleven_multilingual_v2",default:"eleven_monolingual_v1"};class b52{client;apiKey;constructor(A){if(this.apiKey=A||process.env.ELEVENLABS_API_KEY,this.apiKey)this.client=new _52.ElevenLabsClient({apiKey:this.apiKey})}async synthesize(A,Q={}){let B=this.cleanTextForSpeech(A);if(this.client&&this.apiKey)try{return await this.synthesizeWithElevenLabs(B,Q)}catch(E){console.warn(c6.yellow("⚠️ ElevenLabs failed, falling back to local TTS")),console.error(E)}return await this.synthesizeWithLocalTTS(B,Q)}async synthesizeCleanedText(A,Q={}){if(this.client&&this.apiKey)try{return await this.synthesizeWithElevenLabs(A,Q)}catch(B){console.warn(c6.yellow("⚠️ ElevenLabs failed, falling back to local TTS")),console.error(B)}return await this.synthesizeWithLocalTTS(A,Q)}async synthesizeWithElevenLabs(A,Q){if(!this.client)throw new Error("ElevenLabs client not initialized");try{let{voiceId:B,model:E,voiceSettings:C}=this.getOptimalVoiceConfig(Q),U=await this.client.generate({voice:B,text:A,model_id:E,voice_settings:C}),X=[];for await(let w of U)X.push(Buffer.from(w));let H=Buffer.concat(X),N=Q.outputFile||M54(N54(),`glance-audio-${Date.now()}.mp3`);if(await H54(N,H),!Q.outputFile)await this.playAudio(N),setTimeout(()=>K54(N).catch(()=>{}),5000);return{success:!0,outputFile:N}}catch(B){return{success:!1,error:B instanceof Error?B.message:"Unknown error"}}}async synthesizeWithLocalTTS(A,Q){let B=process.platform;try{if(B==="darwin")return await this.useMacOSSay(A,Q);else if(B==="win32")return await this.useWindowsTTS(A,Q);else return await this.useLinuxTTS(A,Q)}catch(E){return{success:!1,error:`Local TTS failed: ${E instanceof Error?E.message:"Unknown error"}`}}}async useMacOSSay(A,Q){return new Promise((B)=>{let E=[],C={fr:"Thomas",es:"Jorge",ht:"Thomas",en:"Alex"};if(Q.voice)E.push("-v",Q.voice);else if(Q.language&&C[Q.language])E.push("-v",C[Q.language]);if(Q.outputFile)E.push("-o",Q.outputFile);E.push(A);let U=Vm("say",E);U.on("error",(X)=>{B({success:!1,error:`macOS say command failed: ${X.message}`})}),U.on("close",(X)=>{if(X===0)B({success:!0,outputFile:Q.outputFile});else B({success:!1,error:`macOS say command exited with code ${X}`})})})}async useWindowsTTS(A,Q){return new Promise((B)=>{let E=`
1271
1271
  Add-Type -AssemblyName System.Speech
1272
1272
  $synthesizer = New-Object System.Speech.Synthesis.SpeechSynthesizer
1273
1273
  ${Q.outputFile?`$synthesizer.SetOutputToWaveFile("${Q.outputFile}")`:""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glance-cli",
3
- "version": "0.10.9",
3
+ "version": "0.10.10",
4
4
  "author": {
5
5
  "name": "Kenley Jean",
6
6
  "email": "alo@jkenley.me",