@lensmcp/core 1.25.59 → 1.25.61

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.
@@ -1,7 +1,7 @@
1
- import { type BaseEvent, type ErrorDismissalDraft } from '@lensmcp/protocol-types';
1
+ import { type BaseEvent, type ErrorDismissalDraft, type MetricsChange } from '@lensmcp/protocol-types';
2
2
  /**
3
- * Events the lens writes about itself — today, a dismissed error and its undo — and the one way
4
- * they reach the bus.
3
+ * Events the lens writes about itself — a dismissed error and its undo, a reset of a catalog's
4
+ * numbers and its undo — and the one way they reach the bus.
5
5
  *
6
6
  * Three processes can dismiss: the dashboard (a click), the MCP server (an agent's tool call, or
7
7
  * the CLI through it). None of them changes its own memory. Each appends to the bus FILE and hears
@@ -13,6 +13,13 @@ export declare function lensEventFile(env?: Record<string, string | undefined>,
13
13
  /** Stamped AT `until`: the reader clamps a dismissal to its own timestamp, so the two must agree. */
14
14
  export declare function dismissalEvent(draft: ErrorDismissalDraft, sessionId: string): BaseEvent;
15
15
  export declare function restoralEvent(groupId: string, sessionId: string, at: number): BaseEvent;
16
+ /**
17
+ * A reset of a catalog's numbers, or its undo (`@lensmcp/protocol-types` metrics-reset.ts), as the events that carry
18
+ * it: one for everything in the scope, else one per batch of ids the bus keeps whole — each stamped AT the reset, which
19
+ * the reader clamps to. The fingerprint is the kind and the scope only: it is the flood guard's bucket, and what was
20
+ * reset is in `raw`.
21
+ */
22
+ export declare function metricsChangeEvents(change: MetricsChange, sessionId: string, at: number): BaseEvent[];
16
23
  /**
17
24
  * Append events to the bus file. Throws when the write fails: the caller is answering a person or
18
25
  * an agent, and "dismissed" must not be a guess.
@@ -1,2 +1,2 @@
1
- "use strict";var p=Object.defineProperty;var t=(n,e)=>p(n,"name",{value:e,configurable:!0});var E=Object.defineProperty,r=t((n,e)=>E(n,"name",{value:e,configurable:!0}),"o");import{appendFileSync as m,closeSync as d,mkdirSync as S,openSync as v,renameSync as y,statSync as f,unlinkSync as I}from"node:fs";import{dirname as N,join as _}from"node:path";import{ERROR_DISMISSED as o,ERROR_RESTORED as a,LENS_EVENT_SOURCE as g}from"@lensmcp/protocol-types";import{rotateBusFile as R}from"./bus-rotation.js";import{ulid as b}from"./ulid.js";export function lensEventFile(n=process.env,e=process.cwd()){return n.LENSMCP_EVENT_FILE??_(e,".lensmcp","events.jsonl")}t(lensEventFile,"lensEventFile"),r(lensEventFile,"lensEventFile");const c=r((n,e,s,i,l)=>({id:b(),sessionId:n,timestamp:e,source:g,category:"runtime",severity:"info",context:{sessionId:n},fingerprint:s,title:i,raw:l}),"lensEvent");export function dismissalEvent(n,e){return c(e,n.until,`${o}:${n.groupId}`,`error dismissed: ${n.title??n.groupId}`,{kind:o,groupId:n.groupId,until:n.until,eventIds:n.eventIds,...n.by?{by:n.by}:{},...n.reason?{reason:n.reason}:{},...n.title?{title:n.title}:{}})}t(dismissalEvent,"dismissalEvent"),r(dismissalEvent,"dismissalEvent");export function restoralEvent(n,e,s){return c(e,s,`${a}:${n}`,"error restored",{kind:a,groupId:n})}t(restoralEvent,"restoralEvent"),r(restoralEvent,"restoralEvent");const u=r((n,e,s)=>{const i=Number(process.env[n]);return Number.isFinite(i)&&s(i)?i:e},"envNumber");export function appendBusEvents(n,e){e.length!==0&&(S(N(n),{recursive:!0}),R(n,{maxBytes:u("LENSMCP_EVENT_MAX_BYTES",50*1024*1024,s=>s>0),maxFiles:u("LENSMCP_EVENT_MAX_FILES",5,s=>s>=1&&s<=20),fs:{statSync:f,renameSync:y,unlinkSync:I,openSync:v,closeSync:d}}),m(n,e.map(s=>JSON.stringify(s)+`
2
- `).join("")))}t(appendBusEvents,"appendBusEvents"),r(appendBusEvents,"appendBusEvents");
1
+ "use strict";var u=Object.defineProperty;var r=(n,e)=>u(n,"name",{value:e,configurable:!0});var E=Object.defineProperty,i=r((n,e)=>E(n,"name",{value:e,configurable:!0}),"o");import{appendFileSync as l,closeSync as m,mkdirSync as S,openSync as v,renameSync as y,statSync as f,unlinkSync as I}from"node:fs";import{dirname as g,join as _}from"node:path";import{ERROR_DISMISSED as c,ERROR_RESTORED as p,LENS_EVENT_SOURCE as N,METRICS_RESET as R,metricsIdBatches as $}from"@lensmcp/protocol-types";import{rotateBusFile as b}from"./bus-rotation.js";import{ulid as x}from"./ulid.js";export function lensEventFile(n=process.env,e=process.cwd()){return n.LENSMCP_EVENT_FILE??_(e,".lensmcp","events.jsonl")}r(lensEventFile,"lensEventFile"),i(lensEventFile,"lensEventFile");const a=i((n,e,s,t,o)=>({id:x(),sessionId:n,timestamp:e,source:N,category:"runtime",severity:"info",context:{sessionId:n},fingerprint:s,title:t,raw:o}),"lensEvent");export function dismissalEvent(n,e){return a(e,n.until,`${c}:${n.groupId}`,`error dismissed: ${n.title??n.groupId}`,{kind:c,groupId:n.groupId,until:n.until,eventIds:n.eventIds,...n.by?{by:n.by}:{},...n.reason?{reason:n.reason}:{},...n.title?{title:n.title}:{}})}r(dismissalEvent,"dismissalEvent"),i(dismissalEvent,"dismissalEvent");export function restoralEvent(n,e,s){return a(e,s,`${p}:${n}`,"error restored",{kind:p,groupId:n})}r(restoralEvent,"restoralEvent"),i(restoralEvent,"restoralEvent");export function metricsChangeEvents(n,e,s){const t=n.kind===R;return(n.ids?$(n.ids):[void 0]).map(o=>a(e,s,`${n.kind}:${n.scope}`,`${t?"numbers reset":"numbers counted whole again"}: ${n.scope}${o?` \xB7 ${o.length}`:" \xB7 all"}`,{kind:n.kind,scope:n.scope,...t?{at:s}:{},...o?{ids:o}:{}}))}r(metricsChangeEvents,"metricsChangeEvents"),i(metricsChangeEvents,"metricsChangeEvents");const d=i((n,e,s)=>{const t=Number(process.env[n]);return Number.isFinite(t)&&s(t)?t:e},"envNumber");export function appendBusEvents(n,e){e.length!==0&&(S(g(n),{recursive:!0}),b(n,{maxBytes:d("LENSMCP_EVENT_MAX_BYTES",50*1024*1024,s=>s>0),maxFiles:d("LENSMCP_EVENT_MAX_FILES",5,s=>s>=1&&s<=20),fs:{statSync:f,renameSync:y,unlinkSync:I,openSync:v,closeSync:m}}),l(n,e.map(s=>JSON.stringify(s)+`
2
+ `).join("")))}r(appendBusEvents,"appendBusEvents"),i(appendBusEvents,"appendBusEvents");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensmcp/core",
3
- "version": "1.25.59",
3
+ "version": "1.25.61",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",
@@ -94,7 +94,7 @@
94
94
  }
95
95
  },
96
96
  "dependencies": {
97
- "@lensmcp/protocol-types": "1.25.59",
97
+ "@lensmcp/protocol-types": "1.25.61",
98
98
  "tslib": "^2.3.0"
99
99
  },
100
100
  "license": "Apache-2.0",