@lensmcp/cluster 1.18.14 → 1.19.0

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 (64) hide show
  1. package/basic-ssl.js +1 -1
  2. package/build-scope-patterns.js +1 -1
  3. package/create-webpack-dev.js +1 -1
  4. package/create-webpack-prod.js +1 -1
  5. package/executors/build/build.impl.js +1 -1
  6. package/executors/gateway/gateway-errors.js +1 -1
  7. package/executors/gateway/gateway.impl.js +1 -1
  8. package/executors/gateway/gateway.lib.js +1 -1
  9. package/executors/gateway/health-check.js +1 -1
  10. package/executors/gateway/jwks-verify.js +1 -1
  11. package/executors/gateway/main.prod-gateway.js +2 -2
  12. package/executors/gateway/main.rollout.js +4 -4
  13. package/executors/gateway/manifest.js +1 -1
  14. package/executors/gateway/metrics.js +1 -1
  15. package/executors/gateway/otel-tracing.js +1 -1
  16. package/executors/gateway/prod-gateway.lib.js +1 -1
  17. package/executors/gateway/prod-runtime/access-log.js +1 -1
  18. package/executors/gateway/prod-runtime/app.js +1 -1
  19. package/executors/gateway/prod-runtime/auth.js +1 -1
  20. package/executors/gateway/prod-runtime/cors.js +1 -1
  21. package/executors/gateway/prod-runtime/edge.js +1 -1
  22. package/executors/gateway/prod-runtime/handler.js +1 -1
  23. package/executors/gateway/prod-runtime/hooks.js +1 -1
  24. package/executors/gateway/prod-runtime/observability.js +1 -1
  25. package/executors/gateway/prod-runtime/rollout.js +1 -1
  26. package/executors/gateway/prod-runtime/routing.js +1 -1
  27. package/executors/gateway/prod-runtime/server.js +1 -1
  28. package/executors/gateway/prod-runtime/trust.js +1 -1
  29. package/executors/gateway/prod-runtime/upgrade.js +2 -2
  30. package/executors/gateway/prod-runtime/upstream.js +1 -1
  31. package/executors/gateway/providers-prod.js +1 -1
  32. package/executors/gateway/rate-limit.js +2 -2
  33. package/executors/gateway/registry-source.js +1 -1
  34. package/executors/gateway/rollout-ops.js +2 -2
  35. package/executors/gateway/runtime/auth.js +1 -1
  36. package/executors/gateway/runtime/chooser.js +7 -7
  37. package/executors/gateway/runtime/control.js +1 -1
  38. package/executors/gateway/runtime/dev-auth.js +1 -1
  39. package/executors/gateway/runtime/discovery.js +1 -1
  40. package/executors/gateway/runtime/edge.js +1 -1
  41. package/executors/gateway/runtime/handler.js +1 -1
  42. package/executors/gateway/runtime/hmr-reload.js +1 -1
  43. package/executors/gateway/runtime/hooks.js +1 -1
  44. package/executors/gateway/runtime/lens-children.js +1 -1
  45. package/executors/gateway/runtime/lifecycle.js +3 -3
  46. package/executors/gateway/runtime/observability.js +2 -2
  47. package/executors/gateway/runtime/pod-env.js +2 -2
  48. package/executors/gateway/runtime/proxy.js +1 -1
  49. package/executors/gateway/runtime/route-registry.js +1 -1
  50. package/executors/gateway/runtime/scope.js +1 -1
  51. package/executors/gateway/runtime/server.js +2 -2
  52. package/executors/gateway/runtime/service-keys.js +1 -1
  53. package/executors/gateway/runtime/types.js +1 -1
  54. package/executors/gateway/runtime/upgrade.js +1 -1
  55. package/executors/gateway/runtime/workspace-registry.js +1 -1
  56. package/executors/gateway/ssrf-guard.js +1 -1
  57. package/executors/serve/serve.impl.js +1 -1
  58. package/executors/trust/trust.impl.js +3 -3
  59. package/gateway.js +1 -1
  60. package/index.js +1 -1
  61. package/main.devserver.js +5 -5
  62. package/package.json +4 -4
  63. package/tsgo-check-plugin.js +4 -4
  64. package/typecheck-bus.js +3 -3
@@ -1,4 +1,4 @@
1
- "use strict";var f=Object.defineProperty;var a=(e,t)=>f(e,"name",{value:t,configurable:!0});var d=Object.defineProperty,l=a((e,t)=>d(e,"name",{value:t,configurable:!0}),"l"),u=Object.defineProperty,r=l((e,t)=>u(e,"name",{value:t,configurable:!0}),"r");Object.defineProperty(exports,"__esModule",{value:!0}),exports.TsgoCheckPlugin=exports.TSGO_MISSING_CAUSE=exports.TSGO_PACKAGE=void 0,exports.resolveTsgoPackageDir=resolveTsgoPackageDir,exports.resolveTsgoBin=resolveTsgoBin,exports.reportTsgoUnavailable=reportTsgoUnavailable,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");exports.TSGO_PACKAGE="@typescript/native-preview";function shimNames(e){return e==="win32"?["tsgo.cmd","tsgo.exe"]:["tsgo"]}a(shimNames,"shimNames"),l(shimNames,"shimNames"),r(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}}a(isExecutableFile,"isExecutableFile"),l(isExecutableFile,"isExecutableFile"),r(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 i=path.join(e,"package.json");if(fs.existsSync(i))try{const{name:o}=JSON.parse(fs.readFileSync(i,"utf8"));if(o===exports.TSGO_PACKAGE)return e}catch{}const s=path.dirname(e);if(s===e)break;e=s}}catch{}return null}a(resolveTsgoPackageDir,"resolveTsgoPackageDir"),l(resolveTsgoPackageDir,"resolveTsgoPackageDir"),r(resolveTsgoPackageDir,"resolveTsgoPackageDir");function packageDeclaredBin(e){try{const{bin:t}=JSON.parse(fs.readFileSync(path.join(e,"package.json"),"utf8")),i=typeof t=="string"?t:t?.tsgo;return i?path.join(e,i):null}catch{return null}}a(packageDeclaredBin,"packageDeclaredBin"),l(packageDeclaredBin,"packageDeclaredBin"),r(packageDeclaredBin,"packageDeclaredBin");function ownBinCandidates(e,t){const i=path.resolve(e,"..","..",".bin"),s=shimNames(t).map(n=>path.join(i,n)),o=t==="win32"?null:packageDeclaredBin(e);return o?[o,...s]:s}a(ownBinCandidates,"ownBinCandidates"),l(ownBinCandidates,"ownBinCandidates"),r(ownBinCandidates,"ownBinCandidates");function resolveTsgoBin(e,t,i={}){const s=i.platform??process.platform,o=i.isExecutable??(p=>isExecutableFile(p,s));if(t)return o(t)?t:null;for(const p of shimNames(s)){const c=path.join(e,"node_modules",".bin",p);if(o(c))return c}const n=(i.ownPackageDir??resolveTsgoPackageDir)();return n?ownBinCandidates(n,s).find(o)??null:null}a(resolveTsgoBin,"resolveTsgoBin"),l(resolveTsgoBin,"resolveTsgoBin"),r(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{}}a(reportTsgoUnavailable,"reportTsgoUnavailable"),l(reportTsgoUnavailable,"reportTsgoUnavailable"),r(reportTsgoUnavailable,"reportTsgoUnavailable");function writeShimTsconfig(e,t,i){const s=path.join(i,"tmp","lensmcp-tsgo");fs.mkdirSync(s,{recursive:!0});const o=path.join(s,`${e}.tsconfig.json`);return fs.writeFileSync(o,JSON.stringify({extends:t,compilerOptions:{module:"preserve",moduleResolution:"bundler",isolatedModules:!1,baseUrl:null}},null,2)),o}a(writeShimTsconfig,"writeShimTsconfig"),l(writeShimTsconfig,"writeShimTsconfig"),r(writeShimTsconfig,"writeShimTsconfig");class TsgoCheckPlugin{static{a(this,"TsgoCheckPlugin")}static{l(this,"TsgoCheckPlugin")}static{r(this,"TsgoCheckPlugin")}constructor(t){this.timer=null,this.inflight=null,this.shimPath=null,this.disabled=!1,this.opts=t,this.spawnImpl=t.spawnImpl??node_child_process_1.spawn}apply(t){t.hooks.done.tap("TsgoCheckPlugin",i=>{i.hasErrors()||this.schedule()})}schedule(){this.disabled||(this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>this.run(),this.opts.debounceMs??500),this.timer.unref?.())}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(){const t=resolveTsgoBin(this.opts.workspaceRoot,this.opts.binPath);if(!t){this.disabled=!0;const n=`${exports.TSGO_MISSING_CAUSE}. Type checking is disabled for the rest of this session`;console.warn(`[tsgo] ${this.opts.appName}: ${n}.`),this.publish({output:"",durationMs:0,toolError:n});return}this.inflight&&(this.inflight.kill("SIGTERM"),this.inflight=null),this.shimPath||(this.shimPath=writeShimTsconfig(this.opts.appName,this.opts.tsConfig,this.opts.workspaceRoot));const i=Date.now(),s=this.spawnImpl(t,["--noEmit","--pretty","false","-p",this.shimPath],{cwd:this.opts.workspaceRoot,stdio:["ignore","pipe","pipe"]});this.inflight=s;let o="";s.stdout?.on("data",n=>{o+=n.toString()}),s.stderr?.on("data",n=>{o+=n.toString()}),s.on("error",()=>{this.inflight===s&&(this.inflight=null),console.warn(`[tsgo] ${this.opts.appName}: failed to spawn ${t}`),this.publish({output:"",durationMs:Date.now()-i,toolError:`failed to spawn ${t}`})}),s.on("close",(n,p)=>{if(this.inflight===s&&(this.inflight=null),p)return;const c=Date.now()-i,g=(c/1e3).toFixed(1);if(n===0){console.log(`[tsgo] ${this.opts.appName}: types clean (${g}s)`),this.publish({output:"",durationMs:c});return}o.trim()&&process.stdout.write(o.endsWith(`
2
- `)?o:`${o}
3
- `);const h=(o.match(/error TS\d+/g)??[]).length;console.log(`[tsgo] ${this.opts.appName}: ${h} type error${h===1?"":"s"} (${g}s)`),this.publish({output:o,durationMs:c,...h===0?{toolError:`tsgo exited ${n} with no diagnostics: ${firstLine(o)}`}:{}})})}}exports.TsgoCheckPlugin=TsgoCheckPlugin;function firstLine(e){return e.trim().split(`
4
- `)[0]?.slice(0,300)??""}a(firstLine,"firstLine"),l(firstLine,"firstLine"),r(firstLine,"firstLine");
1
+ "use strict";var d=Object.defineProperty;var l=(s,t)=>d(s,"name",{value:t,configurable:!0});var u=Object.defineProperty,r=l((s,t)=>u(s,"name",{value:t,configurable:!0}),"r");Object.defineProperty(exports,"__esModule",{value:!0}),exports.TsgoCheckPlugin=exports.TSGO_MISSING_CAUSE=exports.TSGO_PACKAGE=void 0,exports.resolveTsgoPackageDir=resolveTsgoPackageDir,exports.resolveTsgoBin=resolveTsgoBin,exports.reportTsgoUnavailable=reportTsgoUnavailable,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");exports.TSGO_PACKAGE="@typescript/native-preview";function shimNames(s){return s==="win32"?["tsgo.cmd","tsgo.exe"]:["tsgo"]}l(shimNames,"shimNames"),r(shimNames,"shimNames");function isExecutableFile(s,t){try{if(!fs.statSync(s).isFile())return!1}catch{return!1}if(t==="win32")return!0;try{return fs.accessSync(s,fs.constants.X_OK),!0}catch{return!1}}l(isExecutableFile,"isExecutableFile"),r(isExecutableFile,"isExecutableFile");function resolveTsgoPackageDir(){try{return path.dirname(require.resolve(`${exports.TSGO_PACKAGE}/package.json`))}catch{}try{let s=path.dirname(require.resolve(exports.TSGO_PACKAGE));for(let t=0;t<6;t++){const i=path.join(s,"package.json");if(fs.existsSync(i))try{const{name:e}=JSON.parse(fs.readFileSync(i,"utf8"));if(e===exports.TSGO_PACKAGE)return s}catch{}const o=path.dirname(s);if(o===s)break;s=o}}catch{}return null}l(resolveTsgoPackageDir,"resolveTsgoPackageDir"),r(resolveTsgoPackageDir,"resolveTsgoPackageDir");function packageDeclaredBin(s){try{const{bin:t}=JSON.parse(fs.readFileSync(path.join(s,"package.json"),"utf8")),i=typeof t=="string"?t:t?.tsgo;return i?path.join(s,i):null}catch{return null}}l(packageDeclaredBin,"packageDeclaredBin"),r(packageDeclaredBin,"packageDeclaredBin");function ownBinCandidates(s,t){const i=path.resolve(s,"..","..",".bin"),o=shimNames(t).map(n=>path.join(i,n)),e=t==="win32"?null:packageDeclaredBin(s);return e?[e,...o]:o}l(ownBinCandidates,"ownBinCandidates"),r(ownBinCandidates,"ownBinCandidates");function resolveTsgoBin(s,t,i={}){const o=i.platform??process.platform,e=i.isExecutable??(p=>isExecutableFile(p,o));if(t)return e(t)?t:null;for(const p of shimNames(o)){const a=path.join(s,"node_modules",".bin",p);if(e(a))return a}const n=(i.ownPackageDir??resolveTsgoPackageDir)();return n?ownBinCandidates(n,o).find(e)??null:null}l(resolveTsgoBin,"resolveTsgoBin"),r(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(s){try{(0,typecheck_bus_1.publishTypecheckRun)({workspaceRoot:s.workspaceRoot,project:s.appName,tool:"tsgo",tsConfig:s.tsConfig,output:"",durationMs:0,toolError:s.detail,...s.eventFile?{eventFile:s.eventFile}:{}})}catch{}}l(reportTsgoUnavailable,"reportTsgoUnavailable"),r(reportTsgoUnavailable,"reportTsgoUnavailable");function writeShimTsconfig(s,t,i){const o=path.join(i,"tmp","lensmcp-tsgo");fs.mkdirSync(o,{recursive:!0});const e=path.join(o,`${s}.tsconfig.json`);return fs.writeFileSync(e,JSON.stringify({extends:t,compilerOptions:{module:"preserve",moduleResolution:"bundler",isolatedModules:!1,baseUrl:null}},null,2)),e}l(writeShimTsconfig,"writeShimTsconfig"),r(writeShimTsconfig,"writeShimTsconfig");class TsgoCheckPlugin{static{l(this,"TsgoCheckPlugin")}static{r(this,"TsgoCheckPlugin")}constructor(t){this.timer=null,this.inflight=null,this.shimPath=null,this.disabled=!1,this.opts=t,this.spawnImpl=t.spawnImpl??node_child_process_1.spawn}apply(t){t.hooks.done.tap("TsgoCheckPlugin",i=>{i.hasErrors()||this.schedule()})}schedule(){this.disabled||(this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>this.run(),this.opts.debounceMs??500),this.timer.unref?.())}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(){const t=resolveTsgoBin(this.opts.workspaceRoot,this.opts.binPath);if(!t){this.disabled=!0;const n=`${exports.TSGO_MISSING_CAUSE}. Type checking is disabled for the rest of this session`;console.warn(`[tsgo] ${this.opts.appName}: ${n}.`),this.publish({output:"",durationMs:0,toolError:n});return}this.inflight&&(this.inflight.kill("SIGTERM"),this.inflight=null),this.shimPath||(this.shimPath=writeShimTsconfig(this.opts.appName,this.opts.tsConfig,this.opts.workspaceRoot));const i=Date.now(),o=this.spawnImpl(t,["--noEmit","--pretty","false","-p",this.shimPath],{cwd:this.opts.workspaceRoot,stdio:["ignore","pipe","pipe"]});this.inflight=o;let e="";o.stdout?.on("data",n=>{e+=n.toString()}),o.stderr?.on("data",n=>{e+=n.toString()}),o.on("error",()=>{this.inflight===o&&(this.inflight=null),console.warn(`[tsgo] ${this.opts.appName}: failed to spawn ${t}`),this.publish({output:"",durationMs:Date.now()-i,toolError:`failed to spawn ${t}`})}),o.on("close",(n,p)=>{if(this.inflight===o&&(this.inflight=null),p)return;const a=Date.now()-i,h=(a/1e3).toFixed(1);if(n===0){console.log(`[tsgo] ${this.opts.appName}: types clean (${h}s)`),this.publish({output:"",durationMs:a});return}e.trim()&&process.stdout.write(e.endsWith(`
2
+ `)?e:`${e}
3
+ `);const c=(e.match(/error TS\d+/g)??[]).length;console.log(`[tsgo] ${this.opts.appName}: ${c} type error${c===1?"":"s"} (${h}s)`),this.publish({output:e,durationMs:a,...c===0?{toolError:`tsgo exited ${n} with no diagnostics: ${firstLine(e)}`}:{}})})}}exports.TsgoCheckPlugin=TsgoCheckPlugin;function firstLine(s){return s.trim().split(`
4
+ `)[0]?.slice(0,300)??""}l(firstLine,"firstLine"),r(firstLine,"firstLine");
package/typecheck-bus.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var y=Object.defineProperty;var c=(e,r)=>y(e,"name",{value:r,configurable:!0});var g=Object.defineProperty,s=c((e,r)=>g(e,"name",{value:r,configurable:!0}),"s"),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.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,"")}c(stripAnsi,"stripAnsi"),s(stripAnsi,"stripAnsi"),i(stripAnsi,"stripAnsi");function parseTscDiagnosticLine(e){const r=stripAnsi(e).trim();if(!r)return null;const t=DIAG_LINE_REGEX.exec(r);if(!t)return null;const[,o,l,a,p,d,u]=t;return!o||!l||!a||!p||!d||!u?null:{file:o,line:Number(l),column:Number(a),severity:p==="warning"?"warning":"error",code:d,message:u}}c(parseTscDiagnosticLine,"parseTscDiagnosticLine"),s(parseTscDiagnosticLine,"parseTscDiagnosticLine"),i(parseTscDiagnosticLine,"parseTscDiagnosticLine");function parseTscOutput(e){const r=[];for(const t of e.split(`
2
- `)){const o=parseTscDiagnosticLine(t);o&&r.push(o)}return r}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(e){const r=(e.now??Date.now)(),t=e.idImpl??makeId,o="pending",l={sessionId:o,source:"typescript",category:"typecheck",context:{sessionId:o,projectName:e.project}},a={project:e.project,tool:e.tool,...e.tsConfig?{tsConfig:e.tsConfig}:{}},p=e.diagnostics.filter(n=>n.severity==="error"),d=e.diagnostics.slice(0,exports.MAX_DIAGNOSTICS_PER_RUN),u=[];if(!e.toolError){u.push({...l,id:t(),timestamp:r,severity:"info",title:`tsc clear: ${e.project}`,message:`typecheck run starting for ${e.project}`,fingerprint:`tsc:${e.project}:run-start`,raw:{...a,kind:"typecheck-run",phase:"start"}});for(const n of d)u.push({...l,id:t(),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:{...a,kind:"typecheck-diagnostic",code:n.code}})}const h=e.toolError?"error":p.length>0?"failing":"clean";return u.push({...l,id:t(),timestamp:r,severity:"info",title:`typecheck run: ${e.project} \u2014 ${e.toolError?"tool error":`${p.length} error${p.length===1?"":"s"}`} (${e.durationMs}ms)`,...e.toolError?{message:e.toolError}:{},fingerprint:`tsc:${e.project}:run-end`,raw:{...a,kind:"typecheck-run",phase:"end",status:h,durationMs:e.durationMs,errorCount:p.length,warningCount:e.diagnostics.length-p.length,...e.diagnostics.length>d.length?{truncatedDiagnostics:e.diagnostics.length-d.length}:{},...e.toolError?{error:e.toolError}:{}}}),u}c(buildTypecheckRunEvents,"buildTypecheckRunEvents"),s(buildTypecheckRunEvents,"buildTypecheckRunEvents"),i(buildTypecheckRunEvents,"buildTypecheckRunEvents");function resolveEventFile(e){return process.env.LENSMCP_EVENT_FILE||path.join(e,".lensmcp","events.jsonl")}c(resolveEventFile,"resolveEventFile"),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)}c(ensureDir,"ensureDir"),s(ensureDir,"ensureDir"),i(ensureDir,"ensureDir");function appendTypecheckEvents(e,r){if(r.length===0)return;const t=r.map(o=>JSON.stringify(o)).join(`
1
+ "use strict";var g=Object.defineProperty;var s=(t,e)=>g(t,"name",{value:e,configurable:!0});var 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.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,"")}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,u,c,a,p]=n;return!o||!l||!u||!c||!a||!p?null:{file:o,line:Number(l),column:Number(u),severity:c==="warning"?"warning":"error",code:a,message:p}}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}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(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}},u={project:t.project,tool:t.tool,...t.tsConfig?{tsConfig:t.tsConfig}:{}},c=t.diagnostics.filter(r=>r.severity==="error"),a=t.diagnostics.slice(0,exports.MAX_DIAGNOSTICS_PER_RUN),p=[];if(!t.toolError){p.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:{...u,kind:"typecheck-run",phase:"start"}});for(const r of a)p.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:{...u,kind:"typecheck-diagnostic",code:r.code}})}const d=t.toolError?"error":c.length>0?"failing":"clean";return p.push({...l,id:n(),timestamp:e,severity:"info",title:`typecheck run: ${t.project} \u2014 ${t.toolError?"tool error":`${c.length} error${c.length===1?"":"s"}`} (${t.durationMs}ms)`,...t.toolError?{message:t.toolError}:{},fingerprint:`tsc:${t.project}:run-end`,raw:{...u,kind:"typecheck-run",phase:"end",status:d,durationMs:t.durationMs,errorCount:c.length,warningCount:t.diagnostics.length-c.length,...t.diagnostics.length>a.length?{truncatedDiagnostics:t.diagnostics.length-a.length}:{},...t.toolError?{error:t.toolError}:{}}}),p}s(buildTypecheckRunEvents,"buildTypecheckRunEvents"),i(buildTypecheckRunEvents,"buildTypecheckRunEvents");function resolveEventFile(t){return process.env.LENSMCP_EVENT_FILE||path.join(t,".lensmcp","events.jsonl")}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)}s(ensureDir,"ensureDir"),i(ensureDir,"ensureDir");function appendTypecheckEvents(t,e){if(e.length===0)return;const n=e.map(o=>JSON.stringify(o)).join(`
3
3
  `)+`
4
- `;try{ensureDir(e),busHygiene?.maybeRotateEventFile(e,t.length),fs.appendFileSync(e,t)}catch(o){if(o?.code==="ENOENT"){try{ensuredDir=null,ensureDir(e),fs.appendFileSync(e,t)}catch{}return}}}c(appendTypecheckEvents,"appendTypecheckEvents"),s(appendTypecheckEvents,"appendTypecheckEvents"),i(appendTypecheckEvents,"appendTypecheckEvents");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}c(publishTypecheckRun,"publishTypecheckRun"),s(publishTypecheckRun,"publishTypecheckRun"),i(publishTypecheckRun,"publishTypecheckRun");
4
+ `;try{ensureDir(t),busHygiene?.maybeRotateEventFile(t,n.length),fs.appendFileSync(t,n)}catch(o){if(o?.code==="ENOENT"){try{ensuredDir=null,ensureDir(t),fs.appendFileSync(t,n)}catch{}return}}}s(appendTypecheckEvents,"appendTypecheckEvents"),i(appendTypecheckEvents,"appendTypecheckEvents");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}s(publishTypecheckRun,"publishTypecheckRun"),i(publishTypecheckRun,"publishTypecheckRun");