@psnext/slingcli 3.3.20260918-1 → 3.3.20260922-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.
Files changed (29) hide show
  1. package/node_modules/@types/node/README.md +2 -2
  2. package/node_modules/@types/node/package.json +2 -17
  3. package/node_modules/lru-cache/dist/commonjs/react-native/diagnostics-channel-react-native.d.ts.map +1 -0
  4. package/node_modules/lru-cache/dist/commonjs/react-native/diagnostics-channel-react-native.js.map +1 -0
  5. package/node_modules/lru-cache/dist/commonjs/react-native/diagnostics-channel.d.ts +5 -0
  6. package/node_modules/lru-cache/dist/commonjs/react-native/diagnostics-channel.js +7 -0
  7. package/node_modules/lru-cache/dist/commonjs/react-native/index.d.ts +1400 -0
  8. package/node_modules/lru-cache/dist/commonjs/react-native/index.d.ts.map +1 -0
  9. package/node_modules/lru-cache/dist/commonjs/react-native/index.js +1733 -0
  10. package/node_modules/lru-cache/dist/commonjs/react-native/index.js.map +1 -0
  11. package/node_modules/lru-cache/dist/commonjs/react-native/perf.d.ts +12 -0
  12. package/node_modules/lru-cache/dist/commonjs/react-native/perf.d.ts.map +1 -0
  13. package/node_modules/lru-cache/dist/commonjs/react-native/perf.js +10 -0
  14. package/node_modules/lru-cache/dist/commonjs/react-native/perf.js.map +1 -0
  15. package/node_modules/lru-cache/dist/esm/react-native/diagnostics-channel-react-native.d.ts.map +1 -0
  16. package/node_modules/lru-cache/dist/esm/react-native/diagnostics-channel-react-native.js.map +1 -0
  17. package/node_modules/lru-cache/dist/esm/react-native/diagnostics-channel.d.ts +5 -0
  18. package/node_modules/lru-cache/dist/esm/react-native/diagnostics-channel.js +4 -0
  19. package/node_modules/lru-cache/dist/esm/react-native/index.d.ts +1400 -0
  20. package/node_modules/lru-cache/dist/esm/react-native/index.d.ts.map +1 -0
  21. package/node_modules/lru-cache/dist/esm/react-native/index.js +1729 -0
  22. package/node_modules/lru-cache/dist/esm/react-native/index.js.map +1 -0
  23. package/node_modules/lru-cache/dist/esm/react-native/perf.d.ts +12 -0
  24. package/node_modules/lru-cache/dist/esm/react-native/perf.d.ts.map +1 -0
  25. package/node_modules/lru-cache/dist/esm/react-native/perf.js +7 -0
  26. package/node_modules/lru-cache/dist/esm/react-native/perf.js.map +1 -0
  27. package/node_modules/lru-cache/package.json +27 -1
  28. package/package.json +2 -2
  29. package/slingshot/index.js +2 -2
@@ -447,11 +447,11 @@ Log file: ${zr}
447
447
  `;Yo.appendFileSync(zr,n)}catch{}}function Ge(t,e){if(!(!zr||!Yo||!gd))try{let i=`[${new Date().toISOString()}] ${t}:
448
448
  ${JSON.stringify(e,null,2)}
449
449
 
450
- `;Yo.appendFileSync(zr,i)}catch{}}var fr=null,c2=!1;function GZ(t){if(!t)return;let e=t.trim();if(e)return e.replace(/\/+$/,"")}var $=class t{static{this.BASE_URL="base_url"}static{this.ANALYTICS_DOMAIN="analytics_domain"}static{this.CLIENT_ID="client_id"}static{this.PROJECT_ID="project_id"}static{this.WORKSPACE_ID="workspace_id"}static{this.PROJECT_NAME="project_name"}static{this.WORKSPACE_NAME="workspace_name"}static{this.CLIENT_DISPLAY_NAME="client_name"}static{this.SCHEMA_VERSION="schema_version"}static{this.ACTIVE_CLIENT="active_client"}static{this.KNOWN_CLIENTS="known_clients"}static{this.ECG_ENABLED="ecg_enabled"}static{this.ECG_RESOURCES="ecg_resources"}static{this.ECG_DOMAIN="ecg_domain"}static{this.CURRENT_SCHEMA_VERSION=2}static{this.ANALYTICS_HOST_PREFIX="slingshot"}static{this.CACHE_CONTROL="cache_control"}static{this.APP_TOKEN_HOST_EXCEPTIONS={"sapientaiproducts.com":"https://slingshot.sapientaiproducts.com","uat.sapientaiproducts.com":"https://uat-slingshot.sapientaiproducts.com","dev.sapientaiproducts.com":"https://dev-slingshot.sapientaiproducts.com"}}static{this.defaultValues={[t.BASE_URL]:"https://sapientaiproducts.com",[t.ANALYTICS_DOMAIN]:"https://slingshot.sapientaiproducts.com",[t.CLIENT_ID]:"b97fbef7-cad9-4e56-9850-39e86c8fdf61",[t.PROJECT_ID]:"fa8121c4-e2fc-48f1-9478-8949c04e13cc",[t.WORKSPACE_ID]:"6e5756eb-d7e2-4d80-ad07-9d7a51600d85",[t.CACHE_CONTROL]:"5m"}}static defaultsFor(e){let n=String(e[this.BASE_URL]||this.defaultValues[this.BASE_URL]||"");if(this.makeClientKey(n)===this.getDefaultClientKey())return this.defaultValues;let i={...this.defaultValues};for(let r of[this.ANALYTICS_DOMAIN,this.CLIENT_ID,this.PROJECT_ID,this.WORKSPACE_ID])delete i[r];return i}static{this.LOGIN_PATH="/web/v1/studio-auth/login"}static{this.EXCHANGE_PATH="/api/v1/studio-auth/auth/desktop/exchange"}static{this.REFRESH_PATH="/api/v3/auth/refreshtoken"}static{this.QUERY_CLIENTS_PATH="/api/v2/projects/clients/queryClients"}static{this.API_BASE_PATH="/api/v1/llm"}static{this.SAGE_EVENTS_PATH="/api/v1/ai-portal/sage_events"}static{this.APP_TOKEN_PATH="/api/v1/ai-auth/token/app"}static{this.ECG_MCP_PATH="/api/v1/ecg/mcp"}static{this.USER_RESOURCES_PATH="/api/v1/ai-auth/auth/user"}static{this.SLINGSHOT_RAG_MCP="/api/v1/ai-prompt-lib/mcp/"}static{this.SAPI="/save/api/v1"}static{this.REFRESH_CLIENT_NAME="machine"}static{this.APP_TOKEN_REFRESH_BUFFER_MS=60*1e3}static{this.TOKEN_EXPIRY_BUFFER_MS=300*1e3}static{this.CLIENT_NAME="desktop"}static defaults(e){return this.defaultValues[e]}static deriveAnalyticsDomain(e){let n=(e||"").trim().replace(/\/+$/,"");if(!n)return"";let i;try{i=new URL(n)}catch{return""}return i.hostname?(i.hostname.startsWith(`${this.ANALYTICS_HOST_PREFIX}.`)||(i.hostname=`${this.ANALYTICS_HOST_PREFIX}.${i.hostname}`),`${i.protocol}//${i.host}`):""}static resolveAppTokenDomainForSave(e){let n=(e||"").trim().replace(/\/+$/,"");if(!n)return"";let i;try{i=new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(n)?n:`https://${n}`)}catch{return n}if(!i.hostname)return n;let r=`${i.protocol}//${i.host}`;return this.APP_TOKEN_HOST_EXCEPTIONS[i.host.toLowerCase()]||r}static makeClientKey(e){try{return new URL((e||"").trim()).host}catch{return""}}static makeClientLabel(e){return this.makeClientKey(e)||e}static toKnownClient(e){let n=String(e[this.BASE_URL]||"");if(!this.makeClientKey(n))return null;let i=s=>String(e[s]||""),r=i(this.ANALYTICS_DOMAIN),o=i(this.CLIENT_DISPLAY_NAME);return{label:this.makeClientLabel(n),domain:n,client_id:i(this.CLIENT_ID),project_id:i(this.PROJECT_ID),project_name:i(this.PROJECT_NAME),workspace_id:i(this.WORKSPACE_ID),workspace_name:i(this.WORKSPACE_NAME),...r?{analytics_domain:r}:{},...o?{client_name:o}:{}}}static persist(e,n){let i=xd.dirname(e);Zt.existsSync(i)||Zt.mkdirSync(i,{recursive:!0}),Zt.writeFileSync(e,JSON.stringify(n,null,2),"utf-8")}static migrate(e,n,i){if(e[this.SCHEMA_VERSION]===this.CURRENT_SCHEMA_VERSION)return e;let r=String(e[this.BASE_URL]||""),o=this.makeClientKey(r),s={...e[this.KNOWN_CLIENTS]||{}};if(o&&!s[o]){let l=this.toKnownClient(e);l&&(s[o]=l)}let a={[this.SCHEMA_VERSION]:this.CURRENT_SCHEMA_VERSION,[this.ACTIVE_CLIENT]:e[this.ACTIVE_CLIENT]||o,[this.KNOWN_CLIENTS]:s};if(n===this.getGlobalSettingsPath())try{this.persist(n,{...i,...a})}catch(l){Ge("Error persisting sling.settings.json migration: ",l)}return{...e,...a}}static readGlobalSettings(){let e=this.getGlobalSettingsPath();try{let n=Zt.existsSync(e)?Zt.readFileSync(e,"utf-8"):"",i=n?JSON.parse(n)||{}:{};return this.migrate({...this.defaultsFor(i),...i},e,i)}catch(n){return Ge("Error reading global sling.settings.json: ",n),{...this.defaultValues}}}static getClientRegistry(){let e=this.readGlobalSettings()[this.KNOWN_CLIENTS];return{activeKey:String(this.getSettings()[this.ACTIVE_CLIENT]||""),clients:e&&typeof e=="object"?e:{}}}static getKnownClients(){return this.getClientRegistry().clients}static getGlobalActiveClientKey(){return String(this.readGlobalSettings()[this.ACTIVE_CLIENT]||"")}static writeRegistry(e){this.updateSettings({[this.KNOWN_CLIENTS]:e},{scope:"global"})}static patchActiveClient(e){let{activeKey:n,clients:i}=this.getClientRegistry(),r=n?i[n]:void 0;r&&this.writeRegistry({...i,[n]:{...r,...e}})}static applyClient(e,n){let i=this.makeClientKey(e.domain),r=n?.scope??this.resolveWriteScope(),o=this.resolveAppTokenDomainForSave(e.domain),s={...this.getKnownClients()};s[i]={...e,analytics_domain:o,last_used:new Date().toISOString()},this.updateSettings({[this.BASE_URL]:e.domain,[this.ANALYTICS_DOMAIN]:o,[this.CLIENT_ID]:e.client_id||"",[this.PROJECT_ID]:e.project_id||"",[this.WORKSPACE_ID]:e.workspace_id||"",[this.PROJECT_NAME]:e.project_name||"",[this.WORKSPACE_NAME]:e.workspace_name||"",[this.CLIENT_DISPLAY_NAME]:e.client_name||"",[this.ACTIVE_CLIENT]:i,[this.SCHEMA_VERSION]:this.CURRENT_SCHEMA_VERSION},{scope:r}),this.writeRegistry(s)}static recordActiveClientId(e){let n=(e||"").trim();if(!n)return;let{activeKey:i,clients:r}=this.getClientRegistry();(i?r[i]:void 0)?.client_id===n&&this.getDefaultClientId()===n||(this.updateSettings({[this.CLIENT_ID]:n}),this.patchActiveClient({client_id:n}))}static recordActiveAppTokenOverride(e){let n=(e||"").trim();this.patchActiveClient({analytics_domain:n||void 0})}static recordActiveProjectSelection(e){this.patchActiveClient(e)}static hasProjectSelection(){return!!(this.getDefaultProjectId()&&this.getDefaultWorkspaceId())}static getDefaultClientKey(){return this.makeClientKey(String(this.defaultValues[this.BASE_URL]||""))}static removeKnownClient(e){if(!e||e===this.getDefaultClientKey())return!1;let{activeKey:n,clients:i}=this.getClientRegistry();if(e===n||e===this.getGlobalActiveClientKey()||!i[e])return!1;let r={...i};return delete r[e],this.writeRegistry(r),!0}static getLocalSettingsPath(){return xd.resolve(process.cwd(),".sling","sling.settings.json")}static getGlobalSettingsPath(){return xd.resolve(Ee(),"sling.settings.json")}static getSettingsPath(e){return e==="local"?this.getLocalSettingsPath():e==="global"?this.getGlobalSettingsPath():this.getActivePinPath()??this.getGlobalSettingsPath()}static getActivePinPath(){if(c2)return null;let e=this.getLocalSettingsPath();return Zt.existsSync(e)?e:null}static disableLocalSettingsForSession(){c2=!0,fr=null}static getUntrustedPinDomain(){if(!this.getActivePinPath())return null;let e=String(this.getSettings()[this.BASE_URL]||""),n=this.makeClientKey(e);return n?this.getClientRegistry().clients[n]?null:e:null}static trustActivePin(){let e=this.toKnownClient(this.getSettings());if(!e)return!1;let n=this.makeClientKey(e.domain),{clients:i}=this.getClientRegistry();return i[n]||this.writeRegistry({...i,[n]:{...e,last_used:new Date().toISOString()}}),!0}static resolveWriteScope(){return this.getActivePinPath()?"local":"global"}static clearLocalSettings(){let e=this.getLocalSettingsPath();try{return Zt.existsSync(e)?(Zt.unlinkSync(e),fr=null,!0):!1}catch(n){return Ge("Error removing local sling.settings.json: ",n),!1}}static loadSettingsFile(e){if(Zt.existsSync(e)){let i=Zt.readFileSync(e,"utf-8"),r=JSON.parse(i)||{};return this.migrate({...this.defaultsFor(r),...r},e,r)}let n=xd.dirname(e);return Zt.existsSync(n)||Zt.mkdirSync(n,{recursive:!0}),this.migrate({...this.defaultValues},e,{...this.defaultValues})}static getSettings(){if(!fr)try{fr=this.loadSettingsFile(this.getSettingsPath())}catch(n){Ge("Error reading/writing sling.settings.json: ",n);let i=this.getActivePinPath();if(i){Ge("Ignoring unreadable local pin for this session: ",i),this.disableLocalSettingsForSession();try{fr=this.loadSettingsFile(this.getSettingsPath())}catch(r){Ge("Error reading global sling.settings.json: ",r)}}fr||(fr={...this.defaultValues})}let e=GZ(process.env.SLINGSHOT_API_DOMAIN);return{...fr,[t.BASE_URL]:e||fr[t.BASE_URL]}}static updateSettings(e,n){let i=n?.scope??this.resolveWriteScope();if(i==="local"&&this.KNOWN_CLIENTS in e){let{[this.KNOWN_CLIENTS]:r,...o}=e;this.writeToScope({[this.KNOWN_CLIENTS]:r},"global"),Object.keys(o).length>0&&this.writeToScope(o,"local");return}this.writeToScope(e,i)}static writeToScope(e,n){let i=this.getSettingsPath(n);try{let r={};if(Zt.existsSync(i)){let l=Zt.readFileSync(i,"utf-8");r=JSON.parse(l)||{}}let o={...r,...e},s={...this.defaultsFor(o),...o},a=xd.dirname(i);Zt.existsSync(a)||Zt.mkdirSync(a,{recursive:!0}),Zt.writeFileSync(i,JSON.stringify(s,null,2),"utf-8"),fr=null}catch(r){Ge("Error updating sling.settings.json: ",r)}}static getLoginUrl(e){let n=this.getSettings(),i=new URLSearchParams({client:this.CLIENT_NAME,port:String(e.port),localState:e.localState});return e.clientId&&i.set("clientId",e.clientId),`${n[t.BASE_URL]}${this.LOGIN_PATH}?${i.toString()}`}static getExchangeUrl(){return`${this.getSettings()[t.BASE_URL]}${this.EXCHANGE_PATH}`}static getRefreshUrl(){let e=this.getSettings(),n=new URLSearchParams({client:this.REFRESH_CLIENT_NAME});return`${e[t.BASE_URL]}${this.REFRESH_PATH}?${n.toString()}`}static getApiBaseUrl(){return`${this.getSettings()[t.BASE_URL]}${this.API_BASE_PATH}`}static resolvePlatformDomain(){return this.deriveAnalyticsDomain(String(this.getSettings()[t.BASE_URL]||""))}static getAppTokenDomain(){let e=this.getSettings();return String(e[t.ANALYTICS_DOMAIN]||"").trim()||String(e[t.BASE_URL]||"").trim()}static getLegacyPlatformDomain(){return this.resolvePlatformDomain()}static getSageEventsUrl(){return`${this.getLegacyPlatformDomain()}${this.SAGE_EVENTS_PATH}`}static getSlingshotRAGMCPUrl(){return`${this.getLegacyPlatformDomain()}${this.SLINGSHOT_RAG_MCP}`}static getTokenExpiryBuffer(){return this.TOKEN_EXPIRY_BUFFER_MS}static getCacheControlForClaude(){let n=this.getSettings()[t.CACHE_CONTROL]||"5m";return!n||typeof n!="string"||!/^(5m|1h)$/.test(n)?(Ge("Invalid cache control value in sling.settings.json, falling back to default: ",n),"5m"):n}static getDefaultProjectId(){let e=this.getSettings();return process.env.SLINGSHOT_PROJECT_ID||e[t.PROJECT_ID]||""}static getDefaultWorkspaceId(){let e=this.getSettings();return process.env.SLINGSHOT_WORKSPACE_ID||e[t.WORKSPACE_ID]||""}static getDefaultClientId(){let e=this.getSettings();return process.env.CLIENT_ID||e[t.CLIENT_ID]||""}static getClientName(){return String(this.getSettings()[t.CLIENT_DISPLAY_NAME]||"").trim()}static recordClientName(e){let n=(e||"").trim();if(!n)return;let{activeKey:i,clients:r}=this.getClientRegistry(),o=i?r[i]:void 0;this.getClientName()===n&&o?.client_name===n||(this.updateSettings({[t.CLIENT_DISPLAY_NAME]:n}),this.patchActiveClient({client_name:n}))}static getEcgResourceKey(){let e=this.getDefaultClientId().trim(),n=this.getDefaultProjectId().trim();return e&&n?`${e}:${n}`:""}static isEcgEnabled(){return this.getSettings()[t.ECG_ENABLED]===!0}static setEcgEnabled(e){this.updateSettings({[t.ECG_ENABLED]:e})}static getEcgSelection(){let e=this.getEcgResourceKey();if(!e)return null;let i=this.getSettings()[t.ECG_RESOURCES]?.[e];return!i||!Array.isArray(i.resources)||i.resources.length===0?null:i}static setEcgSelection(e){let n=this.getEcgResourceKey();if(!n)return;let i={...this.getSettings()[t.ECG_RESOURCES]||{}};!e||e.resources.length===0?delete i[n]:i[n]=e,this.updateSettings({[t.ECG_RESOURCES]:i})}static getQueryClientsUrl(){return`${this.getSettings()[t.BASE_URL]}${this.QUERY_CLIENTS_PATH}`}static getUserActivityUrl(){return`${this.getSettings()[t.BASE_URL]}${this.SAPI}/users/activity`}static getUserUrl(){return`${this.getSettings()[t.BASE_URL]}${this.SAPI}/users`}static getModelsUrl(){return`${this.getSettings()[t.BASE_URL]}${this.SAPI}/ai/models`}static getPrimaryAppTokenUrl(){return`${this.getSettings()[t.BASE_URL]||""}${this.APP_TOKEN_PATH}`}static getAppTokenUrl(){return`${this.getAppTokenDomain()}${this.APP_TOKEN_PATH}`}static getAppTokenRefreshBuffer(){return this.APP_TOKEN_REFRESH_BUFFER_MS}static getEcgDomain(){return String(this.getSettings()[t.ECG_DOMAIN]||"").trim().replace(/\/+$/,"")||this.getAppTokenDomain()}static getEcgMcpUrl(){return`${this.getEcgDomain()}${this.ECG_MCP_PATH}`}static getUserResourcesUrl(){return`${this.getEcgDomain()}${this.USER_RESOURCES_PATH}`}};function $w(t,e=!1){let n=t.split(".");if(!(n.length<2||!n[1])&&!(e&&n.length!==3))try{let i=n[1].replace(/-/g,"+").replace(/_/g,"/"),r=(4-(i.length%4||4))%4,o=`${i}${"=".repeat(r)}`,s=JSON.parse(Buffer.from(o,"base64").toString("utf8"));return s&&typeof s=="object"?s:void 0}catch{return}}function ca(t){let e=$w(t,!0)?.exp;return typeof e=="number"?e*1e3:0}function u2(t){let e=$w(t,!0)?.iss;return typeof e=="string"?e:""}function p2(t){let e=$w(t);if(!e)return;let n=e.UserInfo&&typeof e.UserInfo=="object"?e.UserInfo:void 0;return{sub:typeof e.sub=="string"?e.sub:void 0,user_id:typeof e.user_id=="string"?e.user_id:typeof n?.id=="string"?n.id:void 0,email:typeof e.email=="string"?e.email:typeof n?.email=="string"?n.email:void 0}}function Nw(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}import{randomUUID as KZ}from"node:crypto";import d2 from"node:fs";import HZ from"node:path";var zZ="slingcli",VZ=1e4,JZ=2e3,QZ=1e3,YZ=5e3,XZ="sling.app-creds.json",ua=null,bd=null,Vr=null,Bw=0;function g2(){let t=HZ.resolve(Ee(),XZ);try{d2.existsSync(t)&&(d2.unlinkSync(t),fe(`app-token: removed legacy app credentials at ${t}`))}catch(e){Ge("app-token: failed to remove legacy app credentials",e)}}function ZZ(){let t=Uy("slingshot");return t?.type==="oauth"&&typeof t.access=="string"?t.access:void 0}function eee(t){Vr&&(clearTimeout(Vr),Vr=null);let e=$.getAppTokenRefreshBuffer(),i=t.realExpiry-Date.now()>e?t.realExpiry-e:t.realExpiry+JZ;Vr=setTimeout(()=>{Vr=null,Gt().catch(r=>{Ge("app-token: scheduled refresh failed",r)})},Math.max(i-Date.now(),QZ)),Vr.unref?.()}async function tee(t,e){let n={accept:"application/json","x-app-name":zZ,"trace-id":KZ()};e&&(n.authorization=`Bearer ${e}`);try{return await fetch(t,{method:"GET",headers:n})}catch(i){let r=i instanceof Error?i.message:String(i);throw new Error(`Cannot reach app-token service: ${r}`)}}async function m2(t){let e=`${t.status} ${t.statusText}`;try{let n=await t.text()||"";n&&(e=n)}catch{}return e}function nee(t){if(!t.app_token)throw new Error("App token response missing app_token");let e=typeof t.expires_in=="number"?Date.now()+t.expires_in*1e3:ca(t.app_token);if(!e)throw new Error("App token response missing expires_in and its JWT has no decodable exp claim");return fe(`app-token: minted, expires ${new Date(e).toISOString()}`),{token:t.app_token,usableUntil:e-VZ,realExpiry:e}}async function h2(t,e){let n=await tee(t,e);if(n.ok)return nee(await n.json());if(n.status===404)return{notFound:await m2(n)};throw new Error(`App token request failed: ${await m2(n)}`)}async function iee(t){let e=$.getPrimaryAppTokenUrl(),n=t??ZZ();fe(`app-token: minting from ${e}`);let i=await h2(e,n);if(!("notFound"in i))return i;let r=$.getAppTokenUrl();fe(`app-token: primary 404, falling back to ${r}`);let o=await h2(r);if("notFound"in o)throw new Error(`App token request failed: ${o.notFound}`);return o}async function Gt(t){let e=Date.now();if(ua&&(ua.usableUntil>e||ua.realExpiry>e&&e-Bw<YZ))return ua.token;if(bd)return(await bd).token;let n=iee(t).then(r=>(ua=r,Bw=Date.now(),eee(r),r)).finally(()=>{bd=null});return bd=n,(await n).token}function f2(){ua=null,bd=null,Bw=0,Vr&&(clearTimeout(Vr),Vr=null)}var vd=null,jw=null;typeof process<"u"&&process.versions?.node&&(jw=import("node:http").then(t=>{vd=t.createServer}));async function ree(){if(vd||(jw&&await jw,vd))return vd;throw new Error("Slingshot OAuth requires Node.js")}async function qw(t){let e=await ree(),n,i,r,o=!1,s=new Promise((u,p)=>{i=u,r=p}),a=u=>{if(!o){o=!0;try{n.close()}catch{}u()}};n=e((u,p)=>{let d=new URL(u.url||"","http://127.0.0.1"),m=d.searchParams.get("code"),g=d.searchParams.get("state"),h=d.searchParams.get("clientId"),f=d.searchParams.get("error"),x=d.searchParams.get("error_description");if(f){p.writeHead(400,{"Content-Type":"text/html"}),p.end(`<html><body><h1>Login Failed</h1><p>${x||f}</p><p>You can close this window.</p></body></html>`),a(()=>r(new Error(`Login failed: ${x||f}`)));return}if(!m||!g){p.writeHead(400,{"Content-Type":"text/html"}),p.end("<html><body><h1>Login Failed</h1><p>Missing code or state in callback.</p><p>You can close this window.</p></body></html>"),a(()=>r(new Error("Missing code or state in callback")));return}p.writeHead(200,{"Content-Type":"text/html"}),p.end("<html><body><h1>Login Successful</h1><p>You can close this window and return to your terminal.</p><script>setTimeout(()=>window.close(),3000)</script></body></html>"),a(()=>i({code:m,state:g,clientId:h||""}))}),n.on("error",u=>{a(()=>r(u))});let l=setTimeout(()=>{a(()=>r(new Error("Login timeout - no callback received within 5 minutes")))},300*1e3);return n.on("close",()=>clearTimeout(l)),t&&t.addEventListener("abort",()=>{a(()=>r(new Error("Login cancelled")))}),{port:await new Promise((u,p)=>{n.once("error",p),n.listen(0,"127.0.0.1",()=>{let d=n.address();d&&typeof d=="object"?u(d.port):p(new Error("Failed to obtain loopback server port"))})}),result:s}}async function Gw(t,e){if(!t)throw new Error("Missing exchange code");if(!e)throw new Error("Missing clientId for exchange");let n=$.getExchangeUrl(),i;try{i=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json"},body:JSON.stringify({code:t,clientId:e})})}catch(o){let s=o instanceof Error?o.message:String(o);throw new Error(`Cannot reach Studio Auth: ${s}`)}if(!i.ok){let o,s=`${i.status} ${i.statusText}`;try{let a=await i.json();o=a.error?.code,a.error?.message?s=a.error.message:a.message?s=a.message:o&&(s=o)}catch{}throw o==="INVALID_CALLBACK"?new Error("Login failed: exchange code is expired, already used, or bound to a different tenant. Please log in again."):new Error(`Code exchange failed: ${s}`)}let r=await i.json();if(!r.accessToken||!r.refreshToken)throw new Error("Exchange response missing accessToken or refreshToken");return r}function see(){return oee(16).toString("hex")}function aee(t){let e=new URL(t),n=e.searchParams.get("code"),i=e.searchParams.get("state"),r=e.searchParams.get("clientId");if(!n||!i)throw new Error("Pasted URL is missing code or state");return{code:n,state:i,clientId:r||""}}async function Kw(t){let e=process.env.SLINGSHOT_TOKEN;if(e){let u=ca(e);return fe("Using Slingshot token from SLINGSHOT_TOKEN environment variable"),await Gt(e),{refresh:"",access:e,expires:u>0?u-$.getTokenExpiryBuffer():Date.now()+10800*1e3,projectId:$.getDefaultProjectId(),workspaceId:$.getDefaultWorkspaceId()}}let{port:n,result:i}=await qw(t.signal),r=see(),o=$.getDefaultClientId(),s=$.getLoginUrl({port:n,localState:r,clientId:o||void 0});t.onAuth({url:s});let a;if(t.onManualCodeInput){let u=t.onManualCodeInput().then(aee);a=await Promise.race([i,u])}else a=await i;if(a.state!==r)throw new Error("CSRF check failed - state does not match localState");if(!a.clientId)throw new Error("Login callback did not include clientId");let l=await Gw(a.code,a.clientId);$.recordActiveClientId(a.clientId);let c=ca(l.accessToken);return await Gt(l.accessToken),{refresh:l.refreshToken,access:l.accessToken,expires:c>0?c-$.getTokenExpiryBuffer():Date.now()+10800*1e3,projectId:$.getDefaultProjectId(),workspaceId:$.getDefaultWorkspaceId()}}import{randomUUID as lee}from"node:crypto";async function Hw(t){if(!t.refresh)throw new Error("No refresh token available. Please login again.");let e;try{e=await Gt(t.access)}catch(a){throw Ge("auth/refresh: app token unavailable for refresh call",a),new Error(`Cannot refresh Slingshot token: app token unavailable (${a instanceof Error?a.message:String(a)}). Please /login slingshot.`)}let n=lee(),i={accept:"application/json",rt:t.refresh,"trace-id":n,Authorization:`Bearer ${e}`},r;try{let a=$.getRefreshUrl();r=await fetch(a,{headers:i})}catch(a){let l=a instanceof Error?a.message:String(a);throw new Error(`Cannot reach Slingshot server: ${l}`)}if(!r.ok){let a=`${r.status} ${r.statusText}`;try{let l=await r.json();l.message?a=String(l.message):l.error&&(a=String(l.error))}catch{}throw new Error(`Token refresh failed: ${a}`)}let o=await r.json();if(!o.accessToken)throw new Error("No access token in refresh response");let s=ca(o.accessToken);try{await Gt(o.accessToken)}catch(a){throw Ge("auth/refresh: app token refresh failed",a),a}return{refresh:o.refreshToken||t.refresh,access:o.accessToken,expires:s>0?s-$.getTokenExpiryBuffer():Date.now()+10800*1e3,projectId:t.projectId,workspaceId:t.workspaceId}}var yd=[{id:"gpt-5.4-nano",name:"GPT-5.4 nano",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:.2,output:1.25,cacheRead:.02,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,api:"openai-responses",provider:"slingshot"},{id:"gpt-4.1",name:"GPT-4.1",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:1047576,maxTokens:32768,provider:"slingshot",api:"openai-completions"},{id:"gpt-5",name:"GPT-5",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5-mini",name:"GPT-5 Mini",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5-nano",name:"GPT-5 Nano",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.05,output:.4,cacheRead:.005,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5.1",name:"GPT-5.1",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.13,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5.2",name:"GPT-5.2",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5.4-mini",name:"GPT-5.4 mini",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:.75,output:4.5,cacheRead:.075,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,api:"openai-responses",provider:"slingshot"},{id:"gpt-5.4",name:"GPT-5.4",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},contextWindow:272e3,maxTokens:128e3,api:"openai-responses",provider:"slingshot"},{id:"gpt-5.5",name:"GPT-5.5",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:0},contextWindow:272e3,maxTokens:128e3,api:"openai-responses",provider:"slingshot"},{id:"gpt-5.6-luna",name:"GPT-5.6 Luna",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:.96,output:5.76,cacheRead:.096,cacheWrite:0},contextWindow:105e4,maxTokens:5e5,api:"openai-responses",provider:"slingshot"},{id:"gpt-5.6-terra",name:"GPT-5.6 Terra",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:2.4,output:14.4,cacheRead:.24,cacheWrite:0},contextWindow:105e4,maxTokens:5e5,api:"openai-responses",provider:"slingshot"},{id:"gpt-5.6-sol",name:"GPT-5.6 Sol",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:4.8,output:28.8,cacheRead:.48,cacheWrite:0},contextWindow:105e4,maxTokens:5e5,api:"openai-responses",provider:"slingshot"},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"claude-opus-4@20250514",name:"Claude Opus 4",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3,provider:"slingshot",api:"openai-completions"},{id:"claude-sonnet-4@20250514",name:"Claude Sonnet 4",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3,provider:"slingshot",api:"openai-completions"},{id:"claude-sonnet-4-5@20250929",name:"Claude Sonnet 4.5",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3,provider:"slingshot",api:"openai-completions"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3,provider:"slingshot",api:"openai-completions"},{id:"claude-opus-4-6",name:"Claude Opus 4.6",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,provider:"slingshot",api:"openai-completions"},{id:"claude-sonnet-5",name:"Claude Sonnet 5",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e5,maxTokens:64e3,provider:"slingshot",api:"openai-completions"},{id:"Qwen/Qwen3.6-27B-FP8",name:"Qwen 3.6 27B FP8",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.2,output:3.6,cacheRead:.3,cacheWrite:3.75},contextWindow:64e3,maxTokens:56e3,provider:"slingshot",api:"openai-completions"},{id:"o3",name:"O3",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,provider:"slingshot",api:"openai-completions"},{id:"o3-mini",name:"o3-mini",baseUrl:"",reasoning:!0,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,provider:"slingshot",api:"openai-completions"},{id:"o4-mini",name:"o4-mini",baseUrl:"",reasoning:!0,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.28,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,provider:"slingshot",api:"openai-completions"},{id:"gemini-3.1-flash-lite",name:"Gemini 3.1 Flash Lite",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.44,output:1.32,cacheRead:.075,cacheWrite:0},contextWindow:1e6,maxTokens:65535,provider:"slingshot",api:"openai-completions"},{id:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.76,output:10.56,cacheRead:.075,cacheWrite:0},contextWindow:1e6,maxTokens:65535,provider:"slingshot",api:"openai-completions"}];var Sf=t=>Math.round((t??0)*1e3*1e6)/1e6,cee=32768,uee=16384,pee=new Map(yd.map(t=>[t.id,t.maxTokens]));async function x2(t,e){let n=await fetch(t,{headers:{Authorization:`Bearer ${e}`,Accept:"application/json"}});if(!n.ok)throw new Error(`Slingshot models fetch failed: ${n.status}`);let i=await n.json();return dee(Array.isArray(i)?i:i?.data??[])}function dee(t){return t.filter(e=>e.model_type==="chat").map(e=>{let n=e.metadata??{},i=typeof n.family=="string"?n.family.trim():"",r=i==="smart",o=n.context_length??0,s=(n.supported_modalities??["text"]).filter(a=>a==="text"||a==="image");return{id:e.id,name:n.name||e.id,baseUrl:"",reasoning:r?!1:!!n.reasoning,input:s,cost:{input:Sf(e.inputCostPer1KTokens),output:Sf(e.outputCostPer1KTokens),cacheRead:Sf(e.cacheCostPer1KTokens?.read),cacheWrite:Sf(e.cacheCostPer1KTokens?.write)},contextWindow:o,maxTokens:Math.min(o,r?uee:pee.get(e.id)??cee),provider:"slingshot",api:r?"openai-completions":e.supported_apis?.includes("responses")?"openai-responses":"openai-completions",...i===""?{}:{family:i}}}).sort((e,n)=>e.id.localeCompare(n.id))}import b2 from"node:fs";function v2(t,e,n){try{b2.writeFileSync(t,JSON.stringify({baseUrl:e,fetchedAt:new Date().toISOString(),models:n}))}catch{}}function zw(t,e){try{let n=JSON.parse(b2.readFileSync(t,"utf-8"));return n?.baseUrl!==e||!Array.isArray(n.models)||n.models.length===0?null:n.models}catch{return null}}import Tf from"node:fs";import y2 from"node:path";import mee from"proper-lockfile";var hee=250;function gee(){return y2.resolve(Ee(),"settings.json")}function fee(t){if(!Tf.existsSync(t))return{};try{let e=JSON.parse(Tf.readFileSync(t,"utf-8"));return e===null||typeof e!="object"||Array.isArray(e)?(fe(`default-model: refusing to write to non-object settings at ${t}`),null):e}catch(e){return fe(`default-model: could not parse ${t}, leaving it alone: ${Vw(e)}`),null}}async function xee(t,e,n){let i;try{Tf.mkdirSync(y2.dirname(t),{recursive:!0}),i=await mee.lock(t,{realpath:!1,retries:{retries:10,minTimeout:20,maxTimeout:200},onCompromised:o=>fe(`default-model: settings lock compromised: ${Vw(o)}`)});let r=fee(t);return r===null?!1:(r.defaultProvider===e&&r.defaultModel===n||(r.defaultProvider=e,r.defaultModel=n,Tf.writeFileSync(t,`${JSON.stringify(r,null,2)}
450
+ `;Yo.appendFileSync(zr,i)}catch{}}var fr=null,c2=!1;function GZ(t){if(!t)return;let e=t.trim();if(e)return e.replace(/\/+$/,"")}var $=class t{static{this.BASE_URL="base_url"}static{this.ANALYTICS_DOMAIN="analytics_domain"}static{this.CLIENT_ID="client_id"}static{this.PROJECT_ID="project_id"}static{this.WORKSPACE_ID="workspace_id"}static{this.PROJECT_NAME="project_name"}static{this.WORKSPACE_NAME="workspace_name"}static{this.CLIENT_DISPLAY_NAME="client_name"}static{this.SCHEMA_VERSION="schema_version"}static{this.ACTIVE_CLIENT="active_client"}static{this.KNOWN_CLIENTS="known_clients"}static{this.ECG_ENABLED="ecg_enabled"}static{this.ECG_RESOURCES="ecg_resources"}static{this.ECG_DOMAIN="ecg_domain"}static{this.CURRENT_SCHEMA_VERSION=2}static{this.ANALYTICS_HOST_PREFIX="slingshot"}static{this.CACHE_CONTROL="cache_control"}static{this.APP_TOKEN_HOST_EXCEPTIONS={"sapientaiproducts.com":"https://slingshot.sapientaiproducts.com","uat.sapientaiproducts.com":"https://uat-slingshot.sapientaiproducts.com","dev.sapientaiproducts.com":"https://dev-slingshot.sapientaiproducts.com"}}static{this.defaultValues={[t.BASE_URL]:"https://sapientaiproducts.com",[t.ANALYTICS_DOMAIN]:"https://slingshot.sapientaiproducts.com",[t.CLIENT_ID]:"b97fbef7-cad9-4e56-9850-39e86c8fdf61",[t.PROJECT_ID]:"fa8121c4-e2fc-48f1-9478-8949c04e13cc",[t.WORKSPACE_ID]:"6e5756eb-d7e2-4d80-ad07-9d7a51600d85",[t.CACHE_CONTROL]:"5m"}}static defaultsFor(e){let n=String(e[this.BASE_URL]||this.defaultValues[this.BASE_URL]||"");if(this.makeClientKey(n)===this.getDefaultClientKey())return this.defaultValues;let i={...this.defaultValues};for(let r of[this.ANALYTICS_DOMAIN,this.CLIENT_ID,this.PROJECT_ID,this.WORKSPACE_ID])delete i[r];return i}static{this.LOGIN_PATH="/web/v1/studio-auth/login"}static{this.EXCHANGE_PATH="/api/v1/studio-auth/auth/desktop/exchange"}static{this.REFRESH_PATH="/api/v3/auth/refreshtoken"}static{this.QUERY_CLIENTS_PATH="/api/v2/projects/clients/queryClients"}static{this.API_BASE_PATH="/api/v1/llm"}static{this.SAGE_EVENTS_PATH="/api/v1/ai-portal/sage_events"}static{this.APP_TOKEN_PATH="/api/v1/ai-auth/token/app"}static{this.ECG_MCP_PATH="/api/v1/ecg/mcp"}static{this.USER_RESOURCES_PATH="/api/v1/ai-auth/auth/user"}static{this.SLINGSHOT_RAG_MCP="/api/v1/ai-prompt-lib/mcp/"}static{this.SAPI="/save/api/v1"}static{this.REFRESH_CLIENT_NAME="machine"}static{this.APP_TOKEN_REFRESH_BUFFER_MS=60*1e3}static{this.TOKEN_EXPIRY_BUFFER_MS=300*1e3}static{this.CLIENT_NAME="desktop"}static defaults(e){return this.defaultValues[e]}static deriveAnalyticsDomain(e){let n=(e||"").trim().replace(/\/+$/,"");if(!n)return"";let i;try{i=new URL(n)}catch{return""}return i.hostname?(i.hostname.startsWith(`${this.ANALYTICS_HOST_PREFIX}.`)||(i.hostname=`${this.ANALYTICS_HOST_PREFIX}.${i.hostname}`),`${i.protocol}//${i.host}`):""}static resolveAppTokenDomainForSave(e){let n=(e||"").trim().replace(/\/+$/,"");if(!n)return"";let i;try{i=new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(n)?n:`https://${n}`)}catch{return n}if(!i.hostname)return n;let r=`${i.protocol}//${i.host}`;return this.APP_TOKEN_HOST_EXCEPTIONS[i.host.toLowerCase()]||r}static makeClientKey(e){try{return new URL((e||"").trim()).host}catch{return""}}static makeClientLabel(e){return this.makeClientKey(e)||e}static toKnownClient(e){let n=String(e[this.BASE_URL]||"");if(!this.makeClientKey(n))return null;let i=s=>String(e[s]||""),r=i(this.ANALYTICS_DOMAIN),o=i(this.CLIENT_DISPLAY_NAME);return{label:this.makeClientLabel(n),domain:n,client_id:i(this.CLIENT_ID),project_id:i(this.PROJECT_ID),project_name:i(this.PROJECT_NAME),workspace_id:i(this.WORKSPACE_ID),workspace_name:i(this.WORKSPACE_NAME),...r?{analytics_domain:r}:{},...o?{client_name:o}:{}}}static persist(e,n){let i=xd.dirname(e);Zt.existsSync(i)||Zt.mkdirSync(i,{recursive:!0}),Zt.writeFileSync(e,JSON.stringify(n,null,2),"utf-8")}static migrate(e,n,i){if(e[this.SCHEMA_VERSION]===this.CURRENT_SCHEMA_VERSION)return e;let r=String(e[this.BASE_URL]||""),o=this.makeClientKey(r),s={...e[this.KNOWN_CLIENTS]||{}};if(o&&!s[o]){let l=this.toKnownClient(e);l&&(s[o]=l)}let a={[this.SCHEMA_VERSION]:this.CURRENT_SCHEMA_VERSION,[this.ACTIVE_CLIENT]:e[this.ACTIVE_CLIENT]||o,[this.KNOWN_CLIENTS]:s};if(n===this.getGlobalSettingsPath())try{this.persist(n,{...i,...a})}catch(l){Ge("Error persisting sling.settings.json migration: ",l)}return{...e,...a}}static readGlobalSettings(){let e=this.getGlobalSettingsPath();try{let n=Zt.existsSync(e)?Zt.readFileSync(e,"utf-8"):"",i=n?JSON.parse(n)||{}:{};return this.migrate({...this.defaultsFor(i),...i},e,i)}catch(n){return Ge("Error reading global sling.settings.json: ",n),{...this.defaultValues}}}static getClientRegistry(){let e=this.readGlobalSettings()[this.KNOWN_CLIENTS];return{activeKey:String(this.getSettings()[this.ACTIVE_CLIENT]||""),clients:e&&typeof e=="object"?e:{}}}static getKnownClients(){return this.getClientRegistry().clients}static getGlobalActiveClientKey(){return String(this.readGlobalSettings()[this.ACTIVE_CLIENT]||"")}static writeRegistry(e){this.updateSettings({[this.KNOWN_CLIENTS]:e},{scope:"global"})}static patchActiveClient(e){let{activeKey:n,clients:i}=this.getClientRegistry(),r=n?i[n]:void 0;r&&this.writeRegistry({...i,[n]:{...r,...e}})}static applyClient(e,n){let i=this.makeClientKey(e.domain),r=n?.scope??this.resolveWriteScope(),o=this.resolveAppTokenDomainForSave(e.domain),s={...this.getKnownClients()};s[i]={...e,analytics_domain:o,last_used:new Date().toISOString()},this.updateSettings({[this.BASE_URL]:e.domain,[this.ANALYTICS_DOMAIN]:o,[this.CLIENT_ID]:e.client_id||"",[this.PROJECT_ID]:e.project_id||"",[this.WORKSPACE_ID]:e.workspace_id||"",[this.PROJECT_NAME]:e.project_name||"",[this.WORKSPACE_NAME]:e.workspace_name||"",[this.CLIENT_DISPLAY_NAME]:e.client_name||"",[this.ACTIVE_CLIENT]:i,[this.SCHEMA_VERSION]:this.CURRENT_SCHEMA_VERSION},{scope:r}),this.writeRegistry(s)}static recordActiveClientId(e){let n=(e||"").trim();if(!n)return;let{activeKey:i,clients:r}=this.getClientRegistry();(i?r[i]:void 0)?.client_id===n&&this.getDefaultClientId()===n||(this.updateSettings({[this.CLIENT_ID]:n}),this.patchActiveClient({client_id:n}))}static recordActiveAppTokenOverride(e){let n=(e||"").trim();this.patchActiveClient({analytics_domain:n||void 0})}static recordActiveProjectSelection(e){this.patchActiveClient(e)}static hasProjectSelection(){return!!(this.getDefaultProjectId()&&this.getDefaultWorkspaceId())}static getDefaultClientKey(){return this.makeClientKey(String(this.defaultValues[this.BASE_URL]||""))}static removeKnownClient(e){if(!e||e===this.getDefaultClientKey())return!1;let{activeKey:n,clients:i}=this.getClientRegistry();if(e===n||e===this.getGlobalActiveClientKey()||!i[e])return!1;let r={...i};return delete r[e],this.writeRegistry(r),!0}static getLocalSettingsPath(){return xd.resolve(process.cwd(),".sling","sling.settings.json")}static getGlobalSettingsPath(){return xd.resolve(Ee(),"sling.settings.json")}static getSettingsPath(e){return e==="local"?this.getLocalSettingsPath():e==="global"?this.getGlobalSettingsPath():this.getActivePinPath()??this.getGlobalSettingsPath()}static getActivePinPath(){if(c2)return null;let e=this.getLocalSettingsPath();return Zt.existsSync(e)?e:null}static disableLocalSettingsForSession(){c2=!0,fr=null}static getUntrustedPinDomain(){if(!this.getActivePinPath())return null;let e=String(this.getSettings()[this.BASE_URL]||""),n=this.makeClientKey(e);return n?this.getClientRegistry().clients[n]?null:e:null}static trustActivePin(){let e=this.toKnownClient(this.getSettings());if(!e)return!1;let n=this.makeClientKey(e.domain),{clients:i}=this.getClientRegistry();return i[n]||this.writeRegistry({...i,[n]:{...e,last_used:new Date().toISOString()}}),!0}static resolveWriteScope(){return this.getActivePinPath()?"local":"global"}static clearLocalSettings(){let e=this.getLocalSettingsPath();try{return Zt.existsSync(e)?(Zt.unlinkSync(e),fr=null,!0):!1}catch(n){return Ge("Error removing local sling.settings.json: ",n),!1}}static loadSettingsFile(e){if(Zt.existsSync(e)){let i=Zt.readFileSync(e,"utf-8"),r=JSON.parse(i)||{};return this.migrate({...this.defaultsFor(r),...r},e,r)}let n=xd.dirname(e);return Zt.existsSync(n)||Zt.mkdirSync(n,{recursive:!0}),this.migrate({...this.defaultValues},e,{...this.defaultValues})}static getSettings(){if(!fr)try{fr=this.loadSettingsFile(this.getSettingsPath())}catch(n){Ge("Error reading/writing sling.settings.json: ",n);let i=this.getActivePinPath();if(i){Ge("Ignoring unreadable local pin for this session: ",i),this.disableLocalSettingsForSession();try{fr=this.loadSettingsFile(this.getSettingsPath())}catch(r){Ge("Error reading global sling.settings.json: ",r)}}fr||(fr={...this.defaultValues})}let e=GZ(process.env.SLINGSHOT_API_DOMAIN);return{...fr,[t.BASE_URL]:e||fr[t.BASE_URL]}}static updateSettings(e,n){let i=n?.scope??this.resolveWriteScope();if(i==="local"&&this.KNOWN_CLIENTS in e){let{[this.KNOWN_CLIENTS]:r,...o}=e;this.writeToScope({[this.KNOWN_CLIENTS]:r},"global"),Object.keys(o).length>0&&this.writeToScope(o,"local");return}this.writeToScope(e,i)}static writeToScope(e,n){let i=this.getSettingsPath(n);try{let r={};if(Zt.existsSync(i)){let l=Zt.readFileSync(i,"utf-8");r=JSON.parse(l)||{}}let o={...r,...e},s={...this.defaultsFor(o),...o},a=xd.dirname(i);Zt.existsSync(a)||Zt.mkdirSync(a,{recursive:!0}),Zt.writeFileSync(i,JSON.stringify(s,null,2),"utf-8"),fr=null}catch(r){Ge("Error updating sling.settings.json: ",r)}}static getLoginUrl(e){let n=this.getSettings(),i=new URLSearchParams({client:this.CLIENT_NAME,port:String(e.port),localState:e.localState});return e.clientId&&i.set("clientId",e.clientId),`${n[t.BASE_URL]}${this.LOGIN_PATH}?${i.toString()}`}static getExchangeUrl(){return`${this.getSettings()[t.BASE_URL]}${this.EXCHANGE_PATH}`}static getRefreshUrl(){let e=this.getSettings(),n=new URLSearchParams({client:this.REFRESH_CLIENT_NAME});return`${e[t.BASE_URL]}${this.REFRESH_PATH}?${n.toString()}`}static getApiBaseUrl(){return`${this.getSettings()[t.BASE_URL]}${this.API_BASE_PATH}`}static resolvePlatformDomain(){return this.deriveAnalyticsDomain(String(this.getSettings()[t.BASE_URL]||""))}static getAppTokenDomain(){let e=this.getSettings();return String(e[t.ANALYTICS_DOMAIN]||"").trim()||String(e[t.BASE_URL]||"").trim()}static getLegacyPlatformDomain(){return this.resolvePlatformDomain()}static getSageEventsUrl(){return`${this.getLegacyPlatformDomain()}${this.SAGE_EVENTS_PATH}`}static getSlingshotRAGMCPUrl(){return`${this.getLegacyPlatformDomain()}${this.SLINGSHOT_RAG_MCP}`}static getTokenExpiryBuffer(){return this.TOKEN_EXPIRY_BUFFER_MS}static getCacheControlForClaude(){let n=this.getSettings()[t.CACHE_CONTROL]||"5m";return!n||typeof n!="string"||!/^(5m|1h)$/.test(n)?(Ge("Invalid cache control value in sling.settings.json, falling back to default: ",n),"5m"):n}static getDefaultProjectId(){let e=this.getSettings();return process.env.SLINGSHOT_PROJECT_ID||e[t.PROJECT_ID]||""}static getDefaultWorkspaceId(){let e=this.getSettings();return process.env.SLINGSHOT_WORKSPACE_ID||e[t.WORKSPACE_ID]||""}static getDefaultClientId(){let e=this.getSettings();return process.env.CLIENT_ID||e[t.CLIENT_ID]||""}static getClientName(){return String(this.getSettings()[t.CLIENT_DISPLAY_NAME]||"").trim()}static recordClientName(e){let n=(e||"").trim();if(!n)return;let{activeKey:i,clients:r}=this.getClientRegistry(),o=i?r[i]:void 0;this.getClientName()===n&&o?.client_name===n||(this.updateSettings({[t.CLIENT_DISPLAY_NAME]:n}),this.patchActiveClient({client_name:n}))}static getEcgResourceKey(){let e=this.getDefaultClientId().trim(),n=this.getDefaultProjectId().trim();return e&&n?`${e}:${n}`:""}static isEcgEnabled(){return this.getSettings()[t.ECG_ENABLED]===!0}static setEcgEnabled(e){this.updateSettings({[t.ECG_ENABLED]:e})}static getEcgSelection(){let e=this.getEcgResourceKey();if(!e)return null;let i=this.getSettings()[t.ECG_RESOURCES]?.[e];return!i||!Array.isArray(i.resources)||i.resources.length===0?null:i}static setEcgSelection(e){let n=this.getEcgResourceKey();if(!n)return;let i={...this.getSettings()[t.ECG_RESOURCES]||{}};!e||e.resources.length===0?delete i[n]:i[n]=e,this.updateSettings({[t.ECG_RESOURCES]:i})}static getQueryClientsUrl(){return`${this.getSettings()[t.BASE_URL]}${this.QUERY_CLIENTS_PATH}`}static getUserActivityUrl(){return`${this.getSettings()[t.BASE_URL]}${this.SAPI}/users/activity`}static getUserUrl(){return`${this.getSettings()[t.BASE_URL]}${this.SAPI}/users`}static getModelsUrl(){return`${this.getSettings()[t.BASE_URL]}${this.SAPI}/ai/models`}static getPrimaryAppTokenUrl(){return`${this.getSettings()[t.BASE_URL]||""}${this.SAPI}/ai-auth/token/app`}static getAppTokenUrl(){return`${this.getAppTokenDomain()}${this.APP_TOKEN_PATH}`}static getAppTokenRefreshBuffer(){return this.APP_TOKEN_REFRESH_BUFFER_MS}static getEcgDomain(){return String(this.getSettings()[t.ECG_DOMAIN]||"").trim().replace(/\/+$/,"")||this.getAppTokenDomain()}static getEcgMcpUrl(){return`${this.getEcgDomain()}${this.ECG_MCP_PATH}`}static getUserResourcesUrl(){return`${this.getEcgDomain()}${this.USER_RESOURCES_PATH}`}};function $w(t,e=!1){let n=t.split(".");if(!(n.length<2||!n[1])&&!(e&&n.length!==3))try{let i=n[1].replace(/-/g,"+").replace(/_/g,"/"),r=(4-(i.length%4||4))%4,o=`${i}${"=".repeat(r)}`,s=JSON.parse(Buffer.from(o,"base64").toString("utf8"));return s&&typeof s=="object"?s:void 0}catch{return}}function ca(t){let e=$w(t,!0)?.exp;return typeof e=="number"?e*1e3:0}function u2(t){let e=$w(t,!0)?.iss;return typeof e=="string"?e:""}function p2(t){let e=$w(t);if(!e)return;let n=e.UserInfo&&typeof e.UserInfo=="object"?e.UserInfo:void 0;return{sub:typeof e.sub=="string"?e.sub:void 0,user_id:typeof e.user_id=="string"?e.user_id:typeof n?.id=="string"?n.id:void 0,email:typeof e.email=="string"?e.email:typeof n?.email=="string"?n.email:void 0}}function Nw(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}import{randomUUID as KZ}from"node:crypto";import d2 from"node:fs";import HZ from"node:path";var zZ="slingcli",VZ=1e4,JZ=2e3,QZ=1e3,YZ=5e3,XZ="sling.app-creds.json",ua=null,bd=null,Vr=null,Bw=0;function g2(){let t=HZ.resolve(Ee(),XZ);try{d2.existsSync(t)&&(d2.unlinkSync(t),fe(`app-token: removed legacy app credentials at ${t}`))}catch(e){Ge("app-token: failed to remove legacy app credentials",e)}}function ZZ(){let t=Uy("slingshot");return t?.type==="oauth"&&typeof t.access=="string"?t.access:void 0}function eee(t){Vr&&(clearTimeout(Vr),Vr=null);let e=$.getAppTokenRefreshBuffer(),i=t.realExpiry-Date.now()>e?t.realExpiry-e:t.realExpiry+JZ;Vr=setTimeout(()=>{Vr=null,Gt().catch(r=>{Ge("app-token: scheduled refresh failed",r)})},Math.max(i-Date.now(),QZ)),Vr.unref?.()}async function tee(t,e){let n={accept:"application/json","x-app-name":zZ,"trace-id":KZ()};e&&(n.authorization=`Bearer ${e}`);try{return await fetch(t,{method:"GET",headers:n})}catch(i){let r=i instanceof Error?i.message:String(i);throw new Error(`Cannot reach app-token service: ${r}`)}}async function m2(t){let e=`${t.status} ${t.statusText}`;try{let n=await t.text()||"";n&&(e=n)}catch{}return e}function nee(t){if(!t.app_token)throw new Error("App token response missing app_token");let e=typeof t.expires_in=="number"?Date.now()+t.expires_in*1e3:ca(t.app_token);if(!e)throw new Error("App token response missing expires_in and its JWT has no decodable exp claim");return fe(`app-token: minted, expires ${new Date(e).toISOString()}`),{token:t.app_token,usableUntil:e-VZ,realExpiry:e}}async function h2(t,e){let n=await tee(t,e);if(n.ok)return nee(await n.json());if(n.status===404)return{notFound:await m2(n)};throw new Error(`App token request failed: ${await m2(n)}`)}async function iee(t){let e=$.getPrimaryAppTokenUrl(),n=t??ZZ();fe(`app-token: minting from ${e}`);let i=await h2(e,n);if(!("notFound"in i))return i;let r=$.getAppTokenUrl();fe(`app-token: primary 404, falling back to ${r}`);let o=await h2(r);if("notFound"in o)throw new Error(`App token request failed: ${o.notFound}`);return o}async function Gt(t){let e=Date.now();if(ua&&(ua.usableUntil>e||ua.realExpiry>e&&e-Bw<YZ))return ua.token;if(bd)return(await bd).token;let n=iee(t).then(r=>(ua=r,Bw=Date.now(),eee(r),r)).finally(()=>{bd=null});return bd=n,(await n).token}function f2(){ua=null,bd=null,Bw=0,Vr&&(clearTimeout(Vr),Vr=null)}var vd=null,jw=null;typeof process<"u"&&process.versions?.node&&(jw=import("node:http").then(t=>{vd=t.createServer}));async function ree(){if(vd||(jw&&await jw,vd))return vd;throw new Error("Slingshot OAuth requires Node.js")}async function qw(t){let e=await ree(),n,i,r,o=!1,s=new Promise((u,p)=>{i=u,r=p}),a=u=>{if(!o){o=!0;try{n.close()}catch{}u()}};n=e((u,p)=>{let d=new URL(u.url||"","http://127.0.0.1"),m=d.searchParams.get("code"),g=d.searchParams.get("state"),h=d.searchParams.get("clientId"),f=d.searchParams.get("error"),x=d.searchParams.get("error_description");if(f){p.writeHead(400,{"Content-Type":"text/html"}),p.end(`<html><body><h1>Login Failed</h1><p>${x||f}</p><p>You can close this window.</p></body></html>`),a(()=>r(new Error(`Login failed: ${x||f}`)));return}if(!m||!g){p.writeHead(400,{"Content-Type":"text/html"}),p.end("<html><body><h1>Login Failed</h1><p>Missing code or state in callback.</p><p>You can close this window.</p></body></html>"),a(()=>r(new Error("Missing code or state in callback")));return}p.writeHead(200,{"Content-Type":"text/html"}),p.end("<html><body><h1>Login Successful</h1><p>You can close this window and return to your terminal.</p><script>setTimeout(()=>window.close(),3000)</script></body></html>"),a(()=>i({code:m,state:g,clientId:h||""}))}),n.on("error",u=>{a(()=>r(u))});let l=setTimeout(()=>{a(()=>r(new Error("Login timeout - no callback received within 5 minutes")))},300*1e3);return n.on("close",()=>clearTimeout(l)),t&&t.addEventListener("abort",()=>{a(()=>r(new Error("Login cancelled")))}),{port:await new Promise((u,p)=>{n.once("error",p),n.listen(0,"127.0.0.1",()=>{let d=n.address();d&&typeof d=="object"?u(d.port):p(new Error("Failed to obtain loopback server port"))})}),result:s}}async function Gw(t,e){if(!t)throw new Error("Missing exchange code");if(!e)throw new Error("Missing clientId for exchange");let n=$.getExchangeUrl(),i;try{i=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json"},body:JSON.stringify({code:t,clientId:e})})}catch(o){let s=o instanceof Error?o.message:String(o);throw new Error(`Cannot reach Studio Auth: ${s}`)}if(!i.ok){let o,s=`${i.status} ${i.statusText}`;try{let a=await i.json();o=a.error?.code,a.error?.message?s=a.error.message:a.message?s=a.message:o&&(s=o)}catch{}throw o==="INVALID_CALLBACK"?new Error("Login failed: exchange code is expired, already used, or bound to a different tenant. Please log in again."):new Error(`Code exchange failed: ${s}`)}let r=await i.json();if(!r.accessToken||!r.refreshToken)throw new Error("Exchange response missing accessToken or refreshToken");return r}function see(){return oee(16).toString("hex")}function aee(t){let e=new URL(t),n=e.searchParams.get("code"),i=e.searchParams.get("state"),r=e.searchParams.get("clientId");if(!n||!i)throw new Error("Pasted URL is missing code or state");return{code:n,state:i,clientId:r||""}}async function Kw(t){let e=process.env.SLINGSHOT_TOKEN;if(e){let u=ca(e);return fe("Using Slingshot token from SLINGSHOT_TOKEN environment variable"),await Gt(e),{refresh:"",access:e,expires:u>0?u-$.getTokenExpiryBuffer():Date.now()+10800*1e3,projectId:$.getDefaultProjectId(),workspaceId:$.getDefaultWorkspaceId()}}let{port:n,result:i}=await qw(t.signal),r=see(),o=$.getDefaultClientId(),s=$.getLoginUrl({port:n,localState:r,clientId:o||void 0});t.onAuth({url:s});let a;if(t.onManualCodeInput){let u=t.onManualCodeInput().then(aee);a=await Promise.race([i,u])}else a=await i;if(a.state!==r)throw new Error("CSRF check failed - state does not match localState");if(!a.clientId)throw new Error("Login callback did not include clientId");let l=await Gw(a.code,a.clientId);$.recordActiveClientId(a.clientId);let c=ca(l.accessToken);return await Gt(l.accessToken),{refresh:l.refreshToken,access:l.accessToken,expires:c>0?c-$.getTokenExpiryBuffer():Date.now()+10800*1e3,projectId:$.getDefaultProjectId(),workspaceId:$.getDefaultWorkspaceId()}}import{randomUUID as lee}from"node:crypto";async function Hw(t){if(!t.refresh)throw new Error("No refresh token available. Please login again.");let e;try{e=await Gt(t.access)}catch(a){throw Ge("auth/refresh: app token unavailable for refresh call",a),new Error(`Cannot refresh Slingshot token: app token unavailable (${a instanceof Error?a.message:String(a)}). Please /login slingshot.`)}let n=lee(),i={accept:"application/json",rt:t.refresh,"trace-id":n,Authorization:`Bearer ${e}`},r;try{let a=$.getRefreshUrl();r=await fetch(a,{headers:i})}catch(a){let l=a instanceof Error?a.message:String(a);throw new Error(`Cannot reach Slingshot server: ${l}`)}if(!r.ok){let a=`${r.status} ${r.statusText}`;try{let l=await r.json();l.message?a=String(l.message):l.error&&(a=String(l.error))}catch{}throw new Error(`Token refresh failed: ${a}`)}let o=await r.json();if(!o.accessToken)throw new Error("No access token in refresh response");let s=ca(o.accessToken);try{await Gt(o.accessToken)}catch(a){throw Ge("auth/refresh: app token refresh failed",a),a}return{refresh:o.refreshToken||t.refresh,access:o.accessToken,expires:s>0?s-$.getTokenExpiryBuffer():Date.now()+10800*1e3,projectId:t.projectId,workspaceId:t.workspaceId}}var yd=[{id:"gpt-5.4-nano",name:"GPT-5.4 nano",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:.2,output:1.25,cacheRead:.02,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,api:"openai-responses",provider:"slingshot"},{id:"gpt-4.1",name:"GPT-4.1",baseUrl:"",reasoning:!1,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:1047576,maxTokens:32768,provider:"slingshot",api:"openai-completions"},{id:"gpt-5",name:"GPT-5",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.125,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5-mini",name:"GPT-5 Mini",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.25,output:2,cacheRead:.025,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5-nano",name:"GPT-5 Nano",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.05,output:.4,cacheRead:.005,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5.1",name:"GPT-5.1",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.25,output:10,cacheRead:.13,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5.2",name:"GPT-5.2",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"gpt-5.4-mini",name:"GPT-5.4 mini",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:.75,output:4.5,cacheRead:.075,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,api:"openai-responses",provider:"slingshot"},{id:"gpt-5.4",name:"GPT-5.4",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:2.5,output:15,cacheRead:.25,cacheWrite:0},contextWindow:272e3,maxTokens:128e3,api:"openai-responses",provider:"slingshot"},{id:"gpt-5.5",name:"GPT-5.5",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:5,output:30,cacheRead:.5,cacheWrite:0},contextWindow:272e3,maxTokens:128e3,api:"openai-responses",provider:"slingshot"},{id:"gpt-5.6-luna",name:"GPT-5.6 Luna",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:.96,output:5.76,cacheRead:.096,cacheWrite:0},contextWindow:105e4,maxTokens:5e5,api:"openai-responses",provider:"slingshot"},{id:"gpt-5.6-terra",name:"GPT-5.6 Terra",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:2.4,output:14.4,cacheRead:.24,cacheWrite:0},contextWindow:105e4,maxTokens:5e5,api:"openai-responses",provider:"slingshot"},{id:"gpt-5.6-sol",name:"GPT-5.6 Sol",baseUrl:"",reasoning:!0,thinkingLevelMap:{xhigh:"xhigh"},input:["text","image"],cost:{input:4.8,output:28.8,cacheRead:.48,cacheWrite:0},contextWindow:105e4,maxTokens:5e5,api:"openai-responses",provider:"slingshot"},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,provider:"slingshot",api:"openai-responses"},{id:"claude-opus-4@20250514",name:"Claude Opus 4",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},contextWindow:2e5,maxTokens:32e3,provider:"slingshot",api:"openai-completions"},{id:"claude-sonnet-4@20250514",name:"Claude Sonnet 4",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3,provider:"slingshot",api:"openai-completions"},{id:"claude-sonnet-4-5@20250929",name:"Claude Sonnet 4.5",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:2e5,maxTokens:64e3,provider:"slingshot",api:"openai-completions"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:64e3,provider:"slingshot",api:"openai-completions"},{id:"claude-opus-4-6",name:"Claude Opus 4.6",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:128e3,provider:"slingshot",api:"openai-completions"},{id:"claude-sonnet-5",name:"Claude Sonnet 5",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e5,maxTokens:64e3,provider:"slingshot",api:"openai-completions"},{id:"Qwen/Qwen3.6-27B-FP8",name:"Qwen 3.6 27B FP8",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.2,output:3.6,cacheRead:.3,cacheWrite:3.75},contextWindow:64e3,maxTokens:56e3,provider:"slingshot",api:"openai-completions"},{id:"o3",name:"O3",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:2,output:8,cacheRead:.5,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,provider:"slingshot",api:"openai-completions"},{id:"o3-mini",name:"o3-mini",baseUrl:"",reasoning:!0,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,provider:"slingshot",api:"openai-completions"},{id:"o4-mini",name:"o4-mini",baseUrl:"",reasoning:!0,input:["text"],cost:{input:1.1,output:4.4,cacheRead:.28,cacheWrite:0},contextWindow:2e5,maxTokens:1e5,provider:"slingshot",api:"openai-completions"},{id:"gemini-3.1-flash-lite",name:"Gemini 3.1 Flash Lite",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:.44,output:1.32,cacheRead:.075,cacheWrite:0},contextWindow:1e6,maxTokens:65535,provider:"slingshot",api:"openai-completions"},{id:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview",baseUrl:"",reasoning:!0,input:["text","image"],cost:{input:1.76,output:10.56,cacheRead:.075,cacheWrite:0},contextWindow:1e6,maxTokens:65535,provider:"slingshot",api:"openai-completions"}];var Sf=t=>Math.round((t??0)*1e3*1e6)/1e6,cee=32768,uee=16384,pee=new Map(yd.map(t=>[t.id,t.maxTokens]));async function x2(t,e){let n=await fetch(t,{headers:{Authorization:`Bearer ${e}`,Accept:"application/json"}});if(!n.ok)throw new Error(`Slingshot models fetch failed: ${n.status}`);let i=await n.json();return dee(Array.isArray(i)?i:i?.data??[])}function dee(t){return t.filter(e=>e.model_type==="chat").map(e=>{let n=e.metadata??{},i=typeof n.family=="string"?n.family.trim():"",r=i==="smart",o=n.context_length??0,s=(n.supported_modalities??["text"]).filter(a=>a==="text"||a==="image");return{id:e.id,name:n.name||e.id,baseUrl:"",reasoning:r?!1:!!n.reasoning,input:s,cost:{input:Sf(e.inputCostPer1KTokens),output:Sf(e.outputCostPer1KTokens),cacheRead:Sf(e.cacheCostPer1KTokens?.read),cacheWrite:Sf(e.cacheCostPer1KTokens?.write)},contextWindow:o,maxTokens:Math.min(o,r?uee:pee.get(e.id)??cee),provider:"slingshot",api:r?"openai-completions":e.supported_apis?.includes("responses")?"openai-responses":"openai-completions",...i===""?{}:{family:i}}}).sort((e,n)=>e.id.localeCompare(n.id))}import b2 from"node:fs";function v2(t,e,n){try{b2.writeFileSync(t,JSON.stringify({baseUrl:e,fetchedAt:new Date().toISOString(),models:n}))}catch{}}function zw(t,e){try{let n=JSON.parse(b2.readFileSync(t,"utf-8"));return n?.baseUrl!==e||!Array.isArray(n.models)||n.models.length===0?null:n.models}catch{return null}}import Tf from"node:fs";import y2 from"node:path";import mee from"proper-lockfile";var hee=250;function gee(){return y2.resolve(Ee(),"settings.json")}function fee(t){if(!Tf.existsSync(t))return{};try{let e=JSON.parse(Tf.readFileSync(t,"utf-8"));return e===null||typeof e!="object"||Array.isArray(e)?(fe(`default-model: refusing to write to non-object settings at ${t}`),null):e}catch(e){return fe(`default-model: could not parse ${t}, leaving it alone: ${Vw(e)}`),null}}async function xee(t,e,n){let i;try{Tf.mkdirSync(y2.dirname(t),{recursive:!0}),i=await mee.lock(t,{realpath:!1,retries:{retries:10,minTimeout:20,maxTimeout:200},onCompromised:o=>fe(`default-model: settings lock compromised: ${Vw(o)}`)});let r=fee(t);return r===null?!1:(r.defaultProvider===e&&r.defaultModel===n||(r.defaultProvider=e,r.defaultModel=n,Tf.writeFileSync(t,`${JSON.stringify(r,null,2)}
451
451
  `,"utf-8"),fe(`default-model: recorded ${e}/${n}`)),!0)}catch(r){return fe(`default-model: failed to record ${e}/${n}: ${Vw(r)}`),!1}finally{await i?.().catch(()=>{})}}function Vw(t){return t instanceof Error?t.message:String(t)}function Jw(t){let e,n;async function i(){n=void 0;let r=e;e=void 0,r&&await xee(gee(),r.provider,r.modelId)}t.on("model_select",async r=>{r.source!=="restore"&&(e={provider:r.model.provider,modelId:r.model.id},n&&clearTimeout(n),n=setTimeout(()=>{i()},hee),n.unref?.())}),t.on("session_shutdown",async()=>{n&&clearTimeout(n),await i()})}var Qw="slingshot-smart-model-attribution";function wd(t){return typeof t=="string"&&t.trim().length>0}function kf(t){let e=new Set;for(let n of t)wd(n.family)&&n.family==="smart"&&e.add(n.id);return e}function w2(t){return{smartModelIds:new Set(t),pendingResponseModel:void 0}}function Yw(t,e){t.smartModelIds=new Set(e)}function S2(t){t.pendingResponseModel=void 0}function T2(t){return t===null||typeof t!="object"||Array.isArray(t)?null:t}function k2(t,e){let n=T2(e);if(n===null)return;let i,r,o,s;try{i=n.role,r=n.provider,o=n.model,s=n.responseModel}catch{return}i==="assistant"&&r==="slingshot"&&wd(o)&&t.smartModelIds.has(o)&&wd(s)&&(t.pendingResponseModel=s)}function C2(t,e){if(!wd(t.pendingResponseModel))return;let n=t.pendingResponseModel;try{e({responseModel:n})}catch{}finally{t.pendingResponseModel=void 0}}function R2(t){let e=T2(t);return e===null?!1:wd(e.responseModel)}function M2(t,e){let n;try{if(t===null||typeof t!="object")return;n=t.responseModel}catch{return}let i={responseModel:n};if(!R2(i))return;let r=i.responseModel.replace(/[\x00-\x1f\x7f-\x9f]/g,"").trim();if(r.length!==0)return new A(e.fg("dim",`Model used: ${r}`),0,0)}function Xw(t,e){let n=new Headers(e.headers);return n.delete("content-length"),n.delete("content-encoding"),new Response(t,{status:e.status,statusText:e.statusText,headers:n})}function bee(t){let e=new TextDecoder,n=new TextEncoder,i="";return new TransformStream({transform(r,o){i+=e.decode(r,{stream:!0});let s=i.split(`
452
452
  `);i=s.pop()??"",s.length>0&&o.enqueue(n.encode(`${s.map(t).join(`
453
453
  `)}
454
- `))},flush(r){i&&r.enqueue(n.encode(t(i)))}})}function Cf(t,e,n,i){return async(r,o)=>{let s=await t(r,o);if(!s.ok||!s.body)return s;let a=s.headers.get("content-type")??"";if(a.includes("event-stream"))return Xw(s.body.pipeThrough(bee(i)),s);if(!a.includes("json"))return s;let l=await s.text();if(!l.includes(e))return Xw(l,s);let c=n(l);return Xw(c??l,s)}}var E2="_input_tokens";function P2(t){if(!t)return!1;let e=t.prompt_tokens_details??{},n=e.cached_tokens??t.cache_read_input_tokens,i=e.cache_write_tokens??t.cache_creation_input_tokens;return n===e.cached_tokens&&i===e.cache_write_tokens?!1:(t.prompt_tokens_details={...e,cached_tokens:n??0,cache_write_tokens:i??0},!0)}function I2(t){let e=P2(t?.usage);for(let n of t?.choices??[])P2(n?.usage)&&(e=!0);return e}function vee(t){if(!t.startsWith("data: ")||!t.includes(E2))return t;try{let e=JSON.parse(t.slice(6));return I2(e)?`data: ${JSON.stringify(e)}`:t}catch{return t}}function A2(t=globalThis.fetch){return Cf(t,E2,e=>{try{let n=JSON.parse(e);return I2(n)?JSON.stringify(n):null}catch{return null}},vee)}var Rf=null,Zw=null;function Xc(){return Rf}function _2(){Rf=null,Zw=null}function yee(t){Rf=(Rf??0)+t,Zw=t}var O2='"usage"';function L2(t){if(!t||typeof t!="object")return;let n=t.usage;if(n&&typeof n=="object"){let i=n.cost;if(i&&typeof i=="object"){let r=i.totalCost;typeof r=="number"&&Number.isFinite(r)&&yee(r)}}}function wee(t){if(!t.startsWith("data: ")||!t.includes(O2))return t;try{L2(JSON.parse(t.slice(6)))}catch{}return t}function W2(t=globalThis.fetch){let e=Cf(t,O2,n=>{try{L2(JSON.parse(n))}catch{}return null},wee);return async(n,i)=>(Zw=null,e(n,i))}var See=["patternProperties"];function Tee(t){return typeof t=="string"&&t.toLowerCase().includes("gemini")}function eS(t){if(Array.isArray(t)){let i=!1;for(let r of t)eS(r)&&(i=!0);return i}if(typeof t!="object"||t===null)return!1;let e=!1,n=t;for(let i of See)i in n&&(delete n[i],e=!0);for(let i of Object.values(n))eS(i)&&(e=!0);return e}function D2(t){if(typeof t!="object"||t===null)return!1;let{model:e,tools:n}=t;return!Tee(e)||!Array.isArray(n)?!1:eS(n)}import pa from"node:fs";import kee from"node:path";var Cee="auth.json",tS="slingshot",Ree=3e4,Mee=2e3,Pee=50,Eee=t=>new Promise(e=>setTimeout(e,t));async function Iee(t){let e=`${t}.lock`,n=Date.now()+Mee;for(;;)try{return pa.mkdirSync(e),()=>{try{pa.rmdirSync(e)}catch{}}}catch(i){if(i.code!=="EEXIST")throw i;try{if(Date.now()-pa.statSync(e).mtimeMs>Ree){pa.rmdirSync(e);continue}}catch{}if(Date.now()>=n)return null;await Eee(Pee)}}async function Aee(){let t=kee.resolve(Ee(),Cee),e=null;try{if(!pa.existsSync(t))return;if(e=await Iee(t),!e){fe(`client-state: could not lock ${t}; leaving stored credential in place`);return}let n=pa.readFileSync(t,"utf-8"),i=JSON.parse(n);if(!i||typeof i!="object"||Array.isArray(i)||!(tS in i))return;delete i[tS],pa.writeFileSync(t,JSON.stringify(i,null,2),"utf-8"),fe(`client-state: cleared "${tS}" credential from ${t}`)}catch(n){Ge("client-state: failed to clear stored user credential",n)}finally{e?.()}}async function Sd(){f2(),await Aee(),fe("client-state: reset complete")}var Mf={name:"slingshot.cli",private:!0,type:"module",workspaces:["packages/*","packages/web-ui/example","packages/coding-agent/examples/extensions/with-deps","packages/coding-agent/examples/extensions/custom-provider-anthropic","packages/coding-agent/examples/extensions/custom-provider-gitlab-duo"],scripts:{clean:"npm run clean --workspaces",build:"cd packages/tui && npm run build && cd ../ai && npm run build && cd ../agent && npm run build && cd ../storage/sqlite-node && npm run build && cd ../../coding-agent && npm run build && cd ../server && npm run build","build:offline":"cd packages/tui && npm run build && cd ../ai && npm run build:offline && cd ../agent && npm run build && cd ../storage/sqlite-node && npm run build && cd ../../coding-agent && npm run build && cd ../server && npm run build",dev:'concurrently --names "ai,agent,coding-agent,web-ui,tui" --prefix-colors "cyan,yellow,red,white,green,magenta" "cd packages/ai && npm run dev" "cd packages/agent && npm run dev" "cd packages/coding-agent && npm run dev" "cd packages/server && npm run dev" "cd packages/tui && npm run dev"',"dev:tsc":'concurrently --names "ai,web-ui" --prefix-colors "cyan,green" "cd packages/ai && npm run dev:tsc" "cd packages/web-ui && npm run dev:tsc"',check:"","check:browser-smoke":"","test:models":"node scripts/test-models.mjs","profile:tui":"node scripts/profile-coding-agent-node.mjs --mode tui","profile:rpc":"node scripts/profile-coding-agent-node.mjs --mode rpc",test:"npm run test --workspaces --if-present","version:patch":"npm version patch -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install","version:minor":"npm version minor -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install","version:major":"npm version major -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install","version:set":"npm version -ws",prepublishOnly:"npm run clean && npm run build && npm run check",publish:"npm run prepublishOnly && npm publish -ws --access public","publish:dry":"npm run prepublishOnly && npm publish -ws --access public --dry-run","release:patch":"node scripts/release.mjs patch","release:minor":"node scripts/release.mjs minor","release:major":"node scripts/release.mjs major",prepare:"husky"},devDependencies:{"@anthropic-ai/sandbox-runtime":"0.0.57","@biomejs/biome":"2.3.15","@types/better-sqlite3":"^7.6.13","@types/lodash.mergewith":"^4.6.9","@types/node":"24.13.2","@types/turndown":"^5.0.6","@typescript/native-preview":"7.0.0-dev.20260120.1",concurrently:"^9.2.3",esbuild:"0.28.1","fast-xml-parser":"^5.9.3",husky:"9.1.7",jiti:"2.7.0",psadk:"^1.5.1",shx:"0.4.0",tsx:"4.22.4",turbo:"^2.9.18",typescript:"5.9.3",vitest:"^4.1.9"},engines:{node:">=20.0.0"},slingVersion:"3.3.20260918-1",overrides:{rimraf:"6.1.2",gaxios:{rimraf:"6.1.2"},postcss:"8.5.14",next:{postcss:"8.5.14"},"ip-address":"10.7.1","fast-uri":"3.1.8","brace-expansion":"5.0.12","proxy-addr":"2.0.8",undici:"8.10.2","@modelcontextprotocol/sdk":"^1.29.0",ai:">=5.0.52","fast-xml-parser":"^5.9.3","@aws-sdk/xml-builder":{"fast-xml-parser":"^5.9.3"},"adaptivecards-templating":{"adaptive-expressions":{"fast-xml-parser":"^5.5.8"}},picomatch:"^4.0.4","path-to-regexp":"8.4.1",router:{"path-to-regexp":"8.4.1"},minimatch:"^10.2.3",tar:"7.5.11",react:"19.1.1","react-dom":"19.1.1","@types/react":"19","@types/react-dom":"19",tailwindcss:"4.1.12",lightningcss:"1.30.2",glob:{".":"13.0.6",minimatch:"10.2.3"},prismjs:"^1.30.0",qs:"6.16.0","shell-quote":"1.9.0","@hono/node-server":"1.19.15",protobufjs:"^8.2.0","@opentelemetry/otlp-transformer":{protobufjs:"^8.2.0"},langchain:{langsmith:">=0.7.0"},hono:"4.13.7",fsevents:"^2.3.3",swiper:"^12.1.2",lodash:"^4.18.0","lodash-es":"^4.18.1",axios:"^1.15.0","ibm-cloud-sdk-core":"^5.4.11",dompurify:">=3.4.0","react-markdown-mermaid":{mermaid:"10.9.6"}},dependencies:{"@modelcontextprotocol/sdk":"^1.29.0","@mozilla/readability":"^0.6.0","better-sqlite3":"^12.11.1","compound-engineering-pi":"^0.2.4","get-east-asian-width":"^1.4.0",linkedom:"^0.18.12",turndown:"^7.2.4",unpdf:"^1.6.2"}};import Td from"chalk";function F2(t,e){return{render(n){let i=` \u26AC _______. __ __ .__ __. _______
454
+ `))},flush(r){i&&r.enqueue(n.encode(t(i)))}})}function Cf(t,e,n,i){return async(r,o)=>{let s=await t(r,o);if(!s.ok||!s.body)return s;let a=s.headers.get("content-type")??"";if(a.includes("event-stream"))return Xw(s.body.pipeThrough(bee(i)),s);if(!a.includes("json"))return s;let l=await s.text();if(!l.includes(e))return Xw(l,s);let c=n(l);return Xw(c??l,s)}}var E2="_input_tokens";function P2(t){if(!t)return!1;let e=t.prompt_tokens_details??{},n=e.cached_tokens??t.cache_read_input_tokens,i=e.cache_write_tokens??t.cache_creation_input_tokens;return n===e.cached_tokens&&i===e.cache_write_tokens?!1:(t.prompt_tokens_details={...e,cached_tokens:n??0,cache_write_tokens:i??0},!0)}function I2(t){let e=P2(t?.usage);for(let n of t?.choices??[])P2(n?.usage)&&(e=!0);return e}function vee(t){if(!t.startsWith("data: ")||!t.includes(E2))return t;try{let e=JSON.parse(t.slice(6));return I2(e)?`data: ${JSON.stringify(e)}`:t}catch{return t}}function A2(t=globalThis.fetch){return Cf(t,E2,e=>{try{let n=JSON.parse(e);return I2(n)?JSON.stringify(n):null}catch{return null}},vee)}var Rf=null,Zw=null;function Xc(){return Rf}function _2(){Rf=null,Zw=null}function yee(t){Rf=(Rf??0)+t,Zw=t}var O2='"usage"';function L2(t){if(!t||typeof t!="object")return;let n=t.usage;if(n&&typeof n=="object"){let i=n.cost;if(i&&typeof i=="object"){let r=i.totalCost;typeof r=="number"&&Number.isFinite(r)&&yee(r)}}}function wee(t){if(!t.startsWith("data: ")||!t.includes(O2))return t;try{L2(JSON.parse(t.slice(6)))}catch{}return t}function W2(t=globalThis.fetch){let e=Cf(t,O2,n=>{try{L2(JSON.parse(n))}catch{}return null},wee);return async(n,i)=>(Zw=null,e(n,i))}var See=["patternProperties"];function Tee(t){return typeof t=="string"&&t.toLowerCase().includes("gemini")}function eS(t){if(Array.isArray(t)){let i=!1;for(let r of t)eS(r)&&(i=!0);return i}if(typeof t!="object"||t===null)return!1;let e=!1,n=t;for(let i of See)i in n&&(delete n[i],e=!0);for(let i of Object.values(n))eS(i)&&(e=!0);return e}function D2(t){if(typeof t!="object"||t===null)return!1;let{model:e,tools:n}=t;return!Tee(e)||!Array.isArray(n)?!1:eS(n)}import pa from"node:fs";import kee from"node:path";var Cee="auth.json",tS="slingshot",Ree=3e4,Mee=2e3,Pee=50,Eee=t=>new Promise(e=>setTimeout(e,t));async function Iee(t){let e=`${t}.lock`,n=Date.now()+Mee;for(;;)try{return pa.mkdirSync(e),()=>{try{pa.rmdirSync(e)}catch{}}}catch(i){if(i.code!=="EEXIST")throw i;try{if(Date.now()-pa.statSync(e).mtimeMs>Ree){pa.rmdirSync(e);continue}}catch{}if(Date.now()>=n)return null;await Eee(Pee)}}async function Aee(){let t=kee.resolve(Ee(),Cee),e=null;try{if(!pa.existsSync(t))return;if(e=await Iee(t),!e){fe(`client-state: could not lock ${t}; leaving stored credential in place`);return}let n=pa.readFileSync(t,"utf-8"),i=JSON.parse(n);if(!i||typeof i!="object"||Array.isArray(i)||!(tS in i))return;delete i[tS],pa.writeFileSync(t,JSON.stringify(i,null,2),"utf-8"),fe(`client-state: cleared "${tS}" credential from ${t}`)}catch(n){Ge("client-state: failed to clear stored user credential",n)}finally{e?.()}}async function Sd(){f2(),await Aee(),fe("client-state: reset complete")}var Mf={name:"slingshot.cli",private:!0,type:"module",workspaces:["packages/*","packages/web-ui/example","packages/coding-agent/examples/extensions/with-deps","packages/coding-agent/examples/extensions/custom-provider-anthropic","packages/coding-agent/examples/extensions/custom-provider-gitlab-duo"],scripts:{clean:"npm run clean --workspaces",build:"cd packages/tui && npm run build && cd ../ai && npm run build && cd ../agent && npm run build && cd ../storage/sqlite-node && npm run build && cd ../../coding-agent && npm run build && cd ../server && npm run build","build:offline":"cd packages/tui && npm run build && cd ../ai && npm run build:offline && cd ../agent && npm run build && cd ../storage/sqlite-node && npm run build && cd ../../coding-agent && npm run build && cd ../server && npm run build",dev:'concurrently --names "ai,agent,coding-agent,web-ui,tui" --prefix-colors "cyan,yellow,red,white,green,magenta" "cd packages/ai && npm run dev" "cd packages/agent && npm run dev" "cd packages/coding-agent && npm run dev" "cd packages/server && npm run dev" "cd packages/tui && npm run dev"',"dev:tsc":'concurrently --names "ai,web-ui" --prefix-colors "cyan,green" "cd packages/ai && npm run dev:tsc" "cd packages/web-ui && npm run dev:tsc"',check:"","check:browser-smoke":"","test:models":"node scripts/test-models.mjs","profile:tui":"node scripts/profile-coding-agent-node.mjs --mode tui","profile:rpc":"node scripts/profile-coding-agent-node.mjs --mode rpc",test:"npm run test --workspaces --if-present","version:patch":"npm version patch -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install","version:minor":"npm version minor -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install","version:major":"npm version major -ws --no-git-tag-version && node scripts/sync-versions.js && shx rm -rf node_modules packages/*/node_modules package-lock.json && npm install","version:set":"npm version -ws",prepublishOnly:"npm run clean && npm run build && npm run check",publish:"npm run prepublishOnly && npm publish -ws --access public","publish:dry":"npm run prepublishOnly && npm publish -ws --access public --dry-run","release:patch":"node scripts/release.mjs patch","release:minor":"node scripts/release.mjs minor","release:major":"node scripts/release.mjs major",prepare:"husky"},devDependencies:{"@anthropic-ai/sandbox-runtime":"0.0.57","@biomejs/biome":"2.3.15","@types/better-sqlite3":"^7.6.13","@types/lodash.mergewith":"^4.6.9","@types/node":"24.13.2","@types/turndown":"^5.0.6","@typescript/native-preview":"7.0.0-dev.20260120.1",concurrently:"^9.2.3",esbuild:"0.28.1","fast-xml-parser":"^5.9.3",husky:"9.1.7",jiti:"2.7.0",psadk:"^1.5.1",shx:"0.4.0",tsx:"4.22.4",turbo:"^2.9.18",typescript:"5.9.3",vitest:"^4.1.9"},engines:{node:">=20.0.0"},slingVersion:"3.3.20260922-1",overrides:{rimraf:"6.1.2",gaxios:{rimraf:"6.1.2"},postcss:"8.5.14",next:{postcss:"8.5.14"},"ip-address":"10.7.1","fast-uri":"3.1.8","brace-expansion":"5.0.12","proxy-addr":"2.0.8",undici:"8.10.2","@modelcontextprotocol/sdk":"^1.29.0",ai:">=5.0.52","fast-xml-parser":"^5.9.3","@aws-sdk/xml-builder":{"fast-xml-parser":"^5.9.3"},"adaptivecards-templating":{"adaptive-expressions":{"fast-xml-parser":"^5.5.8"}},picomatch:"^4.0.4","path-to-regexp":"8.4.1",router:{"path-to-regexp":"8.4.1"},minimatch:"^10.2.3",tar:"7.5.11",react:"19.1.1","react-dom":"19.1.1","@types/react":"19","@types/react-dom":"19",tailwindcss:"4.1.12",lightningcss:"1.30.2",glob:{".":"13.0.6",minimatch:"10.2.3"},prismjs:"^1.30.0",qs:"6.16.0","shell-quote":"1.9.0","@hono/node-server":"1.19.15",protobufjs:"^8.2.0","@opentelemetry/otlp-transformer":{protobufjs:"^8.2.0"},langchain:{langsmith:">=0.7.0"},hono:"4.13.7",fsevents:"^2.3.3",swiper:"^12.1.2",lodash:"^4.18.0","lodash-es":"^4.18.1",axios:"^1.15.0","ibm-cloud-sdk-core":"^5.4.11",dompurify:">=3.4.0","react-markdown-mermaid":{mermaid:"10.9.6"}},dependencies:{"@modelcontextprotocol/sdk":"^1.29.0","@mozilla/readability":"^0.6.0","better-sqlite3":"^12.11.1","compound-engineering-pi":"^0.2.4","get-east-asian-width":"^1.4.0",linkedom:"^0.18.12",turndown:"^7.2.4",unpdf:"^1.6.2"}};import Td from"chalk";function F2(t,e){return{render(n){let i=` \u26AC _______. __ __ .__ __. _______
455
455
  \u274D \xB7 \u274D / || | | | | \\ | | / _____|
456
456
  \u2726 \u26AC \u2726 | (----\`| | | | | \\| | | | __
457
457
  \u26AC \xB7 \u26AC \u26AC \xB7 \u26AC \\ \\ | | | | | . \` | | | |_ |