@vladar107/claudescope 0.5.0 → 0.5.1

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/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cr } from 'node:module';
3
3
  const require = __cr(import.meta.url);
4
- import{spawn as G,spawnSync as I}from"node:child_process";import{existsSync as D,mkdirSync as B,openSync as ue,readFileSync as N,realpathSync as de,rmSync as C,writeFileSync as J}from"node:fs";import{dirname as fe,join as E}from"node:path";import{createInterface as me}from"node:readline/promises";import{parseArgs as ge}from"node:util";import{fileURLToPath as he}from"node:url";import{copyFileSync as ke,existsSync as X,mkdirSync as De}from"node:fs";import{homedir as l}from"node:os";import{dirname as Y,join as i}from"node:path";import{fileURLToPath as q}from"node:url";var R=Y(q(import.meta.url));function T(e,t){return e.find(n=>X(n))??t}var v=Number(process.env.PORT??4317),h=i(R,"..");function _(e){return e==="~"?l():e.startsWith("~/")?i(l(),e.slice(2)):e}var b=_(process.env.CLAUDE_PROJECTS_DIR??i(l(),".claude","projects")),Te=_(process.env.CODEX_SESSIONS_DIR??i(l(),".codex","sessions")),$e=_(process.env.JUNIE_SESSIONS_DIR??i(l(),".junie","sessions")),Me=process.env.OPEN_BROWSER==="1",Ue=Number(process.env.REINDEX_INTERVAL_MS??15e3),a=_(process.env.CLAUDESCOPE_HOME??i(l(),".claudescope")),Fe=process.env.DUCKDB_PATH??i(a,"index.duckdb"),He=T([i(R,"pricing.default.json"),i(h,"pricing.json")],i(h,"pricing.json")),je=process.env.PRICING_PATH??i(a,"pricing.json"),p=process.env.FETCHED_PRICING_PATH??i(a,"pricing.fetched.json"),$=process.env.LITELLM_PRICING_URL??"https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json",Ge=Number(process.env.PRICING_REFRESH_INTERVAL_MS??24*60*60*1e3),Be=process.env.WEB_DIST_DIR??T([i(R,"web"),i(h,"..","web","dist")],i(h,"..","web","dist")),c="0.5.0";import{mkdirSync as z,readFileSync as Q,renameSync as Z,writeFileSync as ee}from"node:fs";import{dirname as M,join as te}from"node:path";var oe=new Set(["anthropic","openai","gemini","xai","mistral","deepseek"]),ne=new Set(["chat","responses"]),re=1e6,se=1e4,ie=3e4;function y(e){if(typeof e!="number"||!Number.isFinite(e)||e<0)return null;let t=e*re;return t<=se?t:null}function U(e){return e==null?0:y(e)}function ce(e){let t={};if(typeof e!="object"||e===null)return t;for(let[n,r]of Object.entries(e)){if(n==="sample_spec"||n.includes("/")||typeof r!="object"||r===null)continue;let o=r;if(typeof o.litellm_provider!="string"||!oe.has(o.litellm_provider)||typeof o.mode!="string"||!ne.has(o.mode))continue;let s=y(o.input_cost_per_token),d=y(o.output_cost_per_token),f=U(o.cache_creation_input_token_cost),A=U(o.cache_read_input_token_cost);s===null||d===null||f===null||A===null||(t[n]={input:s,output:d,cacheWrite:f,cacheRead:A})}return t}function ae(e){let t=Object.keys(e),n=t.some(o=>o.startsWith("claude")),r=t.some(o=>/^(gpt|o\d|chatgpt|codex)/.test(o));if(!n||!r){let o=[!n&&"anthropic",!r&&"openai"].filter(Boolean).join(", ");throw new Error(`Fetched pricing failed validation: no ${o} model survived mapping (${t.length} model(s) total). LiteLLM schema may have drifted.`)}}function le(e){try{return JSON.parse(Q(e,"utf8"))?.models??{}}catch{return{}}}function pe(e,t){let n=0;for(let[r,o]of Object.entries(e)){let s=t[r];(!s||s.input!==o.input||s.output!==o.output||s.cacheWrite!==o.cacheWrite||s.cacheRead!==o.cacheRead)&&(n+=1)}return n}async function F(){let e=await fetch($,{signal:AbortSignal.timeout(ie)});if(!e.ok)throw new Error(`Pricing fetch failed: ${e.status} ${e.statusText}`);let t=await e.json(),n=ce(t);ae(n);let r=le(p),o=pe(n,r),s=new Date().toISOString(),d={fetchedAt:s,models:n};z(M(p),{recursive:!0});let f=te(M(p),`.pricing.fetched.${process.pid}.tmp`);return ee(f,`${JSON.stringify(d,null,2)}
4
+ import{spawn as G,spawnSync as I}from"node:child_process";import{existsSync as D,mkdirSync as B,openSync as ue,readFileSync as N,realpathSync as de,rmSync as C,writeFileSync as J}from"node:fs";import{dirname as fe,join as E}from"node:path";import{createInterface as me}from"node:readline/promises";import{parseArgs as ge}from"node:util";import{fileURLToPath as he}from"node:url";import{copyFileSync as ke,existsSync as X,mkdirSync as De}from"node:fs";import{homedir as l}from"node:os";import{dirname as Y,join as i}from"node:path";import{fileURLToPath as q}from"node:url";var R=Y(q(import.meta.url));function T(e,t){return e.find(n=>X(n))??t}var v=Number(process.env.PORT??4317),h=i(R,"..");function _(e){return e==="~"?l():e.startsWith("~/")?i(l(),e.slice(2)):e}var b=_(process.env.CLAUDE_PROJECTS_DIR??i(l(),".claude","projects")),Te=_(process.env.CODEX_SESSIONS_DIR??i(l(),".codex","sessions")),$e=_(process.env.JUNIE_SESSIONS_DIR??i(l(),".junie","sessions")),Me=process.env.OPEN_BROWSER==="1",Ue=Number(process.env.REINDEX_INTERVAL_MS??15e3),a=_(process.env.CLAUDESCOPE_HOME??i(l(),".claudescope")),Fe=process.env.DUCKDB_PATH??i(a,"index.duckdb"),He=T([i(R,"pricing.default.json"),i(h,"pricing.json")],i(h,"pricing.json")),je=process.env.PRICING_PATH??i(a,"pricing.json"),p=process.env.FETCHED_PRICING_PATH??i(a,"pricing.fetched.json"),$=process.env.LITELLM_PRICING_URL??"https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json",Ge=Number(process.env.PRICING_REFRESH_INTERVAL_MS??24*60*60*1e3),Be=process.env.WEB_DIST_DIR??T([i(R,"web"),i(h,"..","web","dist")],i(h,"..","web","dist")),c="0.5.1";import{mkdirSync as z,readFileSync as Q,renameSync as Z,writeFileSync as ee}from"node:fs";import{dirname as M,join as te}from"node:path";var oe=new Set(["anthropic","openai","gemini","xai","mistral","deepseek"]),ne=new Set(["chat","responses"]),re=1e6,se=1e4,ie=3e4;function y(e){if(typeof e!="number"||!Number.isFinite(e)||e<0)return null;let t=e*re;return t<=se?t:null}function U(e){return e==null?0:y(e)}function ce(e){let t={};if(typeof e!="object"||e===null)return t;for(let[n,r]of Object.entries(e)){if(n==="sample_spec"||n.includes("/")||typeof r!="object"||r===null)continue;let o=r;if(typeof o.litellm_provider!="string"||!oe.has(o.litellm_provider)||typeof o.mode!="string"||!ne.has(o.mode))continue;let s=y(o.input_cost_per_token),d=y(o.output_cost_per_token),f=U(o.cache_creation_input_token_cost),A=U(o.cache_read_input_token_cost);s===null||d===null||f===null||A===null||(t[n]={input:s,output:d,cacheWrite:f,cacheRead:A})}return t}function ae(e){let t=Object.keys(e),n=t.some(o=>o.startsWith("claude")),r=t.some(o=>/^(gpt|o\d|chatgpt|codex)/.test(o));if(!n||!r){let o=[!n&&"anthropic",!r&&"openai"].filter(Boolean).join(", ");throw new Error(`Fetched pricing failed validation: no ${o} model survived mapping (${t.length} model(s) total). LiteLLM schema may have drifted.`)}}function le(e){try{return JSON.parse(Q(e,"utf8"))?.models??{}}catch{return{}}}function pe(e,t){let n=0;for(let[r,o]of Object.entries(e)){let s=t[r];(!s||s.input!==o.input||s.output!==o.output||s.cacheWrite!==o.cacheWrite||s.cacheRead!==o.cacheRead)&&(n+=1)}return n}async function F(){let e=await fetch($,{signal:AbortSignal.timeout(ie)});if(!e.ok)throw new Error(`Pricing fetch failed: ${e.status} ${e.statusText}`);let t=await e.json(),n=ce(t);ae(n);let r=le(p),o=pe(n,r),s=new Date().toISOString(),d={fetchedAt:s,models:n};z(M(p),{recursive:!0});let f=te(M(p),`.pricing.fetched.${process.pid}.tmp`);return ee(f,`${JSON.stringify(d,null,2)}
5
5
  `),Z(f,p),{fetchedAt:s,modelCount:Object.keys(n).length,changed:o,path:p}}var O=fe(he(import.meta.url)),_e=E(O,"server.js"),u=E(a,"daemon.json"),w=E(a,"daemon.log"),P=E(a,"update-check.json"),m="@vladar107/claudescope",we=24*60*60*1e3;function S(){if(!D(u))return null;try{return JSON.parse(N(u,"utf8"))}catch{return null}}function g(e){try{return process.kill(e,0),!0}catch{return!1}}async function x(e){try{return(await fetch(`http://127.0.0.1:${e}/api/health`,{signal:AbortSignal.timeout(1500)})).ok}catch{return!1}}async function Ee(e,t){let n=Date.now()+t;for(;Date.now()<n;){if(await x(e))return!0;process.stdout.write("."),await new Promise(r=>setTimeout(r,500))}return!1}function L(e){let t=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";try{G(t,[e],{stdio:"ignore",detached:!0,shell:process.platform==="win32"}).unref()}catch{}}async function H(e,t){B(a,{recursive:!0});let n=S();if(n&&g(n.pid)&&await x(n.port)){console.log(`\u2713 claudescope is already running \u2192 ${n.url}`),t&&L(n.url);return}n&&!g(n.pid)&&C(u,{force:!0});let r=`http://localhost:${e}`,o=ue(w,"a"),s=G(process.execPath,[_e],{detached:!0,stdio:["ignore",o,o],env:{...process.env,PORT:String(e),OPEN_BROWSER:"0"}});if(s.unref(),J(u,JSON.stringify({pid:s.pid,port:e,url:r,version:c,startedAt:new Date().toISOString()},null,2)),process.stdout.write("\u203A Starting claudescope"),!await Ee(e,2e4)){console.error(`
6
6
  \u2717 Server did not become healthy in time. Inspect: claudescope logs`),process.exitCode=1;return}console.log(`
7
7
  \u2713 claudescope running \u2192 ${r}`),console.log(` Sessions: ${b} (read-only)`),t&&L(r),await K(!1)}function k(){let e=S();if(!e||!g(e.pid)){console.log("claudescope is not running."),C(u,{force:!0});return}try{process.kill(e.pid,"SIGTERM")}catch{}C(u,{force:!0}),console.log(`\u2713 Stopped claudescope (pid ${e.pid}).`)}async function Se(){let e=S();e&&g(e.pid)&&await x(e.port)?console.log(`\u25CF running ${e.url} (pid ${e.pid}, v${e.version})`):console.log(`\u25CB stopped (installed v${c})`),await K(!0)}function Re(){let e=S();e&&g(e.pid)?L(e.url):console.log("claudescope is not running. Start it with: claudescope start")}function ve(e){if(!D(w)){console.log("No logs yet.");return}e&&process.platform!=="win32"?I("tail",["-f",w],{stdio:"inherit"}):process.stdout.write(N(w,"utf8"))}async function be(e,t){if(!process.stdin.isTTY)return t;let n=me({input:process.stdin,output:process.stdout});try{let r=(await n.question(`${e} ${t?"[Y/n]":"[y/N]"} `)).trim().toLowerCase();return r?r==="y"||r==="yes":t}finally{n.close()}}function ye(){let e=O;try{e=de(O)}catch{}return e.includes("/nix/store/")?"nix":/[\\/]Cellar[\\/]claudescope[\\/]/.test(e)?"brew":"npm"}async function Pe(e){let t=await W(!0);if(t&&!V(t,c)){console.log(`\u2713 Already on the latest version (v${c}).`);return}let n=ye();if(n==="brew"){console.log("claudescope was installed via Homebrew."),console.log(" Run: brew upgrade vladar107/tap/claudescope");return}if(n==="nix"){console.log("claudescope was installed via Nix."),console.log(" Run: nix profile upgrade claudescope"),console.log(" (flake users: re-run `nix run --refresh github:vladar107/claudescope`)");return}t||console.log("\u26A0 Could not reach the npm registry to confirm the latest version.");let r=t?`v${c} \u2192 v${t}`:`v${c} \u2192 latest`;if(console.log(`\u203A Will run: npm install -g ${m}@latest (${r})`),!e&&!await be("Proceed?",!0)){console.log("Aborted.");return}console.log(`\u203A Updating ${m}\u2026`);let o=process.platform==="win32"?"npm.cmd":"npm";if(I(o,["install","-g",`${m}@latest`],{stdio:"inherit"}).status!==0){console.error(`\u2717 Update failed. If you run via npx, just re-run \`npx ${m}\` to get the latest.`),process.exitCode=1;return}k(),console.log("\u2713 Updated. Restarting\u2026"),I("claudescope",["start"],{stdio:"inherit",shell:process.platform==="win32"})}function V(e,t){let n=e.split(".").map(o=>Number.parseInt(o,10)||0),r=t.split(".").map(o=>Number.parseInt(o,10)||0);for(let o=0;o<3;o++){if((n[o]??0)>(r[o]??0))return!0;if((n[o]??0)<(r[o]??0))return!1}return!1}async function W(e){let t=Date.now();if(!e&&D(P))try{let s=JSON.parse(N(P,"utf8"));if(t-s.lastCheck<we)return s.latest}catch{}let n=`https://registry.npmjs.org/${m.replace("/","%2f")}/latest`,r=await fetch(n,{signal:AbortSignal.timeout(2500)});if(!r.ok)return null;let o=await r.json();return o.version?(B(a,{recursive:!0}),J(P,JSON.stringify({lastCheck:t,latest:o.version})),o.version):null}async function K(e){try{let t=await W(e);t&&V(t,c)&&console.log(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vladar107/claudescope",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Local, read-only web app to browse, read, search, and analyze your AI coding-agent transcripts — Claude Code, OpenAI Codex, and JetBrains Junie.",
5
5
  "keywords": [
6
6
  "claude",
package/server.js CHANGED
@@ -389,7 +389,7 @@ globstar while`,O,X,N,re,fe),this.matchOne(O.slice(X),N.slice(re),L))return this
389
389
  \x1B[36mat `+r[i].toString()+"\x1B[39m";return n}return t&&(n+=" \x1B[36m"+iy(t)+"\x1B[39m"),n}function iy(e){return _X(vX,e[0])+":"+e[1]+":"+e[2]}function Tu(){var e=Error.stackTraceLimit,t={},r=Error.prepareStackTrace;Error.prepareStackTrace=AX,Error.stackTraceLimit=Math.max(10,e),Error.captureStackTrace(t);var n=t.stack.slice(1);return Error.prepareStackTrace=r,Error.stackTraceLimit=e,n}function AX(e,t){return t}function kX(e,t){if(typeof e!="function")throw new TypeError("argument fn must be a function");var r=wX(e.length),n=Tu(),i=vs(n[1]);i.name=e.name;var s=new Function("fn","log","deprecate","message","site",`"use strict"
390
390
  return function (`+r+`) {log.call(deprecate, message, site)
391
391
  return fn.apply(this, arguments)
392
- }`)(e,Ru,this,t,i);return s}function CX(e,t,r){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("argument obj must be object");var n=Object.getOwnPropertyDescriptor(e,t);if(!n)throw new TypeError("must call property on owner object");if(!n.configurable)throw new TypeError("property must be configurable");var i=this,s=Tu(),o=vs(s[1]);o.name=t,"value"in n&&(n=SX(e,t,r));var a=n.get,l=n.set;typeof a=="function"&&(n.get=function(){return Ru.call(i,r,o),a.apply(this,arguments)}),typeof l=="function"&&(n.set=function(){return Ru.call(i,r,o),l.apply(this,arguments)}),Object.defineProperty(e,t,n)}function o1(e,t,r){var n=new Error,i;return Object.defineProperty(n,"constructor",{value:o1}),Object.defineProperty(n,"message",{configurable:!0,enumerable:!1,value:t,writable:!0}),Object.defineProperty(n,"name",{enumerable:!1,configurable:!0,value:"DeprecationError",writable:!0}),Object.defineProperty(n,"namespace",{configurable:!0,enumerable:!1,value:e,writable:!0}),Object.defineProperty(n,"stack",{configurable:!0,enumerable:!1,get:function(){return i!==void 0?i:i=bX.call(this,r)},set:function(o){i=o}}),n}});var u1=R((Uoe,c1)=>{"use strict";c1.exports=Object.setPrototypeOf||({__proto__:[]}instanceof Array?$X:IX);function $X(e,t){return e.__proto__=t,e}function IX(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(e,r)||(e[r]=t[r]);return e}});var f1=R((Boe,NX)=>{NX.exports={"100":"Continue","101":"Switching Protocols","102":"Processing","103":"Early Hints","200":"OK","201":"Created","202":"Accepted","203":"Non-Authoritative Information","204":"No Content","205":"Reset Content","206":"Partial Content","207":"Multi-Status","208":"Already Reported","226":"IM Used","300":"Multiple Choices","301":"Moved Permanently","302":"Found","303":"See Other","304":"Not Modified","305":"Use Proxy","307":"Temporary Redirect","308":"Permanent Redirect","400":"Bad Request","401":"Unauthorized","402":"Payment Required","403":"Forbidden","404":"Not Found","405":"Method Not Allowed","406":"Not Acceptable","407":"Proxy Authentication Required","408":"Request Timeout","409":"Conflict","410":"Gone","411":"Length Required","412":"Precondition Failed","413":"Payload Too Large","414":"URI Too Long","415":"Unsupported Media Type","416":"Range Not Satisfiable","417":"Expectation Failed","418":"I'm a Teapot","421":"Misdirected Request","422":"Unprocessable Entity","423":"Locked","424":"Failed Dependency","425":"Too Early","426":"Upgrade Required","428":"Precondition Required","429":"Too Many Requests","431":"Request Header Fields Too Large","451":"Unavailable For Legal Reasons","500":"Internal Server Error","501":"Not Implemented","502":"Bad Gateway","503":"Service Unavailable","504":"Gateway Timeout","505":"HTTP Version Not Supported","506":"Variant Also Negotiates","507":"Insufficient Storage","508":"Loop Detected","509":"Bandwidth Limit Exceeded","510":"Not Extended","511":"Network Authentication Required"}});var p1=R((Voe,h1)=>{"use strict";var sy=f1();h1.exports=vr;vr.message=sy;vr.code=LX(sy);vr.codes=jX(sy);vr.redirect={300:!0,301:!0,302:!0,303:!0,305:!0,307:!0,308:!0};vr.empty={204:!0,205:!0,304:!0};vr.retry={502:!0,503:!0,504:!0};function LX(e){var t={};return Object.keys(e).forEach(function(n){var i=e[n],s=Number(n);t[i.toLowerCase()]=s}),t}function jX(e){return Object.keys(e).map(function(r){return Number(r)})}function DX(e){var t=e.toLowerCase();if(!Object.prototype.hasOwnProperty.call(vr.code,t))throw new Error('invalid status message: "'+e+'"');return vr.code[t]}function d1(e){if(!Object.prototype.hasOwnProperty.call(vr.message,e))throw new Error("invalid status code: "+e);return vr.message[e]}function vr(e){if(typeof e=="number")return d1(e);if(typeof e!="string")throw new TypeError("code must be a number or string");var t=parseInt(e,10);return isNaN(t)?DX(e):d1(t)}});var m1=R((Goe,oy)=>{typeof Object.create=="function"?oy.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:oy.exports=function(t,r){if(r){t.super_=r;var n=function(){};n.prototype=r.prototype,t.prototype=new n,t.prototype.constructor=t}}});var g1=R((Woe,ly)=>{try{if(ay=ee("util"),typeof ay.inherits!="function")throw"";ly.exports=ay.inherits}catch{ly.exports=m1()}var ay});var _1=R((Joe,y1)=>{"use strict";y1.exports=qX;function qX(e){return e.split(" ").map(function(t){return t.slice(0,1).toUpperCase()+t.slice(1)}).join("").replace(/[^ _0-9a-z]/gi,"")}});var E1=R((Koe,fi)=>{"use strict";var FX=l1()("http-errors"),v1=u1(),Ss=p1(),cy=g1(),MX=_1();fi.exports=Ou;fi.exports.HttpError=HX();fi.exports.isHttpError=UX(fi.exports.HttpError);VX(fi.exports,Ss.codes,fi.exports.HttpError);function S1(e){return+(String(e).charAt(0)+"00")}function Ou(){for(var e,t,r=500,n={},i=0;i<arguments.length;i++){var s=arguments[i],o=typeof s;if(o==="object"&&s instanceof Error)e=s,r=e.status||e.statusCode||r;else if(o==="number"&&i===0)r=s;else if(o==="string")t=s;else if(o==="object")n=s;else throw new TypeError("argument #"+(i+1)+" unsupported type "+o)}typeof r=="number"&&(r<400||r>=600)&&FX("non-error status code; use only 4xx or 5xx status codes"),(typeof r!="number"||!Ss.message[r]&&(r<400||r>=600))&&(r=500);var a=Ou[r]||Ou[S1(r)];e||(e=a?new a(t):new Error(t||Ss.message[r]),Error.captureStackTrace(e,Ou)),(!a||!(e instanceof a)||e.status!==r)&&(e.expose=r<500,e.status=e.statusCode=r);for(var l in n)l!=="status"&&l!=="statusCode"&&(e[l]=n[l]);return e}function HX(){function e(){throw new TypeError("cannot construct abstract class")}return cy(e,Error),e}function zX(e,t,r){var n=b1(t);function i(s){var o=s??Ss.message[r],a=new Error(o);return Error.captureStackTrace(a,i),v1(a,i.prototype),Object.defineProperty(a,"message",{enumerable:!0,configurable:!0,value:o,writable:!0}),Object.defineProperty(a,"name",{enumerable:!1,configurable:!0,value:n,writable:!0}),a}return cy(i,e),w1(i,n),i.prototype.status=r,i.prototype.statusCode=r,i.prototype.expose=!0,i}function UX(e){return function(r){return!r||typeof r!="object"?!1:r instanceof e?!0:r instanceof Error&&typeof r.expose=="boolean"&&typeof r.statusCode=="number"&&r.status===r.statusCode}}function BX(e,t,r){var n=b1(t);function i(s){var o=s??Ss.message[r],a=new Error(o);return Error.captureStackTrace(a,i),v1(a,i.prototype),Object.defineProperty(a,"message",{enumerable:!0,configurable:!0,value:o,writable:!0}),Object.defineProperty(a,"name",{enumerable:!1,configurable:!0,value:n,writable:!0}),a}return cy(i,e),w1(i,n),i.prototype.status=r,i.prototype.statusCode=r,i.prototype.expose=!1,i}function w1(e,t){var r=Object.getOwnPropertyDescriptor(e,"name");r&&r.configurable&&(r.value=t,Object.defineProperty(e,"name",r))}function VX(e,t,r){t.forEach(function(i){var s,o=MX(Ss.message[i]);switch(S1(i)){case 400:s=zX(r,o,i);break;case 500:s=BX(r,o,i);break}s&&(e[i]=s,e[o]=s)})}function b1(e){return e.slice(-5)==="Error"?e:e+"Error"}});var T1=R((Yoe,R1)=>{"use strict";var uy=E1();function GX(e,t){return t?t instanceof Error?uy(e,t,{expose:!1}):uy(e,t):uy(e)}R1.exports.createHttpError=GX});var j1=R((Xoe,L1)=>{"use strict";var k1=ee("node:fs"),da=ee("node:path"),WX=ee("node:stream"),kt=ee("node:util").debuglog("send"),JX=Zm(),KX=HC(),O1=ty(),YX=zC(),{collapseLeadingSlashes:XX}=BC(),{containsDotFile:QX}=GC(),{contentRange:x1}=JC(),{createHtmlDocument:di}=YC(),{isUtf8MimeType:ZX}=ey(),{normalizeList:P1}=QC(),{parseBytesRange:eQ}=e1(),{parseTokenList:C1}=n1(),{createHttpError:tQ}=T1(),rQ=da.extname,$1=da.join,fy=da.normalize,I1=da.resolve,xu=da.sep,Pu=WX.Readable,nQ=/^ *bytes=/,iQ=60*60*24*365*1e3,A1=/(?:^|[\\/])\.\.(?:[\\/]|$)/,sQ={400:di("Error","Bad Request"),403:di("Error","Forbidden"),404:di("Error","Not Found"),412:di("Error","Precondition Failed"),416:di("Error","Range Not Satisfiable"),500:di("Error","Internal Server Error")},oQ=["allow","ignore","deny"];function aQ(e){let t;return typeof e=="string"?t=YX.parse(e):t=Number(e),t!==t?0:Math.min(Math.max(0,t),iQ)}function lQ(e){e=e??{};let t=e.acceptRanges!==void 0?!!e.acceptRanges:!0,r=e.cacheControl!==void 0?!!e.cacheControl:!0,n=e.contentType!==void 0?!!e.contentType:!0,i=e.etag!==void 0?!!e.etag:!0,s=e.dotfiles!==void 0?oQ.indexOf(e.dotfiles):1;if(s===-1)throw new TypeError('dotfiles option must be "allow", "deny", or "ignore"');let o=e.extensions!==void 0?P1(e.extensions,"extensions option"):[],a=e.immutable!==void 0?!!e.immutable:!1,l=e.index!==void 0?P1(e.index,"index option"):["index.html"],c=e.lastModified!==void 0?!!e.lastModified:!0,u=aQ(e.maxAge??e.maxage),h=e.maxContentRangeChunkSize!==void 0?Number(e.maxContentRangeChunkSize):null,m=e.root?I1(e.root):null,d=Number.isSafeInteger(e.highWaterMark)&&e.highWaterMark>0?e.highWaterMark:null;return{acceptRanges:t,cacheControl:r,contentType:n,etag:i,dotfiles:s,extensions:o,immutable:a,index:l,lastModified:c,maxage:u,maxContentRangeChunkSize:h,root:m,highWaterMark:d,start:e.start,end:e.end}}function cQ(e,t){let r=JX(e);if(r==null)return{statusCode:400};if(~r.indexOf("\0"))return{statusCode:400};let n;if(t!==null){if(r&&(r=fy("."+xu+r)),A1.test(r))return kt('malicious path "%s"',r),{statusCode:403};n=r.split(xu),r=fy($1(t,r))}else{if(A1.test(r))return kt('malicious path "%s"',r),{statusCode:403};n=fy(r).split(xu),r=I1(r)}return{path:r,parts:n}}function N1(e){return e[e.length-1]==="/"}function uQ(e){return e.headers["if-match"]||e.headers["if-unmodified-since"]||e.headers["if-none-match"]||e.headers["if-modified-since"]}function fQ(e,t){if("cache-control"in e.headers&&e.headers["cache-control"].indexOf("no-cache")!==-1)return!1;if("if-none-match"in e.headers){let r=e.headers["if-none-match"];if(r==="*")return!0;let n=t.ETag;if(typeof n!="string")return!1;let i=n.length;return!!C1(r,function(o){let a=o.length;if(i===a&&o===n||i>a&&"W/"+o===n)return!0})}if("if-modified-since"in e.headers){let r=e.headers["if-modified-since"],n=t["Last-Modified"];if(!n||Date.parse(n)<=Date.parse(r))return!0}return!1}function dQ(e,t){let r=e.headers["if-match"];if(r){let n=t.ETag;if(r!=="*"&&(C1(r,function(s){if(s===n||"W/"+s===n)return!0})||!1)!==!0)return!0}if("if-unmodified-since"in e.headers){let n=e.headers["if-unmodified-since"],i=Date.parse(n);if(i===i){let s=Date.parse(t["Last-Modified"]);if(s!==s||s>i)return!0}}return!1}function hQ(e,t){if(!("if-range"in e.headers))return!0;let r=e.headers["if-range"];if(r.indexOf('"')!==-1){let s=t.ETag;return s&&r.indexOf(s)!==-1||!1}let n=Date.parse(r);if(n!==n)return!1;let i=Date.parse(t["Last-Modified"]);return i!==i||i<=n}function dy(e){return new Promise(t=>{k1.stat(e,function(n,i){t({error:n,stat:i})})})}function jr(e,t){let r={};if(t&&t.headers)for(let i in t.headers)r[i]=t.headers[i];let n=sQ[e];return r["Content-Type"]="text/html; charset=utf-8",r["Content-Length"]=n[1],r["Content-Security-Policy"]="default-src 'none'",r["X-Content-Type-Options"]="nosniff",{statusCode:e,headers:r,stream:Pu.from(n[0]),type:"error",metadata:{error:tQ(e,t)}}}function hy(e){switch(e.code){case"ENAMETOOLONG":case"ENOTDIR":case"ENOENT":return jr(404,e);default:return jr(500,e)}}function pQ(e,t,r){return kt("not modified"),delete e["Content-Encoding"],delete e["Content-Language"],delete e["Content-Length"],delete e["Content-Range"],delete e["Content-Type"],{statusCode:304,headers:e,stream:Pu.from(""),type:"file",metadata:{path:t,stat:r}}}function py(e,t,r,n){let i=r.size,s=n.start??0,o=200,a={};if(kt('send "%s"',t),n.acceptRanges&&(kt("accept ranges"),a["Accept-Ranges"]="bytes"),n.cacheControl){let c="public, max-age="+Math.floor(n.maxage/1e3);n.immutable&&(c+=", immutable"),kt("cache-control %s",c),a["Cache-Control"]=c}if(n.lastModified){let c=r.mtime.toUTCString();kt("modified %s",c),a["Last-Modified"]=c}if(n.etag){let c='W/"'+r.size.toString(16)+"-"+r.mtime.getTime().toString(16)+'"';kt("etag %s",c),a.ETag=c}if(n.contentType){let c=O1.getType(t)||O1.default_type;kt("content-type %s",c),c&&ZX(c)&&(c+="; charset=utf-8"),c&&(a["Content-Type"]=c)}if(uQ(e)){if(dQ(e,a))return jr(412);if(fQ(e,a))return pQ(a,t,r)}if(i=Math.max(0,i-s),n.end!==void 0){let c=n.end-s+1;i>c&&(i=c)}if(n.acceptRanges){let c=e.headers.range;if(c!==void 0&&nQ.test(c))if(hQ(e,a)){let u=eQ(i,c);if(u.length===0)return kt("range unsatisfiable"),a["Content-Range"]=x1("bytes",i),jr(416,{headers:{"Content-Range":a["Content-Range"]}});u.length===1&&(kt("range %j",u),o=206,n.maxContentRangeChunkSize&&(u[0].end=Math.min(u[0].end,u[0].start+n.maxContentRangeChunkSize-1)),a["Content-Range"]=x1("bytes",i,u[0]),s+=u[0].start,i=u[0].end-u[0].start+1)}else kt("range stale")}if(a["Content-Length"]=i,e.method==="HEAD")return{statusCode:o,headers:a,stream:Pu.from(""),type:"file",metadata:{path:t,stat:r}};let l=k1.createReadStream(t,{highWaterMark:n.highWaterMark,start:s,end:Math.max(s,s+i-1)});return{statusCode:o,headers:a,stream:l,type:"file",metadata:{path:t,stat:r}}}function mQ(e,t){if(N1(t.path))return jr(403);let r=encodeURI(XX(t.path+"/")),n=di("Redirecting","Redirecting to "+KX(r)),i={};return i["Content-Type"]="text/html; charset=utf-8",i["Content-Length"]=n[1],i["Content-Security-Policy"]="default-src 'none'",i["X-Content-Type-Options"]="nosniff",i.Location=r,{statusCode:301,headers:i,stream:Pu.from(n[0]),type:"directory",metadata:{requestPath:t.path,path:e}}}async function gQ(e,t,r){let n;for(let i=0;i<r.index.length;i++){let s=r.index[i],o=$1(t,s),{error:a,stat:l}=await dy(o);if(a){n=a;continue}if(!l.isDirectory())return py(e,o,l,r)}return n?hy(n):jr(404)}async function yQ(e,t,r){let{error:n,stat:i}=await dy(t);if(n&&n.code==="ENOENT"&&!rQ(t)&&t[t.length-1]!==xu){let s=n;for(let o=0;o<r.extensions.length;o++){let a=r.extensions[o],l=t+"."+a,{error:c,stat:u}=await dy(l);if(c){s=c;continue}if(u.isDirectory()){s=null;continue}return py(e,l,u,r)}return s?hy(s):jr(404)}return n?hy(n):i.isDirectory()?mQ(t,r):py(e,t,i,r)}async function _Q(e,t,r){let n=lQ(r);n.path=t;let i=cQ(t,n.root),{path:s,parts:o}=i;if(i.statusCode!==void 0)return jr(i.statusCode);if((kt.enabled||n.dotfiles!==0)&&QX(o))switch(n.dotfiles){case 0:kt('allow dotfile "%s"',s);break;case 2:return kt('deny dotfile "%s"',s),jr(403);case 1:default:return kt('ignore dotfile "%s"',s),jr(404)}return n.index.length&&N1(t)?gQ(e,s,n):yQ(e,s,n)}L1.exports.send=_Q});var D1=R((Qoe,ws)=>{"use strict";var vQ=ey().isUtf8MimeType,SQ=ty(),my=j1().send;ws.exports=my;ws.exports.default=my;ws.exports.send=my;ws.exports.isUtf8MimeType=vQ;ws.exports.mime=SQ});var q1=R((Zoe,ga)=>{"use strict";function yy(e){if(!new.target)return new yy(e);let{supportedValues:t=[],cache:r}=e&&typeof e=="object"&&e||{};this.supportedValues=t,this.cache=r}yy.prototype.negotiate=function(e){return typeof e!="string"?null:this.cache?(this.cache.has(e)||this.cache.set(e,ma(e,this.supportedValues)),this.cache.get(e)):ma(e,this.supportedValues)};function ma(e,t){if(!e||!Array.isArray(t)||t.length===0)return null;if(e==="*")return t[0];let r=null,n=1/0,i=0;function s(o,a){if(a===0||i>a)return!1;let l=o==="*"&&t[0]||o,c=t.indexOf(l);return c===-1?!1:c===0&&a===1?(r=l,!0):((i<a||n>c)&&(r=l,n=c,i=a),!1)}return wQ(e,s),r}var ha=0,pa=1,Au=2,gy=3;function wQ(e,t){let r="",n,i=ha;for(let s=0,o=e.length;s<o;++s){let a=e[s];if(!(a===" "||a===" ")){if(a===";"){i===pa&&(i=Au,n="");continue}else if(a===","){if(i===pa){if(t(r,1)){i=gy;break}i=ha,r=""}else if(i===Au){if(t(r,parseFloat(n)||0)){i=gy;break}i=ha,r="",n=""}continue}else if(i===Au){if(a==="q"||a==="=")continue;if(a==="."||a==="1"||a==="0"||a==="2"||a==="3"||a==="4"||a==="5"||a==="6"||a==="7"||a==="8"||a==="9"){n+=a;continue}}else if(i===ha){i=pa,r+=a;continue}if(i===pa){let l=e[s-1];(l===" "||l===" ")&&(r=""),r+=a;continue}if(t(r,parseFloat(n)||0)){i=gy;break}i=ha,r=a,n=""}}i===pa?t(r,1):i===Au&&t(r,parseFloat(n)||0)}ga.exports=ma;ga.exports.default=ma;ga.exports.negotiate=ma;ga.exports.Negotiator=yy});var V1=R((eae,_y)=>{"use strict";_y.exports=kQ;_y.exports.parse=NQ;var bQ=new TextDecoder("utf-8"),EQ=/[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g,z1=/[^\x20-\x7e\xa0-\xff]/g,RQ=/\\([\u0000-\u007f])/g,TQ=/([\\"])/g,F1=/;[\x09\x20]*([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*=[\x09\x20]*("(?:[\x20!\x23-\x5b\x5d-\x7e\x80-\xff]|\\[\x20-\x7e])*"|[!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*/g,OQ=/^[\x20-\x7e\x80-\xff]+$/,xQ=/^[!#$%&'*+.0-9A-Z^_`a-z|~-]+$/,PQ=/^([A-Za-z0-9!#$%&+\-^_`{}~]+)'(?:[A-Za-z]{2,3}(?:-[A-Za-z]{3}){0,3}|[A-Za-z]{4,8}|)'((?:%[0-9A-Fa-f]{2}|[A-Za-z0-9!#$&+.^_`|~-])+)$/,AQ=/^([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*(?:$|;)/;function kQ(e,t){var r=t||{},n=r.type||"attachment",i=CQ(e,r.fallback);return $Q(new B1(n,i))}function CQ(e,t){if(e!==void 0){var r={};if(typeof e!="string")throw new TypeError("filename must be a string");if(t===void 0&&(t=!0),typeof t!="string"&&typeof t!="boolean")throw new TypeError("fallback must be a string or boolean");if(typeof t=="string"&&z1.test(t))throw new TypeError("fallback must be ISO-8859-1 string");var n=M1(e),i=OQ.test(n),s=typeof t!="string"?t&&U1(n):M1(t),o=typeof s=="string"&&s!==n;return(o||!i||qQ(n))&&(r["filename*"]=n),(i||o)&&(r.filename=o?s:n),r}}function $Q(e){var t=e.parameters,r=e.type;if(!r||typeof r!="string"||!xQ.test(r))throw new TypeError("invalid type");var n=String(r).toLowerCase();if(t&&typeof t=="object")for(var i,s=Object.keys(t).sort(),o=0;o<s.length;o++){i=s[o];var a=i.slice(-1)==="*"?DQ(t[i]):jQ(t[i]);n+="; "+i+"="+a}return n}function IQ(e){let t=PQ.exec(e);if(!t)throw new TypeError("invalid extended field value");let r=t[1].toLowerCase(),n=t[2];switch(r){case"iso-8859-1":{let i=H1(n);return U1(i)}case"utf-8":case"utf8":try{return decodeURIComponent(n)}catch{let i=H1(n),s=new Uint8Array(i.length);for(let o=0;o<i.length;o++)s[o]=i.charCodeAt(o);return bQ.decode(s)}}throw new TypeError("unsupported charset in extended field")}function U1(e){return String(e).replace(z1,"?")}function NQ(e){if(!e||typeof e!="string")throw new TypeError("argument string is required");var t=AQ.exec(e);if(!t)throw new TypeError("invalid type format");var r=t[0].length,n=t[1].toLowerCase(),i,s=[],o={},a;for(r=F1.lastIndex=t[0].slice(-1)===";"?r-1:r;t=F1.exec(e);){if(t.index!==r)throw new TypeError("invalid parameter format");if(r+=t[0].length,i=t[1].toLowerCase(),a=t[2],s.indexOf(i)!==-1)throw new TypeError("invalid duplicate parameter");if(s.push(i),i.indexOf("*")+1===i.length){i=i.slice(0,-1),a=IQ(a),o[i]=a;continue}typeof o[i]!="string"&&(a[0]==='"'&&(a=a.slice(1,-1).replace(RQ,"$1")),o[i]=a)}if(r!==-1&&r!==e.length)throw new TypeError("invalid parameter format");return new B1(n,o)}function LQ(e){return"%"+String(e).charCodeAt(0).toString(16).toUpperCase()}function jQ(e){var t=String(e);return'"'+t.replace(TQ,"\\$1")+'"'}function DQ(e){var t=String(e),r=encodeURIComponent(t).replace(EQ,LQ);return"UTF-8''"+r}function B1(e,t){this.type=e,this.parameters=t}function M1(e){let t=e.replaceAll("\\","/"),r=t.length;for(;r>0&&t[r-1]==="/";)r--;if(r===0)return"";let n=r-1;for(;n>=0&&t[n]!=="/";)n--;return t.slice(n+1,r)}function ku(e){let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function qQ(e){let t=e.length-3,r=-1;for(;(r=e.indexOf("%",r+1))!==-1&&r<=t;)if(ku(e[r+1])&&ku(e[r+2]))return!0;return!1}function H1(e){let t=e.indexOf("%");if(t===-1)return e;let r=e.slice(0,t);for(let n=t;n<e.length;n++)e[n]==="%"&&n+2<e.length&&ku(e[n+1])&&ku(e[n+2])?(r+=String.fromCharCode(Number.parseInt(e[n+1]+e[n+2],16)),n+=2):r+=e[n];return r}});var K1=R((tae,J1)=>{"use strict";var FQ=ee("node:os"),bt=ee("node:path"),Cu=ee("node:fs/promises"),G1=Bu(),W1=Math.max(1,FQ.cpus().length-1);function MQ(e,t){let r=bt.relative(e,t);return r===""||r!==".."&&!r.startsWith(`..${bt.sep}`)&&!bt.isAbsolute(r)}var hi={_getExtendedInfo:async function(e,t){let r=e.split(bt.sep).length,n=await Cu.readdir(e),i=async o=>{let a=bt.join(e,o),l;try{l=await Cu.stat(a)}catch{return}l.isDirectory()?(t.totalFolderCount++,a.split(bt.sep).length===r+1&&t.folderCount++,await hi._getExtendedInfo(a,t)):(t.totalSize+=l.size,t.totalFileCount++,a.split(bt.sep).length===r+1&&t.fileCount++,t.lastModified=Math.max(t.lastModified,l.mtimeMs))},s=G1.promise(i,W1);await Promise.all(n.map(o=>s.push(o)))},getExtendedInfo:async function(e){let t={totalSize:0,fileCount:0,totalFileCount:0,folderCount:0,totalFolderCount:0,lastModified:0};return await hi._getExtendedInfo(e,t),t},list:async function(e,t,r){let n={dirs:[],files:[]},i=await Cu.readdir(e);if((r==="deny"||r==="ignore")&&(i=i.filter(a=>a.charAt(0)!==".")),i.length<1)return n;let s=async a=>{let l;try{l=await Cu.stat(bt.join(e,a))}catch{return}let c={name:a,stats:l};l.isDirectory()?(t.extendedFolderInfo&&(c.extendedInfo=await hi.getExtendedInfo(bt.join(e,a))),n.dirs.push(c)):n.files.push(c)},o=G1.promise(s,W1);return await Promise.all(i.map(a=>o.push(a))),n.dirs.sort((a,l)=>a.name.localeCompare(l.name)),n.files.sort((a,l)=>a.name.localeCompare(l.name)),n},send:async function({reply:e,dir:t,options:r,route:n,prefix:i,dotfiles:s}){if(e.request.query.format==="html"&&typeof r.render!="function")throw new TypeError("The `list.render` option must be a function and is required with the URL parameter `format=html`");let o;try{o=await hi.list(t,r,s)}catch{return e.callNotFound()}if((e.request.query.format||r.format)!=="html"){if(r.jsonFormat!=="extended"){let c={dirs:[],files:[]};o.dirs.forEach(u=>c.dirs.push(u.name)),o.files.forEach(u=>c.files.push(u.name)),await e.send(c)}else await e.send(o);return}let l=r.render(o.dirs.map(c=>hi.htmlInfo(c,n,i,r)),o.files.map(c=>hi.htmlInfo(c,n,i,r)));await e.type("text/html").send(l)},htmlInfo:function(e,t,r,n){return n.names?.includes(bt.basename(t))&&(t=bt.posix.normalize(bt.posix.join(t,".."))),{href:encodeURI(bt.posix.join(r,t,e.name)),name:e.name,stats:e.stats,extendedInfo:e.extendedInfo}},handle:function(e,t){return t.names?.includes(bt.basename(e))||((t.names?.includes("/")&&e[e.length-1]==="/")??!1)},path:function(e,t){let r=t[t.length-1]==="/"?"."+t+"none":"."+t,n=bt.resolve(e),i=bt.dirname(bt.resolve(n,r));return MQ(n,i)?i:null},validateOptions:function(e){if(e.list){if(Array.isArray(e.root))return new TypeError("multi-root with list option is not supported");if(e.list.format&&e.list.format!=="json"&&e.list.format!=="html")return new TypeError("The `list.format` option must be json or html");if(e.list.names&&!Array.isArray(e.list.names))return new TypeError("The `list.names` option must be an array");if(e.list.jsonFormat!=null&&e.list.jsonFormat!=="names"&&e.list.jsonFormat!=="extended")return new TypeError("The `list.jsonFormat` option must be name or extended");if(e.list.format==="html"&&typeof e.list.render!="function")return new TypeError("The `list.render` option must be a function and is required with html format")}}};J1.exports=hi});var r$=R((rae,$u)=>{"use strict";var tn=ee("node:path"),{fileURLToPath:Y1}=ee("node:url"),{statSync:t$}=ee("node:fs"),{glob:HQ}=OC(),zQ=CC(),_a=D1(),UQ=q1(),BQ=V1(),ya=K1(),X1=/\/$/u,VQ=/\*/gu,GQ=["br","gzip","deflate"];_a.mime.default_type="application/octet-stream";var Q1={br:".br",gzip:".gz"};async function Sy(e,t){(t.serve!==!1||t.root!==void 0)&&(t.root=WQ(t.root),JQ(e,t.root));let r=t.setHeaders;if(r!==void 0&&typeof r!="function")throw new TypeError("The `setHeaders` option must be a function");let n=ya.validateOptions(t);if(n)throw n;t.dotfiles??="allow";let i={root:t.root,acceptRanges:t.acceptRanges,contentType:t.contentType,cacheControl:t.cacheControl,dotfiles:t.dotfiles,etag:t.etag,extensions:t.extensions,immutable:t.immutable,index:t.index,lastModified:t.lastModified,maxAge:t.maxAge},s=t.prefix??="/";t.prefixAvoidTrailingSlash||(s=s[s.length-1]==="/"?s:s+"/");let o={constraints:t.constraints,schema:{hide:t.schemaHide??!0},logLevel:t.logLevel,errorHandler(m,d,f){if(m?.code==="ERR_STREAM_PREMATURE_CLOSE"){f.request.raw.destroy();return}e.errorHandler(m,d,f)}};if(t.decorateReply!==!1&&(e.decorateReply("sendFile",function(m,d,f){let p=typeof d=="object"?d:f,g=typeof d=="string"?d:p?.root;return c(this.request,this,m,g||i.root,0,p),this}),e.decorateReply("download",function(m,d,f={}){let{root:p,...g}=typeof d=="object"?d:f;return d=typeof d=="string"?d:m,this.header("content-disposition",BQ(d)),c(this.request,this,m,p,0,g),this})),t.serve!==!1){if(t.wildcard&&typeof t.wildcard!="boolean")throw new TypeError('"wildcard" option must be a boolean');if(t.wildcard===void 0||t.wildcard===!0){let m;e.route({...o,method:["HEAD","GET"],path:s+"*",handler(d,f){m??=ZQ(d.routeOptions.url);let p=eZ(d.raw.url,m);if(!p)return f.callNotFound();c(d,f,p,i.root)}}),t.redirect===!0&&s!==t.prefix&&e.get(t.prefix,o,(d,f)=>{f.redirect(e$(d.raw.url),301)})}else{let m=new Set(t.index===void 0?["index.html"]:[].concat(t.index)),d=new Map,f=new Set,p=Array.isArray(i.root)?i.root:[i.root];for(let g of p){g=g.split(tn.win32.sep).join(tn.posix.sep),!g.endsWith("/")&&(g+="/");let _=await HQ("**/**",{cwd:g,absolute:!1,follow:!0,nodir:!0,dot:t.serveDotFiles,ignore:t.globIgnore});for(let w of _){w=w.split(tn.win32.sep).join(tn.posix.sep);let S=s+w;if(f.has(S))continue;f.add(S),u(o,S,`/${w}`,g);let v=tn.posix.basename(S);m.has(v)&&!d.has(v)&&d.set(tn.posix.dirname(S),g)}}for(let[g,_]of d.entries()){let w=g+(g.endsWith("/")?"":"/"),S="/"+w.replace(s,"");u(o,w,S,_),t.redirect===!0&&u(o,w.replace(X1,""),S.replace(X1,""),_)}}}let a=t.allowedPath;async function l(m,d){let f=ya.path(t.root,d);return f?(await ya.send({reply:m,dir:f,options:t.list,route:d,prefix:s,dotfiles:t.dotfiles}).catch(p=>m.send(p)),!0):!1}async function c(m,d,f,p,g=0,_,w){let S=f,v=Object.assign({},i,_);if(p)Array.isArray(p)?v.root=p[g]:v.root=p;else if(tn.isAbsolute(f)===!1)return d.callNotFound();if(a&&!a(f,v.root,m))return d.callNotFound();let E,A=f;if(t.preCompressed&&(w??=new Set,E=YQ(m.headers,w),E))if(f.endsWith("/")){if(f=vy(f,v.root,v.index),!f)return d.callNotFound();A=A+f+Q1[E]}else A=f+Q1[E];let{statusCode:P,headers:T,stream:$,type:x,metadata:C}=await _a(m.raw,encodeURI(A),v);switch(x){case"directory":{let I=C.path;if(t.list&&await ya.send({reply:d,dir:I,options:t.list,route:f,prefix:s,dotfiles:t.dotfiles}).catch(j=>d.send(j)),t.redirect===!0)try{d.redirect(e$(m.raw.url),301)}catch(j){await d.send(j)}else{if(!f.endsWith("/")&&vy(f,v.root,v.index))return c(m,d,f+"/",p,void 0,_,w);d.callNotFound()}break}case"error":{if(P===403&&(!v.index||!v.index.length)&&A[A.length-1]==="/"&&t.list&&await l(d,f))return;if(C.error.code==="ENOENT")return t.preCompressed&&E&&t.redirect!==!0&&vy(f,v.root,v.index)?c(m,d,f+"/",p,void 0,_,w):t.list&&ya.handle(f,t.list)&&await l(d,f)?void 0:Array.isArray(p)&&g<p.length-1?c(m,d,f,p,g+1,_,void 0):t.preCompressed&&!w.has(E)?(w.add(E),c(m,d,S,p,g,_,w)):d.callNotFound();if(C.error.status===404)return d.callNotFound();await d.send(C.error);break}case"file":{let I=d.statusCode!==200?d.statusCode:P;d.code(I),r?.(d.raw,C.path,C.stat),d.headers(T),E&&(d.header("content-type",KQ(f)),d.header("content-encoding",E)),await d.send($);break}}}function u(m,d,f,p){let g=Object.assign({},m,{method:["HEAD","GET"],url:d,handler:h});g.config??={},g.config.file=f,g.config.rootPath=p,e.route(g)}async function h(m,d){let f=m.routeOptions?.config;return c(m,d,f.file,f.rootPath)}}function WQ(e){if(e===void 0)return e;if(e instanceof URL&&e.protocol==="file:")return Y1(e);if(Array.isArray(e)){let t=[];for(let r=0,n=e.length;r<n;++r)e[r]instanceof URL&&e[r].protocol==="file:"?t.push(Y1(e[r])):t.push(e[r]);return t}return e}function JQ(e,t){if(t===void 0)throw new Error('"root" option is required');if(Array.isArray(t)){if(!t.length)throw new Error('"root" option array requires one or more paths');if(new Set(t).size!==t.length)throw new Error('"root" option array contains one or more duplicate paths');t.map(r=>Z1(e,r));return}if(typeof t=="string")return Z1(e,t);throw new Error('"root" option must be a string or array of strings')}function Z1(e,t){if(typeof t!="string")throw new TypeError('"root" option must be a string');if(tn.isAbsolute(t)===!1)throw new Error('"root" option must be an absolute path');let r;try{r=t$(t)}catch(n){if(n.code==="ENOENT"){e.log.warn(`"root" path "${t}" must exist`);return}throw n}if(r.isDirectory()===!1)throw new Error('"root" option must point to a directory')}function KQ(e){let t=_a.mime.getType(e)||_a.mime.default_type;return _a.isUtf8MimeType(t)?`${t}; charset=utf-8`:t}function vy(e,t,r=["index.html"]){return Array.isArray(r)?r.find(n=>{let i=tn.join(t,e,n);try{return!t$(i).isDirectory()}catch{return!1}}):!1}function YQ(e,t){if(!("accept-encoding"in e))return;let r=e["accept-encoding"].toLowerCase().replace(VQ,"gzip");return UQ.negotiate(r,GQ.filter(n=>!t.has(n)))}function XQ(e){let t=[],r=0,n=0;for(;r<e.length;){if(e[r]!==":"){r++;continue}for(n!==r&&t.push(e.slice(n,r)),r++;r<e.length&&e[r]!=="/";)r++;t.push(void 0),n=r}return n!==e.length&&t.push(e.slice(n)),t}function QQ(e,t,r){let n=0;for(let i of r){if(i===void 0){let o=n,a=e.indexOf("/",n);if(n=a===-1||a>t?t:a,n===o)return;continue}let s=n+i.length;if(s>t||!e.startsWith(i,n))return;n=s}return n}function ZQ(e){let t=e.replace(/\*$/u,""),r=t.length;if(t==="/")return()=>0;if(t.includes(":")===!1)return(i,s)=>r<=s&&i.startsWith(t)?r:void 0;let n=XQ(t);return(i,s)=>QQ(i,s,n)}function eZ(e,t){let r=e.indexOf("?"),n=r===-1?e.length:r,i=t(e,n);if(i===void 0)return;let s=e.slice(i,n);s===""?s="/":s.startsWith("/")||(s="/"+s);try{return decodeURI(s)}catch{}}function e$(e){let t=0;for(let r=e.length;t<r&&!(e[t]!=="/"&&e[t]!=="\\");++t);e="/"+e.slice(t);try{let r=new URL(e,"http://localhost.com/"),n=r.pathname;return n+(n[n.length-1]!=="/"?"/":"")+(r.search||"")}catch{let r=new Error(`Invalid redirect URL: ${e}`);throw r.statusCode=400,r}}$u.exports=zQ(Sy,{fastify:"5.x",name:"@fastify/static"});$u.exports.default=Sy;$u.exports.fastifyStatic=Sy});var X$=zy(cC(),1),Q$=zy(r$(),1);import{existsSync as My,readFileSync as Uee}from"node:fs";import{spawn as Bee}from"node:child_process";import{copyFileSync as tZ,existsSync as wy,mkdirSync as rZ}from"node:fs";import{homedir as bs}from"node:os";import{dirname as nZ,join as jt}from"node:path";import{fileURLToPath as iZ}from"node:url";var by=nZ(iZ(import.meta.url));function n$(e,t){return e.find(r=>wy(r))??t}var Ey=Number(process.env.PORT??4317),Iu=jt(by,"..");function Lu(e){return e==="~"?bs():e.startsWith("~/")?jt(bs(),e.slice(2)):e}var pi=Lu(process.env.CLAUDE_PROJECTS_DIR??jt(bs(),".claude","projects")),Ry=Lu(process.env.CODEX_SESSIONS_DIR??jt(bs(),".codex","sessions")),ju=Lu(process.env.JUNIE_SESSIONS_DIR??jt(bs(),".junie","sessions")),i$=process.env.OPEN_BROWSER==="1",Ty=Number(process.env.REINDEX_INTERVAL_MS??15e3),kn=Lu(process.env.CLAUDESCOPE_HOME??jt(bs(),".claudescope")),Sa=process.env.DUCKDB_PATH??jt(kn,"index.duckdb"),Nu=n$([jt(by,"pricing.default.json"),jt(Iu,"pricing.json")],jt(Iu,"pricing.json")),va=process.env.PRICING_PATH??jt(kn,"pricing.json"),Sr=process.env.FETCHED_PRICING_PATH??jt(kn,"pricing.fetched.json"),s$=process.env.LITELLM_PRICING_URL??"https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json",Oy=Number(process.env.PRICING_REFRESH_INTERVAL_MS??24*60*60*1e3),Du=process.env.WEB_DIST_DIR??n$([jt(by,"web"),jt(Iu,"..","web","dist")],jt(Iu,"..","web","dist")),qu="0.5.0";function o$(){rZ(kn,{recursive:!0}),!wy(va)&&wy(Nu)&&tZ(Nu,va)}import{createHash as sZ}from"node:crypto";import{mkdirSync as oZ,rmSync as aZ}from"node:fs";import{dirname as lZ}from"node:path";import{DuckDBInstance as cZ}from"@duckdb/node-api";var xy=["CREATE TABLE IF NOT EXISTS meta (key VARCHAR PRIMARY KEY, value VARCHAR)",`CREATE TABLE IF NOT EXISTS files (
392
+ }`)(e,Ru,this,t,i);return s}function CX(e,t,r){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("argument obj must be object");var n=Object.getOwnPropertyDescriptor(e,t);if(!n)throw new TypeError("must call property on owner object");if(!n.configurable)throw new TypeError("property must be configurable");var i=this,s=Tu(),o=vs(s[1]);o.name=t,"value"in n&&(n=SX(e,t,r));var a=n.get,l=n.set;typeof a=="function"&&(n.get=function(){return Ru.call(i,r,o),a.apply(this,arguments)}),typeof l=="function"&&(n.set=function(){return Ru.call(i,r,o),l.apply(this,arguments)}),Object.defineProperty(e,t,n)}function o1(e,t,r){var n=new Error,i;return Object.defineProperty(n,"constructor",{value:o1}),Object.defineProperty(n,"message",{configurable:!0,enumerable:!1,value:t,writable:!0}),Object.defineProperty(n,"name",{enumerable:!1,configurable:!0,value:"DeprecationError",writable:!0}),Object.defineProperty(n,"namespace",{configurable:!0,enumerable:!1,value:e,writable:!0}),Object.defineProperty(n,"stack",{configurable:!0,enumerable:!1,get:function(){return i!==void 0?i:i=bX.call(this,r)},set:function(o){i=o}}),n}});var u1=R((Uoe,c1)=>{"use strict";c1.exports=Object.setPrototypeOf||({__proto__:[]}instanceof Array?$X:IX);function $X(e,t){return e.__proto__=t,e}function IX(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(e,r)||(e[r]=t[r]);return e}});var f1=R((Boe,NX)=>{NX.exports={"100":"Continue","101":"Switching Protocols","102":"Processing","103":"Early Hints","200":"OK","201":"Created","202":"Accepted","203":"Non-Authoritative Information","204":"No Content","205":"Reset Content","206":"Partial Content","207":"Multi-Status","208":"Already Reported","226":"IM Used","300":"Multiple Choices","301":"Moved Permanently","302":"Found","303":"See Other","304":"Not Modified","305":"Use Proxy","307":"Temporary Redirect","308":"Permanent Redirect","400":"Bad Request","401":"Unauthorized","402":"Payment Required","403":"Forbidden","404":"Not Found","405":"Method Not Allowed","406":"Not Acceptable","407":"Proxy Authentication Required","408":"Request Timeout","409":"Conflict","410":"Gone","411":"Length Required","412":"Precondition Failed","413":"Payload Too Large","414":"URI Too Long","415":"Unsupported Media Type","416":"Range Not Satisfiable","417":"Expectation Failed","418":"I'm a Teapot","421":"Misdirected Request","422":"Unprocessable Entity","423":"Locked","424":"Failed Dependency","425":"Too Early","426":"Upgrade Required","428":"Precondition Required","429":"Too Many Requests","431":"Request Header Fields Too Large","451":"Unavailable For Legal Reasons","500":"Internal Server Error","501":"Not Implemented","502":"Bad Gateway","503":"Service Unavailable","504":"Gateway Timeout","505":"HTTP Version Not Supported","506":"Variant Also Negotiates","507":"Insufficient Storage","508":"Loop Detected","509":"Bandwidth Limit Exceeded","510":"Not Extended","511":"Network Authentication Required"}});var p1=R((Voe,h1)=>{"use strict";var sy=f1();h1.exports=vr;vr.message=sy;vr.code=LX(sy);vr.codes=jX(sy);vr.redirect={300:!0,301:!0,302:!0,303:!0,305:!0,307:!0,308:!0};vr.empty={204:!0,205:!0,304:!0};vr.retry={502:!0,503:!0,504:!0};function LX(e){var t={};return Object.keys(e).forEach(function(n){var i=e[n],s=Number(n);t[i.toLowerCase()]=s}),t}function jX(e){return Object.keys(e).map(function(r){return Number(r)})}function DX(e){var t=e.toLowerCase();if(!Object.prototype.hasOwnProperty.call(vr.code,t))throw new Error('invalid status message: "'+e+'"');return vr.code[t]}function d1(e){if(!Object.prototype.hasOwnProperty.call(vr.message,e))throw new Error("invalid status code: "+e);return vr.message[e]}function vr(e){if(typeof e=="number")return d1(e);if(typeof e!="string")throw new TypeError("code must be a number or string");var t=parseInt(e,10);return isNaN(t)?DX(e):d1(t)}});var m1=R((Goe,oy)=>{typeof Object.create=="function"?oy.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:oy.exports=function(t,r){if(r){t.super_=r;var n=function(){};n.prototype=r.prototype,t.prototype=new n,t.prototype.constructor=t}}});var g1=R((Woe,ly)=>{try{if(ay=ee("util"),typeof ay.inherits!="function")throw"";ly.exports=ay.inherits}catch{ly.exports=m1()}var ay});var _1=R((Joe,y1)=>{"use strict";y1.exports=qX;function qX(e){return e.split(" ").map(function(t){return t.slice(0,1).toUpperCase()+t.slice(1)}).join("").replace(/[^ _0-9a-z]/gi,"")}});var E1=R((Koe,fi)=>{"use strict";var FX=l1()("http-errors"),v1=u1(),Ss=p1(),cy=g1(),MX=_1();fi.exports=Ou;fi.exports.HttpError=HX();fi.exports.isHttpError=UX(fi.exports.HttpError);VX(fi.exports,Ss.codes,fi.exports.HttpError);function S1(e){return+(String(e).charAt(0)+"00")}function Ou(){for(var e,t,r=500,n={},i=0;i<arguments.length;i++){var s=arguments[i],o=typeof s;if(o==="object"&&s instanceof Error)e=s,r=e.status||e.statusCode||r;else if(o==="number"&&i===0)r=s;else if(o==="string")t=s;else if(o==="object")n=s;else throw new TypeError("argument #"+(i+1)+" unsupported type "+o)}typeof r=="number"&&(r<400||r>=600)&&FX("non-error status code; use only 4xx or 5xx status codes"),(typeof r!="number"||!Ss.message[r]&&(r<400||r>=600))&&(r=500);var a=Ou[r]||Ou[S1(r)];e||(e=a?new a(t):new Error(t||Ss.message[r]),Error.captureStackTrace(e,Ou)),(!a||!(e instanceof a)||e.status!==r)&&(e.expose=r<500,e.status=e.statusCode=r);for(var l in n)l!=="status"&&l!=="statusCode"&&(e[l]=n[l]);return e}function HX(){function e(){throw new TypeError("cannot construct abstract class")}return cy(e,Error),e}function zX(e,t,r){var n=b1(t);function i(s){var o=s??Ss.message[r],a=new Error(o);return Error.captureStackTrace(a,i),v1(a,i.prototype),Object.defineProperty(a,"message",{enumerable:!0,configurable:!0,value:o,writable:!0}),Object.defineProperty(a,"name",{enumerable:!1,configurable:!0,value:n,writable:!0}),a}return cy(i,e),w1(i,n),i.prototype.status=r,i.prototype.statusCode=r,i.prototype.expose=!0,i}function UX(e){return function(r){return!r||typeof r!="object"?!1:r instanceof e?!0:r instanceof Error&&typeof r.expose=="boolean"&&typeof r.statusCode=="number"&&r.status===r.statusCode}}function BX(e,t,r){var n=b1(t);function i(s){var o=s??Ss.message[r],a=new Error(o);return Error.captureStackTrace(a,i),v1(a,i.prototype),Object.defineProperty(a,"message",{enumerable:!0,configurable:!0,value:o,writable:!0}),Object.defineProperty(a,"name",{enumerable:!1,configurable:!0,value:n,writable:!0}),a}return cy(i,e),w1(i,n),i.prototype.status=r,i.prototype.statusCode=r,i.prototype.expose=!1,i}function w1(e,t){var r=Object.getOwnPropertyDescriptor(e,"name");r&&r.configurable&&(r.value=t,Object.defineProperty(e,"name",r))}function VX(e,t,r){t.forEach(function(i){var s,o=MX(Ss.message[i]);switch(S1(i)){case 400:s=zX(r,o,i);break;case 500:s=BX(r,o,i);break}s&&(e[i]=s,e[o]=s)})}function b1(e){return e.slice(-5)==="Error"?e:e+"Error"}});var T1=R((Yoe,R1)=>{"use strict";var uy=E1();function GX(e,t){return t?t instanceof Error?uy(e,t,{expose:!1}):uy(e,t):uy(e)}R1.exports.createHttpError=GX});var j1=R((Xoe,L1)=>{"use strict";var k1=ee("node:fs"),da=ee("node:path"),WX=ee("node:stream"),kt=ee("node:util").debuglog("send"),JX=Zm(),KX=HC(),O1=ty(),YX=zC(),{collapseLeadingSlashes:XX}=BC(),{containsDotFile:QX}=GC(),{contentRange:x1}=JC(),{createHtmlDocument:di}=YC(),{isUtf8MimeType:ZX}=ey(),{normalizeList:P1}=QC(),{parseBytesRange:eQ}=e1(),{parseTokenList:C1}=n1(),{createHttpError:tQ}=T1(),rQ=da.extname,$1=da.join,fy=da.normalize,I1=da.resolve,xu=da.sep,Pu=WX.Readable,nQ=/^ *bytes=/,iQ=60*60*24*365*1e3,A1=/(?:^|[\\/])\.\.(?:[\\/]|$)/,sQ={400:di("Error","Bad Request"),403:di("Error","Forbidden"),404:di("Error","Not Found"),412:di("Error","Precondition Failed"),416:di("Error","Range Not Satisfiable"),500:di("Error","Internal Server Error")},oQ=["allow","ignore","deny"];function aQ(e){let t;return typeof e=="string"?t=YX.parse(e):t=Number(e),t!==t?0:Math.min(Math.max(0,t),iQ)}function lQ(e){e=e??{};let t=e.acceptRanges!==void 0?!!e.acceptRanges:!0,r=e.cacheControl!==void 0?!!e.cacheControl:!0,n=e.contentType!==void 0?!!e.contentType:!0,i=e.etag!==void 0?!!e.etag:!0,s=e.dotfiles!==void 0?oQ.indexOf(e.dotfiles):1;if(s===-1)throw new TypeError('dotfiles option must be "allow", "deny", or "ignore"');let o=e.extensions!==void 0?P1(e.extensions,"extensions option"):[],a=e.immutable!==void 0?!!e.immutable:!1,l=e.index!==void 0?P1(e.index,"index option"):["index.html"],c=e.lastModified!==void 0?!!e.lastModified:!0,u=aQ(e.maxAge??e.maxage),h=e.maxContentRangeChunkSize!==void 0?Number(e.maxContentRangeChunkSize):null,m=e.root?I1(e.root):null,d=Number.isSafeInteger(e.highWaterMark)&&e.highWaterMark>0?e.highWaterMark:null;return{acceptRanges:t,cacheControl:r,contentType:n,etag:i,dotfiles:s,extensions:o,immutable:a,index:l,lastModified:c,maxage:u,maxContentRangeChunkSize:h,root:m,highWaterMark:d,start:e.start,end:e.end}}function cQ(e,t){let r=JX(e);if(r==null)return{statusCode:400};if(~r.indexOf("\0"))return{statusCode:400};let n;if(t!==null){if(r&&(r=fy("."+xu+r)),A1.test(r))return kt('malicious path "%s"',r),{statusCode:403};n=r.split(xu),r=fy($1(t,r))}else{if(A1.test(r))return kt('malicious path "%s"',r),{statusCode:403};n=fy(r).split(xu),r=I1(r)}return{path:r,parts:n}}function N1(e){return e[e.length-1]==="/"}function uQ(e){return e.headers["if-match"]||e.headers["if-unmodified-since"]||e.headers["if-none-match"]||e.headers["if-modified-since"]}function fQ(e,t){if("cache-control"in e.headers&&e.headers["cache-control"].indexOf("no-cache")!==-1)return!1;if("if-none-match"in e.headers){let r=e.headers["if-none-match"];if(r==="*")return!0;let n=t.ETag;if(typeof n!="string")return!1;let i=n.length;return!!C1(r,function(o){let a=o.length;if(i===a&&o===n||i>a&&"W/"+o===n)return!0})}if("if-modified-since"in e.headers){let r=e.headers["if-modified-since"],n=t["Last-Modified"];if(!n||Date.parse(n)<=Date.parse(r))return!0}return!1}function dQ(e,t){let r=e.headers["if-match"];if(r){let n=t.ETag;if(r!=="*"&&(C1(r,function(s){if(s===n||"W/"+s===n)return!0})||!1)!==!0)return!0}if("if-unmodified-since"in e.headers){let n=e.headers["if-unmodified-since"],i=Date.parse(n);if(i===i){let s=Date.parse(t["Last-Modified"]);if(s!==s||s>i)return!0}}return!1}function hQ(e,t){if(!("if-range"in e.headers))return!0;let r=e.headers["if-range"];if(r.indexOf('"')!==-1){let s=t.ETag;return s&&r.indexOf(s)!==-1||!1}let n=Date.parse(r);if(n!==n)return!1;let i=Date.parse(t["Last-Modified"]);return i!==i||i<=n}function dy(e){return new Promise(t=>{k1.stat(e,function(n,i){t({error:n,stat:i})})})}function jr(e,t){let r={};if(t&&t.headers)for(let i in t.headers)r[i]=t.headers[i];let n=sQ[e];return r["Content-Type"]="text/html; charset=utf-8",r["Content-Length"]=n[1],r["Content-Security-Policy"]="default-src 'none'",r["X-Content-Type-Options"]="nosniff",{statusCode:e,headers:r,stream:Pu.from(n[0]),type:"error",metadata:{error:tQ(e,t)}}}function hy(e){switch(e.code){case"ENAMETOOLONG":case"ENOTDIR":case"ENOENT":return jr(404,e);default:return jr(500,e)}}function pQ(e,t,r){return kt("not modified"),delete e["Content-Encoding"],delete e["Content-Language"],delete e["Content-Length"],delete e["Content-Range"],delete e["Content-Type"],{statusCode:304,headers:e,stream:Pu.from(""),type:"file",metadata:{path:t,stat:r}}}function py(e,t,r,n){let i=r.size,s=n.start??0,o=200,a={};if(kt('send "%s"',t),n.acceptRanges&&(kt("accept ranges"),a["Accept-Ranges"]="bytes"),n.cacheControl){let c="public, max-age="+Math.floor(n.maxage/1e3);n.immutable&&(c+=", immutable"),kt("cache-control %s",c),a["Cache-Control"]=c}if(n.lastModified){let c=r.mtime.toUTCString();kt("modified %s",c),a["Last-Modified"]=c}if(n.etag){let c='W/"'+r.size.toString(16)+"-"+r.mtime.getTime().toString(16)+'"';kt("etag %s",c),a.ETag=c}if(n.contentType){let c=O1.getType(t)||O1.default_type;kt("content-type %s",c),c&&ZX(c)&&(c+="; charset=utf-8"),c&&(a["Content-Type"]=c)}if(uQ(e)){if(dQ(e,a))return jr(412);if(fQ(e,a))return pQ(a,t,r)}if(i=Math.max(0,i-s),n.end!==void 0){let c=n.end-s+1;i>c&&(i=c)}if(n.acceptRanges){let c=e.headers.range;if(c!==void 0&&nQ.test(c))if(hQ(e,a)){let u=eQ(i,c);if(u.length===0)return kt("range unsatisfiable"),a["Content-Range"]=x1("bytes",i),jr(416,{headers:{"Content-Range":a["Content-Range"]}});u.length===1&&(kt("range %j",u),o=206,n.maxContentRangeChunkSize&&(u[0].end=Math.min(u[0].end,u[0].start+n.maxContentRangeChunkSize-1)),a["Content-Range"]=x1("bytes",i,u[0]),s+=u[0].start,i=u[0].end-u[0].start+1)}else kt("range stale")}if(a["Content-Length"]=i,e.method==="HEAD")return{statusCode:o,headers:a,stream:Pu.from(""),type:"file",metadata:{path:t,stat:r}};let l=k1.createReadStream(t,{highWaterMark:n.highWaterMark,start:s,end:Math.max(s,s+i-1)});return{statusCode:o,headers:a,stream:l,type:"file",metadata:{path:t,stat:r}}}function mQ(e,t){if(N1(t.path))return jr(403);let r=encodeURI(XX(t.path+"/")),n=di("Redirecting","Redirecting to "+KX(r)),i={};return i["Content-Type"]="text/html; charset=utf-8",i["Content-Length"]=n[1],i["Content-Security-Policy"]="default-src 'none'",i["X-Content-Type-Options"]="nosniff",i.Location=r,{statusCode:301,headers:i,stream:Pu.from(n[0]),type:"directory",metadata:{requestPath:t.path,path:e}}}async function gQ(e,t,r){let n;for(let i=0;i<r.index.length;i++){let s=r.index[i],o=$1(t,s),{error:a,stat:l}=await dy(o);if(a){n=a;continue}if(!l.isDirectory())return py(e,o,l,r)}return n?hy(n):jr(404)}async function yQ(e,t,r){let{error:n,stat:i}=await dy(t);if(n&&n.code==="ENOENT"&&!rQ(t)&&t[t.length-1]!==xu){let s=n;for(let o=0;o<r.extensions.length;o++){let a=r.extensions[o],l=t+"."+a,{error:c,stat:u}=await dy(l);if(c){s=c;continue}if(u.isDirectory()){s=null;continue}return py(e,l,u,r)}return s?hy(s):jr(404)}return n?hy(n):i.isDirectory()?mQ(t,r):py(e,t,i,r)}async function _Q(e,t,r){let n=lQ(r);n.path=t;let i=cQ(t,n.root),{path:s,parts:o}=i;if(i.statusCode!==void 0)return jr(i.statusCode);if((kt.enabled||n.dotfiles!==0)&&QX(o))switch(n.dotfiles){case 0:kt('allow dotfile "%s"',s);break;case 2:return kt('deny dotfile "%s"',s),jr(403);case 1:default:return kt('ignore dotfile "%s"',s),jr(404)}return n.index.length&&N1(t)?gQ(e,s,n):yQ(e,s,n)}L1.exports.send=_Q});var D1=R((Qoe,ws)=>{"use strict";var vQ=ey().isUtf8MimeType,SQ=ty(),my=j1().send;ws.exports=my;ws.exports.default=my;ws.exports.send=my;ws.exports.isUtf8MimeType=vQ;ws.exports.mime=SQ});var q1=R((Zoe,ga)=>{"use strict";function yy(e){if(!new.target)return new yy(e);let{supportedValues:t=[],cache:r}=e&&typeof e=="object"&&e||{};this.supportedValues=t,this.cache=r}yy.prototype.negotiate=function(e){return typeof e!="string"?null:this.cache?(this.cache.has(e)||this.cache.set(e,ma(e,this.supportedValues)),this.cache.get(e)):ma(e,this.supportedValues)};function ma(e,t){if(!e||!Array.isArray(t)||t.length===0)return null;if(e==="*")return t[0];let r=null,n=1/0,i=0;function s(o,a){if(a===0||i>a)return!1;let l=o==="*"&&t[0]||o,c=t.indexOf(l);return c===-1?!1:c===0&&a===1?(r=l,!0):((i<a||n>c)&&(r=l,n=c,i=a),!1)}return wQ(e,s),r}var ha=0,pa=1,Au=2,gy=3;function wQ(e,t){let r="",n,i=ha;for(let s=0,o=e.length;s<o;++s){let a=e[s];if(!(a===" "||a===" ")){if(a===";"){i===pa&&(i=Au,n="");continue}else if(a===","){if(i===pa){if(t(r,1)){i=gy;break}i=ha,r=""}else if(i===Au){if(t(r,parseFloat(n)||0)){i=gy;break}i=ha,r="",n=""}continue}else if(i===Au){if(a==="q"||a==="=")continue;if(a==="."||a==="1"||a==="0"||a==="2"||a==="3"||a==="4"||a==="5"||a==="6"||a==="7"||a==="8"||a==="9"){n+=a;continue}}else if(i===ha){i=pa,r+=a;continue}if(i===pa){let l=e[s-1];(l===" "||l===" ")&&(r=""),r+=a;continue}if(t(r,parseFloat(n)||0)){i=gy;break}i=ha,r=a,n=""}}i===pa?t(r,1):i===Au&&t(r,parseFloat(n)||0)}ga.exports=ma;ga.exports.default=ma;ga.exports.negotiate=ma;ga.exports.Negotiator=yy});var V1=R((eae,_y)=>{"use strict";_y.exports=kQ;_y.exports.parse=NQ;var bQ=new TextDecoder("utf-8"),EQ=/[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g,z1=/[^\x20-\x7e\xa0-\xff]/g,RQ=/\\([\u0000-\u007f])/g,TQ=/([\\"])/g,F1=/;[\x09\x20]*([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*=[\x09\x20]*("(?:[\x20!\x23-\x5b\x5d-\x7e\x80-\xff]|\\[\x20-\x7e])*"|[!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*/g,OQ=/^[\x20-\x7e\x80-\xff]+$/,xQ=/^[!#$%&'*+.0-9A-Z^_`a-z|~-]+$/,PQ=/^([A-Za-z0-9!#$%&+\-^_`{}~]+)'(?:[A-Za-z]{2,3}(?:-[A-Za-z]{3}){0,3}|[A-Za-z]{4,8}|)'((?:%[0-9A-Fa-f]{2}|[A-Za-z0-9!#$&+.^_`|~-])+)$/,AQ=/^([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*(?:$|;)/;function kQ(e,t){var r=t||{},n=r.type||"attachment",i=CQ(e,r.fallback);return $Q(new B1(n,i))}function CQ(e,t){if(e!==void 0){var r={};if(typeof e!="string")throw new TypeError("filename must be a string");if(t===void 0&&(t=!0),typeof t!="string"&&typeof t!="boolean")throw new TypeError("fallback must be a string or boolean");if(typeof t=="string"&&z1.test(t))throw new TypeError("fallback must be ISO-8859-1 string");var n=M1(e),i=OQ.test(n),s=typeof t!="string"?t&&U1(n):M1(t),o=typeof s=="string"&&s!==n;return(o||!i||qQ(n))&&(r["filename*"]=n),(i||o)&&(r.filename=o?s:n),r}}function $Q(e){var t=e.parameters,r=e.type;if(!r||typeof r!="string"||!xQ.test(r))throw new TypeError("invalid type");var n=String(r).toLowerCase();if(t&&typeof t=="object")for(var i,s=Object.keys(t).sort(),o=0;o<s.length;o++){i=s[o];var a=i.slice(-1)==="*"?DQ(t[i]):jQ(t[i]);n+="; "+i+"="+a}return n}function IQ(e){let t=PQ.exec(e);if(!t)throw new TypeError("invalid extended field value");let r=t[1].toLowerCase(),n=t[2];switch(r){case"iso-8859-1":{let i=H1(n);return U1(i)}case"utf-8":case"utf8":try{return decodeURIComponent(n)}catch{let i=H1(n),s=new Uint8Array(i.length);for(let o=0;o<i.length;o++)s[o]=i.charCodeAt(o);return bQ.decode(s)}}throw new TypeError("unsupported charset in extended field")}function U1(e){return String(e).replace(z1,"?")}function NQ(e){if(!e||typeof e!="string")throw new TypeError("argument string is required");var t=AQ.exec(e);if(!t)throw new TypeError("invalid type format");var r=t[0].length,n=t[1].toLowerCase(),i,s=[],o={},a;for(r=F1.lastIndex=t[0].slice(-1)===";"?r-1:r;t=F1.exec(e);){if(t.index!==r)throw new TypeError("invalid parameter format");if(r+=t[0].length,i=t[1].toLowerCase(),a=t[2],s.indexOf(i)!==-1)throw new TypeError("invalid duplicate parameter");if(s.push(i),i.indexOf("*")+1===i.length){i=i.slice(0,-1),a=IQ(a),o[i]=a;continue}typeof o[i]!="string"&&(a[0]==='"'&&(a=a.slice(1,-1).replace(RQ,"$1")),o[i]=a)}if(r!==-1&&r!==e.length)throw new TypeError("invalid parameter format");return new B1(n,o)}function LQ(e){return"%"+String(e).charCodeAt(0).toString(16).toUpperCase()}function jQ(e){var t=String(e);return'"'+t.replace(TQ,"\\$1")+'"'}function DQ(e){var t=String(e),r=encodeURIComponent(t).replace(EQ,LQ);return"UTF-8''"+r}function B1(e,t){this.type=e,this.parameters=t}function M1(e){let t=e.replaceAll("\\","/"),r=t.length;for(;r>0&&t[r-1]==="/";)r--;if(r===0)return"";let n=r-1;for(;n>=0&&t[n]!=="/";)n--;return t.slice(n+1,r)}function ku(e){let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function qQ(e){let t=e.length-3,r=-1;for(;(r=e.indexOf("%",r+1))!==-1&&r<=t;)if(ku(e[r+1])&&ku(e[r+2]))return!0;return!1}function H1(e){let t=e.indexOf("%");if(t===-1)return e;let r=e.slice(0,t);for(let n=t;n<e.length;n++)e[n]==="%"&&n+2<e.length&&ku(e[n+1])&&ku(e[n+2])?(r+=String.fromCharCode(Number.parseInt(e[n+1]+e[n+2],16)),n+=2):r+=e[n];return r}});var K1=R((tae,J1)=>{"use strict";var FQ=ee("node:os"),bt=ee("node:path"),Cu=ee("node:fs/promises"),G1=Bu(),W1=Math.max(1,FQ.cpus().length-1);function MQ(e,t){let r=bt.relative(e,t);return r===""||r!==".."&&!r.startsWith(`..${bt.sep}`)&&!bt.isAbsolute(r)}var hi={_getExtendedInfo:async function(e,t){let r=e.split(bt.sep).length,n=await Cu.readdir(e),i=async o=>{let a=bt.join(e,o),l;try{l=await Cu.stat(a)}catch{return}l.isDirectory()?(t.totalFolderCount++,a.split(bt.sep).length===r+1&&t.folderCount++,await hi._getExtendedInfo(a,t)):(t.totalSize+=l.size,t.totalFileCount++,a.split(bt.sep).length===r+1&&t.fileCount++,t.lastModified=Math.max(t.lastModified,l.mtimeMs))},s=G1.promise(i,W1);await Promise.all(n.map(o=>s.push(o)))},getExtendedInfo:async function(e){let t={totalSize:0,fileCount:0,totalFileCount:0,folderCount:0,totalFolderCount:0,lastModified:0};return await hi._getExtendedInfo(e,t),t},list:async function(e,t,r){let n={dirs:[],files:[]},i=await Cu.readdir(e);if((r==="deny"||r==="ignore")&&(i=i.filter(a=>a.charAt(0)!==".")),i.length<1)return n;let s=async a=>{let l;try{l=await Cu.stat(bt.join(e,a))}catch{return}let c={name:a,stats:l};l.isDirectory()?(t.extendedFolderInfo&&(c.extendedInfo=await hi.getExtendedInfo(bt.join(e,a))),n.dirs.push(c)):n.files.push(c)},o=G1.promise(s,W1);return await Promise.all(i.map(a=>o.push(a))),n.dirs.sort((a,l)=>a.name.localeCompare(l.name)),n.files.sort((a,l)=>a.name.localeCompare(l.name)),n},send:async function({reply:e,dir:t,options:r,route:n,prefix:i,dotfiles:s}){if(e.request.query.format==="html"&&typeof r.render!="function")throw new TypeError("The `list.render` option must be a function and is required with the URL parameter `format=html`");let o;try{o=await hi.list(t,r,s)}catch{return e.callNotFound()}if((e.request.query.format||r.format)!=="html"){if(r.jsonFormat!=="extended"){let c={dirs:[],files:[]};o.dirs.forEach(u=>c.dirs.push(u.name)),o.files.forEach(u=>c.files.push(u.name)),await e.send(c)}else await e.send(o);return}let l=r.render(o.dirs.map(c=>hi.htmlInfo(c,n,i,r)),o.files.map(c=>hi.htmlInfo(c,n,i,r)));await e.type("text/html").send(l)},htmlInfo:function(e,t,r,n){return n.names?.includes(bt.basename(t))&&(t=bt.posix.normalize(bt.posix.join(t,".."))),{href:encodeURI(bt.posix.join(r,t,e.name)),name:e.name,stats:e.stats,extendedInfo:e.extendedInfo}},handle:function(e,t){return t.names?.includes(bt.basename(e))||((t.names?.includes("/")&&e[e.length-1]==="/")??!1)},path:function(e,t){let r=t[t.length-1]==="/"?"."+t+"none":"."+t,n=bt.resolve(e),i=bt.dirname(bt.resolve(n,r));return MQ(n,i)?i:null},validateOptions:function(e){if(e.list){if(Array.isArray(e.root))return new TypeError("multi-root with list option is not supported");if(e.list.format&&e.list.format!=="json"&&e.list.format!=="html")return new TypeError("The `list.format` option must be json or html");if(e.list.names&&!Array.isArray(e.list.names))return new TypeError("The `list.names` option must be an array");if(e.list.jsonFormat!=null&&e.list.jsonFormat!=="names"&&e.list.jsonFormat!=="extended")return new TypeError("The `list.jsonFormat` option must be name or extended");if(e.list.format==="html"&&typeof e.list.render!="function")return new TypeError("The `list.render` option must be a function and is required with html format")}}};J1.exports=hi});var r$=R((rae,$u)=>{"use strict";var tn=ee("node:path"),{fileURLToPath:Y1}=ee("node:url"),{statSync:t$}=ee("node:fs"),{glob:HQ}=OC(),zQ=CC(),_a=D1(),UQ=q1(),BQ=V1(),ya=K1(),X1=/\/$/u,VQ=/\*/gu,GQ=["br","gzip","deflate"];_a.mime.default_type="application/octet-stream";var Q1={br:".br",gzip:".gz"};async function Sy(e,t){(t.serve!==!1||t.root!==void 0)&&(t.root=WQ(t.root),JQ(e,t.root));let r=t.setHeaders;if(r!==void 0&&typeof r!="function")throw new TypeError("The `setHeaders` option must be a function");let n=ya.validateOptions(t);if(n)throw n;t.dotfiles??="allow";let i={root:t.root,acceptRanges:t.acceptRanges,contentType:t.contentType,cacheControl:t.cacheControl,dotfiles:t.dotfiles,etag:t.etag,extensions:t.extensions,immutable:t.immutable,index:t.index,lastModified:t.lastModified,maxAge:t.maxAge},s=t.prefix??="/";t.prefixAvoidTrailingSlash||(s=s[s.length-1]==="/"?s:s+"/");let o={constraints:t.constraints,schema:{hide:t.schemaHide??!0},logLevel:t.logLevel,errorHandler(m,d,f){if(m?.code==="ERR_STREAM_PREMATURE_CLOSE"){f.request.raw.destroy();return}e.errorHandler(m,d,f)}};if(t.decorateReply!==!1&&(e.decorateReply("sendFile",function(m,d,f){let p=typeof d=="object"?d:f,g=typeof d=="string"?d:p?.root;return c(this.request,this,m,g||i.root,0,p),this}),e.decorateReply("download",function(m,d,f={}){let{root:p,...g}=typeof d=="object"?d:f;return d=typeof d=="string"?d:m,this.header("content-disposition",BQ(d)),c(this.request,this,m,p,0,g),this})),t.serve!==!1){if(t.wildcard&&typeof t.wildcard!="boolean")throw new TypeError('"wildcard" option must be a boolean');if(t.wildcard===void 0||t.wildcard===!0){let m;e.route({...o,method:["HEAD","GET"],path:s+"*",handler(d,f){m??=ZQ(d.routeOptions.url);let p=eZ(d.raw.url,m);if(!p)return f.callNotFound();c(d,f,p,i.root)}}),t.redirect===!0&&s!==t.prefix&&e.get(t.prefix,o,(d,f)=>{f.redirect(e$(d.raw.url),301)})}else{let m=new Set(t.index===void 0?["index.html"]:[].concat(t.index)),d=new Map,f=new Set,p=Array.isArray(i.root)?i.root:[i.root];for(let g of p){g=g.split(tn.win32.sep).join(tn.posix.sep),!g.endsWith("/")&&(g+="/");let _=await HQ("**/**",{cwd:g,absolute:!1,follow:!0,nodir:!0,dot:t.serveDotFiles,ignore:t.globIgnore});for(let w of _){w=w.split(tn.win32.sep).join(tn.posix.sep);let S=s+w;if(f.has(S))continue;f.add(S),u(o,S,`/${w}`,g);let v=tn.posix.basename(S);m.has(v)&&!d.has(v)&&d.set(tn.posix.dirname(S),g)}}for(let[g,_]of d.entries()){let w=g+(g.endsWith("/")?"":"/"),S="/"+w.replace(s,"");u(o,w,S,_),t.redirect===!0&&u(o,w.replace(X1,""),S.replace(X1,""),_)}}}let a=t.allowedPath;async function l(m,d){let f=ya.path(t.root,d);return f?(await ya.send({reply:m,dir:f,options:t.list,route:d,prefix:s,dotfiles:t.dotfiles}).catch(p=>m.send(p)),!0):!1}async function c(m,d,f,p,g=0,_,w){let S=f,v=Object.assign({},i,_);if(p)Array.isArray(p)?v.root=p[g]:v.root=p;else if(tn.isAbsolute(f)===!1)return d.callNotFound();if(a&&!a(f,v.root,m))return d.callNotFound();let E,A=f;if(t.preCompressed&&(w??=new Set,E=YQ(m.headers,w),E))if(f.endsWith("/")){if(f=vy(f,v.root,v.index),!f)return d.callNotFound();A=A+f+Q1[E]}else A=f+Q1[E];let{statusCode:P,headers:T,stream:$,type:x,metadata:C}=await _a(m.raw,encodeURI(A),v);switch(x){case"directory":{let I=C.path;if(t.list&&await ya.send({reply:d,dir:I,options:t.list,route:f,prefix:s,dotfiles:t.dotfiles}).catch(j=>d.send(j)),t.redirect===!0)try{d.redirect(e$(m.raw.url),301)}catch(j){await d.send(j)}else{if(!f.endsWith("/")&&vy(f,v.root,v.index))return c(m,d,f+"/",p,void 0,_,w);d.callNotFound()}break}case"error":{if(P===403&&(!v.index||!v.index.length)&&A[A.length-1]==="/"&&t.list&&await l(d,f))return;if(C.error.code==="ENOENT")return t.preCompressed&&E&&t.redirect!==!0&&vy(f,v.root,v.index)?c(m,d,f+"/",p,void 0,_,w):t.list&&ya.handle(f,t.list)&&await l(d,f)?void 0:Array.isArray(p)&&g<p.length-1?c(m,d,f,p,g+1,_,void 0):t.preCompressed&&!w.has(E)?(w.add(E),c(m,d,S,p,g,_,w)):d.callNotFound();if(C.error.status===404)return d.callNotFound();await d.send(C.error);break}case"file":{let I=d.statusCode!==200?d.statusCode:P;d.code(I),r?.(d.raw,C.path,C.stat),d.headers(T),E&&(d.header("content-type",KQ(f)),d.header("content-encoding",E)),await d.send($);break}}}function u(m,d,f,p){let g=Object.assign({},m,{method:["HEAD","GET"],url:d,handler:h});g.config??={},g.config.file=f,g.config.rootPath=p,e.route(g)}async function h(m,d){let f=m.routeOptions?.config;return c(m,d,f.file,f.rootPath)}}function WQ(e){if(e===void 0)return e;if(e instanceof URL&&e.protocol==="file:")return Y1(e);if(Array.isArray(e)){let t=[];for(let r=0,n=e.length;r<n;++r)e[r]instanceof URL&&e[r].protocol==="file:"?t.push(Y1(e[r])):t.push(e[r]);return t}return e}function JQ(e,t){if(t===void 0)throw new Error('"root" option is required');if(Array.isArray(t)){if(!t.length)throw new Error('"root" option array requires one or more paths');if(new Set(t).size!==t.length)throw new Error('"root" option array contains one or more duplicate paths');t.map(r=>Z1(e,r));return}if(typeof t=="string")return Z1(e,t);throw new Error('"root" option must be a string or array of strings')}function Z1(e,t){if(typeof t!="string")throw new TypeError('"root" option must be a string');if(tn.isAbsolute(t)===!1)throw new Error('"root" option must be an absolute path');let r;try{r=t$(t)}catch(n){if(n.code==="ENOENT"){e.log.warn(`"root" path "${t}" must exist`);return}throw n}if(r.isDirectory()===!1)throw new Error('"root" option must point to a directory')}function KQ(e){let t=_a.mime.getType(e)||_a.mime.default_type;return _a.isUtf8MimeType(t)?`${t}; charset=utf-8`:t}function vy(e,t,r=["index.html"]){return Array.isArray(r)?r.find(n=>{let i=tn.join(t,e,n);try{return!t$(i).isDirectory()}catch{return!1}}):!1}function YQ(e,t){if(!("accept-encoding"in e))return;let r=e["accept-encoding"].toLowerCase().replace(VQ,"gzip");return UQ.negotiate(r,GQ.filter(n=>!t.has(n)))}function XQ(e){let t=[],r=0,n=0;for(;r<e.length;){if(e[r]!==":"){r++;continue}for(n!==r&&t.push(e.slice(n,r)),r++;r<e.length&&e[r]!=="/";)r++;t.push(void 0),n=r}return n!==e.length&&t.push(e.slice(n)),t}function QQ(e,t,r){let n=0;for(let i of r){if(i===void 0){let o=n,a=e.indexOf("/",n);if(n=a===-1||a>t?t:a,n===o)return;continue}let s=n+i.length;if(s>t||!e.startsWith(i,n))return;n=s}return n}function ZQ(e){let t=e.replace(/\*$/u,""),r=t.length;if(t==="/")return()=>0;if(t.includes(":")===!1)return(i,s)=>r<=s&&i.startsWith(t)?r:void 0;let n=XQ(t);return(i,s)=>QQ(i,s,n)}function eZ(e,t){let r=e.indexOf("?"),n=r===-1?e.length:r,i=t(e,n);if(i===void 0)return;let s=e.slice(i,n);s===""?s="/":s.startsWith("/")||(s="/"+s);try{return decodeURI(s)}catch{}}function e$(e){let t=0;for(let r=e.length;t<r&&!(e[t]!=="/"&&e[t]!=="\\");++t);e="/"+e.slice(t);try{let r=new URL(e,"http://localhost.com/"),n=r.pathname;return n+(n[n.length-1]!=="/"?"/":"")+(r.search||"")}catch{let r=new Error(`Invalid redirect URL: ${e}`);throw r.statusCode=400,r}}$u.exports=zQ(Sy,{fastify:"5.x",name:"@fastify/static"});$u.exports.default=Sy;$u.exports.fastifyStatic=Sy});var X$=zy(cC(),1),Q$=zy(r$(),1);import{existsSync as My,readFileSync as Uee}from"node:fs";import{spawn as Bee}from"node:child_process";import{copyFileSync as tZ,existsSync as wy,mkdirSync as rZ}from"node:fs";import{homedir as bs}from"node:os";import{dirname as nZ,join as jt}from"node:path";import{fileURLToPath as iZ}from"node:url";var by=nZ(iZ(import.meta.url));function n$(e,t){return e.find(r=>wy(r))??t}var Ey=Number(process.env.PORT??4317),Iu=jt(by,"..");function Lu(e){return e==="~"?bs():e.startsWith("~/")?jt(bs(),e.slice(2)):e}var pi=Lu(process.env.CLAUDE_PROJECTS_DIR??jt(bs(),".claude","projects")),Ry=Lu(process.env.CODEX_SESSIONS_DIR??jt(bs(),".codex","sessions")),ju=Lu(process.env.JUNIE_SESSIONS_DIR??jt(bs(),".junie","sessions")),i$=process.env.OPEN_BROWSER==="1",Ty=Number(process.env.REINDEX_INTERVAL_MS??15e3),kn=Lu(process.env.CLAUDESCOPE_HOME??jt(bs(),".claudescope")),Sa=process.env.DUCKDB_PATH??jt(kn,"index.duckdb"),Nu=n$([jt(by,"pricing.default.json"),jt(Iu,"pricing.json")],jt(Iu,"pricing.json")),va=process.env.PRICING_PATH??jt(kn,"pricing.json"),Sr=process.env.FETCHED_PRICING_PATH??jt(kn,"pricing.fetched.json"),s$=process.env.LITELLM_PRICING_URL??"https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json",Oy=Number(process.env.PRICING_REFRESH_INTERVAL_MS??24*60*60*1e3),Du=process.env.WEB_DIST_DIR??n$([jt(by,"web"),jt(Iu,"..","web","dist")],jt(Iu,"..","web","dist")),qu="0.5.1";function o$(){rZ(kn,{recursive:!0}),!wy(va)&&wy(Nu)&&tZ(Nu,va)}import{createHash as sZ}from"node:crypto";import{mkdirSync as oZ,rmSync as aZ}from"node:fs";import{dirname as lZ}from"node:path";import{DuckDBInstance as cZ}from"@duckdb/node-api";var xy=["CREATE TABLE IF NOT EXISTS meta (key VARCHAR PRIMARY KEY, value VARCHAR)",`CREATE TABLE IF NOT EXISTS files (
393
393
  path VARCHAR PRIMARY KEY,
394
394
  mtime_ms BIGINT NOT NULL,
395
395
  size_bytes BIGINT NOT NULL,