@lensmcp/memory-tracker 1.22.5 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ export declare function onFlowStart(flowId: string): void;
4
4
  * more than `leakItemThreshold` and didn't shrink are flagged. Returns
5
5
  * the list of flagged owner ids (also useful for tests).
6
6
  */
7
- export declare function onFlowSettled(flowId: string): string[];
7
+ export declare function onFlowSettled(flowKey: string, flowId?: string): string[];
8
8
  export declare function checkStaleGeneration(args: {
9
9
  logicalId: string;
10
10
  instanceId: string;
package/lib/detectors.js CHANGED
@@ -1 +1 @@
1
- "use strict";var s=Object.defineProperty;var n=(e,t)=>s(e,"name",{value:t,configurable:!0});var l=Object.defineProperty,r=n((e,t)=>l(e,"name",{value:t,configurable:!0}),"n");import{activeMemoryOptions as i}from"./context.js";import{clearFlowStart as c,flowGrowth as d,markFlowStart as w}from"./owners.js";import{emitRetention as u,emitStaleGeneration as f}from"./emit.js";export function onFlowStart(e){w(e)}n(onFlowStart,"onFlowStart"),r(onFlowStart,"onFlowStart");export function onFlowSettled(e){const t=i();if(!t)return[];const a=[];for(const o of d(e))o.growth>=t.leakItemThreshold&&o.endCount>=o.growth&&(u({options:t,ownerId:o.owner.ownerId,flowId:e,startCount:o.startCount,endCount:o.endCount,growth:o.growth}),a.push(o.owner.ownerId));return c(e),a}n(onFlowSettled,"onFlowSettled"),r(onFlowSettled,"onFlowSettled");export function checkStaleGeneration(e){const t=i();return t&&e.retainedBytes>t.staleGenerationBytesThreshold?(f({options:t,logicalId:e.logicalId,instanceId:e.instanceId,generation:e.generation,retainedBytes:e.retainedBytes}),!0):!1}n(checkStaleGeneration,"checkStaleGeneration"),r(checkStaleGeneration,"checkStaleGeneration");
1
+ "use strict";var c=Object.defineProperty;var n=(e,t)=>c(e,"name",{value:t,configurable:!0});var d=Object.defineProperty,a=n((e,t)=>d(e,"name",{value:t,configurable:!0}),"n");import{activeMemoryOptions as l}from"./context.js";import{clearFlowStart as w,flowGrowth as u,markFlowStart as f}from"./owners.js";import{emitRetention as h,emitStaleGeneration as m}from"./emit.js";export function onFlowStart(e){f(e)}n(onFlowStart,"onFlowStart"),a(onFlowStart,"onFlowStart");export function onFlowSettled(e,t){const r=l();if(!r)return[];const i=[],s=t??e;for(const o of u(e))o.growth>=r.leakItemThreshold&&o.endCount>=o.growth&&(h({options:r,ownerId:o.owner.ownerId,flowId:s,...s!==e?{requestId:e}:{},startCount:o.startCount,endCount:o.endCount,growth:o.growth}),i.push(o.owner.ownerId));return w(e),i}n(onFlowSettled,"onFlowSettled"),a(onFlowSettled,"onFlowSettled");export function checkStaleGeneration(e){const t=l();return t&&e.retainedBytes>t.staleGenerationBytesThreshold?(m({options:t,logicalId:e.logicalId,instanceId:e.instanceId,generation:e.generation,retainedBytes:e.retainedBytes}),!0):!1}n(checkStaleGeneration,"checkStaleGeneration"),a(checkStaleGeneration,"checkStaleGeneration");
package/lib/emit.d.ts CHANGED
@@ -14,6 +14,8 @@ export declare function emitRetention(args: {
14
14
  options: ResolvedMemoryOptions;
15
15
  ownerId: string;
16
16
  flowId: string;
17
+ /** The request the growth was measured over, when it is not the flow id itself. */
18
+ requestId?: string;
17
19
  startCount: number;
18
20
  endCount: number;
19
21
  growth: number;
package/lib/emit.js CHANGED
@@ -1 +1 @@
1
- "use strict";var m=Object.defineProperty;var n=(t,e)=>m(t,"name",{value:e,configurable:!0});var I=Object.defineProperty,o=n((t,e)=>I(t,"name",{value:e,configurable:!0}),"n");const c=Date.now().toString(36)+Math.random().toString(36).slice(2,8);let a=0;function r(t){return a=(a+1)%16777215,`${t}-${c}-${a.toString(36)}`}n(r,"d"),o(r,"memId");function d(t,e){return{sessionId:e?.sessionId??t.sessionId,...e?.flowId?{flowId:e.flowId}:{},...e?.requestId?{requestId:e.requestId}:{},...e?.originNodeId?{originNodeId:e.originNodeId}:{}}}n(d,"s"),o(d,"baseContext");export function emitMutation(t){const{options:e}=t,i={id:r("memmut"),sessionId:t.context?.sessionId??e.sessionId,timestamp:t.timestamp??s(),source:"memory",category:"memory",severity:"debug",context:d(e,t.context),fingerprint:`memory-mutation:${t.ownerId}:${t.operation}`,title:`${t.operation} ${t.ownerId}`,raw:{kind:"memory-mutation",mutation:{ownerNodeId:t.ownerId,operation:t.operation,beforeCount:t.beforeCount,afterCount:t.afterCount,estimatedDeltaBytes:t.estimatedDeltaBytes,keyPreview:t.keyPreview}}};e.sink(i)}n(emitMutation,"emitMutation"),o(emitMutation,"emitMutation");export function emitRetention(t){const{options:e}=t,i={id:r("memret"),sessionId:t.context?.sessionId??e.sessionId,timestamp:t.timestamp??s(),source:"memory",category:"memory",severity:"warning",context:{...d(e,t.context),flowId:t.flowId},fingerprint:`memory-retention:${t.ownerId}`,title:`Suspected leak: ${t.ownerId} grew by ${t.growth} and did not shrink`,raw:{kind:"memory-retention",retention:{ownerId:t.ownerId,flowId:t.flowId,startCount:t.startCount,endCount:t.endCount,growth:t.growth}}};e.sink(i)}n(emitRetention,"emitRetention"),o(emitRetention,"emitRetention");export function emitStaleGeneration(t){const{options:e}=t,i={id:r("memstale"),sessionId:e.sessionId,timestamp:t.timestamp??s(),source:"memory",category:"memory",severity:"warning",context:{sessionId:e.sessionId},fingerprint:`memory-stale-generation:${t.logicalId}`,title:`Stale generation retained: ${t.logicalId} gen ${t.generation} holds ${t.retainedBytes} bytes`,raw:{kind:"singleton-stale-generation",staleGeneration:{logicalId:t.logicalId,instanceId:t.instanceId,generation:t.generation,retainedBytes:t.retainedBytes}}};e.sink(i)}n(emitStaleGeneration,"emitStaleGeneration"),o(emitStaleGeneration,"emitStaleGeneration");function s(){return Date.now()}n(s,"r"),o(s,"nowMs");
1
+ "use strict";var m=Object.defineProperty;var n=(t,e)=>m(t,"name",{value:e,configurable:!0});var I=Object.defineProperty,o=n((t,e)=>I(t,"name",{value:e,configurable:!0}),"n");const u=Date.now().toString(36)+Math.random().toString(36).slice(2,8);let d=0;function r(t){return d=(d+1)%16777215,`${t}-${u}-${d.toString(36)}`}n(r,"d"),o(r,"memId");function a(t,e){return{sessionId:e?.sessionId??t.sessionId,...e?.flowId?{flowId:e.flowId}:{},...e?.requestId?{requestId:e.requestId}:{},...e?.originNodeId?{originNodeId:e.originNodeId}:{}}}n(a,"s"),o(a,"baseContext");export function emitMutation(t){const{options:e}=t,i={id:r("memmut"),sessionId:t.context?.sessionId??e.sessionId,timestamp:t.timestamp??s(),source:"memory",category:"memory",severity:"debug",context:a(e,t.context),fingerprint:`memory-mutation:${t.ownerId}:${t.operation}`,title:`${t.operation} ${t.ownerId}`,raw:{kind:"memory-mutation",mutation:{ownerNodeId:t.ownerId,operation:t.operation,beforeCount:t.beforeCount,afterCount:t.afterCount,estimatedDeltaBytes:t.estimatedDeltaBytes,keyPreview:t.keyPreview}}};e.sink(i)}n(emitMutation,"emitMutation"),o(emitMutation,"emitMutation");export function emitRetention(t){const{options:e}=t,i={id:r("memret"),sessionId:t.context?.sessionId??e.sessionId,timestamp:t.timestamp??s(),source:"memory",category:"memory",severity:"warning",context:{...a(e,t.context),flowId:t.flowId,...t.requestId?{requestId:t.requestId}:{}},fingerprint:`memory-retention:${t.ownerId}`,title:`Suspected leak: ${t.ownerId} grew by ${t.growth} and did not shrink`,raw:{kind:"memory-retention",retention:{ownerId:t.ownerId,flowId:t.flowId,...t.requestId?{requestId:t.requestId}:{},startCount:t.startCount,endCount:t.endCount,growth:t.growth}}};e.sink(i)}n(emitRetention,"emitRetention"),o(emitRetention,"emitRetention");export function emitStaleGeneration(t){const{options:e}=t,i={id:r("memstale"),sessionId:e.sessionId,timestamp:t.timestamp??s(),source:"memory",category:"memory",severity:"warning",context:{sessionId:e.sessionId},fingerprint:`memory-stale-generation:${t.logicalId}`,title:`Stale generation retained: ${t.logicalId} gen ${t.generation} holds ${t.retainedBytes} bytes`,raw:{kind:"singleton-stale-generation",staleGeneration:{logicalId:t.logicalId,instanceId:t.instanceId,generation:t.generation,retainedBytes:t.retainedBytes}}};e.sink(i)}n(emitStaleGeneration,"emitStaleGeneration"),o(emitStaleGeneration,"emitStaleGeneration");function s(){return Date.now()}n(s,"r"),o(s,"nowMs");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensmcp/memory-tracker",
3
- "version": "1.22.5",
3
+ "version": "1.23.0",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",
@@ -14,7 +14,7 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@lensmcp/protocol-types": "1.22.5",
17
+ "@lensmcp/protocol-types": "1.23.0",
18
18
  "tslib": "^2.3.0"
19
19
  },
20
20
  "license": "Apache-2.0",