@lensmcp/cluster 1.25.0 → 1.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/basic-ssl.js +1 -1
  2. package/build-host.js +1 -1
  3. package/build-scope-patterns.js +1 -1
  4. package/bundle-parent.js +1 -1
  5. package/checkout-cache.js +1 -1
  6. package/create-webpack-dev.js +1 -1
  7. package/create-webpack-prod.js +1 -1
  8. package/dev-devtool.js +1 -1
  9. package/devserver-notifier.js +1 -1
  10. package/devserver-transport.js +1 -1
  11. package/error-stack-release.js +1 -1
  12. package/executors/build/build.impl.js +1 -1
  13. package/executors/gateway/body-stall.js +1 -1
  14. package/executors/gateway/canonical-path.js +1 -1
  15. package/executors/gateway/client-ip.js +1 -1
  16. package/executors/gateway/gateway-errors.js +1 -1
  17. package/executors/gateway/gateway.impl.js +1 -1
  18. package/executors/gateway/gateway.lib.js +1 -1
  19. package/executors/gateway/health-check.js +1 -1
  20. package/executors/gateway/jwks-verify.js +1 -1
  21. package/executors/gateway/jwt-claims.js +1 -1
  22. package/executors/gateway/main.prod-gateway.js +2 -2
  23. package/executors/gateway/main.rollout.js +4 -4
  24. package/executors/gateway/manifest.js +1 -1
  25. package/executors/gateway/metrics.js +1 -1
  26. package/executors/gateway/otel-tracing.js +1 -1
  27. package/executors/gateway/prod-config.js +1 -1
  28. package/executors/gateway/prod-gateway.lib.js +1 -1
  29. package/executors/gateway/prod-runtime/access-log.js +1 -1
  30. package/executors/gateway/prod-runtime/app.js +1 -1
  31. package/executors/gateway/prod-runtime/auth.js +1 -1
  32. package/executors/gateway/prod-runtime/body-stall.js +1 -1
  33. package/executors/gateway/prod-runtime/cors.js +1 -1
  34. package/executors/gateway/prod-runtime/edge.js +1 -1
  35. package/executors/gateway/prod-runtime/handler.js +1 -1
  36. package/executors/gateway/prod-runtime/hooks.js +1 -1
  37. package/executors/gateway/prod-runtime/observability.js +1 -1
  38. package/executors/gateway/prod-runtime/rollout.js +1 -1
  39. package/executors/gateway/prod-runtime/routing.js +1 -1
  40. package/executors/gateway/prod-runtime/server.js +1 -1
  41. package/executors/gateway/prod-runtime/trust.js +1 -1
  42. package/executors/gateway/prod-runtime/upgrade.js +7 -7
  43. package/executors/gateway/prod-runtime/upstream.js +1 -1
  44. package/executors/gateway/providers-prod.js +1 -1
  45. package/executors/gateway/rate-limit.js +2 -2
  46. package/executors/gateway/registry-source.js +1 -1
  47. package/executors/gateway/rollout-ops.js +2 -2
  48. package/executors/gateway/runtime/auth.js +1 -1
  49. package/executors/gateway/runtime/chooser.js +12 -12
  50. package/executors/gateway/runtime/control.js +2 -2
  51. package/executors/gateway/runtime/dev-auth.js +1 -1
  52. package/executors/gateway/runtime/discovery.js +1 -1
  53. package/executors/gateway/runtime/edge.js +1 -1
  54. package/executors/gateway/runtime/guest-graph.js +2 -2
  55. package/executors/gateway/runtime/guest-replay.js +2 -2
  56. package/executors/gateway/runtime/handler.js +1 -1
  57. package/executors/gateway/runtime/hmr-reload.js +1 -1
  58. package/executors/gateway/runtime/hooks.js +1 -1
  59. package/executors/gateway/runtime/instance.js +2 -2
  60. package/executors/gateway/runtime/lens-children.js +1 -1
  61. package/executors/gateway/runtime/lifecycle.js +3 -3
  62. package/executors/gateway/runtime/observability.js +2 -2
  63. package/executors/gateway/runtime/pod-env.js +2 -2
  64. package/executors/gateway/runtime/pod-output.js +1 -1
  65. package/executors/gateway/runtime/pod-probe.js +1 -1
  66. package/executors/gateway/runtime/process-names.js +1 -1
  67. package/executors/gateway/runtime/project-graph-store.js +1 -1
  68. package/executors/gateway/runtime/proxy.js +1 -1
  69. package/executors/gateway/runtime/registration-guards.js +1 -1
  70. package/executors/gateway/runtime/route-registry.js +1 -1
  71. package/executors/gateway/runtime/scope.js +1 -1
  72. package/executors/gateway/runtime/serve-launch.js +3 -3
  73. package/executors/gateway/runtime/server.js +2 -2
  74. package/executors/gateway/runtime/service-keys.js +1 -1
  75. package/executors/gateway/runtime/shared-build.js +4 -4
  76. package/executors/gateway/runtime/types.js +1 -1
  77. package/executors/gateway/runtime/upgrade.js +1 -1
  78. package/executors/gateway/runtime/workspace-log.js +1 -1
  79. package/executors/gateway/runtime/workspace-middleware.js +1 -1
  80. package/executors/gateway/runtime/workspace-registry.js +1 -1
  81. package/executors/gateway/ssrf-guard.js +1 -1
  82. package/executors/serve/serve.impl.js +1 -1
  83. package/executors/trust/hostname.js +1 -1
  84. package/executors/trust/trust.impl.js +3 -3
  85. package/exit-reason.js +2 -2
  86. package/fork-ts-check-reporter.js +1 -1
  87. package/gateway.js +1 -1
  88. package/gc-notice.js +1 -1
  89. package/graph-snapshot.js +1 -1
  90. package/handoff-retire.js +1 -1
  91. package/heap-snapshot.js +1 -1
  92. package/hot-swap-registries.js +1 -1
  93. package/index.js +1 -1
  94. package/inspector-secret.js +1 -1
  95. package/main.devserver.js +9 -9
  96. package/notice-generation.js +1 -1
  97. package/package.json +4 -4
  98. package/perf/heavy-barrel-import.js +1 -1
  99. package/perf/perf-config.js +1 -1
  100. package/perf/perf-rule-events.js +2 -2
  101. package/perf/perf-rules-analysis.js +1 -1
  102. package/perf/perf-rules-plugin.js +1 -1
  103. package/perf/source-scan.js +5 -5
  104. package/perf/workspace-libraries.js +2 -2
  105. package/pod-memory-events.js +2 -2
  106. package/pod-memory.js +1 -1
  107. package/pod-sock.js +1 -1
  108. package/process-name.js +1 -1
  109. package/redis-disconnect-fix.js +1 -1
  110. package/schema-first-instance.js +1 -1
  111. package/serve-runner.js +1 -1
  112. package/service-build-events.js +1 -1
  113. package/shared-build/attach.js +2 -2
  114. package/shared-build/host.js +3 -3
  115. package/shared-build/protocol.js +1 -1
  116. package/shared-build/shared-compilation.js +3 -3
  117. package/shared-build/signature.js +1 -1
  118. package/stdio-guard.js +1 -1
  119. package/swap-recycle.js +1 -1
  120. package/tsgo-check-plugin.js +4 -4
  121. package/typecheck-bus.js +3 -3
  122. package/typecheck-queue.js +1 -1
  123. package/workspace-paths.js +1 -1
package/swap-recycle.js CHANGED
@@ -1 +1 @@
1
- "use strict";var o=Object.defineProperty;var n=(s,e)=>o(s,"name",{value:e,configurable:!0});var t=Object.defineProperty,r=n((s,e)=>t(s,"name",{value:e,configurable:!0}),"r");Object.defineProperty(exports,"__esModule",{value:!0}),exports.swapRecyclePolicy=swapRecyclePolicy,exports.recycleReason=recycleReason;const MB=1024*1024,numberFrom=r((s,e,a)=>{if(s===void 0||s.trim()==="")return e;const i=Number(s);return Number.isFinite(i)&&i>=a?i:e},"numberFrom");function swapRecyclePolicy(s=process.env){return{enabled:!["0","false","no","off"].includes((s.LENSMCP_SWAP_RECYCLE??"").trim().toLowerCase()),heapFactor:numberFrom(s.LENSMCP_SWAP_RECYCLE_HEAP_FACTOR,3,0),minHeapBytes:numberFrom(s.LENSMCP_SWAP_RECYCLE_MIN_MB,512,0)*MB,heapRatio:Math.min(1,numberFrom(s.LENSMCP_SWAP_RECYCLE_HEAP_RATIO,.7,0)),maxSwaps:Math.floor(numberFrom(s.LENSMCP_SWAP_RECYCLE_AFTER,0,0)),stuckCloseMs:Math.floor(numberFrom(s.LENSMCP_SWAP_RECYCLE_STUCK_CLOSE_MS,6e4,0)),settleMs:Math.floor(numberFrom(s.LENSMCP_SWAP_RECYCLE_SETTLE_MS,5e3,0)),retainedMs:Math.floor(numberFrom(s.LENSMCP_SWAP_RECYCLE_RETAINED_MS,10*6e4,0))}}n(swapRecyclePolicy,"swapRecyclePolicy"),r(swapRecyclePolicy,"swapRecyclePolicy");const mb=r(s=>(s/MB).toFixed(0),"mb");function recycleReason(s,e){if(!(!s.enabled||e.swaps<1)){if(s.maxSwaps>0&&e.swaps>=s.maxSwaps)return`${e.swaps} hot swaps in this process (LENSMCP_SWAP_RECYCLE_AFTER=${s.maxSwaps})`;if(s.stuckCloseMs>0&&(e.stuckCloses??0)>0){const a=e.stuckCloses;return`${a} previous app${a===1?" has":"s have"} not finished closing after ${Math.round(s.stuckCloseMs/1e3)}s \u2014 a shutdown hook that never returns keeps the whole app, its connections included, in memory`}if(s.retainedMs>0&&e.retained&&e.retained.gcs>=2&&e.retained.ageMs>=s.retainedMs){const a=e.retained,i=a.ageMs<9e4?`${Math.round(a.ageMs/1e3)}s`:`${Math.round(a.ageMs/6e4)} min`;return`generation ${a.generation} is still in memory ${i} after its app was closed, through ${a.gcs} full GCs \u2014 something still points into it, and only a fresh process gives it back`}if(s.heapRatio>0&&e.limitBytes>0&&e.usedBytes>=s.heapRatio*e.limitBytes){const a=Math.round(e.usedBytes/e.limitBytes*100);return`its heap is ${mb(e.usedBytes)} MB after a full GC, ${a}% of V8's ${mb(e.limitBytes)} MB limit`}if(s.heapFactor>0&&e.settled!==!1&&e.baselineBytes!==void 0&&e.baselineBytes>0&&e.usedBytes>=s.minHeapBytes&&e.usedBytes>=s.heapFactor*e.baselineBytes){const a=(e.usedBytes/e.baselineBytes).toFixed(1);return`its heap is ${mb(e.usedBytes)} MB after a full GC, ${a}\xD7 the ${mb(e.baselineBytes)} MB it booted with \u2014 earlier generations of the bundle are still in memory`}}}n(recycleReason,"recycleReason"),r(recycleReason,"recycleReason");
1
+ "use strict";var c=Object.defineProperty;var l=(s,e)=>c(s,"name",{value:e,configurable:!0});var o=Object.defineProperty,n=l((s,e)=>o(s,"name",{value:e,configurable:!0}),"n"),t=Object.defineProperty,r=n((s,e)=>t(s,"name",{value:e,configurable:!0}),"r");Object.defineProperty(exports,"__esModule",{value:!0}),exports.swapRecyclePolicy=swapRecyclePolicy,exports.recycleReason=recycleReason;const MB=1024*1024,numberFrom=r((s,e,a)=>{if(s===void 0||s.trim()==="")return e;const i=Number(s);return Number.isFinite(i)&&i>=a?i:e},"numberFrom");function swapRecyclePolicy(s=process.env){return{enabled:!["0","false","no","off"].includes((s.LENSMCP_SWAP_RECYCLE??"").trim().toLowerCase()),heapFactor:numberFrom(s.LENSMCP_SWAP_RECYCLE_HEAP_FACTOR,3,0),minHeapBytes:numberFrom(s.LENSMCP_SWAP_RECYCLE_MIN_MB,512,0)*MB,heapRatio:Math.min(1,numberFrom(s.LENSMCP_SWAP_RECYCLE_HEAP_RATIO,.7,0)),maxSwaps:Math.floor(numberFrom(s.LENSMCP_SWAP_RECYCLE_AFTER,0,0)),stuckCloseMs:Math.floor(numberFrom(s.LENSMCP_SWAP_RECYCLE_STUCK_CLOSE_MS,6e4,0)),settleMs:Math.floor(numberFrom(s.LENSMCP_SWAP_RECYCLE_SETTLE_MS,5e3,0)),retainedMs:Math.floor(numberFrom(s.LENSMCP_SWAP_RECYCLE_RETAINED_MS,10*6e4,0))}}l(swapRecyclePolicy,"swapRecyclePolicy"),n(swapRecyclePolicy,"swapRecyclePolicy"),r(swapRecyclePolicy,"swapRecyclePolicy");const mb=r(s=>(s/MB).toFixed(0),"mb");function recycleReason(s,e){if(!(!s.enabled||e.swaps<1)){if(s.maxSwaps>0&&e.swaps>=s.maxSwaps)return`${e.swaps} hot swaps in this process (LENSMCP_SWAP_RECYCLE_AFTER=${s.maxSwaps})`;if(s.stuckCloseMs>0&&(e.stuckCloses??0)>0){const a=e.stuckCloses;return`${a} previous app${a===1?" has":"s have"} not finished closing after ${Math.round(s.stuckCloseMs/1e3)}s \u2014 a shutdown hook that never returns keeps the whole app, its connections included, in memory`}if(s.retainedMs>0&&e.retained&&e.retained.gcs>=2&&e.retained.ageMs>=s.retainedMs){const a=e.retained,i=a.ageMs<9e4?`${Math.round(a.ageMs/1e3)}s`:`${Math.round(a.ageMs/6e4)} min`;return`generation ${a.generation} is still in memory ${i} after its app was closed, through ${a.gcs} full GCs \u2014 something still points into it, and only a fresh process gives it back`}if(s.heapRatio>0&&e.limitBytes>0&&e.usedBytes>=s.heapRatio*e.limitBytes){const a=Math.round(e.usedBytes/e.limitBytes*100);return`its heap is ${mb(e.usedBytes)} MB after a full GC, ${a}% of V8's ${mb(e.limitBytes)} MB limit`}if(s.heapFactor>0&&e.settled!==!1&&e.baselineBytes!==void 0&&e.baselineBytes>0&&e.usedBytes>=s.minHeapBytes&&e.usedBytes>=s.heapFactor*e.baselineBytes){const a=(e.usedBytes/e.baselineBytes).toFixed(1);return`its heap is ${mb(e.usedBytes)} MB after a full GC, ${a}\xD7 the ${mb(e.baselineBytes)} MB it booted with \u2014 earlier generations of the bundle are still in memory`}}}l(recycleReason,"recycleReason"),n(recycleReason,"recycleReason"),r(recycleReason,"recycleReason");
@@ -1,5 +1,5 @@
1
- "use strict";var y=Object.defineProperty;var h=(e,t)=>y(e,"name",{value:t,configurable:!0});var S=Object.defineProperty,a=h((e,t)=>S(e,"name",{value:t,configurable:!0}),"a");Object.defineProperty(exports,"__esModule",{value:!0}),exports.TsgoCheckPlugin=exports.TSGO_MISSING_CAUSE=exports.TSGO_PACKAGE=void 0,exports.checkerMaxProcs=checkerMaxProcs,exports.resolveTsgoPackageDir=resolveTsgoPackageDir,exports.resolveTsgoBin=resolveTsgoBin,exports.reportTsgoUnavailable=reportTsgoUnavailable,exports.effectivePaths=effectivePaths,exports.writeShimTsconfig=writeShimTsconfig;const tslib_1=require("tslib"),node_child_process_1=require("node:child_process"),fs=tslib_1.__importStar(require("node:fs")),path=tslib_1.__importStar(require("node:path")),typecheck_bus_1=require("./typecheck-bus"),typecheck_queue_1=require("./typecheck-queue"),DEFAULT_TIMEOUT_MS=12e4,DEFAULT_MAX_PROCS=4;function checkerMaxProcs(e=process.env){const t=Number(e.LENSMCP_TYPECHECK_GOMAXPROCS);return Number.isInteger(t)&&t>=1?t:DEFAULT_MAX_PROCS}h(checkerMaxProcs,"checkerMaxProcs"),a(checkerMaxProcs,"checkerMaxProcs");const livePlugins=new Set;let exitHooked=!1;function stopWithTheProcess(e){livePlugins.add(e),!exitHooked&&(exitHooked=!0,process.once("exit",()=>{for(const t of livePlugins)t.dispose()}))}h(stopWithTheProcess,"stopWithTheProcess"),a(stopWithTheProcess,"stopWithTheProcess"),exports.TSGO_PACKAGE="@typescript/native-preview";function shimNames(e){return e==="win32"?["tsgo.cmd","tsgo.exe"]:["tsgo"]}h(shimNames,"shimNames"),a(shimNames,"shimNames");function isExecutableFile(e,t){try{if(!fs.statSync(e).isFile())return!1}catch{return!1}if(t==="win32")return!0;try{return fs.accessSync(e,fs.constants.X_OK),!0}catch{return!1}}h(isExecutableFile,"isExecutableFile"),a(isExecutableFile,"isExecutableFile");function resolveTsgoPackageDir(){try{return path.dirname(require.resolve(`${exports.TSGO_PACKAGE}/package.json`))}catch{}try{let e=path.dirname(require.resolve(exports.TSGO_PACKAGE));for(let t=0;t<6;t++){const o=path.join(e,"package.json");if(fs.existsSync(o))try{const{name:s}=JSON.parse(fs.readFileSync(o,"utf8"));if(s===exports.TSGO_PACKAGE)return e}catch{}const r=path.dirname(e);if(r===e)break;e=r}}catch{}return null}h(resolveTsgoPackageDir,"resolveTsgoPackageDir"),a(resolveTsgoPackageDir,"resolveTsgoPackageDir");function packageDeclaredBin(e){try{const{bin:t}=JSON.parse(fs.readFileSync(path.join(e,"package.json"),"utf8")),o=typeof t=="string"?t:t?.tsgo;return o?path.join(e,o):null}catch{return null}}h(packageDeclaredBin,"packageDeclaredBin"),a(packageDeclaredBin,"packageDeclaredBin");function ownBinCandidates(e,t){const o=path.resolve(e,"..","..",".bin"),r=shimNames(t).map(i=>path.join(o,i)),s=t==="win32"?null:packageDeclaredBin(e);return s?[s,...r]:r}h(ownBinCandidates,"ownBinCandidates"),a(ownBinCandidates,"ownBinCandidates");function resolveTsgoBin(e,t,o={}){const r=o.platform??process.platform,s=o.isExecutable??(n=>isExecutableFile(n,r));if(t)return s(t)?t:null;for(const n of shimNames(r)){const l=path.join(e,"node_modules",".bin",n);if(s(l))return l}const i=(o.ownPackageDir??resolveTsgoPackageDir)();return i?ownBinCandidates(i,r).find(s)??null:null}h(resolveTsgoBin,"resolveTsgoBin"),a(resolveTsgoBin,"resolveTsgoBin"),exports.TSGO_MISSING_CAUSE=`tsgo binary not found \u2014 @lensmcp/cluster depends on ${exports.TSGO_PACKAGE}, so an absent binary means an incomplete install (reinstall node_modules), a platform with no ${exports.TSGO_PACKAGE} build, or a LENSMCP_TSGO_BIN override pointing at a missing or non-executable file`;function reportTsgoUnavailable(e){try{(0,typecheck_bus_1.publishTypecheckRun)({workspaceRoot:e.workspaceRoot,project:e.appName,tool:"tsgo",tsConfig:e.tsConfig,output:"",durationMs:0,toolError:e.detail,...e.eventFile?{eventFile:e.eventFile}:{}})}catch{}}h(reportTsgoUnavailable,"reportTsgoUnavailable"),a(reportTsgoUnavailable,"reportTsgoUnavailable");function parseJsonc(e){let t="",o=!1,r=!1,s=!1;for(let i=0;i<e.length;i++){const n=e[i],l=e[i+1];if(r){n===`
2
- `&&(r=!1,t+=n);continue}if(s){n==="*"&&l==="/"&&(s=!1,i++);continue}if(o){t+=n,n==="\\"?(t+=l??"",i++):n==='"'&&(o=!1);continue}if(n==='"'){o=!0,t+=n;continue}if(n==="/"&&l==="/"){r=!0,i++;continue}if(n==="/"&&l==="*"){s=!0,i++;continue}t+=n}try{return JSON.parse(t.replace(/,(\s*[}\]])/g,"$1"))}catch{return null}}h(parseJsonc,"parseJsonc"),a(parseJsonc,"parseJsonc");function resolveExtends(e,t){if(!e.startsWith(".")&&!path.isAbsolute(e))return null;const o=path.isAbsolute(e)?e:path.resolve(t,e);for(const r of[o,`${o}.json`,path.join(o,"tsconfig.json")])try{if(fs.statSync(r).isFile())return r}catch{}return null}h(resolveExtends,"resolveExtends"),a(resolveExtends,"resolveExtends");function effectivePaths(e,t=new Set){if(t.has(e))return null;t.add(e);let o;try{o=fs.readFileSync(e,"utf8")}catch{return null}const r=parseJsonc(o);if(!r)return null;const s=path.dirname(e),i=r.compilerOptions??{},n=Array.isArray(r.extends)?r.extends.filter(p=>typeof p=="string"):typeof r.extends=="string"?[r.extends]:[],l=a(()=>{for(const p of[...n].reverse()){const d=resolveExtends(p,s);if(!d)continue;const f=effectivePaths(d,t);if(f)return f}return null},"inherited"),u=i.paths,c=typeof i.baseUrl=="string"?path.resolve(s,i.baseUrl):void 0;if(!u){const p=l();return p?{paths:p.paths,anchorDir:c??p.anchorDir}:null}return{paths:u,anchorDir:c??l()?.anchorDir??s}}h(effectivePaths,"effectivePaths"),a(effectivePaths,"effectivePaths");function writeShimTsconfig(e,t,o){const r=path.join(o,"tmp","lensmcp-tsgo");fs.mkdirSync(r,{recursive:!0});const s=path.join(r,`${e}.tsconfig.json`),i=effectivePaths(t),n=i?Object.fromEntries(Object.entries(i.paths).map(([l,u])=>[l,(Array.isArray(u)?u:[]).map(c=>path.isAbsolute(c)?c:path.resolve(i.anchorDir,c))])):void 0;return fs.writeFileSync(s,JSON.stringify({extends:t,compilerOptions:{module:"preserve",moduleResolution:"bundler",isolatedModules:!1,baseUrl:null,...n&&Object.keys(n).length?{paths:n}:{}}},null,2)),s}h(writeShimTsconfig,"writeShimTsconfig"),a(writeShimTsconfig,"writeShimTsconfig");class TsgoCheckPlugin{static{h(this,"TsgoCheckPlugin")}static{a(this,"TsgoCheckPlugin")}constructor(t){this.timer=null,this.phase="idle",this.dirty=!1,this.ticket=null,this.inflight=null,this.askedAt=0,this.shimPath=null,this.disabled=!1,this.disposed=!1,this.opts=t,this.spawnImpl=t.spawnImpl??node_child_process_1.spawn,this.queue=t.queue??(0,typecheck_queue_1.machineTypecheckQueue)()}apply(t){t.hooks.done.tap("TsgoCheckPlugin",o=>{o.hasErrors()||this.schedule()}),t.hooks.shutdown?.tap?.("TsgoCheckPlugin",()=>this.dispose()),stopWithTheProcess(this)}schedule(){this.disabled||this.disposed||(this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>this.request(),this.opts.debounceMs??500),this.timer.unref?.())}request(){if(this.disabled||this.disposed)return;if(this.phase==="running"){this.dirty=!0;return}if(this.phase==="waiting")return;this.phase="waiting",this.askedAt=Date.now();const t=this.queue(this.opts.appName,()=>this.run());this.isIdle()?t.release():this.ticket=t}isIdle(){return this.phase==="idle"}publish(t){if(this.opts.publishEvents!==!1)try{(0,typecheck_bus_1.publishTypecheckRun)({workspaceRoot:this.opts.workspaceRoot,project:this.opts.appName,tool:"tsgo",tsConfig:this.opts.tsConfig,output:t.output,durationMs:t.durationMs,...t.toolError?{toolError:t.toolError}:{},...this.opts.eventFile?{eventFile:this.opts.eventFile}:{}})}catch{}}run(){if(this.disposed)return this.leave();let t;try{t=resolveTsgoBin(this.opts.workspaceRoot,this.opts.binPath),t&&!this.shimPath&&(this.shimPath=writeShimTsconfig(this.opts.appName,this.opts.tsConfig,this.opts.workspaceRoot))}catch(c){return console.warn(`[tsgo] ${this.opts.appName}: could not prepare the check \u2014 ${c.message}`),this.publish({output:"",durationMs:0,toolError:`could not prepare the check: ${c.message}`}),this.leave()}if(!t){this.disabled=!0;const c=`${exports.TSGO_MISSING_CAUSE}. Type checking is disabled for the rest of this session`;return console.warn(`[tsgo] ${this.opts.appName}: ${c}.`),this.publish({output:"",durationMs:0,toolError:c}),this.leave()}this.phase="running",this.dirty=!1;const o=Date.now(),r=o-this.askedAt,s=this.spawnImpl(t,["--noEmit","--pretty","false","-p",this.shimPath],{cwd:this.opts.workspaceRoot,stdio:["ignore","pipe","pipe"],env:{...process.env,GOMAXPROCS:process.env.GOMAXPROCS??String(this.opts.maxProcs??checkerMaxProcs())}});this.inflight=s;let i="",n=!1;const l=this.opts.timeoutMs??DEFAULT_TIMEOUT_MS,u=setTimeout(()=>{n=!0,s.kill("SIGKILL")},l);u.unref?.(),s.stdout?.on("data",c=>{i+=c.toString()}),s.stderr?.on("data",c=>{i+=c.toString()}),s.on("error",()=>{clearTimeout(u),this.inflight===s&&(console.warn(`[tsgo] ${this.opts.appName}: failed to spawn ${t}`),this.publish({output:"",durationMs:Date.now()-o,toolError:`failed to spawn ${t}`}),this.finish(s))}),s.on("close",(c,p)=>{if(clearTimeout(u),this.inflight!==s)return;const d=Date.now()-o,f=(d/1e3).toFixed(1),m=r>=1e3?`${f}s, waited ${(r/1e3).toFixed(1)}s`:`${f}s`;if(this.disposed)return this.finish(s);if(n){const k=`the check was killed after ${Math.round(l/1e3)}s without finishing`;return console.warn(`[tsgo] ${this.opts.appName}: ${k} \u2014 no verdict.`),this.publish({output:"",durationMs:d,toolError:k}),this.finish(s)}if(p)return this.finish(s);if(c===0)return console.log(`[tsgo] ${this.opts.appName}: types clean (${m})`),this.publish({output:"",durationMs:d}),this.finish(s);i.trim()&&process.stdout.write(i.endsWith(`
1
+ "use strict";var b=Object.defineProperty;var l=(e,t)=>b(e,"name",{value:t,configurable:!0});var y=Object.defineProperty,h=l((e,t)=>y(e,"name",{value:t,configurable:!0}),"h"),S=Object.defineProperty,a=h((e,t)=>S(e,"name",{value:t,configurable:!0}),"a");Object.defineProperty(exports,"__esModule",{value:!0}),exports.TsgoCheckPlugin=exports.TSGO_MISSING_CAUSE=exports.TSGO_PACKAGE=void 0,exports.checkerMaxProcs=checkerMaxProcs,exports.resolveTsgoPackageDir=resolveTsgoPackageDir,exports.resolveTsgoBin=resolveTsgoBin,exports.reportTsgoUnavailable=reportTsgoUnavailable,exports.effectivePaths=effectivePaths,exports.writeShimTsconfig=writeShimTsconfig;const tslib_1=require("tslib"),node_child_process_1=require("node:child_process"),fs=tslib_1.__importStar(require("node:fs")),path=tslib_1.__importStar(require("node:path")),typecheck_bus_1=require("./typecheck-bus"),typecheck_queue_1=require("./typecheck-queue"),DEFAULT_TIMEOUT_MS=12e4,DEFAULT_MAX_PROCS=4;function checkerMaxProcs(e=process.env){const t=Number(e.LENSMCP_TYPECHECK_GOMAXPROCS);return Number.isInteger(t)&&t>=1?t:DEFAULT_MAX_PROCS}l(checkerMaxProcs,"checkerMaxProcs"),h(checkerMaxProcs,"checkerMaxProcs"),a(checkerMaxProcs,"checkerMaxProcs");const livePlugins=new Set;let exitHooked=!1;function stopWithTheProcess(e){livePlugins.add(e),!exitHooked&&(exitHooked=!0,process.once("exit",()=>{for(const t of livePlugins)t.dispose()}))}l(stopWithTheProcess,"stopWithTheProcess"),h(stopWithTheProcess,"stopWithTheProcess"),a(stopWithTheProcess,"stopWithTheProcess"),exports.TSGO_PACKAGE="@typescript/native-preview";function shimNames(e){return e==="win32"?["tsgo.cmd","tsgo.exe"]:["tsgo"]}l(shimNames,"shimNames"),h(shimNames,"shimNames"),a(shimNames,"shimNames");function isExecutableFile(e,t){try{if(!fs.statSync(e).isFile())return!1}catch{return!1}if(t==="win32")return!0;try{return fs.accessSync(e,fs.constants.X_OK),!0}catch{return!1}}l(isExecutableFile,"isExecutableFile"),h(isExecutableFile,"isExecutableFile"),a(isExecutableFile,"isExecutableFile");function resolveTsgoPackageDir(){try{return path.dirname(require.resolve(`${exports.TSGO_PACKAGE}/package.json`))}catch{}try{let e=path.dirname(require.resolve(exports.TSGO_PACKAGE));for(let t=0;t<6;t++){const o=path.join(e,"package.json");if(fs.existsSync(o))try{const{name:s}=JSON.parse(fs.readFileSync(o,"utf8"));if(s===exports.TSGO_PACKAGE)return e}catch{}const r=path.dirname(e);if(r===e)break;e=r}}catch{}return null}l(resolveTsgoPackageDir,"resolveTsgoPackageDir"),h(resolveTsgoPackageDir,"resolveTsgoPackageDir"),a(resolveTsgoPackageDir,"resolveTsgoPackageDir");function packageDeclaredBin(e){try{const{bin:t}=JSON.parse(fs.readFileSync(path.join(e,"package.json"),"utf8")),o=typeof t=="string"?t:t?.tsgo;return o?path.join(e,o):null}catch{return null}}l(packageDeclaredBin,"packageDeclaredBin"),h(packageDeclaredBin,"packageDeclaredBin"),a(packageDeclaredBin,"packageDeclaredBin");function ownBinCandidates(e,t){const o=path.resolve(e,"..","..",".bin"),r=shimNames(t).map(i=>path.join(o,i)),s=t==="win32"?null:packageDeclaredBin(e);return s?[s,...r]:r}l(ownBinCandidates,"ownBinCandidates"),h(ownBinCandidates,"ownBinCandidates"),a(ownBinCandidates,"ownBinCandidates");function resolveTsgoBin(e,t,o={}){const r=o.platform??process.platform,s=o.isExecutable??(n=>isExecutableFile(n,r));if(t)return s(t)?t:null;for(const n of shimNames(r)){const u=path.join(e,"node_modules",".bin",n);if(s(u))return u}const i=(o.ownPackageDir??resolveTsgoPackageDir)();return i?ownBinCandidates(i,r).find(s)??null:null}l(resolveTsgoBin,"resolveTsgoBin"),h(resolveTsgoBin,"resolveTsgoBin"),a(resolveTsgoBin,"resolveTsgoBin"),exports.TSGO_MISSING_CAUSE=`tsgo binary not found \u2014 @lensmcp/cluster depends on ${exports.TSGO_PACKAGE}, so an absent binary means an incomplete install (reinstall node_modules), a platform with no ${exports.TSGO_PACKAGE} build, or a LENSMCP_TSGO_BIN override pointing at a missing or non-executable file`;function reportTsgoUnavailable(e){try{(0,typecheck_bus_1.publishTypecheckRun)({workspaceRoot:e.workspaceRoot,project:e.appName,tool:"tsgo",tsConfig:e.tsConfig,output:"",durationMs:0,toolError:e.detail,...e.eventFile?{eventFile:e.eventFile}:{}})}catch{}}l(reportTsgoUnavailable,"reportTsgoUnavailable"),h(reportTsgoUnavailable,"reportTsgoUnavailable"),a(reportTsgoUnavailable,"reportTsgoUnavailable");function parseJsonc(e){let t="",o=!1,r=!1,s=!1;for(let i=0;i<e.length;i++){const n=e[i],u=e[i+1];if(r){n===`
2
+ `&&(r=!1,t+=n);continue}if(s){n==="*"&&u==="/"&&(s=!1,i++);continue}if(o){t+=n,n==="\\"?(t+=u??"",i++):n==='"'&&(o=!1);continue}if(n==='"'){o=!0,t+=n;continue}if(n==="/"&&u==="/"){r=!0,i++;continue}if(n==="/"&&u==="*"){s=!0,i++;continue}t+=n}try{return JSON.parse(t.replace(/,(\s*[}\]])/g,"$1"))}catch{return null}}l(parseJsonc,"parseJsonc"),h(parseJsonc,"parseJsonc"),a(parseJsonc,"parseJsonc");function resolveExtends(e,t){if(!e.startsWith(".")&&!path.isAbsolute(e))return null;const o=path.isAbsolute(e)?e:path.resolve(t,e);for(const r of[o,`${o}.json`,path.join(o,"tsconfig.json")])try{if(fs.statSync(r).isFile())return r}catch{}return null}l(resolveExtends,"resolveExtends"),h(resolveExtends,"resolveExtends"),a(resolveExtends,"resolveExtends");function effectivePaths(e,t=new Set){if(t.has(e))return null;t.add(e);let o;try{o=fs.readFileSync(e,"utf8")}catch{return null}const r=parseJsonc(o);if(!r)return null;const s=path.dirname(e),i=r.compilerOptions??{},n=Array.isArray(r.extends)?r.extends.filter(d=>typeof d=="string"):typeof r.extends=="string"?[r.extends]:[],u=a(()=>{for(const d of[...n].reverse()){const f=resolveExtends(d,s);if(!f)continue;const g=effectivePaths(f,t);if(g)return g}return null},"inherited"),p=i.paths,c=typeof i.baseUrl=="string"?path.resolve(s,i.baseUrl):void 0;if(!p){const d=u();return d?{paths:d.paths,anchorDir:c??d.anchorDir}:null}return{paths:p,anchorDir:c??u()?.anchorDir??s}}l(effectivePaths,"effectivePaths"),h(effectivePaths,"effectivePaths"),a(effectivePaths,"effectivePaths");function writeShimTsconfig(e,t,o){const r=path.join(o,"tmp","lensmcp-tsgo");fs.mkdirSync(r,{recursive:!0});const s=path.join(r,`${e}.tsconfig.json`),i=effectivePaths(t),n=i?Object.fromEntries(Object.entries(i.paths).map(([u,p])=>[u,(Array.isArray(p)?p:[]).map(c=>path.isAbsolute(c)?c:path.resolve(i.anchorDir,c))])):void 0;return fs.writeFileSync(s,JSON.stringify({extends:t,compilerOptions:{module:"preserve",moduleResolution:"bundler",isolatedModules:!1,baseUrl:null,...n&&Object.keys(n).length?{paths:n}:{}}},null,2)),s}l(writeShimTsconfig,"writeShimTsconfig"),h(writeShimTsconfig,"writeShimTsconfig"),a(writeShimTsconfig,"writeShimTsconfig");class TsgoCheckPlugin{static{l(this,"TsgoCheckPlugin")}static{h(this,"TsgoCheckPlugin")}static{a(this,"TsgoCheckPlugin")}constructor(t){this.timer=null,this.phase="idle",this.dirty=!1,this.ticket=null,this.inflight=null,this.askedAt=0,this.shimPath=null,this.disabled=!1,this.disposed=!1,this.opts=t,this.spawnImpl=t.spawnImpl??node_child_process_1.spawn,this.queue=t.queue??(0,typecheck_queue_1.machineTypecheckQueue)()}apply(t){t.hooks.done.tap("TsgoCheckPlugin",o=>{o.hasErrors()||this.schedule()}),t.hooks.shutdown?.tap?.("TsgoCheckPlugin",()=>this.dispose()),stopWithTheProcess(this)}schedule(){this.disabled||this.disposed||(this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>this.request(),this.opts.debounceMs??500),this.timer.unref?.())}request(){if(this.disabled||this.disposed)return;if(this.phase==="running"){this.dirty=!0;return}if(this.phase==="waiting")return;this.phase="waiting",this.askedAt=Date.now();const t=this.queue(this.opts.appName,()=>this.run());this.isIdle()?t.release():this.ticket=t}isIdle(){return this.phase==="idle"}publish(t){if(this.opts.publishEvents!==!1)try{(0,typecheck_bus_1.publishTypecheckRun)({workspaceRoot:this.opts.workspaceRoot,project:this.opts.appName,tool:"tsgo",tsConfig:this.opts.tsConfig,output:t.output,durationMs:t.durationMs,...t.toolError?{toolError:t.toolError}:{},...this.opts.eventFile?{eventFile:this.opts.eventFile}:{}})}catch{}}run(){if(this.disposed)return this.leave();let t;try{t=resolveTsgoBin(this.opts.workspaceRoot,this.opts.binPath),t&&!this.shimPath&&(this.shimPath=writeShimTsconfig(this.opts.appName,this.opts.tsConfig,this.opts.workspaceRoot))}catch(c){return console.warn(`[tsgo] ${this.opts.appName}: could not prepare the check \u2014 ${c.message}`),this.publish({output:"",durationMs:0,toolError:`could not prepare the check: ${c.message}`}),this.leave()}if(!t){this.disabled=!0;const c=`${exports.TSGO_MISSING_CAUSE}. Type checking is disabled for the rest of this session`;return console.warn(`[tsgo] ${this.opts.appName}: ${c}.`),this.publish({output:"",durationMs:0,toolError:c}),this.leave()}this.phase="running",this.dirty=!1;const o=Date.now(),r=o-this.askedAt,s=this.spawnImpl(t,["--noEmit","--pretty","false","-p",this.shimPath],{cwd:this.opts.workspaceRoot,stdio:["ignore","pipe","pipe"],env:{...process.env,GOMAXPROCS:process.env.GOMAXPROCS??String(this.opts.maxProcs??checkerMaxProcs())}});this.inflight=s;let i="",n=!1;const u=this.opts.timeoutMs??DEFAULT_TIMEOUT_MS,p=setTimeout(()=>{n=!0,s.kill("SIGKILL")},u);p.unref?.(),s.stdout?.on("data",c=>{i+=c.toString()}),s.stderr?.on("data",c=>{i+=c.toString()}),s.on("error",()=>{clearTimeout(p),this.inflight===s&&(console.warn(`[tsgo] ${this.opts.appName}: failed to spawn ${t}`),this.publish({output:"",durationMs:Date.now()-o,toolError:`failed to spawn ${t}`}),this.finish(s))}),s.on("close",(c,d)=>{if(clearTimeout(p),this.inflight!==s)return;const f=Date.now()-o,g=(f/1e3).toFixed(1),k=r>=1e3?`${g}s, waited ${(r/1e3).toFixed(1)}s`:`${g}s`;if(this.disposed)return this.finish(s);if(n){const v=`the check was killed after ${Math.round(u/1e3)}s without finishing`;return console.warn(`[tsgo] ${this.opts.appName}: ${v} \u2014 no verdict.`),this.publish({output:"",durationMs:f,toolError:v}),this.finish(s)}if(d)return this.finish(s);if(c===0)return console.log(`[tsgo] ${this.opts.appName}: types clean (${k})`),this.publish({output:"",durationMs:f}),this.finish(s);i.trim()&&process.stdout.write(i.endsWith(`
3
3
  `)?i:`${i}
4
- `);const g=(i.match(/error TS\d+/g)??[]).length;console.log(`[tsgo] ${this.opts.appName}: ${g} type error${g===1?"":"s"} (${m})`),this.publish({output:i,durationMs:d,...g===0?{toolError:`tsgo exited ${c} with no diagnostics: ${firstLine(i)}`}:{}}),this.finish(s)})}finish(t){this.inflight===t&&(this.inflight=null),this.leave(),this.dirty&&!this.disposed&&(this.dirty=!1,this.request())}leave(){this.phase="idle",this.ticket?.release(),this.ticket=null}dispose(){this.disposed||(this.disposed=!0,livePlugins.delete(this),this.timer&&clearTimeout(this.timer),this.inflight?.kill("SIGKILL"),this.ticket?.release(),this.ticket=null)}}exports.TsgoCheckPlugin=TsgoCheckPlugin;function firstLine(e){return e.trim().split(`
5
- `)[0]?.slice(0,300)??""}h(firstLine,"firstLine"),a(firstLine,"firstLine");
4
+ `);const m=(i.match(/error TS\d+/g)??[]).length;console.log(`[tsgo] ${this.opts.appName}: ${m} type error${m===1?"":"s"} (${k})`),this.publish({output:i,durationMs:f,...m===0?{toolError:`tsgo exited ${c} with no diagnostics: ${firstLine(i)}`}:{}}),this.finish(s)})}finish(t){this.inflight===t&&(this.inflight=null),this.leave(),this.dirty&&!this.disposed&&(this.dirty=!1,this.request())}leave(){this.phase="idle",this.ticket?.release(),this.ticket=null}dispose(){this.disposed||(this.disposed=!0,livePlugins.delete(this),this.timer&&clearTimeout(this.timer),this.inflight?.kill("SIGKILL"),this.ticket?.release(),this.ticket=null)}}exports.TsgoCheckPlugin=TsgoCheckPlugin;function firstLine(e){return e.trim().split(`
5
+ `)[0]?.slice(0,300)??""}l(firstLine,"firstLine"),h(firstLine,"firstLine"),a(firstLine,"firstLine");
package/typecheck-bus.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var d=Object.defineProperty;var s=(e,r)=>d(e,"name",{value:r,configurable:!0});var f=Object.defineProperty,i=s((e,r)=>f(e,"name",{value:r,configurable:!0}),"i");Object.defineProperty(exports,"__esModule",{value:!0}),exports.MAX_DIAGNOSTICS_PER_RUN=void 0,exports.stripAnsi=stripAnsi,exports.parseTscDiagnosticLine=parseTscDiagnosticLine,exports.parseTscOutput=parseTscOutput,exports.buildTypecheckRunEvents=buildTypecheckRunEvents,exports.resolveEventFile=resolveEventFile,exports.appendTypecheckEvents=appendTypecheckEvents,exports.publishTypecheckDiagnostics=publishTypecheckDiagnostics,exports.publishTypecheckRun=publishTypecheckRun;const tslib_1=require("tslib"),fs=tslib_1.__importStar(require("node:fs")),path=tslib_1.__importStar(require("node:path")),busHygiene=(()=>{try{return require("@lensmcp/node-instrumentation")}catch{return}})(),DIAG_LINE_REGEX=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+(TS\d+):\s+(.+)$/,ANSI_CSI=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function stripAnsi(e){return e.replace(ANSI_CSI,"")}s(stripAnsi,"stripAnsi"),i(stripAnsi,"stripAnsi");function parseTscDiagnosticLine(e){const r=stripAnsi(e).trim();if(!r)return null;const o=DIAG_LINE_REGEX.exec(r);if(!o)return null;const[,t,u,l,c,a,p]=o;return!t||!u||!l||!c||!a||!p?null:{file:t,line:Number(u),column:Number(l),severity:c==="warning"?"warning":"error",code:a,message:p}}s(parseTscDiagnosticLine,"parseTscDiagnosticLine"),i(parseTscDiagnosticLine,"parseTscDiagnosticLine");function parseTscOutput(e){const r=[];for(const o of e.split(`
2
- `)){const t=parseTscDiagnosticLine(o);t&&r.push(t)}return r}s(parseTscOutput,"parseTscOutput"),i(parseTscOutput,"parseTscOutput"),exports.MAX_DIAGNOSTICS_PER_RUN=200;let idCounter=0;function makeId(){return idCounter=(idCounter+1)%65535,`${Date.now().toString(36)}${idCounter.toString(36)}${Math.random().toString(36).slice(2,8)}`}s(makeId,"makeId"),i(makeId,"makeId");function buildTypecheckRunEvents(e){const r=(e.now??Date.now)(),o=e.idImpl??makeId,t="pending",u={sessionId:t,source:"typescript",category:"typecheck",context:{sessionId:t,projectName:e.project}},l={project:e.project,tool:e.tool,...e.tsConfig?{tsConfig:e.tsConfig}:{}},c=e.diagnostics.filter(n=>n.severity==="error"),a=e.diagnostics.slice(0,exports.MAX_DIAGNOSTICS_PER_RUN),p=[];if(!e.toolError){p.push({...u,id:o(),timestamp:r,severity:"info",title:`tsc clear: ${e.project}`,message:`typecheck run starting for ${e.project}`,fingerprint:`tsc:${e.project}:run-start`,raw:{...l,kind:"typecheck-run",phase:"start"}});for(const n of a)p.push({...u,id:o(),timestamp:r,severity:n.severity,title:`${n.code}: ${n.message}`,message:n.message,location:{file:n.file,line:n.line,column:n.column},fingerprint:`tsc:${e.project}:${n.file}:${n.line}:${n.column}:${n.code}`,raw:{...l,kind:"typecheck-diagnostic",code:n.code}})}const g=e.toolError?"error":c.length>0?"failing":"clean";return p.push({...u,id:o(),timestamp:r,severity:"info",title:`typecheck run: ${e.project} \u2014 ${e.toolError?"tool error":`${c.length} error${c.length===1?"":"s"}`} (${e.durationMs}ms)`,...e.toolError?{message:e.toolError}:{},fingerprint:`tsc:${e.project}:run-end`,raw:{...l,kind:"typecheck-run",phase:"end",status:g,durationMs:e.durationMs,errorCount:c.length,warningCount:e.diagnostics.length-c.length,...e.diagnostics.length>a.length?{truncatedDiagnostics:e.diagnostics.length-a.length}:{},...e.toolError?{error:e.toolError}:{}}}),p}s(buildTypecheckRunEvents,"buildTypecheckRunEvents"),i(buildTypecheckRunEvents,"buildTypecheckRunEvents");function resolveEventFile(e){return process.env.LENSMCP_EVENT_FILE||path.join(e,".lensmcp","events.jsonl")}s(resolveEventFile,"resolveEventFile"),i(resolveEventFile,"resolveEventFile");let ensuredDir=null;function ensureDir(e){const r=path.dirname(e);ensuredDir!==r&&(fs.mkdirSync(r,{recursive:!0}),ensuredDir=r)}s(ensureDir,"ensureDir"),i(ensureDir,"ensureDir");function appendTypecheckEvents(e,r){if(r.length===0)return;const o=r.map(t=>JSON.stringify(t)).join(`
1
+ "use strict";var y=Object.defineProperty;var c=(t,e)=>y(t,"name",{value:e,configurable:!0});var d=Object.defineProperty,s=c((t,e)=>d(t,"name",{value:e,configurable:!0}),"s"),f=Object.defineProperty,i=s((t,e)=>f(t,"name",{value:e,configurable:!0}),"i");Object.defineProperty(exports,"__esModule",{value:!0}),exports.MAX_DIAGNOSTICS_PER_RUN=void 0,exports.stripAnsi=stripAnsi,exports.parseTscDiagnosticLine=parseTscDiagnosticLine,exports.parseTscOutput=parseTscOutput,exports.buildTypecheckRunEvents=buildTypecheckRunEvents,exports.resolveEventFile=resolveEventFile,exports.appendTypecheckEvents=appendTypecheckEvents,exports.publishTypecheckDiagnostics=publishTypecheckDiagnostics,exports.publishTypecheckRun=publishTypecheckRun;const tslib_1=require("tslib"),fs=tslib_1.__importStar(require("node:fs")),path=tslib_1.__importStar(require("node:path")),busHygiene=(()=>{try{return require("@lensmcp/node-instrumentation")}catch{return}})(),DIAG_LINE_REGEX=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+(TS\d+):\s+(.+)$/,ANSI_CSI=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function stripAnsi(t){return t.replace(ANSI_CSI,"")}c(stripAnsi,"stripAnsi"),s(stripAnsi,"stripAnsi"),i(stripAnsi,"stripAnsi");function parseTscDiagnosticLine(t){const e=stripAnsi(t).trim();if(!e)return null;const n=DIAG_LINE_REGEX.exec(e);if(!n)return null;const[,o,l,a,p,g,u]=n;return!o||!l||!a||!p||!g||!u?null:{file:o,line:Number(l),column:Number(a),severity:p==="warning"?"warning":"error",code:g,message:u}}c(parseTscDiagnosticLine,"parseTscDiagnosticLine"),s(parseTscDiagnosticLine,"parseTscDiagnosticLine"),i(parseTscDiagnosticLine,"parseTscDiagnosticLine");function parseTscOutput(t){const e=[];for(const n of t.split(`
2
+ `)){const o=parseTscDiagnosticLine(n);o&&e.push(o)}return e}c(parseTscOutput,"parseTscOutput"),s(parseTscOutput,"parseTscOutput"),i(parseTscOutput,"parseTscOutput"),exports.MAX_DIAGNOSTICS_PER_RUN=200;let idCounter=0;function makeId(){return idCounter=(idCounter+1)%65535,`${Date.now().toString(36)}${idCounter.toString(36)}${Math.random().toString(36).slice(2,8)}`}c(makeId,"makeId"),s(makeId,"makeId"),i(makeId,"makeId");function buildTypecheckRunEvents(t){const e=(t.now??Date.now)(),n=t.idImpl??makeId,o="pending",l={sessionId:o,source:"typescript",category:"typecheck",context:{sessionId:o,projectName:t.project}},a={project:t.project,tool:t.tool,...t.tsConfig?{tsConfig:t.tsConfig}:{}},p=t.diagnostics.filter(r=>r.severity==="error"),g=t.diagnostics.slice(0,exports.MAX_DIAGNOSTICS_PER_RUN),u=[];if(!t.toolError){u.push({...l,id:n(),timestamp:e,severity:"info",title:`tsc clear: ${t.project}`,message:`typecheck run starting for ${t.project}`,fingerprint:`tsc:${t.project}:run-start`,raw:{...a,kind:"typecheck-run",phase:"start"}});for(const r of g)u.push({...l,id:n(),timestamp:e,severity:r.severity,title:`${r.code}: ${r.message}`,message:r.message,location:{file:r.file,line:r.line,column:r.column},fingerprint:`tsc:${t.project}:${r.file}:${r.line}:${r.column}:${r.code}`,raw:{...a,kind:"typecheck-diagnostic",code:r.code}})}const h=t.toolError?"error":p.length>0?"failing":"clean";return u.push({...l,id:n(),timestamp:e,severity:"info",title:`typecheck run: ${t.project} \u2014 ${t.toolError?"tool error":`${p.length} error${p.length===1?"":"s"}`} (${t.durationMs}ms)`,...t.toolError?{message:t.toolError}:{},fingerprint:`tsc:${t.project}:run-end`,raw:{...a,kind:"typecheck-run",phase:"end",status:h,durationMs:t.durationMs,errorCount:p.length,warningCount:t.diagnostics.length-p.length,...t.diagnostics.length>g.length?{truncatedDiagnostics:t.diagnostics.length-g.length}:{},...t.toolError?{error:t.toolError}:{}}}),u}c(buildTypecheckRunEvents,"buildTypecheckRunEvents"),s(buildTypecheckRunEvents,"buildTypecheckRunEvents"),i(buildTypecheckRunEvents,"buildTypecheckRunEvents");function resolveEventFile(t){return process.env.LENSMCP_EVENT_FILE||path.join(t,".lensmcp","events.jsonl")}c(resolveEventFile,"resolveEventFile"),s(resolveEventFile,"resolveEventFile"),i(resolveEventFile,"resolveEventFile");let ensuredDir=null;function ensureDir(t){const e=path.dirname(t);ensuredDir!==e&&(fs.mkdirSync(e,{recursive:!0}),ensuredDir=e)}c(ensureDir,"ensureDir"),s(ensureDir,"ensureDir"),i(ensureDir,"ensureDir");function appendTypecheckEvents(t,e){if(e.length===0)return;const n=e.map(o=>JSON.stringify(o)).join(`
3
3
  `)+`
4
- `;try{ensureDir(e),busHygiene?.maybeRotateEventFile(e,o.length),fs.appendFileSync(e,o)}catch(t){if(t?.code==="ENOENT"){try{ensuredDir=null,ensureDir(e),fs.appendFileSync(e,o)}catch{}return}}}s(appendTypecheckEvents,"appendTypecheckEvents"),i(appendTypecheckEvents,"appendTypecheckEvents");function publishTypecheckDiagnostics(e){const r=buildTypecheckRunEvents({project:e.project,tool:e.tool,...e.tsConfig?{tsConfig:e.tsConfig}:{},diagnostics:e.diagnostics,durationMs:e.durationMs});return appendTypecheckEvents(e.eventFile??resolveEventFile(e.workspaceRoot),r),r}s(publishTypecheckDiagnostics,"publishTypecheckDiagnostics"),i(publishTypecheckDiagnostics,"publishTypecheckDiagnostics");function publishTypecheckRun(e){const r=buildTypecheckRunEvents({project:e.project,tool:e.tool,...e.tsConfig?{tsConfig:e.tsConfig}:{},diagnostics:e.toolError?[]:parseTscOutput(e.output),durationMs:e.durationMs,...e.toolError?{toolError:e.toolError}:{}});return appendTypecheckEvents(e.eventFile??resolveEventFile(e.workspaceRoot),r),r}s(publishTypecheckRun,"publishTypecheckRun"),i(publishTypecheckRun,"publishTypecheckRun");
4
+ `;try{ensureDir(t),busHygiene?.maybeRotateEventFile(t,n.length),fs.appendFileSync(t,n)}catch(o){if(o?.code==="ENOENT"){try{ensuredDir=null,ensureDir(t),fs.appendFileSync(t,n)}catch{}return}}}c(appendTypecheckEvents,"appendTypecheckEvents"),s(appendTypecheckEvents,"appendTypecheckEvents"),i(appendTypecheckEvents,"appendTypecheckEvents");function publishTypecheckDiagnostics(t){const e=buildTypecheckRunEvents({project:t.project,tool:t.tool,...t.tsConfig?{tsConfig:t.tsConfig}:{},diagnostics:t.diagnostics,durationMs:t.durationMs});return appendTypecheckEvents(t.eventFile??resolveEventFile(t.workspaceRoot),e),e}c(publishTypecheckDiagnostics,"publishTypecheckDiagnostics"),s(publishTypecheckDiagnostics,"publishTypecheckDiagnostics"),i(publishTypecheckDiagnostics,"publishTypecheckDiagnostics");function publishTypecheckRun(t){const e=buildTypecheckRunEvents({project:t.project,tool:t.tool,...t.tsConfig?{tsConfig:t.tsConfig}:{},diagnostics:t.toolError?[]:parseTscOutput(t.output),durationMs:t.durationMs,...t.toolError?{toolError:t.toolError}:{}});return appendTypecheckEvents(t.eventFile??resolveEventFile(t.workspaceRoot),e),e}c(publishTypecheckRun,"publishTypecheckRun"),s(publishTypecheckRun,"publishTypecheckRun"),i(publishTypecheckRun,"publishTypecheckRun");
@@ -1 +1 @@
1
- "use strict";var T=Object.defineProperty;var c=(e,t)=>T(e,"name",{value:t,configurable:!0});var E=Object.defineProperty,r=c((e,t)=>E(e,"name",{value:t,configurable:!0}),"r");Object.defineProperty(exports,"__esModule",{value:!0}),exports.immediateQueue=void 0,exports.typecheckQueueDir=typecheckQueueDir,exports.typecheckSlots=typecheckSlots,exports.liveTickets=liveTickets,exports.machineTypecheckQueue=machineTypecheckQueue;const tslib_1=require("tslib"),fs=tslib_1.__importStar(require("node:fs")),os=tslib_1.__importStar(require("node:os")),path=tslib_1.__importStar(require("node:path")),TICKET_SUFFIX=".ticket",DEFAULT_POLL_MS=250,DEFAULT_SETTLE_MS=120,DEFAULT_MAX_AGE_MS=15*6e4,MAX_SLOTS=8;function typecheckQueueDir(e=process.env){return path.join(e.LENSMCP_HOME||os.homedir(),".lensmcp","typecheck-queue")}c(typecheckQueueDir,"typecheckQueueDir"),r(typecheckQueueDir,"typecheckQueueDir");function typecheckSlots(e=process.env){const t=Number(e.LENSMCP_TYPECHECK_CONCURRENCY);return Number.isInteger(t)&&t>=1?Math.min(t,MAX_SLOTS):1}c(typecheckSlots,"typecheckSlots"),r(typecheckSlots,"typecheckSlots");function pidAlive(e){try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}c(pidAlive,"pidAlive"),r(pidAlive,"pidAlive");const ticketPid=r(e=>{const t=Number(e.split("-")[0]);return Number.isInteger(t)&&t>0?t:void 0},"ticketPid");function liveTickets(e,t={}){const h=t.isAlive??pidAlive,S=(t.now??Date.now)(),m=t.maxAgeMs??DEFAULT_MAX_AGE_MS;let s;try{s=fs.readdirSync(e).filter(i=>i.endsWith(TICKET_SUFFIX))}catch{return[]}const u=[];for(const i of s){const n=path.join(e,i);let o;try{o=fs.statSync(n,{bigint:!0})}catch{continue}const a=ticketPid(i);if(a===void 0||!h(a)||S-Number(o.mtimeMs)>m){try{fs.unlinkSync(n)}catch{}continue}u.push({name:i,at:o.mtimeNs})}return u.sort((i,n)=>i.at<n.at?-1:i.at>n.at?1:i.name<n.name?-1:i.name>n.name?1:0),u.map(i=>i.name)}c(liveTickets,"liveTickets"),r(liveTickets,"liveTickets");let ticketSeq=0;function machineTypecheckQueue(e={}){const t=e.dir??typecheckQueueDir(),h=Math.max(1,e.slots??typecheckSlots()),S=e.pollMs??DEFAULT_POLL_MS,m=e.settleMs??DEFAULT_SETTLE_MS,s=e.pid??process.pid,u=r(()=>liveTickets(t,e),"scan");return(i,n)=>{const o=`${s}-${(ticketSeq++).toString(36)}-${Math.random().toString(36).slice(2,8)}${TICKET_SUFFIX}`,a=path.join(t,o);let l=!1,y=!1,p;const f=r(()=>{l||y||(y=!0,n())},"turn"),_=r(()=>{try{return fs.mkdirSync(t,{recursive:!0}),fs.writeFileSync(a,JSON.stringify({pid:s,label:i,at:(e.now??Date.now)()})),!0}catch{return!1}},"write"),k=r(d=>{p=setTimeout(M,d),p.unref?.()},"later");function M(){if(l||y)return;const d=u().indexOf(o);if(d===-1)return _()?k(m):f();if(d<h)return f();k(S)}return c(M,"k"),r(M,"look"),_()?(k(m),{release(){if(!l){l=!0,p&&clearTimeout(p);try{fs.unlinkSync(a)}catch{}}}}):(f(),{release(){l=!0}})}}c(machineTypecheckQueue,"machineTypecheckQueue"),r(machineTypecheckQueue,"machineTypecheckQueue");const immediateQueue=r((e,t)=>(t(),{release(){}}),"immediateQueue");exports.immediateQueue=immediateQueue;
1
+ "use strict";var b=Object.defineProperty;var o=(e,t)=>b(e,"name",{value:t,configurable:!0});var T=Object.defineProperty,c=o((e,t)=>T(e,"name",{value:t,configurable:!0}),"c"),E=Object.defineProperty,r=c((e,t)=>E(e,"name",{value:t,configurable:!0}),"r");Object.defineProperty(exports,"__esModule",{value:!0}),exports.immediateQueue=void 0,exports.typecheckQueueDir=typecheckQueueDir,exports.typecheckSlots=typecheckSlots,exports.liveTickets=liveTickets,exports.machineTypecheckQueue=machineTypecheckQueue;const tslib_1=require("tslib"),fs=tslib_1.__importStar(require("node:fs")),os=tslib_1.__importStar(require("node:os")),path=tslib_1.__importStar(require("node:path")),TICKET_SUFFIX=".ticket",DEFAULT_POLL_MS=250,DEFAULT_SETTLE_MS=120,DEFAULT_MAX_AGE_MS=15*6e4,MAX_SLOTS=8;function typecheckQueueDir(e=process.env){return path.join(e.LENSMCP_HOME||os.homedir(),".lensmcp","typecheck-queue")}o(typecheckQueueDir,"typecheckQueueDir"),c(typecheckQueueDir,"typecheckQueueDir"),r(typecheckQueueDir,"typecheckQueueDir");function typecheckSlots(e=process.env){const t=Number(e.LENSMCP_TYPECHECK_CONCURRENCY);return Number.isInteger(t)&&t>=1?Math.min(t,MAX_SLOTS):1}o(typecheckSlots,"typecheckSlots"),c(typecheckSlots,"typecheckSlots"),r(typecheckSlots,"typecheckSlots");function pidAlive(e){try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}o(pidAlive,"pidAlive"),c(pidAlive,"pidAlive"),r(pidAlive,"pidAlive");const ticketPid=r(e=>{const t=Number(e.split("-")[0]);return Number.isInteger(t)&&t>0?t:void 0},"ticketPid");function liveTickets(e,t={}){const y=t.isAlive??pidAlive,k=(t.now??Date.now)(),p=t.maxAgeMs??DEFAULT_MAX_AGE_MS;let s;try{s=fs.readdirSync(e).filter(i=>i.endsWith(TICKET_SUFFIX))}catch{return[]}const a=[];for(const i of s){const n=path.join(e,i);let u;try{u=fs.statSync(n,{bigint:!0})}catch{continue}const l=ticketPid(i);if(l===void 0||!y(l)||k-Number(u.mtimeMs)>p){try{fs.unlinkSync(n)}catch{}continue}a.push({name:i,at:u.mtimeNs})}return a.sort((i,n)=>i.at<n.at?-1:i.at>n.at?1:i.name<n.name?-1:i.name>n.name?1:0),a.map(i=>i.name)}o(liveTickets,"liveTickets"),c(liveTickets,"liveTickets"),r(liveTickets,"liveTickets");let ticketSeq=0;function machineTypecheckQueue(e={}){const t=e.dir??typecheckQueueDir(),y=Math.max(1,e.slots??typecheckSlots()),k=e.pollMs??DEFAULT_POLL_MS,p=e.settleMs??DEFAULT_SETTLE_MS,s=e.pid??process.pid,a=r(()=>liveTickets(t,e),"scan");return(i,n)=>{const u=`${s}-${(ticketSeq++).toString(36)}-${Math.random().toString(36).slice(2,8)}${TICKET_SUFFIX}`,l=path.join(t,u);let m=!1,S=!1,h;const f=r(()=>{m||S||(S=!0,n())},"turn"),M=r(()=>{try{return fs.mkdirSync(t,{recursive:!0}),fs.writeFileSync(l,JSON.stringify({pid:s,label:i,at:(e.now??Date.now)()})),!0}catch{return!1}},"write"),_=r(d=>{h=setTimeout(v,d),h.unref?.()},"later");function v(){if(m||S)return;const d=a().indexOf(u);if(d===-1)return M()?_(p):f();if(d<y)return f();_(k)}return o(v,"M"),c(v,"k"),r(v,"look"),M()?(_(p),{release(){if(!m){m=!0,h&&clearTimeout(h);try{fs.unlinkSync(l)}catch{}}}}):(f(),{release(){m=!0}})}}o(machineTypecheckQueue,"machineTypecheckQueue"),c(machineTypecheckQueue,"machineTypecheckQueue"),r(machineTypecheckQueue,"machineTypecheckQueue");const immediateQueue=r((e,t)=>(t(),{release(){}}),"immediateQueue");exports.immediateQueue=immediateQueue;
@@ -1 +1 @@
1
- "use strict";var x=Object.defineProperty;var f=(s,e)=>x(s,"name",{value:e,configurable:!0});var h=Object.defineProperty,u=f((s,e)=>h(s,"name",{value:e,configurable:!0}),"u");Object.defineProperty(exports,"__esModule",{value:!0}),exports.WorkspacePathsResolverPlugin=void 0,exports.readWorkspacePaths=readWorkspacePaths,exports.hasPathMappings=hasPathMappings,exports.workspacePathCandidates=workspacePathCandidates;const tslib_1=require("tslib"),fs=tslib_1.__importStar(require("node:fs")),node_module_1=require("node:module"),path=tslib_1.__importStar(require("node:path"));function loadTypeScript(s){try{return(0,node_module_1.createRequire)(path.join(s,"package.json"))("typescript")}catch{return require("typescript")}}f(loadTypeScript,"loadTypeScript"),u(loadTypeScript,"loadTypeScript");function readWorkspacePaths(s,e){const i=path.resolve(e,s);if(!fs.existsSync(i))return null;try{const n=loadTypeScript(e),r=n.readJsonConfigFile(i,o=>n.sys.readFile(o)),a={...n.sys,readDirectory:u(()=>[],"readDirectory")},{options:t}=n.parseJsonSourceFileConfigFileContent(r,a,path.dirname(i),void 0,i),l=new Map,d=[];for(const[o,c]of Object.entries(t.paths??{})){if(!Array.isArray(c))continue;const p=o.indexOf("*");p===-1?l.set(o,c):o.indexOf("*",p+1)===-1&&d.push({key:o,prefix:o.slice(0,p),suffix:o.slice(p+1),targets:c})}return{configFiles:[i,...(r.extendedSourceFiles??[]).map(o=>path.resolve(o))],baseDir:t.baseUrl??t.pathsBasePath??path.dirname(i),...t.baseUrl?{baseUrl:t.baseUrl}:{},exact:l,patterns:d}}catch{return null}}f(readWorkspacePaths,"readWorkspacePaths"),u(readWorkspacePaths,"readWorkspacePaths");function hasPathMappings(s){return!!s&&(s.exact.size>0||s.patterns.length>0)}f(hasPathMappings,"hasPathMappings"),u(hasPathMappings,"hasPathMappings");function workspacePathCandidates(s,e){const i=[],n=s.exact.get(e);if(n)for(const r of n)i.push({file:path.resolve(s.baseDir,r),via:e});else{let r;for(const a of s.patterns)e.length<a.prefix.length+a.suffix.length||!e.startsWith(a.prefix)||!e.endsWith(a.suffix)||(!r||a.prefix.length>r.prefix.length)&&(r=a);if(r){const a=e.slice(r.prefix.length,e.length-r.suffix.length);for(const t of r.targets){const l=t.indexOf("*"),d=l===-1?t:t.slice(0,l)+a+t.slice(l+1);i.push({file:path.resolve(s.baseDir,d),via:r.key})}}}return s.baseUrl&&i.push({file:path.resolve(s.baseUrl,e),via:"baseUrl"}),i}f(workspacePathCandidates,"workspacePathCandidates"),u(workspacePathCandidates,"workspacePathCandidates");class WorkspacePathsResolverPlugin{static{f(this,"WorkspacePathsResolverPlugin")}static{u(this,"WorkspacePathsResolverPlugin")}constructor(e){this.paths=e}apply(e){const i=e.ensureHook("internal-resolve");e.getHook("normal-resolve").tapAsync("WorkspacePathsResolverPlugin",(n,r,a)=>{const t=n.request;if(!t||t.startsWith(".")||path.isAbsolute(t))return a();const l=workspacePathCandidates(this.paths,t);let d=0;const o=u(()=>{const c=l[d++];if(!c)return a();e.doResolve(i,{...n,request:c.file,fullySpecified:!1},`aliased with mapping '${c.via}' (tsconfig paths): '${t}' to '${c.file}'`,r,(p,g)=>{if(p)return a(p);if(g)return a(null,g);o()})},"attempt");o()})}}exports.WorkspacePathsResolverPlugin=WorkspacePathsResolverPlugin;
1
+ "use strict";var v=Object.defineProperty;var d=(t,e)=>v(t,"name",{value:e,configurable:!0});var x=Object.defineProperty,f=d((t,e)=>x(t,"name",{value:e,configurable:!0}),"f"),h=Object.defineProperty,u=f((t,e)=>h(t,"name",{value:e,configurable:!0}),"u");Object.defineProperty(exports,"__esModule",{value:!0}),exports.WorkspacePathsResolverPlugin=void 0,exports.readWorkspacePaths=readWorkspacePaths,exports.hasPathMappings=hasPathMappings,exports.workspacePathCandidates=workspacePathCandidates;const tslib_1=require("tslib"),fs=tslib_1.__importStar(require("node:fs")),node_module_1=require("node:module"),path=tslib_1.__importStar(require("node:path"));function loadTypeScript(t){try{return(0,node_module_1.createRequire)(path.join(t,"package.json"))("typescript")}catch{return require("typescript")}}d(loadTypeScript,"loadTypeScript"),f(loadTypeScript,"loadTypeScript"),u(loadTypeScript,"loadTypeScript");function readWorkspacePaths(t,e){const i=path.resolve(e,t);if(!fs.existsSync(i))return null;try{const n=loadTypeScript(e),s=n.readJsonConfigFile(i,o=>n.sys.readFile(o)),a={...n.sys,readDirectory:u(()=>[],"readDirectory")},{options:r}=n.parseJsonSourceFileConfigFileContent(s,a,path.dirname(i),void 0,i),l=new Map,g=[];for(const[o,c]of Object.entries(r.paths??{})){if(!Array.isArray(c))continue;const p=o.indexOf("*");p===-1?l.set(o,c):o.indexOf("*",p+1)===-1&&g.push({key:o,prefix:o.slice(0,p),suffix:o.slice(p+1),targets:c})}return{configFiles:[i,...(s.extendedSourceFiles??[]).map(o=>path.resolve(o))],baseDir:r.baseUrl??r.pathsBasePath??path.dirname(i),...r.baseUrl?{baseUrl:r.baseUrl}:{},exact:l,patterns:g}}catch{return null}}d(readWorkspacePaths,"readWorkspacePaths"),f(readWorkspacePaths,"readWorkspacePaths"),u(readWorkspacePaths,"readWorkspacePaths");function hasPathMappings(t){return!!t&&(t.exact.size>0||t.patterns.length>0)}d(hasPathMappings,"hasPathMappings"),f(hasPathMappings,"hasPathMappings"),u(hasPathMappings,"hasPathMappings");function workspacePathCandidates(t,e){const i=[],n=t.exact.get(e);if(n)for(const s of n)i.push({file:path.resolve(t.baseDir,s),via:e});else{let s;for(const a of t.patterns)e.length<a.prefix.length+a.suffix.length||!e.startsWith(a.prefix)||!e.endsWith(a.suffix)||(!s||a.prefix.length>s.prefix.length)&&(s=a);if(s){const a=e.slice(s.prefix.length,e.length-s.suffix.length);for(const r of s.targets){const l=r.indexOf("*"),g=l===-1?r:r.slice(0,l)+a+r.slice(l+1);i.push({file:path.resolve(t.baseDir,g),via:s.key})}}}return t.baseUrl&&i.push({file:path.resolve(t.baseUrl,e),via:"baseUrl"}),i}d(workspacePathCandidates,"workspacePathCandidates"),f(workspacePathCandidates,"workspacePathCandidates"),u(workspacePathCandidates,"workspacePathCandidates");class WorkspacePathsResolverPlugin{static{d(this,"WorkspacePathsResolverPlugin")}static{f(this,"WorkspacePathsResolverPlugin")}static{u(this,"WorkspacePathsResolverPlugin")}constructor(e){this.paths=e}apply(e){const i=e.ensureHook("internal-resolve");e.getHook("normal-resolve").tapAsync("WorkspacePathsResolverPlugin",(n,s,a)=>{const r=n.request;if(!r||r.startsWith(".")||path.isAbsolute(r))return a();const l=workspacePathCandidates(this.paths,r);let g=0;const o=u(()=>{const c=l[g++];if(!c)return a();e.doResolve(i,{...n,request:c.file,fullySpecified:!1},`aliased with mapping '${c.via}' (tsconfig paths): '${r}' to '${c.file}'`,s,(p,P)=>{if(p)return a(p);if(P)return a(null,P);o()})},"attempt");o()})}}exports.WorkspacePathsResolverPlugin=WorkspacePathsResolverPlugin;