@lensmcp/cluster 1.25.1 → 1.25.3

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 (132) 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.d.ts +3 -0
  51. package/executors/gateway/runtime/control.js +2 -2
  52. package/executors/gateway/runtime/dev-auth.js +1 -1
  53. package/executors/gateway/runtime/discovery.js +1 -1
  54. package/executors/gateway/runtime/edge.js +1 -1
  55. package/executors/gateway/runtime/guest-graph.js +2 -2
  56. package/executors/gateway/runtime/guest-replay.js +2 -2
  57. package/executors/gateway/runtime/handler.js +1 -1
  58. package/executors/gateway/runtime/hmr-reload.js +1 -1
  59. package/executors/gateway/runtime/hooks.js +1 -1
  60. package/executors/gateway/runtime/instance.js +2 -2
  61. package/executors/gateway/runtime/lens-children.js +1 -1
  62. package/executors/gateway/runtime/lifecycle.d.ts +23 -1
  63. package/executors/gateway/runtime/lifecycle.js +3 -3
  64. package/executors/gateway/runtime/observability.js +2 -2
  65. package/executors/gateway/runtime/own-log.d.ts +41 -0
  66. package/executors/gateway/runtime/own-log.js +3 -0
  67. package/executors/gateway/runtime/pod-env.js +2 -2
  68. package/executors/gateway/runtime/pod-output.js +1 -1
  69. package/executors/gateway/runtime/pod-probe.js +1 -1
  70. package/executors/gateway/runtime/process-names.js +1 -1
  71. package/executors/gateway/runtime/project-graph-store.js +1 -1
  72. package/executors/gateway/runtime/proxy.d.ts +1 -0
  73. package/executors/gateway/runtime/proxy.js +1 -1
  74. package/executors/gateway/runtime/registration-guards.js +1 -1
  75. package/executors/gateway/runtime/route-registry.js +1 -1
  76. package/executors/gateway/runtime/scope.js +1 -1
  77. package/executors/gateway/runtime/serve-launch.js +3 -3
  78. package/executors/gateway/runtime/server.js +2 -2
  79. package/executors/gateway/runtime/service-keys.js +1 -1
  80. package/executors/gateway/runtime/shared-build.js +4 -4
  81. package/executors/gateway/runtime/types.d.ts +30 -0
  82. package/executors/gateway/runtime/types.js +1 -1
  83. package/executors/gateway/runtime/upgrade.js +1 -1
  84. package/executors/gateway/runtime/workspace-log.js +1 -1
  85. package/executors/gateway/runtime/workspace-middleware.js +1 -1
  86. package/executors/gateway/runtime/workspace-registry.js +1 -1
  87. package/executors/gateway/ssrf-guard.js +1 -1
  88. package/executors/serve/serve.impl.js +1 -1
  89. package/executors/trust/hostname.js +1 -1
  90. package/executors/trust/trust.impl.js +3 -3
  91. package/exit-reason.js +2 -2
  92. package/fork-ts-check-reporter.js +1 -1
  93. package/gateway.js +1 -1
  94. package/gc-notice.js +1 -1
  95. package/graph-snapshot.js +1 -1
  96. package/handoff-retire.js +1 -1
  97. package/heap-snapshot.js +1 -1
  98. package/hot-swap-registries.js +1 -1
  99. package/index.js +1 -1
  100. package/inspector-secret.js +1 -1
  101. package/main.devserver.js +10 -10
  102. package/notice-generation.js +1 -1
  103. package/package.json +4 -4
  104. package/perf/heavy-barrel-import.js +1 -1
  105. package/perf/perf-config.js +1 -1
  106. package/perf/perf-rule-events.js +2 -2
  107. package/perf/perf-rules-analysis.js +1 -1
  108. package/perf/perf-rules-plugin.js +1 -1
  109. package/perf/source-scan.js +5 -5
  110. package/perf/workspace-libraries.js +2 -2
  111. package/pod-memory-events.js +2 -2
  112. package/pod-memory.js +1 -1
  113. package/pod-sock.js +1 -1
  114. package/process-name.js +1 -1
  115. package/redis-disconnect-fix.js +1 -1
  116. package/schema-first-instance.js +1 -1
  117. package/serve-runner.js +1 -1
  118. package/service-build-events.d.ts +7 -0
  119. package/service-build-events.js +1 -1
  120. package/shared-build/attach.js +2 -2
  121. package/shared-build/host.js +3 -3
  122. package/shared-build/protocol.js +1 -1
  123. package/shared-build/shared-compilation.js +3 -3
  124. package/shared-build/signature.js +1 -1
  125. package/stdio-guard.js +1 -1
  126. package/swap-mode.d.ts +31 -0
  127. package/swap-mode.js +1 -0
  128. package/swap-recycle.js +1 -1
  129. package/tsgo-check-plugin.js +4 -4
  130. package/typecheck-bus.js +3 -3
  131. package/typecheck-queue.js +1 -1
  132. package/workspace-paths.js +1 -1
@@ -1,4 +1,4 @@
1
- "use strict";var _=Object.defineProperty;var d=(a,e)=>_(a,"name",{value:e,configurable:!0});var y=Object.defineProperty,g=d((a,e)=>y(a,"name",{value:e,configurable:!0}),"g"),v=Object.defineProperty,p=g((a,e)=>v(a,"name",{value:e,configurable:!0}),"p");Object.defineProperty(exports,"__esModule",{value:!0}),exports.BuildHost=exports.DEFAULT_PAUSE_MS=void 0,exports.withEnv=withEnv,exports.buildTargetString=buildTargetString;const tslib_1=require("tslib"),node_crypto_1=require("node:crypto"),path=tslib_1.__importStar(require("node:path")),checkout_cache_1=require("../checkout-cache"),dev_devtool_1=require("../dev-devtool"),create_webpack_dev_1=require("../create-webpack-dev"),perf_rules_plugin_1=require("../perf/perf-rules-plugin"),signature_1=require("./signature"),shared_compilation_1=require("./shared-compilation");exports.DEFAULT_PAUSE_MS=5e3;function withEnv(a,e){const t={...process.env};for(const r of Object.keys(process.env))delete process.env[r];for(const[r,s]of Object.entries(a))s!==void 0&&(process.env[r]=s);try{return e()}finally{for(const r of Object.keys(process.env))delete process.env[r];Object.assign(process.env,t)}}d(withEnv,"withEnv"),g(withEnv,"withEnv"),p(withEnv,"withEnv");function buildTargetString(a){return`${a.project}:${a.target}${a.configuration?`:${a.configuration}`:""}`}d(buildTargetString,"buildTargetString"),g(buildTargetString,"buildTargetString"),p(buildTargetString,"buildTargetString");const shortHash=p(a=>(0,node_crypto_1.createHash)("sha256").update(a).digest("hex").slice(0,16),"shortHash");class BuildHost{static{d(this,"BuildHost")}static{g(this,"BuildHost")}static{p(this,"BuildHost")}constructor(e){this.opts=e,this.groups=new Map,this.members=new Map,this.stopped=!1,this.pauseMs=e.pauseMs??exports.DEFAULT_PAUSE_MS,this.webpack=e.webpack??require("webpack")}tell(e,t){this.opts.send({type:"member",member:e,event:t})}describe(){return[...this.groups.values()].map(e=>({group:e.key,projects:e.registry.projects()}))}evaluate(e){const t=e.options;if(t.webpackConfigPath)try{delete require.cache[require.resolve(path.resolve(t.appRoot,t.webpackConfigPath))]}catch{}const r={...e.env,NODE_ENV:"development",NX_BUILD_TARGET:buildTargetString(e),NX_WORKSPACE_ROOT:this.opts.root,LENSMCP_TYPECHECK:"off"},s=withEnv(r,()=>(0,create_webpack_dev_1.createDevWebpackConfig)(t)),o=(0,signature_1.transpileCompilerOptions)(t.tsConfig,this.opts.root),n=(0,signature_1.memberSignature)({join:e,devtool:s.devtool,config:s,compilerOptions:o});return{config:s,signature:n}}join(e,t){if(this.stopped)return this.tell(e,{type:"refused",reason:"the build host is stopping"});this.leave(e,{quiet:!0});const r=(0,signature_1.refusalOf)(t,this.opts.root);if(r)return this.opts.log(`${t.project}: compiles on its own \u2014 ${r}`),this.tell(e,{type:"refused",reason:r});let s;try{s=this.evaluate(t)}catch(i){const c=`its webpack config could not be built here (${(i?.message??String(i)).split(`
1
+ "use strict";var y=Object.defineProperty;var g=(l,e)=>y(l,"name",{value:e,configurable:!0});var v=Object.defineProperty,p=g((l,e)=>v(l,"name",{value:e,configurable:!0}),"p");Object.defineProperty(exports,"__esModule",{value:!0}),exports.BuildHost=exports.DEFAULT_PAUSE_MS=void 0,exports.withEnv=withEnv,exports.buildTargetString=buildTargetString;const tslib_1=require("tslib"),node_crypto_1=require("node:crypto"),path=tslib_1.__importStar(require("node:path")),checkout_cache_1=require("../checkout-cache"),dev_devtool_1=require("../dev-devtool"),create_webpack_dev_1=require("../create-webpack-dev"),perf_rules_plugin_1=require("../perf/perf-rules-plugin"),signature_1=require("./signature"),shared_compilation_1=require("./shared-compilation");exports.DEFAULT_PAUSE_MS=5e3;function withEnv(l,e){const t={...process.env};for(const r of Object.keys(process.env))delete process.env[r];for(const[r,s]of Object.entries(l))s!==void 0&&(process.env[r]=s);try{return e()}finally{for(const r of Object.keys(process.env))delete process.env[r];Object.assign(process.env,t)}}g(withEnv,"withEnv"),p(withEnv,"withEnv");function buildTargetString(l){return`${l.project}:${l.target}${l.configuration?`:${l.configuration}`:""}`}g(buildTargetString,"buildTargetString"),p(buildTargetString,"buildTargetString");const shortHash=p(l=>(0,node_crypto_1.createHash)("sha256").update(l).digest("hex").slice(0,16),"shortHash");class BuildHost{static{g(this,"BuildHost")}static{p(this,"BuildHost")}constructor(e){this.opts=e,this.groups=new Map,this.members=new Map,this.stopped=!1,this.pauseMs=e.pauseMs??exports.DEFAULT_PAUSE_MS,this.webpack=e.webpack??require("webpack")}tell(e,t){this.opts.send({type:"member",member:e,event:t})}describe(){return[...this.groups.values()].map(e=>({group:e.key,projects:e.registry.projects()}))}evaluate(e){const t=e.options;if(t.webpackConfigPath)try{delete require.cache[require.resolve(path.resolve(t.appRoot,t.webpackConfigPath))]}catch{}const r={...e.env,NODE_ENV:"development",NX_BUILD_TARGET:buildTargetString(e),NX_WORKSPACE_ROOT:this.opts.root,LENSMCP_TYPECHECK:"off"},s=withEnv(r,()=>(0,create_webpack_dev_1.createDevWebpackConfig)(t)),o=(0,signature_1.transpileCompilerOptions)(t.tsConfig,this.opts.root),n=(0,signature_1.memberSignature)({join:e,devtool:s.devtool,config:s,compilerOptions:o});return{config:s,signature:n}}join(e,t){if(this.stopped)return this.tell(e,{type:"refused",reason:"the build host is stopping"});this.leave(e,{quiet:!0});const r=(0,signature_1.refusalOf)(t,this.opts.root);if(r)return this.opts.log(`${t.project}: compiles on its own \u2014 ${r}`),this.tell(e,{type:"refused",reason:r});let s;try{s=this.evaluate(t)}catch(i){const c=`its webpack config could not be built here (${(i?.message??String(i)).split(`
2
2
  `)[0]})`;return this.opts.log(`${t.project}: compiles on its own \u2014 ${c}`),this.tell(e,{type:"refused",reason:c})}let o=this.groups.get(s.signature.key);if(!o){for(const i of this.groups.values()){const c=(0,signature_1.describeDifference)(s.signature,i.signature);this.opts.log(`${t.project}: compiled apart from ${i.registry.projects().sort().join(", ")||"the other group"} \u2014 ${c??"its compile signature differs"}`);break}try{o=this.createGroup(s,t)}catch(i){const c=`the shared compiler could not be created (${(i?.message??String(i)).split(`
3
- `)[0]})`;return this.opts.log(`${t.project}: compiles on its own \u2014 ${c}`),this.tell(e,{type:"refused",reason:c})}this.groups.set(o.key,o)}this.members.set(e,{project:t.project,group:o});const n=o.projects.get(t.project)??new Set;n.add(e);const l=!o.projects.has(t.project);o.projects.set(t.project,n);const u=o.pausing.get(t.project);if(u&&(clearTimeout(u),o.pausing.delete(t.project)),this.tell(e,{type:"accepted",group:o.key,projects:[...o.projects.keys()]}),l)o.registry.set(t.project,(0,shared_compilation_1.memberEntries)(t.project,t.options)),this.opts.log(`shared compilation ${o.key.slice(0,8)}: ${o.registry.projects().sort().join(", ")}`),this.kick(o);else{const i=o.last.get(t.project);i&&this.tellBuilt(o,e,i)}}leave(e,t={}){const r=this.members.get(e);if(!r)return;this.members.delete(e);const{project:s,group:o}=r;o.told.delete(e),o.toldFiles.delete(e);const n=o.projects.get(s);if(n?.delete(e),n&&n.size>0)return;t.quiet||this.opts.log(`${s}: no member left \u2014 its entries pause in ${Math.round(this.pauseMs/1e3)} s`);const l=setTimeout(()=>this.pause(o,s),this.pauseMs);l.unref?.(),o.pausing.set(s,l)}pause(e,t){if(e.pausing.delete(t),!((e.projects.get(t)?.size??0)>0)){if(e.projects.delete(t),e.registry.delete(t),e.last.delete(t),e.projects.size===0){this.opts.log(`shared compilation ${e.key.slice(0,8)}: no service left \u2014 closed`),this.groups.delete(e.key),this.closeGroup(e);return}this.opts.log(`shared compilation ${e.key.slice(0,8)}: ${t} paused \u2014 ${e.registry.projects().sort().join(", ")}`),this.kick(e)}}kick(e){if(e.watching){e.watching.invalidate();return}e.watching=e.compiler.watch(e.watchOptions,(t,r)=>this.onBuild(e,t,r))}createGroup(e,t){const r=e.signature.key,s=new shared_compilation_1.EntryRegistry,o=t.options,n=e.config,l=n.devtool,u=path.join((0,checkout_cache_1.checkoutCacheDir)(this.opts.root,"lensmcp-build"),r,"out"),i=(0,create_webpack_dev_1.devCacheOptions)(o,l),c={key:r,signature:e.signature,registry:s,projects:new Map,pausing:new Map,last:new Map,told:new Map,toldFiles:new Map,compiler:void 0,watching:void 0,watchOptions:{},sourceMaps:!1,webpackVersion:""},h=n.plugins.filter(m=>!signature_1.PER_SERVICE_PLUGINS.has(m?.constructor?.name));h.push(new perf_rules_plugin_1.PerfRulesPlugin({project:t.project,workspaceRoot:this.opts.root,tsConfig:o.tsConfig,entries:p(()=>s.entryProjects(),"entries")}),new shared_compilation_1.SharedEntriesPlugin({registry:s,workspaceRoot:this.opts.root,outputPath:u,cache:{...i,name:`shared-${r}`,version:`${i.version}-${r}`}}),{apply:p(m=>{m.hooks.watchRun.tap("LensmcpSharedBuild",b=>{const k=[...b.modifiedFiles??[],...b.removedFiles??[]].filter(w=>typeof w=="string").slice(-32);for(const w of this.membersOf(c))this.tell(w,{type:"watch-run",paths:k})}),m.hooks.watchClose.tap("LensmcpSharedBuild",()=>{for(const b of this.membersOf(c))this.tell(b,{type:"watch-closed"})})},"apply")});const f={...n,plugins:h};delete f.watch,c.watchOptions=n.watchOptions??{};const j={...t.env,NODE_ENV:"development",NX_BUILD_TARGET:buildTargetString(t),NX_WORKSPACE_ROOT:this.opts.root,LENSMCP_TYPECHECK:"off"};return c.compiler=withEnv(j,()=>this.webpack(f)),c.sourceMaps=(0,dev_devtool_1.bundleCarriesSourceMaps)(c.compiler.options.devtool),c.webpackVersion=String(c.compiler.webpack?.version??"5"),c}membersOf(e){const t=[];for(const r of e.projects.values())t.push(...r);return t}onBuild(e,t,r){if(this.stopped)return;if(t){const i=t?.message??String(t);this.opts.log(`shared compilation ${e.key.slice(0,8)} failed: ${i}`);for(const c of this.membersOf(e))this.tell(c,{type:"failed",message:i});return}const s=r,o=Math.max(0,(s.endTime??0)-(s.startTime??0)),n=(0,shared_compilation_1.attributeCompilation)(s.compilation,e.registry),l=[];for(const[i,c]of n){e.last.get(i)?.attribution.hash!==c.hash&&l.push(i);const h={attribution:c,durationMs:o};e.last.set(i,h);for(const f of e.projects.get(i)??[])this.tellBuilt(e,f,h)}const u=[...n.values()].filter(i=>i.errorCount>0).map(i=>i.project);this.opts.log(`built ${[...n.keys()].sort().join(", ")||"nothing"} in ${o} ms \u2014 ${l.length?`changed: ${l.sort().join(", ")}`:"no bundle changed"}${u.length?`; errors in: ${u.sort().join(", ")}`:""}`)}tellBuilt(e,t,r){const s=r.attribution,o=e.told.get(t)!==s.hash;e.told.set(t,s.hash);const n=shortHash([...s.files].sort().join(`
4
- `)),l=e.toldFiles.get(t)!==n;e.toldFiles.set(t,n),this.tell(t,{type:"built",ok:s.errorCount===0,changed:o,hash:s.hash,text:(0,shared_compilation_1.describeBuild)(s,{webpackVersion:e.webpackVersion,durationMs:r.durationMs,changed:o}),errors:s.errorCount,warnings:s.warningCount,durationMs:r.durationMs,sourceMaps:e.sourceMaps,...l?{files:s.files}:{}})}closeGroup(e){for(const o of e.pausing.values())clearTimeout(o);e.pausing.clear();const t=e.compiler,r=e.watching;e.watching=void 0;const s=p(()=>{try{t?.close?.(()=>{})}catch{}},"closeCompiler");r?r.close(s):s()}stop(e=5e3){this.stopped=!0;const t=[...this.groups.values()];return this.groups.clear(),this.members.clear(),new Promise(r=>{let s=t.length;if(s===0)return r();const o=setTimeout(r,e);o.unref?.();for(const n of t){for(const c of n.pausing.values())clearTimeout(c);const l=p(()=>{--s===0&&(clearTimeout(o),r())},"done"),u=n.compiler,i=p(()=>{try{u.close(()=>l())}catch{l()}},"closeCompiler");n.watching?n.watching.close(i):i()}})}}exports.BuildHost=BuildHost;
3
+ `)[0]})`;return this.opts.log(`${t.project}: compiles on its own \u2014 ${c}`),this.tell(e,{type:"refused",reason:c})}this.groups.set(o.key,o)}this.members.set(e,{project:t.project,group:o});const n=o.projects.get(t.project)??new Set;n.add(e);const a=!o.projects.has(t.project);o.projects.set(t.project,n);const u=o.pausing.get(t.project);if(u&&(clearTimeout(u),o.pausing.delete(t.project)),this.tell(e,{type:"accepted",group:o.key,projects:[...o.projects.keys()]}),a)o.registry.set(t.project,(0,shared_compilation_1.memberEntries)(t.project,t.options)),this.opts.log(`shared compilation ${o.key.slice(0,8)}: ${o.registry.projects().sort().join(", ")}`),this.kick(o);else{const i=o.last.get(t.project);i&&this.tellBuilt(o,e,i)}}leave(e,t={}){const r=this.members.get(e);if(!r)return;this.members.delete(e);const{project:s,group:o}=r;o.told.delete(e),o.toldFiles.delete(e);const n=o.projects.get(s);if(n?.delete(e),n&&n.size>0)return;t.quiet||this.opts.log(`${s}: no member left \u2014 its entries pause in ${Math.round(this.pauseMs/1e3)} s`);const a=setTimeout(()=>this.pause(o,s),this.pauseMs);a.unref?.(),o.pausing.set(s,a)}pause(e,t){if(e.pausing.delete(t),!((e.projects.get(t)?.size??0)>0)){if(e.projects.delete(t),e.registry.delete(t),e.last.delete(t),e.projects.size===0){this.opts.log(`shared compilation ${e.key.slice(0,8)}: no service left \u2014 closed`),this.groups.delete(e.key),this.closeGroup(e);return}this.opts.log(`shared compilation ${e.key.slice(0,8)}: ${t} paused \u2014 ${e.registry.projects().sort().join(", ")}`),this.kick(e)}}kick(e){if(e.watching){e.watching.invalidate();return}e.watching=e.compiler.watch(e.watchOptions,(t,r)=>this.onBuild(e,t,r))}createGroup(e,t){const r=e.signature.key,s=new shared_compilation_1.EntryRegistry,o=t.options,n=e.config,a=n.devtool,u=path.join((0,checkout_cache_1.checkoutCacheDir)(this.opts.root,"lensmcp-build"),r,"out"),i=(0,create_webpack_dev_1.devCacheOptions)(o,a),c={key:r,signature:e.signature,registry:s,projects:new Map,pausing:new Map,last:new Map,told:new Map,toldFiles:new Map,compiler:void 0,watching:void 0,watchOptions:{},sourceMaps:!1,webpackVersion:""},h=n.plugins.filter(f=>!signature_1.PER_SERVICE_PLUGINS.has(f?.constructor?.name));h.push(new perf_rules_plugin_1.PerfRulesPlugin({project:t.project,workspaceRoot:this.opts.root,tsConfig:o.tsConfig,entries:p(()=>s.entryProjects(),"entries")}),new shared_compilation_1.SharedEntriesPlugin({registry:s,workspaceRoot:this.opts.root,outputPath:u,cache:{...i,name:`shared-${r}`,version:`${i.version}-${r}`}}),{apply:p(f=>{f.hooks.watchRun.tap("LensmcpSharedBuild",m=>{const j=[...m.modifiedFiles??[],...m.removedFiles??[]].filter(b=>typeof b=="string").slice(-32);for(const b of this.membersOf(c))this.tell(b,{type:"watch-run",paths:j})}),f.hooks.watchClose.tap("LensmcpSharedBuild",()=>{for(const m of this.membersOf(c))this.tell(m,{type:"watch-closed"})})},"apply")});const d={...n,plugins:h};delete d.watch,c.watchOptions=n.watchOptions??{};const w={...t.env,NODE_ENV:"development",NX_BUILD_TARGET:buildTargetString(t),NX_WORKSPACE_ROOT:this.opts.root,LENSMCP_TYPECHECK:"off"};return c.compiler=withEnv(w,()=>this.webpack(d)),c.sourceMaps=(0,dev_devtool_1.bundleCarriesSourceMaps)(c.compiler.options.devtool),c.webpackVersion=String(c.compiler.webpack?.version??"5"),c}membersOf(e){const t=[];for(const r of e.projects.values())t.push(...r);return t}onBuild(e,t,r){if(this.stopped)return;if(t){const i=t?.message??String(t);this.opts.log(`shared compilation ${e.key.slice(0,8)} failed: ${i}`);for(const c of this.membersOf(e))this.tell(c,{type:"failed",message:i});return}const s=r,o=Math.max(0,(s.endTime??0)-(s.startTime??0)),n=(0,shared_compilation_1.attributeCompilation)(s.compilation,e.registry),a=[];for(const[i,c]of n){e.last.get(i)?.attribution.hash!==c.hash&&a.push(i);const h={attribution:c,durationMs:o};e.last.set(i,h);for(const d of e.projects.get(i)??[])this.tellBuilt(e,d,h)}const u=[...n.values()].filter(i=>i.errorCount>0).map(i=>i.project);this.opts.log(`built ${[...n.keys()].sort().join(", ")||"nothing"} in ${o} ms \u2014 ${a.length?`changed: ${a.sort().join(", ")}`:"no bundle changed"}${u.length?`; errors in: ${u.sort().join(", ")}`:""}`)}tellBuilt(e,t,r){const s=r.attribution,o=e.told.get(t)!==s.hash;e.told.set(t,s.hash);const n=shortHash([...s.files].sort().join(`
4
+ `)),a=e.toldFiles.get(t)!==n;e.toldFiles.set(t,n),this.tell(t,{type:"built",ok:s.errorCount===0,changed:o,hash:s.hash,text:(0,shared_compilation_1.describeBuild)(s,{webpackVersion:e.webpackVersion,durationMs:r.durationMs,changed:o}),errors:s.errorCount,warnings:s.warningCount,durationMs:r.durationMs,sourceMaps:e.sourceMaps,...a?{files:s.files}:{}})}closeGroup(e){for(const o of e.pausing.values())clearTimeout(o);e.pausing.clear();const t=e.compiler,r=e.watching;e.watching=void 0;const s=p(()=>{try{t?.close?.(()=>{})}catch{}},"closeCompiler");r?r.close(s):s()}stop(e=5e3){this.stopped=!0;const t=[...this.groups.values()];return this.groups.clear(),this.members.clear(),new Promise(r=>{let s=t.length;if(s===0)return r();const o=setTimeout(r,e);o.unref?.();for(const n of t){for(const c of n.pausing.values())clearTimeout(c);const a=p(()=>{--s===0&&(clearTimeout(o),r())},"done"),u=n.compiler,i=p(()=>{try{u.close(()=>a())}catch{a()}},"closeCompiler");n.watching?n.watching.close(i):i()}})}}exports.BuildHost=BuildHost;
@@ -1 +1 @@
1
- "use strict";var E=Object.defineProperty;var t=(n,e)=>E(n,"name",{value:e,configurable:!0});var _=Object.defineProperty,r=t((n,e)=>_(n,"name",{value:e,configurable:!0}),"r"),o=Object.defineProperty,s=r((n,e)=>o(n,"name",{value:e,configurable:!0}),"s");Object.defineProperty(exports,"__esModule",{value:!0}),exports.SHARED_COMPILER_DEFAULT=exports.BUILD_HOST_ROOT_FLAG=exports.BUILD_HOST_ROLE=exports.SHARED_BUILD_CHANNEL=exports.SHARED_BUILD_ENV=exports.SHARED_COMPILER_ENV=void 0,exports.sharedCompilerEnabled=sharedCompilerEnabled,exports.isRunnerJoinMessage=isRunnerJoinMessage,exports.isRunnerInbound=isRunnerInbound,exports.buildHostArgs=buildHostArgs,exports.isBuildHostCommandOf=isBuildHostCommandOf,exports.SHARED_COMPILER_ENV="LENSMCP_SHARED_COMPILER",exports.SHARED_BUILD_ENV="LENSMCP_SHARED_BUILD",exports.SHARED_BUILD_CHANNEL="lensmcp-shared-build",exports.BUILD_HOST_ROLE="build",exports.BUILD_HOST_ROOT_FLAG="--workspace-root=";const ON=/^(1|on|true|yes)$/i,OFF=/^(0|off|false|no)$/i;exports.SHARED_COMPILER_DEFAULT=!1;function sharedCompilerEnabled(n=process.env,e){const i=(n[exports.SHARED_COMPILER_ENV]??"").trim();return ON.test(i)?!0:OFF.test(i)?!1:e??exports.SHARED_COMPILER_DEFAULT}t(sharedCompilerEnabled,"sharedCompilerEnabled"),r(sharedCompilerEnabled,"sharedCompilerEnabled"),s(sharedCompilerEnabled,"sharedCompilerEnabled");function isRunnerJoinMessage(n){const e=n;return!!e&&e.channel===exports.SHARED_BUILD_CHANNEL&&e.type==="join"&&typeof e.join?.project=="string"}t(isRunnerJoinMessage,"isRunnerJoinMessage"),r(isRunnerJoinMessage,"isRunnerJoinMessage"),s(isRunnerJoinMessage,"isRunnerJoinMessage");function isRunnerInbound(n){const e=n;return!!e&&e.channel===exports.SHARED_BUILD_CHANNEL&&typeof e.event?.type=="string"}t(isRunnerInbound,"isRunnerInbound"),r(isRunnerInbound,"isRunnerInbound"),s(isRunnerInbound,"isRunnerInbound");function buildHostArgs(n){return["host",`${exports.BUILD_HOST_ROOT_FLAG}${n.replace(/\/+$/,"")}`]}t(buildHostArgs,"buildHostArgs"),r(buildHostArgs,"buildHostArgs"),s(buildHostArgs,"buildHostArgs");function isBuildHostCommandOf(n,e){return/\bbuild-host\.(js|ts)\b/.test(n)&&n.trimEnd().endsWith(` ${exports.BUILD_HOST_ROOT_FLAG}${e.replace(/\/+$/,"")}`)}t(isBuildHostCommandOf,"isBuildHostCommandOf"),r(isBuildHostCommandOf,"isBuildHostCommandOf"),s(isBuildHostCommandOf,"isBuildHostCommandOf");
1
+ "use strict";var _=Object.defineProperty;var r=(t,e)=>_(t,"name",{value:e,configurable:!0});var o=Object.defineProperty,s=r((t,e)=>o(t,"name",{value:e,configurable:!0}),"s");Object.defineProperty(exports,"__esModule",{value:!0}),exports.SHARED_COMPILER_DEFAULT=exports.BUILD_HOST_ROOT_FLAG=exports.BUILD_HOST_ROLE=exports.SHARED_BUILD_CHANNEL=exports.SHARED_BUILD_ENV=exports.SHARED_COMPILER_ENV=void 0,exports.sharedCompilerEnabled=sharedCompilerEnabled,exports.isRunnerJoinMessage=isRunnerJoinMessage,exports.isRunnerInbound=isRunnerInbound,exports.buildHostArgs=buildHostArgs,exports.isBuildHostCommandOf=isBuildHostCommandOf,exports.SHARED_COMPILER_ENV="LENSMCP_SHARED_COMPILER",exports.SHARED_BUILD_ENV="LENSMCP_SHARED_BUILD",exports.SHARED_BUILD_CHANNEL="lensmcp-shared-build",exports.BUILD_HOST_ROLE="build",exports.BUILD_HOST_ROOT_FLAG="--workspace-root=";const ON=/^(1|on|true|yes)$/i,OFF=/^(0|off|false|no)$/i;exports.SHARED_COMPILER_DEFAULT=!1;function sharedCompilerEnabled(t=process.env,e){const n=(t[exports.SHARED_COMPILER_ENV]??"").trim();return ON.test(n)?!0:OFF.test(n)?!1:e??exports.SHARED_COMPILER_DEFAULT}r(sharedCompilerEnabled,"sharedCompilerEnabled"),s(sharedCompilerEnabled,"sharedCompilerEnabled");function isRunnerJoinMessage(t){const e=t;return!!e&&e.channel===exports.SHARED_BUILD_CHANNEL&&e.type==="join"&&typeof e.join?.project=="string"}r(isRunnerJoinMessage,"isRunnerJoinMessage"),s(isRunnerJoinMessage,"isRunnerJoinMessage");function isRunnerInbound(t){const e=t;return!!e&&e.channel===exports.SHARED_BUILD_CHANNEL&&typeof e.event?.type=="string"}r(isRunnerInbound,"isRunnerInbound"),s(isRunnerInbound,"isRunnerInbound");function buildHostArgs(t){return["host",`${exports.BUILD_HOST_ROOT_FLAG}${t.replace(/\/+$/,"")}`]}r(buildHostArgs,"buildHostArgs"),s(buildHostArgs,"buildHostArgs");function isBuildHostCommandOf(t,e){return/\bbuild-host\.(js|ts)\b/.test(t)&&t.trimEnd().endsWith(` ${exports.BUILD_HOST_ROOT_FLAG}${e.replace(/\/+$/,"")}`)}r(isBuildHostCommandOf,"isBuildHostCommandOf"),s(isBuildHostCommandOf,"isBuildHostCommandOf");
@@ -1,3 +1,3 @@
1
- "use strict";var j=Object.defineProperty;var p=(t,e)=>j(t,"name",{value:e,configurable:!0});var w=Object.defineProperty,l=p((t,e)=>w(t,"name",{value:e,configurable:!0}),"l"),$=Object.defineProperty,c=l((t,e)=>$(t,"name",{value:e,configurable:!0}),"c");Object.defineProperty(exports,"__esModule",{value:!0}),exports.SharedEntriesPlugin=exports.EntryRegistry=void 0,exports.memberEntries=memberEntries,exports.attributeCompilation=attributeCompilation,exports.describeBuild=describeBuild;const tslib_1=require("tslib"),node_crypto_1=require("node:crypto"),path=tslib_1.__importStar(require("node:path"));function memberEntries(t,e){const r=[{name:t,project:t,import:e.main,outputFile:path.join(e.outputDir,"main.js")}];for(const o of e.additionalEntryPoints??[])r.push({name:`${t}~${o.entryName}`,project:t,import:o.entryPath,outputFile:path.join(e.outputDir,`${o.entryName}.js`)});return r}p(memberEntries,"memberEntries"),l(memberEntries,"memberEntries"),c(memberEntries,"memberEntries");class EntryRegistry{static{p(this,"EntryRegistry")}static{l(this,"EntryRegistry")}static{c(this,"EntryRegistry")}constructor(){this.byProject=new Map}set(e,r){this.byProject.set(e,r)}delete(e){return this.byProject.delete(e)}has(e){return this.byProject.has(e)}projects(){return[...this.byProject.keys()]}entriesOf(e){return this.byProject.get(e)??[]}entryProjects(){const e={};for(const[r,o]of this.byProject)for(const n of o)e[n.name]=r;return e}entry(e){for(const r of this.byProject.values()){const o=r.find(n=>n.name===e);if(o)return o}}webpackEntries(e){const r={};for(const o of this.byProject.values())for(const n of o)r[n.name]={import:[n.import],filename:path.relative(e,n.outputFile)};return r}}exports.EntryRegistry=EntryRegistry;class SharedEntriesPlugin{static{p(this,"SharedEntriesPlugin")}static{l(this,"SharedEntriesPlugin")}static{c(this,"SharedEntriesPlugin")}constructor(e){this.options=e}apply(e){const{registry:r,workspaceRoot:o,outputPath:n,cache:s}=this.options;e.options.context=o,e.context=o,e.options.output={...e.options.output,path:n,clean:!1,chunkFilename:c(g=>{const i=g.chunk?.runtime,h=typeof i=="string"?i:i?[...i].sort()[0]:void 0,a=h?r.entry(h):void 0;return`${a?path.relative(n,path.dirname(a.outputFile)):"."}/[id].js`},"chunkFilename")},e.options.cache={...s,buildDependencies:{...s.buildDependencies}},e.options.entry=()=>Promise.resolve(r.webpackEntries(n))}}exports.SharedEntriesPlugin=SharedEntriesPlugin;const resourceOf=c(t=>{if(typeof t.resource!="string"||!t.resource)return;const e=t.resource.search(/[?#]/);return e===-1?t.resource:t.resource.slice(0,e)},"resourceOf");function formatLoc(t){const e=t?.start;if(!e||typeof e.line!="number")return"";const r=`${e.line}:${e.column??0}`,o=t?.end;return!o||typeof o.line!="number"?r:o.line===e.line?`${r}-${o.column??0}`:`${r}-${o.line}:${o.column??0}`}p(formatLoc,"formatLoc"),l(formatLoc,"formatLoc"),c(formatLoc,"formatLoc");function formatProblem(t,e,r){const o=e.module;let n="";try{n=o?.readableIdentifier?o.readableIdentifier(r.requestShortener):""}catch{}const s=formatLoc(e.loc);return`${n?`${t} in ${n}${s?` ${s}`:""}`:t}
2
- ${String(e.message??e).trim()}`}p(formatProblem,"formatProblem"),l(formatProblem,"formatProblem"),c(formatProblem,"formatProblem");const MAX_PROBLEMS=30,MAX_PROBLEM_CHARS=4e3;function attributeCompilation(t,e){const r=new Map,o=new Map,n=t.compiler?.context??t.options?.context??process.cwd();for(const i of e.projects()){const h=new Set;let a=!1;for(const u of e.entriesOf(i)){const f=t.entrypoints?.get(u.name);if(f){a=!0;for(const d of f.chunks??[]){h.add(d);for(const b of d.getAllAsyncChunks?.()??[])h.add(b)}}}if(!a)continue;const m=new Set,y=[],P=[];for(const u of h){y.push(`${String(u.id)}:${u.hash??""}`);for(const f of t.chunkGraph.getChunkModulesIterable(u)){let d=o.get(f);d||o.set(f,d=new Set),d.add(i);const b=resourceOf(f);b&&m.add(b)}for(const f of u.files??[]){const d=t.getAsset?.(f),b=path.resolve(t.outputOptions?.path??n,f);P.push({file:path.relative(n,b),size:d?.info?.size??d?.source?.size?.()??0})}}r.set(i,{project:i,hash:(0,node_crypto_1.createHash)("sha256").update(y.sort().join("|")).digest("hex").slice(0,16),errors:[],warnings:[],errorCount:0,warningCount:0,files:[...m],assets:P})}const s=e.entryProjects(),g=c((i,h)=>{for(const a of h){let m=a.module?o.get(a.module):void 0;!m&&a.loc?.name&&s[a.loc.name]&&(m=[s[a.loc.name]]),m||(m=r.keys());const y=formatProblem(i==="errors"?"ERROR":"WARNING",a,t);for(const P of m){const u=r.get(P);u&&(i==="errors"?u.errorCount+=1:u.warningCount+=1,u[i].length<MAX_PROBLEMS&&u[i].push(y.length>MAX_PROBLEM_CHARS?`${y.slice(0,MAX_PROBLEM_CHARS)}\u2026`:y))}}},"assign");return g("errors",t.errors??[]),g("warnings",t.warnings??[]),r}p(attributeCompilation,"attributeCompilation"),l(attributeCompilation,"attributeCompilation"),c(attributeCompilation,"attributeCompilation");function describeBuild(t,e){const r=[];if(e.changed)for(const s of t.assets)r.push(`asset ${s.file} ${formatSize(s.size)} [emitted]`);for(const s of t.errors)r.push("",s);for(const s of t.warnings)r.push("",s);(t.errors.length||t.warnings.length)&&r.push("");const o=c((s,g)=>`${s} ${g}${s===1?"":"s"}`,"plural"),n=t.errorCount?`compiled with ${o(t.errorCount,"error")}${t.warningCount?` and ${o(t.warningCount,"warning")}`:""}`:t.warningCount?`compiled with ${o(t.warningCount,"warning")}`:"compiled successfully";return r.push(`webpack ${e.webpackVersion} ${n} in ${e.durationMs} ms (shared compilation${e.changed?"":" \u2014 this service's bundle is unchanged"})`),r.join(`
3
- `)}p(describeBuild,"describeBuild"),l(describeBuild,"describeBuild"),c(describeBuild,"describeBuild");function formatSize(t){return t>=1024*1024?`${(t/(1024*1024)).toFixed(2)} MiB`:t>=1024?`${(t/1024).toFixed(1)} KiB`:`${t} bytes`}p(formatSize,"formatSize"),l(formatSize,"formatSize"),c(formatSize,"formatSize");
1
+ "use strict";var w=Object.defineProperty;var l=(t,e)=>w(t,"name",{value:e,configurable:!0});var $=Object.defineProperty,c=l((t,e)=>$(t,"name",{value:e,configurable:!0}),"c");Object.defineProperty(exports,"__esModule",{value:!0}),exports.SharedEntriesPlugin=exports.EntryRegistry=void 0,exports.memberEntries=memberEntries,exports.attributeCompilation=attributeCompilation,exports.describeBuild=describeBuild;const tslib_1=require("tslib"),node_crypto_1=require("node:crypto"),path=tslib_1.__importStar(require("node:path"));function memberEntries(t,e){const r=[{name:t,project:t,import:e.main,outputFile:path.join(e.outputDir,"main.js")}];for(const o of e.additionalEntryPoints??[])r.push({name:`${t}~${o.entryName}`,project:t,import:o.entryPath,outputFile:path.join(e.outputDir,`${o.entryName}.js`)});return r}l(memberEntries,"memberEntries"),c(memberEntries,"memberEntries");class EntryRegistry{static{l(this,"EntryRegistry")}static{c(this,"EntryRegistry")}constructor(){this.byProject=new Map}set(e,r){this.byProject.set(e,r)}delete(e){return this.byProject.delete(e)}has(e){return this.byProject.has(e)}projects(){return[...this.byProject.keys()]}entriesOf(e){return this.byProject.get(e)??[]}entryProjects(){const e={};for(const[r,o]of this.byProject)for(const n of o)e[n.name]=r;return e}entry(e){for(const r of this.byProject.values()){const o=r.find(n=>n.name===e);if(o)return o}}webpackEntries(e){const r={};for(const o of this.byProject.values())for(const n of o)r[n.name]={import:[n.import],filename:path.relative(e,n.outputFile)};return r}}exports.EntryRegistry=EntryRegistry;class SharedEntriesPlugin{static{l(this,"SharedEntriesPlugin")}static{c(this,"SharedEntriesPlugin")}constructor(e){this.options=e}apply(e){const{registry:r,workspaceRoot:o,outputPath:n,cache:s}=this.options;e.options.context=o,e.context=o,e.options.output={...e.options.output,path:n,clean:!1,chunkFilename:c(m=>{const i=m.chunk?.runtime,d=typeof i=="string"?i:i?[...i].sort()[0]:void 0,u=d?r.entry(d):void 0;return`${u?path.relative(n,path.dirname(u.outputFile)):"."}/[id].js`},"chunkFilename")},e.options.cache={...s,buildDependencies:{...s.buildDependencies}},e.options.entry=()=>Promise.resolve(r.webpackEntries(n))}}exports.SharedEntriesPlugin=SharedEntriesPlugin;const resourceOf=c(t=>{if(typeof t.resource!="string"||!t.resource)return;const e=t.resource.search(/[?#]/);return e===-1?t.resource:t.resource.slice(0,e)},"resourceOf");function formatLoc(t){const e=t?.start;if(!e||typeof e.line!="number")return"";const r=`${e.line}:${e.column??0}`,o=t?.end;return!o||typeof o.line!="number"?r:o.line===e.line?`${r}-${o.column??0}`:`${r}-${o.line}:${o.column??0}`}l(formatLoc,"formatLoc"),c(formatLoc,"formatLoc");function formatProblem(t,e,r){const o=e.module;let n="";try{n=o?.readableIdentifier?o.readableIdentifier(r.requestShortener):""}catch{}const s=formatLoc(e.loc);return`${n?`${t} in ${n}${s?` ${s}`:""}`:t}
2
+ ${String(e.message??e).trim()}`}l(formatProblem,"formatProblem"),c(formatProblem,"formatProblem");const MAX_PROBLEMS=30,MAX_PROBLEM_CHARS=4e3;function attributeCompilation(t,e){const r=new Map,o=new Map,n=t.compiler?.context??t.options?.context??process.cwd();for(const i of e.projects()){const d=new Set;let u=!1;for(const a of e.entriesOf(i)){const p=t.entrypoints?.get(a.name);if(p){u=!0;for(const f of p.chunks??[]){d.add(f);for(const y of f.getAllAsyncChunks?.()??[])d.add(y)}}}if(!u)continue;const h=new Set,g=[],b=[];for(const a of d){g.push(`${String(a.id)}:${a.hash??""}`);for(const p of t.chunkGraph.getChunkModulesIterable(a)){let f=o.get(p);f||o.set(p,f=new Set),f.add(i);const y=resourceOf(p);y&&h.add(y)}for(const p of a.files??[]){const f=t.getAsset?.(p),y=path.resolve(t.outputOptions?.path??n,p);b.push({file:path.relative(n,y),size:f?.info?.size??f?.source?.size?.()??0})}}r.set(i,{project:i,hash:(0,node_crypto_1.createHash)("sha256").update(g.sort().join("|")).digest("hex").slice(0,16),errors:[],warnings:[],errorCount:0,warningCount:0,files:[...h],assets:b})}const s=e.entryProjects(),m=c((i,d)=>{for(const u of d){let h=u.module?o.get(u.module):void 0;!h&&u.loc?.name&&s[u.loc.name]&&(h=[s[u.loc.name]]),h||(h=r.keys());const g=formatProblem(i==="errors"?"ERROR":"WARNING",u,t);for(const b of h){const a=r.get(b);a&&(i==="errors"?a.errorCount+=1:a.warningCount+=1,a[i].length<MAX_PROBLEMS&&a[i].push(g.length>MAX_PROBLEM_CHARS?`${g.slice(0,MAX_PROBLEM_CHARS)}\u2026`:g))}}},"assign");return m("errors",t.errors??[]),m("warnings",t.warnings??[]),r}l(attributeCompilation,"attributeCompilation"),c(attributeCompilation,"attributeCompilation");function describeBuild(t,e){const r=[];if(e.changed)for(const s of t.assets)r.push(`asset ${s.file} ${formatSize(s.size)} [emitted]`);for(const s of t.errors)r.push("",s);for(const s of t.warnings)r.push("",s);(t.errors.length||t.warnings.length)&&r.push("");const o=c((s,m)=>`${s} ${m}${s===1?"":"s"}`,"plural"),n=t.errorCount?`compiled with ${o(t.errorCount,"error")}${t.warningCount?` and ${o(t.warningCount,"warning")}`:""}`:t.warningCount?`compiled with ${o(t.warningCount,"warning")}`:"compiled successfully";return r.push(`webpack ${e.webpackVersion} ${n} in ${e.durationMs} ms (shared compilation${e.changed?"":" \u2014 this service's bundle is unchanged"})`),r.join(`
3
+ `)}l(describeBuild,"describeBuild"),c(describeBuild,"describeBuild");function formatSize(t){return t>=1024*1024?`${(t/(1024*1024)).toFixed(2)} MiB`:t>=1024?`${(t/1024).toFixed(1)} KiB`:`${t} bytes`}l(formatSize,"formatSize"),c(formatSize,"formatSize");
@@ -1 +1 @@
1
- "use strict";var b=Object.defineProperty;var l=(e,o)=>b(e,"name",{value:o,configurable:!0});var g=Object.defineProperty,p=l((e,o)=>g(e,"name",{value:o,configurable:!0}),"p"),d=Object.defineProperty,a=p((e,o)=>d(e,"name",{value:o,configurable:!0}),"a");Object.defineProperty(exports,"__esModule",{value:!0}),exports.PER_SERVICE_PLUGINS=exports.TYPECHECK_ONLY_COMPILER_OPTIONS=exports.PER_SERVICE_TARGET_KEYS=void 0,exports.transpileCompilerOptions=transpileCompilerOptions,exports.memberMasks=memberMasks,exports.configFingerprint=configFingerprint,exports.memberSignature=memberSignature,exports.describeDifference=describeDifference,exports.refusalOf=refusalOf;const tslib_1=require("tslib"),node_crypto_1=require("node:crypto"),node_module_1=require("node:module"),path=tslib_1.__importStar(require("node:path"));exports.PER_SERVICE_TARGET_KEYS=["entryFile","tsConfigFile","outputPath","workers","configEnv","childCount","serviceName","servePrefix","gateway","internalPort","debugPort","logFile","webpackConfigPath","devtool","memoryLimit","port"],exports.TYPECHECK_ONLY_COMPILER_OPTIONS=new Set(["configFilePath","pathsBasePath","rootDir","rootDirs","outDir","outFile","declaration","declarationDir","declarationMap","emitDeclarationOnly","composite","incremental","tsBuildInfoFile","noEmit","noEmitOnError","types","typeRoots","lib","skipLibCheck","skipDefaultLibCheck","forceConsistentCasingInFileNames","strict","noImplicitAny","strictNullChecks","strictFunctionTypes","strictBindCallApply","strictPropertyInitialization","strictBuiltinIteratorReturn","noImplicitThis","useUnknownInCatchVariables","noUnusedLocals","noUnusedParameters","exactOptionalPropertyTypes","noImplicitReturns","noFallthroughCasesInSwitch","noUncheckedIndexedAccess","noImplicitOverride","noPropertyAccessFromIndexSignature","allowUnusedLabels","allowUnreachableCode","noErrorTruncation","diagnostics","extendedDiagnostics","listFiles","listEmittedFiles","traceResolution","explainFiles","pretty","preserveWatchOutput","assumeChangesOnlyAffectDirectDependencies","noStrictGenericChecks","suppressExcessPropertyErrors","suppressImplicitAnyIndexErrors","disableSizeLimit","disableSourceOfProjectReferenceRedirect","disableSolutionSearching","disableReferencedProjectLoad","noCheck","noUncheckedSideEffectImports","checkJs","maxNodeModuleJsDepth","isolatedDeclarations","erasableSyntaxOnly","libReplacement"]),exports.PER_SERVICE_PLUGINS=new Set(["DevServerReloadPlugin","PerfRulesPlugin","ForkTsCheckReporterPlugin","TsgoCheckPlugin","ForkTsCheckerWebpackPlugin","HotModuleReplacementPlugin"]);const UNWALKED_PLUGINS=new Set([...exports.PER_SERVICE_PLUGINS,"NxAppWebpackPlugin"]),sha=a(e=>(0,node_crypto_1.createHash)("sha256").update(e).digest("hex").slice(0,16),"sha");function loadTypeScript(e){try{return(0,node_module_1.createRequire)(path.join(e,"package.json"))("typescript")}catch{return require("typescript")}}l(loadTypeScript,"loadTypeScript"),p(loadTypeScript,"loadTypeScript"),a(loadTypeScript,"loadTypeScript");function canonical(e){if(Array.isArray(e))return e.map(canonical);if(e&&typeof e=="object"){const o={};for(const i of Object.keys(e).sort())o[i]=canonical(e[i]);return o}return e}l(canonical,"canonical"),p(canonical,"canonical"),a(canonical,"canonical");function transpileCompilerOptions(e,o){const i=loadTypeScript(o),r=i.readConfigFile(e,c=>i.sys.readFile(c));if(r.error)throw new Error(`cannot read ${e}: ${String(r.error.messageText)}`);const s={...i.sys,readDirectory:a(()=>[],"readDirectory")},f=i.parseJsonConfigFileContent(r.config,s,path.dirname(e),void 0,e),t={};for(const[c,m]of Object.entries(f.options))exports.TYPECHECK_ONLY_COMPILER_OPTIONS.has(c)||(t[c]=m);const n=f.options.paths;if(n){const c=f.options.baseUrl??f.options.pathsBasePath??path.dirname(e);t.paths=Object.fromEntries(Object.entries(n).map(([m,u])=>[m,u.map(y=>path.resolve(c,y))]))}return canonical(t)}l(transpileCompilerOptions,"transpileCompilerOptions"),p(transpileCompilerOptions,"transpileCompilerOptions"),a(transpileCompilerOptions,"transpileCompilerOptions");function memberMasks(e,o){const i=[{from:e.appRoot,to:"<appRoot>"},{from:e.outputDir,to:"<outputDir>"},{from:e.main,to:"<main>"},{from:e.tsConfig,to:"<tsConfig>"}];for(const r of e.additionalEntryPoints??[])i.push({from:r.entryPath,to:`<worker:${r.entryName}>`});return i.filter(r=>r.from).sort((r,s)=>s.from.length-r.from.length).concat([o,o.replace(/[^\w.-]+/g,"_"),e.appName,e.serviceName].filter(r=>!!r).map(r=>({from:r,to:"<project>",whole:!0})))}l(memberMasks,"memberMasks"),p(memberMasks,"memberMasks"),a(memberMasks,"memberMasks");const MAX_DEPTH=8,MAX_KEYS=200;function configFingerprint(e,o){const i=new WeakSet,r=a(t=>{let n=t;for(const c of o){if(c.whole){if(n===c.from)return c.to;continue}n.includes(c.from)&&(n=n.split(c.from).join(c.to))}return n},"mask"),s=a((t,n)=>{if(typeof t=="string")return r(t);if(typeof t=="function")return`fn:${sha(r(Function.prototype.toString.call(t)))}`;if(t instanceof RegExp)return`re:${r(String(t))}`;if(!t||typeof t!="object")return t;if(i.has(t))return"<cycle>";if(n>=MAX_DEPTH)return"<deep>";i.add(t);try{if(Array.isArray(t))return t.slice(0,MAX_KEYS).map(u=>s(u,n+1));if(t instanceof Map)return{$map:[...t.entries()].slice(0,MAX_KEYS).map(([u,y])=>[s(u,n+1),s(y,n+1)])};if(t instanceof Set)return{$set:[...t].slice(0,MAX_KEYS).map(u=>s(u,n+1))};const c=t.constructor?.name,m=c&&c!=="Object"?{$class:c}:{};for(const u of Object.keys(t).sort().slice(0,MAX_KEYS))m[u]=s(t[u],n+1);return m}finally{i.delete(t)}},"walk"),f={};for(const t of Object.keys(e).sort()){if(t==="entry"||t==="watch")continue;let n=e[t];t==="plugins"&&Array.isArray(n)&&(n=n.filter(c=>!UNWALKED_PLUGINS.has(c?.constructor?.name??""))),t==="output"&&n&&typeof n=="object"&&(n=Object.fromEntries(Object.entries(n).filter(([c])=>c!=="path"))),f[`config.${t}`]=sha(JSON.stringify(s(n,0)))}return f}l(configFingerprint,"configFingerprint"),p(configFingerprint,"configFingerprint"),a(configFingerprint,"configFingerprint");function moduleShapingOptions(e,o){return canonical({devtool:o,buildLibsFromSource:e.buildLibsFromSource??!0,orgScopes:e.orgScopes??[],bundlePackages:e.bundlePackages??[],nodeExternalsConfig:e.nodeExternalsConfig??null})}l(moduleShapingOptions,"moduleShapingOptions"),p(moduleShapingOptions,"moduleShapingOptions"),a(moduleShapingOptions,"moduleShapingOptions");function memberSignature(e){const{join:o}=e,i={};for(const[s,f]of Object.entries(o.targetOptions??{}))exports.PER_SERVICE_TARGET_KEYS.includes(s)||(i[s]=f);const r={options:sha(JSON.stringify(moduleShapingOptions(o.options,e.devtool))),targetOptions:sha(JSON.stringify(canonical(i))),tsconfig:sha(JSON.stringify(e.compilerOptions)),...configFingerprint(e.config,memberMasks(o.options,o.project))};return{key:sha(JSON.stringify(canonical(r))),parts:r}}l(memberSignature,"memberSignature"),p(memberSignature,"memberSignature"),a(memberSignature,"memberSignature");const PART_NAMES={options:"its build options (devtool, buildLibsFromSource, orgScopes, bundlePackages or nodeExternalsConfig)",targetOptions:"its serve target options",tsconfig:"its tsconfig compiler options"};function describeDifference(e,o){const i=[...new Set([...Object.keys(e.parts),...Object.keys(o.parts)])].sort((r,s)=>order(r)-order(s)||r.localeCompare(s));for(const r of i)if(e.parts[r]!==o.parts[r])return PART_NAMES[r]??`its webpack config (\`${r.slice(7)}\` \u2014 a webpackConfigPath override?)`}l(describeDifference,"describeDifference"),p(describeDifference,"describeDifference"),a(describeDifference,"describeDifference");function order(e){return e in PART_NAMES?0:1}l(order,"order"),p(order,"order"),a(order,"order");function refusalOf(e,o){const{options:i}=e,r=a(s=>!!s&&!path.relative(o,path.resolve(o,s)).startsWith(".."),"inside");if(i.buildLibsFromSource===!1)return"buildLibsFromSource is false \u2014 its library paths are its own (a tsconfig nx writes per project)";if([...i.assets??[],...Array.isArray(e.targetOptions?.assets)?e.targetOptions.assets:[]].length>0)return"it copies assets \u2014 they are copied relative to one output directory, and a shared compilation writes several";if(!r(i.outputDir))return`its output directory (${i.outputDir}) is outside the workspace`;if(i.webpackConfigPath&&!r(path.resolve(i.appRoot,i.webpackConfigPath)))return"its webpackConfigPath is outside the workspace";for(const s of i.additionalEntryPoints??[])if(!/^[\w.-]+$/.test(s.entryName))return`worker "${s.entryName}" is not a plain file name`}l(refusalOf,"refusalOf"),p(refusalOf,"refusalOf"),a(refusalOf,"refusalOf");
1
+ "use strict";var g=Object.defineProperty;var p=(e,i)=>g(e,"name",{value:i,configurable:!0});var d=Object.defineProperty,a=p((e,i)=>d(e,"name",{value:i,configurable:!0}),"a");Object.defineProperty(exports,"__esModule",{value:!0}),exports.PER_SERVICE_PLUGINS=exports.TYPECHECK_ONLY_COMPILER_OPTIONS=exports.PER_SERVICE_TARGET_KEYS=void 0,exports.transpileCompilerOptions=transpileCompilerOptions,exports.memberMasks=memberMasks,exports.configFingerprint=configFingerprint,exports.memberSignature=memberSignature,exports.describeDifference=describeDifference,exports.refusalOf=refusalOf;const tslib_1=require("tslib"),node_crypto_1=require("node:crypto"),node_module_1=require("node:module"),path=tslib_1.__importStar(require("node:path"));exports.PER_SERVICE_TARGET_KEYS=["entryFile","tsConfigFile","outputPath","workers","configEnv","childCount","serviceName","servePrefix","gateway","internalPort","debugPort","logFile","webpackConfigPath","devtool","memoryLimit","port"],exports.TYPECHECK_ONLY_COMPILER_OPTIONS=new Set(["configFilePath","pathsBasePath","rootDir","rootDirs","outDir","outFile","declaration","declarationDir","declarationMap","emitDeclarationOnly","composite","incremental","tsBuildInfoFile","noEmit","noEmitOnError","types","typeRoots","lib","skipLibCheck","skipDefaultLibCheck","forceConsistentCasingInFileNames","strict","noImplicitAny","strictNullChecks","strictFunctionTypes","strictBindCallApply","strictPropertyInitialization","strictBuiltinIteratorReturn","noImplicitThis","useUnknownInCatchVariables","noUnusedLocals","noUnusedParameters","exactOptionalPropertyTypes","noImplicitReturns","noFallthroughCasesInSwitch","noUncheckedIndexedAccess","noImplicitOverride","noPropertyAccessFromIndexSignature","allowUnusedLabels","allowUnreachableCode","noErrorTruncation","diagnostics","extendedDiagnostics","listFiles","listEmittedFiles","traceResolution","explainFiles","pretty","preserveWatchOutput","assumeChangesOnlyAffectDirectDependencies","noStrictGenericChecks","suppressExcessPropertyErrors","suppressImplicitAnyIndexErrors","disableSizeLimit","disableSourceOfProjectReferenceRedirect","disableSolutionSearching","disableReferencedProjectLoad","noCheck","noUncheckedSideEffectImports","checkJs","maxNodeModuleJsDepth","isolatedDeclarations","erasableSyntaxOnly","libReplacement"]),exports.PER_SERVICE_PLUGINS=new Set(["DevServerReloadPlugin","PerfRulesPlugin","ForkTsCheckReporterPlugin","TsgoCheckPlugin","ForkTsCheckerWebpackPlugin","HotModuleReplacementPlugin"]);const UNWALKED_PLUGINS=new Set([...exports.PER_SERVICE_PLUGINS,"NxAppWebpackPlugin"]),sha=a(e=>(0,node_crypto_1.createHash)("sha256").update(e).digest("hex").slice(0,16),"sha");function loadTypeScript(e){try{return(0,node_module_1.createRequire)(path.join(e,"package.json"))("typescript")}catch{return require("typescript")}}p(loadTypeScript,"loadTypeScript"),a(loadTypeScript,"loadTypeScript");function canonical(e){if(Array.isArray(e))return e.map(canonical);if(e&&typeof e=="object"){const i={};for(const o of Object.keys(e).sort())i[o]=canonical(e[o]);return i}return e}p(canonical,"canonical"),a(canonical,"canonical");function transpileCompilerOptions(e,i){const o=loadTypeScript(i),r=o.readConfigFile(e,c=>o.sys.readFile(c));if(r.error)throw new Error(`cannot read ${e}: ${String(r.error.messageText)}`);const s={...o.sys,readDirectory:a(()=>[],"readDirectory")},u=o.parseJsonConfigFileContent(r.config,s,path.dirname(e),void 0,e),t={};for(const[c,f]of Object.entries(u.options))exports.TYPECHECK_ONLY_COMPILER_OPTIONS.has(c)||(t[c]=f);const n=u.options.paths;if(n){const c=u.options.baseUrl??u.options.pathsBasePath??path.dirname(e);t.paths=Object.fromEntries(Object.entries(n).map(([f,l])=>[f,l.map(m=>path.resolve(c,m))]))}return canonical(t)}p(transpileCompilerOptions,"transpileCompilerOptions"),a(transpileCompilerOptions,"transpileCompilerOptions");function memberMasks(e,i){const o=[{from:e.appRoot,to:"<appRoot>"},{from:e.outputDir,to:"<outputDir>"},{from:e.main,to:"<main>"},{from:e.tsConfig,to:"<tsConfig>"}];for(const r of e.additionalEntryPoints??[])o.push({from:r.entryPath,to:`<worker:${r.entryName}>`});return o.filter(r=>r.from).sort((r,s)=>s.from.length-r.from.length).concat([i,i.replace(/[^\w.-]+/g,"_"),e.appName,e.serviceName].filter(r=>!!r).map(r=>({from:r,to:"<project>",whole:!0})))}p(memberMasks,"memberMasks"),a(memberMasks,"memberMasks");const MAX_DEPTH=8,MAX_KEYS=200;function configFingerprint(e,i){const o=new WeakSet,r=a(t=>{let n=t;for(const c of i){if(c.whole){if(n===c.from)return c.to;continue}n.includes(c.from)&&(n=n.split(c.from).join(c.to))}return n},"mask"),s=a((t,n)=>{if(typeof t=="string")return r(t);if(typeof t=="function")return`fn:${sha(r(Function.prototype.toString.call(t)))}`;if(t instanceof RegExp)return`re:${r(String(t))}`;if(!t||typeof t!="object")return t;if(o.has(t))return"<cycle>";if(n>=MAX_DEPTH)return"<deep>";o.add(t);try{if(Array.isArray(t))return t.slice(0,MAX_KEYS).map(l=>s(l,n+1));if(t instanceof Map)return{$map:[...t.entries()].slice(0,MAX_KEYS).map(([l,m])=>[s(l,n+1),s(m,n+1)])};if(t instanceof Set)return{$set:[...t].slice(0,MAX_KEYS).map(l=>s(l,n+1))};const c=t.constructor?.name,f=c&&c!=="Object"?{$class:c}:{};for(const l of Object.keys(t).sort().slice(0,MAX_KEYS))f[l]=s(t[l],n+1);return f}finally{o.delete(t)}},"walk"),u={};for(const t of Object.keys(e).sort()){if(t==="entry"||t==="watch")continue;let n=e[t];t==="plugins"&&Array.isArray(n)&&(n=n.filter(c=>!UNWALKED_PLUGINS.has(c?.constructor?.name??""))),t==="output"&&n&&typeof n=="object"&&(n=Object.fromEntries(Object.entries(n).filter(([c])=>c!=="path"))),u[`config.${t}`]=sha(JSON.stringify(s(n,0)))}return u}p(configFingerprint,"configFingerprint"),a(configFingerprint,"configFingerprint");function moduleShapingOptions(e,i){return canonical({devtool:i,buildLibsFromSource:e.buildLibsFromSource??!0,orgScopes:e.orgScopes??[],bundlePackages:e.bundlePackages??[],nodeExternalsConfig:e.nodeExternalsConfig??null})}p(moduleShapingOptions,"moduleShapingOptions"),a(moduleShapingOptions,"moduleShapingOptions");function memberSignature(e){const{join:i}=e,o={};for(const[s,u]of Object.entries(i.targetOptions??{}))exports.PER_SERVICE_TARGET_KEYS.includes(s)||(o[s]=u);const r={options:sha(JSON.stringify(moduleShapingOptions(i.options,e.devtool))),targetOptions:sha(JSON.stringify(canonical(o))),tsconfig:sha(JSON.stringify(e.compilerOptions)),...configFingerprint(e.config,memberMasks(i.options,i.project))};return{key:sha(JSON.stringify(canonical(r))),parts:r}}p(memberSignature,"memberSignature"),a(memberSignature,"memberSignature");const PART_NAMES={options:"its build options (devtool, buildLibsFromSource, orgScopes, bundlePackages or nodeExternalsConfig)",targetOptions:"its serve target options",tsconfig:"its tsconfig compiler options"};function describeDifference(e,i){const o=[...new Set([...Object.keys(e.parts),...Object.keys(i.parts)])].sort((r,s)=>order(r)-order(s)||r.localeCompare(s));for(const r of o)if(e.parts[r]!==i.parts[r])return PART_NAMES[r]??`its webpack config (\`${r.slice(7)}\` \u2014 a webpackConfigPath override?)`}p(describeDifference,"describeDifference"),a(describeDifference,"describeDifference");function order(e){return e in PART_NAMES?0:1}p(order,"order"),a(order,"order");function refusalOf(e,i){const{options:o}=e,r=a(s=>!!s&&!path.relative(i,path.resolve(i,s)).startsWith(".."),"inside");if(o.buildLibsFromSource===!1)return"buildLibsFromSource is false \u2014 its library paths are its own (a tsconfig nx writes per project)";if([...o.assets??[],...Array.isArray(e.targetOptions?.assets)?e.targetOptions.assets:[]].length>0)return"it copies assets \u2014 they are copied relative to one output directory, and a shared compilation writes several";if(!r(o.outputDir))return`its output directory (${o.outputDir}) is outside the workspace`;if(o.webpackConfigPath&&!r(path.resolve(o.appRoot,o.webpackConfigPath)))return"its webpackConfigPath is outside the workspace";for(const s of o.additionalEntryPoints??[])if(!/^[\w.-]+$/.test(s.entryName))return`worker "${s.entryName}" is not a plain file name`}p(refusalOf,"refusalOf"),a(refusalOf,"refusalOf");
package/stdio-guard.js CHANGED
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var t=(o,e)=>u(o,"name",{value:e,configurable:!0});var c=Object.defineProperty,r=t((o,e)=>c(o,"name",{value:e,configurable:!0}),"r"),d=Object.defineProperty,s=r((o,e)=>d(o,"name",{value:e,configurable:!0}),"s");Object.defineProperty(exports,"__esModule",{value:!0}),exports.guardBrokenStdio=guardBrokenStdio;function guardBrokenStdio(o=[process.stdout,process.stderr]){for(const e of o){const n=e;n.__lensmcpStdioGuard||(n.__lensmcpStdioGuard=!0,e.on("error",a=>{if(a?.code!=="EPIPE")throw a}))}}t(guardBrokenStdio,"guardBrokenStdio"),r(guardBrokenStdio,"guardBrokenStdio"),s(guardBrokenStdio,"guardBrokenStdio");
1
+ "use strict";var c=Object.defineProperty;var r=(o,e)=>c(o,"name",{value:e,configurable:!0});var d=Object.defineProperty,s=r((o,e)=>d(o,"name",{value:e,configurable:!0}),"s");Object.defineProperty(exports,"__esModule",{value:!0}),exports.guardBrokenStdio=guardBrokenStdio;function guardBrokenStdio(o=[process.stdout,process.stderr]){for(const e of o){const t=e;t.__lensmcpStdioGuard||(t.__lensmcpStdioGuard=!0,e.on("error",n=>{if(n?.code!=="EPIPE")throw n}))}}r(guardBrokenStdio,"guardBrokenStdio"),s(guardBrokenStdio,"guardBrokenStdio");
package/swap-mode.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ /**
2
+ * How a pod takes a new build — `LENSMCP_SWAP_MODE`.
3
+ *
4
+ * process (the default) the parent starts a FRESH pod on the new bundle; the serving pod keeps serving, at full
5
+ * speed, until its successor is ready, then drains and exits — the make-before-break handoff `recyclePod`
6
+ * already did for a pod that outgrew its memory bound.
7
+ * in-process the serving pod re-evaluates the bundle and builds the new app itself (`swapNow`). Nothing new to start,
8
+ * so the new code serves a little sooner — but the pod stands still while it builds.
9
+ *
10
+ * Why the default changed (2026-10-19): FoodGuard's engine bundle is 35 MB. Evaluating it and building the app inside
11
+ * the serving pod held its event loop 2–17 s per swap, and everything waiting in that process timed out on wake — pg's
12
+ * pool waits («timeout exceeded when trying to connect», read as "Postgres ran out of connections") in 42 of the 53
13
+ * minutes they happened. A fresh process builds beside the serving one and freezes nothing that serves; it also
14
+ * carries no earlier generation, so the memory a swapped-out app leaves behind (swap-recycle.ts) never accumulates.
15
+ */
16
+ export type SwapMode = 'process' | 'in-process';
17
+ export declare function swapMode(env?: Record<string, string | undefined>): SwapMode;
18
+ /**
19
+ * A fresh pod still booting for a build that a newer one has already replaced is abandoned, and one pod boots for the
20
+ * newest build instead (issues/closed/foodguard-75). It used to finish booting, take over, and be replaced at once by
21
+ * yet another full pod — FoodGuard booted five engine pods (each ~1.8 GB, 9–20 s) in two minutes of an agent's edits.
22
+ * At most `LENSMCP_SWAP_MAX_SUPERSEDED` (default 2) in a row, so non-stop edits cannot keep a service on an old build
23
+ * for ever: past it, the booting pod is let through and the next build gets one more.
24
+ */
25
+ export declare function abandonSuperseded(supersededInARow: number, env?: Record<string, string | undefined>): boolean;
26
+ /**
27
+ * Pods a reload-handoff may leave finishing their work at once (`LENSMCP_SWAP_MAX_RETIRING`, default 2). Edits come
28
+ * faster than a long job ends; past the cap the oldest retiring pod is stopped, as the in-process swap closes the
29
+ * oldest draining app at its own cap.
30
+ */
31
+ export declare function maxRetiring(env?: Record<string, string | undefined>): number;
package/swap-mode.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var a=Object.defineProperty;var o=(r,e)=>a(r,"name",{value:e,configurable:!0});var t=Object.defineProperty,s=o((r,e)=>t(r,"name",{value:e,configurable:!0}),"s");Object.defineProperty(exports,"__esModule",{value:!0}),exports.swapMode=swapMode,exports.abandonSuperseded=abandonSuperseded,exports.maxRetiring=maxRetiring;function swapMode(r=process.env){const e=(r.LENSMCP_SWAP_MODE??"").trim().toLowerCase();return e==="in-process"||e==="inprocess"||e==="hot"?"in-process":"process"}o(swapMode,"swapMode"),s(swapMode,"swapMode");function abandonSuperseded(r,e=process.env){const n=Number(e.LENSMCP_SWAP_MAX_SUPERSEDED),i=Number.isFinite(n)&&n>=0?Math.floor(n):2;return r<i}o(abandonSuperseded,"abandonSuperseded"),s(abandonSuperseded,"abandonSuperseded");function maxRetiring(r=process.env){const e=Number(r.LENSMCP_SWAP_MAX_RETIRING);return Number.isFinite(e)&&e>=1?Math.floor(e):2}o(maxRetiring,"maxRetiring"),s(maxRetiring,"maxRetiring");
package/swap-recycle.js CHANGED
@@ -1 +1 @@
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
+ "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,5 +1,5 @@
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(`
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(`
3
3
  `)?i:`${i}
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");
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");
package/typecheck-bus.js CHANGED
@@ -1,4 +1,4 @@
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(`
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(`
3
3
  `)+`
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");
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");
@@ -1 +1 @@
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
+ "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 +1 @@
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;
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;