@lunora/observability 1.0.0-alpha.102 → 1.0.0-alpha.104

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.
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{AUTH_METRICS_BUCKETS_TABLE as t,AUTH_METRICS_BUCKET_MS as T,AUTH_METRICS_BUCKET_RETENTION as o,AUTH_METRICS_TABLE as a,ensureAuthMetricsTables as s,readAuthMetrics as E,recordAuthEvent as _}from"./packem_shared/AUTH_METRICS_BUCKETS_TABLE-CeplWoRm.mjs";import{createMetrics as S,createSpanCollector as I,createTracedFetch as i,createTracer as n,dispatchRootSpan as M}from"./packem_shared/createMetrics-Lh0oGuDt.mjs";import{createDatabaseTally as A,formatTally as C,instrumentDatabase as N}from"./packem_shared/createDatabaseTally-j6FBQgYe.mjs";import{FUNCTION_METRICS_BUCKETS_TABLE as f,FUNCTION_METRICS_BUCKET_MS as U,FUNCTION_METRICS_BUCKET_RETENTION as d,FUNCTION_METRICS_INDEX_TABLE as R,FUNCTION_METRICS_MAX_PATHS as L,FUNCTION_METRICS_READ_LIMIT as m,FUNCTION_METRICS_SCANS_TABLE as x,FUNCTION_METRICS_TABLE as B,ensureFunctionMetricsTables as F,mergeScanAttribution as l,readFunctionMetricBuckets as g,readFunctionMetricIndexHits as O,readFunctionMetricScans as H,readFunctionMetrics as y,readFunctionMetricsTotals as b,recordFunctionMetric as D}from"./packem_shared/FUNCTION_METRICS_BUCKETS_TABLE-ChlIe0vF.mjs";import{DEFAULT_EXPLAIN_ISSUE_MODEL as K,explainIssue as q,parseExplainIssueArgs as v}from"./packem_shared/DEFAULT_EXPLAIN_ISSUE_MODEL-BkFTgdkd.mjs";import{ISSUE_SEVERITIES as G,ISSUE_STATE_TABLE as X,ISSUE_STATUSES as P,upsertIssueState as k}from"./packem_shared/ISSUE_SEVERITIES-gLC4VEPQ.mjs";import{LogBuffer as j}from"./packem_shared/LogBuffer-BmD4CfV0.mjs";import{M as z}from"./packem_shared/metric-buffer-Bx0XbypU.mjs";import{readMetricHistory as W,recordMetricHistory as Y}from"./packem_shared/readMetricHistory-TKfnwFNv.mjs";import{readQueryInsights as $,readQueryMetrics as ee,recordQueryMetric as re}from"./packem_shared/readQueryInsights-8nYLTftS.mjs";import{R as Te,a as oe,e as ae,b as se,c as Ee,p as _e,r as ce,d as Se,f as Ie}from"./packem_shared/request-log-BujFR0De.mjs";import{MIN_ADMIN_TOKEN_LENGTH as ne,MIN_AUTH_SECRET_LENGTH as Me,buildSecurityAudit as ue}from"./packem_shared/MIN_ADMIN_TOKEN_LENGTH-DSOQ6rno.mjs";import{SpanBuffer as Ce,foldTraces as Ne}from"./packem_shared/SpanBuffer-DnYOc8uk.mjs";import{findDanglingReferences as fe}from"./packem_shared/findDanglingReferences-BuanX4k7.mjs";import{r as de}from"./packem_shared/trace-context-d_EfGPSZ.mjs";export{t as AUTH_METRICS_BUCKETS_TABLE,T as AUTH_METRICS_BUCKET_MS,o as AUTH_METRICS_BUCKET_RETENTION,a as AUTH_METRICS_TABLE,K as DEFAULT_EXPLAIN_ISSUE_MODEL,f as FUNCTION_METRICS_BUCKETS_TABLE,U as FUNCTION_METRICS_BUCKET_MS,d as FUNCTION_METRICS_BUCKET_RETENTION,R as FUNCTION_METRICS_INDEX_TABLE,L as FUNCTION_METRICS_MAX_PATHS,m as FUNCTION_METRICS_READ_LIMIT,x as FUNCTION_METRICS_SCANS_TABLE,B as FUNCTION_METRICS_TABLE,G as ISSUE_SEVERITIES,X as ISSUE_STATE_TABLE,P as ISSUE_STATUSES,j as LogBuffer,ne as MIN_ADMIN_TOKEN_LENGTH,Me as MIN_AUTH_SECRET_LENGTH,z as MetricBuffer,Te as REQUEST_LOG_TABLE,Ce as SpanBuffer,oe as appendRequestLogEntry,ue as buildSecurityAudit,A as createDatabaseTally,S as createMetrics,I as createSpanCollector,i as createTracedFetch,n as createTracer,M as dispatchRootSpan,ae as emitLogEvent,se as emitRequestLogEvent,s as ensureAuthMetricsTables,F as ensureFunctionMetricsTables,Ee as ensureRequestLogTable,q as explainIssue,fe as findDanglingReferences,Ne as foldTraces,C as formatTally,N as instrumentDatabase,l as mergeScanAttribution,v as parseExplainIssueArgs,_e as parseLogArgs,E as readAuthMetrics,ce as readErrorIssues,g as readFunctionMetricBuckets,O as readFunctionMetricIndexHits,H as readFunctionMetricScans,y as readFunctionMetrics,b as readFunctionMetricsTotals,W as readMetricHistory,$ as readQueryInsights,ee as readQueryMetrics,Se as readRequestLog,_ as recordAuthEvent,D as recordFunctionMetric,Y as recordMetricHistory,re as recordQueryMetric,Ie as redactArgs,de as resolveTraceAnchor,k as upsertIssueState};
1
+ import{AUTH_METRICS_BUCKETS_TABLE as t,AUTH_METRICS_BUCKET_MS as T,AUTH_METRICS_BUCKET_RETENTION as o,AUTH_METRICS_TABLE as a,ensureAuthMetricsTables as s,readAuthMetrics as E,recordAuthEvent as _}from"./packem_shared/AUTH_METRICS_BUCKETS_TABLE-C-qbQA-w.mjs";import{createMetrics as S,createSpanCollector as I,createTracedFetch as i,createTracer as n,dispatchRootSpan as M}from"./packem_shared/createMetrics-BmF7DdTk.mjs";import{createDatabaseTally as A,formatTally as C,instrumentDatabase as N}from"./packem_shared/createDatabaseTally-C0ViFQDq.mjs";import{FUNCTION_METRICS_BUCKETS_TABLE as f,FUNCTION_METRICS_BUCKET_MS as U,FUNCTION_METRICS_BUCKET_RETENTION as d,FUNCTION_METRICS_INDEX_TABLE as R,FUNCTION_METRICS_MAX_PATHS as L,FUNCTION_METRICS_READ_LIMIT as m,FUNCTION_METRICS_SCANS_TABLE as x,FUNCTION_METRICS_TABLE as B,ensureFunctionMetricsTables as F,mergeScanAttribution as l,readFunctionMetricBuckets as g,readFunctionMetricIndexHits as O,readFunctionMetricScans as H,readFunctionMetrics as y,readFunctionMetricsTotals as b,recordFunctionMetric as D}from"./packem_shared/FUNCTION_METRICS_BUCKETS_TABLE-ChlIe0vF.mjs";import{DEFAULT_EXPLAIN_ISSUE_MODEL as K,explainIssue as q,parseExplainIssueArgs as v}from"./packem_shared/DEFAULT_EXPLAIN_ISSUE_MODEL-BkFTgdkd.mjs";import{ISSUE_SEVERITIES as G,ISSUE_STATE_TABLE as X,ISSUE_STATUSES as P,upsertIssueState as k}from"./packem_shared/ISSUE_SEVERITIES-0SJ0glV4.mjs";import{LogBuffer as j}from"./packem_shared/LogBuffer-BmD4CfV0.mjs";import{M as z}from"./packem_shared/metric-buffer-Bx0XbypU.mjs";import{readMetricHistory as W,recordMetricHistory as Y}from"./packem_shared/readMetricHistory-TKfnwFNv.mjs";import{readQueryInsights as $,readQueryMetrics as ee,recordQueryMetric as re}from"./packem_shared/readQueryInsights-DkQfxGfP.mjs";import{R as Te,a as oe,e as ae,b as se,c as Ee,p as _e,r as ce,d as Se,f as Ie}from"./packem_shared/request-log-ClXupUgG.mjs";import{MIN_ADMIN_TOKEN_LENGTH as ne,MIN_AUTH_SECRET_LENGTH as Me,buildSecurityAudit as ue}from"./packem_shared/MIN_ADMIN_TOKEN_LENGTH-DSOQ6rno.mjs";import{SpanBuffer as Ce,foldTraces as Ne}from"./packem_shared/SpanBuffer-DnYOc8uk.mjs";import{findDanglingReferences as fe}from"./packem_shared/findDanglingReferences-BaOyIdxz.mjs";import{r as de}from"./packem_shared/trace-context-d_EfGPSZ.mjs";export{t as AUTH_METRICS_BUCKETS_TABLE,T as AUTH_METRICS_BUCKET_MS,o as AUTH_METRICS_BUCKET_RETENTION,a as AUTH_METRICS_TABLE,K as DEFAULT_EXPLAIN_ISSUE_MODEL,f as FUNCTION_METRICS_BUCKETS_TABLE,U as FUNCTION_METRICS_BUCKET_MS,d as FUNCTION_METRICS_BUCKET_RETENTION,R as FUNCTION_METRICS_INDEX_TABLE,L as FUNCTION_METRICS_MAX_PATHS,m as FUNCTION_METRICS_READ_LIMIT,x as FUNCTION_METRICS_SCANS_TABLE,B as FUNCTION_METRICS_TABLE,G as ISSUE_SEVERITIES,X as ISSUE_STATE_TABLE,P as ISSUE_STATUSES,j as LogBuffer,ne as MIN_ADMIN_TOKEN_LENGTH,Me as MIN_AUTH_SECRET_LENGTH,z as MetricBuffer,Te as REQUEST_LOG_TABLE,Ce as SpanBuffer,oe as appendRequestLogEntry,ue as buildSecurityAudit,A as createDatabaseTally,S as createMetrics,I as createSpanCollector,i as createTracedFetch,n as createTracer,M as dispatchRootSpan,ae as emitLogEvent,se as emitRequestLogEvent,s as ensureAuthMetricsTables,F as ensureFunctionMetricsTables,Ee as ensureRequestLogTable,q as explainIssue,fe as findDanglingReferences,Ne as foldTraces,C as formatTally,N as instrumentDatabase,l as mergeScanAttribution,v as parseExplainIssueArgs,_e as parseLogArgs,E as readAuthMetrics,ce as readErrorIssues,g as readFunctionMetricBuckets,O as readFunctionMetricIndexHits,H as readFunctionMetricScans,y as readFunctionMetrics,b as readFunctionMetricsTotals,W as readMetricHistory,$ as readQueryInsights,ee as readQueryMetrics,Se as readRequestLog,_ as recordAuthEvent,D as recordFunctionMetric,Y as recordMetricHistory,re as recordQueryMetric,Ie as redactArgs,de as resolveTraceAnchor,k as upsertIssueState};
@@ -19,4 +19,4 @@ import{s as n}from"./prune-marker-B4An9Nuj.mjs";import{r as e}from"./run-sql-0aP
19
19
  failures = failures + excluded.failures`,T,E),n(t,T)&&e(t,`DELETE FROM "${r}"
20
20
  WHERE bucket_ms <= (
21
21
  SELECT MAX(bucket_ms) - ? FROM "${r}"
22
- )`,N*c)},S=t=>{m(t);const s=e(t,`SELECT attempts, failures, since_ms FROM "${u}" WHERE key = ?`,_).toArray()[0],E=s?.attempts??0,T=s?.failures??0,o=s?.since_ms??0,i=e(t,`SELECT bucket_ms, attempts, failures FROM "${r}" ORDER BY bucket_ms ASC`).toArray().map(a=>({attempts:a.attempts,bucketMs:a.bucket_ms,failures:a.failures}));return{attempts:E,failureRate:E===0?0:T/E,failures:T,history:i,sinceMs:o}};export{r as AUTH_METRICS_BUCKETS_TABLE,c as AUTH_METRICS_BUCKET_MS,N as AUTH_METRICS_BUCKET_RETENTION,_ as AUTH_METRICS_ROW_KEY,u as AUTH_METRICS_TABLE,m as ensureAuthMetricsTables,S as readAuthMetrics,I as recordAuthEvent};
22
+ )`,N*c)},S=t=>{m(t);const s=e(t,`SELECT attempts, failures, since_ms FROM "${u}" WHERE key = ?`,_).toArray()[0],E=s?.attempts??0,T=s?.failures??0,o=s?.since_ms??0,i=e(t,`SELECT bucket_ms, attempts, failures FROM "${r}" ORDER BY bucket_ms ASC`).toArray().map(a=>({attempts:a.attempts,bucketMs:a.bucket_ms,failures:a.failures}));return{attempts:E,failureRate:E===0?0:T/E,failures:T,history:i,sinceMs:o}};export{r as AUTH_METRICS_BUCKETS_TABLE,c as AUTH_METRICS_BUCKET_MS,N as AUTH_METRICS_BUCKET_RETENTION,u as AUTH_METRICS_TABLE,m as ensureAuthMetricsTables,S as readAuthMetrics,I as recordAuthEvent};
@@ -12,4 +12,4 @@ import{r as T}from"./run-sql-0aPgJkIw.mjs";const S="__lunora_issue_state__",y=10
12
12
  assignee = CASE WHEN ? = 1 THEN NULL ELSE COALESCE(?, assignee) END,
13
13
  severity = CASE WHEN ? = 1 THEN NULL ELSE COALESCE(?, severity) END,
14
14
  updated_at = ?,
15
- updated_by = ?`,t,e,u,r,E,c,e,d,u,o,r,E,c);const[_]=T(s,`SELECT hash, status, assignee, severity, updated_at, updated_by FROM "${S}" WHERE hash = ?`,t).toArray();return _===void 0?{hash:t,status:e??"open",updatedAt:E,...n===void 0?{}:{updatedBy:n}}:L(_)};export{y as DEFAULT_HASH_QUERY_BATCH,g as ISSUE_SEVERITIES,S as ISSUE_STATE_TABLE,h as ISSUE_STATUSES,l as ensureIssueStateTable,p as readIssueStates,v as upsertIssueState};
15
+ updated_by = ?`,t,e,u,r,E,c,e,d,u,o,r,E,c);const[_]=T(s,`SELECT hash, status, assignee, severity, updated_at, updated_by FROM "${S}" WHERE hash = ?`,t).toArray();return _===void 0?{hash:t,status:e??"open",updatedAt:E,...n===void 0?{}:{updatedBy:n}}:L(_)};export{g as ISSUE_SEVERITIES,S as ISSUE_STATE_TABLE,h as ISSUE_STATUSES,l as ensureIssueStateTable,p as readIssueStates,v as upsertIssueState};
@@ -1 +1 @@
1
- import{h as t,R as o,a as g,e as E,b as L,c as R,p as d,r as p,d as n,f as u,g as T,i}from"./request-log-BujFR0De.mjs";import"./ISSUE_SEVERITIES-gLC4VEPQ.mjs";import"./run-sql-0aPgJkIw.mjs";export{t as REQUEST_LOG_RETENTION,o as REQUEST_LOG_TABLE,g as appendRequestLogEntry,E as emitLogEvent,L as emitRequestLogEvent,R as ensureRequestLogTable,d as parseLogArgs,p as readErrorIssues,n as readRequestLog,u as redactArgs,T as redactSecrets,i as renderLogMessage};
1
+ import{h as t,R as o,a as g,e as E,b as L,c as R,p as d,r as p,d as n,f as u,g as T,i}from"./request-log-ClXupUgG.mjs";import"./ISSUE_SEVERITIES-0SJ0glV4.mjs";import"./run-sql-0aPgJkIw.mjs";export{t as REQUEST_LOG_RETENTION,o as REQUEST_LOG_TABLE,g as appendRequestLogEntry,E as emitLogEvent,L as emitRequestLogEvent,R as ensureRequestLogTable,d as parseLogArgs,p as readErrorIssues,n as readRequestLog,u as redactArgs,T as redactSecrets,i as renderLogMessage};
@@ -1 +1 @@
1
- import{o as m,t as b}from"./trace-context-d_EfGPSZ.mjs";import{f as M}from"./request-log-BujFR0De.mjs";const y=100,T=new Set(["aggregate","count","delete","deleteMany","deleteWhere","findFirst","findFirstOrThrow","findMany","get","groupBy","insert","insertMany","insertManyUnsafe","lookupById","patch","patchMany","patchWhere","rank","rankBefore","rankPage","rankPageRows","related","replace","restore"]),w=new Set(["aggregate","count","deleteWhere","findFirst","findFirstOrThrow","findMany","groupBy","insert","insertMany","insertManyUnsafe","patchWhere","rank","rankBefore","rankPage","rankPageRows"]),S=(e,t)=>{if(!w.has(e))return;const n=t[0];return typeof n=="string"&&n.length>0?n:void 0},k=e=>e instanceof Error?e.message:typeof e=="string"?e:JSON.stringify(e)??String(e),E=e=>{const{deps:t,durationMs:n,failure:a,operation:s,startTs:r,table:o}=e;return{attributes:{"db.operation.name":s,...o===void 0?{}:{"db.collection.name":o},"db.system.name":"sqlite"},durationMs:n,...a===void 0?{}:{error:{message:M(k(a),t.captureRaw),type:b(a)}},functionPath:t.functionPath,kind:"client",name:o===void 0?`db.${s}`:`db.${s} ${o}`,ok:a===void 0,parentSpanId:t.anchor.rootSpanId,shardKey:t.shardKey,spanId:m(8),startTs:r,traceId:t.anchor.traceId,userId:t.userId()}},v=(e,t)=>{if(t.mode==="off")return e;const{tally:n}=t,a=new Map;return new Proxy(e,{get(s,r,o){const c=Reflect.get(s,r,o);if(typeof r!="string"||typeof c!="function"||!T.has(r))return c;const f=a.get(r);if(f!==void 0)return f;const g=c,u=async(...p)=>{const l=Date.now(),h=S(r,p);let d;try{return await g.apply(s,p)}catch(i){throw d=i,i}finally{const i=Date.now()-l;n.calls+=1,n.durationMs+=i,n.perOperation[r]=(n.perOperation[r]??0)+1,d!==void 0&&(n.errors+=1);try{t.mode==="spans"&&(n.spansEmitted>=y?n.spansTruncated=!0:(n.spansEmitted+=1,t.record(E({deps:t,durationMs:i,failure:d,operation:r,startTs:l,table:h}))))}catch{}}};return a.set(r,u),u}})},D=()=>({calls:0,durationMs:0,errors:0,perOperation:{},spansEmitted:0,spansTruncated:!1}),P=e=>{const t={"db.calls":e.calls,"db.duration_ms":e.durationMs};e.errors>0&&(t["db.errors"]=e.errors),e.spansTruncated&&(t["db.spans_truncated"]=!0);for(const[n,a]of Object.entries(e.perOperation))t[`db.op.${n}`]=a;return t};export{D as createDatabaseTally,P as formatTally,v as instrumentDatabase};
1
+ import{o as m,t as b}from"./trace-context-d_EfGPSZ.mjs";import{f as M}from"./request-log-ClXupUgG.mjs";const y=100,T=new Set(["aggregate","count","delete","deleteMany","deleteWhere","findFirst","findFirstOrThrow","findMany","get","groupBy","insert","insertMany","insertManyUnsafe","lookupById","patch","patchMany","patchWhere","rank","rankBefore","rankPage","rankPageRows","related","replace","restore"]),w=new Set(["aggregate","count","deleteWhere","findFirst","findFirstOrThrow","findMany","groupBy","insert","insertMany","insertManyUnsafe","patchWhere","rank","rankBefore","rankPage","rankPageRows"]),S=(e,t)=>{if(!w.has(e))return;const n=t[0];return typeof n=="string"&&n.length>0?n:void 0},k=e=>e instanceof Error?e.message:typeof e=="string"?e:JSON.stringify(e)??String(e),E=e=>{const{deps:t,durationMs:n,failure:a,operation:s,startTs:r,table:o}=e;return{attributes:{"db.operation.name":s,...o===void 0?{}:{"db.collection.name":o},"db.system.name":"sqlite"},durationMs:n,...a===void 0?{}:{error:{message:M(k(a),t.captureRaw),type:b(a)}},functionPath:t.functionPath,kind:"client",name:o===void 0?`db.${s}`:`db.${s} ${o}`,ok:a===void 0,parentSpanId:t.anchor.rootSpanId,shardKey:t.shardKey,spanId:m(8),startTs:r,traceId:t.anchor.traceId,userId:t.userId()}},v=(e,t)=>{if(t.mode==="off")return e;const{tally:n}=t,a=new Map;return new Proxy(e,{get(s,r,o){const c=Reflect.get(s,r,o);if(typeof r!="string"||typeof c!="function"||!T.has(r))return c;const f=a.get(r);if(f!==void 0)return f;const g=c,u=async(...p)=>{const l=Date.now(),h=S(r,p);let d;try{return await g.apply(s,p)}catch(i){throw d=i,i}finally{const i=Date.now()-l;n.calls+=1,n.durationMs+=i,n.perOperation[r]=(n.perOperation[r]??0)+1,d!==void 0&&(n.errors+=1);try{t.mode==="spans"&&(n.spansEmitted>=y?n.spansTruncated=!0:(n.spansEmitted+=1,t.record(E({deps:t,durationMs:i,failure:d,operation:r,startTs:l,table:h}))))}catch{}}};return a.set(r,u),u}})},D=()=>({calls:0,durationMs:0,errors:0,perOperation:{},spansEmitted:0,spansTruncated:!1}),P=e=>{const t={"db.calls":e.calls,"db.duration_ms":e.durationMs};e.errors>0&&(t["db.errors"]=e.errors),e.spansTruncated&&(t["db.spans_truncated"]=!0);for(const[n,a]of Object.entries(e.perOperation))t[`db.op.${n}`]=a;return t};export{D as createDatabaseTally,P as formatTally,v as instrumentDatabase};
@@ -1 +1 @@
1
- import{f as O,g as A,n as I}from"./request-log-BujFR0De.mjs";import{L as g,o as K,b as D,t as P,O as U}from"./trace-context-d_EfGPSZ.mjs";const F=/[\w.-]/u,q=t=>{let e="";for(const r of t)e+=F.test(r)?r:"_";return e},C=t=>{if(typeof t.name!="string"||t.name.length===0)throw new TypeError("recordEvaluation requires a non-empty `name`");if(typeof t.score!="number"||!Number.isFinite(t.score))throw new TypeError("recordEvaluation `score` must be a finite number");const e=q(t.name),r={[`gen_ai.evaluation.${e}.score`]:t.score};return t.label!==void 0&&(r[`gen_ai.evaluation.${e}.label`]=t.label),r},X=t=>{const e=Object.keys(t);if(e.length===0||!e.every(o=>o==="attributes"||o==="kind"||o==="links"))return!1;const{kind:r}=t;return r===void 0||Object.hasOwn(U,r)},B=128,V=128,L=128,m=(t,e)=>{if(e===void 0)return;let r=Object.keys(t).length;for(const[o,s]of Object.entries(e)){const n=!Object.hasOwn(t,o);n&&r>=L||(n&&(r+=1),t[o]=s)}},H=t=>{const e=I(t);if(e===void 0||Object.keys(e).length<=L)return e;const r={};return m(r,e),r},G=t=>{try{const e=new URL(t);return`${e.protocol}//${e.host}${e.pathname}`}catch{return t}},J=t=>{try{return new URL(t).host}catch{return t}},Q=(t,e)=>{try{return t(new URL(e))}catch{return!1}},W=t=>t===void 0?{}:X(t)?t:{attributes:t},Y=(t,e)=>{if(t.isTraced){t.setAttribute(g.functionPath,e.functionPath),t.setAttribute(g.ok,e.ok),t.setAttribute(g.durationMs,e.durationMs),e.shardKey!==void 0&&t.setAttribute(g.shardKey,e.shardKey),e.userId!==void 0&&t.setAttribute(g.userId,e.userId),e.error!==void 0&&(t.setAttribute(g.errorType,e.error.type),t.setAttribute(g.errorMessage,e.error.message));for(const[r,o]of Object.entries(e.attributes))(typeof o=="boolean"||typeof o=="number"||typeof o=="string")&&t.setAttribute(`lunora.attr.${r}`,o)}},Z=(t,e=!1)=>{const r={attributes:{},events:[],links:[]},o={spanContext:()=>t,addEvent:(s,n)=>{if(r.events.length>=B)return;const a=A(H(n),e);r.events.push({...a===void 0?{}:{attributes:a},name:s,ts:Date.now()})},addLink:s=>{if(r.links.length>=V)return;const n=A(H(s.attributes),e);r.links.push({...n===void 0?{}:{attributes:n},spanId:s.spanId,traceId:s.traceId})},recordEvaluation:s=>{m(r.attributes,I(C(s)))},recordException:s=>{const n=s instanceof Error?s.message:String(s);o.addEvent("exception",{"exception.message":O(n,e),...e&&s instanceof Error&&typeof s.stack=="string"?{"exception.stacktrace":s.stack}:{},"exception.type":P(s)})},setAttribute:(s,n)=>{m(r.attributes,I({[s]:n}))},setAttributes:s=>{m(r.attributes,I(s))}};return{collected:r,handle:o}},rt=t=>{const{anchor:e,captureRaw:r=!1,fuseHostSpans:o,functionPath:s,record:n,resolveHostTracing:a,shardKey:c,userId:p}=t,d=y=>async(k,T,u,M)=>{const l=M?.spanId??K(8),w=M?.parentSpanId??y,i=Date.now(),b=W(u),x=I(b.attributes),{collected:E,handle:z}=Z({...e.sampled===void 0?{}:{sampled:e.sampled},spanId:l,traceId:e.traceId},r),$=async S=>{let f=!0,v;try{return await T(d(l),z)}catch(h){f=!1;const _=h instanceof Error?h.message:String(h);throw v={message:O(_,r),type:P(h)},h}finally{const h=Date.now()-i,_=p(),N={};m(N,x),m(N,E.attributes);const R=A(N,r),j=[...b.links??[],...E.links];try{n({...Object.keys(R).length===0?{}:{attributes:R},durationMs:h,...E.events.length===0?{}:{events:E.events},...v===void 0?{}:{error:v},functionPath:s,...b.kind===void 0||b.kind==="internal"?{}:{kind:b.kind},...j.length===0?{}:{links:j},name:k,ok:f,parentSpanId:w,shardKey:c,spanId:l,startTs:i,traceId:e.traceId,userId:_})}catch{}if(S!==void 0)try{Y(S,{attributes:R,durationMs:h,error:v,functionPath:s,ok:f,shardKey:c,userId:_})}catch{}}};if(o===!0&&a!==void 0){let S=!1;try{const f=await a();if(f!==void 0&&typeof f.enterSpan=="function")return await f.enterSpan(k,v=>(S=!0,$(v)))}catch(f){if(S)throw f}}return await $()};return d(e.rootSpanId)},st=(t,e)=>{const{anchor:r,captureRaw:o=!1,functionPath:s,propagate:n=!0,record:a,shardKey:c,userId:p}=t;return async(d,y)=>{const k=K(8),T=Date.now(),u=new Request(d,y);(typeof n=="function"?Q(n,u.url):n)&&u.headers.set("traceparent",D(r.traceId,k,r.sampled??!0));let l,w;try{const i=await e(u);return w=i.status,i.ok||(l={message:`HTTP ${String(i.status)}`,type:`HTTP_${String(i.status)}`}),i}catch(i){const b=i instanceof Error?i.message:String(i);throw l={message:O(b,o),type:P(i)},i}finally{try{a({attributes:{"http.request.method":u.method,...w===void 0?{}:{"http.response.status_code":w},"url.full":G(u.url)},durationMs:Date.now()-T,...l===void 0?{}:{error:l},functionPath:s,kind:"client",name:`${u.method} ${J(u.url)}`,ok:l===void 0,parentSpanId:r.rootSpanId,shardKey:c,spanId:k,startTs:T,traceId:r.traceId,userId:p()})}catch{}}}},nt=t=>{const{functionPath:e,record:r,shardKey:o}=t,s=(n,a,c,p)=>{if(!Number.isFinite(c))return;const d=A(I(p));try{r({...d===void 0?{}:{attributes:d},functionPath:e,kind:n,name:a,shardKey:o,ts:Date.now(),value:c})}catch{}};return{count:(n,a=1,c)=>{s("counter",n,a,c)},gauge:(n,a,c)=>{s("gauge",n,a,c)},record:(n,a,c)=>{s("histogram",n,a,c)}}},ot=t=>{const{anchor:e,captureRaw:r=!1,collected:o,durationMs:s,failure:n,functionPath:a,shardKey:c,startTs:p,userId:d}=t,y=A(o?.attributes??{},r);return{...Object.keys(y).length===0?{}:{attributes:y},dispatch:!0,durationMs:s,...o===void 0||o.events.length===0?{}:{events:o.events},...n===void 0?{}:{error:{message:O(n.thrown instanceof Error?n.thrown.message:String(n.thrown),r),type:P(n.thrown)}},functionPath:a,...o===void 0||o.links.length===0?{}:{links:o.links},name:a,ok:n===void 0,parentSpanId:"",shardKey:c,spanId:e.rootSpanId,startTs:p,traceId:e.traceId,userId:d}};export{Y as applyHostSpanAttributes,nt as createMetrics,Z as createSpanCollector,st as createTracedFetch,rt as createTracer,ot as dispatchRootSpan};
1
+ import{f as O,g as A,n as I}from"./request-log-ClXupUgG.mjs";import{L as g,o as K,b as D,t as P,O as U}from"./trace-context-d_EfGPSZ.mjs";const F=/[\w.-]/u,q=t=>{let e="";for(const r of t)e+=F.test(r)?r:"_";return e},C=t=>{if(typeof t.name!="string"||t.name.length===0)throw new TypeError("recordEvaluation requires a non-empty `name`");if(typeof t.score!="number"||!Number.isFinite(t.score))throw new TypeError("recordEvaluation `score` must be a finite number");const e=q(t.name),r={[`gen_ai.evaluation.${e}.score`]:t.score};return t.label!==void 0&&(r[`gen_ai.evaluation.${e}.label`]=t.label),r},X=t=>{const e=Object.keys(t);if(e.length===0||!e.every(o=>o==="attributes"||o==="kind"||o==="links"))return!1;const{kind:r}=t;return r===void 0||Object.hasOwn(U,r)},B=128,V=128,L=128,m=(t,e)=>{if(e===void 0)return;let r=Object.keys(t).length;for(const[o,s]of Object.entries(e)){const n=!Object.hasOwn(t,o);n&&r>=L||(n&&(r+=1),t[o]=s)}},H=t=>{const e=I(t);if(e===void 0||Object.keys(e).length<=L)return e;const r={};return m(r,e),r},G=t=>{try{const e=new URL(t);return`${e.protocol}//${e.host}${e.pathname}`}catch{return t}},J=t=>{try{return new URL(t).host}catch{return t}},Q=(t,e)=>{try{return t(new URL(e))}catch{return!1}},W=t=>t===void 0?{}:X(t)?t:{attributes:t},Y=(t,e)=>{if(t.isTraced){t.setAttribute(g.functionPath,e.functionPath),t.setAttribute(g.ok,e.ok),t.setAttribute(g.durationMs,e.durationMs),e.shardKey!==void 0&&t.setAttribute(g.shardKey,e.shardKey),e.userId!==void 0&&t.setAttribute(g.userId,e.userId),e.error!==void 0&&(t.setAttribute(g.errorType,e.error.type),t.setAttribute(g.errorMessage,e.error.message));for(const[r,o]of Object.entries(e.attributes))(typeof o=="boolean"||typeof o=="number"||typeof o=="string")&&t.setAttribute(`lunora.attr.${r}`,o)}},Z=(t,e=!1)=>{const r={attributes:{},events:[],links:[]},o={spanContext:()=>t,addEvent:(s,n)=>{if(r.events.length>=B)return;const a=A(H(n),e);r.events.push({...a===void 0?{}:{attributes:a},name:s,ts:Date.now()})},addLink:s=>{if(r.links.length>=V)return;const n=A(H(s.attributes),e);r.links.push({...n===void 0?{}:{attributes:n},spanId:s.spanId,traceId:s.traceId})},recordEvaluation:s=>{m(r.attributes,I(C(s)))},recordException:s=>{const n=s instanceof Error?s.message:String(s);o.addEvent("exception",{"exception.message":O(n,e),...e&&s instanceof Error&&typeof s.stack=="string"?{"exception.stacktrace":s.stack}:{},"exception.type":P(s)})},setAttribute:(s,n)=>{m(r.attributes,I({[s]:n}))},setAttributes:s=>{m(r.attributes,I(s))}};return{collected:r,handle:o}},rt=t=>{const{anchor:e,captureRaw:r=!1,fuseHostSpans:o,functionPath:s,record:n,resolveHostTracing:a,shardKey:c,userId:p}=t,d=y=>async(k,T,u,M)=>{const l=M?.spanId??K(8),w=M?.parentSpanId??y,i=Date.now(),b=W(u),x=I(b.attributes),{collected:E,handle:z}=Z({...e.sampled===void 0?{}:{sampled:e.sampled},spanId:l,traceId:e.traceId},r),$=async S=>{let f=!0,v;try{return await T(d(l),z)}catch(h){f=!1;const _=h instanceof Error?h.message:String(h);throw v={message:O(_,r),type:P(h)},h}finally{const h=Date.now()-i,_=p(),N={};m(N,x),m(N,E.attributes);const R=A(N,r),j=[...b.links??[],...E.links];try{n({...Object.keys(R).length===0?{}:{attributes:R},durationMs:h,...E.events.length===0?{}:{events:E.events},...v===void 0?{}:{error:v},functionPath:s,...b.kind===void 0||b.kind==="internal"?{}:{kind:b.kind},...j.length===0?{}:{links:j},name:k,ok:f,parentSpanId:w,shardKey:c,spanId:l,startTs:i,traceId:e.traceId,userId:_})}catch{}if(S!==void 0)try{Y(S,{attributes:R,durationMs:h,error:v,functionPath:s,ok:f,shardKey:c,userId:_})}catch{}}};if(o===!0&&a!==void 0){let S=!1;try{const f=await a();if(f!==void 0&&typeof f.enterSpan=="function")return await f.enterSpan(k,v=>(S=!0,$(v)))}catch(f){if(S)throw f}}return await $()};return d(e.rootSpanId)},st=(t,e)=>{const{anchor:r,captureRaw:o=!1,functionPath:s,propagate:n=!0,record:a,shardKey:c,userId:p}=t;return async(d,y)=>{const k=K(8),T=Date.now(),u=new Request(d,y);(typeof n=="function"?Q(n,u.url):n)&&u.headers.set("traceparent",D(r.traceId,k,r.sampled??!0));let l,w;try{const i=await e(u);return w=i.status,i.ok||(l={message:`HTTP ${String(i.status)}`,type:`HTTP_${String(i.status)}`}),i}catch(i){const b=i instanceof Error?i.message:String(i);throw l={message:O(b,o),type:P(i)},i}finally{try{a({attributes:{"http.request.method":u.method,...w===void 0?{}:{"http.response.status_code":w},"url.full":G(u.url)},durationMs:Date.now()-T,...l===void 0?{}:{error:l},functionPath:s,kind:"client",name:`${u.method} ${J(u.url)}`,ok:l===void 0,parentSpanId:r.rootSpanId,shardKey:c,spanId:k,startTs:T,traceId:r.traceId,userId:p()})}catch{}}}},nt=t=>{const{functionPath:e,record:r,shardKey:o}=t,s=(n,a,c,p)=>{if(!Number.isFinite(c))return;const d=A(I(p));try{r({...d===void 0?{}:{attributes:d},functionPath:e,kind:n,name:a,shardKey:o,ts:Date.now(),value:c})}catch{}};return{count:(n,a=1,c)=>{s("counter",n,a,c)},gauge:(n,a,c)=>{s("gauge",n,a,c)},record:(n,a,c)=>{s("histogram",n,a,c)}}},ot=t=>{const{anchor:e,captureRaw:r=!1,collected:o,durationMs:s,failure:n,functionPath:a,shardKey:c,startTs:p,userId:d}=t,y=A(o?.attributes??{},r);return{...Object.keys(y).length===0?{}:{attributes:y},dispatch:!0,durationMs:s,...o===void 0||o.events.length===0?{}:{events:o.events},...n===void 0?{}:{error:{message:O(n.thrown instanceof Error?n.thrown.message:String(n.thrown),r),type:P(n.thrown)}},functionPath:a,...o===void 0||o.links.length===0?{}:{links:o.links},name:a,ok:n===void 0,parentSpanId:"",shardKey:c,spanId:e.rootSpanId,startTs:p,traceId:e.traceId,userId:d}};export{Y as applyHostSpanAttributes,nt as createMetrics,Z as createSpanCollector,st as createTracedFetch,rt as createTracer,ot as dispatchRootSpan};
@@ -1 +1 @@
1
- import{isInternalTableName as d}from"@lunora/shard-engine";const u=/^[A-Za-z_$][\w$]*$/u,_=e=>u.test(e)?e:`"${e.replaceAll("\\",String.raw`\\`).replaceAll('"',String.raw`\"`)}"`,A=e=>`"${e.replaceAll('"','""')}"`,l=5e3,m=500,p="__doc__",E=(e,t)=>d(t)?!1:e.exec("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ? LIMIT 1",t).toArray().length>0,S=(e,t)=>{const r=t.includes(e),c=t.includes(p);if(!(!r&&!c))return r?{expression:A(e),params:[]}:{expression:`json_extract(${A(p)}, ?)`,params:[`$.${_(e)}`]}},$=(e,t,r,c,i,a,s)=>{const n=S(c,i);if(n===void 0)return;const f=e.exec(`SELECT id, ${n.expression} AS ref FROM ${t} WHERE ${n.expression} IS NOT NULL AND ${n.expression} <> '' LIMIT ?`,...n.params,...n.params,...n.params,l+1).toArray();f.length>l&&(s.truncated=!0);for(const o of f.slice(0,l))if(s.scanned+=1,!a.has(o.ref)){if(s.references.length>=m){s.truncated=!0;continue}s.references.push({column:c,id:o.id,key:o.ref,table:r})}},L=(e,t,r)=>{const c=r instanceof Set?r:new Set(r),i={references:[],scanned:0,truncated:!1};for(const[a,s]of Object.entries(t)){if(!E(e,a))continue;const n=A(a),f=e.exec(`PRAGMA table_info(${n})`).toArray().map(o=>o.name);for(const o of s)$(e,n,a,o,f,c,i)}return i};export{m as DANGLING_RESULT_CAP,l as DANGLING_SCAN_CAP,L as findDanglingReferences};
1
+ import{isInternalTableName as d}from"@lunora/shard-engine";const u=/^[A-Za-z_$][\w$]*$/u,_=e=>u.test(e)?e:`"${e.replaceAll("\\",String.raw`\\`).replaceAll('"',String.raw`\"`)}"`,A=e=>`"${e.replaceAll('"','""')}"`,l=5e3,m=500,p="__doc__",E=(e,t)=>d(t)?!1:e.exec("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ? LIMIT 1",t).toArray().length>0,S=(e,t)=>{const r=t.includes(e),c=t.includes(p);if(!(!r&&!c))return r?{expression:A(e),params:[]}:{expression:`json_extract(${A(p)}, ?)`,params:[`$.${_(e)}`]}},$=(e,t,r,c,i,a,s)=>{const n=S(c,i);if(n===void 0)return;const f=e.exec(`SELECT id, ${n.expression} AS ref FROM ${t} WHERE ${n.expression} IS NOT NULL AND ${n.expression} <> '' LIMIT ?`,...n.params,...n.params,...n.params,l+1).toArray();f.length>l&&(s.truncated=!0);for(const o of f.slice(0,l))if(s.scanned+=1,!a.has(o.ref)){if(s.references.length>=m){s.truncated=!0;continue}s.references.push({column:c,id:o.id,key:o.ref,table:r})}},L=(e,t,r)=>{const c=r instanceof Set?r:new Set(r),i={references:[],scanned:0,truncated:!1};for(const[a,s]of Object.entries(t)){if(!E(e,a))continue;const n=A(a),f=e.exec(`PRAGMA table_info(${n})`).toArray().map(o=>o.name);for(const o of s)$(e,n,a,o,f,c,i)}return i};export{m as DANGLING_RESULT_CAP,L as findDanglingReferences};
@@ -29,4 +29,4 @@ import{r as a}from"./run-sql-0aPgJkIw.mjs";const F=2166136261,b=16777619,C=(t,e=
29
29
  exec_count = exec_count + excluded.exec_count,
30
30
  total_duration_ms = total_duration_ms + excluded.total_duration_ms,
31
31
  rows_read = rows_read + excluded.rows_read,
32
- rows_written = rows_written + excluded.rows_written`;a(t,l,u,s,r,o,_),Y(t,u,r,o,_,c,s)},K=t=>(w(t),a(t,`SELECT normalized_sql, exec_count, total_duration_ms, rows_read, rows_written FROM "${i}" ORDER BY total_duration_ms DESC`).toArray().map(r=>({execCount:r.exec_count,normalizedSql:r.normalized_sql,rowsRead:r.rows_read,rowsWritten:r.rows_written,totalDurationMs:r.total_duration_ms})));export{d as LATENCY_BUCKET_EDGES,m as QUERY_BUCKETS_TABLE,L as QUERY_BUCKET_MS,$ as QUERY_BUCKET_RETENTION,U as QUERY_METRICS_MAX_SQL_LEN,I as QUERY_METRICS_MAX_STATEMENTS,i as QUERY_METRICS_TABLE,g as ensureQueryBucketsTable,w as ensureQueryMetricsTable,f as hashStatement,y as latencyBucketIndex,p as normalizeSql,x as percentileFrom,B as pruneQueryBuckets,H as readQueryInsights,K as readQueryMetrics,Y as recordQueryBucket,P as recordQueryMetric};
32
+ rows_written = rows_written + excluded.rows_written`;a(t,l,u,s,r,o,_),Y(t,u,r,o,_,c,s)},K=t=>(w(t),a(t,`SELECT normalized_sql, exec_count, total_duration_ms, rows_read, rows_written FROM "${i}" ORDER BY total_duration_ms DESC`).toArray().map(r=>({execCount:r.exec_count,normalizedSql:r.normalized_sql,rowsRead:r.rows_read,rowsWritten:r.rows_written,totalDurationMs:r.total_duration_ms})));export{$ as QUERY_BUCKET_RETENTION,U as QUERY_METRICS_MAX_SQL_LEN,I as QUERY_METRICS_MAX_STATEMENTS,i as QUERY_METRICS_TABLE,p as normalizeSql,B as pruneQueryBuckets,H as readQueryInsights,K as readQueryMetrics,P as recordQueryMetric};
@@ -1,4 +1,4 @@
1
- import{fingerprintError as M}from"@lunora/fingerprint";import{createRedactor as G,standardRules as X}from"@visulima/redact";import{readIssueStates as z}from"./ISSUE_SEVERITIES-gLC4VEPQ.mjs";import{r as E}from"./run-sql-0aPgJkIw.mjs";const H=e=>{if(typeof e=="string")return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}},O=e=>typeof e=="boolean"||typeof e=="number"||typeof e=="string"?e:H(e),I=(e,t)=>{if(e===void 0&&t===void 0)return;const s={};if(t!==void 0)for(const[r,n]of Object.entries(t))s[r]=O(n);if(e!==void 0)for(const[r,n]of Object.entries(e))s[r]=O(n);return Object.keys(s).length===0?void 0:s},V=new Set(["auth","authorization","bearer","card","cc","cookie","credential","cvc","cvv","dsn","hmac","hotp","iban","jwt","kek","mnemonic","otp","pass","passcode","passphrase","passwd","password","pem","pin","pwd","salt","secret","session","sid","sig","signature","ssn","token","totp","verifier"]),J=new Set(["card","pass","pin","session"]),Z=new Set(["access","api","client","encryption","master","priv","private","secret","signing"]),K=new Set(["2fa","auth","authorization","backup","factor","hotp","mfa","otp","pin","recovery","reset","security","totp","verification","verify"]),B=new Set(["card no","connection string","database url","one time"]),Y=["accesskey","apikey","authorization","cookie","credential","mfacode","otpcode","passcode","passphrase","passwd","password","privatekey","secret","secretkey","sessionid","signature","token"],q=new Set(["again","b64","base","base64","bytes","confirm","confirmation","data","digest","encrypted","hash","hashed","header","hex","id","input","key","no","num","number","plain","plaintext","raw","repeat","str","string","text","value"]),Q=new Set(["count","counts","length","limit","limits","size","tokens","total","usage"]),ee=new Set(["max","min","num","total"]),T=4096,te=128,se=16384,u="<REDACTED>",re="[redaction budget exceeded]",ne=e=>e.replaceAll(/([a-z\d])([A-Z])/g,"$1 $2").replaceAll(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/[^a-z\d]+/).filter(t=>t.length>0),N=e=>e.length>3&&e.endsWith("s")&&!e.endsWith("ss")?e.slice(0,-1):e,oe=(e,t)=>{const s=N(e[t]),r=t>0?N(e[t-1]):void 0;if(V.has(s))return s;if(r!==void 0){if(s==="key"&&Z.has(r))return"key";if(s==="code"&&K.has(r))return"code";if(B.has(`${r} ${s}`))return`${r} ${s}`}return Y.some(n=>s.endsWith(n))?s:void 0},D=e=>{const t=ne(e);if(t.length===0)return"none";const s=Q.has(t.at(-1))||ee.has(t[0]);for(let r=t.length-1;r>=0;r-=1){const n=oe(t,r);if(n!==void 0)return s?"count-secret":t.slice(r+1).every(a=>q.has(a))?J.has(n)&&r===t.length-1?"scalar-secret":"secret":"none"}return"none"},ie=e=>typeof e=="boolean"||e===null||e===void 0?e:u,ae=e=>{const t=e.indexOf("://")+3,s=e.slice(t),r=s.split(/[?#]/,1)[0],n=r.lastIndexOf("@"),a=r.indexOf(":"),c=r.indexOf("/"),o=a!==-1&&/^\d+$/.test(r.slice(a+1,c===-1?void 0:c)),i=a!==-1&&!o&&(c===-1||a<c);if(n===-1&&i&&s.includes("@",r.length))return e.slice(0,t);const d=n!==-1&&(c===-1||n<c||a!==-1&&a<n&&!o);return`${e.slice(0,t)}${d?r.slice(n+1):r}`},ce=/\b[a-z][\d+.a-z-]{1,15}:\/\/[^\s"'<>()[\]{}]+/gi,de=/-----BEGIN ([A-Z ]{0,32}PRIVATE KEY)-----[\s\S]*?(?:-----END [A-Z ]{0,32}PRIVATE KEY-----|$)/g,le=/\b(Basic|Bearer|Digest)\s+[\w+/=.~-]{4,}/g,$=String.raw`%[\dA-Fa-f]{2}|\\(?:[bfnrt]|u[\dA-Fa-f]{4})`,C=[{body:String.raw`[\dA-Za-z]{10,}`,name:"Stripe secret or restricted key",prefix:String.raw`[rs]k_(?:live|test)_`},{body:String.raw`[\d+/=A-Za-z]{20,}`,name:"Stripe webhook secret",prefix:"whsec_"},{body:String.raw`[\dA-Za-z]{30,}`,name:"GitHub classic token (personal, OAuth, user/server-to-server, refresh)",prefix:"gh[oprsu]_"},{body:String.raw`\w{20,}`,name:"GitHub fine-grained token",prefix:"github_pat_"},{body:String.raw`[\w-]{20,}`,name:"GitLab personal, pipeline-trigger and deploy tokens",prefix:"gl(?:pat|ptt|dt)-"},{body:String.raw`[\dA-Za-z-]{10,}`,name:"Slack token",prefix:"xox[a-eprs]-"},{body:String.raw`\d-[\dA-Za-z-]{10,}`,name:"Slack app-level token",prefix:"xapp-"},{body:String.raw`[\dA-Z]{16}\b`,name:"AWS access-key id, long-lived and temporary",prefix:"(?:AKIA|ASIA)"},{body:String.raw`[\w-]{35}(?![\w-])`,name:"Google API key",prefix:"AIza"},{body:String.raw`[\w-]{24,}`,name:"Google OAuth client secret",prefix:"GOCSPX-"},{body:String.raw`[\w-]{20,}`,name:"Google OAuth access token",prefix:String.raw`ya29\.`},{body:String.raw`[\dA-Za-z]{36}\b`,name:"npm token",prefix:"npm_"},{body:String.raw`[\dA-Za-z]{30,}`,name:"Hugging Face token",prefix:"hf_"},{body:String.raw`[\dA-Fa-f]{32}\b`,name:"Shopify token",prefix:"shp(?:at|ca|pa|ss)_"},{body:String.raw`[\da-f]{64}\b`,name:"DigitalOcean token",prefix:"do[opr]_v1_"},{body:String.raw`[\w-]{20,}`,name:"OpenAI project/service/admin key, Anthropic key",prefix:"sk-(?:admin|ant|proj|svcacct)-"},{body:String.raw`[\dA-Za-z]{20}T3BlbkFJ[\dA-Za-z]{20}\b`,name:"OpenAI legacy key",prefix:"sk-"},{body:String.raw`[\w-]{22}\.[\w-]{43}(?![\w-])`,name:"SendGrid key",prefix:String.raw`SG\.`}],fe=String.raw`(?<=^|[^\w-]|${$})eyJ[\w-]{2,}\.[\w-]{2,}\.[\w-]*`,ue=new RegExp([...C.map(({body:e,prefix:t})=>String.raw`(?<=^|[^\dA-Za-z]|${$})${t}${e}`),fe].join("|"),"g"),ge=new RegExp([...C.map(({prefix:e})=>e),"eyJ"].join("|")),pe=/(\s|^)(-u|--user|--password|--pass|--token|--api-key)(\s+|=)[^\s"']+/g,S=/(?<![\w.-])(\\?["']?)([A-Za-z_][\w.-]{0,63})\1[ \t]{0,4}([:=])[ \t]{0,4}/g,L=/(?:basic|bearer|digest|token)\s+[^\s"&'),;\]}]+|\\"(?:[^"\\\n]|\\[^"])*(?:\\")?|"[^\n"]*"?|'[^\n']*'?|[^\s"&'),;\]}]+/iy,k=/(?:[ \t]+(?![A-Za-z_][\w.-]{0,63}[:=])[^\s,;)\]}]+)*/y,he=e=>{let t="",s=0;S.lastIndex=0;for(let r=S.exec(e);r!==null;r=S.exec(e)){const n=D(r[2]),a=r.index+r[0].length;L.lastIndex=a;const c=n==="none"?null:L.exec(e);if(c===null||n==="count-secret"&&/^["']?[\d.]+["']?$/.test(c[0])){S.lastIndex=Math.max(a,r.index+1);continue}const o=c[0],i=o.startsWith('\\"')?'\\"':o.startsWith('"')||o.startsWith("'")?o[0]:"";let d=a+o.length;i===""&&r[3]===":"&&(k.lastIndex=d,d+=k.exec(e)?.[0].length??0),t+=`${e.slice(s,a)}${i}${u}${o.length>i.length&&o.endsWith(i)?i:""}`,s=d,S.lastIndex=s}return t+e.slice(s)},Ee=/[:=@]|basic|bearer|digest|-u\b|--/i,_e=e=>{const t=ge.test(e);if(!t&&!Ee.test(e))return e;const s=e.replaceAll(de,`-----BEGIN $1-----${u}`).replaceAll(ce,ae).replaceAll(le,`$1 ${u}`);return he((t?s.replaceAll(ue,u):s).replaceAll(pe,`$1$2$3${u}`))},Se=(e,t)=>{if(t.remaining<=0)return re;const s=e.slice(0,T+te);t.remaining-=s.length;const r=_e(s);return r.length>T||e.length>s.length?`${r.slice(0,T)}…[truncated]`:r},me=e=>e instanceof Error||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof WeakMap||e instanceof WeakSet||e instanceof Promise||e instanceof ArrayBuffer||ArrayBuffer.isView(e),m=Symbol("no-json"),Ae=e=>{const{toJSON:t}=e;if(typeof t!="function")return m;try{const s=t.call(e);return s===e?m:s}catch{return m}},Te=32,A=(e,t,s,r,n)=>{if(typeof e=="string")return r?u:Se(e,n);if(typeof e!="object"||e===null||!Array.isArray(e)&&me(e))return e;if(t.has(e)||s>=Te)return u;const a=Array.isArray(e)?m:Ae(e);if(a!==m){t.add(e);const o=A(a,t,s+1,r,n);return t.delete(e),o}t.add(e);const c=Array.isArray(e)?e.map(o=>A(o,t,s+1,r,n)):Object.fromEntries(Object.entries(e).map(([o,i])=>{const d=D(o);return d==="secret"||d==="scalar-secret"&&(typeof i!="object"||i===null)?[o,ie(i)]:[o,A(i,t,s+1,d==="count-secret"&&(typeof i=="string"||Array.isArray(i)),n)]}));return t.delete(e),c},U=e=>A(e,new WeakSet,0,!1,{remaining:se}),p="__lunora_reqlog__",y=1e3,P="lunora",ye=["error_fingerprint TEXT","trace_id TEXT","deployment_id TEXT","version_tag TEXT"],be=G(X,{exclude:["pass"]}),Ce=(e,t=!1)=>t||e===null||e===void 0?e:U(e),g=(e,t=!1)=>t||e===null||e===void 0?e:be(U(e)),w=new WeakSet,b=e=>{if(!w.has(e)){E(e,`CREATE TABLE IF NOT EXISTS "${p}" (
1
+ import{fingerprintError as M}from"@lunora/fingerprint";import{createRedactor as G,standardRules as X}from"@visulima/redact";import{readIssueStates as z}from"./ISSUE_SEVERITIES-0SJ0glV4.mjs";import{r as E}from"./run-sql-0aPgJkIw.mjs";const H=e=>{if(typeof e=="string")return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}},O=e=>typeof e=="boolean"||typeof e=="number"||typeof e=="string"?e:H(e),I=(e,t)=>{if(e===void 0&&t===void 0)return;const s={};if(t!==void 0)for(const[r,n]of Object.entries(t))s[r]=O(n);if(e!==void 0)for(const[r,n]of Object.entries(e))s[r]=O(n);return Object.keys(s).length===0?void 0:s},V=new Set(["auth","authorization","bearer","card","cc","cookie","credential","cvc","cvv","dsn","hmac","hotp","iban","jwt","kek","mnemonic","otp","pass","passcode","passphrase","passwd","password","pem","pin","pwd","salt","secret","session","sid","sig","signature","ssn","token","totp","verifier"]),J=new Set(["card","pass","pin","session"]),Z=new Set(["access","api","client","encryption","master","priv","private","secret","signing"]),K=new Set(["2fa","auth","authorization","backup","factor","hotp","mfa","otp","pin","recovery","reset","security","totp","verification","verify"]),B=new Set(["card no","connection string","database url","one time"]),Y=["accesskey","apikey","authorization","cookie","credential","mfacode","otpcode","passcode","passphrase","passwd","password","privatekey","secret","secretkey","sessionid","signature","token"],q=new Set(["again","b64","base","base64","bytes","confirm","confirmation","data","digest","encrypted","hash","hashed","header","hex","id","input","key","no","num","number","plain","plaintext","raw","repeat","str","string","text","value"]),Q=new Set(["count","counts","length","limit","limits","size","tokens","total","usage"]),ee=new Set(["max","min","num","total"]),T=4096,te=128,se=16384,u="<REDACTED>",re="[redaction budget exceeded]",ne=e=>e.replaceAll(/([a-z\d])([A-Z])/g,"$1 $2").replaceAll(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/[^a-z\d]+/).filter(t=>t.length>0),N=e=>e.length>3&&e.endsWith("s")&&!e.endsWith("ss")?e.slice(0,-1):e,oe=(e,t)=>{const s=N(e[t]),r=t>0?N(e[t-1]):void 0;if(V.has(s))return s;if(r!==void 0){if(s==="key"&&Z.has(r))return"key";if(s==="code"&&K.has(r))return"code";if(B.has(`${r} ${s}`))return`${r} ${s}`}return Y.some(n=>s.endsWith(n))?s:void 0},D=e=>{const t=ne(e);if(t.length===0)return"none";const s=Q.has(t.at(-1))||ee.has(t[0]);for(let r=t.length-1;r>=0;r-=1){const n=oe(t,r);if(n!==void 0)return s?"count-secret":t.slice(r+1).every(a=>q.has(a))?J.has(n)&&r===t.length-1?"scalar-secret":"secret":"none"}return"none"},ie=e=>typeof e=="boolean"||e===null||e===void 0?e:u,ae=e=>{const t=e.indexOf("://")+3,s=e.slice(t),r=s.split(/[?#]/,1)[0],n=r.lastIndexOf("@"),a=r.indexOf(":"),c=r.indexOf("/"),o=a!==-1&&/^\d+$/.test(r.slice(a+1,c===-1?void 0:c)),i=a!==-1&&!o&&(c===-1||a<c);if(n===-1&&i&&s.includes("@",r.length))return e.slice(0,t);const d=n!==-1&&(c===-1||n<c||a!==-1&&a<n&&!o);return`${e.slice(0,t)}${d?r.slice(n+1):r}`},ce=/\b[a-z][\d+.a-z-]{1,15}:\/\/[^\s"'<>()[\]{}]+/gi,de=/-----BEGIN ([A-Z ]{0,32}PRIVATE KEY)-----[\s\S]*?(?:-----END [A-Z ]{0,32}PRIVATE KEY-----|$)/g,le=/\b(Basic|Bearer|Digest)\s+[\w+/=.~-]{4,}/g,$=String.raw`%[\dA-Fa-f]{2}|\\(?:[bfnrt]|u[\dA-Fa-f]{4})`,C=[{body:String.raw`[\dA-Za-z]{10,}`,name:"Stripe secret or restricted key",prefix:String.raw`[rs]k_(?:live|test)_`},{body:String.raw`[\d+/=A-Za-z]{20,}`,name:"Stripe webhook secret",prefix:"whsec_"},{body:String.raw`[\dA-Za-z]{30,}`,name:"GitHub classic token (personal, OAuth, user/server-to-server, refresh)",prefix:"gh[oprsu]_"},{body:String.raw`\w{20,}`,name:"GitHub fine-grained token",prefix:"github_pat_"},{body:String.raw`[\w-]{20,}`,name:"GitLab personal, pipeline-trigger and deploy tokens",prefix:"gl(?:pat|ptt|dt)-"},{body:String.raw`[\dA-Za-z-]{10,}`,name:"Slack token",prefix:"xox[a-eprs]-"},{body:String.raw`\d-[\dA-Za-z-]{10,}`,name:"Slack app-level token",prefix:"xapp-"},{body:String.raw`[\dA-Z]{16}\b`,name:"AWS access-key id, long-lived and temporary",prefix:"(?:AKIA|ASIA)"},{body:String.raw`[\w-]{35}(?![\w-])`,name:"Google API key",prefix:"AIza"},{body:String.raw`[\w-]{24,}`,name:"Google OAuth client secret",prefix:"GOCSPX-"},{body:String.raw`[\w-]{20,}`,name:"Google OAuth access token",prefix:String.raw`ya29\.`},{body:String.raw`[\dA-Za-z]{36}\b`,name:"npm token",prefix:"npm_"},{body:String.raw`[\dA-Za-z]{30,}`,name:"Hugging Face token",prefix:"hf_"},{body:String.raw`[\dA-Fa-f]{32}\b`,name:"Shopify token",prefix:"shp(?:at|ca|pa|ss)_"},{body:String.raw`[\da-f]{64}\b`,name:"DigitalOcean token",prefix:"do[opr]_v1_"},{body:String.raw`[\w-]{20,}`,name:"OpenAI project/service/admin key, Anthropic key",prefix:"sk-(?:admin|ant|proj|svcacct)-"},{body:String.raw`[\dA-Za-z]{20}T3BlbkFJ[\dA-Za-z]{20}\b`,name:"OpenAI legacy key",prefix:"sk-"},{body:String.raw`[\w-]{22}\.[\w-]{43}(?![\w-])`,name:"SendGrid key",prefix:String.raw`SG\.`}],fe=String.raw`(?<=^|[^\w-]|${$})eyJ[\w-]{2,}\.[\w-]{2,}\.[\w-]*`,ue=new RegExp([...C.map(({body:e,prefix:t})=>String.raw`(?<=^|[^\dA-Za-z]|${$})${t}${e}`),fe].join("|"),"g"),ge=new RegExp([...C.map(({prefix:e})=>e),"eyJ"].join("|")),pe=/(\s|^)(-u|--user|--password|--pass|--token|--api-key)(\s+|=)[^\s"']+/g,S=/(?<![\w.-])(\\?["']?)([A-Za-z_][\w.-]{0,63})\1[ \t]{0,4}([:=])[ \t]{0,4}/g,L=/(?:basic|bearer|digest|token)\s+[^\s"&'),;\]}]+|\\"(?:[^"\\\n]|\\[^"])*(?:\\")?|"[^\n"]*"?|'[^\n']*'?|[^\s"&'),;\]}]+/iy,k=/(?:[ \t]+(?![A-Za-z_][\w.-]{0,63}[:=])[^\s,;)\]}]+)*/y,he=e=>{let t="",s=0;S.lastIndex=0;for(let r=S.exec(e);r!==null;r=S.exec(e)){const n=D(r[2]),a=r.index+r[0].length;L.lastIndex=a;const c=n==="none"?null:L.exec(e);if(c===null||n==="count-secret"&&/^["']?[\d.]+["']?$/.test(c[0])){S.lastIndex=Math.max(a,r.index+1);continue}const o=c[0],i=o.startsWith('\\"')?'\\"':o.startsWith('"')||o.startsWith("'")?o[0]:"";let d=a+o.length;i===""&&r[3]===":"&&(k.lastIndex=d,d+=k.exec(e)?.[0].length??0),t+=`${e.slice(s,a)}${i}${u}${o.length>i.length&&o.endsWith(i)?i:""}`,s=d,S.lastIndex=s}return t+e.slice(s)},Ee=/[:=@]|basic|bearer|digest|-u\b|--/i,_e=e=>{const t=ge.test(e);if(!t&&!Ee.test(e))return e;const s=e.replaceAll(de,`-----BEGIN $1-----${u}`).replaceAll(ce,ae).replaceAll(le,`$1 ${u}`);return he((t?s.replaceAll(ue,u):s).replaceAll(pe,`$1$2$3${u}`))},Se=(e,t)=>{if(t.remaining<=0)return re;const s=e.slice(0,T+te);t.remaining-=s.length;const r=_e(s);return r.length>T||e.length>s.length?`${r.slice(0,T)}…[truncated]`:r},me=e=>e instanceof Error||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof WeakMap||e instanceof WeakSet||e instanceof Promise||e instanceof ArrayBuffer||ArrayBuffer.isView(e),m=Symbol("no-json"),Ae=e=>{const{toJSON:t}=e;if(typeof t!="function")return m;try{const s=t.call(e);return s===e?m:s}catch{return m}},Te=32,A=(e,t,s,r,n)=>{if(typeof e=="string")return r?u:Se(e,n);if(typeof e!="object"||e===null||!Array.isArray(e)&&me(e))return e;if(t.has(e)||s>=Te)return u;const a=Array.isArray(e)?m:Ae(e);if(a!==m){t.add(e);const o=A(a,t,s+1,r,n);return t.delete(e),o}t.add(e);const c=Array.isArray(e)?e.map(o=>A(o,t,s+1,r,n)):Object.fromEntries(Object.entries(e).map(([o,i])=>{const d=D(o);return d==="secret"||d==="scalar-secret"&&(typeof i!="object"||i===null)?[o,ie(i)]:[o,A(i,t,s+1,d==="count-secret"&&(typeof i=="string"||Array.isArray(i)),n)]}));return t.delete(e),c},U=e=>A(e,new WeakSet,0,!1,{remaining:se}),p="__lunora_reqlog__",y=1e3,P="lunora",ye=["error_fingerprint TEXT","trace_id TEXT","deployment_id TEXT","version_tag TEXT"],be=G(X,{exclude:["pass"]}),Ce=(e,t=!1)=>t||e===null||e===void 0?e:U(e),g=(e,t=!1)=>t||e===null||e===void 0?e:be(U(e)),w=new WeakSet,b=e=>{if(!w.has(e)){E(e,`CREATE TABLE IF NOT EXISTS "${p}" (
2
2
  seq INTEGER PRIMARY KEY AUTOINCREMENT,
3
3
  ts REAL NOT NULL,
4
4
  function_path TEXT NOT NULL,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/observability",
3
- "version": "1.0.0-alpha.102",
3
+ "version": "1.0.0-alpha.104",
4
4
  "description": "Host-neutral telemetry storage and read models for Lunora, backing the Studio's Logs, Traces, Metrics and Issues views",
5
5
  "keywords": [
6
6
  "lunora",
@@ -43,9 +43,9 @@
43
43
  "access": "public"
44
44
  },
45
45
  "dependencies": {
46
- "@lunora/errors": "1.0.0-alpha.44",
46
+ "@lunora/errors": "1.0.0-alpha.46",
47
47
  "@lunora/fingerprint": "1.0.0-alpha.9",
48
- "@lunora/shard-engine": "1.0.0-alpha.93",
48
+ "@lunora/shard-engine": "1.0.0-alpha.95",
49
49
  "@visulima/redact": "5.0.0"
50
50
  },
51
51
  "engines": {