opencrater 1.3.0 → 1.3.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/dist/cli.js CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  `;o+=`${t}[compat.${n}]
9
9
  hooks = false
10
- `;}return o}function Le(e){try{let o=f__namespace.join(J("grok_cli",e),"config.toml"),n="";try{n=p__namespace.readFileSync(o,"utf8");}catch{}let t=qe(n);if(t===n)return;p__namespace.mkdirSync(f__namespace.dirname(o),{recursive:!0}),p__namespace.writeFileSync(o,t,"utf8");}catch{}}function L(e,o,n){let t=q(e);return t.length===0?"nochange":(e==="grok_cli"&&Le(process.env),e==="copilot_cli"?He(e,o,n,t):Ne(e,o,n,t))}function P(e,o,n=process.env){return K(n).map(t=>{try{let i=L(t,e,o);return {host:t,status:i,events:q(t)}}catch(i){return {host:t,status:"error",events:[],error:i.message}}})}function Y(e=process.env){let o=[];for(let n of b){let t;try{t=H(M(n,e));}catch{continue}let i=t.hooks;if(!(!i||typeof i!="object"))for(let[r,s]of Object.entries(i))for(let d of Array.isArray(s)?s:[]){let a=d,c=Array.isArray(a.hooks)?a.hooks.find(u=>typeof u.command=="string"&&j(u.command))?.command:void 0,l=[a.bash,a.command,a.powershell].find(u=>typeof u=="string"&&j(u)),g=c??l;g&&o.push({host:n,event:r,command:g});}}return o}function ce(e=process.env){let o=0;for(let n of b){let t=M(n,e),i;try{i=H(t);}catch{continue}let r=i.hooks;if(!r||typeof r!="object")continue;let s=r,d=false;for(let a of Object.keys(s)){let c=Array.isArray(s[a])?s[a]:[],l=c.filter(g=>{let u=g,_=Array.isArray(u.hooks)&&u.hooks.some(C=>typeof C.command=="string"&&j(C.command))||[u.bash,u.powershell,u.command].some(C=>typeof C=="string"&&j(C));return _&&o++,!_});l.length!==c.length&&(d=true,l.length>0?s[a]=l:delete s[a]);}if(d)try{let a=Object.keys(i).filter(l=>l!=="version"&&l!=="hooks"),c=n==="copilot_cli"||n==="codex";Object.keys(s).length===0&&a.length===0&&c?p__namespace.rmSync(t,{force:!0}):V(t,i);}catch{}}return o}var E="1.3.0";var Be="https://api.opencrater.to";function x(e,o=process.env){let n=o.OPENCRATER_API_ORIGIN;return (e??(n&&n.trim()!==""?n:Be)).replace(/\/+$/,"")}function Fe(){return f__namespace.join(N__namespace.homedir(),".config","opencrater","runtime")}function De(e){return ["install","--prefix",e,"opencrater@latest","--silent","--no-audit","--no-fund"]}function B(e=Fe()){if(process.env.VITEST||process.env.OPENCRATER_DISABLE_RUNTIME_PIN)return false;try{return child_process.spawnSync("npm",De(e),{stdio:"ignore",windowsHide:!0,shell:process.platform==="win32"}).status===0}catch{return false}}function ze(){let e=process.env.OPENCRATER_WEB_ORIGIN;return e&&e.trim()!==""?e.replace(/\/$/,""):x().replace("//api.","//").replace(/\/$/,"")}function Ge(e){try{let o=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";child_process.spawn(o,[e],{stdio:"ignore",detached:!0,shell:process.platform==="win32"}).unref();}catch{}}function Je(e){let o=pe__namespace.createInterface({input:process.stdin,output:process.stdout});return new Promise(n=>o.question(e,t=>(o.close(),n(t))))}function T(e){return `${Math.round(e/1e3).toLocaleString()} tokens`}function Ke(e){let o=e/1e3;return o>0&&o<10?`${(Math.round(o*10)/10).toFixed(1)} tokens`:`${Math.round(o).toLocaleString()} tokens`}function $(e){let o=e?.pendingMicroUsd??0;return o>0?` \xB7 +${Ke(o)} pending`:""}async function W(e,o){try{let n=new URL(`${x()}/v1/dev/me`);o&&n.searchParams.set("installId",o);let t=await fetch(n,{headers:{authorization:`Bearer ${e}`}});return t.ok?await t.json():null}catch{return null}}async function Ve(){let e=`${ze()}/dev/link`;console.log("Sign in and generate a CLI token here (we tried to open it):"),console.log(` ${e}
10
+ `;}return o}function Le(e){try{let o=f__namespace.join(J("grok_cli",e),"config.toml"),n="";try{n=p__namespace.readFileSync(o,"utf8");}catch{}let t=qe(n);if(t===n)return;p__namespace.mkdirSync(f__namespace.dirname(o),{recursive:!0}),p__namespace.writeFileSync(o,t,"utf8");}catch{}}function L(e,o,n){let t=q(e);return t.length===0?"nochange":(e==="grok_cli"&&Le(process.env),e==="copilot_cli"?He(e,o,n,t):Ne(e,o,n,t))}function P(e,o,n=process.env){return K(n).map(t=>{try{let i=L(t,e,o);return {host:t,status:i,events:q(t)}}catch(i){return {host:t,status:"error",events:[],error:i.message}}})}function Y(e=process.env){let o=[];for(let n of b){let t;try{t=H(M(n,e));}catch{continue}let i=t.hooks;if(!(!i||typeof i!="object"))for(let[r,s]of Object.entries(i))for(let d of Array.isArray(s)?s:[]){let a=d,c=Array.isArray(a.hooks)?a.hooks.find(u=>typeof u.command=="string"&&j(u.command))?.command:void 0,l=[a.bash,a.command,a.powershell].find(u=>typeof u=="string"&&j(u)),g=c??l;g&&o.push({host:n,event:r,command:g});}}return o}function ce(e=process.env){let o=0;for(let n of b){let t=M(n,e),i;try{i=H(t);}catch{continue}let r=i.hooks;if(!r||typeof r!="object")continue;let s=r,d=false;for(let a of Object.keys(s)){let c=Array.isArray(s[a])?s[a]:[],l=c.filter(g=>{let u=g,_=Array.isArray(u.hooks)&&u.hooks.some(C=>typeof C.command=="string"&&j(C.command))||[u.bash,u.powershell,u.command].some(C=>typeof C=="string"&&j(C));return _&&o++,!_});l.length!==c.length&&(d=true,l.length>0?s[a]=l:delete s[a]);}if(d)try{let a=Object.keys(i).filter(l=>l!=="version"&&l!=="hooks"),c=n==="copilot_cli"||n==="codex";Object.keys(s).length===0&&a.length===0&&c?p__namespace.rmSync(t,{force:!0}):V(t,i);}catch{}}return o}var E="1.3.1";var Be="https://api.opencrater.to";function x(e,o=process.env){let n=o.OPENCRATER_API_ORIGIN;return (e??(n&&n.trim()!==""?n:Be)).replace(/\/+$/,"")}function Fe(){return f__namespace.join(N__namespace.homedir(),".config","opencrater","runtime")}function De(e){return ["install","--prefix",e,"opencrater@latest","--silent","--no-audit","--no-fund"]}function B(e=Fe()){if(process.env.VITEST||process.env.OPENCRATER_DISABLE_RUNTIME_PIN)return false;try{return child_process.spawnSync("npm",De(e),{stdio:"ignore",windowsHide:!0,shell:process.platform==="win32"}).status===0}catch{return false}}function ze(){let e=process.env.OPENCRATER_WEB_ORIGIN;return e&&e.trim()!==""?e.replace(/\/$/,""):x().replace("//api.","//").replace(/\/$/,"")}function Ge(e){try{let o=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";child_process.spawn(o,[e],{stdio:"ignore",detached:!0,shell:process.platform==="win32"}).unref();}catch{}}function Je(e){let o=pe__namespace.createInterface({input:process.stdin,output:process.stdout});return new Promise(n=>o.question(e,t=>(o.close(),n(t))))}function T(e){return `${Math.round(e/1e3).toLocaleString()} tokens`}function Ke(e){let o=e/1e3;return o>0&&o<10?`${(Math.round(o*10)/10).toFixed(1)} tokens`:`${Math.round(o).toLocaleString()} tokens`}function $(e){let o=e?.pendingMicroUsd??0;return o>0?` \xB7 +${Ke(o)} pending`:""}async function W(e,o){try{let n=new URL(`${x()}/v1/dev/me`);o&&n.searchParams.set("installId",o);let t=await fetch(n,{headers:{authorization:`Bearer ${e}`}});return t.ok?await t.json():null}catch{return null}}async function Ve(){let e=`${ze()}/dev/link`;console.log("Sign in and generate a CLI token here (we tried to open it):"),console.log(` ${e}
11
11
  `),Ge(e);let o=(await Je("Paste your token (ocd_\u2026): ")).trim();if(!o.startsWith("ocd_"))return console.error("That doesn't look like a token (should start with ocd_)."),1;let n=await W(o,m().installId);if(!n)return console.error("Couldn't verify that token \u2014 check it and try again."),1;S({devToken:o}),console.log(`
12
12
  \u2713 Signed in as ${n.displayName}.`),console.log(` Compute balance: ${T(n.balanceMicroUsd)}${$(n)} \xB7 tier: ${n.trustTier}`);let t=P().filter(i=>i.status!=="error").map(i=>i.host);return t.length?(console.log(` Wired into: ${t.join(", ")}`),process.stdout.write(" Pinning fast runtime (one-time, ~15s)\u2026 "),console.log(B()?"\u2713":"skipped (hooks use npx fallback)")):console.log(" No supported AI CLIs detected yet \u2014 they'll wire automatically once you install one."),console.log(" See Blips in your sessions to earn your weekly compute."),0}async function Ye(){let e=m().devToken;if(!e)return console.error("Not signed in. Run: opencrater login"),1;let o=await W(e,m().installId);return o?(console.log(`Compute balance: ${T(o.balanceMicroUsd)}${$(o)}`),console.log(` signed in as: ${o.displayName} \xB7 tier: ${o.trustTier}`),0):(console.error("Couldn't reach OpenCrater (or your session expired \u2014 try: opencrater login)."),1)}function Xe(){return O({...m(),devToken:null},process.env,{allowClearToken:true}),console.log("Signed out of the OpenCrater compute wallet on this machine."),0}async function Qe(e){let o=m().devToken;if(!o)return console.error("Not signed in. Run: opencrater login"),1;let n=await W(o,m().installId);if(n&&n.balanceMicroUsd<=0)return console.error("Your OpenCrater compute balance is empty \u2014 see Blips to earn more."),console.error("Check anytime with: opencrater balance"),1;let t=`${x().replace(/\/$/,"")}/gateway`,i=f__namespace.join(f__namespace.dirname(A()),"claude-gateway.settings.json");try{p__namespace.mkdirSync(f__namespace.dirname(i),{recursive:!0}),p__namespace.writeFileSync(i,JSON.stringify({apiKeyHelper:`echo ${o}`}),{mode:384});}catch(d){return console.error(`Couldn't write gateway settings: ${d.message}`),1}n&&console.log(`Launching Claude Code on OpenCrater compute \xB7 balance ${T(n.balanceMicroUsd)}${$(n)}`);let r={...process.env,ANTHROPIC_BASE_URL:t,OPENCRATER_ON_GATEWAY:"1"};delete r.ANTHROPIC_API_KEY;let s=child_process.spawn("claude",[...e,"--settings",i],{stdio:"inherit",env:r,shell:process.platform==="win32"});return await new Promise(d=>{s.on("exit",a=>d(a??0)),s.on("error",a=>{console.error(`Couldn't launch claude: ${a.message}`),console.error("Is Claude Code installed? https://claude.com/claude-code"),d(127);});})}async function Ze(e){let o=m().devToken;if(!o)return console.error("Not signed in. Run: opencrater login"),1;let n=await W(o,m().installId);if(n&&n.balanceMicroUsd<=0)return console.error("Your OpenCrater compute balance is empty \u2014 see Blips to earn more."),console.error("Check anytime with: opencrater balance"),1;let t=`${x().replace(/\/$/,"")}/gateway/v1`;n&&console.log(`Launching Codex on OpenCrater compute \xB7 balance ${T(n.balanceMicroUsd)}${$(n)}`);let i={...process.env,OPENCRATER_TOKEN:o,OPENCRATER_ON_GATEWAY:"1"},r=["-c",'model_provider="opencrater"',"-c",'model_providers.opencrater.name="OpenCrater"',"-c",`model_providers.opencrater.base_url="${t}"`,"-c",'model_providers.opencrater.wire_api="responses"',"-c",'model_providers.opencrater.env_key="OPENCRATER_TOKEN"'],s=[];for(let a=0;a<e.length;a++){let c=e[a],l=e[a+1];c==="-c"&&(l===void 0||!l.includes("="))?s.push("resume","--last"):s.push(c);}let d=child_process.spawn("codex",[...r,...s],{stdio:"inherit",env:i,shell:process.platform==="win32"});return await new Promise(a=>{d.on("exit",c=>a(c??0)),d.on("error",c=>{console.error(`Couldn't launch codex: ${c.message}`),console.error("Is Codex installed? npm i -g @openai/codex"),a(127);});})}function en(){let e=process.env.GROK_HOME;return e&&e.trim()!==""?e:f__namespace.join(N__namespace.homedir(),".grok")}function nn(e){let o=f__namespace.join(en(),"config.toml"),n="";try{n=p__namespace.readFileSync(o,"utf8");}catch{}if(/^\s*\[model\.opencrater\]/m.test(n))return;let t=n.length===0?"":n.endsWith(`
13
13
  `)?`
package/dist/hook.js CHANGED
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';var child_process=require('child_process'),h=require('fs'),I=require('os'),b=require('path'),crypto=require('crypto');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var h__namespace=/*#__PURE__*/_interopNamespace(h);var I__namespace=/*#__PURE__*/_interopNamespace(I);var b__namespace=/*#__PURE__*/_interopNamespace(b);var M=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(o,e)=>(typeof require<"u"?require:o)[e]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var B={minIntervalSeconds:600,serveTimeoutMs:2500,preloadPoolSize:3,killSwitch:false,displayDurationSeconds:25,minSdkVersion:""},Te={claude_code:["SessionStart","Stop","SessionEnd","Notification"],codex:["Stop"],openclaw:[],antigravity:["AfterAgent","SessionStart","SessionEnd"],copilot_cli:["agentStop","sessionStart","sessionEnd","notification"],grok_cli:["SessionStart","Stop","SessionEnd","Notification"],generic:["SessionStart","Stop"]},je={claude_code:["SessionStart","Stop","SessionEnd","Notification","UserPromptSubmit","SubagentStart","SubagentStop","StopFailure","PreToolUse","PostToolUse","PostToolUseFailure","PostToolBatch","PermissionRequest","PermissionDenied","UserPromptExpansion","PreCompact","PostCompact","TaskCreated","TaskCompleted","Setup","TeammateIdle","Elicitation","ElicitationResult","ConfigChange","InstructionsLoaded","WorktreeCreate","WorktreeRemove","CwdChanged","FileChanged","MessageDisplay"],codex:["Stop","SessionStart","UserPromptSubmit","PreToolUse","PostToolUse","PermissionRequest","PreCompact","PostCompact"],openclaw:[],antigravity:["AfterAgent","SessionStart","SessionEnd","Notification","BeforeAgent","BeforeModel","AfterModel","BeforeToolSelection","BeforeTool","AfterTool","PreCompress"],copilot_cli:["agentStop","sessionStart","sessionEnd","notification","userPromptSubmitted","preToolUse","postToolUse","permissionRequest","errorOccurred","subagentStart","subagentStop"],grok_cli:["SessionStart","Stop","SessionEnd","Notification"],generic:["SessionStart","Stop"]};var N="1.3.0";var yt="https://api.opencrater.to";function G(t,o=process.env){let e=o.OPENCRATER_API_ORIGIN;return ((e&&e.trim()!==""?e:yt)).replace(/\/+$/,"")}function x(...t){try{if(process.env.OPENCRATER_DEBUG!=="1")return;console.error("[opencrater]",...t);try{let o=M("os"),e=M("fs"),r=M("path");e.appendFileSync(r.join(o.homedir(),".config","opencrater","hook.log"),`${new Date().toISOString()} [opencrater] ${t.map(n=>String(n)).join(" ")}
3
- `);}catch{}}catch{}}function z(t){return typeof t=="number"&&Number.isFinite(t)}function bt(t){let o=B;if(typeof t!="object"||t===null)return {...o};let e=t;return {minIntervalSeconds:z(e.minIntervalSeconds)?e.minIntervalSeconds:o.minIntervalSeconds,serveTimeoutMs:z(e.serveTimeoutMs)?e.serveTimeoutMs:o.serveTimeoutMs,preloadPoolSize:z(e.preloadPoolSize)?e.preloadPoolSize:o.preloadPoolSize,killSwitch:e.killSwitch===true,displayDurationSeconds:z(e.displayDurationSeconds)?e.displayDurationSeconds:o.displayDurationSeconds,minSdkVersion:typeof e.minSdkVersion=="string"?e.minSdkVersion:o.minSdkVersion}}async function Re(t,o,e,r,n){try{let c=await fetch(`${t}${o}`,{method:"POST",headers:{"content-type":"application/json",...n??{}},body:JSON.stringify(e),signal:AbortSignal.timeout(r)});return c.ok?await c.json():(x(`POST ${o} -> HTTP ${c.status}`),null)}catch(c){return x(`POST ${o} failed:`,c),null}}function Ee(t,o){let e=t.host??"generic";return {publisherKey:t.publisherKey,packageName:t.packageName,placement:t.placement,host:e,sdkVersion:N,installId:o.installId,os:process.platform,termProgram:process.env.TERM_PROGRAM??void 0,topics:o.topics&&o.topics.length>0?o.topics:void 0,tags:o.tags&&o.tags.length>0?o.tags:void 0}}function _e(t){if(typeof t!="object"||t===null)return null;let o=t;if(typeof o.fill!="boolean")return null;let e={fill:o.fill,fallback:o.fallback??null,config:bt(o.config),...Array.isArray(o.allowedPlacements)?{allowedPlacements:o.allowedPlacements.filter(r=>typeof r=="string")}:{}};return o.blip!==void 0&&o.blip!==null&&(e.blip=o.blip),typeof o.computeBalanceMicroUsd=="number"&&(e.computeBalanceMicroUsd=o.computeBalanceMicroUsd),typeof o.weeklyGrantMicroUsd=="number"&&(e.weeklyGrantMicroUsd=o.weeklyGrantMicroUsd),typeof o.pendingMicroUsd=="number"&&(e.pendingMicroUsd=o.pendingMicroUsd),e}async function Oe(t,o){let e=await Re(o.origin,"/v1/serve",Ee(t,o),o.timeoutMs);return _e(e)}async function Ae(t,o,e){let r={...Ee(o,e),publisherKey:o.publisherKey??"",packageName:o.packageName??""},n=await Re(e.origin,"/v1/dev/serve",r,e.timeoutMs,{authorization:`Bearer ${t}`});return _e(n)}var wt=48,J=360*60*1e3;function Pe(t){return crypto.createHash("sha256").update(t).digest("hex").slice(0,16)}function Ie(t){let o=new Set,e=s=>{o.size<wt&&o.add(s);},r=[];try{r=h__namespace.readdirSync(t);}catch{return []}let n=s=>r.includes(s),c=s=>{try{return h__namespace.readFileSync(b__namespace.join(t,s),"utf8")}catch{return ""}},f=s=>{try{return JSON.parse(c(s))}catch{return null}},u=f("package.json")??{},d={...u.dependencies??{},...u.devDependencies??{},...u.peerDependencies??{}},a=s=>Object.prototype.hasOwnProperty.call(d,s),p=s=>Object.keys(d).some(i=>i===s||i.startsWith(s));n("package.json")&&(e("lang:javascript"),(a("typescript")||n("tsconfig.json"))&&e("lang:typescript")),(n("deno.json")||n("deno.jsonc"))&&e("lang:typescript"),(n("tsconfig.json")||n("tsconfig.base.json"))&&e("lang:typescript"),n("jsconfig.json")&&e("lang:javascript"),(n("bun.lockb")||n("bun.lock"))&&e("lang:javascript"),r.some(s=>s.endsWith(".ts")||s.endsWith(".tsx")||s.endsWith(".mts")||s.endsWith(".cts"))&&e("lang:typescript"),r.some(s=>s.endsWith(".js")||s.endsWith(".jsx")||s.endsWith(".mjs")||s.endsWith(".cjs"))&&e("lang:javascript"),(n("requirements.txt")||n("pyproject.toml")||n("setup.py")||n("Pipfile"))&&e("lang:python"),(n("setup.cfg")||n("Pipfile.lock")||n("poetry.lock")||n("uv.lock")||n("environment.yml"))&&e("lang:python"),r.some(s=>s.endsWith(".py")||s.endsWith(".pyi")||s.endsWith(".ipynb"))&&e("lang:python"),(n("go.mod")||n("go.sum")||n("go.work"))&&e("lang:go"),r.some(s=>s.endsWith(".go"))&&e("lang:go"),(n("Cargo.toml")||n("Cargo.lock"))&&e("lang:rust"),r.some(s=>s.endsWith(".rs"))&&e("lang:rust"),(n("pom.xml")||n("build.gradle"))&&e("lang:java"),r.some(s=>s.endsWith(".java"))&&e("lang:java"),(n("build.gradle.kts")||n("settings.gradle.kts"))&&e("lang:kotlin"),r.some(s=>s.endsWith(".kt")||s.endsWith(".kts"))&&e("lang:kotlin"),(n("build.sbt")||n(".scalafmt.conf"))&&e("lang:scala"),r.some(s=>s.endsWith(".scala")||s.endsWith(".sc"))&&e("lang:scala"),r.some(s=>s.endsWith(".groovy")||s.endsWith(".gradle"))&&e("lang:groovy"),(n("deps.edn")||n("project.clj")||n("shadow-cljs.edn"))&&e("lang:clojure"),r.some(s=>s.endsWith(".clj")||s.endsWith(".cljs")||s.endsWith(".cljc"))&&e("lang:clojure"),r.some(s=>s.endsWith(".csproj")||s.endsWith(".sln"))&&e("lang:csharp"),r.some(s=>s.endsWith(".fsproj"))&&e("lang:fsharp"),r.some(s=>s.endsWith(".cs"))&&e("lang:csharp"),r.some(s=>s.endsWith(".fs")||s.endsWith(".fsx")||s.endsWith(".fsi"))&&e("lang:fsharp"),r.some(s=>s.endsWith(".cpp")||s.endsWith(".cc")||s.endsWith(".cxx")||s.endsWith(".hpp")||s.endsWith(".hxx"))&&e("lang:cpp"),r.some(s=>s.endsWith(".c"))&&e("lang:c"),(n("composer.json")||n("composer.lock"))&&e("lang:php"),r.some(s=>s.endsWith(".php"))&&e("lang:php"),(n("Gemfile")||n("Gemfile.lock")||n(".ruby-version")||r.some(s=>s.endsWith(".gemspec")))&&e("lang:ruby"),r.some(s=>s.endsWith(".rb")||s==="Rakefile")&&e("lang:ruby"),(n("Package.swift")||n("Podfile")||r.some(s=>s.endsWith(".xcodeproj")||s.endsWith(".xcworkspace")))&&e("lang:swift"),r.some(s=>s.endsWith(".swift"))&&e("lang:swift"),r.some(s=>s.endsWith(".m")||s.endsWith(".mm"))&&e("lang:objective-c"),(n("pubspec.yaml")||n("pubspec.yml")||n("pubspec.lock"))&&e("lang:dart"),r.some(s=>s.endsWith(".dart"))&&e("lang:dart"),(n("mix.exs")||n("mix.lock"))&&e("lang:elixir"),r.some(s=>s.endsWith(".ex")||s.endsWith(".exs"))&&e("lang:elixir"),(n("rebar.config")||n("rebar.lock"))&&e("lang:erlang"),r.some(s=>s.endsWith(".erl")||s.endsWith(".hrl"))&&e("lang:erlang"),(n("gleam.toml")||r.some(s=>s.endsWith(".gleam")))&&e("lang:gleam"),(n("stack.yaml")||n("cabal.project")||r.some(s=>s.endsWith(".cabal")||s.endsWith(".hs")))&&e("lang:haskell"),(n("dune-project")||n("dune")||r.some(s=>s.endsWith(".ml")||s.endsWith(".mli")))&&e("lang:ocaml"),(r.some(s=>s.endsWith(".rockspec")||s.endsWith(".lua"))||n(".luarc.json"))&&e("lang:lua"),(n("cpanfile")||n("Makefile.PL")||r.some(s=>s.endsWith(".pl")||s.endsWith(".pm")))&&e("lang:perl"),(n("DESCRIPTION")||n("renv.lock")||r.some(s=>s.endsWith(".Rproj")||s.endsWith(".Rmd")||s.endsWith(".R")))&&e("lang:r"),(n("Project.toml")||n("Manifest.toml")||r.some(s=>s.endsWith(".jl")))&&e("lang:julia"),(n("build.zig")||n("build.zig.zon")||r.some(s=>s.endsWith(".zig")))&&e("lang:zig"),r.some(s=>s.endsWith(".nimble")||s.endsWith(".nim"))&&e("lang:nim"),(n("shard.yml")||n("shard.lock")||r.some(s=>s.endsWith(".cr")))&&e("lang:crystal"),(n("v.mod")||r.some(s=>s.endsWith(".vsh")))&&e("lang:vlang"),r.some(s=>s.endsWith(".hx")||s.endsWith(".hxml"))&&e("lang:haxe"),(n("foundry.toml")||n("hardhat.config.js")||n("hardhat.config.ts")||r.some(s=>s.endsWith(".sol")))&&e("lang:solidity"),r.some(s=>s.endsWith(".f")||s.endsWith(".f90")||s.endsWith(".f95"))&&e("lang:fortran"),r.some(s=>s.endsWith(".cob")||s.endsWith(".cbl"))&&e("lang:cobol"),r.some(s=>s.endsWith(".asm"))&&e("lang:assembly"),r.some(s=>s.endsWith(".sh")||s.endsWith(".bash")||s.endsWith(".zsh"))&&e("lang:shell"),r.some(s=>s.endsWith(".ps1")||s.endsWith(".psm1"))&&e("lang:powershell"),r.some(s=>s.endsWith(".sql"))&&e("lang:sql"),r.some(s=>s.endsWith(".html")||s.endsWith(".htm"))&&e("lang:html"),r.some(s=>s.endsWith(".css"))&&e("lang:css"),r.some(s=>s.endsWith(".scss")||s.endsWith(".sass"))&&e("lang:scss"),r.some(s=>s.endsWith(".graphql")||s.endsWith(".gql"))&&e("lang:graphql"),r.some(s=>s.endsWith(".proto"))&&e("lang:protobuf");{if(a("react")&&e("fw:react"),a("next")&&e("fw:nextjs"),a("vue")&&e("fw:vue"),(a("nuxt")||a("nuxt3"))&&e("fw:nuxt"),a("@angular/core")&&e("fw:angular"),a("svelte")&&e("fw:svelte"),a("@sveltejs/kit")&&e("fw:sveltekit"),(a("@remix-run/react")||a("@remix-run/node"))&&e("fw:remix"),a("astro")&&e("fw:astro"),a("gatsby")&&e("fw:gatsby"),a("solid-js")&&e("fw:solid"),(a("@solidjs/start")||a("solid-start"))&&e("fw:solidstart"),(a("@builder.io/qwik")||a("@qwik.dev/core"))&&e("fw:qwik"),a("preact")&&e("fw:preact"),(a("lit")||a("lit-element"))&&e("fw:lit"),(a("ember-source")||a("ember-cli"))&&e("fw:ember"),a("htmx.org")&&e("fw:htmx"),a("vite")&&e("fw:vite"),a("webpack")&&e("fw:webpack"),a("express")&&e("fw:express"),a("fastify")&&e("fw:fastify"),a("@nestjs/core")&&e("fw:nestjs"),a("koa")&&e("fw:koa"),a("hono")&&e("fw:hono"),(a("@hapi/hapi")||a("hapi"))&&e("fw:hapi"),a("@adonisjs/core")&&e("fw:adonis"),(a("@trpc/server")||a("@trpc/client"))&&e("fw:trpc"),a("sails")&&e("fw:sails"),a("electron")&&e("fw:electron"),a("react-native")&&e("fw:react-native"),a("expo")&&e("fw:expo"),p("@ionic/")&&e("fw:ionic"),a("@capacitor/core")&&e("fw:capacitor"),n("requirements.txt")||n("pyproject.toml")||n("setup.py")||n("Pipfile")){let i=(c("requirements.txt")+c("pyproject.toml")+c("Pipfile")+c("setup.py")).toLowerCase();i.includes("fastapi")&&e("fw:fastapi"),i.includes("django")&&e("fw:django"),i.includes("flask")&&e("fw:flask"),i.includes("litestar")&&e("fw:litestar"),i.includes("starlette")&&e("fw:starlette"),i.includes("tornado")&&e("fw:tornado"),i.includes("sanic")&&e("fw:sanic"),i.includes("aiohttp")&&e("fw:aiohttp"),i.includes("pyramid")&&e("fw:pyramid"),i.includes("fasthtml")&&e("fw:fasthtml"),(i.includes("torch")||i.includes("pytorch"))&&e("fw:pytorch"),i.includes("tensorflow")&&e("fw:tensorflow"),(i.includes("jax")||i.includes("jaxlib"))&&e("fw:jax"),i.includes("keras")&&e("fw:keras"),(i.includes("scikit-learn")||i.includes("sklearn"))&&e("fw:scikit-learn"),i.includes("transformers")&&e("fw:transformers"),i.includes("langchain")&&e("fw:langchain"),(i.includes("llama-index")||i.includes("llama_index")||i.includes("llamaindex"))&&e("fw:llamaindex"),i.includes("pandas")&&e("fw:pandas"),i.includes("numpy")&&e("fw:numpy"),i.includes("streamlit")&&e("fw:streamlit"),i.includes("gradio")&&e("fw:gradio"),i.includes("fastai")&&e("fw:fastai");}if(n("go.mod")){let i=c("go.mod").toLowerCase();i.includes("gin-gonic/gin")&&e("fw:gin"),i.includes("labstack/echo")&&e("fw:echo"),i.includes("gofiber/fiber")&&e("fw:fiber"),i.includes("go-chi/chi")&&e("fw:chi"),(i.includes("gorilla/mux")||i.includes("gorilla/websocket"))&&e("fw:gorilla"),(i.includes("beego/beego")||i.includes("astaxie/beego"))&&e("fw:beego"),i.includes("gobuffalo/buffalo")&&e("fw:buffalo");}if(n("Cargo.toml")){let i=c("Cargo.toml").toLowerCase();i.includes("actix-web")&&e("fw:actix"),i.includes("axum")&&e("fw:axum"),i.includes("rocket")&&e("fw:rocket"),i.includes("warp")&&e("fw:warp"),i.includes("tonic")&&e("fw:tonic"),i.includes("leptos")&&e("fw:leptos"),i.includes("yew")&&e("fw:yew"),i.includes("tauri")&&e("fw:tauri"),i.includes("dioxus")&&e("fw:dioxus"),i.includes("bevy")&&e("fw:bevy");}if(n("pom.xml")||n("build.gradle")||n("build.gradle.kts")){let i=(c("pom.xml")+c("build.gradle")+c("build.gradle.kts")).toLowerCase();(i.includes("spring-boot")||i.includes("springframework"))&&e("fw:spring"),i.includes("quarkus")&&e("fw:quarkus"),i.includes("micronaut")&&e("fw:micronaut"),(i.includes("io.ktor")||i.includes("ktor-"))&&e("fw:ktor"),(i.includes("vertx")||i.includes("vert.x"))&&e("fw:vertx"),(i.includes("com.android")||i.includes("androidx"))&&e("fw:android"),(i.includes("androidx.compose")||i.includes("jetpack"))&&e("fw:jetpack-compose"),(i.includes("kotlin-multiplatform")||i.includes('kotlin("multiplatform")'))&&e("fw:kotlin-multiplatform");}if(n("Gemfile")){let i=c("Gemfile").toLowerCase();i.includes("rails")&&e("fw:rails"),i.includes("sinatra")&&e("fw:sinatra"),i.includes("hanami")&&e("fw:hanami");}if(n("composer.json")){let i=c("composer.json").toLowerCase();(i.includes("laravel/framework")||i.includes("laravel/laravel"))&&e("fw:laravel"),i.includes("symfony/")&&e("fw:symfony"),i.includes("drupal/")&&e("fw:drupal"),i.includes("codeigniter")&&e("fw:codeigniter"),i.includes("slim/slim")&&e("fw:slim");}(n("wp-config.php")||n("wp-load.php")||n("wp-content"))&&e("fw:wordpress"),n("pubspec.yaml")&&c("pubspec.yaml").toLowerCase().includes("flutter")&&e("fw:flutter");{let i=r.filter(y=>y.endsWith(".csproj"));if(i.length>0){let y=i.map(g=>c(g)).join(`
4
- `).toLowerCase();(y.includes("microsoft.net.sdk.web")||y.includes("microsoft.aspnetcore"))&&e("fw:aspnet"),y.includes("blazor")&&e("fw:blazor"),(y.includes("microsoft.net.sdk.maui")||y.includes("usemaui"))&&e("fw:maui");}}(n("ProjectSettings")||r.includes("Assembly-CSharp.csproj"))&&e("fw:unity"),n("project.godot")&&e("fw:godot");{let i=c("Package.swift").toLowerCase();i.includes("swiftui")&&e("fw:swiftui"),i.includes("uikit")&&e("fw:uikit");}let s=i=>r.some(y=>y===i||y.startsWith(i+"."));s("next.config")&&e("fw:nextjs"),s("nuxt.config")&&e("fw:nuxt"),s("astro.config")&&e("fw:astro"),s("svelte.config")&&e("fw:svelte"),s("remix.config")&&e("fw:remix"),s("gatsby-config")&&e("fw:gatsby"),s("vite.config")&&e("fw:vite"),s("vue.config")&&e("fw:vue"),s("qwik.config")&&e("fw:qwik"),n("angular.json")&&e("fw:angular"),s("capacitor.config")&&e("fw:capacitor"),s("ionic.config")&&e("fw:ionic"),n("app.json")&&c("app.json").toLowerCase().includes('"expo"')&&e("fw:expo");}{if((a("pg")||a("postgres")||a("pg-promise")||a("@vercel/postgres"))&&e("infra:postgres"),(a("mysql")||a("mysql2"))&&e("infra:mysql"),a("mariadb")&&e("infra:mariadb"),(a("redis")||a("ioredis"))&&e("infra:redis"),(a("mongodb")||a("mongoose"))&&e("infra:mongodb"),a("mongoose")&&e("infra:mongoose"),(a("better-sqlite3")||a("sqlite3")||a("sqlite"))&&e("infra:sqlite"),a("@libsql/client")&&e("infra:libsql"),a("cassandra-driver")&&e("infra:cassandra"),(a("@elastic/elasticsearch")||a("elasticsearch"))&&e("infra:elasticsearch"),a("@opensearch-project/opensearch")&&e("infra:opensearch"),(a("@clickhouse/client")||a("clickhouse"))&&e("infra:clickhouse"),(a("duckdb")||a("@duckdb/node-api"))&&e("infra:duckdb"),a("neo4j-driver")&&e("infra:neo4j"),a("@influxdata/influxdb-client")&&e("infra:influxdb"),a("snowflake-sdk")&&e("infra:snowflake"),a("@google-cloud/bigquery")&&e("infra:bigquery"),(a("firebase-admin")||a("@google-cloud/firestore"))&&e("infra:firestore"),(a("faunadb")||a("fauna"))&&e("infra:fauna"),(a("surrealdb")||a("surrealdb.js"))&&e("infra:surrealdb"),a("@qdrant/js-client-rest")&&e("infra:qdrant"),a("@pinecone-database/pinecone")&&e("infra:pinecone"),(a("weaviate-ts-client")||a("weaviate-client"))&&e("infra:weaviate"),a("chromadb")&&e("infra:chromadb"),a("@zilliz/milvus2-sdk-node")&&e("infra:milvus"),(a("@prisma/client")||a("prisma"))&&e("infra:prisma"),a("drizzle-orm")&&e("infra:drizzle"),a("typeorm")&&e("infra:typeorm"),(a("aws-sdk")||p("@aws-sdk/"))&&e("infra:aws"),(p("@google-cloud/")||a("googleapis"))&&e("infra:gcp"),p("@azure/")&&e("infra:azure"),(p("@cloudflare/")||a("wrangler"))&&e("infra:cloudflare"),(a("@vercel/node")||a("@vercel/kv")||a("@vercel/blob"))&&e("infra:vercel"),(a("firebase")||a("firebase-admin"))&&e("infra:firebase"),a("@supabase/supabase-js")&&e("infra:supabase"),a("@neondatabase/serverless")&&e("infra:neon"),a("@planetscale/database")&&e("infra:planetscale"),p("@upstash/")&&e("infra:upstash"),a("@tursodatabase/api")&&e("infra:turso"),a("modal")&&e("infra:modal"),a("replicate")&&e("infra:replicate"),(a("kafkajs")||a("node-rdkafka"))&&e("infra:kafka"),(a("amqplib")||a("rabbitmq-client"))&&e("infra:rabbitmq"),a("nats")&&e("infra:nats"),(p("@aws-sdk/client-sqs")||a("sqs-consumer"))&&e("infra:sqs"),a("@google-cloud/pubsub")&&e("infra:pubsub"),p("@temporalio/")&&e("infra:temporal"),(a("bullmq")||a("bull"))&&e("infra:bullmq"),p("@sentry/")&&e("infra:sentry"),(p("@datadog/")||a("dd-trace"))&&e("infra:datadog"),p("@opentelemetry/")&&e("infra:opentelemetry"),a("newrelic")&&e("infra:newrelic"),(a("posthog-node")||a("posthog-js"))&&e("infra:posthog"),p("@honeycombio/")&&e("infra:honeycomb"),a("prom-client")&&e("infra:prometheus"),(a("stripe")||a("@stripe/stripe-js"))&&e("infra:stripe"),p("@paddle/")&&e("infra:paddle"),p("@clerk/")&&e("infra:clerk"),(a("auth0")||p("@auth0/"))&&e("infra:auth0"),(a("next-auth")||p("@auth/"))&&e("infra:nextauth"),a("twilio")&&e("infra:twilio"),a("@sendgrid/mail")&&e("infra:sendgrid"),a("resend")&&e("infra:resend"),a("postmark")&&e("infra:postmark"),p("@pulumi/")&&e("infra:pulumi"),n("requirements.txt")||n("pyproject.toml")||n("setup.py")||n("Pipfile")){let i=(c("requirements.txt")+c("pyproject.toml")+c("Pipfile")+c("setup.py")).toLowerCase();(i.includes("psycopg")||i.includes("asyncpg"))&&e("infra:postgres"),(i.includes("pymysql")||i.includes("aiomysql")||i.includes("mysqlclient"))&&e("infra:mysql"),(i.includes("redis")||i.includes("aioredis"))&&e("infra:redis"),(i.includes("pymongo")||i.includes("motor")||i.includes("mongoengine"))&&e("infra:mongodb"),i.includes("elasticsearch")&&e("infra:elasticsearch"),i.includes("clickhouse")&&e("infra:clickhouse"),i.includes("duckdb")&&e("infra:duckdb"),i.includes("neo4j")&&e("infra:neo4j"),i.includes("snowflake")&&e("infra:snowflake"),i.includes("qdrant-client")&&e("infra:qdrant"),i.includes("pinecone")&&e("infra:pinecone"),i.includes("chromadb")&&e("infra:chromadb"),i.includes("pymilvus")&&e("infra:milvus"),i.includes("sqlalchemy")&&e("infra:sqlalchemy"),(i.includes("boto3")||i.includes("botocore"))&&e("infra:aws"),i.includes("google-cloud")&&e("infra:gcp"),i.includes("azure-")&&e("infra:azure"),i.includes("supabase")&&e("infra:supabase"),(i.includes("confluent-kafka")||i.includes("aiokafka")||i.includes("kafka-python"))&&e("infra:kafka"),(i.includes("pika")||i.includes("aio-pika"))&&e("infra:rabbitmq"),i.includes("temporalio")&&e("infra:temporal"),i.includes("sentry-sdk")&&e("infra:sentry"),(i.includes("ddtrace")||i.includes("datadog"))&&e("infra:datadog"),i.includes("opentelemetry")&&e("infra:opentelemetry"),i.includes("stripe")&&e("infra:stripe"),i.includes("twilio")&&e("infra:twilio"),i.includes("pulumi")&&e("infra:pulumi"),i.includes("ansible")&&e("infra:ansible");}if(n("go.mod")){let i=c("go.mod").toLowerCase();(i.includes("lib/pq")||i.includes("jackc/pgx"))&&e("infra:postgres"),i.includes("go-sql-driver/mysql")&&e("infra:mysql"),(i.includes("go-redis")||i.includes("redis/go-redis"))&&e("infra:redis"),i.includes("go.mongodb.org/mongo-driver")&&e("infra:mongodb"),i.includes("aws/aws-sdk-go")&&e("infra:aws"),i.includes("cloud.google.com/go")&&e("infra:gcp"),(i.includes("segmentio/kafka-go")||i.includes("sarama"))&&e("infra:kafka"),i.includes("getsentry/sentry-go")&&e("infra:sentry"),i.includes("go.opentelemetry.io")&&e("infra:opentelemetry"),i.includes("stripe/stripe-go")&&e("infra:stripe"),i.includes("hashicorp/terraform")&&e("infra:terraform"),i.includes("k8s.io/client-go")&&e("infra:kubernetes");}(n("Dockerfile")||n("docker-compose.yml")||n("docker-compose.yaml")||n("compose.yaml")||n("compose.yml")||n(".dockerignore"))&&e("infra:docker"),(n("Containerfile")||n("podman-compose.yml"))&&e("infra:podman"),r.some(i=>i.endsWith(".tf")||i===".terraform.lock.hcl")&&e("infra:terraform"),(n("Pulumi.yaml")||n("Pulumi.yml"))&&e("infra:pulumi"),(n("ansible.cfg")||n("playbook.yml")||n("playbook.yaml"))&&e("infra:ansible"),(n("kustomization.yaml")||n("kustomization.yml")||n("k8s")||n("kubernetes")||n("skaffold.yaml"))&&e("infra:kubernetes"),(n("Chart.yaml")||n("helmfile.yaml"))&&(e("infra:helm"),e("infra:kubernetes")),r.some(i=>i.endsWith(".nomad")||i.endsWith(".nomad.hcl"))&&e("infra:nomad"),(n("vercel.json")||n(".vercel"))&&e("infra:vercel"),(n("netlify.toml")||n(".netlify"))&&e("infra:netlify"),n("fly.toml")&&e("infra:fly"),(n("railway.json")||n("railway.toml"))&&e("infra:railway"),n("render.yaml")&&e("infra:render"),n("Procfile")&&e("infra:heroku"),(n("wrangler.toml")||n("wrangler.jsonc")||n("wrangler.json"))&&e("infra:cloudflare"),n("supabase")&&e("infra:supabase"),(n("firebase.json")||n(".firebaserc"))&&e("infra:firebase"),(n("serverless.yml")||n("serverless.yaml")||n("template.yaml")||n("samconfig.toml"))&&e("infra:aws"),(n("prisma")||n("schema.prisma"))&&e("infra:prisma"),(n("drizzle.config.ts")||n("drizzle.config.js"))&&e("infra:drizzle");let s=false;try{s=n(".github")&&h__namespace.existsSync(b__namespace.join(t,".github","workflows"));}catch{s=false;}s&&e("infra:github-actions"),(n(".gitlab-ci.yml")||n(".gitlab-ci.yaml"))&&e("infra:gitlab-ci"),n(".circleci")&&e("infra:circleci"),n("Jenkinsfile")&&e("infra:jenkins");{let i=(c("Dockerfile")+c("docker-compose.yml")+c("docker-compose.yaml")+c("compose.yaml")+c("compose.yml")).toLowerCase();i&&((i.includes("postgres")||i.includes("pgvector"))&&e("infra:postgres"),i.includes("timescale")&&e("infra:timescaledb"),i.includes("mysql")&&e("infra:mysql"),i.includes("mariadb")&&e("infra:mariadb"),i.includes("redis")&&e("infra:redis"),i.includes("mongo")&&e("infra:mongodb"),i.includes("cassandra")&&e("infra:cassandra"),i.includes("cockroach")&&e("infra:cockroachdb"),i.includes("clickhouse")&&e("infra:clickhouse"),i.includes("elasticsearch")&&e("infra:elasticsearch"),i.includes("neo4j")&&e("infra:neo4j"),i.includes("qdrant")&&e("infra:qdrant"),i.includes("rabbitmq")&&e("infra:rabbitmq"),(i.includes("kafka")||i.includes("redpanda"))&&e("infra:kafka"),i.includes("nats")&&e("infra:nats"),i.includes("grafana")&&e("infra:grafana"),(i.includes("prometheus")||i.includes("prom/"))&&e("infra:prometheus"));}}{let i=(...w)=>w.some(a),y=(c("requirements.txt")+c("pyproject.toml")+c("Pipfile")+c("setup.py")+c("environment.yml")).toLowerCase(),g=c("go.mod").toLowerCase(),m=c("Cargo.toml").toLowerCase(),l=w=>y.includes(w),A=w=>r.some(ae=>ae.toLowerCase().endsWith(w)),k=(...w)=>w.some(ae=>n(ae)),j=()=>Array.from(o).some(w=>w.startsWith("type:")),se=()=>Array.from(o).some(w=>w.startsWith("fw:"));(a("@modelcontextprotocol/sdk")||l("modelcontextprotocol")||l("fastmcp")||g.includes("modelcontextprotocol")||k("mcp.json",".mcp.json"))&&e("type:mcp-server"),(i("langgraph","@langchain/langgraph","crewai","autogen","@mastra/core","@openai/agents","@langchain/core")||l("langgraph")||l("crewai")||l("autogen")||l("pyautogen")||l("smolagents")||l("haystack"))&&e("type:agent-framework"),(i("ai","openai","@anthropic-ai/sdk","@google/generative-ai","@ai-sdk/openai","@ai-sdk/anthropic","langchain","@huggingface/inference","cohere-ai","ollama","groq-sdk","@mistralai/mistralai")||l("openai")||l("anthropic")||l("langchain")||l("litellm")||l("google-generativeai")||l("cohere")||l("ollama"))&&e("type:ai-app"),(A(".sol")||k("hardhat.config.js","hardhat.config.ts","foundry.toml","truffle-config.js","Anchor.toml","Move.toml")||i("hardhat","ethers","web3","@solana/web3.js","wagmi","viem","@openzeppelin/contracts"))&&e("type:smart-contract"),(k("project.godot","ProjectSettings")||A(".unity")||A(".uproject")||i("phaser","kaplay","kaboom","excalibur","playcanvas")||m.includes("bevy")||m.includes("macroquad")||m.includes("ggez")||l("pygame")||l("arcade"))&&e("type:game");{let w=f("manifest.json");(w&&Object.prototype.hasOwnProperty.call(w,"manifest_version")||i("webextension-polyfill","@types/chrome","wxt","plasmo"))&&e("type:browser-extension");}(i("react-native","expo","nativescript")||n("pubspec.yaml")||A(".xcodeproj")||k("AndroidManifest.xml"))&&e("type:mobile-app"),(i("electron","@tauri-apps/api","@tauri-apps/cli","nw")||k("tauri.conf.json","src-tauri")||m.includes("tauri")||m.includes("egui")||l("pyqt5")||l("pyqt6")||l("pyside6")||l("kivy"))&&e("type:desktop-app"),(i("discord.js","telegraf","node-telegram-bot-api","@slack/bolt","probot","grammy")||l("discord.py")||l("python-telegram-bot")||l("slack-bolt")||l("slack_bolt")||l("aiogram")||l("pyrogram"))&&e("type:bot"),(k("dbt_project.yml","dagster.yaml")||i("@dagster-io/dagster","apache-airflow")||l("airflow")||l("dagster")||l("prefect")||l("dbt-core")||l("luigi")||l("kedro")||l("pyspark")||l("apache-beam"))&&e("type:data-pipeline"),(l("torch")||l("tensorflow")||l("keras")||l("jax")||l("scikit-learn")||l("sklearn")||l("xgboost")||l("lightgbm")||l("pytorch-lightning")||l("diffusers")||l("mlflow"))&&e("type:ml-model"),(A(".ipynb")||l("jupyter")||l("jupyterlab")||l("marimo")||n("notebooks"))&&e("type:notebook"),(k("mkdocs.yml","mkdocs.yaml","mint.json","docusaurus.config.js","docusaurus.config.ts","book.toml")||i("@docusaurus/core","vitepress","vuepress","nextra","@astrojs/starlight")||l("mkdocs")||l("sphinx"))&&e("type:documentation"),(k("hugo.toml","_config.yml",".eleventy.js","eleventy.config.js","astro.config.mjs","astro.config.ts","astro.config.js")||i("astro","gatsby","@11ty/eleventy","hexo","gridsome")||l("pelican"))&&e("type:static-site"),i("@medusajs/medusa","@saleor/sdk","@shopify/hydrogen","vendure","@vendure/core","snipcart","use-shopping-cart","swell-js")&&e("type:ecommerce"),(u.bin||i("commander","yargs","oclif","@oclif/core","cac","meow","inquirer","@clack/prompts","ink")||l("click")||l("typer")||l("docopt")||g.includes("spf13/cobra")||g.includes("urfave/cli")||m.includes("clap")||m.includes("structopt"))&&e("type:cli"),(k("pnpm-workspace.yaml","turbo.json","nx.json","lerna.json","rush.json")||Array.isArray(u.workspaces)||m.includes("[workspace]")||n("go.work"))&&e("type:monorepo");let T=i("next","react","vue","@angular/core","svelte","@sveltejs/kit","solid-js","nuxt","remix","@remix-run/react","preact","qwik"),R=i("express","fastify","@nestjs/core","koa","hapi","@hapi/hapi","hono")||l("fastapi")||l("django")||l("flask")||l("starlette")||l("sanic")||g.includes("gin-gonic/gin")||g.includes("labstack/echo")||g.includes("gofiber/fiber")||m.includes("axum")||m.includes("actix-web")||(c("pom.xml")+c("build.gradle")).toLowerCase().includes("spring-boot"),ve=Array.from(o).some(w=>["infra:postgres","infra:mysql","infra:mongodb","infra:supabase","infra:neon"].includes(w)),xe=i("next-auth","@clerk/nextjs","@auth0/auth0-react","passport","lucia","@workos-inc/node")||l("django-allauth")||l("flask-login"),Ce=i("stripe","@stripe/stripe-js","@paddle/paddle-js","@lemonsqueezy/lemonsqueezy.js")||l("stripe");(!T&&!R&&(u.main||u.exports||u.module||u.types||u.publishConfig)||n("Cargo.toml")&&!m.includes("[[bin]]")&&m.includes("[lib]")||k("LICENSE","LICENSE.md","LICENSE.txt")&&!T&&!R&&!j())&&!j()&&e("type:library"),T?(ve&&(xe||Ce)&&e("type:saas"),e("type:web-app")):R&&(ve&&(xe||Ce)&&e("type:saas"),e("type:api-service")),j()||(se()?e("type:web-app"):k("Dockerfile","docker-compose.yml","compose.yaml")||r.some(w=>w.endsWith(".tf"))||k("Chart.yaml","kustomization.yaml","wrangler.toml","serverless.yml",".github")||i("@pulumi/pulumi","aws-cdk-lib","cdktf")?e("type:devops-tool"):n("package.json")&&(u.main||u.exports)&&e("type:library"));}return Array.from(o)}function Ne(t){let o={sponsorLabel:t.sponsorLabel,title:t.creative.title,body:t.creative.body,url:t.clickUrl};return t.creative.cta!==void 0&&(o.cta=t.creative.cta),o}function $e(t){return {sponsorLabel:"",title:t.title,body:t.body,url:t.url}}function K(t){let o=Ne(t),e=t.creative;switch(e.format){case "image":case "gif":return {...o,body:e.textFallback??o.body};case "video":return {...o,body:e.textFallback??o.body,cta:o.cta??"\u25B6 Watch"};case "audio":return {...o,body:e.textFallback??o.body,cta:o.cta??"\u{1F50A} Listen"};default:return o}}function H(t=process.env){return b__namespace.join(I__namespace.homedir(),".config","opencrater")}function V(t=process.env){return b__namespace.join(H(t),"state.json")}function Y(){return {installId:crypto.randomUUID(),lastShownAt:0,optOut:false,disclosureShown:false,cachedConfig:null,configFetchedAt:0,pool:[],allowedPlacements:{},sessionTopics:[],integrations:[],devToken:null,computeRouting:null,computeCards:null}}function E(t){return typeof t=="number"&&Number.isFinite(t)}var Le=new Set(["EPERM","EACCES","EBUSY","EEXIST"]);function De(t){for(let o=0;;o++)try{return {text:h__namespace.readFileSync(t,"utf8")}}catch(e){let r=e.code??"";if(!(r==="ENOENT"||Le.has(r)))return {locked:true};if(o>=4)return r==="ENOENT"?{missing:true}:{locked:true};try{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,15*(o+1));}catch{}}}function vt(t){if(typeof t!="object"||t===null)return null;let o=t;return !E(o.minIntervalSeconds)||!E(o.serveTimeoutMs)||!E(o.preloadPoolSize)||typeof o.killSwitch!="boolean"?null:{minIntervalSeconds:o.minIntervalSeconds,serveTimeoutMs:o.serveTimeoutMs,preloadPoolSize:o.preloadPoolSize,killSwitch:o.killSwitch,displayDurationSeconds:E(o.displayDurationSeconds)?o.displayDurationSeconds:25,minSdkVersion:typeof o.minSdkVersion=="string"?o.minSdkVersion:""}}function xt(t){if(!Array.isArray(t))return [];let o=[];for(let e of t){if(typeof e!="object"||e===null)continue;let r=e,n=r.blip;if(!E(r.renderBy)||typeof n!="object"||n===null||typeof n.impressionId!="string"||typeof n.clickUrl!="string"||typeof n.sponsorLabel!="string"||typeof n.creative!="object"||n.creative===null)continue;let c=n.creative;typeof c.title!="string"||typeof c.body!="string"||o.push({blip:{impressionId:n.impressionId,...typeof n.campaignId=="string"?{campaignId:n.campaignId}:{},clickUrl:n.clickUrl,sponsorLabel:n.sponsorLabel,creative:{format:"text",title:c.title,body:c.body,...typeof c.cta=="string"?{cta:c.cta}:{}}},renderBy:r.renderBy});}return o}function Ct(t){if(typeof t!="object"||t===null||Array.isArray(t))return {};let o={};for(let[e,r]of Object.entries(t)){if(!Array.isArray(r))continue;let n=r.filter(c=>typeof c=="string"&&c.length<=64);o[e]=n.slice(0,64);}return o}function Tt(t){if(!Array.isArray(t))return [];let o=[];for(let e of t){if(typeof e!="object"||e===null)continue;let r=e;if(!(typeof r.topic!="string"||!E(r.at))&&(o.push({topic:r.topic.slice(0,32),at:r.at}),o.length>=24))break}return o}function jt(t){if(!Array.isArray(t))return [];let o=[],e=new Set;for(let r of t){if(typeof r!="object"||r===null)continue;let n=r;if(typeof n.key!="string"||typeof n.package!="string"||n.key===""||n.package==="")continue;let c=`${n.package}\0${n.key}`;if(!e.has(c)&&(e.add(c),o.push({key:n.key,package:n.package}),o.length>=32))break}return o}function Rt(t){if(typeof t!="object"||t===null)return null;let o=t,e={};if(typeof o.savedEnv=="object"&&o.savedEnv!==null)for(let[r,n]of Object.entries(o.savedEnv))(typeof n=="string"||n===null)&&(e[r]=n);return {active:o.active===true,savedEnv:e}}function Et(t){if(typeof t!="object"||t===null)return null;let o=t,e=r=>E(r)&&r>=0?r:0;return {turns:e(o.turns),lastLimitAt:e(o.lastLimitAt),lastDepletedAt:e(o.lastDepletedAt),lastBackupAt:e(o.lastBackupAt)}}function _t(t){let o=t.attrTagsAt,e=t.attrTagsCwd;return !E(o)||Date.now()-o>J||typeof e!="string"||e.length===0||e.length>64?{}:{attrTags:Array.isArray(t.attrTags)?t.attrTags.filter(n=>typeof n=="string"&&n.length<=40).slice(0,48):[],attrTagsCwd:e,attrTagsAt:o}}function Ot(t){let o=Y();if(typeof t!="object"||t===null)return o;let e=t;return {installId:typeof e.installId=="string"&&e.installId.length>0?e.installId:o.installId,lastShownAt:E(e.lastShownAt)&&e.lastShownAt>=0?e.lastShownAt:0,optOut:e.optOut===true,disclosureShown:e.disclosureShown===true,cachedConfig:vt(e.cachedConfig),allowedPlacements:Ct(e.allowedPlacements),sessionTopics:Tt(e.sessionTopics),integrations:jt(e.integrations),devToken:typeof e.devToken=="string"?e.devToken:null,computeRouting:Rt(e.computeRouting),computeCards:Et(e.computeCards),configFetchedAt:E(e.configFetchedAt)&&e.configFetchedAt>=0?e.configFetchedAt:0,pool:xt(e.pool),..._t(e)}}function le(t=process.env){let o=V(t),e=De(o);if(e.text!==void 0)try{return Ot(JSON.parse(e.text))}catch{let r=Y();try{C(r,t);}catch{}return r}if(e.missing){let r=Y();try{C(r,t);}catch{}return r}return Y()}function C(t,o=process.env,e={}){let r=V(o),n=b__namespace.dirname(r);h__namespace.mkdirSync(n,{recursive:true});let c=De(r),f=null;if(c.text!==void 0)try{f=JSON.parse(c.text);}catch{f=null;}if(f)typeof f.lastShownAt=="number"&&f.lastShownAt>t.lastShownAt&&(t={...t,lastShownAt:f.lastShownAt}),!e.allowClearToken&&typeof f.devToken=="string"&&t.devToken==null&&(t={...t,devToken:f.devToken}),typeof f.installId=="string"&&f.installId.length>0&&f.installId!==t.installId&&(t={...t,installId:f.installId});else if(!e.allowClearToken&&t.devToken==null&&c.text===void 0&&!c.missing)return;let u=b__namespace.join(n,`.state.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`);h__namespace.writeFileSync(u,JSON.stringify(t,null,2)+`
5
- `,"utf8");for(let d=0;;d++)try{h__namespace.renameSync(u,r);return}catch(a){let p=a.code??"";if(d>=4||!Le.has(p)){try{h__namespace.rmSync(u,{force:!0});}catch{}if(d>=4)return;throw a}try{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,15*(d+1));}catch{}}}var At=300*1e3;function Pt(){return b__namespace.join(H(),"blocked-ads.json")}function fe(){return b__namespace.join(H(),"recent-renders.json")}function It(){return b__namespace.join(H(),"reported-ads.json")}function We(t,o){let e={};for(let[r,n]of Object.entries(t))typeof n=="number"&&Number.isFinite(n)&&n>o&&(e[r]=n);return e}function Nt(t){try{let o=JSON.parse(h__namespace.readFileSync(Pt(),"utf8"));return We(o&&typeof o=="object"?o:{},t)}catch{return {}}}function $t(){try{let t=JSON.parse(h__namespace.readFileSync(It(),"utf8"));return t&&typeof t=="object"?t:{}}catch{return {}}}function Mt(t){return t?$t()[t]!==void 0:false}function X(t,o=Date.now()){return t?Nt(o)[t]!==void 0||Mt(t):false}function Be(t){try{let o=JSON.parse(h__namespace.readFileSync(fe(),"utf8"));return We(o&&typeof o=="object"?o:{},t)}catch{return {}}}function Z(t,o=Date.now()){if(t)try{let e=Be(o);e[t]=o+At,h__namespace.mkdirSync(b__namespace.dirname(fe()),{recursive:!0}),h__namespace.writeFileSync(fe(),JSON.stringify(e));}catch{}}function Q(t,o=Date.now()){return t?Be(o)[t]!==void 0:false}function Lt(t,o){return t.filter(e=>e.renderBy>o)}function ue(t,o){let e=Lt(t.pool,o),r=e.shift();return {blip:r?r.blip:null,pool:e}}var Dt=["claude_code","codex","antigravity","copilot_cli","grok_cli"];function ze(t){return t.includes("opencrater-hook")||/opencrater[\\/][^"']*hook\.js/.test(t)}function Wt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Bt(t,o){return ze(t)&&new RegExp(`--package ['"]?${Wt(o)}['"]?`).test(t)}function Ge(t,o){return o?Bt(t,o):ze(t)&&!/--package\b/.test(t)}function He(t){return /^[A-Za-z0-9@_./:-]+$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`}var Ue='"$HOME/.config/opencrater/runtime/node_modules/opencrater/dist/hook.js"',Fe="$env:USERPROFILE\\.config\\opencrater\\runtime\\node_modules\\opencrater\\dist\\hook.js";function U(t,o,e,r){let n=`--placement ${o}`;return e&&(n+=` --key ${He(e)}`),r&&(n+=` --package ${He(r)}`),n+=` --host ${t}`,`{ if [ -f ${Ue} ]; then node ${Ue} ${n}; else npx -y -p opencrater opencrater-hook ${n}; fi; } 2>/dev/null || true`}function Ht(t,o,e){if(process.platform!=="win32")return U("grok_cli",t,o,e);let r=`--placement ${t}`;o&&(r+=` --key ${o}`),e&&(r+=` --package ${e}`),r+=" --host grok_cli";let n=`${I__namespace.homedir()}\\.config\\opencrater\\runtime\\node_modules\\opencrater\\dist\\hook.js`;return `try { if (Test-Path "${n}") { node "${n}" ${r} } else { npx -y -p opencrater opencrater-hook ${r} } } catch {}`}function Je(t,o,e,r){let n=`--placement ${o}`;return e&&(n+=` --key '${e}'`),r&&(n+=` --package '${r}'`),n+=` --host ${t}`,`try { if (Test-Path "${Fe}") { node "${Fe}" ${n} } else { npx -y -p opencrater opencrater-hook ${n} } } catch {}`}function Ut(t,o,e){if(process.platform!=="win32")return U("claude_code",t,o,e);let r=`--placement ${t}`;return o&&(r+=` --key ${o}`),e&&(r+=` --package ${e}`),r+=" --host claude_code",`node "${`${I__namespace.homedir()}\\.config\\opencrater\\runtime\\node_modules\\opencrater\\dist\\hook.js`}" ${r}; exit 0`}function de(t,o,e,r){if(t==="grok_cli")return {type:"command",command:Ht(o,e,r),timeout:15};let c={type:"command",command:t==="claude_code"?Ut(o,e,r):U(t,o,e,r)};return t==="codex"&&(c.commandWindows=Je(t,o,e,r)),c}function pe(t,o){let e=I__namespace.homedir();switch(t){case "claude_code":{let r=o.CLAUDE_CONFIG_DIR;return r&&r.trim()!==""?r:b__namespace.join(e,".claude")}case "codex":{let r=o.CODEX_HOME;return r&&r.trim()!==""?r:b__namespace.join(e,".codex")}case "antigravity":return b__namespace.join(e,".gemini");case "copilot_cli":{let r=o.COPILOT_HOME;return r&&r.trim()!==""?r:b__namespace.join(e,".copilot")}case "grok_cli":{let r=o.GROK_HOME;return r&&r.trim()!==""?r:b__namespace.join(e,".grok")}default:return b__namespace.join(e,".opencrater-unknown")}}function te(t,o=process.env){let e=pe(t,o);switch(t){case "claude_code":return b__namespace.join(e,"settings.json");case "codex":return b__namespace.join(e,"hooks.json");case "antigravity":return b__namespace.join(e,"settings.json");case "copilot_cli":return b__namespace.join(e,"hooks","hooks.json");case "grok_cli":return b__namespace.join(e,"hooks","opencrater.json");default:return b__namespace.join(e,"hooks.json")}}var Ft={claude_code:["claude"],codex:["codex"],antigravity:["agy"],copilot_cli:["copilot"],grok_cli:["grok"]};function qt(t,o){if(t.length===0)return false;let e=(o.PATH??o.Path??"").split(b__namespace.delimiter).filter(Boolean),r=process.platform==="win32"?["",".exe",".cmd",".bat"]:[""];for(let n of e)for(let c of t)for(let f of r)try{if(h__namespace.existsSync(b__namespace.join(n,c+f)))return !0}catch{}return false}function zt(t,o=process.env){try{if(h__namespace.existsSync(pe(t,o)))return !0}catch{}return qt(Ft[t]??[],o)}function me(t=process.env){return Dt.filter(o=>zt(o,t))}function Ke(t){let o;try{o=h__namespace.readFileSync(t,"utf8");}catch{return {}}let e=JSON.parse(o);if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`${t} is not a JSON object`);return e}function Ye(t,o){let e=b__namespace.dirname(t);h__namespace.mkdirSync(e,{recursive:true});let r=b__namespace.join(e,`.${b__namespace.basename(t)}.${process.pid}.tmp`);h__namespace.writeFileSync(r,JSON.stringify(o,null,2)+`
6
- `,"utf8"),h__namespace.renameSync(r,t);}function Gt(t,o){return Array.isArray(t.hooks)&&t.hooks.some(e=>typeof e.command=="string"&&Ge(e.command,o))}function Jt(t,o,e,r){let n=te(t),c=Ke(n),f=c.hooks&&typeof c.hooks=="object"?c.hooks:{};if(!(t==="antigravity"&&c["json-hooks-enabled"]!==true)&&r.every(a=>{let p=de(t,a,o,e);return (Array.isArray(f[a])?f[a]:[]).some(s=>Array.isArray(s.hooks)&&s.hooks.some(i=>i.command===p.command&&i.commandWindows===p.commandWindows))}))return "nochange";for(let a of r){let s=(Array.isArray(f[a])?f[a]:[]).filter(y=>!Gt(y,e)),i=t==="grok_cli"?{hooks:[de(t,a,o,e)]}:{matcher:"",hooks:[de(t,a,o,e)]};s.push(i),f[a]=s;}return t==="antigravity"&&(c["json-hooks-enabled"]=true),c.hooks=f,Ye(n,c),"wrote"}var qe=12;function Kt(t,o){return [t.bash,t.powershell,t.command].some(e=>typeof e=="string"&&Ge(e,o))}function Yt(t,o,e,r){let n=te(t),c=Ke(n);typeof c.version!="number"&&(c.version=1);let f=c.hooks&&typeof c.hooks=="object"?c.hooks:{};if(r.every(d=>{let a=U(t,d,o,e);return (Array.isArray(f[d])?f[d]:[]).some(p=>p.bash===a&&p.timeoutSec===qe)}))return "nochange";for(let d of r){let p=(Array.isArray(f[d])?f[d]:[]).filter(s=>!Kt(s,e));p.push({type:"command",bash:U(t,d,o,e),powershell:Je(t,d,o,e),timeoutSec:qe}),f[d]=p;}return c.hooks=f,Ye(n,c),"wrote"}function Ve(t){return [...je[t]]}function Vt(t){let o=t;for(let e of ["claude","cursor"]){if(new RegExp(`^\\s*\\[compat\\.${e}\\]`,"m").test(o))continue;let r=o.length===0?"":o.endsWith(`
2
+ 'use strict';var child_process=require('child_process'),h=require('fs'),N=require('os'),b=require('path'),crypto=require('crypto');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var h__namespace=/*#__PURE__*/_interopNamespace(h);var N__namespace=/*#__PURE__*/_interopNamespace(N);var b__namespace=/*#__PURE__*/_interopNamespace(b);var M=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(o,e)=>(typeof require<"u"?require:o)[e]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var B={minIntervalSeconds:600,serveTimeoutMs:2500,preloadPoolSize:3,killSwitch:false,displayDurationSeconds:25,minSdkVersion:""},Te={claude_code:["SessionStart","Stop","SessionEnd","Notification"],codex:["Stop"],openclaw:[],antigravity:["AfterAgent","SessionStart","SessionEnd"],copilot_cli:["agentStop","sessionStart","sessionEnd","notification"],grok_cli:["SessionStart","Stop","SessionEnd","Notification"],generic:["SessionStart","Stop"]},je={claude_code:["SessionStart","Stop","SessionEnd","Notification","UserPromptSubmit","SubagentStart","SubagentStop","StopFailure","PreToolUse","PostToolUse","PostToolUseFailure","PostToolBatch","PermissionRequest","PermissionDenied","UserPromptExpansion","PreCompact","PostCompact","TaskCreated","TaskCompleted","Setup","TeammateIdle","Elicitation","ElicitationResult","ConfigChange","InstructionsLoaded","WorktreeCreate","WorktreeRemove","CwdChanged","FileChanged","MessageDisplay"],codex:["Stop","SessionStart","UserPromptSubmit","PreToolUse","PostToolUse","PermissionRequest","PreCompact","PostCompact"],openclaw:[],antigravity:["AfterAgent","SessionStart","SessionEnd","Notification","BeforeAgent","BeforeModel","AfterModel","BeforeToolSelection","BeforeTool","AfterTool","PreCompress"],copilot_cli:["agentStop","sessionStart","sessionEnd","notification","userPromptSubmitted","preToolUse","postToolUse","permissionRequest","errorOccurred","subagentStart","subagentStop"],grok_cli:["SessionStart","Stop","SessionEnd","Notification"],generic:["SessionStart","Stop"]};var O="1.3.1";var yt="https://api.opencrater.to";function G(t,o=process.env){let e=o.OPENCRATER_API_ORIGIN;return ((e&&e.trim()!==""?e:yt)).replace(/\/+$/,"")}function x(...t){try{if(process.env.OPENCRATER_DEBUG!=="1")return;console.error("[opencrater]",...t);try{let o=M("os"),e=M("fs"),r=M("path");e.appendFileSync(r.join(o.homedir(),".config","opencrater","hook.log"),`${new Date().toISOString()} [opencrater] ${t.map(n=>String(n)).join(" ")}
3
+ `);}catch{}}catch{}}function z(t){return typeof t=="number"&&Number.isFinite(t)}function bt(t){let o=B;if(typeof t!="object"||t===null)return {...o};let e=t;return {minIntervalSeconds:z(e.minIntervalSeconds)?e.minIntervalSeconds:o.minIntervalSeconds,serveTimeoutMs:z(e.serveTimeoutMs)?e.serveTimeoutMs:o.serveTimeoutMs,preloadPoolSize:z(e.preloadPoolSize)?e.preloadPoolSize:o.preloadPoolSize,killSwitch:e.killSwitch===true,displayDurationSeconds:z(e.displayDurationSeconds)?e.displayDurationSeconds:o.displayDurationSeconds,minSdkVersion:typeof e.minSdkVersion=="string"?e.minSdkVersion:o.minSdkVersion}}async function Re(t,o,e,r,n){try{let c=await fetch(`${t}${o}`,{method:"POST",headers:{"content-type":"application/json",...n??{}},body:JSON.stringify(e),signal:AbortSignal.timeout(r)});return c.ok?await c.json():(x(`POST ${o} -> HTTP ${c.status}`),null)}catch(c){return x(`POST ${o} failed:`,c),null}}function Ee(t,o){let e=t.host??"generic";return {publisherKey:t.publisherKey,packageName:t.packageName,placement:t.placement,host:e,sdkVersion:O,installId:o.installId,os:process.platform,termProgram:process.env.TERM_PROGRAM??void 0,topics:o.topics&&o.topics.length>0?o.topics:void 0,tags:o.tags&&o.tags.length>0?o.tags:void 0}}function _e(t){if(typeof t!="object"||t===null)return null;let o=t;if(typeof o.fill!="boolean")return null;let e={fill:o.fill,fallback:o.fallback??null,config:bt(o.config),...Array.isArray(o.allowedPlacements)?{allowedPlacements:o.allowedPlacements.filter(r=>typeof r=="string")}:{}};return o.blip!==void 0&&o.blip!==null&&(e.blip=o.blip),typeof o.computeBalanceMicroUsd=="number"&&(e.computeBalanceMicroUsd=o.computeBalanceMicroUsd),typeof o.weeklyGrantMicroUsd=="number"&&(e.weeklyGrantMicroUsd=o.weeklyGrantMicroUsd),typeof o.pendingMicroUsd=="number"&&(e.pendingMicroUsd=o.pendingMicroUsd),e}async function Oe(t,o){let e=await Re(o.origin,"/v1/serve",Ee(t,o),o.timeoutMs);return _e(e)}async function Ae(t,o,e){let r={...Ee(o,e),publisherKey:o.publisherKey??"",packageName:o.packageName??""},n=await Re(e.origin,"/v1/dev/serve",r,e.timeoutMs,{authorization:`Bearer ${t}`});return _e(n)}var wt=48,J=360*60*1e3;function Pe(t){return crypto.createHash("sha256").update(t).digest("hex").slice(0,16)}function Ie(t){let o=new Set,e=s=>{o.size<wt&&o.add(s);},r=[];try{r=h__namespace.readdirSync(t);}catch{return []}let n=s=>r.includes(s),c=s=>{try{return h__namespace.readFileSync(b__namespace.join(t,s),"utf8")}catch{return ""}},f=s=>{try{return JSON.parse(c(s))}catch{return null}},d=f("package.json")??{},p={...d.dependencies??{},...d.devDependencies??{},...d.peerDependencies??{}},a=s=>Object.prototype.hasOwnProperty.call(p,s),u=s=>Object.keys(p).some(i=>i===s||i.startsWith(s));n("package.json")&&(e("lang:javascript"),(a("typescript")||n("tsconfig.json"))&&e("lang:typescript")),(n("deno.json")||n("deno.jsonc"))&&e("lang:typescript"),(n("tsconfig.json")||n("tsconfig.base.json"))&&e("lang:typescript"),n("jsconfig.json")&&e("lang:javascript"),(n("bun.lockb")||n("bun.lock"))&&e("lang:javascript"),r.some(s=>s.endsWith(".ts")||s.endsWith(".tsx")||s.endsWith(".mts")||s.endsWith(".cts"))&&e("lang:typescript"),r.some(s=>s.endsWith(".js")||s.endsWith(".jsx")||s.endsWith(".mjs")||s.endsWith(".cjs"))&&e("lang:javascript"),(n("requirements.txt")||n("pyproject.toml")||n("setup.py")||n("Pipfile"))&&e("lang:python"),(n("setup.cfg")||n("Pipfile.lock")||n("poetry.lock")||n("uv.lock")||n("environment.yml"))&&e("lang:python"),r.some(s=>s.endsWith(".py")||s.endsWith(".pyi")||s.endsWith(".ipynb"))&&e("lang:python"),(n("go.mod")||n("go.sum")||n("go.work"))&&e("lang:go"),r.some(s=>s.endsWith(".go"))&&e("lang:go"),(n("Cargo.toml")||n("Cargo.lock"))&&e("lang:rust"),r.some(s=>s.endsWith(".rs"))&&e("lang:rust"),(n("pom.xml")||n("build.gradle"))&&e("lang:java"),r.some(s=>s.endsWith(".java"))&&e("lang:java"),(n("build.gradle.kts")||n("settings.gradle.kts"))&&e("lang:kotlin"),r.some(s=>s.endsWith(".kt")||s.endsWith(".kts"))&&e("lang:kotlin"),(n("build.sbt")||n(".scalafmt.conf"))&&e("lang:scala"),r.some(s=>s.endsWith(".scala")||s.endsWith(".sc"))&&e("lang:scala"),r.some(s=>s.endsWith(".groovy")||s.endsWith(".gradle"))&&e("lang:groovy"),(n("deps.edn")||n("project.clj")||n("shadow-cljs.edn"))&&e("lang:clojure"),r.some(s=>s.endsWith(".clj")||s.endsWith(".cljs")||s.endsWith(".cljc"))&&e("lang:clojure"),r.some(s=>s.endsWith(".csproj")||s.endsWith(".sln"))&&e("lang:csharp"),r.some(s=>s.endsWith(".fsproj"))&&e("lang:fsharp"),r.some(s=>s.endsWith(".cs"))&&e("lang:csharp"),r.some(s=>s.endsWith(".fs")||s.endsWith(".fsx")||s.endsWith(".fsi"))&&e("lang:fsharp"),r.some(s=>s.endsWith(".cpp")||s.endsWith(".cc")||s.endsWith(".cxx")||s.endsWith(".hpp")||s.endsWith(".hxx"))&&e("lang:cpp"),r.some(s=>s.endsWith(".c"))&&e("lang:c"),(n("composer.json")||n("composer.lock"))&&e("lang:php"),r.some(s=>s.endsWith(".php"))&&e("lang:php"),(n("Gemfile")||n("Gemfile.lock")||n(".ruby-version")||r.some(s=>s.endsWith(".gemspec")))&&e("lang:ruby"),r.some(s=>s.endsWith(".rb")||s==="Rakefile")&&e("lang:ruby"),(n("Package.swift")||n("Podfile")||r.some(s=>s.endsWith(".xcodeproj")||s.endsWith(".xcworkspace")))&&e("lang:swift"),r.some(s=>s.endsWith(".swift"))&&e("lang:swift"),r.some(s=>s.endsWith(".m")||s.endsWith(".mm"))&&e("lang:objective-c"),(n("pubspec.yaml")||n("pubspec.yml")||n("pubspec.lock"))&&e("lang:dart"),r.some(s=>s.endsWith(".dart"))&&e("lang:dart"),(n("mix.exs")||n("mix.lock"))&&e("lang:elixir"),r.some(s=>s.endsWith(".ex")||s.endsWith(".exs"))&&e("lang:elixir"),(n("rebar.config")||n("rebar.lock"))&&e("lang:erlang"),r.some(s=>s.endsWith(".erl")||s.endsWith(".hrl"))&&e("lang:erlang"),(n("gleam.toml")||r.some(s=>s.endsWith(".gleam")))&&e("lang:gleam"),(n("stack.yaml")||n("cabal.project")||r.some(s=>s.endsWith(".cabal")||s.endsWith(".hs")))&&e("lang:haskell"),(n("dune-project")||n("dune")||r.some(s=>s.endsWith(".ml")||s.endsWith(".mli")))&&e("lang:ocaml"),(r.some(s=>s.endsWith(".rockspec")||s.endsWith(".lua"))||n(".luarc.json"))&&e("lang:lua"),(n("cpanfile")||n("Makefile.PL")||r.some(s=>s.endsWith(".pl")||s.endsWith(".pm")))&&e("lang:perl"),(n("DESCRIPTION")||n("renv.lock")||r.some(s=>s.endsWith(".Rproj")||s.endsWith(".Rmd")||s.endsWith(".R")))&&e("lang:r"),(n("Project.toml")||n("Manifest.toml")||r.some(s=>s.endsWith(".jl")))&&e("lang:julia"),(n("build.zig")||n("build.zig.zon")||r.some(s=>s.endsWith(".zig")))&&e("lang:zig"),r.some(s=>s.endsWith(".nimble")||s.endsWith(".nim"))&&e("lang:nim"),(n("shard.yml")||n("shard.lock")||r.some(s=>s.endsWith(".cr")))&&e("lang:crystal"),(n("v.mod")||r.some(s=>s.endsWith(".vsh")))&&e("lang:vlang"),r.some(s=>s.endsWith(".hx")||s.endsWith(".hxml"))&&e("lang:haxe"),(n("foundry.toml")||n("hardhat.config.js")||n("hardhat.config.ts")||r.some(s=>s.endsWith(".sol")))&&e("lang:solidity"),r.some(s=>s.endsWith(".f")||s.endsWith(".f90")||s.endsWith(".f95"))&&e("lang:fortran"),r.some(s=>s.endsWith(".cob")||s.endsWith(".cbl"))&&e("lang:cobol"),r.some(s=>s.endsWith(".asm"))&&e("lang:assembly"),r.some(s=>s.endsWith(".sh")||s.endsWith(".bash")||s.endsWith(".zsh"))&&e("lang:shell"),r.some(s=>s.endsWith(".ps1")||s.endsWith(".psm1"))&&e("lang:powershell"),r.some(s=>s.endsWith(".sql"))&&e("lang:sql"),r.some(s=>s.endsWith(".html")||s.endsWith(".htm"))&&e("lang:html"),r.some(s=>s.endsWith(".css"))&&e("lang:css"),r.some(s=>s.endsWith(".scss")||s.endsWith(".sass"))&&e("lang:scss"),r.some(s=>s.endsWith(".graphql")||s.endsWith(".gql"))&&e("lang:graphql"),r.some(s=>s.endsWith(".proto"))&&e("lang:protobuf");{if(a("react")&&e("fw:react"),a("next")&&e("fw:nextjs"),a("vue")&&e("fw:vue"),(a("nuxt")||a("nuxt3"))&&e("fw:nuxt"),a("@angular/core")&&e("fw:angular"),a("svelte")&&e("fw:svelte"),a("@sveltejs/kit")&&e("fw:sveltekit"),(a("@remix-run/react")||a("@remix-run/node"))&&e("fw:remix"),a("astro")&&e("fw:astro"),a("gatsby")&&e("fw:gatsby"),a("solid-js")&&e("fw:solid"),(a("@solidjs/start")||a("solid-start"))&&e("fw:solidstart"),(a("@builder.io/qwik")||a("@qwik.dev/core"))&&e("fw:qwik"),a("preact")&&e("fw:preact"),(a("lit")||a("lit-element"))&&e("fw:lit"),(a("ember-source")||a("ember-cli"))&&e("fw:ember"),a("htmx.org")&&e("fw:htmx"),a("vite")&&e("fw:vite"),a("webpack")&&e("fw:webpack"),a("express")&&e("fw:express"),a("fastify")&&e("fw:fastify"),a("@nestjs/core")&&e("fw:nestjs"),a("koa")&&e("fw:koa"),a("hono")&&e("fw:hono"),(a("@hapi/hapi")||a("hapi"))&&e("fw:hapi"),a("@adonisjs/core")&&e("fw:adonis"),(a("@trpc/server")||a("@trpc/client"))&&e("fw:trpc"),a("sails")&&e("fw:sails"),a("electron")&&e("fw:electron"),a("react-native")&&e("fw:react-native"),a("expo")&&e("fw:expo"),u("@ionic/")&&e("fw:ionic"),a("@capacitor/core")&&e("fw:capacitor"),n("requirements.txt")||n("pyproject.toml")||n("setup.py")||n("Pipfile")){let i=(c("requirements.txt")+c("pyproject.toml")+c("Pipfile")+c("setup.py")).toLowerCase();i.includes("fastapi")&&e("fw:fastapi"),i.includes("django")&&e("fw:django"),i.includes("flask")&&e("fw:flask"),i.includes("litestar")&&e("fw:litestar"),i.includes("starlette")&&e("fw:starlette"),i.includes("tornado")&&e("fw:tornado"),i.includes("sanic")&&e("fw:sanic"),i.includes("aiohttp")&&e("fw:aiohttp"),i.includes("pyramid")&&e("fw:pyramid"),i.includes("fasthtml")&&e("fw:fasthtml"),(i.includes("torch")||i.includes("pytorch"))&&e("fw:pytorch"),i.includes("tensorflow")&&e("fw:tensorflow"),(i.includes("jax")||i.includes("jaxlib"))&&e("fw:jax"),i.includes("keras")&&e("fw:keras"),(i.includes("scikit-learn")||i.includes("sklearn"))&&e("fw:scikit-learn"),i.includes("transformers")&&e("fw:transformers"),i.includes("langchain")&&e("fw:langchain"),(i.includes("llama-index")||i.includes("llama_index")||i.includes("llamaindex"))&&e("fw:llamaindex"),i.includes("pandas")&&e("fw:pandas"),i.includes("numpy")&&e("fw:numpy"),i.includes("streamlit")&&e("fw:streamlit"),i.includes("gradio")&&e("fw:gradio"),i.includes("fastai")&&e("fw:fastai");}if(n("go.mod")){let i=c("go.mod").toLowerCase();i.includes("gin-gonic/gin")&&e("fw:gin"),i.includes("labstack/echo")&&e("fw:echo"),i.includes("gofiber/fiber")&&e("fw:fiber"),i.includes("go-chi/chi")&&e("fw:chi"),(i.includes("gorilla/mux")||i.includes("gorilla/websocket"))&&e("fw:gorilla"),(i.includes("beego/beego")||i.includes("astaxie/beego"))&&e("fw:beego"),i.includes("gobuffalo/buffalo")&&e("fw:buffalo");}if(n("Cargo.toml")){let i=c("Cargo.toml").toLowerCase();i.includes("actix-web")&&e("fw:actix"),i.includes("axum")&&e("fw:axum"),i.includes("rocket")&&e("fw:rocket"),i.includes("warp")&&e("fw:warp"),i.includes("tonic")&&e("fw:tonic"),i.includes("leptos")&&e("fw:leptos"),i.includes("yew")&&e("fw:yew"),i.includes("tauri")&&e("fw:tauri"),i.includes("dioxus")&&e("fw:dioxus"),i.includes("bevy")&&e("fw:bevy");}if(n("pom.xml")||n("build.gradle")||n("build.gradle.kts")){let i=(c("pom.xml")+c("build.gradle")+c("build.gradle.kts")).toLowerCase();(i.includes("spring-boot")||i.includes("springframework"))&&e("fw:spring"),i.includes("quarkus")&&e("fw:quarkus"),i.includes("micronaut")&&e("fw:micronaut"),(i.includes("io.ktor")||i.includes("ktor-"))&&e("fw:ktor"),(i.includes("vertx")||i.includes("vert.x"))&&e("fw:vertx"),(i.includes("com.android")||i.includes("androidx"))&&e("fw:android"),(i.includes("androidx.compose")||i.includes("jetpack"))&&e("fw:jetpack-compose"),(i.includes("kotlin-multiplatform")||i.includes('kotlin("multiplatform")'))&&e("fw:kotlin-multiplatform");}if(n("Gemfile")){let i=c("Gemfile").toLowerCase();i.includes("rails")&&e("fw:rails"),i.includes("sinatra")&&e("fw:sinatra"),i.includes("hanami")&&e("fw:hanami");}if(n("composer.json")){let i=c("composer.json").toLowerCase();(i.includes("laravel/framework")||i.includes("laravel/laravel"))&&e("fw:laravel"),i.includes("symfony/")&&e("fw:symfony"),i.includes("drupal/")&&e("fw:drupal"),i.includes("codeigniter")&&e("fw:codeigniter"),i.includes("slim/slim")&&e("fw:slim");}(n("wp-config.php")||n("wp-load.php")||n("wp-content"))&&e("fw:wordpress"),n("pubspec.yaml")&&c("pubspec.yaml").toLowerCase().includes("flutter")&&e("fw:flutter");{let i=r.filter(y=>y.endsWith(".csproj"));if(i.length>0){let y=i.map(g=>c(g)).join(`
4
+ `).toLowerCase();(y.includes("microsoft.net.sdk.web")||y.includes("microsoft.aspnetcore"))&&e("fw:aspnet"),y.includes("blazor")&&e("fw:blazor"),(y.includes("microsoft.net.sdk.maui")||y.includes("usemaui"))&&e("fw:maui");}}(n("ProjectSettings")||r.includes("Assembly-CSharp.csproj"))&&e("fw:unity"),n("project.godot")&&e("fw:godot");{let i=c("Package.swift").toLowerCase();i.includes("swiftui")&&e("fw:swiftui"),i.includes("uikit")&&e("fw:uikit");}let s=i=>r.some(y=>y===i||y.startsWith(i+"."));s("next.config")&&e("fw:nextjs"),s("nuxt.config")&&e("fw:nuxt"),s("astro.config")&&e("fw:astro"),s("svelte.config")&&e("fw:svelte"),s("remix.config")&&e("fw:remix"),s("gatsby-config")&&e("fw:gatsby"),s("vite.config")&&e("fw:vite"),s("vue.config")&&e("fw:vue"),s("qwik.config")&&e("fw:qwik"),n("angular.json")&&e("fw:angular"),s("capacitor.config")&&e("fw:capacitor"),s("ionic.config")&&e("fw:ionic"),n("app.json")&&c("app.json").toLowerCase().includes('"expo"')&&e("fw:expo");}{if((a("pg")||a("postgres")||a("pg-promise")||a("@vercel/postgres"))&&e("infra:postgres"),(a("mysql")||a("mysql2"))&&e("infra:mysql"),a("mariadb")&&e("infra:mariadb"),(a("redis")||a("ioredis"))&&e("infra:redis"),(a("mongodb")||a("mongoose"))&&e("infra:mongodb"),a("mongoose")&&e("infra:mongoose"),(a("better-sqlite3")||a("sqlite3")||a("sqlite"))&&e("infra:sqlite"),a("@libsql/client")&&e("infra:libsql"),a("cassandra-driver")&&e("infra:cassandra"),(a("@elastic/elasticsearch")||a("elasticsearch"))&&e("infra:elasticsearch"),a("@opensearch-project/opensearch")&&e("infra:opensearch"),(a("@clickhouse/client")||a("clickhouse"))&&e("infra:clickhouse"),(a("duckdb")||a("@duckdb/node-api"))&&e("infra:duckdb"),a("neo4j-driver")&&e("infra:neo4j"),a("@influxdata/influxdb-client")&&e("infra:influxdb"),a("snowflake-sdk")&&e("infra:snowflake"),a("@google-cloud/bigquery")&&e("infra:bigquery"),(a("firebase-admin")||a("@google-cloud/firestore"))&&e("infra:firestore"),(a("faunadb")||a("fauna"))&&e("infra:fauna"),(a("surrealdb")||a("surrealdb.js"))&&e("infra:surrealdb"),a("@qdrant/js-client-rest")&&e("infra:qdrant"),a("@pinecone-database/pinecone")&&e("infra:pinecone"),(a("weaviate-ts-client")||a("weaviate-client"))&&e("infra:weaviate"),a("chromadb")&&e("infra:chromadb"),a("@zilliz/milvus2-sdk-node")&&e("infra:milvus"),(a("@prisma/client")||a("prisma"))&&e("infra:prisma"),a("drizzle-orm")&&e("infra:drizzle"),a("typeorm")&&e("infra:typeorm"),(a("aws-sdk")||u("@aws-sdk/"))&&e("infra:aws"),(u("@google-cloud/")||a("googleapis"))&&e("infra:gcp"),u("@azure/")&&e("infra:azure"),(u("@cloudflare/")||a("wrangler"))&&e("infra:cloudflare"),(a("@vercel/node")||a("@vercel/kv")||a("@vercel/blob"))&&e("infra:vercel"),(a("firebase")||a("firebase-admin"))&&e("infra:firebase"),a("@supabase/supabase-js")&&e("infra:supabase"),a("@neondatabase/serverless")&&e("infra:neon"),a("@planetscale/database")&&e("infra:planetscale"),u("@upstash/")&&e("infra:upstash"),a("@tursodatabase/api")&&e("infra:turso"),a("modal")&&e("infra:modal"),a("replicate")&&e("infra:replicate"),(a("kafkajs")||a("node-rdkafka"))&&e("infra:kafka"),(a("amqplib")||a("rabbitmq-client"))&&e("infra:rabbitmq"),a("nats")&&e("infra:nats"),(u("@aws-sdk/client-sqs")||a("sqs-consumer"))&&e("infra:sqs"),a("@google-cloud/pubsub")&&e("infra:pubsub"),u("@temporalio/")&&e("infra:temporal"),(a("bullmq")||a("bull"))&&e("infra:bullmq"),u("@sentry/")&&e("infra:sentry"),(u("@datadog/")||a("dd-trace"))&&e("infra:datadog"),u("@opentelemetry/")&&e("infra:opentelemetry"),a("newrelic")&&e("infra:newrelic"),(a("posthog-node")||a("posthog-js"))&&e("infra:posthog"),u("@honeycombio/")&&e("infra:honeycomb"),a("prom-client")&&e("infra:prometheus"),(a("stripe")||a("@stripe/stripe-js"))&&e("infra:stripe"),u("@paddle/")&&e("infra:paddle"),u("@clerk/")&&e("infra:clerk"),(a("auth0")||u("@auth0/"))&&e("infra:auth0"),(a("next-auth")||u("@auth/"))&&e("infra:nextauth"),a("twilio")&&e("infra:twilio"),a("@sendgrid/mail")&&e("infra:sendgrid"),a("resend")&&e("infra:resend"),a("postmark")&&e("infra:postmark"),u("@pulumi/")&&e("infra:pulumi"),n("requirements.txt")||n("pyproject.toml")||n("setup.py")||n("Pipfile")){let i=(c("requirements.txt")+c("pyproject.toml")+c("Pipfile")+c("setup.py")).toLowerCase();(i.includes("psycopg")||i.includes("asyncpg"))&&e("infra:postgres"),(i.includes("pymysql")||i.includes("aiomysql")||i.includes("mysqlclient"))&&e("infra:mysql"),(i.includes("redis")||i.includes("aioredis"))&&e("infra:redis"),(i.includes("pymongo")||i.includes("motor")||i.includes("mongoengine"))&&e("infra:mongodb"),i.includes("elasticsearch")&&e("infra:elasticsearch"),i.includes("clickhouse")&&e("infra:clickhouse"),i.includes("duckdb")&&e("infra:duckdb"),i.includes("neo4j")&&e("infra:neo4j"),i.includes("snowflake")&&e("infra:snowflake"),i.includes("qdrant-client")&&e("infra:qdrant"),i.includes("pinecone")&&e("infra:pinecone"),i.includes("chromadb")&&e("infra:chromadb"),i.includes("pymilvus")&&e("infra:milvus"),i.includes("sqlalchemy")&&e("infra:sqlalchemy"),(i.includes("boto3")||i.includes("botocore"))&&e("infra:aws"),i.includes("google-cloud")&&e("infra:gcp"),i.includes("azure-")&&e("infra:azure"),i.includes("supabase")&&e("infra:supabase"),(i.includes("confluent-kafka")||i.includes("aiokafka")||i.includes("kafka-python"))&&e("infra:kafka"),(i.includes("pika")||i.includes("aio-pika"))&&e("infra:rabbitmq"),i.includes("temporalio")&&e("infra:temporal"),i.includes("sentry-sdk")&&e("infra:sentry"),(i.includes("ddtrace")||i.includes("datadog"))&&e("infra:datadog"),i.includes("opentelemetry")&&e("infra:opentelemetry"),i.includes("stripe")&&e("infra:stripe"),i.includes("twilio")&&e("infra:twilio"),i.includes("pulumi")&&e("infra:pulumi"),i.includes("ansible")&&e("infra:ansible");}if(n("go.mod")){let i=c("go.mod").toLowerCase();(i.includes("lib/pq")||i.includes("jackc/pgx"))&&e("infra:postgres"),i.includes("go-sql-driver/mysql")&&e("infra:mysql"),(i.includes("go-redis")||i.includes("redis/go-redis"))&&e("infra:redis"),i.includes("go.mongodb.org/mongo-driver")&&e("infra:mongodb"),i.includes("aws/aws-sdk-go")&&e("infra:aws"),i.includes("cloud.google.com/go")&&e("infra:gcp"),(i.includes("segmentio/kafka-go")||i.includes("sarama"))&&e("infra:kafka"),i.includes("getsentry/sentry-go")&&e("infra:sentry"),i.includes("go.opentelemetry.io")&&e("infra:opentelemetry"),i.includes("stripe/stripe-go")&&e("infra:stripe"),i.includes("hashicorp/terraform")&&e("infra:terraform"),i.includes("k8s.io/client-go")&&e("infra:kubernetes");}(n("Dockerfile")||n("docker-compose.yml")||n("docker-compose.yaml")||n("compose.yaml")||n("compose.yml")||n(".dockerignore"))&&e("infra:docker"),(n("Containerfile")||n("podman-compose.yml"))&&e("infra:podman"),r.some(i=>i.endsWith(".tf")||i===".terraform.lock.hcl")&&e("infra:terraform"),(n("Pulumi.yaml")||n("Pulumi.yml"))&&e("infra:pulumi"),(n("ansible.cfg")||n("playbook.yml")||n("playbook.yaml"))&&e("infra:ansible"),(n("kustomization.yaml")||n("kustomization.yml")||n("k8s")||n("kubernetes")||n("skaffold.yaml"))&&e("infra:kubernetes"),(n("Chart.yaml")||n("helmfile.yaml"))&&(e("infra:helm"),e("infra:kubernetes")),r.some(i=>i.endsWith(".nomad")||i.endsWith(".nomad.hcl"))&&e("infra:nomad"),(n("vercel.json")||n(".vercel"))&&e("infra:vercel"),(n("netlify.toml")||n(".netlify"))&&e("infra:netlify"),n("fly.toml")&&e("infra:fly"),(n("railway.json")||n("railway.toml"))&&e("infra:railway"),n("render.yaml")&&e("infra:render"),n("Procfile")&&e("infra:heroku"),(n("wrangler.toml")||n("wrangler.jsonc")||n("wrangler.json"))&&e("infra:cloudflare"),n("supabase")&&e("infra:supabase"),(n("firebase.json")||n(".firebaserc"))&&e("infra:firebase"),(n("serverless.yml")||n("serverless.yaml")||n("template.yaml")||n("samconfig.toml"))&&e("infra:aws"),(n("prisma")||n("schema.prisma"))&&e("infra:prisma"),(n("drizzle.config.ts")||n("drizzle.config.js"))&&e("infra:drizzle");let s=false;try{s=n(".github")&&h__namespace.existsSync(b__namespace.join(t,".github","workflows"));}catch{s=false;}s&&e("infra:github-actions"),(n(".gitlab-ci.yml")||n(".gitlab-ci.yaml"))&&e("infra:gitlab-ci"),n(".circleci")&&e("infra:circleci"),n("Jenkinsfile")&&e("infra:jenkins");{let i=(c("Dockerfile")+c("docker-compose.yml")+c("docker-compose.yaml")+c("compose.yaml")+c("compose.yml")).toLowerCase();i&&((i.includes("postgres")||i.includes("pgvector"))&&e("infra:postgres"),i.includes("timescale")&&e("infra:timescaledb"),i.includes("mysql")&&e("infra:mysql"),i.includes("mariadb")&&e("infra:mariadb"),i.includes("redis")&&e("infra:redis"),i.includes("mongo")&&e("infra:mongodb"),i.includes("cassandra")&&e("infra:cassandra"),i.includes("cockroach")&&e("infra:cockroachdb"),i.includes("clickhouse")&&e("infra:clickhouse"),i.includes("elasticsearch")&&e("infra:elasticsearch"),i.includes("neo4j")&&e("infra:neo4j"),i.includes("qdrant")&&e("infra:qdrant"),i.includes("rabbitmq")&&e("infra:rabbitmq"),(i.includes("kafka")||i.includes("redpanda"))&&e("infra:kafka"),i.includes("nats")&&e("infra:nats"),i.includes("grafana")&&e("infra:grafana"),(i.includes("prometheus")||i.includes("prom/"))&&e("infra:prometheus"));}}{let i=(...w)=>w.some(a),y=(c("requirements.txt")+c("pyproject.toml")+c("Pipfile")+c("setup.py")+c("environment.yml")).toLowerCase(),g=c("go.mod").toLowerCase(),m=c("Cargo.toml").toLowerCase(),l=w=>y.includes(w),P=w=>r.some(ae=>ae.toLowerCase().endsWith(w)),k=(...w)=>w.some(ae=>n(ae)),j=()=>Array.from(o).some(w=>w.startsWith("type:")),se=()=>Array.from(o).some(w=>w.startsWith("fw:"));(a("@modelcontextprotocol/sdk")||l("modelcontextprotocol")||l("fastmcp")||g.includes("modelcontextprotocol")||k("mcp.json",".mcp.json"))&&e("type:mcp-server"),(i("langgraph","@langchain/langgraph","crewai","autogen","@mastra/core","@openai/agents","@langchain/core")||l("langgraph")||l("crewai")||l("autogen")||l("pyautogen")||l("smolagents")||l("haystack"))&&e("type:agent-framework"),(i("ai","openai","@anthropic-ai/sdk","@google/generative-ai","@ai-sdk/openai","@ai-sdk/anthropic","langchain","@huggingface/inference","cohere-ai","ollama","groq-sdk","@mistralai/mistralai")||l("openai")||l("anthropic")||l("langchain")||l("litellm")||l("google-generativeai")||l("cohere")||l("ollama"))&&e("type:ai-app"),(P(".sol")||k("hardhat.config.js","hardhat.config.ts","foundry.toml","truffle-config.js","Anchor.toml","Move.toml")||i("hardhat","ethers","web3","@solana/web3.js","wagmi","viem","@openzeppelin/contracts"))&&e("type:smart-contract"),(k("project.godot","ProjectSettings")||P(".unity")||P(".uproject")||i("phaser","kaplay","kaboom","excalibur","playcanvas")||m.includes("bevy")||m.includes("macroquad")||m.includes("ggez")||l("pygame")||l("arcade"))&&e("type:game");{let w=f("manifest.json");(w&&Object.prototype.hasOwnProperty.call(w,"manifest_version")||i("webextension-polyfill","@types/chrome","wxt","plasmo"))&&e("type:browser-extension");}(i("react-native","expo","nativescript")||n("pubspec.yaml")||P(".xcodeproj")||k("AndroidManifest.xml"))&&e("type:mobile-app"),(i("electron","@tauri-apps/api","@tauri-apps/cli","nw")||k("tauri.conf.json","src-tauri")||m.includes("tauri")||m.includes("egui")||l("pyqt5")||l("pyqt6")||l("pyside6")||l("kivy"))&&e("type:desktop-app"),(i("discord.js","telegraf","node-telegram-bot-api","@slack/bolt","probot","grammy")||l("discord.py")||l("python-telegram-bot")||l("slack-bolt")||l("slack_bolt")||l("aiogram")||l("pyrogram"))&&e("type:bot"),(k("dbt_project.yml","dagster.yaml")||i("@dagster-io/dagster","apache-airflow")||l("airflow")||l("dagster")||l("prefect")||l("dbt-core")||l("luigi")||l("kedro")||l("pyspark")||l("apache-beam"))&&e("type:data-pipeline"),(l("torch")||l("tensorflow")||l("keras")||l("jax")||l("scikit-learn")||l("sklearn")||l("xgboost")||l("lightgbm")||l("pytorch-lightning")||l("diffusers")||l("mlflow"))&&e("type:ml-model"),(P(".ipynb")||l("jupyter")||l("jupyterlab")||l("marimo")||n("notebooks"))&&e("type:notebook"),(k("mkdocs.yml","mkdocs.yaml","mint.json","docusaurus.config.js","docusaurus.config.ts","book.toml")||i("@docusaurus/core","vitepress","vuepress","nextra","@astrojs/starlight")||l("mkdocs")||l("sphinx"))&&e("type:documentation"),(k("hugo.toml","_config.yml",".eleventy.js","eleventy.config.js","astro.config.mjs","astro.config.ts","astro.config.js")||i("astro","gatsby","@11ty/eleventy","hexo","gridsome")||l("pelican"))&&e("type:static-site"),i("@medusajs/medusa","@saleor/sdk","@shopify/hydrogen","vendure","@vendure/core","snipcart","use-shopping-cart","swell-js")&&e("type:ecommerce"),(d.bin||i("commander","yargs","oclif","@oclif/core","cac","meow","inquirer","@clack/prompts","ink")||l("click")||l("typer")||l("docopt")||g.includes("spf13/cobra")||g.includes("urfave/cli")||m.includes("clap")||m.includes("structopt"))&&e("type:cli"),(k("pnpm-workspace.yaml","turbo.json","nx.json","lerna.json","rush.json")||Array.isArray(d.workspaces)||m.includes("[workspace]")||n("go.work"))&&e("type:monorepo");let T=i("next","react","vue","@angular/core","svelte","@sveltejs/kit","solid-js","nuxt","remix","@remix-run/react","preact","qwik"),R=i("express","fastify","@nestjs/core","koa","hapi","@hapi/hapi","hono")||l("fastapi")||l("django")||l("flask")||l("starlette")||l("sanic")||g.includes("gin-gonic/gin")||g.includes("labstack/echo")||g.includes("gofiber/fiber")||m.includes("axum")||m.includes("actix-web")||(c("pom.xml")+c("build.gradle")).toLowerCase().includes("spring-boot"),ve=Array.from(o).some(w=>["infra:postgres","infra:mysql","infra:mongodb","infra:supabase","infra:neon"].includes(w)),xe=i("next-auth","@clerk/nextjs","@auth0/auth0-react","passport","lucia","@workos-inc/node")||l("django-allauth")||l("flask-login"),Ce=i("stripe","@stripe/stripe-js","@paddle/paddle-js","@lemonsqueezy/lemonsqueezy.js")||l("stripe");(!T&&!R&&(d.main||d.exports||d.module||d.types||d.publishConfig)||n("Cargo.toml")&&!m.includes("[[bin]]")&&m.includes("[lib]")||k("LICENSE","LICENSE.md","LICENSE.txt")&&!T&&!R&&!j())&&!j()&&e("type:library"),T?(ve&&(xe||Ce)&&e("type:saas"),e("type:web-app")):R&&(ve&&(xe||Ce)&&e("type:saas"),e("type:api-service")),j()||(se()?e("type:web-app"):k("Dockerfile","docker-compose.yml","compose.yaml")||r.some(w=>w.endsWith(".tf"))||k("Chart.yaml","kustomization.yaml","wrangler.toml","serverless.yml",".github")||i("@pulumi/pulumi","aws-cdk-lib","cdktf")?e("type:devops-tool"):n("package.json")&&(d.main||d.exports)&&e("type:library"));}return Array.from(o)}function Ne(t){let o={sponsorLabel:t.sponsorLabel,title:t.creative.title,body:t.creative.body,url:t.clickUrl};return t.creative.cta!==void 0&&(o.cta=t.creative.cta),o}function $e(t){return {sponsorLabel:"",title:t.title,body:t.body,url:t.url}}function K(t){let o=Ne(t),e=t.creative;switch(e.format){case "image":case "gif":return {...o,body:e.textFallback??o.body};case "video":return {...o,body:e.textFallback??o.body,cta:o.cta??"\u25B6 Watch"};case "audio":return {...o,body:e.textFallback??o.body,cta:o.cta??"\u{1F50A} Listen"};default:return o}}function H(t=process.env){return b__namespace.join(N__namespace.homedir(),".config","opencrater")}function V(t=process.env){return b__namespace.join(H(t),"state.json")}function Y(){return {installId:crypto.randomUUID(),lastShownAt:0,optOut:false,disclosureShown:false,cachedConfig:null,configFetchedAt:0,pool:[],allowedPlacements:{},sessionTopics:[],integrations:[],devToken:null,computeRouting:null,computeCards:null}}function E(t){return typeof t=="number"&&Number.isFinite(t)}var Le=new Set(["EPERM","EACCES","EBUSY","EEXIST"]);function De(t){for(let o=0;;o++)try{return {text:h__namespace.readFileSync(t,"utf8")}}catch(e){let r=e.code??"";if(!(r==="ENOENT"||Le.has(r)))return {locked:true};if(o>=4)return r==="ENOENT"?{missing:true}:{locked:true};try{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,15*(o+1));}catch{}}}function vt(t){if(typeof t!="object"||t===null)return null;let o=t;return !E(o.minIntervalSeconds)||!E(o.serveTimeoutMs)||!E(o.preloadPoolSize)||typeof o.killSwitch!="boolean"?null:{minIntervalSeconds:o.minIntervalSeconds,serveTimeoutMs:o.serveTimeoutMs,preloadPoolSize:o.preloadPoolSize,killSwitch:o.killSwitch,displayDurationSeconds:E(o.displayDurationSeconds)?o.displayDurationSeconds:25,minSdkVersion:typeof o.minSdkVersion=="string"?o.minSdkVersion:""}}function xt(t){if(!Array.isArray(t))return [];let o=[];for(let e of t){if(typeof e!="object"||e===null)continue;let r=e,n=r.blip;if(!E(r.renderBy)||typeof n!="object"||n===null||typeof n.impressionId!="string"||typeof n.clickUrl!="string"||typeof n.sponsorLabel!="string"||typeof n.creative!="object"||n.creative===null)continue;let c=n.creative;typeof c.title!="string"||typeof c.body!="string"||o.push({blip:{impressionId:n.impressionId,...typeof n.campaignId=="string"?{campaignId:n.campaignId}:{},clickUrl:n.clickUrl,sponsorLabel:n.sponsorLabel,creative:{format:"text",title:c.title,body:c.body,...typeof c.cta=="string"?{cta:c.cta}:{}}},renderBy:r.renderBy});}return o}function Ct(t){if(typeof t!="object"||t===null||Array.isArray(t))return {};let o={};for(let[e,r]of Object.entries(t)){if(!Array.isArray(r))continue;let n=r.filter(c=>typeof c=="string"&&c.length<=64);o[e]=n.slice(0,64);}return o}function Tt(t){if(!Array.isArray(t))return [];let o=[];for(let e of t){if(typeof e!="object"||e===null)continue;let r=e;if(!(typeof r.topic!="string"||!E(r.at))&&(o.push({topic:r.topic.slice(0,32),at:r.at}),o.length>=24))break}return o}function jt(t){if(!Array.isArray(t))return [];let o=[],e=new Set;for(let r of t){if(typeof r!="object"||r===null)continue;let n=r;if(typeof n.key!="string"||typeof n.package!="string"||n.key===""||n.package==="")continue;let c=`${n.package}\0${n.key}`;if(!e.has(c)&&(e.add(c),o.push({key:n.key,package:n.package}),o.length>=32))break}return o}function Rt(t){if(typeof t!="object"||t===null)return null;let o=t,e={};if(typeof o.savedEnv=="object"&&o.savedEnv!==null)for(let[r,n]of Object.entries(o.savedEnv))(typeof n=="string"||n===null)&&(e[r]=n);return {active:o.active===true,savedEnv:e}}function Et(t){if(typeof t!="object"||t===null)return null;let o=t,e=r=>E(r)&&r>=0?r:0;return {turns:e(o.turns),lastLimitAt:e(o.lastLimitAt),lastDepletedAt:e(o.lastDepletedAt),lastBackupAt:e(o.lastBackupAt)}}function _t(t){let o=t.attrTagsAt,e=t.attrTagsCwd;return !E(o)||Date.now()-o>J||typeof e!="string"||e.length===0||e.length>64?{}:{attrTags:Array.isArray(t.attrTags)?t.attrTags.filter(n=>typeof n=="string"&&n.length<=40).slice(0,48):[],attrTagsCwd:e,attrTagsAt:o}}function Ot(t){let o=Y();if(typeof t!="object"||t===null)return o;let e=t;return {installId:typeof e.installId=="string"&&e.installId.length>0?e.installId:o.installId,lastShownAt:E(e.lastShownAt)&&e.lastShownAt>=0?e.lastShownAt:0,optOut:e.optOut===true,disclosureShown:e.disclosureShown===true,cachedConfig:vt(e.cachedConfig),allowedPlacements:Ct(e.allowedPlacements),sessionTopics:Tt(e.sessionTopics),integrations:jt(e.integrations),devToken:typeof e.devToken=="string"?e.devToken:null,computeRouting:Rt(e.computeRouting),computeCards:Et(e.computeCards),configFetchedAt:E(e.configFetchedAt)&&e.configFetchedAt>=0?e.configFetchedAt:0,pool:xt(e.pool),..._t(e)}}function le(t=process.env){let o=V(t),e=De(o);if(e.text!==void 0)try{return Ot(JSON.parse(e.text))}catch{let r=Y();try{C(r,t);}catch{}return r}if(e.missing){let r=Y();try{C(r,t);}catch{}return r}return Y()}function C(t,o=process.env,e={}){let r=V(o),n=b__namespace.dirname(r);h__namespace.mkdirSync(n,{recursive:true});let c=De(r),f=null;if(c.text!==void 0)try{f=JSON.parse(c.text);}catch{f=null;}if(f)typeof f.lastShownAt=="number"&&f.lastShownAt>t.lastShownAt&&(t={...t,lastShownAt:f.lastShownAt}),!e.allowClearToken&&typeof f.devToken=="string"&&t.devToken==null&&(t={...t,devToken:f.devToken}),typeof f.installId=="string"&&f.installId.length>0&&f.installId!==t.installId&&(t={...t,installId:f.installId});else if(!e.allowClearToken&&t.devToken==null&&c.text===void 0&&!c.missing)return;let d=b__namespace.join(n,`.state.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`);h__namespace.writeFileSync(d,JSON.stringify(t,null,2)+`
5
+ `,"utf8");for(let p=0;;p++)try{h__namespace.renameSync(d,r);return}catch(a){let u=a.code??"";if(p>=4||!Le.has(u)){try{h__namespace.rmSync(d,{force:!0});}catch{}if(p>=4)return;throw a}try{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,15*(p+1));}catch{}}}var At=300*1e3;function Pt(){return b__namespace.join(H(),"blocked-ads.json")}function fe(){return b__namespace.join(H(),"recent-renders.json")}function It(){return b__namespace.join(H(),"reported-ads.json")}function We(t,o){let e={};for(let[r,n]of Object.entries(t))typeof n=="number"&&Number.isFinite(n)&&n>o&&(e[r]=n);return e}function Nt(t){try{let o=JSON.parse(h__namespace.readFileSync(Pt(),"utf8"));return We(o&&typeof o=="object"?o:{},t)}catch{return {}}}function $t(){try{let t=JSON.parse(h__namespace.readFileSync(It(),"utf8"));return t&&typeof t=="object"?t:{}}catch{return {}}}function Mt(t){return t?$t()[t]!==void 0:false}function X(t,o=Date.now()){return t?Nt(o)[t]!==void 0||Mt(t):false}function Be(t){try{let o=JSON.parse(h__namespace.readFileSync(fe(),"utf8"));return We(o&&typeof o=="object"?o:{},t)}catch{return {}}}function Z(t,o=Date.now()){if(t)try{let e=Be(o);e[t]=o+At,h__namespace.mkdirSync(b__namespace.dirname(fe()),{recursive:!0}),h__namespace.writeFileSync(fe(),JSON.stringify(e));}catch{}}function Q(t,o=Date.now()){return t?Be(o)[t]!==void 0:false}function Lt(t,o){return t.filter(e=>e.renderBy>o)}function ue(t,o){let e=Lt(t.pool,o),r=e.shift();return {blip:r?r.blip:null,pool:e}}var Dt=["claude_code","codex","antigravity","copilot_cli","grok_cli"];function ze(t){return t.includes("opencrater-hook")||/opencrater[\\/][^"']*hook\.js/.test(t)}function Wt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Bt(t,o){return ze(t)&&new RegExp(`--package ['"]?${Wt(o)}['"]?`).test(t)}function Ge(t,o){return o?Bt(t,o):ze(t)&&!/--package\b/.test(t)}function He(t){return /^[A-Za-z0-9@_./:-]+$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`}var Ue='"$HOME/.config/opencrater/runtime/node_modules/opencrater/dist/hook.js"',Fe="$env:USERPROFILE\\.config\\opencrater\\runtime\\node_modules\\opencrater\\dist\\hook.js";function U(t,o,e,r){let n=`--placement ${o}`;return e&&(n+=` --key ${He(e)}`),r&&(n+=` --package ${He(r)}`),n+=` --host ${t}`,`{ if [ -f ${Ue} ]; then node ${Ue} ${n}; else npx -y -p opencrater opencrater-hook ${n}; fi; } 2>/dev/null || true`}function Ht(t,o,e){if(process.platform!=="win32")return U("grok_cli",t,o,e);let r=`--placement ${t}`;o&&(r+=` --key ${o}`),e&&(r+=` --package ${e}`),r+=" --host grok_cli";let n=`${N__namespace.homedir()}\\.config\\opencrater\\runtime\\node_modules\\opencrater\\dist\\hook.js`;return `try { if (Test-Path "${n}") { node "${n}" ${r} } else { npx -y -p opencrater opencrater-hook ${r} } } catch {}`}function Je(t,o,e,r){let n=`--placement ${o}`;return e&&(n+=` --key '${e}'`),r&&(n+=` --package '${r}'`),n+=` --host ${t}`,`try { if (Test-Path "${Fe}") { node "${Fe}" ${n} } else { npx -y -p opencrater opencrater-hook ${n} } } catch {}`}function Ut(t,o,e){if(process.platform!=="win32")return U("claude_code",t,o,e);let r=`--placement ${t}`;return o&&(r+=` --key ${o}`),e&&(r+=` --package ${e}`),r+=" --host claude_code",`node "${`${N__namespace.homedir()}\\.config\\opencrater\\runtime\\node_modules\\opencrater\\dist\\hook.js`}" ${r}; exit 0`}function de(t,o,e,r){if(t==="grok_cli")return {type:"command",command:Ht(o,e,r),timeout:15};let c={type:"command",command:t==="claude_code"?Ut(o,e,r):U(t,o,e,r)};return t==="codex"&&(c.commandWindows=Je(t,o,e,r)),c}function pe(t,o){let e=N__namespace.homedir();switch(t){case "claude_code":{let r=o.CLAUDE_CONFIG_DIR;return r&&r.trim()!==""?r:b__namespace.join(e,".claude")}case "codex":{let r=o.CODEX_HOME;return r&&r.trim()!==""?r:b__namespace.join(e,".codex")}case "antigravity":return b__namespace.join(e,".gemini");case "copilot_cli":{let r=o.COPILOT_HOME;return r&&r.trim()!==""?r:b__namespace.join(e,".copilot")}case "grok_cli":{let r=o.GROK_HOME;return r&&r.trim()!==""?r:b__namespace.join(e,".grok")}default:return b__namespace.join(e,".opencrater-unknown")}}function te(t,o=process.env){let e=pe(t,o);switch(t){case "claude_code":return b__namespace.join(e,"settings.json");case "codex":return b__namespace.join(e,"hooks.json");case "antigravity":return b__namespace.join(e,"settings.json");case "copilot_cli":return b__namespace.join(e,"hooks","hooks.json");case "grok_cli":return b__namespace.join(e,"hooks","opencrater.json");default:return b__namespace.join(e,"hooks.json")}}var Ft={claude_code:["claude"],codex:["codex"],antigravity:["agy"],copilot_cli:["copilot"],grok_cli:["grok"]};function qt(t,o){if(t.length===0)return false;let e=(o.PATH??o.Path??"").split(b__namespace.delimiter).filter(Boolean),r=process.platform==="win32"?["",".exe",".cmd",".bat"]:[""];for(let n of e)for(let c of t)for(let f of r)try{if(h__namespace.existsSync(b__namespace.join(n,c+f)))return !0}catch{}return false}function zt(t,o=process.env){try{if(h__namespace.existsSync(pe(t,o)))return !0}catch{}return qt(Ft[t]??[],o)}function me(t=process.env){return Dt.filter(o=>zt(o,t))}function Ke(t){let o;try{o=h__namespace.readFileSync(t,"utf8");}catch{return {}}let e=JSON.parse(o);if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`${t} is not a JSON object`);return e}function Ye(t,o){let e=b__namespace.dirname(t);h__namespace.mkdirSync(e,{recursive:true});let r=b__namespace.join(e,`.${b__namespace.basename(t)}.${process.pid}.tmp`);h__namespace.writeFileSync(r,JSON.stringify(o,null,2)+`
6
+ `,"utf8"),h__namespace.renameSync(r,t);}function Gt(t,o){return Array.isArray(t.hooks)&&t.hooks.some(e=>typeof e.command=="string"&&Ge(e.command,o))}function Jt(t,o,e,r){let n=te(t),c=Ke(n),f=c.hooks&&typeof c.hooks=="object"?c.hooks:{};if(!(t==="antigravity"&&c["json-hooks-enabled"]!==true)&&r.every(a=>{let u=de(t,a,o,e);return (Array.isArray(f[a])?f[a]:[]).some(s=>Array.isArray(s.hooks)&&s.hooks.some(i=>i.command===u.command&&i.commandWindows===u.commandWindows))}))return "nochange";for(let a of r){let s=(Array.isArray(f[a])?f[a]:[]).filter(y=>!Gt(y,e)),i=t==="grok_cli"?{hooks:[de(t,a,o,e)]}:{matcher:"",hooks:[de(t,a,o,e)]};s.push(i),f[a]=s;}return t==="antigravity"&&(c["json-hooks-enabled"]=true),c.hooks=f,Ye(n,c),"wrote"}var qe=12;function Kt(t,o){return [t.bash,t.powershell,t.command].some(e=>typeof e=="string"&&Ge(e,o))}function Yt(t,o,e,r){let n=te(t),c=Ke(n);typeof c.version!="number"&&(c.version=1);let f=c.hooks&&typeof c.hooks=="object"?c.hooks:{};if(r.every(p=>{let a=U(t,p,o,e);return (Array.isArray(f[p])?f[p]:[]).some(u=>u.bash===a&&u.timeoutSec===qe)}))return "nochange";for(let p of r){let u=(Array.isArray(f[p])?f[p]:[]).filter(s=>!Kt(s,e));u.push({type:"command",bash:U(t,p,o,e),powershell:Je(t,p,o,e),timeoutSec:qe}),f[p]=u;}return c.hooks=f,Ye(n,c),"wrote"}function Ve(t){return [...je[t]]}function Vt(t){let o=t;for(let e of ["claude","cursor"]){if(new RegExp(`^\\s*\\[compat\\.${e}\\]`,"m").test(o))continue;let r=o.length===0?"":o.endsWith(`
7
7
  `)?`
8
8
  `:`
9
9
 
10
10
  `;o+=`${r}[compat.${e}]
11
11
  hooks = false
12
- `;}return o}function Xt(t){try{let o=b__namespace.join(pe("grok_cli",t),"config.toml"),e="";try{e=h__namespace.readFileSync(o,"utf8");}catch{}let r=Vt(e);if(r===e)return;h__namespace.mkdirSync(b__namespace.dirname(o),{recursive:!0}),h__namespace.writeFileSync(o,r,"utf8");}catch{}}function Zt(t,o,e){let r=Ve(t);return r.length===0?"nochange":(t==="grok_cli"&&Xt(process.env),t==="copilot_cli"?Yt(t,o,e,r):Jt(t,o,e,r))}function ge(t,o,e=process.env){return me(e).map(r=>{try{let n=Zt(r,t,o);return {host:r,status:n,events:Ve(r)}}catch(n){return {host:r,status:"error",events:[],error:n.message}}})}function en(){return b__namespace.join(I__namespace.homedir(),".config","opencrater","runtime")}function tn(t){return ["install","--prefix",t,"opencrater@latest","--silent","--no-audit","--no-fund"]}function he(t=en()){child_process.spawn("npm",tn(t),process.platform==="win32"?{detached:false,stdio:"ignore",windowsHide:true,shell:true}:{detached:true,stdio:"ignore"}).unref();}var et={atLimit:false,resetAt:null};function tt(t,o=I__namespace.homedir()){try{if(t==="claude_code")return nn(o);if(t==="codex")return on(o)}catch{}return et}function nn(t){let o=h__namespace.readFileSync(b__namespace.join(t,".claude.json"),"utf8"),e=JSON.parse(o),r=e.hasAvailableSubscription===false||e.cachedExtraUsageDisabledReason==="out_of_credits",n=null,u=e.cachedGrowthBookFeatures?.tengu_saffron_lattice?.planLimitsEndDate;if(typeof u=="string"){let d=Date.parse(u);Number.isFinite(d)&&(n=d);}return {atLimit:r,resetAt:n}}function on(t){return h__namespace.accessSync(b__namespace.join(t,".codex","auth.json")),et}function nt(t,o){switch(t){case "antigravity":return o==="AfterAgent";case "copilot_cli":return o==="agentStop";default:return o==="Stop"}}var ot=36e5,rn=30*6e4,sn=30*6e4,an=4*ot,cn=3,ne="https://opencrater.to/dashboard";function F(t){return `${Math.round(t/1e3).toLocaleString()} tokens`}function ln(t){let o=t/1e3;return o>0&&o<10?`${(Math.round(o*10)/10).toFixed(1)} tokens`:`${Math.round(o).toLocaleString()} tokens`}function fn(t){switch(t){case "claude_code":return {name:"Claude Code",launch:"opencrater claude",resume:"opencrater claude -c"};case "codex":return {name:"Codex",launch:"opencrater codex",resume:"opencrater codex -c"};case "grok_cli":return {name:"Grok",launch:"opencrater grok",resume:"opencrater grok -c"};default:return null}}var oe="opencrater claude";function un(t,o){if(!t||t<=o)return "";let e=t-o,r=e>=864e5?`${Math.floor(e/864e5)}d`:`${Math.max(1,Math.floor(e/ot))}h`,n=new Date(t).toISOString().slice(0,10);return ` Your host limit resets in ${r} (${n}).`}function rt(t){let{balanceMicroUsd:o,pendingMicroUsd:e,onGateway:r,turnEnd:n,hostName:c,host:f,cc:u,now:d}=t;if(o===null)return null;let a=fn(c),p=e&&e>0?` (+${ln(e)} pending)`:"";return o<=0?d-(u.lastDepletedAt??0)<sn?null:{kind:"depleted",card:{sponsorLabel:"OpenCrater",title:"Compute used up",body:`Keep coding in any CLI to earn more compute, then switch back to ${a?.name??"your plan"}.`+un(f.resetAt,d),url:ne,cta:"Earn more"}}:r?!n||(u.turns??0)%cn!==0?null:{kind:"hud",card:{sponsorLabel:"OpenCrater",title:"Running on OpenCrater compute",body:`${F(o)} compute available${p}.`,url:ne,cta:"Wallet"}}:f.atLimit?d-(u.lastLimitAt??0)<rn?null:{kind:"limit",card:{sponsorLabel:"OpenCrater",title:"Hit your limit? You've got compute",body:a?`${F(o)} of OpenCrater compute is ready. Continue this ${a.name} session now: ${a.resume}`:`${F(o)} of OpenCrater compute is ready. Run your coding agent on it: ${oe}`,url:ne,cta:a?a.resume:oe}}:d-(u.lastBackupAt??0)>=an?{kind:"backup",card:{sponsorLabel:"OpenCrater",title:"Backup compute ready",body:a?`${F(o)} of OpenCrater compute waiting${p}. When you hit your limit: ${a.resume}`:`${F(o)} of OpenCrater compute waiting${p}. Spend it any time: ${oe}`,url:ne,cta:a?a.resume:oe}}:null}var gn=["CI","CONTINUOUS_INTEGRATION","GITHUB_ACTIONS","GITLAB_CI","CIRCLECI","TRAVIS","BUILDKITE","JENKINS_URL","TEAMCITY_VERSION","TF_BUILD","APPVEYOR","CODEBUILD_BUILD_ID","DRONE","NETLIFY","VERCEL"];function be(t){return t!==void 0&&t!==""&&t!=="0"&&t.toLowerCase()!=="false"}function hn(t){return be(t.OPENCRATER_DISABLE)||be(t.TSN_DISABLE)}function yn(t){return gn.some(o=>be(t[o]))}function ie(t){return t?{...B,...t}:B}function ut(t,o={}){if(hn(t.env))return "env_disabled";if(t.state.optOut)return "opt_out";let e=ie(t.state.cachedConfig);if(e.killSwitch)return "kill_switch";if(yn(t.env))return "ci";if(!o.skipTTY&&false);if(!o.skipFrequency){let r=e.minIntervalSeconds*1e3;if(t.state.lastShownAt>0&&t.now-t.state.lastShownAt<r)return "frequency"}return null}var bn=new Set(["the","and","for","but","not","you","all","any","can","this","that","with","have","will","your","from","they","what","when","where","how","why","make","fix","add","update","remove","create","delete","change","error","errors","bug","bugs","file","files","code","test","tests","run","running","build","please","help","want","need","should","would","could","into","about","then","here","there","now","new","use","using","used","work","working","works","check","show","see","look","get","set","let","lets","dont","cant","issue"]);function kn(t){if(t.includes("/")||t.includes("\\")||t.includes("@")||t.includes("://"))return true;let o=t.toLowerCase();return !!(/^(sk|pk|rk|ock|ghp|gho|ghs|xox|akia|eyj|npm|glpat)[-_]/.test(o)||t.length>=16&&/^[0-9a-f]+$/i.test(t)||t.length>=20&&/^[A-Za-z0-9+/=_-]+$/.test(t)&&/[A-Z]/.test(t)&&/[0-9]/.test(t))}function wn(t,o=12){let e=[];for(let r of t.slice(0,2e3).split(/\s+/))if(!(!r||kn(r)))for(let n of r.split(/[^A-Za-z0-9+#.]+|(?<=[a-z0-9])(?=[A-Z])/)){let c=n.replace(/^[.]+|[.]+$/g,"").toLowerCase();if(!(c.length<3||c.length>24)&&!(/^\d+$/.test(c)||bn.has(c))&&!e.includes(c)&&(e.push(c),e.length>=o))return e}return e}function ke(t){let o=[];typeof t.prompt=="string"&&o.push(t.prompt);let e=t.cwd;if(typeof e=="string"&&e.length>0){let r=e.replace(/[\\/]+$/,""),n=r.split(/[\\/]/).pop()??"",c=(process.env.HOME??process.env.USERPROFILE??"").replace(/[\\/]+$/,""),f=process.env.USER??process.env.USERNAME??"";r!==c&&n!==f&&n.length>0&&o.push(n.replace(/[-_]/g," "));}return wn(o.join(" "))}function we(t,o,e){let r=new Map;for(let{topic:n,at:c}of t)e-c<216e5&&r.set(n,c);for(let n of o)r.set(n,e);return [...r.entries()].map(([n,c])=>({topic:n,at:c})).sort((n,c)=>c.at-n.at).slice(0,24)}function dt(t,o){return t.filter(({at:e})=>o-e<216e5).sort((e,r)=>r.at-e.at).slice(0,12).map(({topic:e})=>e)}var xn=false,Cn=process.platform==="win32"?8e3:3200,Tn=150,jn=2800,Se="claude_code";function Rn(t){let o={host:"claude_code"};for(let e=0;e<t.length;e++){let r=t[e],n=t[e+1];switch(r){case "--placement":n!==void 0&&(o.placement=n,e++);break;case "--key":n!==void 0&&(o.key=n,e++);break;case "--package":n!==void 0&&(o.package=n,e++);break;case "--host":(n==="claude_code"||n==="codex"||n==="openclaw"||n==="antigravity"||n==="copilot_cli"||n==="grok_cli"||n==="generic")&&(o.host=n,e++);break;}}return o}function En(t){return new Promise(o=>{if(process.stdin.isTTY){o("");return}let e="",r=false,n=()=>{r||(r=true,o(e));},c=setTimeout(n,t);c.unref?.(),process.stdin.setEncoding("utf8"),process.stdin.on("data",f=>{e+=f;}),process.stdin.on("end",()=>{clearTimeout(c),n();}),process.stdin.on("error",()=>{clearTimeout(c),n();});})}var _n="\\\\.\\CONOUT$";function On(t){return !t||t==="?"||t==="??"||t==="-"?null:t.startsWith("/")?t:`/dev/${t}`}function An(t){let o=t.match(/^\s*(\d+)\s+(\S+)/);return o?{ppid:Number(o[1]),tty:o[2]}:null}function Pn(t){if(!Number.isInteger(t)||t<=0)return null;let o=t>>8&4095,e=t&255|t>>12&1048320;return o>=136&&o<=143?`/dev/pts/${(o-136)*256+e}`:o===4?e<64?`/dev/tty${e}`:`/dev/ttyS${e-64}`:null}function In(t){let o=t.lastIndexOf(")");if(o<0)return null;let e=t.slice(o+1).trim().split(/\s+/),r=Number(e[1]),n=Number(e[4]);return !Number.isInteger(r)||!Number.isInteger(n)?null:{ppid:r,ttyNr:n}}function Nn(t){try{let o=In(h__namespace.readFileSync(`/proc/${t}/stat`,"utf8"));if(o)return {ppid:o.ppid,ttyPath:Pn(o.ttyNr)}}catch{}try{let o=child_process.spawnSync("ps",["-o","ppid=,tty=","-p",String(t)],{encoding:"utf8",timeout:1500}).stdout?.trim();if(!o)return null;let e=An(o);return e?{ppid:e.ppid,ttyPath:On(e.tty)}:null}catch{return null}}function $n(){if(process.platform==="win32")return {path:_n,ownerPid:null};let t=process.pid;for(let o=0;o<12&&t>1;o++){let e=Nn(t);if(!e)return null;if(e.ttyPath)return {path:e.ttyPath,ownerPid:t};t=e.ppid;}return null}function Mn(t){return t==="win32"?{detached:false,stdio:"ignore",windowsHide:false}:{detached:true,stdio:"ignore",windowsHide:false}}async function q(t,o,e,r,n,c){try{let f=b__namespace.join(__dirname,"paint.js"),u,d;if(c&&r){let g=G();c.kind==="dev"?(u=`${g}/v1/dev/impression`,d=c.token):u=`${g}/v1/events/impression`;}let a=ie(o.cachedConfig),p=Math.min(Math.max(a.displayDurationSeconds??25,3),120),s={...t,format:e?.format,mediaUrl:e?.mediaUrl,mediaPixelUrl:e?.mediaPixelUrl,audioUrl:e?.audioUrl,impressionId:r,campaignId:n,apiOrigin:G(),reportImpressionUrl:u,reportImpressionAuth:d,durationMs:p*1e3,disclosure:!o.disclosureShown,host:Se},i={...process.env,OPENCRATER_PAINT:JSON.stringify(s)};if(!i.OPENCRATER_TTY){let g=$n();g&&(i.OPENCRATER_TTY=g.path,g.ownerPid!==null&&(i.OPENCRATER_HOST_PID=String(g.ownerPid)));}let y=child_process.spawn(process.execPath,[f],{...Mn(process.platform),env:i});process.platform==="win32"?await new Promise(g=>{let m=!1,l=()=>{m||(m=!0,g());};y.on("exit",l),y.on("error",l),setTimeout(l,7500);}):y.unref();}catch{}return {...o,lastShownAt:Date.now(),disclosureShown:true}}function pt(t){if(process.platform!=="win32")return false;try{let o=b__namespace.join(I__namespace.homedir(),".config","opencrater","painter.lock"),e=JSON.parse(h__namespace.readFileSync(o,"utf8"));if(typeof e.startedAt!="number"||Date.now()-e.startedAt>t+1500)return !1;if(typeof e.pid=="number")try{process.kill(e.pid,0);}catch(r){if(r.code==="ESRCH")return !1}return !0}catch{return false}}var Ln=8e3;function mt(){let t=b__namespace.join(I__namespace.homedir(),".config","opencrater","render.lock");try{let o=h__namespace.statSync(t);if(Date.now()-o.mtimeMs<Ln)return !1;h__namespace.unlinkSync(t);}catch{}try{return h__namespace.mkdirSync(b__namespace.join(I__namespace.homedir(),".config","opencrater"),{recursive:!0}),h__namespace.writeFileSync(t,String(process.pid),{flag:"wx"}),!0}catch{return false}}function Dn(t,o,e,r){if(!o)return true;let n=t.allowedPlacements[`${o}:${e}`];return n?n.includes(r):o==="opencrater"?Te[e].includes(r):true}var Wn=1440*60*1e3;function Bn(){try{let t=b__namespace.join(I__namespace.homedir(),".config","opencrater","runtime"),o=b__namespace.join(t,"node_modules","opencrater","dist","hook.js"),e=b__namespace.join(t,".last-update");if(h__namespace.existsSync(o)){try{if(Date.now()-h__namespace.statSync(e).mtimeMs<Wn)return}catch{}try{h__namespace.writeFileSync(e,String(Date.now()));}catch{return}}else {let r=b__namespace.join(t,".installing");try{h__namespace.mkdirSync(t,{recursive:!0});let n=h__namespace.statSync(r);if(Date.now()-n.mtimeMs<600*1e3)return}catch{}h__namespace.writeFileSync(r,String(Date.now()));}he(t);}catch{}}function gt(t,o){if(!o)return false;let e=f=>f.split(/[-+]/)[0].split(".").map(u=>parseInt(u,10)||0),r=e(t),n=e(o),c=Math.max(r.length,n.length);for(let f=0;f<c;f++){let u=r[f]??0,d=n[f]??0;if(u!==d)return u<d}return false}function ht(){try{let t=b__namespace.join(I__namespace.homedir(),".config","opencrater","runtime"),o=b__namespace.join(t,".last-update"),e=b__namespace.join(t,".force-update");try{if(Date.now()-h__namespace.statSync(e).mtimeMs<600*1e3)return}catch{}h__namespace.mkdirSync(t,{recursive:!0}),h__namespace.writeFileSync(e,String(Date.now()));try{h__namespace.rmSync(o,{force:!0});}catch{}he(t);}catch{}}function Hn(){try{let t=b__namespace.join(I__namespace.homedir(),".config","opencrater");h__namespace.mkdirSync(t,{recursive:!0}),h__namespace.writeFileSync(b__namespace.join(t,"activity.signal"),String(Date.now()));}catch{}}var Un=1440*60*1e3;function Fn(){try{let t=b__namespace.join(I__namespace.homedir(),".config","opencrater"),o=b__namespace.join(t,".last-host-check"),e=b__namespace.join(t,".known-hosts"),r=me().sort(),n=[];try{let u=JSON.parse(h__namespace.readFileSync(e,"utf8"));Array.isArray(u)&&(n=u.filter(d=>typeof d=="string"));}catch{}if(!r.some(u=>!n.includes(u)))try{if(Date.now()-h__namespace.statSync(o).mtimeMs<Un)return}catch{}h__namespace.mkdirSync(t,{recursive:!0});try{h__namespace.writeFileSync(o,String(Date.now()));}catch{return}let f=le();try{h__namespace.writeFileSync(e,JSON.stringify(r));}catch{}if(f.optOut)return;if(f.devToken)try{ge();}catch{}for(let u of f.integrations)try{ge(u.key,u.package);}catch{}}catch{}}async function qn(){let t=Rn(process.argv.slice(2));if(Se=t.host,process.env.GROK_HOOK_EVENT&&Se!=="grok_cli")return;Hn(),Bn(),Fn();let o=await En(Tn),e={};if(o)try{e=JSON.parse(o);let m=e.hook_event_name;!t.placement&&typeof m=="string"&&(t.placement=m);}catch{}let r=t.placement??"SessionStart",n=le();x(`state=${V()} devToken=${n.devToken?"present":"MISSING"}`,`host=${t.host} placement=${r}`);let c=ut({env:process.env,state:n,now:Date.now()},{skipTTY:true});if(c!==null){if(c==="frequency"){let m=ke(e);m.length>0&&C({...n,sessionTopics:we(n.sessionTopics,m,Date.now())});}x("hook suppressed:",c);return}if(n={...n,sessionTopics:we(n.sessionTopics,ke(e),Date.now())},!Dn(n,t.package,t.host,r)){C(n),x("hook gated: placement",r,"not selected for",t.package);return}let f=ie(n.cachedConfig),u=G(),d=typeof e?.cwd=="string"&&e.cwd||process.cwd(),a=Pe(d),p=n.attrTags??[];if(n.attrTagsCwd!==a||!n.attrTagsAt||Date.now()-n.attrTagsAt>J){try{p=Ie(d);}catch{p=[];}n={...n,attrTags:p,attrTagsCwd:a,attrTagsAt:Date.now()};}let s={origin:u,timeoutMs:Math.min(f.serveTimeoutMs,jn),installId:n.installId,topics:dt(n.sessionTopics,Date.now()),tags:p};if(n.devToken){let m=await Ae(n.devToken,{publisherKey:t.key??"",packageName:t.package??"",placement:r,host:t.host},s);if(m){if(n={...n,cachedConfig:m.config,configFetchedAt:Date.now()},gt(N,m.config.minSdkVersion)&&ht(),xn);let l=t.host??"claude_code",A=nt(l,r),k=n.computeCards??{turns:0,lastLimitAt:0,lastDepletedAt:0,lastBackupAt:0};A&&(k.turns+=1);let j=rt({balanceMicroUsd:typeof m.computeBalanceMicroUsd=="number"?m.computeBalanceMicroUsd:null,weeklyGrantMicroUsd:typeof m.weeklyGrantMicroUsd=="number"?m.weeklyGrantMicroUsd:null,pendingMicroUsd:typeof m.pendingMicroUsd=="number"?m.pendingMicroUsd:null,onGateway:(process.env.ANTHROPIC_BASE_URL??"").includes("/gateway")||process.env.OPENCRATER_ON_GATEWAY==="1",turnEnd:A,hostName:l,host:tt(l),cc:k,now:Date.now()}),se=(m.config.displayDurationSeconds??25)*1e3,T=m.fill&&m.blip&&!X(m.blip.campaignId)&&!Q(m.blip.campaignId)?m.blip:null;if((j||T)&&!pt(se)&&mt())if(j){let R=Date.now();j.kind==="limit"?k.lastLimitAt=R:j.kind==="depleted"?k.lastDepletedAt=R:j.kind==="backup"&&(k.lastBackupAt=R),n=await q({...j.card,label:"OpenCrater"},n);}else T&&(Z(T.campaignId),n=await q(K(T),n,T.creative,T.impressionId,T.campaignId,n.devToken?{kind:"dev",token:n.devToken}:void 0));n={...n,computeCards:k};}C(n);return}let{blip:i,pool:y}=ue(n,Date.now());for(;i&&(X(i.campaignId)||Q(i.campaignId));)x("hook: pooled blip skipped \u2014 campaign inside a local cooldown"),{blip:i,pool:y}=ue({pool:y},Date.now());if((i||t.key)&&pt((f.displayDurationSeconds??25)*1e3)){C(n),x("hook: a card is already on screen \u2014 not rendering another");return}if((i||t.key)&&!mt()){C(n),x("hook: render slot already claimed by a concurrent fire");return}if(i){Z(i.campaignId),n=await q(K(i),{...n,pool:y},i.creative,i.impressionId,i.campaignId,{kind:"publisher"}),C(n);return}if(y.length!==n.pool.length&&(n={...n,pool:y}),!t.key||!t.package){C(n),x("hook: pool empty and no --key/--package; nothing to render");return}let g=await Oe({publisherKey:t.key,packageName:t.package,placement:r,host:t.host},s);if(!g){C(n);return}if(n={...n,cachedConfig:g.config,configFetchedAt:Date.now()},gt(N,g.config.minSdkVersion)&&(x(`SDK ${N} below floor ${g.config.minSdkVersion} \u2014 forcing runtime update`),ht()),t.package&&g.allowedPlacements&&(n={...n,allowedPlacements:{...n.allowedPlacements,[`${t.package}:${t.host}`]:g.allowedPlacements}}),g.fill&&g.blip){if(X(g.blip.campaignId)||Q(g.blip.campaignId)){x("hook: served blip suppressed \u2014 campaign inside a local cooldown"),C(n);return}Z(g.blip.campaignId),n=await q(K(g.blip),n,g.blip.creative,g.blip.impressionId,g.blip.campaignId,{kind:"publisher"}),C(n);return}g.fallback&&(n=await q($e(g.fallback),n)),C(n);}if(typeof M<"u"&&typeof module<"u"&&M.main===module){let t=setTimeout(()=>process.exit(0),Cn);qn().catch(o=>x(`opencrater-hook v${N} error:`,o)).finally(()=>{clearTimeout(t),process.exit(0);});}
12
+ `;}return o}function Xt(t){try{let o=b__namespace.join(pe("grok_cli",t),"config.toml"),e="";try{e=h__namespace.readFileSync(o,"utf8");}catch{}let r=Vt(e);if(r===e)return;h__namespace.mkdirSync(b__namespace.dirname(o),{recursive:!0}),h__namespace.writeFileSync(o,r,"utf8");}catch{}}function Zt(t,o,e){let r=Ve(t);return r.length===0?"nochange":(t==="grok_cli"&&Xt(process.env),t==="copilot_cli"?Yt(t,o,e,r):Jt(t,o,e,r))}function ge(t,o,e=process.env){return me(e).map(r=>{try{let n=Zt(r,t,o);return {host:r,status:n,events:Ve(r)}}catch(n){return {host:r,status:"error",events:[],error:n.message}}})}function en(){return b__namespace.join(N__namespace.homedir(),".config","opencrater","runtime")}function tn(t){return ["install","--prefix",t,"opencrater@latest","--silent","--no-audit","--no-fund"]}function he(t=en()){child_process.spawn("npm",tn(t),process.platform==="win32"?{detached:false,stdio:"ignore",windowsHide:true,shell:true}:{detached:true,stdio:"ignore"}).unref();}var et={atLimit:false,resetAt:null};function tt(t,o=N__namespace.homedir()){try{if(t==="claude_code")return nn(o);if(t==="codex")return on(o)}catch{}return et}function nn(t){let o=h__namespace.readFileSync(b__namespace.join(t,".claude.json"),"utf8"),e=JSON.parse(o),r=e.hasAvailableSubscription===false||e.cachedExtraUsageDisabledReason==="out_of_credits",n=null,d=e.cachedGrowthBookFeatures?.tengu_saffron_lattice?.planLimitsEndDate;if(typeof d=="string"){let p=Date.parse(d);Number.isFinite(p)&&(n=p);}return {atLimit:r,resetAt:n}}function on(t){return h__namespace.accessSync(b__namespace.join(t,".codex","auth.json")),et}function nt(t,o){switch(t){case "antigravity":return o==="AfterAgent";case "copilot_cli":return o==="agentStop";default:return o==="Stop"}}var ot=36e5,rn=30*6e4,sn=30*6e4,an=4*ot,cn=3,ne="https://opencrater.to/dashboard";function F(t){return `${Math.round(t/1e3).toLocaleString()} tokens`}function ln(t){let o=t/1e3;return o>0&&o<10?`${(Math.round(o*10)/10).toFixed(1)} tokens`:`${Math.round(o).toLocaleString()} tokens`}function fn(t){switch(t){case "claude_code":return {name:"Claude Code",launch:"opencrater claude",resume:"opencrater claude -c"};case "codex":return {name:"Codex",launch:"opencrater codex",resume:"opencrater codex -c"};case "grok_cli":return {name:"Grok",launch:"opencrater grok",resume:"opencrater grok -c"};default:return null}}var oe="opencrater claude";function un(t,o){if(!t||t<=o)return "";let e=t-o,r=e>=864e5?`${Math.floor(e/864e5)}d`:`${Math.max(1,Math.floor(e/ot))}h`,n=new Date(t).toISOString().slice(0,10);return ` Your host limit resets in ${r} (${n}).`}function rt(t){let{balanceMicroUsd:o,pendingMicroUsd:e,onGateway:r,turnEnd:n,hostName:c,host:f,cc:d,now:p}=t;if(o===null)return null;let a=fn(c),u=e&&e>0?` (+${ln(e)} pending)`:"";return o<=0?p-(d.lastDepletedAt??0)<sn?null:{kind:"depleted",card:{sponsorLabel:"OpenCrater",title:"Compute used up",body:`Keep coding in any CLI to earn more compute, then switch back to ${a?.name??"your plan"}.`+un(f.resetAt,p),url:ne,cta:"Earn more"}}:r?!n||(d.turns??0)%cn!==0?null:{kind:"hud",card:{sponsorLabel:"OpenCrater",title:"Running on OpenCrater compute",body:`${F(o)} compute available${u}.`,url:ne,cta:"Wallet"}}:f.atLimit?p-(d.lastLimitAt??0)<rn?null:{kind:"limit",card:{sponsorLabel:"OpenCrater",title:"Hit your limit? You've got compute",body:a?`${F(o)} of OpenCrater compute is ready. Continue this ${a.name} session now: ${a.resume}`:`${F(o)} of OpenCrater compute is ready. Run your coding agent on it: ${oe}`,url:ne,cta:a?a.resume:oe}}:p-(d.lastBackupAt??0)>=an?{kind:"backup",card:{sponsorLabel:"OpenCrater",title:"Backup compute ready",body:a?`${F(o)} of OpenCrater compute waiting${u}. When you hit your limit: ${a.resume}`:`${F(o)} of OpenCrater compute waiting${u}. Spend it any time: ${oe}`,url:ne,cta:a?a.resume:oe}}:null}var gn=["CI","CONTINUOUS_INTEGRATION","GITHUB_ACTIONS","GITLAB_CI","CIRCLECI","TRAVIS","BUILDKITE","JENKINS_URL","TEAMCITY_VERSION","TF_BUILD","APPVEYOR","CODEBUILD_BUILD_ID","DRONE","NETLIFY","VERCEL"];function be(t){return t!==void 0&&t!==""&&t!=="0"&&t.toLowerCase()!=="false"}function hn(t){return be(t.OPENCRATER_DISABLE)||be(t.TSN_DISABLE)}function yn(t){return gn.some(o=>be(t[o]))}function ie(t){return t?{...B,...t}:B}function ut(t,o={}){if(hn(t.env))return "env_disabled";if(t.state.optOut)return "opt_out";let e=ie(t.state.cachedConfig);if(e.killSwitch)return "kill_switch";if(yn(t.env))return "ci";if(!o.skipTTY&&false);if(!o.skipFrequency){let r=e.minIntervalSeconds*1e3;if(t.state.lastShownAt>0&&t.now-t.state.lastShownAt<r)return "frequency"}return null}var bn=new Set(["the","and","for","but","not","you","all","any","can","this","that","with","have","will","your","from","they","what","when","where","how","why","make","fix","add","update","remove","create","delete","change","error","errors","bug","bugs","file","files","code","test","tests","run","running","build","please","help","want","need","should","would","could","into","about","then","here","there","now","new","use","using","used","work","working","works","check","show","see","look","get","set","let","lets","dont","cant","issue"]);function kn(t){if(t.includes("/")||t.includes("\\")||t.includes("@")||t.includes("://"))return true;let o=t.toLowerCase();return !!(/^(sk|pk|rk|ock|ghp|gho|ghs|xox|akia|eyj|npm|glpat)[-_]/.test(o)||t.length>=16&&/^[0-9a-f]+$/i.test(t)||t.length>=20&&/^[A-Za-z0-9+/=_-]+$/.test(t)&&/[A-Z]/.test(t)&&/[0-9]/.test(t))}function wn(t,o=12){let e=[];for(let r of t.slice(0,2e3).split(/\s+/))if(!(!r||kn(r)))for(let n of r.split(/[^A-Za-z0-9+#.]+|(?<=[a-z0-9])(?=[A-Z])/)){let c=n.replace(/^[.]+|[.]+$/g,"").toLowerCase();if(!(c.length<3||c.length>24)&&!(/^\d+$/.test(c)||bn.has(c))&&!e.includes(c)&&(e.push(c),e.length>=o))return e}return e}function ke(t){let o=[];typeof t.prompt=="string"&&o.push(t.prompt);let e=t.cwd;if(typeof e=="string"&&e.length>0){let r=e.replace(/[\\/]+$/,""),n=r.split(/[\\/]/).pop()??"",c=(process.env.HOME??process.env.USERPROFILE??"").replace(/[\\/]+$/,""),f=process.env.USER??process.env.USERNAME??"";r!==c&&n!==f&&n.length>0&&o.push(n.replace(/[-_]/g," "));}return wn(o.join(" "))}function we(t,o,e){let r=new Map;for(let{topic:n,at:c}of t)e-c<216e5&&r.set(n,c);for(let n of o)r.set(n,e);return [...r.entries()].map(([n,c])=>({topic:n,at:c})).sort((n,c)=>c.at-n.at).slice(0,24)}function dt(t,o){return t.filter(({at:e})=>o-e<216e5).sort((e,r)=>r.at-e.at).slice(0,12).map(({topic:e})=>e)}var xn=false,Cn=process.platform==="win32"?8e3:3200,Tn=150,jn=2800,Se="claude_code";function Rn(t){let o={host:"claude_code"};for(let e=0;e<t.length;e++){let r=t[e],n=t[e+1];switch(r){case "--placement":n!==void 0&&(o.placement=n,e++);break;case "--key":n!==void 0&&(o.key=n,e++);break;case "--package":n!==void 0&&(o.package=n,e++);break;case "--host":(n==="claude_code"||n==="codex"||n==="openclaw"||n==="antigravity"||n==="copilot_cli"||n==="grok_cli"||n==="generic")&&(o.host=n,e++);break;}}return o}function En(t){return new Promise(o=>{if(process.stdin.isTTY){o("");return}let e="",r=false,n=()=>{r||(r=true,o(e));},c=setTimeout(n,t);c.unref?.(),process.stdin.setEncoding("utf8"),process.stdin.on("data",f=>{e+=f;}),process.stdin.on("end",()=>{clearTimeout(c),n();}),process.stdin.on("error",()=>{clearTimeout(c),n();});})}var _n="\\\\.\\CONOUT$";function On(t){return !t||t==="?"||t==="??"||t==="-"?null:t.startsWith("/")?t:`/dev/${t}`}function An(t){let o=t.match(/^\s*(\d+)\s+(\S+)/);return o?{ppid:Number(o[1]),tty:o[2]}:null}function Pn(t){if(!Number.isInteger(t)||t<=0)return null;let o=t>>8&4095,e=t&255|t>>12&1048320;return o>=136&&o<=143?`/dev/pts/${(o-136)*256+e}`:o===4?e<64?`/dev/tty${e}`:`/dev/ttyS${e-64}`:null}function In(t){let o=t.lastIndexOf(")");if(o<0)return null;let e=t.slice(o+1).trim().split(/\s+/),r=Number(e[1]),n=Number(e[4]);return !Number.isInteger(r)||!Number.isInteger(n)?null:{ppid:r,ttyNr:n}}function Nn(t){try{let o=In(h__namespace.readFileSync(`/proc/${t}/stat`,"utf8"));if(o)return {ppid:o.ppid,ttyPath:Pn(o.ttyNr)}}catch{}try{let o=child_process.spawnSync("ps",["-o","ppid=,tty=","-p",String(t)],{encoding:"utf8",timeout:1500}).stdout?.trim();if(!o)return null;let e=An(o);return e?{ppid:e.ppid,ttyPath:On(e.tty)}:null}catch{return null}}function $n(){if(process.platform==="win32")return {path:_n,ownerPid:null};let t=process.pid;for(let o=0;o<12&&t>1;o++){let e=Nn(t);if(!e)return null;if(e.ttyPath)return {path:e.ttyPath,ownerPid:t};t=e.ppid;}return null}function Mn(t){return t==="win32"?{detached:false,stdio:"ignore",windowsHide:false}:{detached:true,stdio:"ignore",windowsHide:false}}async function q(t,o,e,r,n,c){try{let f=b__namespace.join(__dirname,"paint.js"),d,p;if(c&&r){let g=G();c.kind==="dev"?(d=`${g}/v1/dev/impression`,p=c.token):d=`${g}/v1/events/impression`;}let a=ie(o.cachedConfig),u=Math.min(Math.max(a.displayDurationSeconds??25,3),120),s={...t,format:e?.format,mediaUrl:e?.mediaUrl,mediaPixelUrl:e?.mediaPixelUrl,audioUrl:e?.audioUrl,impressionId:r,campaignId:n,apiOrigin:G(),reportImpressionUrl:d,reportImpressionAuth:p,durationMs:u*1e3,disclosure:!o.disclosureShown,host:Se},i={...process.env,OPENCRATER_PAINT:JSON.stringify(s)};if(!i.OPENCRATER_TTY){let g=$n();g&&(i.OPENCRATER_TTY=g.path,g.ownerPid!==null&&(i.OPENCRATER_HOST_PID=String(g.ownerPid)));}let y=child_process.spawn(process.execPath,[f],{...Mn(process.platform),env:i});process.platform==="win32"?await new Promise(g=>{let m=!1,l=()=>{m||(m=!0,g());};y.on("exit",l),y.on("error",l),setTimeout(l,7500);}):y.unref();}catch{}return {...o,lastShownAt:Date.now(),disclosureShown:true}}function pt(t){if(process.platform!=="win32")return false;try{let o=b__namespace.join(N__namespace.homedir(),".config","opencrater","painter.lock"),e=JSON.parse(h__namespace.readFileSync(o,"utf8"));if(typeof e.startedAt!="number"||Date.now()-e.startedAt>t+1500)return !1;if(typeof e.pid=="number")try{process.kill(e.pid,0);}catch(r){if(r.code==="ESRCH")return !1}return !0}catch{return false}}var Ln=8e3;function mt(){let t=b__namespace.join(N__namespace.homedir(),".config","opencrater","render.lock");try{let o=h__namespace.statSync(t);if(Date.now()-o.mtimeMs<Ln)return !1;h__namespace.unlinkSync(t);}catch{}try{return h__namespace.mkdirSync(b__namespace.join(N__namespace.homedir(),".config","opencrater"),{recursive:!0}),h__namespace.writeFileSync(t,String(process.pid),{flag:"wx"}),!0}catch{return false}}function Dn(t,o,e,r){if(!o)return true;let n=t.allowedPlacements[`${o}:${e}`];return n?n.includes(r):o==="opencrater"?Te[e].includes(r):true}var Wn=1440*60*1e3;function Bn(){try{let t=b__namespace.join(N__namespace.homedir(),".config","opencrater","runtime"),o=b__namespace.join(t,"node_modules","opencrater","dist","hook.js"),e=b__namespace.join(t,".last-update");if(h__namespace.existsSync(o)){try{if(Date.now()-h__namespace.statSync(e).mtimeMs<Wn)return}catch{}try{h__namespace.writeFileSync(e,String(Date.now()));}catch{return}}else {let r=b__namespace.join(t,".installing");try{h__namespace.mkdirSync(t,{recursive:!0});let n=h__namespace.statSync(r);if(Date.now()-n.mtimeMs<600*1e3)return}catch{}h__namespace.writeFileSync(r,String(Date.now()));}he(t);}catch{}}function gt(t,o){if(!o)return false;let e=f=>f.split(/[-+]/)[0].split(".").map(d=>parseInt(d,10)||0),r=e(t),n=e(o),c=Math.max(r.length,n.length);for(let f=0;f<c;f++){let d=r[f]??0,p=n[f]??0;if(d!==p)return d<p}return false}function ht(){try{let t=b__namespace.join(N__namespace.homedir(),".config","opencrater","runtime"),o=b__namespace.join(t,".last-update"),e=b__namespace.join(t,".force-update");try{if(Date.now()-h__namespace.statSync(e).mtimeMs<600*1e3)return}catch{}h__namespace.mkdirSync(t,{recursive:!0}),h__namespace.writeFileSync(e,String(Date.now()));try{h__namespace.rmSync(o,{force:!0});}catch{}he(t);}catch{}}function Hn(){try{let t=b__namespace.join(N__namespace.homedir(),".config","opencrater");h__namespace.mkdirSync(t,{recursive:!0}),h__namespace.writeFileSync(b__namespace.join(t,"activity.signal"),String(Date.now()));}catch{}}var Un=1440*60*1e3;function Fn(){try{let t=b__namespace.join(N__namespace.homedir(),".config","opencrater"),o=b__namespace.join(t,".last-host-check"),e=b__namespace.join(t,".known-hosts"),r=b__namespace.join(t,".wired-version"),n=me().sort(),c=[];try{let u=JSON.parse(h__namespace.readFileSync(e,"utf8"));Array.isArray(u)&&(c=u.filter(s=>typeof s=="string"));}catch{}let f=n.some(u=>!c.includes(u)),d="";try{d=h__namespace.readFileSync(r,"utf8").trim();}catch{}if(!f&&!(d!==O))try{if(Date.now()-h__namespace.statSync(o).mtimeMs<Un)return}catch{}h__namespace.mkdirSync(t,{recursive:!0});try{h__namespace.writeFileSync(o,String(Date.now()));}catch{return}let a=le();try{h__namespace.writeFileSync(e,JSON.stringify(n)),h__namespace.writeFileSync(r,O);}catch{}if(a.optOut)return;if(a.devToken)try{ge();}catch{}for(let u of a.integrations)try{ge(u.key,u.package);}catch{}}catch{}}async function qn(){let t=Rn(process.argv.slice(2));if(Se=t.host,process.env.GROK_HOOK_EVENT&&Se!=="grok_cli")return;Hn(),Bn(),Fn();let o=await En(Tn),e={};if(o)try{e=JSON.parse(o);let m=e.hook_event_name;!t.placement&&typeof m=="string"&&(t.placement=m);}catch{}let r=t.placement??"SessionStart",n=le();x(`state=${V()} devToken=${n.devToken?"present":"MISSING"}`,`host=${t.host} placement=${r}`);let c=ut({env:process.env,state:n,now:Date.now()},{skipTTY:true});if(c!==null){if(c==="frequency"){let m=ke(e);m.length>0&&C({...n,sessionTopics:we(n.sessionTopics,m,Date.now())});}x("hook suppressed:",c);return}if(n={...n,sessionTopics:we(n.sessionTopics,ke(e),Date.now())},!Dn(n,t.package,t.host,r)){C(n),x("hook gated: placement",r,"not selected for",t.package);return}let f=ie(n.cachedConfig),d=G(),p=typeof e?.cwd=="string"&&e.cwd||process.cwd(),a=Pe(p),u=n.attrTags??[];if(n.attrTagsCwd!==a||!n.attrTagsAt||Date.now()-n.attrTagsAt>J){try{u=Ie(p);}catch{u=[];}n={...n,attrTags:u,attrTagsCwd:a,attrTagsAt:Date.now()};}let s={origin:d,timeoutMs:Math.min(f.serveTimeoutMs,jn),installId:n.installId,topics:dt(n.sessionTopics,Date.now()),tags:u};if(n.devToken){let m=await Ae(n.devToken,{publisherKey:t.key??"",packageName:t.package??"",placement:r,host:t.host},s);if(m){if(n={...n,cachedConfig:m.config,configFetchedAt:Date.now()},gt(O,m.config.minSdkVersion)&&ht(),xn);let l=t.host??"claude_code",P=nt(l,r),k=n.computeCards??{turns:0,lastLimitAt:0,lastDepletedAt:0,lastBackupAt:0};P&&(k.turns+=1);let j=rt({balanceMicroUsd:typeof m.computeBalanceMicroUsd=="number"?m.computeBalanceMicroUsd:null,weeklyGrantMicroUsd:typeof m.weeklyGrantMicroUsd=="number"?m.weeklyGrantMicroUsd:null,pendingMicroUsd:typeof m.pendingMicroUsd=="number"?m.pendingMicroUsd:null,onGateway:(process.env.ANTHROPIC_BASE_URL??"").includes("/gateway")||process.env.OPENCRATER_ON_GATEWAY==="1",turnEnd:P,hostName:l,host:tt(l),cc:k,now:Date.now()}),se=(m.config.displayDurationSeconds??25)*1e3,T=m.fill&&m.blip&&!X(m.blip.campaignId)&&!Q(m.blip.campaignId)?m.blip:null;if((j||T)&&!pt(se)&&mt())if(j){let R=Date.now();j.kind==="limit"?k.lastLimitAt=R:j.kind==="depleted"?k.lastDepletedAt=R:j.kind==="backup"&&(k.lastBackupAt=R),n=await q({...j.card,label:"OpenCrater"},n);}else T&&(Z(T.campaignId),n=await q(K(T),n,T.creative,T.impressionId,T.campaignId,n.devToken?{kind:"dev",token:n.devToken}:void 0));n={...n,computeCards:k};}C(n);return}let{blip:i,pool:y}=ue(n,Date.now());for(;i&&(X(i.campaignId)||Q(i.campaignId));)x("hook: pooled blip skipped \u2014 campaign inside a local cooldown"),{blip:i,pool:y}=ue({pool:y},Date.now());if((i||t.key)&&pt((f.displayDurationSeconds??25)*1e3)){C(n),x("hook: a card is already on screen \u2014 not rendering another");return}if((i||t.key)&&!mt()){C(n),x("hook: render slot already claimed by a concurrent fire");return}if(i){Z(i.campaignId),n=await q(K(i),{...n,pool:y},i.creative,i.impressionId,i.campaignId,{kind:"publisher"}),C(n);return}if(y.length!==n.pool.length&&(n={...n,pool:y}),!t.key||!t.package){C(n),x("hook: pool empty and no --key/--package; nothing to render");return}let g=await Oe({publisherKey:t.key,packageName:t.package,placement:r,host:t.host},s);if(!g){C(n);return}if(n={...n,cachedConfig:g.config,configFetchedAt:Date.now()},gt(O,g.config.minSdkVersion)&&(x(`SDK ${O} below floor ${g.config.minSdkVersion} \u2014 forcing runtime update`),ht()),t.package&&g.allowedPlacements&&(n={...n,allowedPlacements:{...n.allowedPlacements,[`${t.package}:${t.host}`]:g.allowedPlacements}}),g.fill&&g.blip){if(X(g.blip.campaignId)||Q(g.blip.campaignId)){x("hook: served blip suppressed \u2014 campaign inside a local cooldown"),C(n);return}Z(g.blip.campaignId),n=await q(K(g.blip),n,g.blip.creative,g.blip.impressionId,g.blip.campaignId,{kind:"publisher"}),C(n);return}g.fallback&&(n=await q($e(g.fallback),n)),C(n);}if(typeof M<"u"&&typeof module<"u"&&M.main===module){let t=setTimeout(()=>process.exit(0),Cn);qn().catch(o=>x(`opencrater-hook v${O} error:`,o)).finally(()=>{clearTimeout(t),process.exit(0);});}
13
13
  exports.decodeTtyNr=Pn;exports.painterSpawnOptions=Mn;exports.parseArgs=Rn;exports.parseProcStat=In;exports.parsePsLine=An;exports.resolveTtyPath=$n;exports.ttyNameToDevPath=On;
package/dist/index.d.mts CHANGED
@@ -232,7 +232,7 @@ declare function renderBlip(blip: Blip, opts?: MediaRenderOptions): Promise<stri
232
232
 
233
233
  /** Keep in sync with package.json (bundled, so we avoid a runtime fs read).
234
234
  * AUTO-GENERATED by scripts/sync-version.mjs on `npm version`. */
235
- declare const SDK_VERSION = "1.3.0";
235
+ declare const SDK_VERSION = "1.3.1";
236
236
 
237
237
  /** Public API. Every method is fail-silent: it never throws. */
238
238
  declare const sponsor: {
package/dist/index.d.ts CHANGED
@@ -232,7 +232,7 @@ declare function renderBlip(blip: Blip, opts?: MediaRenderOptions): Promise<stri
232
232
 
233
233
  /** Keep in sync with package.json (bundled, so we avoid a runtime fs read).
234
234
  * AUTO-GENERATED by scripts/sync-version.mjs on `npm version`. */
235
- declare const SDK_VERSION = "1.3.0";
235
+ declare const SDK_VERSION = "1.3.1";
236
236
 
237
237
  /** Public API. Every method is fail-silent: it never throws. */
238
238
  declare const sponsor: {
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var crypto=require('crypto'),m=require('fs'),ie=require('os'),S=require('path');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var m__namespace=/*#__PURE__*/_interopNamespace(m);var ie__namespace=/*#__PURE__*/_interopNamespace(ie);var S__namespace=/*#__PURE__*/_interopNamespace(S);var q=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,t)=>(typeof require<"u"?require:n)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var w={minIntervalSeconds:600,serveTimeoutMs:2500,preloadPoolSize:3,killSwitch:false,displayDurationSeconds:25,minSdkVersion:""};var le=["SessionStart","SessionEnd","Stop","PostToolUse","Notification"];var N="1.3.0";var ce="https://api.opencrater.to";function K(e,n=process.env){let t=n.OPENCRATER_API_ORIGIN;return (e??(t&&t.trim()!==""?t:ce)).replace(/\/+$/,"")}function c(...e){try{if(process.env.OPENCRATER_DEBUG!=="1")return;console.error("[opencrater]",...e);try{let n=q("os"),t=q("fs"),o=q("path");t.appendFileSync(o.join(n.homedir(),".config","opencrater","hook.log"),`${new Date().toISOString()} [opencrater] ${e.map(i=>String(i)).join(" ")}
1
+ 'use strict';var crypto=require('crypto'),m=require('fs'),ie=require('os'),S=require('path');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var m__namespace=/*#__PURE__*/_interopNamespace(m);var ie__namespace=/*#__PURE__*/_interopNamespace(ie);var S__namespace=/*#__PURE__*/_interopNamespace(S);var q=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,t)=>(typeof require<"u"?require:n)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var w={minIntervalSeconds:600,serveTimeoutMs:2500,preloadPoolSize:3,killSwitch:false,displayDurationSeconds:25,minSdkVersion:""};var le=["SessionStart","SessionEnd","Stop","PostToolUse","Notification"];var N="1.3.1";var ce="https://api.opencrater.to";function K(e,n=process.env){let t=n.OPENCRATER_API_ORIGIN;return (e??(t&&t.trim()!==""?t:ce)).replace(/\/+$/,"")}function c(...e){try{if(process.env.OPENCRATER_DEBUG!=="1")return;console.error("[opencrater]",...e);try{let n=q("os"),t=q("fs"),o=q("path");t.appendFileSync(o.join(n.homedir(),".config","opencrater","hook.log"),`${new Date().toISOString()} [opencrater] ${e.map(i=>String(i)).join(" ")}
2
2
  `);}catch{}}catch{}}function R(e){return typeof e=="number"&&Number.isFinite(e)}function V(e){let n=w;if(typeof e!="object"||e===null)return {...n};let t=e;return {minIntervalSeconds:R(t.minIntervalSeconds)?t.minIntervalSeconds:n.minIntervalSeconds,serveTimeoutMs:R(t.serveTimeoutMs)?t.serveTimeoutMs:n.serveTimeoutMs,preloadPoolSize:R(t.preloadPoolSize)?t.preloadPoolSize:n.preloadPoolSize,killSwitch:t.killSwitch===true,displayDurationSeconds:R(t.displayDurationSeconds)?t.displayDurationSeconds:n.displayDurationSeconds,minSdkVersion:typeof t.minSdkVersion=="string"?t.minSdkVersion:n.minSdkVersion}}async function D(e,n,t,o,i){try{let r=await fetch(`${e}${n}`,{method:"POST",headers:{"content-type":"application/json",...i??{}},body:JSON.stringify(t),signal:AbortSignal.timeout(o)});return r.ok?await r.json():(c(`POST ${n} -> HTTP ${r.status}`),null)}catch(r){return c(`POST ${n} failed:`,r),null}}function J(e,n){let t=e.host??"generic";return {publisherKey:e.publisherKey,packageName:e.packageName,placement:e.placement,host:t,sdkVersion:N,installId:n.installId,os:process.platform,termProgram:process.env.TERM_PROGRAM??void 0,topics:n.topics&&n.topics.length>0?n.topics:void 0,tags:n.tags&&n.tags.length>0?n.tags:void 0}}function fe(e){if(typeof e!="object"||e===null)return null;let n=e;if(typeof n.fill!="boolean")return null;let t={fill:n.fill,fallback:n.fallback??null,config:V(n.config),...Array.isArray(n.allowedPlacements)?{allowedPlacements:n.allowedPlacements.filter(o=>typeof o=="string")}:{}};return n.blip!==void 0&&n.blip!==null&&(t.blip=n.blip),typeof n.computeBalanceMicroUsd=="number"&&(t.computeBalanceMicroUsd=n.computeBalanceMicroUsd),typeof n.weeklyGrantMicroUsd=="number"&&(t.weeklyGrantMicroUsd=n.weeklyGrantMicroUsd),typeof n.pendingMicroUsd=="number"&&(t.pendingMicroUsd=n.pendingMicroUsd),t}async function F(e,n){let t=await D(n.origin,"/v1/serve",J(e,n),n.timeoutMs);return fe(t)}async function X(e,n,t){let o=await D(t.origin,"/v1/serve/batch",{...J(e,t),count:n},t.timeoutMs);if(typeof o!="object"||o===null)return null;let i=o;return Array.isArray(i.blips)?{blips:i.blips,fallback:i.fallback??null,config:V(i.config),...Array.isArray(i.allowedPlacements)?{allowedPlacements:i.allowedPlacements.filter(r=>typeof r=="string")}:{}}:null}function $(e,n){return D(n.origin,"/v1/events/impression",{impressionId:e},n.timeoutMs).then(()=>{}).catch(()=>{})}var ue=new RegExp("\x1B\\[[0-9;]*m|\x1B\\]8;;[^\x07\x1B]*(?:\x07|\x1B\\\\)","g"),k={dim:"\x1B[2m",bold:"\x1B[1m",reset:"\x1B[0m"},de=60,pe=24,me="\u2139 This project is supported by Blips via OpenCrater. Opt out: `npx opencrater off` or OPENCRATER_DISABLE=1";function ge(e){return e.replace(ue,"").length}function y(e,n){return n<=0?"":e.length<=n?e:n===1?"\u2026":e.slice(0,n-1).trimEnd()+"\u2026"}function he(e,n,t){let o=e.split(/\s+/).filter(l=>l.length>0),i=[],r="";for(let l of o){let u=r===""?l:`${r} ${l}`;if(u.length<=n)r=u;else if(r!==""&&i.push(r),r=l.length>n?y(l,n):l,i.length>=t)break}r!==""&&i.length<t&&i.push(r),i.length>t&&(i.length=t);let s=i.join(" "),a=i.length-1,f=i[a];return f!==void 0&&s.length<o.join(" ").length&&(i[a]=y(`${f}\u2026`,n)),i}function I(e=process.env,n=!!process.stdout.isTTY){if(!n)return false;if(e.FORCE_HYPERLINK!==void 0&&e.FORCE_HYPERLINK!=="0")return true;let t=e.TERM_PROGRAM??"";return !!(["iTerm.app","WezTerm","ghostty","Hyper","vscode","Tabby"].includes(t)||e.KITTY_WINDOW_ID||e.WT_SESSION||Number(e.VTE_VERSION??"0")>=5e3)}function P(e=process.env,n=!!process.stdout.isTTY){return !(e.NO_COLOR!==void 0&&e.NO_COLOR!==""||!n||(e.TERM??"")==="dumb")}function ye(e,n){return `\x1B]8;;${e}\x07${n}\x1B]8;;\x07`}function E(e){let n={sponsorLabel:e.sponsorLabel,title:e.creative.title,body:e.creative.body,url:e.clickUrl};return e.creative.cta!==void 0&&(n.cta=e.creative.cta),n}function Z(e){return {sponsorLabel:"",title:e.title,body:e.body,url:e.url}}function h(e,n={}){let t=n.width??process.stdout.columns??80,i=Math.max(pe,Math.min(t,de))-4,r=n.color??P(),s=n.hyperlinks??I(),a=(g,M)=>r?`${M}${g}${k.reset}`:g,f=e.label?y(e.label,i):e.sponsorLabel?y(`Sponsored Blips \xB7 ${e.sponsorLabel}`,i):"Sponsored Blips",l=[];l.push(a(f,k.dim)),e.title!==e.sponsorLabel&&l.push(a(y(e.title,i),k.bold));for(let g of he(e.body,i,2))l.push(g);let u="\u2192 ";if(s){let g=y(e.cta??e.url,i-u.length);l.push(u+a(ye(e.url,g),k.dim));}else e.cta&&l.push(y(e.cta,i)),l.push(u+a(y(e.url,i-u.length),k.dim));let T=`\u256D${"\u2500".repeat(i+2)}\u256E`,j=`\u2570${"\u2500".repeat(i+2)}\u256F`,L=l.map(g=>{let M=" ".repeat(Math.max(0,i-ge(g)));return `\u2502 ${g}${M} \u2502`}),b=[];return n.disclosure&&b.push(a(me,k.dim)),b.push(T,...L,j),b.join(`
3
3
  `)+`
4
4
  `}function Q(e){return e!==void 0&&e!==""}function z(e=process.env,n=!!process.stdout.isTTY){if(!n)return "none";let t=e.TERM??"";if(Q(e.TMUX)||t.startsWith("tmux")||t.startsWith("screen"))return "none";let o=e.TERM_PROGRAM??"";return o==="iTerm.app"||e.LC_TERMINAL==="iTerm2"||o==="WezTerm"?"iterm2":t==="xterm-kitty"||Q(e.KITTY_WINDOW_ID)?"kitty":"none"}var v="\x1B",be="\x07",we=2e3,ke=2*1024*1024,Se=new Set(["image/png","image/jpeg","image/gif","image/webp"]),O=4096;async function ve(e,n=fetch,t={}){let o=t.timeoutMs??we,i=t.maxBytes??ke;try{let r=await n(e,{signal:AbortSignal.timeout(o)});if(!r.ok)return c(`media: HTTP ${r.status} for ${e}`),null;let s=(r.headers.get("content-type")??"").split(";")[0].trim().toLowerCase();if(!Se.has(s))return c(`media: disallowed content-type "${s}" for ${e}`),null;let a=Number(r.headers.get("content-length")??"0");if(Number.isFinite(a)&&a>i)return c(`media: content-length ${a} exceeds ${i} for ${e}`),null;let f=r.body;if(f&&typeof f.getReader=="function"){let u=f.getReader(),T=[],j=0;for(;;){let{done:L,value:b}=await u.read();if(L)break;if(b!==void 0){if(j+=b.byteLength,j>i)return await u.cancel().catch(()=>{}),c(`media: stream exceeded ${i} bytes for ${e}`),null;T.push(b);}}return Buffer.concat(T)}let l=Buffer.from(await r.arrayBuffer());return l.byteLength>i?(c(`media: body ${l.byteLength} bytes exceeds ${i} for ${e}`),null):l}catch(r){return c(`media: fetch failed for ${e}:`,r),null}}function xe(e){let n=e.toString("base64");return `${v}]1337;File=inline=1;size=${e.byteLength};width=auto:${n}${be}`}function Ce(e){let n=e.toString("base64");if(n.length<=O)return `${v}_Gf=100,a=T;${n}${v}\\`;let t=[];for(let o=0;o<n.length;o+=O){let i=n.slice(o,o+O),s=`m=${o+O>=n.length?0:1}`,a=o===0?`f=100,a=T,${s}`:s;t.push(`${v}_G${a};${i}${v}\\`);}return t.join("")}function A(e){let n=E(e),t=e.creative;switch(t.format){case "image":case "gif":return {...n,body:t.textFallback??n.body};case "video":return {...n,body:t.textFallback??n.body,cta:n.cta??"\u25B6 Watch"};case "audio":return {...n,body:t.textFallback??n.body,cta:n.cta??"\u{1F50A} Listen"};default:return n}}async function U(e,n={}){try{let t=e.creative;if(t.format!=="image"&&t.format!=="gif")return h(A(e),n);let o=n.protocol??z();if(o==="none"||t.mediaUrl===void 0||t.mediaUrl==="")return h(A(e),n);let i={};n.timeoutMs!==void 0&&(i.timeoutMs=n.timeoutMs),n.maxBytes!==void 0&&(i.maxBytes=n.maxBytes);let r=await ve(t.mediaUrl,n.fetchImpl??fetch,i);return r===null||r.byteLength===0?h(A(e),n):(o==="kitty"?Ce(r):xe(r))+`
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import {randomUUID}from'crypto';import*as m from'fs';import*as ie from'os';import*as S from'path';var q=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,t)=>(typeof require<"u"?require:n)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var w={minIntervalSeconds:600,serveTimeoutMs:2500,preloadPoolSize:3,killSwitch:false,displayDurationSeconds:25,minSdkVersion:""};var le=["SessionStart","SessionEnd","Stop","PostToolUse","Notification"];var N="1.3.0";var ce="https://api.opencrater.to";function K(e,n=process.env){let t=n.OPENCRATER_API_ORIGIN;return (e??(t&&t.trim()!==""?t:ce)).replace(/\/+$/,"")}function c(...e){try{if(process.env.OPENCRATER_DEBUG!=="1")return;console.error("[opencrater]",...e);try{let n=q("os"),t=q("fs"),o=q("path");t.appendFileSync(o.join(n.homedir(),".config","opencrater","hook.log"),`${new Date().toISOString()} [opencrater] ${e.map(i=>String(i)).join(" ")}
1
+ import {randomUUID}from'crypto';import*as m from'fs';import*as ie from'os';import*as S from'path';var q=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,t)=>(typeof require<"u"?require:n)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var w={minIntervalSeconds:600,serveTimeoutMs:2500,preloadPoolSize:3,killSwitch:false,displayDurationSeconds:25,minSdkVersion:""};var le=["SessionStart","SessionEnd","Stop","PostToolUse","Notification"];var N="1.3.1";var ce="https://api.opencrater.to";function K(e,n=process.env){let t=n.OPENCRATER_API_ORIGIN;return (e??(t&&t.trim()!==""?t:ce)).replace(/\/+$/,"")}function c(...e){try{if(process.env.OPENCRATER_DEBUG!=="1")return;console.error("[opencrater]",...e);try{let n=q("os"),t=q("fs"),o=q("path");t.appendFileSync(o.join(n.homedir(),".config","opencrater","hook.log"),`${new Date().toISOString()} [opencrater] ${e.map(i=>String(i)).join(" ")}
2
2
  `);}catch{}}catch{}}function R(e){return typeof e=="number"&&Number.isFinite(e)}function V(e){let n=w;if(typeof e!="object"||e===null)return {...n};let t=e;return {minIntervalSeconds:R(t.minIntervalSeconds)?t.minIntervalSeconds:n.minIntervalSeconds,serveTimeoutMs:R(t.serveTimeoutMs)?t.serveTimeoutMs:n.serveTimeoutMs,preloadPoolSize:R(t.preloadPoolSize)?t.preloadPoolSize:n.preloadPoolSize,killSwitch:t.killSwitch===true,displayDurationSeconds:R(t.displayDurationSeconds)?t.displayDurationSeconds:n.displayDurationSeconds,minSdkVersion:typeof t.minSdkVersion=="string"?t.minSdkVersion:n.minSdkVersion}}async function D(e,n,t,o,i){try{let r=await fetch(`${e}${n}`,{method:"POST",headers:{"content-type":"application/json",...i??{}},body:JSON.stringify(t),signal:AbortSignal.timeout(o)});return r.ok?await r.json():(c(`POST ${n} -> HTTP ${r.status}`),null)}catch(r){return c(`POST ${n} failed:`,r),null}}function J(e,n){let t=e.host??"generic";return {publisherKey:e.publisherKey,packageName:e.packageName,placement:e.placement,host:t,sdkVersion:N,installId:n.installId,os:process.platform,termProgram:process.env.TERM_PROGRAM??void 0,topics:n.topics&&n.topics.length>0?n.topics:void 0,tags:n.tags&&n.tags.length>0?n.tags:void 0}}function fe(e){if(typeof e!="object"||e===null)return null;let n=e;if(typeof n.fill!="boolean")return null;let t={fill:n.fill,fallback:n.fallback??null,config:V(n.config),...Array.isArray(n.allowedPlacements)?{allowedPlacements:n.allowedPlacements.filter(o=>typeof o=="string")}:{}};return n.blip!==void 0&&n.blip!==null&&(t.blip=n.blip),typeof n.computeBalanceMicroUsd=="number"&&(t.computeBalanceMicroUsd=n.computeBalanceMicroUsd),typeof n.weeklyGrantMicroUsd=="number"&&(t.weeklyGrantMicroUsd=n.weeklyGrantMicroUsd),typeof n.pendingMicroUsd=="number"&&(t.pendingMicroUsd=n.pendingMicroUsd),t}async function F(e,n){let t=await D(n.origin,"/v1/serve",J(e,n),n.timeoutMs);return fe(t)}async function X(e,n,t){let o=await D(t.origin,"/v1/serve/batch",{...J(e,t),count:n},t.timeoutMs);if(typeof o!="object"||o===null)return null;let i=o;return Array.isArray(i.blips)?{blips:i.blips,fallback:i.fallback??null,config:V(i.config),...Array.isArray(i.allowedPlacements)?{allowedPlacements:i.allowedPlacements.filter(r=>typeof r=="string")}:{}}:null}function $(e,n){return D(n.origin,"/v1/events/impression",{impressionId:e},n.timeoutMs).then(()=>{}).catch(()=>{})}var ue=new RegExp("\x1B\\[[0-9;]*m|\x1B\\]8;;[^\x07\x1B]*(?:\x07|\x1B\\\\)","g"),k={dim:"\x1B[2m",bold:"\x1B[1m",reset:"\x1B[0m"},de=60,pe=24,me="\u2139 This project is supported by Blips via OpenCrater. Opt out: `npx opencrater off` or OPENCRATER_DISABLE=1";function ge(e){return e.replace(ue,"").length}function y(e,n){return n<=0?"":e.length<=n?e:n===1?"\u2026":e.slice(0,n-1).trimEnd()+"\u2026"}function he(e,n,t){let o=e.split(/\s+/).filter(l=>l.length>0),i=[],r="";for(let l of o){let u=r===""?l:`${r} ${l}`;if(u.length<=n)r=u;else if(r!==""&&i.push(r),r=l.length>n?y(l,n):l,i.length>=t)break}r!==""&&i.length<t&&i.push(r),i.length>t&&(i.length=t);let s=i.join(" "),a=i.length-1,f=i[a];return f!==void 0&&s.length<o.join(" ").length&&(i[a]=y(`${f}\u2026`,n)),i}function I(e=process.env,n=!!process.stdout.isTTY){if(!n)return false;if(e.FORCE_HYPERLINK!==void 0&&e.FORCE_HYPERLINK!=="0")return true;let t=e.TERM_PROGRAM??"";return !!(["iTerm.app","WezTerm","ghostty","Hyper","vscode","Tabby"].includes(t)||e.KITTY_WINDOW_ID||e.WT_SESSION||Number(e.VTE_VERSION??"0")>=5e3)}function P(e=process.env,n=!!process.stdout.isTTY){return !(e.NO_COLOR!==void 0&&e.NO_COLOR!==""||!n||(e.TERM??"")==="dumb")}function ye(e,n){return `\x1B]8;;${e}\x07${n}\x1B]8;;\x07`}function E(e){let n={sponsorLabel:e.sponsorLabel,title:e.creative.title,body:e.creative.body,url:e.clickUrl};return e.creative.cta!==void 0&&(n.cta=e.creative.cta),n}function Z(e){return {sponsorLabel:"",title:e.title,body:e.body,url:e.url}}function h(e,n={}){let t=n.width??process.stdout.columns??80,i=Math.max(pe,Math.min(t,de))-4,r=n.color??P(),s=n.hyperlinks??I(),a=(g,M)=>r?`${M}${g}${k.reset}`:g,f=e.label?y(e.label,i):e.sponsorLabel?y(`Sponsored Blips \xB7 ${e.sponsorLabel}`,i):"Sponsored Blips",l=[];l.push(a(f,k.dim)),e.title!==e.sponsorLabel&&l.push(a(y(e.title,i),k.bold));for(let g of he(e.body,i,2))l.push(g);let u="\u2192 ";if(s){let g=y(e.cta??e.url,i-u.length);l.push(u+a(ye(e.url,g),k.dim));}else e.cta&&l.push(y(e.cta,i)),l.push(u+a(y(e.url,i-u.length),k.dim));let T=`\u256D${"\u2500".repeat(i+2)}\u256E`,j=`\u2570${"\u2500".repeat(i+2)}\u256F`,L=l.map(g=>{let M=" ".repeat(Math.max(0,i-ge(g)));return `\u2502 ${g}${M} \u2502`}),b=[];return n.disclosure&&b.push(a(me,k.dim)),b.push(T,...L,j),b.join(`
3
3
  `)+`
4
4
  `}function Q(e){return e!==void 0&&e!==""}function z(e=process.env,n=!!process.stdout.isTTY){if(!n)return "none";let t=e.TERM??"";if(Q(e.TMUX)||t.startsWith("tmux")||t.startsWith("screen"))return "none";let o=e.TERM_PROGRAM??"";return o==="iTerm.app"||e.LC_TERMINAL==="iTerm2"||o==="WezTerm"?"iterm2":t==="xterm-kitty"||Q(e.KITTY_WINDOW_ID)?"kitty":"none"}var v="\x1B",be="\x07",we=2e3,ke=2*1024*1024,Se=new Set(["image/png","image/jpeg","image/gif","image/webp"]),O=4096;async function ve(e,n=fetch,t={}){let o=t.timeoutMs??we,i=t.maxBytes??ke;try{let r=await n(e,{signal:AbortSignal.timeout(o)});if(!r.ok)return c(`media: HTTP ${r.status} for ${e}`),null;let s=(r.headers.get("content-type")??"").split(";")[0].trim().toLowerCase();if(!Se.has(s))return c(`media: disallowed content-type "${s}" for ${e}`),null;let a=Number(r.headers.get("content-length")??"0");if(Number.isFinite(a)&&a>i)return c(`media: content-length ${a} exceeds ${i} for ${e}`),null;let f=r.body;if(f&&typeof f.getReader=="function"){let u=f.getReader(),T=[],j=0;for(;;){let{done:L,value:b}=await u.read();if(L)break;if(b!==void 0){if(j+=b.byteLength,j>i)return await u.cancel().catch(()=>{}),c(`media: stream exceeded ${i} bytes for ${e}`),null;T.push(b);}}return Buffer.concat(T)}let l=Buffer.from(await r.arrayBuffer());return l.byteLength>i?(c(`media: body ${l.byteLength} bytes exceeds ${i} for ${e}`),null):l}catch(r){return c(`media: fetch failed for ${e}:`,r),null}}function xe(e){let n=e.toString("base64");return `${v}]1337;File=inline=1;size=${e.byteLength};width=auto:${n}${be}`}function Ce(e){let n=e.toString("base64");if(n.length<=O)return `${v}_Gf=100,a=T;${n}${v}\\`;let t=[];for(let o=0;o<n.length;o+=O){let i=n.slice(o,o+O),s=`m=${o+O>=n.length?0:1}`,a=o===0?`f=100,a=T,${s}`:s;t.push(`${v}_G${a};${i}${v}\\`);}return t.join("")}function A(e){let n=E(e),t=e.creative;switch(t.format){case "image":case "gif":return {...n,body:t.textFallback??n.body};case "video":return {...n,body:t.textFallback??n.body,cta:n.cta??"\u25B6 Watch"};case "audio":return {...n,body:t.textFallback??n.body,cta:n.cta??"\u{1F50A} Listen"};default:return n}}async function U(e,n={}){try{let t=e.creative;if(t.format!=="image"&&t.format!=="gif")return h(A(e),n);let o=n.protocol??z();if(o==="none"||t.mediaUrl===void 0||t.mediaUrl==="")return h(A(e),n);let i={};n.timeoutMs!==void 0&&(i.timeoutMs=n.timeoutMs),n.maxBytes!==void 0&&(i.maxBytes=n.maxBytes);let r=await ve(t.mediaUrl,n.fetchImpl??fetch,i);return r===null||r.byteLength===0?h(A(e),n):(o==="kitty"?Ce(r):xe(r))+`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencrater",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "OpenCrater — sponsor cards for AI coding terminals (Claude Code, Codex, Gemini CLI, Copilot CLI). One command, auto-wires every host, opt out anytime.",
5
5
  "keywords": [
6
6
  "opencrater",