@sailfish-ai/sf-veritas 0.2.4 → 0.2.6

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 (44) hide show
  1. package/README.md +120 -0
  2. package/dist/funcSpanTransformer-TjdooSrw.cjs +1 -0
  3. package/dist/funcSpanTransformer-sqmZLAcs.js +750 -0
  4. package/dist/plugins/funcspanEsbuildPlugin.cjs +1 -1
  5. package/dist/plugins/funcspanEsbuildPlugin.mjs +1 -1
  6. package/dist/plugins/funcspanRollupPlugin.cjs +1 -1
  7. package/dist/plugins/funcspanRollupPlugin.mjs +1 -1
  8. package/dist/plugins/funcspanTscPlugin.cjs +1 -1
  9. package/dist/plugins/funcspanTscPlugin.mjs +1 -1
  10. package/dist/plugins/funcspanVitePlugin.cjs +1 -1
  11. package/dist/plugins/funcspanVitePlugin.mjs +1 -1
  12. package/dist/plugins/funcspanWebpackLoader.cjs +1 -1
  13. package/dist/plugins/funcspanWebpackLoader.mjs +65 -8
  14. package/dist/plugins/funcspanWebpackPlugin.cjs +1 -1
  15. package/dist/plugins/funcspanWebpackPlugin.mjs +24 -24
  16. package/dist/runtime/register.cjs +1 -0
  17. package/dist/runtime/register.mjs +27 -0
  18. package/dist/sf-veritas.cjs +16 -52
  19. package/dist/sf-veritas.mjs +573 -811
  20. package/dist/types/functionSpanTransmitter.d.ts +15 -1
  21. package/dist/types/index.d.ts +2 -0
  22. package/dist/types/patches/workerPool/argumentCapture.d.ts +47 -0
  23. package/dist/types/patches/workerPool/index.d.ts +19 -0
  24. package/dist/types/patches/workerPool/patchCrypto.d.ts +9 -0
  25. package/dist/types/patches/workerPool/patchDns.d.ts +10 -0
  26. package/dist/types/patches/workerPool/patchFs.d.ts +9 -0
  27. package/dist/types/patches/workerPool/patchZlib.d.ts +9 -0
  28. package/dist/types/patches/workerPool/workerPoolTypes.d.ts +70 -0
  29. package/dist/types/plugins/funcspanWebpackPlugin.d.ts +20 -0
  30. package/dist/types/plugins/workerPoolTransformer.d.ts +42 -0
  31. package/dist/types/requestUtils.d.ts +1 -0
  32. package/dist/types/runtime/register.d.ts +56 -0
  33. package/dist/types/worker-pool-capture.d.ts +9 -0
  34. package/dist/types/workerPoolConfig.d.ts +22 -0
  35. package/dist/types/workerPoolSpanCapture.d.ts +36 -0
  36. package/dist/worker-pool-capture.cjs +1 -0
  37. package/dist/worker-pool-capture.mjs +4 -0
  38. package/dist/workerPoolSpanCapture-BOnYC4s3.js +705 -0
  39. package/dist/workerPoolSpanCapture-CNEouInA.cjs +83 -0
  40. package/package.json +17 -1
  41. package/dist/funcSpanTransformer-CTddGtUV.cjs +0 -1
  42. package/dist/funcSpanTransformer-coYDqcrs.js +0 -136
  43. package/dist/source-map-Cr6YkjTd.js +0 -631
  44. package/dist/source-map-rHHEdpre.cjs +0 -1
package/README.md CHANGED
@@ -85,6 +85,126 @@ setupInterceptors({
85
85
  });
86
86
  ```
87
87
 
88
+ ### Runtime Hooks for Local Development
89
+
90
+ For local development and debugging without a build step, `sf-veritas` provides runtime hooks that automatically instrument your code on-the-fly.
91
+
92
+ **⚠️ Important**: Runtime hooks are intended for **development only**. For production, use the build plugins (webpack, vite, rollup, esbuild, or tsc) which provide better performance.
93
+
94
+ #### Node 20+ with ESM Loader (Recommended)
95
+
96
+ Use the `--import` flag with the loader registration:
97
+
98
+ ```bash
99
+ # With Node.js directly
100
+ node --import @sailfish-ai/sf-veritas/runtime/register-loader app.js
101
+
102
+ # With tsx (TypeScript)
103
+ tsx --import @sailfish-ai/sf-veritas/runtime/register-loader app.ts
104
+
105
+ # In package.json scripts
106
+ {
107
+ "scripts": {
108
+ "dev": "node --import @sailfish-ai/sf-veritas/runtime/register-loader src/app.js"
109
+ }
110
+ }
111
+ ```
112
+
113
+ #### Configuration
114
+
115
+ Runtime hooks respect the same configuration as build plugins:
116
+
117
+ **Environment Variables:**
118
+ ```bash
119
+ SF_FUNCSPAN_CONSOLE_OUTPUT=true # Output function spans to console (for development)
120
+ SF_FUNCSPAN_JSONL_FILE=true # Write function spans to funcspans.jsonl (default)
121
+ SF_FUNCSPAN_JSONL_FILE=/path/to/spans.jsonl # Write function spans to custom JSONL file
122
+ SF_FUNCSPAN_SKIP_BACKEND=true # Skip sending spans to backend (for local-only)
123
+ SF_FUNCSPAN_DEBUG=true # Enable debug logging
124
+ SF_FUNCSPAN_SAMPLE_RATE=1.0 # Override sampling rate (0.0-1.0)
125
+ SF_FUNCSPAN_INCLUDE_NODE_MODULES=express,axios # Instrument specific packages
126
+ ```
127
+
128
+ **Console Output Example:**
129
+
130
+ When `SF_FUNCSPAN_CONSOLE_OUTPUT=true` is set, you'll see clean output like:
131
+
132
+ ```
133
+ 📊 Function Span: {
134
+ function: 'add (src/utils.ts:10:0)',
135
+ duration: '0.05ms',
136
+ arguments: { a: 2, b: 3 },
137
+ result: 5,
138
+ spanId: 'a05a6dea-90ac-4c86-9d74-7815d8de87d2',
139
+ parentSpanId: 'none'
140
+ }
141
+ ```
142
+
143
+ **JSONL File Output:**
144
+
145
+ When `SF_FUNCSPAN_JSONL_FILE=/path/to/file.jsonl` is set, each function span is written as a JSON line:
146
+
147
+ ```json
148
+ {"timestamp":"2025-11-27T18:06:26.821Z","functionName":"add","filePath":"src/utils.ts","line":10,"column":0,"duration":0.05,"arguments":{"a":2,"b":3},"result":5,"spanId":"abc123","parentSpanId":"parent-id","async":false}
149
+ ```
150
+
151
+ This format is ideal for log processing tools and can be easily analyzed with `jq`:
152
+
153
+ ```bash
154
+ # Pretty print a span
155
+ cat spans.jsonl | head -1 | jq .
156
+
157
+ # Find slow functions
158
+ cat spans.jsonl | jq 'select(.duration > 100)'
159
+
160
+ # Group by function name
161
+ cat spans.jsonl | jq -s 'group_by(.functionName) | map({function: .[0].functionName, count: length})'
162
+ ```
163
+
164
+ **`.sailfish` Configuration Files:**
165
+
166
+ Create a `.sailfish` file in your project directory:
167
+
168
+ ```json
169
+ {
170
+ "default": {
171
+ "sample_rate": 1.0,
172
+ "capture_arguments": true,
173
+ "capture_return_value": true
174
+ }
175
+ }
176
+ ```
177
+
178
+ #### Programmatic API
179
+
180
+ You can also register hooks programmatically:
181
+
182
+ ```typescript
183
+ import { registerFuncspanRuntime } from '@sailfish-ai/sf-veritas/runtime/register';
184
+
185
+ // Must be called before importing any modules you want to instrument
186
+ registerFuncspanRuntime({
187
+ debug: true,
188
+ includeNodeModules: ['express'],
189
+ sampleRate: 1.0
190
+ });
191
+
192
+ // Now import your application code
193
+ import './app';
194
+ ```
195
+
196
+ #### Requirements
197
+
198
+ - Node.js 16.12+ (stable in Node 18+, recommended: Node 20+)
199
+ - For ESM loader: Node 20.6+ for full support
200
+
201
+ #### Limitations
202
+
203
+ - Runtime transformation adds ~20-50ms per module on first load
204
+ - Not recommended for production use
205
+ - Cannot transform `eval()` or `vm.runInContext()` code
206
+ - May conflict with other custom loaders
207
+
88
208
  ### Features
89
209
 
90
210
  #### Identify Users
@@ -0,0 +1 @@
1
+ "use strict";const ce=require("@babel/parser"),z=require("@babel/traverse"),J=require("@babel/generator"),pe=require("@babel/types"),R=require("path"),ge=require("fs");function de(a){const p=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const m in a)if(m!=="default"){const _=Object.getOwnPropertyDescriptor(a,m);Object.defineProperty(p,m,_.get?_:{enumerable:!0,get:()=>a[m]})}}return p.default=a,Object.freeze(p)}const l=de(pe);var V,Q,I={},G={},$={},N={};function fe(){if(V)return N;V=1;var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");return N.encode=function(p){if(0<=p&&p<a.length)return a[p];throw new TypeError("Must be between 0 and 63: "+p)},N.decode=function(p){return 65<=p&&p<=90?p-65:97<=p&&p<=122?p-97+26:48<=p&&p<=57?p-48+52:p==43?62:p==47?63:-1},N}function ue(){if(Q)return $;Q=1;var a=fe();return $.encode=function(p){var m,_="",g=(function(t){return t<0?1+(-t<<1):0+(t<<1)})(p);do m=31&g,(g>>>=5)>0&&(m|=32),_+=a.encode(m);while(g>0);return _},$.decode=function(p,m,_){var g,t,o,c,d=p.length,h=0,v=0;do{if(m>=d)throw new Error("Expected more digits in base 64 VLQ value.");if((t=a.decode(p.charCodeAt(m++)))===-1)throw new Error("Invalid base64 digit: "+p.charAt(m-1));g=!!(32&t),h+=(t&=31)<<v,v+=5}while(g);_.value=(c=(o=h)>>1,1&~o?c:-c),_.rest=m},$}var H,K={};function j(){return H||(H=1,(function(a){a.getArg=function(n,e,i){if(e in n)return n[e];if(arguments.length===3)return i;throw new Error('"'+e+'" is a required argument.')};var p=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,m=/^data:.+\,.+$/;function _(n){var e=n.match(p);return e?{scheme:e[1],auth:e[2],host:e[3],port:e[4],path:e[5]}:null}function g(n){var e="";return n.scheme&&(e+=n.scheme+":"),e+="//",n.auth&&(e+=n.auth+"@"),n.host&&(e+=n.host),n.port&&(e+=":"+n.port),n.path&&(e+=n.path),e}a.urlParse=_,a.urlGenerate=g;var t,o,c=(t=function(n){var e=n,i=_(n);if(i){if(!i.path)return n;e=i.path}for(var r=a.isAbsolute(e),f=[],y=0,C=0;;){if(y=C,(C=e.indexOf("/",y))===-1){f.push(e.slice(y));break}for(f.push(e.slice(y,C));C<e.length&&e[C]==="/";)C++}var L,S=0;for(C=f.length-1;C>=0;C--)(L=f[C])==="."?f.splice(C,1):L===".."?S++:S>0&&(L===""?(f.splice(C+1,S),S=0):(f.splice(C,2),S--));return(e=f.join("/"))===""&&(e=r?"/":"."),i?(i.path=e,g(i)):e},o=[],function(n){for(var e=0;e<o.length;e++)if(o[e].input===n){var i=o[0];return o[0]=o[e],o[e]=i,o[0].result}var r=t(n);return o.unshift({input:n,result:r}),o.length>32&&o.pop(),r});function d(n,e){n===""&&(n="."),e===""&&(e=".");var i=_(e),r=_(n);if(r&&(n=r.path||"/"),i&&!i.scheme)return r&&(i.scheme=r.scheme),g(i);if(i||e.match(m))return e;if(r&&!r.host&&!r.path)return r.host=e,g(r);var f=e.charAt(0)==="/"?e:c(n.replace(/\/+$/,"")+"/"+e);return r?(r.path=f,g(r)):f}a.normalize=c,a.join=d,a.isAbsolute=function(n){return n.charAt(0)==="/"||p.test(n)},a.relative=function(n,e){n===""&&(n="."),n=n.replace(/\/$/,"");for(var i=0;e.indexOf(n+"/")!==0;){var r=n.lastIndexOf("/");if(r<0||(n=n.slice(0,r)).match(/^([^\/]+:\/)?\/*$/))return e;++i}return Array(i+1).join("../")+e.substr(n.length+1)};var h=!("__proto__"in Object.create(null));function v(n){return n}function s(n){if(!n)return!1;var e=n.length;if(e<9||n.charCodeAt(e-1)!==95||n.charCodeAt(e-2)!==95||n.charCodeAt(e-3)!==111||n.charCodeAt(e-4)!==116||n.charCodeAt(e-5)!==111||n.charCodeAt(e-6)!==114||n.charCodeAt(e-7)!==112||n.charCodeAt(e-8)!==95||n.charCodeAt(e-9)!==95)return!1;for(var i=e-10;i>=0;i--)if(n.charCodeAt(i)!==36)return!1;return!0}function u(n,e){return n===e?0:n===null?1:e===null?-1:n>e?1:-1}a.toSetString=h?v:function(n){return s(n)?"$"+n:n},a.fromSetString=h?v:function(n){return s(n)?n.slice(1):n},a.compareByOriginalPositions=function(n,e,i){var r=u(n.source,e.source);return r!==0||(r=n.originalLine-e.originalLine)!==0||(r=n.originalColumn-e.originalColumn)!==0||i||(r=n.generatedColumn-e.generatedColumn)!==0||(r=n.generatedLine-e.generatedLine)!==0?r:u(n.name,e.name)},a.compareByOriginalPositionsNoSource=function(n,e,i){var r;return(r=n.originalLine-e.originalLine)!==0||(r=n.originalColumn-e.originalColumn)!==0||i||(r=n.generatedColumn-e.generatedColumn)!==0||(r=n.generatedLine-e.generatedLine)!==0?r:u(n.name,e.name)},a.compareByGeneratedPositionsDeflated=function(n,e,i){var r=n.generatedLine-e.generatedLine;return r!==0||(r=n.generatedColumn-e.generatedColumn)!==0||i||(r=u(n.source,e.source))!==0||(r=n.originalLine-e.originalLine)!==0||(r=n.originalColumn-e.originalColumn)!==0?r:u(n.name,e.name)},a.compareByGeneratedPositionsDeflatedNoLine=function(n,e,i){var r=n.generatedColumn-e.generatedColumn;return r!==0||i||(r=u(n.source,e.source))!==0||(r=n.originalLine-e.originalLine)!==0||(r=n.originalColumn-e.originalColumn)!==0?r:u(n.name,e.name)},a.compareByGeneratedPositionsInflated=function(n,e){var i=n.generatedLine-e.generatedLine;return i!==0||(i=n.generatedColumn-e.generatedColumn)!==0||(i=u(n.source,e.source))!==0||(i=n.originalLine-e.originalLine)!==0||(i=n.originalColumn-e.originalColumn)!==0?i:u(n.name,e.name)},a.parseSourceMapInput=function(n){return JSON.parse(n.replace(/^\)]}'[^\n]*\n/,""))},a.computeSourceURL=function(n,e,i){if(e=e||"",n&&(n[n.length-1]!=="/"&&e[0]!=="/"&&(n+="/"),e=n+e),i){var r=_(i);if(!r)throw new Error("sourceMapURL could not be parsed");if(r.path){var f=r.path.lastIndexOf("/");f>=0&&(r.path=r.path.substring(0,f+1))}e=d(g(r),e)}return c(e)}})(K)),K}var X,D={};function le(){if(X)return D;X=1;var a=j(),p=Object.prototype.hasOwnProperty,m=typeof Map<"u";function _(){this._array=[],this._set=m?new Map:Object.create(null)}return _.fromArray=function(g,t){for(var o=new _,c=0,d=g.length;c<d;c++)o.add(g[c],t);return o},_.prototype.size=function(){return m?this._set.size:Object.getOwnPropertyNames(this._set).length},_.prototype.add=function(g,t){var o=m?g:a.toSetString(g),c=m?this.has(g):p.call(this._set,o),d=this._array.length;c&&!t||this._array.push(g),c||(m?this._set.set(g,d):this._set[o]=d)},_.prototype.has=function(g){if(m)return this._set.has(g);var t=a.toSetString(g);return p.call(this._set,t)},_.prototype.indexOf=function(g){if(m){var t=this._set.get(g);if(t>=0)return t}else{var o=a.toSetString(g);if(p.call(this._set,o))return this._set[o]}throw new Error('"'+g+'" is not in the set.')},_.prototype.at=function(g){if(g>=0&&g<this._array.length)return this._array[g];throw new Error("No element indexed by "+g)},_.prototype.toArray=function(){return this._array.slice()},D.ArraySet=_,D}var Y,Z,U={};function he(){if(Y)return U;Y=1;var a=j();function p(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}return p.prototype.unsortedForEach=function(m,_){this._array.forEach(m,_)},p.prototype.add=function(m){var _,g,t,o,c,d;_=this._last,g=m,t=_.generatedLine,o=g.generatedLine,c=_.generatedColumn,d=g.generatedColumn,o>t||o==t&&d>=c||a.compareByGeneratedPositionsInflated(_,g)<=0?(this._last=m,this._array.push(m)):(this._sorted=!1,this._array.push(m))},p.prototype.toArray=function(){return this._sorted||(this._array.sort(a.compareByGeneratedPositionsInflated),this._sorted=!0),this._array},U.MappingList=p,U}function ee(){if(Z)return G;Z=1;var a=ue(),p=j(),m=le().ArraySet,_=he().MappingList;function g(t){t||(t={}),this._file=p.getArg(t,"file",null),this._sourceRoot=p.getArg(t,"sourceRoot",null),this._skipValidation=p.getArg(t,"skipValidation",!1),this._ignoreInvalidMapping=p.getArg(t,"ignoreInvalidMapping",!1),this._sources=new m,this._names=new m,this._mappings=new _,this._sourcesContents=null}return g.prototype._version=3,g.fromSourceMap=function(t,o){var c=t.sourceRoot,d=new g(Object.assign(o||{},{file:t.file,sourceRoot:c}));return t.eachMapping(function(h){var v={generated:{line:h.generatedLine,column:h.generatedColumn}};h.source!=null&&(v.source=h.source,c!=null&&(v.source=p.relative(c,v.source)),v.original={line:h.originalLine,column:h.originalColumn},h.name!=null&&(v.name=h.name)),d.addMapping(v)}),t.sources.forEach(function(h){var v=h;c!==null&&(v=p.relative(c,h)),d._sources.has(v)||d._sources.add(v);var s=t.sourceContentFor(h);s!=null&&d.setSourceContent(h,s)}),d},g.prototype.addMapping=function(t){var o=p.getArg(t,"generated"),c=p.getArg(t,"original",null),d=p.getArg(t,"source",null),h=p.getArg(t,"name",null);(this._skipValidation||this._validateMapping(o,c,d,h)!==!1)&&(d!=null&&(d=String(d),this._sources.has(d)||this._sources.add(d)),h!=null&&(h=String(h),this._names.has(h)||this._names.add(h)),this._mappings.add({generatedLine:o.line,generatedColumn:o.column,originalLine:c!=null&&c.line,originalColumn:c!=null&&c.column,source:d,name:h}))},g.prototype.setSourceContent=function(t,o){var c=t;this._sourceRoot!=null&&(c=p.relative(this._sourceRoot,c)),o!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[p.toSetString(c)]=o):this._sourcesContents&&(delete this._sourcesContents[p.toSetString(c)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))},g.prototype.applySourceMap=function(t,o,c){var d=o;if(o==null){if(t.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);d=t.file}var h=this._sourceRoot;h!=null&&(d=p.relative(h,d));var v=new m,s=new m;this._mappings.unsortedForEach(function(u){if(u.source===d&&u.originalLine!=null){var n=t.originalPositionFor({line:u.originalLine,column:u.originalColumn});n.source!=null&&(u.source=n.source,c!=null&&(u.source=p.join(c,u.source)),h!=null&&(u.source=p.relative(h,u.source)),u.originalLine=n.line,u.originalColumn=n.column,n.name!=null&&(u.name=n.name))}var e=u.source;e==null||v.has(e)||v.add(e);var i=u.name;i==null||s.has(i)||s.add(i)},this),this._sources=v,this._names=s,t.sources.forEach(function(u){var n=t.sourceContentFor(u);n!=null&&(c!=null&&(u=p.join(c,u)),h!=null&&(u=p.relative(h,u)),this.setSourceContent(u,n))},this)},g.prototype._validateMapping=function(t,o,c,d){if(o&&typeof o.line!="number"&&typeof o.column!="number"){var h="original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.";if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(h),!1;throw new Error(h)}if((!(t&&"line"in t&&"column"in t&&t.line>0&&t.column>=0)||o||c||d)&&!(t&&"line"in t&&"column"in t&&o&&"line"in o&&"column"in o&&t.line>0&&t.column>=0&&o.line>0&&o.column>=0&&c)){if(h="Invalid mapping: "+JSON.stringify({generated:t,source:c,original:o,name:d}),this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(h),!1;throw new Error(h)}},g.prototype._serializeMappings=function(){for(var t,o,c,d,h=0,v=1,s=0,u=0,n=0,e=0,i="",r=this._mappings.toArray(),f=0,y=r.length;f<y;f++){if(t="",(o=r[f]).generatedLine!==v)for(h=0;o.generatedLine!==v;)t+=";",v++;else if(f>0){if(!p.compareByGeneratedPositionsInflated(o,r[f-1]))continue;t+=","}t+=a.encode(o.generatedColumn-h),h=o.generatedColumn,o.source!=null&&(d=this._sources.indexOf(o.source),t+=a.encode(d-e),e=d,t+=a.encode(o.originalLine-1-u),u=o.originalLine-1,t+=a.encode(o.originalColumn-s),s=o.originalColumn,o.name!=null&&(c=this._names.indexOf(o.name),t+=a.encode(c-n),n=c)),i+=t}return i},g.prototype._generateSourcesContent=function(t,o){return t.map(function(c){if(!this._sourcesContents)return null;o!=null&&(c=p.relative(o,c));var d=p.toSetString(c);return Object.prototype.hasOwnProperty.call(this._sourcesContents,d)?this._sourcesContents[d]:null},this)},g.prototype.toJSON=function(){var t={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(t.file=this._file),this._sourceRoot!=null&&(t.sourceRoot=this._sourceRoot),this._sourcesContents&&(t.sourcesContent=this._generateSourcesContent(t.sources,t.sourceRoot)),t},g.prototype.toString=function(){return JSON.stringify(this.toJSON())},G.SourceMapGenerator=g,G}var ne,P={},re={};function me(){return ne||(ne=1,(function(a){function p(m,_,g,t,o,c){var d=Math.floor((_-m)/2)+m,h=o(g,t[d],!0);return h===0?d:h>0?_-d>1?p(d,_,g,t,o,c):c==a.LEAST_UPPER_BOUND?_<t.length?_:-1:d:d-m>1?p(m,d,g,t,o,c):c==a.LEAST_UPPER_BOUND?d:m<0?-1:m}a.GREATEST_LOWER_BOUND=1,a.LEAST_UPPER_BOUND=2,a.search=function(m,_,g,t){if(_.length===0)return-1;var o=p(-1,_.length,m,_,g,t||a.GREATEST_LOWER_BOUND);if(o<0)return-1;for(;o-1>=0&&g(_[o],_[o-1],!0)===0;)--o;return o}})(re)),re}var te,oe,B={};function _e(){if(te)return B;function a(m){function _(g,t,o){var c=g[t];g[t]=g[o],g[o]=c}return function g(t,o,c,d){if(c<d){var h=c-1;_(t,(n=c,e=d,Math.round(n+Math.random()*(e-n))),d);for(var v=t[d],s=c;s<d;s++)o(t[s],v,!1)<=0&&_(t,h+=1,s);_(t,h+1,s);var u=h+1;g(t,o,c,u-1),g(t,o,u+1,d)}var n,e}}te=1;let p=new WeakMap;return B.quickSort=function(m,_,g=0){let t=p.get(_);t===void 0&&(t=(function(o){let c=a.toString();return new Function(`return ${c}`)()(o)})(_),p.set(_,t)),t(m,_,g,m.length-1)},B}var ie,se,W={},ae=(se||(se=1,I.SourceMapGenerator=ee().SourceMapGenerator,I.SourceMapConsumer=(function(){if(oe)return P;oe=1;var a=j(),p=me(),m=le().ArraySet,_=ue(),g=_e().quickSort;function t(s,u){var n=s;return typeof s=="string"&&(n=a.parseSourceMapInput(s)),n.sections!=null?new v(n,u):new o(n,u)}function o(s,u){var n=s;typeof s=="string"&&(n=a.parseSourceMapInput(s));var e=a.getArg(n,"version"),i=a.getArg(n,"sources"),r=a.getArg(n,"names",[]),f=a.getArg(n,"sourceRoot",null),y=a.getArg(n,"sourcesContent",null),C=a.getArg(n,"mappings"),L=a.getArg(n,"file",null);if(e!=this._version)throw new Error("Unsupported version: "+e);f&&(f=a.normalize(f)),i=i.map(String).map(a.normalize).map(function(S){return f&&a.isAbsolute(f)&&a.isAbsolute(S)?a.relative(f,S):S}),this._names=m.fromArray(r.map(String),!0),this._sources=m.fromArray(i,!0),this._absoluteSources=this._sources.toArray().map(function(S){return a.computeSourceURL(f,S,u)}),this.sourceRoot=f,this.sourcesContent=y,this._mappings=C,this._sourceMapURL=u,this.file=L}function c(){this.generatedLine=0,this.generatedColumn=0,this.source=null,this.originalLine=null,this.originalColumn=null,this.name=null}t.fromSourceMap=function(s,u){return o.fromSourceMap(s,u)},t.prototype._version=3,t.prototype.__generatedMappings=null,Object.defineProperty(t.prototype,"_generatedMappings",{configurable:!0,enumerable:!0,get:function(){return this.__generatedMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__generatedMappings}}),t.prototype.__originalMappings=null,Object.defineProperty(t.prototype,"_originalMappings",{configurable:!0,enumerable:!0,get:function(){return this.__originalMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__originalMappings}}),t.prototype._charIsMappingSeparator=function(s,u){var n=s.charAt(u);return n===";"||n===","},t.prototype._parseMappings=function(s,u){throw new Error("Subclasses must implement _parseMappings")},t.GENERATED_ORDER=1,t.ORIGINAL_ORDER=2,t.GREATEST_LOWER_BOUND=1,t.LEAST_UPPER_BOUND=2,t.prototype.eachMapping=function(s,u,n){var e,i=u||null;switch(n||t.GENERATED_ORDER){case t.GENERATED_ORDER:e=this._generatedMappings;break;case t.ORIGINAL_ORDER:e=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}for(var r=this.sourceRoot,f=s.bind(i),y=this._names,C=this._sources,L=this._sourceMapURL,S=0,A=e.length;S<A;S++){var b=e[S],M=b.source===null?null:C.at(b.source);M!==null&&(M=a.computeSourceURL(r,M,L)),f({source:M,generatedLine:b.generatedLine,generatedColumn:b.generatedColumn,originalLine:b.originalLine,originalColumn:b.originalColumn,name:b.name===null?null:y.at(b.name)})}},t.prototype.allGeneratedPositionsFor=function(s){var u=a.getArg(s,"line"),n={source:a.getArg(s,"source"),originalLine:u,originalColumn:a.getArg(s,"column",0)};if(n.source=this._findSourceIndex(n.source),n.source<0)return[];var e=[],i=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",a.compareByOriginalPositions,p.LEAST_UPPER_BOUND);if(i>=0){var r=this._originalMappings[i];if(s.column===void 0)for(var f=r.originalLine;r&&r.originalLine===f;)e.push({line:a.getArg(r,"generatedLine",null),column:a.getArg(r,"generatedColumn",null),lastColumn:a.getArg(r,"lastGeneratedColumn",null)}),r=this._originalMappings[++i];else for(var y=r.originalColumn;r&&r.originalLine===u&&r.originalColumn==y;)e.push({line:a.getArg(r,"generatedLine",null),column:a.getArg(r,"generatedColumn",null),lastColumn:a.getArg(r,"lastGeneratedColumn",null)}),r=this._originalMappings[++i]}return e},P.SourceMapConsumer=t,o.prototype=Object.create(t.prototype),o.prototype.consumer=t,o.prototype._findSourceIndex=function(s){var u,n=s;if(this.sourceRoot!=null&&(n=a.relative(this.sourceRoot,n)),this._sources.has(n))return this._sources.indexOf(n);for(u=0;u<this._absoluteSources.length;++u)if(this._absoluteSources[u]==s)return u;return-1},o.fromSourceMap=function(s,u){var n=Object.create(o.prototype),e=n._names=m.fromArray(s._names.toArray(),!0),i=n._sources=m.fromArray(s._sources.toArray(),!0);n.sourceRoot=s._sourceRoot,n.sourcesContent=s._generateSourcesContent(n._sources.toArray(),n.sourceRoot),n.file=s._file,n._sourceMapURL=u,n._absoluteSources=n._sources.toArray().map(function(b){return a.computeSourceURL(n.sourceRoot,b,u)});for(var r=s._mappings.toArray().slice(),f=n.__generatedMappings=[],y=n.__originalMappings=[],C=0,L=r.length;C<L;C++){var S=r[C],A=new c;A.generatedLine=S.generatedLine,A.generatedColumn=S.generatedColumn,S.source&&(A.source=i.indexOf(S.source),A.originalLine=S.originalLine,A.originalColumn=S.originalColumn,S.name&&(A.name=e.indexOf(S.name)),y.push(A)),f.push(A)}return g(n.__originalMappings,a.compareByOriginalPositions),n},o.prototype._version=3,Object.defineProperty(o.prototype,"sources",{get:function(){return this._absoluteSources.slice()}});const d=a.compareByGeneratedPositionsDeflatedNoLine;function h(s,u){let n=s.length,e=s.length-u;if(!(e<=1))if(e==2){let i=s[u],r=s[u+1];d(i,r)>0&&(s[u]=r,s[u+1]=i)}else if(e<20)for(let i=u;i<n;i++)for(let r=i;r>u;r--){let f=s[r-1],y=s[r];if(d(f,y)<=0)break;s[r-1]=y,s[r]=f}else g(s,d,u)}function v(s,u){var n=s;typeof s=="string"&&(n=a.parseSourceMapInput(s));var e=a.getArg(n,"version"),i=a.getArg(n,"sections");if(e!=this._version)throw new Error("Unsupported version: "+e);this._sources=new m,this._names=new m;var r={line:-1,column:0};this._sections=i.map(function(f){if(f.url)throw new Error("Support for url field in sections not implemented.");var y=a.getArg(f,"offset"),C=a.getArg(y,"line"),L=a.getArg(y,"column");if(C<r.line||C===r.line&&L<r.column)throw new Error("Section offsets must be ordered and non-overlapping.");return r=y,{generatedOffset:{generatedLine:C+1,generatedColumn:L+1},consumer:new t(a.getArg(f,"map"),u)}})}return o.prototype._parseMappings=function(s,u){var n,e,i,r,f=1,y=0,C=0,L=0,S=0,A=0,b=s.length,M=0,w={},E=[],O=[];let T=0;for(;M<b;)if(s.charAt(M)===";")f++,M++,y=0,h(O,T),T=O.length;else if(s.charAt(M)===",")M++;else{for((n=new c).generatedLine=f,i=M;i<b&&!this._charIsMappingSeparator(s,i);i++);for(s.slice(M,i),e=[];M<i;)_.decode(s,M,w),r=w.value,M=w.rest,e.push(r);if(e.length===2)throw new Error("Found a source, but no line and column");if(e.length===3)throw new Error("Found a source and line, but no column");if(n.generatedColumn=y+e[0],y=n.generatedColumn,e.length>1&&(n.source=S+e[1],S+=e[1],n.originalLine=C+e[2],C=n.originalLine,n.originalLine+=1,n.originalColumn=L+e[3],L=n.originalColumn,e.length>4&&(n.name=A+e[4],A+=e[4])),O.push(n),typeof n.originalLine=="number"){let F=n.source;for(;E.length<=F;)E.push(null);E[F]===null&&(E[F]=[]),E[F].push(n)}}h(O,T),this.__generatedMappings=O;for(var x=0;x<E.length;x++)E[x]!=null&&g(E[x],a.compareByOriginalPositionsNoSource);this.__originalMappings=[].concat(...E)},o.prototype._findMapping=function(s,u,n,e,i,r){if(s[n]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+s[n]);if(s[e]<0)throw new TypeError("Column must be greater than or equal to 0, got "+s[e]);return p.search(s,u,i,r)},o.prototype.computeColumnSpans=function(){for(var s=0;s<this._generatedMappings.length;++s){var u=this._generatedMappings[s];if(s+1<this._generatedMappings.length){var n=this._generatedMappings[s+1];if(u.generatedLine===n.generatedLine){u.lastGeneratedColumn=n.generatedColumn-1;continue}}u.lastGeneratedColumn=1/0}},o.prototype.originalPositionFor=function(s){var u={generatedLine:a.getArg(s,"line"),generatedColumn:a.getArg(s,"column")},n=this._findMapping(u,this._generatedMappings,"generatedLine","generatedColumn",a.compareByGeneratedPositionsDeflated,a.getArg(s,"bias",t.GREATEST_LOWER_BOUND));if(n>=0){var e=this._generatedMappings[n];if(e.generatedLine===u.generatedLine){var i=a.getArg(e,"source",null);i!==null&&(i=this._sources.at(i),i=a.computeSourceURL(this.sourceRoot,i,this._sourceMapURL));var r=a.getArg(e,"name",null);return r!==null&&(r=this._names.at(r)),{source:i,line:a.getArg(e,"originalLine",null),column:a.getArg(e,"originalColumn",null),name:r}}}return{source:null,line:null,column:null,name:null}},o.prototype.hasContentsOfAllSources=function(){return!!this.sourcesContent&&this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some(function(s){return s==null})},o.prototype.sourceContentFor=function(s,u){if(!this.sourcesContent)return null;var n=this._findSourceIndex(s);if(n>=0)return this.sourcesContent[n];var e,i=s;if(this.sourceRoot!=null&&(i=a.relative(this.sourceRoot,i)),this.sourceRoot!=null&&(e=a.urlParse(this.sourceRoot))){var r=i.replace(/^file:\/\//,"");if(e.scheme=="file"&&this._sources.has(r))return this.sourcesContent[this._sources.indexOf(r)];if((!e.path||e.path=="/")&&this._sources.has("/"+i))return this.sourcesContent[this._sources.indexOf("/"+i)]}if(u)return null;throw new Error('"'+i+'" is not in the SourceMap.')},o.prototype.generatedPositionFor=function(s){var u=a.getArg(s,"source");if((u=this._findSourceIndex(u))<0)return{line:null,column:null,lastColumn:null};var n={source:u,originalLine:a.getArg(s,"line"),originalColumn:a.getArg(s,"column")},e=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",a.compareByOriginalPositions,a.getArg(s,"bias",t.GREATEST_LOWER_BOUND));if(e>=0){var i=this._originalMappings[e];if(i.source===n.source)return{line:a.getArg(i,"generatedLine",null),column:a.getArg(i,"generatedColumn",null),lastColumn:a.getArg(i,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}},P.BasicSourceMapConsumer=o,v.prototype=Object.create(t.prototype),v.prototype.constructor=t,v.prototype._version=3,Object.defineProperty(v.prototype,"sources",{get:function(){for(var s=[],u=0;u<this._sections.length;u++)for(var n=0;n<this._sections[u].consumer.sources.length;n++)s.push(this._sections[u].consumer.sources[n]);return s}}),v.prototype.originalPositionFor=function(s){var u={generatedLine:a.getArg(s,"line"),generatedColumn:a.getArg(s,"column")},n=p.search(u,this._sections,function(i,r){return i.generatedLine-r.generatedOffset.generatedLine||i.generatedColumn-r.generatedOffset.generatedColumn}),e=this._sections[n];return e?e.consumer.originalPositionFor({line:u.generatedLine-(e.generatedOffset.generatedLine-1),column:u.generatedColumn-(e.generatedOffset.generatedLine===u.generatedLine?e.generatedOffset.generatedColumn-1:0),bias:s.bias}):{source:null,line:null,column:null,name:null}},v.prototype.hasContentsOfAllSources=function(){return this._sections.every(function(s){return s.consumer.hasContentsOfAllSources()})},v.prototype.sourceContentFor=function(s,u){for(var n=0;n<this._sections.length;n++){var e=this._sections[n].consumer.sourceContentFor(s,!0);if(e||e==="")return e}if(u)return null;throw new Error('"'+s+'" is not in the SourceMap.')},v.prototype.generatedPositionFor=function(s){for(var u=0;u<this._sections.length;u++){var n=this._sections[u];if(n.consumer._findSourceIndex(a.getArg(s,"source"))!==-1){var e=n.consumer.generatedPositionFor(s);if(e)return{line:e.line+(n.generatedOffset.generatedLine-1),column:e.column+(n.generatedOffset.generatedLine===e.line?n.generatedOffset.generatedColumn-1:0)}}}return{line:null,column:null}},v.prototype._parseMappings=function(s,u){this.__generatedMappings=[],this.__originalMappings=[];for(var n=0;n<this._sections.length;n++)for(var e=this._sections[n],i=e.consumer._generatedMappings,r=0;r<i.length;r++){var f=i[r],y=e.consumer._sources.at(f.source);y!==null&&(y=a.computeSourceURL(e.consumer.sourceRoot,y,this._sourceMapURL)),this._sources.add(y),y=this._sources.indexOf(y);var C=null;f.name&&(C=e.consumer._names.at(f.name),this._names.add(C),C=this._names.indexOf(C));var L={source:y,generatedLine:f.generatedLine+(e.generatedOffset.generatedLine-1),generatedColumn:f.generatedColumn+(e.generatedOffset.generatedLine===f.generatedLine?e.generatedOffset.generatedColumn-1:0),originalLine:f.originalLine,originalColumn:f.originalColumn,name:C};this.__generatedMappings.push(L),typeof L.originalLine=="number"&&this.__originalMappings.push(L)}g(this.__generatedMappings,a.compareByGeneratedPositionsDeflated),g(this.__originalMappings,a.compareByOriginalPositions)},P.IndexedSourceMapConsumer=v,P})().SourceMapConsumer,I.SourceNode=(function(){if(ie)return W;ie=1;var a=ee().SourceMapGenerator,p=j(),m=/(\r?\n)/,_="$$$isSourceNode$$$";function g(t,o,c,d,h){this.children=[],this.sourceContents={},this.line=t??null,this.column=o??null,this.source=c??null,this.name=h??null,this[_]=!0,d!=null&&this.add(d)}return g.fromStringWithSourceMap=function(t,o,c){var d=new g,h=t.split(m),v=0,s=function(){return r()+(r()||"");function r(){return v<h.length?h[v++]:void 0}},u=1,n=0,e=null;return o.eachMapping(function(r){if(e!==null){if(!(u<r.generatedLine)){var f=(y=h[v]||"").substr(0,r.generatedColumn-n);return h[v]=y.substr(r.generatedColumn-n),n=r.generatedColumn,i(e,f),void(e=r)}i(e,s()),u++,n=0}for(;u<r.generatedLine;)d.add(s()),u++;if(n<r.generatedColumn){var y=h[v]||"";d.add(y.substr(0,r.generatedColumn)),h[v]=y.substr(r.generatedColumn),n=r.generatedColumn}e=r},this),v<h.length&&(e&&i(e,s()),d.add(h.splice(v).join(""))),o.sources.forEach(function(r){var f=o.sourceContentFor(r);f!=null&&(c!=null&&(r=p.join(c,r)),d.setSourceContent(r,f))}),d;function i(r,f){if(r===null||r.source===void 0)d.add(f);else{var y=c?p.join(c,r.source):r.source;d.add(new g(r.originalLine,r.originalColumn,y,f,r.name))}}},g.prototype.add=function(t){if(Array.isArray(t))t.forEach(function(o){this.add(o)},this);else{if(!t[_]&&typeof t!="string")throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+t);t&&this.children.push(t)}return this},g.prototype.prepend=function(t){if(Array.isArray(t))for(var o=t.length-1;o>=0;o--)this.prepend(t[o]);else{if(!t[_]&&typeof t!="string")throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+t);this.children.unshift(t)}return this},g.prototype.walk=function(t){for(var o,c=0,d=this.children.length;c<d;c++)(o=this.children[c])[_]?o.walk(t):o!==""&&t(o,{source:this.source,line:this.line,column:this.column,name:this.name})},g.prototype.join=function(t){var o,c,d=this.children.length;if(d>0){for(o=[],c=0;c<d-1;c++)o.push(this.children[c]),o.push(t);o.push(this.children[c]),this.children=o}return this},g.prototype.replaceRight=function(t,o){var c=this.children[this.children.length-1];return c[_]?c.replaceRight(t,o):typeof c=="string"?this.children[this.children.length-1]=c.replace(t,o):this.children.push("".replace(t,o)),this},g.prototype.setSourceContent=function(t,o){this.sourceContents[p.toSetString(t)]=o},g.prototype.walkSourceContents=function(t){for(var o=0,c=this.children.length;o<c;o++)this.children[o][_]&&this.children[o].walkSourceContents(t);var d=Object.keys(this.sourceContents);for(o=0,c=d.length;o<c;o++)t(p.fromSetString(d[o]),this.sourceContents[d[o]])},g.prototype.toString=function(){var t="";return this.walk(function(o){t+=o}),t},g.prototype.toStringWithSourceMap=function(t){var o={code:"",line:1,column:0},c=new a(t),d=!1,h=null,v=null,s=null,u=null;return this.walk(function(n,e){o.code+=n,e.source!==null&&e.line!==null&&e.column!==null?(h===e.source&&v===e.line&&s===e.column&&u===e.name||c.addMapping({source:e.source,original:{line:e.line,column:e.column},generated:{line:o.line,column:o.column},name:e.name}),h=e.source,v=e.line,s=e.column,u=e.name,d=!0):d&&(c.addMapping({generated:{line:o.line,column:o.column}}),h=null,d=!1);for(var i=0,r=n.length;i<r;i++)n.charCodeAt(i)===10?(o.line++,o.column=0,i+1===r?(h=null,d=!1):d&&c.addMapping({source:e.source,original:{line:e.line,column:e.column},generated:{line:o.line,column:o.column},name:e.name})):o.column++}),this.walkSourceContents(function(n,e){c.setSourceContent(n,e)}),{code:o.code,map:c}},W.SourceNode=g,W})().SourceNode),I);const q=z.default||z,ye=J.default||J;function k(a){const p=[];for(const m of a)l.isIdentifier(m)?p.push(m.name):l.isRestElement(m)&&l.isIdentifier(m.argument)?p.push(`...${m.argument.name}`):l.isAssignmentPattern(m)&&l.isIdentifier(m.left)?p.push(m.left.name):l.isObjectPattern(m)?p.push("{}"):l.isArrayPattern(m)?p.push("[]"):p.push("_");return p}exports.sourceMapExports=ae,exports.transformFunctionSpans=async function(a,p,m={}){const{projectRoot:_=process.cwd(),includeNodeModules:g=[],debug:t=!1}=m;if(p.includes("node_modules")&&!g.some(e=>p.includes(`node_modules/${e}`)))return{code:a,modified:!1,functionsWrapped:0};const o=R.relative(_,p).replace(/\\/g,"/");let c;t&&console.log(`[FuncSpan Transform] Processing: ${o}`);try{c=ce.parse(a,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy","classProperties","objectRestSpread","asyncGenerators","dynamicImport","optionalCatchBinding","optionalChaining","nullishCoalescingOperator"]})}catch(e){return t&&console.error(`[FuncSpan Transform] Parse error in ${o}:`,e),{code:a,modified:!1,functionsWrapped:0}}let d=null,h=null;try{const e=ge.readFileSync(`${p}.map`,"utf-8");d=await new ae.SourceMapConsumer(JSON.parse(e))}catch{}const v=(e,i)=>{if(d){const r=d.originalPositionFor({line:e,column:i});if(r.line!==null&&r.column!==null)return!h&&r.source&&(h=r.source),{line:r.line,column:r.column,source:r.source||void 0}}return{line:e,column:i}};let s=!1,u=0;const n=new Set;if(q(c,{FunctionDeclaration(e){const i=e.node.id?.name;if(!i)return;const r=`decl_${i}`;if(n.has(r))return;t&&console.log(`[FuncSpan Transform] Wrapping function declaration: ${i}`);const f=e.node.loc?.start.line??0,y=e.node.loc?.start.column??0,C=v(f,y),{line:L,column:S}=C;let A=p;C.source&&(A=R.resolve(R.dirname(p),C.source)),!t||L===f&&S===y||console.log(`[FuncSpan Transform] Mapped ${f}:${y} → ${L}:${S} in ${A}`);const b=k(e.node.params),M=l.callExpression(l.identifier("captureFunctionSpan"),[l.identifier(i),l.stringLiteral(i),l.stringLiteral(A),l.objectExpression([l.objectProperty(l.identifier("line"),l.numericLiteral(L)),l.objectProperty(l.identifier("column"),l.numericLiteral(S)),l.objectProperty(l.identifier("paramNames"),l.arrayExpression(b.map(E=>l.stringLiteral(E))))])]),w=l.expressionStatement(l.assignmentExpression("=",l.identifier(i),M));e.insertAfter(w),s=!0,u++,n.add(r)},VariableDeclarator(e){const i=e.node.id,r=e.node.init;if(!l.isIdentifier(i)||!r||!l.isFunctionExpression(r)&&!l.isArrowFunctionExpression(r))return;const f=i.name,y=`var_${f}`;if(n.has(y))return;t&&console.log(`[FuncSpan Transform] Wrapping variable function: ${f}`);const C=r.loc?.start.line??0,L=r.loc?.start.column??0,S=v(C,L),{line:A,column:b}=S;let M=p;S.source&&(M=R.resolve(R.dirname(p),S.source)),!t||A===C&&b===L||console.log(`[FuncSpan Transform] Mapped ${C}:${L} → ${A}:${b} in ${M}`);const w=k(r.params),E=l.callExpression(l.identifier("captureFunctionSpan"),[r,l.stringLiteral(f),l.stringLiteral(M),l.objectExpression([l.objectProperty(l.identifier("line"),l.numericLiteral(A)),l.objectProperty(l.identifier("column"),l.numericLiteral(b)),l.objectProperty(l.identifier("paramNames"),l.arrayExpression(w.map(O=>l.stringLiteral(O))))])]);e.node.init=E,s=!0,u++,n.add(y)},ClassMethod(e){if(e.node.kind==="constructor"||e.node.kind==="get"||e.node.kind==="set")return;const i=l.isIdentifier(e.node.key)?e.node.key.name:"anonymous",r=`method_${i}_${e.node.start}`;if(n.has(r))return;t&&console.log(`[FuncSpan Transform] Wrapping class method: ${i}`);const f=e.node.body,y=l.functionExpression(null,e.node.params,f,e.node.generator,e.node.async),C=l.callExpression(l.identifier("captureFunctionSpan"),[y,l.stringLiteral(i),l.stringLiteral(o)]),L=l.blockStatement([l.returnStatement(l.callExpression(l.memberExpression(C,l.identifier("call")),[l.thisExpression(),l.spreadElement(l.identifier("arguments"))]))]);e.node.body=L,s=!0,u++,n.add(r)},ObjectMethod(e){if(e.node.kind==="get"||e.node.kind==="set")return;const i=l.isIdentifier(e.node.key)?e.node.key.name:l.isStringLiteral(e.node.key)?e.node.key.value:"anonymous",r=`objmethod_${i}_${e.node.start}`;if(n.has(r))return;t&&console.log(`[FuncSpan Transform] Wrapping object method: ${i}`);const f=e.node.loc?.start.line??0,y=e.node.loc?.start.column??0,C=v(f,y),{line:L,column:S}=C;let A=p;C.source&&(A=R.resolve(R.dirname(p),C.source));const b=k(e.node.params),M=l.functionExpression(l.identifier(i),e.node.params,e.node.body,e.node.generator,e.node.async),w=l.callExpression(l.identifier("captureFunctionSpan"),[M,l.stringLiteral(i),l.stringLiteral(A),l.objectExpression([l.objectProperty(l.identifier("line"),l.numericLiteral(L)),l.objectProperty(l.identifier("column"),l.numericLiteral(S)),l.objectProperty(l.identifier("paramNames"),l.arrayExpression(b.map(O=>l.stringLiteral(O))))])]),E=l.objectProperty(e.node.key,w,e.node.computed,!1);e.replaceWith(E),s=!0,u++,n.add(r)},ClassProperty(e){const i=e.node.key,r=e.node.value;if(!l.isIdentifier(i)||!r||!l.isFunctionExpression(r)&&!l.isArrowFunctionExpression(r))return;const f=i.name,y=`classprop_${f}_${e.node.start}`;if(n.has(y))return;t&&console.log(`[FuncSpan Transform] Wrapping class property function: ${f}`);const C=r.loc?.start.line??0,L=r.loc?.start.column??0,S=v(C,L),{line:A,column:b}=S;let M=p;S.source&&(M=R.resolve(R.dirname(p),S.source));const w=k(r.params),E=l.callExpression(l.identifier("captureFunctionSpan"),[r,l.stringLiteral(f),l.stringLiteral(M),l.objectExpression([l.objectProperty(l.identifier("line"),l.numericLiteral(A)),l.objectProperty(l.identifier("column"),l.numericLiteral(b)),l.objectProperty(l.identifier("paramNames"),l.arrayExpression(w.map(O=>l.stringLiteral(O))))])]);e.node.value=E,s=!0,u++,n.add(y)}}),s&&!(function(e){let i=!1;return q(e,{ImportDeclaration(r){l.isStringLiteral(r.node.source)&&r.node.source.value==="@sailfish-ai/sf-veritas"&&r.node.specifiers.some(f=>l.isImportSpecifier(f)&&l.isIdentifier(f.imported)&&f.imported.name==="captureFunctionSpan")&&(i=!0,r.stop())},VariableDeclarator(r){if(l.isObjectPattern(r.node.id)&&l.isCallExpression(r.node.init)&&l.isIdentifier(r.node.init.callee)&&r.node.init.callee.name==="require"){const f=r.node.init.arguments;f.length>0&&l.isStringLiteral(f[0])&&f[0].value==="@sailfish-ai/sf-veritas"&&r.node.id.properties.some(y=>l.isObjectProperty(y)&&l.isIdentifier(y.key)&&y.key.name==="captureFunctionSpan")&&(i=!0,r.stop())}}}),i})(c))if((function(e){let i=!1;return q(e,{CallExpression(r){l.isIdentifier(r.node.callee)&&r.node.callee.name==="require"&&(i=!0,r.stop())},MemberExpression(r){!l.isIdentifier(r.node.object)||r.node.object.name!=="module"&&r.node.object.name!=="exports"||(i=!0,r.stop())}}),i})(c)){const e=l.variableDeclaration("const",[l.variableDeclarator(l.objectPattern([l.objectProperty(l.identifier("captureFunctionSpan"),l.identifier("captureFunctionSpan"),!1,!0)]),l.callExpression(l.identifier("require"),[l.stringLiteral("@sailfish-ai/sf-veritas")]))]);c.program.body.unshift(e)}else{const e=l.importDeclaration([l.importSpecifier(l.identifier("captureFunctionSpan"),l.identifier("captureFunctionSpan"))],l.stringLiteral("@sailfish-ai/sf-veritas"));c.program.body.unshift(e)}if(u>0){const e=ye(c,{retainLines:!0,compact:!1,sourceMaps:!0,sourceFileName:p},a);return t&&console.log(`[FuncSpan Transform] ✅ Wrapped ${u} functions in ${o}`),{code:e.code,map:e.map,modified:!0,functionsWrapped:u}}return{code:a,modified:!1,functionsWrapped:0}};