@sailfish-ai/sf-veritas 0.2.7 → 0.2.10

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 (40) hide show
  1. package/dist/contextManager-CEPhVu9T.js +197 -0
  2. package/dist/contextManager-CGINtRN5.cjs +1 -0
  3. package/dist/funcSpanTransformer-B9WWl-g1.cjs +1 -0
  4. package/dist/funcSpanTransformer-CWNEWRxq.js +225 -0
  5. package/dist/plugins/funcspanEsbuildPlugin.cjs +1 -1
  6. package/dist/plugins/funcspanEsbuildPlugin.mjs +17 -11
  7. package/dist/plugins/funcspanRollupPlugin.cjs +1 -1
  8. package/dist/plugins/funcspanRollupPlugin.mjs +13 -8
  9. package/dist/plugins/funcspanTscPlugin.cjs +1 -1
  10. package/dist/plugins/funcspanTscPlugin.mjs +19 -14
  11. package/dist/plugins/funcspanVitePlugin.cjs +1 -1
  12. package/dist/plugins/funcspanVitePlugin.mjs +15 -10
  13. package/dist/plugins/funcspanWebpackLoader.cjs +1 -1
  14. package/dist/plugins/funcspanWebpackLoader.mjs +1 -1
  15. package/dist/plugins/funcspanWebpackPlugin.cjs +1 -1
  16. package/dist/plugins/funcspanWebpackPlugin.mjs +22 -17
  17. package/dist/runtime/funcspanRegister.cjs +276 -0
  18. package/dist/runtimeConfig-CpQ27dZD.cjs +8 -0
  19. package/dist/runtimeConfig-emBNO3lJ.js +350 -0
  20. package/dist/sf-veritas.cjs +18 -18
  21. package/dist/sf-veritas.mjs +417 -619
  22. package/dist/source-map-Cr6YkjTd.js +631 -0
  23. package/dist/source-map-rHHEdpre.cjs +1 -0
  24. package/dist/types/dataTransmitter.d.ts +1 -0
  25. package/dist/types/funcSpanConfigLoader.d.ts +10 -0
  26. package/dist/types/index.d.ts +3 -1
  27. package/dist/types/logHandler.d.ts +5 -0
  28. package/dist/types/plugins/funcSpanTransformer.d.ts +13 -0
  29. package/dist/types/runtime/instrumentationDetector.d.ts +33 -0
  30. package/dist/types/runtime/runtimeConfig.d.ts +48 -0
  31. package/dist/types/sourceLocation.d.ts +30 -0
  32. package/dist/worker-pool-capture.cjs +1 -1
  33. package/dist/worker-pool-capture.mjs +1 -1
  34. package/dist/workerPoolSpanCapture-B5KN-q4b.js +528 -0
  35. package/dist/workerPoolSpanCapture-Dg_WGjmO.cjs +86 -0
  36. package/package.json +5 -2
  37. package/dist/funcSpanTransformer-BLhIRZqX.js +0 -765
  38. package/dist/funcSpanTransformer-BpWuHXKT.cjs +0 -1
  39. package/dist/workerPoolSpanCapture-D0-0Z0Jw.js +0 -718
  40. package/dist/workerPoolSpanCapture-DEwlTq0a.cjs +0 -86
@@ -0,0 +1 @@
1
+ "use strict";var F,$,N={},j={},G={},U={};function te(){if(F)return U;F=1;var u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");return U.encode=function(p){if(0<=p&&p<u.length)return u[p];throw new TypeError("Must be between 0 and 63: "+p)},U.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},U}function ne(){if($)return G;$=1;var u=te();return G.encode=function(p){var m,d="",c=(function(r){return r<0?1+(-r<<1):0+(r<<1)})(p);do m=31&c,(c>>>=5)>0&&(m|=32),d+=u.encode(m);while(c>0);return d},G.decode=function(p,m,d){var c,r,t,l,g=p.length,h=0,_=0;do{if(m>=g)throw new Error("Expected more digits in base 64 VLQ value.");if((r=u.decode(p.charCodeAt(m++)))===-1)throw new Error("Invalid base64 digit: "+p.charAt(m-1));c=!!(32&r),h+=(r&=31)<<_,_+=5}while(c);d.value=(l=(t=h)>>1,1&~t?l:-l),d.rest=m},G}var z,W={};function R(){return z||(z=1,(function(u){u.getArg=function(e,n,a){if(n in e)return e[n];if(arguments.length===3)return a;throw new Error('"'+n+'" is a required argument.')};var p=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,m=/^data:.+\,.+$/;function d(e){var n=e.match(p);return n?{scheme:n[1],auth:n[2],host:n[3],port:n[4],path:n[5]}:null}function c(e){var n="";return e.scheme&&(n+=e.scheme+":"),n+="//",e.auth&&(n+=e.auth+"@"),e.host&&(n+=e.host),e.port&&(n+=":"+e.port),e.path&&(n+=e.path),n}u.urlParse=d,u.urlGenerate=c;var r,t,l=(r=function(e){var n=e,a=d(e);if(a){if(!a.path)return e;n=a.path}for(var o=u.isAbsolute(n),f=[],v=0,C=0;;){if(v=C,(C=n.indexOf("/",v))===-1){f.push(n.slice(v));break}for(f.push(n.slice(v,C));C<n.length&&n[C]==="/";)C++}var S,y=0;for(C=f.length-1;C>=0;C--)(S=f[C])==="."?f.splice(C,1):S===".."?y++:y>0&&(S===""?(f.splice(C+1,y),y=0):(f.splice(C,2),y--));return(n=f.join("/"))===""&&(n=o?"/":"."),a?(a.path=n,c(a)):n},t=[],function(e){for(var n=0;n<t.length;n++)if(t[n].input===e){var a=t[0];return t[0]=t[n],t[n]=a,t[0].result}var o=r(e);return t.unshift({input:e,result:o}),t.length>32&&t.pop(),o});function g(e,n){e===""&&(e="."),n===""&&(n=".");var a=d(n),o=d(e);if(o&&(e=o.path||"/"),a&&!a.scheme)return o&&(a.scheme=o.scheme),c(a);if(a||n.match(m))return n;if(o&&!o.host&&!o.path)return o.host=n,c(o);var f=n.charAt(0)==="/"?n:l(e.replace(/\/+$/,"")+"/"+n);return o?(o.path=f,c(o)):f}u.normalize=l,u.join=g,u.isAbsolute=function(e){return e.charAt(0)==="/"||p.test(e)},u.relative=function(e,n){e===""&&(e="."),e=e.replace(/\/$/,"");for(var a=0;n.indexOf(e+"/")!==0;){var o=e.lastIndexOf("/");if(o<0||(e=e.slice(0,o)).match(/^([^\/]+:\/)?\/*$/))return n;++a}return Array(a+1).join("../")+n.substr(e.length+1)};var h=!("__proto__"in Object.create(null));function _(e){return e}function i(e){if(!e)return!1;var n=e.length;if(n<9||e.charCodeAt(n-1)!==95||e.charCodeAt(n-2)!==95||e.charCodeAt(n-3)!==111||e.charCodeAt(n-4)!==116||e.charCodeAt(n-5)!==111||e.charCodeAt(n-6)!==114||e.charCodeAt(n-7)!==112||e.charCodeAt(n-8)!==95||e.charCodeAt(n-9)!==95)return!1;for(var a=n-10;a>=0;a--)if(e.charCodeAt(a)!==36)return!1;return!0}function s(e,n){return e===n?0:e===null?1:n===null?-1:e>n?1:-1}u.toSetString=h?_:function(e){return i(e)?"$"+e:e},u.fromSetString=h?_:function(e){return i(e)?e.slice(1):e},u.compareByOriginalPositions=function(e,n,a){var o=s(e.source,n.source);return o!==0||(o=e.originalLine-n.originalLine)!==0||(o=e.originalColumn-n.originalColumn)!==0||a||(o=e.generatedColumn-n.generatedColumn)!==0||(o=e.generatedLine-n.generatedLine)!==0?o:s(e.name,n.name)},u.compareByOriginalPositionsNoSource=function(e,n,a){var o;return(o=e.originalLine-n.originalLine)!==0||(o=e.originalColumn-n.originalColumn)!==0||a||(o=e.generatedColumn-n.generatedColumn)!==0||(o=e.generatedLine-n.generatedLine)!==0?o:s(e.name,n.name)},u.compareByGeneratedPositionsDeflated=function(e,n,a){var o=e.generatedLine-n.generatedLine;return o!==0||(o=e.generatedColumn-n.generatedColumn)!==0||a||(o=s(e.source,n.source))!==0||(o=e.originalLine-n.originalLine)!==0||(o=e.originalColumn-n.originalColumn)!==0?o:s(e.name,n.name)},u.compareByGeneratedPositionsDeflatedNoLine=function(e,n,a){var o=e.generatedColumn-n.generatedColumn;return o!==0||a||(o=s(e.source,n.source))!==0||(o=e.originalLine-n.originalLine)!==0||(o=e.originalColumn-n.originalColumn)!==0?o:s(e.name,n.name)},u.compareByGeneratedPositionsInflated=function(e,n){var a=e.generatedLine-n.generatedLine;return a!==0||(a=e.generatedColumn-n.generatedColumn)!==0||(a=s(e.source,n.source))!==0||(a=e.originalLine-n.originalLine)!==0||(a=e.originalColumn-n.originalColumn)!==0?a:s(e.name,n.name)},u.parseSourceMapInput=function(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))},u.computeSourceURL=function(e,n,a){if(n=n||"",e&&(e[e.length-1]!=="/"&&n[0]!=="/"&&(e+="/"),n=e+n),a){var o=d(a);if(!o)throw new Error("sourceMapURL could not be parsed");if(o.path){var f=o.path.lastIndexOf("/");f>=0&&(o.path=o.path.substring(0,f+1))}n=g(c(o),n)}return l(n)}})(W)),W}var q,x={};function re(){if(q)return x;q=1;var u=R(),p=Object.prototype.hasOwnProperty,m=typeof Map<"u";function d(){this._array=[],this._set=m?new Map:Object.create(null)}return d.fromArray=function(c,r){for(var t=new d,l=0,g=c.length;l<g;l++)t.add(c[l],r);return t},d.prototype.size=function(){return m?this._set.size:Object.getOwnPropertyNames(this._set).length},d.prototype.add=function(c,r){var t=m?c:u.toSetString(c),l=m?this.has(c):p.call(this._set,t),g=this._array.length;l&&!r||this._array.push(c),l||(m?this._set.set(c,g):this._set[t]=g)},d.prototype.has=function(c){if(m)return this._set.has(c);var r=u.toSetString(c);return p.call(this._set,r)},d.prototype.indexOf=function(c){if(m){var r=this._set.get(c);if(r>=0)return r}else{var t=u.toSetString(c);if(p.call(this._set,t))return this._set[t]}throw new Error('"'+c+'" is not in the set.')},d.prototype.at=function(c){if(c>=0&&c<this._array.length)return this._array[c];throw new Error("No element indexed by "+c)},d.prototype.toArray=function(){return this._array.slice()},x.ArraySet=d,x}var J,V,D={};function oe(){if(J)return D;J=1;var u=R();function p(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}return p.prototype.unsortedForEach=function(m,d){this._array.forEach(m,d)},p.prototype.add=function(m){var d,c,r,t,l,g;d=this._last,c=m,r=d.generatedLine,t=c.generatedLine,l=d.generatedColumn,g=c.generatedColumn,t>r||t==r&&g>=l||u.compareByGeneratedPositionsInflated(d,c)<=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(u.compareByGeneratedPositionsInflated),this._sorted=!0),this._array},D.MappingList=p,D}function Q(){if(V)return j;V=1;var u=ne(),p=R(),m=re().ArraySet,d=oe().MappingList;function c(r){r||(r={}),this._file=p.getArg(r,"file",null),this._sourceRoot=p.getArg(r,"sourceRoot",null),this._skipValidation=p.getArg(r,"skipValidation",!1),this._ignoreInvalidMapping=p.getArg(r,"ignoreInvalidMapping",!1),this._sources=new m,this._names=new m,this._mappings=new d,this._sourcesContents=null}return c.prototype._version=3,c.fromSourceMap=function(r,t){var l=r.sourceRoot,g=new c(Object.assign(t||{},{file:r.file,sourceRoot:l}));return r.eachMapping(function(h){var _={generated:{line:h.generatedLine,column:h.generatedColumn}};h.source!=null&&(_.source=h.source,l!=null&&(_.source=p.relative(l,_.source)),_.original={line:h.originalLine,column:h.originalColumn},h.name!=null&&(_.name=h.name)),g.addMapping(_)}),r.sources.forEach(function(h){var _=h;l!==null&&(_=p.relative(l,h)),g._sources.has(_)||g._sources.add(_);var i=r.sourceContentFor(h);i!=null&&g.setSourceContent(h,i)}),g},c.prototype.addMapping=function(r){var t=p.getArg(r,"generated"),l=p.getArg(r,"original",null),g=p.getArg(r,"source",null),h=p.getArg(r,"name",null);(this._skipValidation||this._validateMapping(t,l,g,h)!==!1)&&(g!=null&&(g=String(g),this._sources.has(g)||this._sources.add(g)),h!=null&&(h=String(h),this._names.has(h)||this._names.add(h)),this._mappings.add({generatedLine:t.line,generatedColumn:t.column,originalLine:l!=null&&l.line,originalColumn:l!=null&&l.column,source:g,name:h}))},c.prototype.setSourceContent=function(r,t){var l=r;this._sourceRoot!=null&&(l=p.relative(this._sourceRoot,l)),t!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[p.toSetString(l)]=t):this._sourcesContents&&(delete this._sourcesContents[p.toSetString(l)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))},c.prototype.applySourceMap=function(r,t,l){var g=t;if(t==null){if(r.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);g=r.file}var h=this._sourceRoot;h!=null&&(g=p.relative(h,g));var _=new m,i=new m;this._mappings.unsortedForEach(function(s){if(s.source===g&&s.originalLine!=null){var e=r.originalPositionFor({line:s.originalLine,column:s.originalColumn});e.source!=null&&(s.source=e.source,l!=null&&(s.source=p.join(l,s.source)),h!=null&&(s.source=p.relative(h,s.source)),s.originalLine=e.line,s.originalColumn=e.column,e.name!=null&&(s.name=e.name))}var n=s.source;n==null||_.has(n)||_.add(n);var a=s.name;a==null||i.has(a)||i.add(a)},this),this._sources=_,this._names=i,r.sources.forEach(function(s){var e=r.sourceContentFor(s);e!=null&&(l!=null&&(s=p.join(l,s)),h!=null&&(s=p.relative(h,s)),this.setSourceContent(s,e))},this)},c.prototype._validateMapping=function(r,t,l,g){if(t&&typeof t.line!="number"&&typeof t.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((!(r&&"line"in r&&"column"in r&&r.line>0&&r.column>=0)||t||l||g)&&!(r&&"line"in r&&"column"in r&&t&&"line"in t&&"column"in t&&r.line>0&&r.column>=0&&t.line>0&&t.column>=0&&l)){if(h="Invalid mapping: "+JSON.stringify({generated:r,source:l,original:t,name:g}),this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(h),!1;throw new Error(h)}},c.prototype._serializeMappings=function(){for(var r,t,l,g,h=0,_=1,i=0,s=0,e=0,n=0,a="",o=this._mappings.toArray(),f=0,v=o.length;f<v;f++){if(r="",(t=o[f]).generatedLine!==_)for(h=0;t.generatedLine!==_;)r+=";",_++;else if(f>0){if(!p.compareByGeneratedPositionsInflated(t,o[f-1]))continue;r+=","}r+=u.encode(t.generatedColumn-h),h=t.generatedColumn,t.source!=null&&(g=this._sources.indexOf(t.source),r+=u.encode(g-n),n=g,r+=u.encode(t.originalLine-1-s),s=t.originalLine-1,r+=u.encode(t.originalColumn-i),i=t.originalColumn,t.name!=null&&(l=this._names.indexOf(t.name),r+=u.encode(l-e),e=l)),a+=r}return a},c.prototype._generateSourcesContent=function(r,t){return r.map(function(l){if(!this._sourcesContents)return null;t!=null&&(l=p.relative(t,l));var g=p.toSetString(l);return Object.prototype.hasOwnProperty.call(this._sourcesContents,g)?this._sourcesContents[g]:null},this)},c.prototype.toJSON=function(){var r={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(r.file=this._file),this._sourceRoot!=null&&(r.sourceRoot=this._sourceRoot),this._sourcesContents&&(r.sourcesContent=this._generateSourcesContent(r.sources,r.sourceRoot)),r},c.prototype.toString=function(){return JSON.stringify(this.toJSON())},j.SourceMapGenerator=c,j}var H,E={},K={};function ie(){return H||(H=1,(function(u){function p(m,d,c,r,t,l){var g=Math.floor((d-m)/2)+m,h=t(c,r[g],!0);return h===0?g:h>0?d-g>1?p(g,d,c,r,t,l):l==u.LEAST_UPPER_BOUND?d<r.length?d:-1:g:g-m>1?p(m,g,c,r,t,l):l==u.LEAST_UPPER_BOUND?g:m<0?-1:m}u.GREATEST_LOWER_BOUND=1,u.LEAST_UPPER_BOUND=2,u.search=function(m,d,c,r){if(d.length===0)return-1;var t=p(-1,d.length,m,d,c,r||u.GREATEST_LOWER_BOUND);if(t<0)return-1;for(;t-1>=0&&c(d[t],d[t-1],!0)===0;)--t;return t}})(K)),K}var X,Y,T={};function se(){if(X)return T;function u(m){function d(c,r,t){var l=c[r];c[r]=c[t],c[t]=l}return function c(r,t,l,g){if(l<g){var h=l-1;d(r,(e=l,n=g,Math.round(e+Math.random()*(n-e))),g);for(var _=r[g],i=l;i<g;i++)t(r[i],_,!1)<=0&&d(r,h+=1,i);d(r,h+1,i);var s=h+1;c(r,t,l,s-1),c(r,t,s+1,g)}var e,n}}X=1;let p=new WeakMap;return T.quickSort=function(m,d,c=0){let r=p.get(d);r===void 0&&(r=(function(t){let l=u.toString();return new Function(`return ${l}`)()(t)})(d),p.set(d,r)),r(m,d,c,m.length-1)},T}var Z,ee,k={},ae=(ee||(ee=1,N.SourceMapGenerator=Q().SourceMapGenerator,N.SourceMapConsumer=(function(){if(Y)return E;Y=1;var u=R(),p=ie(),m=re().ArraySet,d=ne(),c=se().quickSort;function r(i,s){var e=i;return typeof i=="string"&&(e=u.parseSourceMapInput(i)),e.sections!=null?new _(e,s):new t(e,s)}function t(i,s){var e=i;typeof i=="string"&&(e=u.parseSourceMapInput(i));var n=u.getArg(e,"version"),a=u.getArg(e,"sources"),o=u.getArg(e,"names",[]),f=u.getArg(e,"sourceRoot",null),v=u.getArg(e,"sourcesContent",null),C=u.getArg(e,"mappings"),S=u.getArg(e,"file",null);if(n!=this._version)throw new Error("Unsupported version: "+n);f&&(f=u.normalize(f)),a=a.map(String).map(u.normalize).map(function(y){return f&&u.isAbsolute(f)&&u.isAbsolute(y)?u.relative(f,y):y}),this._names=m.fromArray(o.map(String),!0),this._sources=m.fromArray(a,!0),this._absoluteSources=this._sources.toArray().map(function(y){return u.computeSourceURL(f,y,s)}),this.sourceRoot=f,this.sourcesContent=v,this._mappings=C,this._sourceMapURL=s,this.file=S}function l(){this.generatedLine=0,this.generatedColumn=0,this.source=null,this.originalLine=null,this.originalColumn=null,this.name=null}r.fromSourceMap=function(i,s){return t.fromSourceMap(i,s)},r.prototype._version=3,r.prototype.__generatedMappings=null,Object.defineProperty(r.prototype,"_generatedMappings",{configurable:!0,enumerable:!0,get:function(){return this.__generatedMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__generatedMappings}}),r.prototype.__originalMappings=null,Object.defineProperty(r.prototype,"_originalMappings",{configurable:!0,enumerable:!0,get:function(){return this.__originalMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__originalMappings}}),r.prototype._charIsMappingSeparator=function(i,s){var e=i.charAt(s);return e===";"||e===","},r.prototype._parseMappings=function(i,s){throw new Error("Subclasses must implement _parseMappings")},r.GENERATED_ORDER=1,r.ORIGINAL_ORDER=2,r.GREATEST_LOWER_BOUND=1,r.LEAST_UPPER_BOUND=2,r.prototype.eachMapping=function(i,s,e){var n,a=s||null;switch(e||r.GENERATED_ORDER){case r.GENERATED_ORDER:n=this._generatedMappings;break;case r.ORIGINAL_ORDER:n=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}for(var o=this.sourceRoot,f=i.bind(a),v=this._names,C=this._sources,S=this._sourceMapURL,y=0,A=n.length;y<A;y++){var M=n[y],L=M.source===null?null:C.at(M.source);L!==null&&(L=u.computeSourceURL(o,L,S)),f({source:L,generatedLine:M.generatedLine,generatedColumn:M.generatedColumn,originalLine:M.originalLine,originalColumn:M.originalColumn,name:M.name===null?null:v.at(M.name)})}},r.prototype.allGeneratedPositionsFor=function(i){var s=u.getArg(i,"line"),e={source:u.getArg(i,"source"),originalLine:s,originalColumn:u.getArg(i,"column",0)};if(e.source=this._findSourceIndex(e.source),e.source<0)return[];var n=[],a=this._findMapping(e,this._originalMappings,"originalLine","originalColumn",u.compareByOriginalPositions,p.LEAST_UPPER_BOUND);if(a>=0){var o=this._originalMappings[a];if(i.column===void 0)for(var f=o.originalLine;o&&o.originalLine===f;)n.push({line:u.getArg(o,"generatedLine",null),column:u.getArg(o,"generatedColumn",null),lastColumn:u.getArg(o,"lastGeneratedColumn",null)}),o=this._originalMappings[++a];else for(var v=o.originalColumn;o&&o.originalLine===s&&o.originalColumn==v;)n.push({line:u.getArg(o,"generatedLine",null),column:u.getArg(o,"generatedColumn",null),lastColumn:u.getArg(o,"lastGeneratedColumn",null)}),o=this._originalMappings[++a]}return n},E.SourceMapConsumer=r,t.prototype=Object.create(r.prototype),t.prototype.consumer=r,t.prototype._findSourceIndex=function(i){var s,e=i;if(this.sourceRoot!=null&&(e=u.relative(this.sourceRoot,e)),this._sources.has(e))return this._sources.indexOf(e);for(s=0;s<this._absoluteSources.length;++s)if(this._absoluteSources[s]==i)return s;return-1},t.fromSourceMap=function(i,s){var e=Object.create(t.prototype),n=e._names=m.fromArray(i._names.toArray(),!0),a=e._sources=m.fromArray(i._sources.toArray(),!0);e.sourceRoot=i._sourceRoot,e.sourcesContent=i._generateSourcesContent(e._sources.toArray(),e.sourceRoot),e.file=i._file,e._sourceMapURL=s,e._absoluteSources=e._sources.toArray().map(function(M){return u.computeSourceURL(e.sourceRoot,M,s)});for(var o=i._mappings.toArray().slice(),f=e.__generatedMappings=[],v=e.__originalMappings=[],C=0,S=o.length;C<S;C++){var y=o[C],A=new l;A.generatedLine=y.generatedLine,A.generatedColumn=y.generatedColumn,y.source&&(A.source=a.indexOf(y.source),A.originalLine=y.originalLine,A.originalColumn=y.originalColumn,y.name&&(A.name=n.indexOf(y.name)),v.push(A)),f.push(A)}return c(e.__originalMappings,u.compareByOriginalPositions),e},t.prototype._version=3,Object.defineProperty(t.prototype,"sources",{get:function(){return this._absoluteSources.slice()}});const g=u.compareByGeneratedPositionsDeflatedNoLine;function h(i,s){let e=i.length,n=i.length-s;if(!(n<=1))if(n==2){let a=i[s],o=i[s+1];g(a,o)>0&&(i[s]=o,i[s+1]=a)}else if(n<20)for(let a=s;a<e;a++)for(let o=a;o>s;o--){let f=i[o-1],v=i[o];if(g(f,v)<=0)break;i[o-1]=v,i[o]=f}else c(i,g,s)}function _(i,s){var e=i;typeof i=="string"&&(e=u.parseSourceMapInput(i));var n=u.getArg(e,"version"),a=u.getArg(e,"sections");if(n!=this._version)throw new Error("Unsupported version: "+n);this._sources=new m,this._names=new m;var o={line:-1,column:0};this._sections=a.map(function(f){if(f.url)throw new Error("Support for url field in sections not implemented.");var v=u.getArg(f,"offset"),C=u.getArg(v,"line"),S=u.getArg(v,"column");if(C<o.line||C===o.line&&S<o.column)throw new Error("Section offsets must be ordered and non-overlapping.");return o=v,{generatedOffset:{generatedLine:C+1,generatedColumn:S+1},consumer:new r(u.getArg(f,"map"),s)}})}return t.prototype._parseMappings=function(i,s){var e,n,a,o,f=1,v=0,C=0,S=0,y=0,A=0,M=i.length,L=0,I={},w=[],O=[];let B=0;for(;L<M;)if(i.charAt(L)===";")f++,L++,v=0,h(O,B),B=O.length;else if(i.charAt(L)===",")L++;else{for((e=new l).generatedLine=f,a=L;a<M&&!this._charIsMappingSeparator(i,a);a++);for(i.slice(L,a),n=[];L<a;)d.decode(i,L,I),o=I.value,L=I.rest,n.push(o);if(n.length===2)throw new Error("Found a source, but no line and column");if(n.length===3)throw new Error("Found a source and line, but no column");if(e.generatedColumn=v+n[0],v=e.generatedColumn,n.length>1&&(e.source=y+n[1],y+=n[1],e.originalLine=C+n[2],C=e.originalLine,e.originalLine+=1,e.originalColumn=S+n[3],S=e.originalColumn,n.length>4&&(e.name=A+n[4],A+=n[4])),O.push(e),typeof e.originalLine=="number"){let P=e.source;for(;w.length<=P;)w.push(null);w[P]===null&&(w[P]=[]),w[P].push(e)}}h(O,B),this.__generatedMappings=O;for(var b=0;b<w.length;b++)w[b]!=null&&c(w[b],u.compareByOriginalPositionsNoSource);this.__originalMappings=[].concat(...w)},t.prototype._findMapping=function(i,s,e,n,a,o){if(i[e]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+i[e]);if(i[n]<0)throw new TypeError("Column must be greater than or equal to 0, got "+i[n]);return p.search(i,s,a,o)},t.prototype.computeColumnSpans=function(){for(var i=0;i<this._generatedMappings.length;++i){var s=this._generatedMappings[i];if(i+1<this._generatedMappings.length){var e=this._generatedMappings[i+1];if(s.generatedLine===e.generatedLine){s.lastGeneratedColumn=e.generatedColumn-1;continue}}s.lastGeneratedColumn=1/0}},t.prototype.originalPositionFor=function(i){var s={generatedLine:u.getArg(i,"line"),generatedColumn:u.getArg(i,"column")},e=this._findMapping(s,this._generatedMappings,"generatedLine","generatedColumn",u.compareByGeneratedPositionsDeflated,u.getArg(i,"bias",r.GREATEST_LOWER_BOUND));if(e>=0){var n=this._generatedMappings[e];if(n.generatedLine===s.generatedLine){var a=u.getArg(n,"source",null);a!==null&&(a=this._sources.at(a),a=u.computeSourceURL(this.sourceRoot,a,this._sourceMapURL));var o=u.getArg(n,"name",null);return o!==null&&(o=this._names.at(o)),{source:a,line:u.getArg(n,"originalLine",null),column:u.getArg(n,"originalColumn",null),name:o}}}return{source:null,line:null,column:null,name:null}},t.prototype.hasContentsOfAllSources=function(){return!!this.sourcesContent&&this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some(function(i){return i==null})},t.prototype.sourceContentFor=function(i,s){if(!this.sourcesContent)return null;var e=this._findSourceIndex(i);if(e>=0)return this.sourcesContent[e];var n,a=i;if(this.sourceRoot!=null&&(a=u.relative(this.sourceRoot,a)),this.sourceRoot!=null&&(n=u.urlParse(this.sourceRoot))){var o=a.replace(/^file:\/\//,"");if(n.scheme=="file"&&this._sources.has(o))return this.sourcesContent[this._sources.indexOf(o)];if((!n.path||n.path=="/")&&this._sources.has("/"+a))return this.sourcesContent[this._sources.indexOf("/"+a)]}if(s)return null;throw new Error('"'+a+'" is not in the SourceMap.')},t.prototype.generatedPositionFor=function(i){var s=u.getArg(i,"source");if((s=this._findSourceIndex(s))<0)return{line:null,column:null,lastColumn:null};var e={source:s,originalLine:u.getArg(i,"line"),originalColumn:u.getArg(i,"column")},n=this._findMapping(e,this._originalMappings,"originalLine","originalColumn",u.compareByOriginalPositions,u.getArg(i,"bias",r.GREATEST_LOWER_BOUND));if(n>=0){var a=this._originalMappings[n];if(a.source===e.source)return{line:u.getArg(a,"generatedLine",null),column:u.getArg(a,"generatedColumn",null),lastColumn:u.getArg(a,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}},E.BasicSourceMapConsumer=t,_.prototype=Object.create(r.prototype),_.prototype.constructor=r,_.prototype._version=3,Object.defineProperty(_.prototype,"sources",{get:function(){for(var i=[],s=0;s<this._sections.length;s++)for(var e=0;e<this._sections[s].consumer.sources.length;e++)i.push(this._sections[s].consumer.sources[e]);return i}}),_.prototype.originalPositionFor=function(i){var s={generatedLine:u.getArg(i,"line"),generatedColumn:u.getArg(i,"column")},e=p.search(s,this._sections,function(a,o){return a.generatedLine-o.generatedOffset.generatedLine||a.generatedColumn-o.generatedOffset.generatedColumn}),n=this._sections[e];return n?n.consumer.originalPositionFor({line:s.generatedLine-(n.generatedOffset.generatedLine-1),column:s.generatedColumn-(n.generatedOffset.generatedLine===s.generatedLine?n.generatedOffset.generatedColumn-1:0),bias:i.bias}):{source:null,line:null,column:null,name:null}},_.prototype.hasContentsOfAllSources=function(){return this._sections.every(function(i){return i.consumer.hasContentsOfAllSources()})},_.prototype.sourceContentFor=function(i,s){for(var e=0;e<this._sections.length;e++){var n=this._sections[e].consumer.sourceContentFor(i,!0);if(n||n==="")return n}if(s)return null;throw new Error('"'+i+'" is not in the SourceMap.')},_.prototype.generatedPositionFor=function(i){for(var s=0;s<this._sections.length;s++){var e=this._sections[s];if(e.consumer._findSourceIndex(u.getArg(i,"source"))!==-1){var n=e.consumer.generatedPositionFor(i);if(n)return{line:n.line+(e.generatedOffset.generatedLine-1),column:n.column+(e.generatedOffset.generatedLine===n.line?e.generatedOffset.generatedColumn-1:0)}}}return{line:null,column:null}},_.prototype._parseMappings=function(i,s){this.__generatedMappings=[],this.__originalMappings=[];for(var e=0;e<this._sections.length;e++)for(var n=this._sections[e],a=n.consumer._generatedMappings,o=0;o<a.length;o++){var f=a[o],v=n.consumer._sources.at(f.source);v!==null&&(v=u.computeSourceURL(n.consumer.sourceRoot,v,this._sourceMapURL)),this._sources.add(v),v=this._sources.indexOf(v);var C=null;f.name&&(C=n.consumer._names.at(f.name),this._names.add(C),C=this._names.indexOf(C));var S={source:v,generatedLine:f.generatedLine+(n.generatedOffset.generatedLine-1),generatedColumn:f.generatedColumn+(n.generatedOffset.generatedLine===f.generatedLine?n.generatedOffset.generatedColumn-1:0),originalLine:f.originalLine,originalColumn:f.originalColumn,name:C};this.__generatedMappings.push(S),typeof S.originalLine=="number"&&this.__originalMappings.push(S)}c(this.__generatedMappings,u.compareByGeneratedPositionsDeflated),c(this.__originalMappings,u.compareByOriginalPositions)},E.IndexedSourceMapConsumer=_,E})().SourceMapConsumer,N.SourceNode=(function(){if(Z)return k;Z=1;var u=Q().SourceMapGenerator,p=R(),m=/(\r?\n)/,d="$$$isSourceNode$$$";function c(r,t,l,g,h){this.children=[],this.sourceContents={},this.line=r??null,this.column=t??null,this.source=l??null,this.name=h??null,this[d]=!0,g!=null&&this.add(g)}return c.fromStringWithSourceMap=function(r,t,l){var g=new c,h=r.split(m),_=0,i=function(){return o()+(o()||"");function o(){return _<h.length?h[_++]:void 0}},s=1,e=0,n=null;return t.eachMapping(function(o){if(n!==null){if(!(s<o.generatedLine)){var f=(v=h[_]||"").substr(0,o.generatedColumn-e);return h[_]=v.substr(o.generatedColumn-e),e=o.generatedColumn,a(n,f),void(n=o)}a(n,i()),s++,e=0}for(;s<o.generatedLine;)g.add(i()),s++;if(e<o.generatedColumn){var v=h[_]||"";g.add(v.substr(0,o.generatedColumn)),h[_]=v.substr(o.generatedColumn),e=o.generatedColumn}n=o},this),_<h.length&&(n&&a(n,i()),g.add(h.splice(_).join(""))),t.sources.forEach(function(o){var f=t.sourceContentFor(o);f!=null&&(l!=null&&(o=p.join(l,o)),g.setSourceContent(o,f))}),g;function a(o,f){if(o===null||o.source===void 0)g.add(f);else{var v=l?p.join(l,o.source):o.source;g.add(new c(o.originalLine,o.originalColumn,v,f,o.name))}}},c.prototype.add=function(r){if(Array.isArray(r))r.forEach(function(t){this.add(t)},this);else{if(!r[d]&&typeof r!="string")throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+r);r&&this.children.push(r)}return this},c.prototype.prepend=function(r){if(Array.isArray(r))for(var t=r.length-1;t>=0;t--)this.prepend(r[t]);else{if(!r[d]&&typeof r!="string")throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+r);this.children.unshift(r)}return this},c.prototype.walk=function(r){for(var t,l=0,g=this.children.length;l<g;l++)(t=this.children[l])[d]?t.walk(r):t!==""&&r(t,{source:this.source,line:this.line,column:this.column,name:this.name})},c.prototype.join=function(r){var t,l,g=this.children.length;if(g>0){for(t=[],l=0;l<g-1;l++)t.push(this.children[l]),t.push(r);t.push(this.children[l]),this.children=t}return this},c.prototype.replaceRight=function(r,t){var l=this.children[this.children.length-1];return l[d]?l.replaceRight(r,t):typeof l=="string"?this.children[this.children.length-1]=l.replace(r,t):this.children.push("".replace(r,t)),this},c.prototype.setSourceContent=function(r,t){this.sourceContents[p.toSetString(r)]=t},c.prototype.walkSourceContents=function(r){for(var t=0,l=this.children.length;t<l;t++)this.children[t][d]&&this.children[t].walkSourceContents(r);var g=Object.keys(this.sourceContents);for(t=0,l=g.length;t<l;t++)r(p.fromSetString(g[t]),this.sourceContents[g[t]])},c.prototype.toString=function(){var r="";return this.walk(function(t){r+=t}),r},c.prototype.toStringWithSourceMap=function(r){var t={code:"",line:1,column:0},l=new u(r),g=!1,h=null,_=null,i=null,s=null;return this.walk(function(e,n){t.code+=e,n.source!==null&&n.line!==null&&n.column!==null?(h===n.source&&_===n.line&&i===n.column&&s===n.name||l.addMapping({source:n.source,original:{line:n.line,column:n.column},generated:{line:t.line,column:t.column},name:n.name}),h=n.source,_=n.line,i=n.column,s=n.name,g=!0):g&&(l.addMapping({generated:{line:t.line,column:t.column}}),h=null,g=!1);for(var a=0,o=e.length;a<o;a++)e.charCodeAt(a)===10?(t.line++,t.column=0,a+1===o?(h=null,g=!1):g&&l.addMapping({source:n.source,original:{line:n.line,column:n.column},generated:{line:t.line,column:t.column},name:n.name})):t.column++}),this.walkSourceContents(function(e,n){l.setSourceContent(e,n)}),{code:t.code,map:l}},k.SourceNode=c,k})().SourceNode),N);exports.sourceMapExports=ae;
@@ -23,6 +23,7 @@ export declare class DataTransmitter extends BaseTransmitter {
23
23
  /**
24
24
  * Sends the contents to the server endpoint. It checks the contents type and prepares the request.
25
25
  * @param contents - The content to be sent, which can be a string or an array of strings.
26
+ * Array format: [message, level, sourceFile?, sourceLine?]
26
27
  */
27
28
  send(contents: string | string[]): Promise<void>;
28
29
  /**
@@ -21,6 +21,7 @@ export declare class FuncspanConfigLoader {
21
21
  private functionConfigs;
22
22
  private directoryConfigs;
23
23
  private hasSailfishFiles;
24
+ private runtimeModeEnabled;
24
25
  private debug;
25
26
  constructor(rootPaths?: string[], debug?: boolean);
26
27
  /**
@@ -31,6 +32,10 @@ export declare class FuncspanConfigLoader {
31
32
  * Get configuration for a specific file and function
32
33
  */
33
34
  getConfig(filePath: string, functionName?: string): FuncspanConfig;
35
+ /**
36
+ * NEW: Check if runtime mode is configured in any .sailfish file
37
+ */
38
+ hasRuntimeMode(): boolean;
34
39
  /**
35
40
  * Walk directory recursively looking for .sailfish files
36
41
  */
@@ -69,3 +74,8 @@ export declare function getGlobalConfig(filePath: string, functionName?: string)
69
74
  * Check if global config loader has been initialized
70
75
  */
71
76
  export declare function isConfigLoaderInitialized(): boolean;
77
+ /**
78
+ * NEW: Check if runtime mode is configured in .sailfish files
79
+ * This is used by runtime hooks to determine if they should be enabled
80
+ */
81
+ export declare function isRuntimeModeConfigured(): boolean;
@@ -3,5 +3,7 @@ export { addOrUpdateMetadata, identify, setupInterceptors, isSetupInterceptorsIn
3
3
  export { captureFunctionSpan, type FunctionSpanMetadata } from "./funcSpanCapture";
4
4
  export { type FuncspanConfig, type FuncspanHeaderOverride, setFuncspanOverride, getFuncspanOverride, clearFuncspanOverride, parseHeaderOverride, getEnvConfig, getDefaultConfig, } from "./funcSpanConfig";
5
5
  export { initializeConfigLoader, getGlobalConfig, isConfigLoaderInitialized, } from "./funcSpanConfigLoader";
6
- export { transformFunctionSpans, type TransformOptions, type TransformResult } from "./plugins/funcSpanTransformer";
6
+ export { transformFunctionSpans, transformFunctionSpansSync, setSkipTypeScriptPlugin, type TransformOptions, type TransformResult } from "./plugins/funcSpanTransformer";
7
+ export { shouldEnableRuntimeHooks, isRuntimeModeEnabled, isProductionEnvironment } from "./runtime/runtimeConfig";
8
+ export { isAlreadyInstrumented } from "./runtime/instrumentationDetector";
7
9
  export { initializeWorkerPoolPatching, isInitialized as isWorkerPoolInitialized } from "./patches/workerPool/index";
@@ -1,2 +1,7 @@
1
1
  import { DataTransmitter } from "./dataTransmitter";
2
+ export declare const internalLog: any;
3
+ export declare const internalError: any;
4
+ export declare const internalWarn: any;
5
+ export declare const internalInfo: any;
6
+ export declare const internalDebug: any;
2
7
  export declare function initializeLogInterceptor(transmitter: DataTransmitter): void;
@@ -4,6 +4,7 @@
4
4
  * Transforms JavaScript/TypeScript code to wrap functions with captureFunctionSpan()
5
5
  * for automatic instrumentation.
6
6
  */
7
+ export declare function setSkipTypeScriptPlugin(skip: boolean): void;
7
8
  export interface TransformOptions {
8
9
  /**
9
10
  * Project root directory for resolving relative paths
@@ -29,3 +30,15 @@ export interface TransformResult {
29
30
  * Transform JavaScript/TypeScript source code to wrap functions
30
31
  */
31
32
  export declare function transformFunctionSpans(source: string, filePath: string, options?: TransformOptions): Promise<TransformResult>;
33
+ /**
34
+ * Synchronous version of transformFunctionSpans for runtime hooks
35
+ *
36
+ * This version skips sourcemap loading since Node's Module._extensions hook is synchronous.
37
+ * Sourcemaps are optional - they're only used to map positions back to original TypeScript source.
38
+ * For runtime instrumentation, using compiled positions is sufficient.
39
+ *
40
+ * @param parseAsJavaScript - If true, parse as JavaScript (for tsx-compiled output). If false, parse as TypeScript.
41
+ */
42
+ export declare function transformFunctionSpansSync(source: string, filePath: string, options?: TransformOptions & {
43
+ parseAsJavaScript?: boolean;
44
+ }): TransformResult;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Instrumentation Detector
3
+ *
4
+ * Detects if source code is already instrumented by build plugins
5
+ * to prevent double-wrapping functions with runtime hooks.
6
+ *
7
+ * Uses fast heuristics to check for telltale signs of instrumentation.
8
+ */
9
+ /**
10
+ * Check if source code is already instrumented
11
+ *
12
+ * Looks for telltale signs that the code has been instrumented by build plugins:
13
+ * 1. Presence of captureFunctionSpan() calls
14
+ * 2. Import/require of @sailfish-ai/sf-veritas
15
+ * 3. Instrumentation marker comments (if we add them in the future)
16
+ *
17
+ * This is a fast heuristic check using string includes.
18
+ * For more accuracy, could parse AST, but that's much slower.
19
+ *
20
+ * @param source - Source code to check
21
+ * @returns true if source appears to be already instrumented
22
+ */
23
+ export declare function isAlreadyInstrumented(source: string): boolean;
24
+ /**
25
+ * More thorough AST-based check for instrumentation
26
+ *
27
+ * This is slower but more accurate. Use only if heuristic check is ambiguous.
28
+ * Currently not used, but available for future enhancements.
29
+ *
30
+ * @param source - Source code to check
31
+ * @returns true if source is instrumented based on AST analysis
32
+ */
33
+ export declare function isAlreadyInstrumentedAST(source: string): boolean;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Runtime Configuration Module
3
+ *
4
+ * Centralized gating logic for runtime function span hooks.
5
+ * Determines when runtime instrumentation should be enabled based on:
6
+ * 1. SF_FUNCSPAN_RUNTIME_ENABLED environment variable (highest priority)
7
+ * 2. .sailfish config file runtime_mode setting
8
+ * 3. Production environment detection (safety gate)
9
+ */
10
+ /**
11
+ * Check if runtime mode is enabled via environment variable or .sailfish config
12
+ *
13
+ * Priority order:
14
+ * 1. SF_FUNCSPAN_RUNTIME_ENABLED env var (highest priority)
15
+ * 2. .sailfish config file runtime_mode setting
16
+ * 3. Default: false (opt-in system)
17
+ *
18
+ * @returns true if runtime mode should be enabled
19
+ */
20
+ export declare function isRuntimeModeEnabled(): boolean;
21
+ /**
22
+ * Detect if running in production environment
23
+ *
24
+ * Uses existing detectIsLocalEnv() from exceptionHandler.ts which checks:
25
+ * - SF_IS_LOCAL explicit override
26
+ * - NODE_ENV (local, dev, development)
27
+ * - Cloud markers (KUBERNETES_SERVICE_HOST, AWS_EXECUTION_ENV, etc.)
28
+ * - Hostname heuristics
29
+ *
30
+ * @returns true if production environment, false if local/dev
31
+ */
32
+ export declare function isProductionEnvironment(): boolean;
33
+ /**
34
+ * Master gate function - determines if runtime hooks should activate
35
+ *
36
+ * Returns TRUE only if ALL conditions are met:
37
+ * 1. Runtime mode is enabled (env var or config)
38
+ * 2. NOT in production environment
39
+ *
40
+ * This is the single source of truth for whether runtime hooks should run.
41
+ *
42
+ * @returns true if runtime hooks should be active
43
+ */
44
+ export declare function shouldEnableRuntimeHooks(): boolean;
45
+ /**
46
+ * Clear cached values (useful for testing)
47
+ */
48
+ export declare function clearRuntimeConfigCache(): void;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Get caller location from the call stack.
3
+ * Captures file path and line number of the code that triggered the log,
4
+ * filtering out internal library frames.
5
+ *
6
+ * Performance: ~7-15 µs per call (first call), ~50 ns (cached)
7
+ *
8
+ * @param skipFrames - Additional frames to skip beyond this function
9
+ * Default: 0 (skip only getCallerLocation itself)
10
+ *
11
+ * @returns Tuple of [absolutePath, lineNumber] or [null, null] if not found
12
+ *
13
+ * @example
14
+ * // From user code:
15
+ * const [sourceFile, sourceLine] = getCallerLocation(2);
16
+ * // Returns: ['/Users/name/project/src/app.ts', 42]
17
+ */
18
+ export declare function getCallerLocation(skipFrames?: number): [string | null, number | null];
19
+ /**
20
+ * Clear the location cache.
21
+ * Useful for testing or if cache invalidation is needed.
22
+ */
23
+ export declare function clearLocationCache(): void;
24
+ /**
25
+ * Get current cache size.
26
+ * Useful for monitoring and testing cache effectiveness.
27
+ *
28
+ * @returns Number of entries in cache
29
+ */
30
+ export declare function getCacheSize(): number;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./workerPoolSpanCapture-DEwlTq0a.cjs");exports.captureWorkerPoolOperation=e.captureWorkerPoolOperation;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./workerPoolSpanCapture-Dg_WGjmO.cjs");exports.captureWorkerPoolOperation=e.captureWorkerPoolOperation;
@@ -1,4 +1,4 @@
1
- import { c as e } from "./workerPoolSpanCapture-D0-0Z0Jw.js";
1
+ import { c as e } from "./workerPoolSpanCapture-B5KN-q4b.js";
2
2
  export {
3
3
  e as captureWorkerPoolOperation
4
4
  };