@lensmcp/protocol-types 1.26.0 → 1.26.2
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/index.d.ts +1 -0
- package/index.js +1 -1
- package/lib/ai-call-groups.js +2 -2
- package/lib/ai-call-row.js +3 -3
- package/lib/ai-call.js +9 -9
- package/lib/ai-context.js +6 -6
- package/lib/ai-origins.js +9 -9
- package/lib/attributes.d.ts +4 -4
- package/lib/bounded-clone.js +1 -1
- package/lib/bounded-map.js +1 -1
- package/lib/bounded-writer.js +1 -1
- package/lib/capture-demand.js +1 -1
- package/lib/context.d.ts +2 -2
- package/lib/dashboard-path.d.ts +1 -1
- package/lib/dashboard-path.js +1 -1
- package/lib/dashboard.d.ts +46 -0
- package/lib/edge.d.ts +8 -8
- package/lib/error-cause.js +5 -5
- package/lib/error-dismissal.js +1 -1
- package/lib/event-loop.js +1 -1
- package/lib/event.d.ts +45 -45
- package/lib/expected-failure.d.ts +251 -0
- package/lib/expected-failure.js +2 -0
- package/lib/flood-guard.js +1 -1
- package/lib/goal-design.js +1 -1
- package/lib/lint-coverage.js +1 -1
- package/lib/log-query.js +1 -1
- package/lib/metrics-reset.js +1 -1
- package/lib/node.d.ts +11 -11
- package/lib/overseer-findings.js +1 -1
- package/lib/perf-rules.js +1 -1
- package/lib/pod-memory.js +1 -1
- package/lib/producer-health.js +1 -1
- package/lib/resources.d.ts +28 -28
- package/lib/sources.js +1 -1
- package/lib/system-report.js +1 -1
- package/lib/team.js +1 -1
- package/package.json +1 -1
package/lib/bounded-clone.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var T=Object.defineProperty;var
|
|
1
|
+
"use strict";var T=Object.defineProperty;var i=(e,t)=>T(e,"name",{value:t,configurable:!0});var h=Object.defineProperty,l=i((e,t)=>h(e,"name",{value:t,configurable:!0}),"_");export const DEFAULT_RAW_BYTE_LIMIT=32768,DEFAULT_MAX_STRING_BYTES=4096,DEFAULT_MAX_ARRAY_ITEMS=64,DEFAULT_MAX_DEPTH=12,CHEAP_ENTRY_BYTES=512,NOMINAL_DEEP_BYTES=32,DEEP_REPORT_DEPTH=64,SKELETON_STRING_BYTES=256,MAX_RECORDED_PATHS=20,TRUNCATION_MARKER_KEY="__lensmcpTruncation",TRUNCATED_VALUE_KEY="__lensmcpTruncated";export function estimateJsonBytes(e,t=Number.POSITIVE_INFINITY,r=12){return y(e,t,r,32)}i(estimateJsonBytes,"estimateJsonBytes"),l(estimateJsonBytes,"estimateJsonBytes");export function exceedsJsonByteBudget(e,t,r=12){return y(e,t,r,Number.POSITIVE_INFINITY)>t}i(exceedsJsonByteBudget,"exceedsJsonByteBudget"),l(exceedsJsonByteBudget,"exceedsJsonByteBudget");function y(e,t,r,a){switch(typeof e){case"undefined":case"function":case"symbol":return 0;case"boolean":return 5;case"number":return Number.isFinite(e)?8:4;case"bigint":return 20;case"string":return e.length+2;default:break}if(e===null)return 4;if(r<=0)return a;if(e instanceof Date)return 26;if(Array.isArray(e)){let n=2;for(let s=0;s<e.length;s++)if(n+=y(e[s],t-n,r-1,a)+1,n>t)return n;return n}let u=2;const o=e;for(const n in o){if(!Object.prototype.hasOwnProperty.call(o,n))continue;const s=y(o[n],t-u,r-1,a);if(s!==0&&(u+=n.length+4+s,u>t))return u}return u}i(y,"T"),l(y,"walk");function g(e,t){e.truncatedAnything=!0,e.paths.length<20&&e.paths.push(t||"<root>")}i(g,"A"),l(g,"record");function f(e,t,r){return g(e,r),{[TRUNCATED_VALUE_KEY]:!0,originalBytes:estimateJsonBytes(t,Number.POSITIVE_INFINITY,64)}}i(f,"I"),l(f,"stub");function p(e){if(e===null)return!0;const t=typeof e;return t==="number"||t==="boolean"||t==="string"||t==="bigint"}i(p,"y"),l(p,"isScalar");export function clampValue(e,t,r,a){if(typeof e=="string"){const u=t.budget<=0?256:t.maxStringBytes;if(e.length+2<=u)return t.budget-=e.length+2,e;const o=Math.max(0,u-64);return g(t,a),t.budget-=o,`${e.slice(0,o)}\u2026[lensmcp truncated: ${e.length-o} more chars]`}return e===null||typeof e!="object"?(t.budget-=y(e,Number.POSITIVE_INFINITY,1,32),e):r<=0?f(t,e,a):e instanceof Date?(t.budget-=26,e):Array.isArray(e)?m(e,t,r,a):b(e,t,r,a)}i(clampValue,"clampValue"),l(clampValue,"clampValue");function m(e,t,r,a){const u=[],o=Math.min(e.length,t.maxArrayItems);for(let n=0;n<o&&!(t.budget<=0);n++)u.push(clampValue(e[n],t,r-1,`${a}[${n}]`));return u.length<e.length&&g(t,`${a}[] (+${e.length-u.length} items dropped)`),u}i(m,"f"),l(m,"clampArray");function b(e,t,r,a){const u={};let o;const n=t.budget<=0;for(const s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;const c=e[s],I=y(c,512,r-1,Number.POSITIVE_INFINITY);if(I<=512&&(!n||p(c))){u[s]=c,t.budget-=s.length+4+I;continue}(o??=[]).push({key:s,bytes:I})}if(!o)return u;o.sort((s,c)=>s.bytes===c.bytes?0:s.bytes<c.bytes?-1:1);for(const{key:s}of o){const c=a?`${a}.${s}`:s;u[s]=clampValue(e[s],t,r-1,c)}return u}i(b,"m"),l(b,"clampObject");export function boundedClone(e,t={}){const r=t.rawByteLimit??32768,a=t.maxDepth??12;if(r<=0)return{value:void 0,truncated:!1,originalBytes:0,keptBytes:0,paths:[]};if(e==null)return{value:e,truncated:!1,originalBytes:0,keptBytes:0,paths:[]};if(!exceedsJsonByteBudget(e,r,a)){const c=estimateJsonBytes(e,r,a),I={budget:r,maxStringBytes:t.maxStringBytes??4096,maxArrayItems:t.maxArrayItems??64,paths:[],truncatedAnything:!1};return{value:clampValue(e,I,a,""),truncated:!1,originalBytes:c,keptBytes:c,paths:[]}}const u=estimateJsonBytes(e,Number.POSITIVE_INFINITY,64),o={budget:r,maxStringBytes:t.maxStringBytes??4096,maxArrayItems:t.maxArrayItems??64,paths:[],truncatedAnything:!1},n=clampValue(e,o,a,""),s=estimateJsonBytes(n,Number.POSITIVE_INFINITY,a);if(o.truncatedAnything&&n!==null&&typeof n=="object"&&!Array.isArray(n)){const c={truncated:!0,originalBytes:u,keptBytes:s,paths:o.paths};n[TRUNCATION_MARKER_KEY]=c}return{value:n,truncated:o.truncatedAnything,originalBytes:u,keptBytes:s,paths:o.paths}}i(boundedClone,"boundedClone"),l(boundedClone,"boundedClone");
|
package/lib/bounded-map.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var c=Object.defineProperty;var t=(e,r)=>c(e,"name",{value:r,configurable:!0});var i=Object.defineProperty,s=t((e,r)=>i(e,"name",{value:r,configurable:!0}),"o");export function capMap(e,r){if(e.size<=r)return 0;let n=0;const o=e.keys();for(;e.size>r;){const a=o.next();if(a.done)break;e.delete(a.value)&&(n+=1)}return n}t(capMap,"capMap"),s(capMap,"capMap");export const MAX_PRODUCER_KEYS=256;
|
package/lib/bounded-writer.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var y=Object.defineProperty;var r=(e,t)=>y(e,"name",{value:t,configurable:!0});var v=Object.defineProperty,o=r((e,t)=>v(e,"name",{value:t,configurable:!0}),"c");import{renameSync as l,statSync as f,unlinkSync as x}from"node:fs";export function eventMaxBytes(e=process.env){const t=Number(e.LENSMCP_EVENT_MAX_BYTES);return Number.isFinite(t)&&t>0?t:50*1024*1024}r(eventMaxBytes,"eventMaxBytes"),o(eventMaxBytes,"eventMaxBytes");export function eventMaxFiles(e=process.env){const t=Number(e.LENSMCP_EVENT_MAX_FILES);return Number.isFinite(t)&&t>=1&&t<=20?Math.floor(t):5}r(eventMaxFiles,"eventMaxFiles"),o(eventMaxFiles,"eventMaxFiles");const E=1024*1024,a=new Map;export function maybeRotateEventFile(e,t,i){const s=(a.get(e)??0)+t,c=i?.maxBytes??eventMaxBytes(),u=i?.maxFiles??eventMaxFiles(),m=Math.min(E,c);if(s<m){a.set(e,s);return}try{const n=f(e).size;if(a.set(e,0),n<=c)return}catch{a.set(e,s);return}try{x(`${e}.${u}`)}catch{}for(let n=u-1;n>=1;n--)try{l(`${e}.${n}`,`${e}.${n+1}`)}catch{}try{l(e,`${e}.1`)}catch{}}r(maybeRotateEventFile,"maybeRotateEventFile"),o(maybeRotateEventFile,"maybeRotateEventFile");export function resetRotationThrottle(e){e===void 0?a.clear():a.delete(e)}r(resetRotationThrottle,"resetRotationThrottle"),o(resetRotationThrottle,"resetRotationThrottle");
|
package/lib/capture-demand.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var c=Object.defineProperty;var o=(t,e)=>c(t,"name",{value:e,configurable:!0});var s=Object.defineProperty,u=o((t,e)=>s(t,"name",{value:e,configurable:!0}),"s");export const CAPTURE_REQUEST_FILENAME="capture-request.json",CAPTURE_PRESENCE_FILENAME="capture-runner.json";export function appMatchesPage(t,e){const r=t.trim().toLowerCase();if(!r)return!1;if(e.project&&e.project.toLowerCase()===r)return!0;const n=e.url.toLowerCase();if(n===r||n.replace(/\/+$/,"")===r.replace(/\/+$/,""))return!0;try{const a=new URL(e.url);return/^\d+$/.test(r)?a.port===r:a.origin.toLowerCase()===r.replace(/\/+$/,"")}catch{return!1}}o(appMatchesPage,"appMatchesPage"),u(appMatchesPage,"appMatchesPage");export const CAPTURE_RULES_FILENAME="capture-rules.json";
|
package/lib/context.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const FlowOriginTypeSchema: z.ZodEnum<{
|
|
3
|
-
request: "request";
|
|
4
3
|
"user-click": "user-click";
|
|
5
4
|
"user-input": "user-input";
|
|
6
5
|
keyboard: "keyboard";
|
|
@@ -26,6 +25,7 @@ export declare const FlowOriginTypeSchema: z.ZodEnum<{
|
|
|
26
25
|
"page-load": "page-load";
|
|
27
26
|
"form-submit": "form-submit";
|
|
28
27
|
"input-change": "input-change";
|
|
28
|
+
request: "request";
|
|
29
29
|
job: "job";
|
|
30
30
|
}>;
|
|
31
31
|
export type FlowOriginType = z.infer<typeof FlowOriginTypeSchema>;
|
|
@@ -38,7 +38,6 @@ export declare const TraceContextSchema: z.ZodObject<{
|
|
|
38
38
|
url: z.ZodOptional<z.ZodString>;
|
|
39
39
|
flowId: z.ZodOptional<z.ZodString>;
|
|
40
40
|
originType: z.ZodOptional<z.ZodEnum<{
|
|
41
|
-
request: "request";
|
|
42
41
|
"user-click": "user-click";
|
|
43
42
|
"user-input": "user-input";
|
|
44
43
|
keyboard: "keyboard";
|
|
@@ -64,6 +63,7 @@ export declare const TraceContextSchema: z.ZodObject<{
|
|
|
64
63
|
"page-load": "page-load";
|
|
65
64
|
"form-submit": "form-submit";
|
|
66
65
|
"input-change": "input-change";
|
|
66
|
+
request: "request";
|
|
67
67
|
job: "job";
|
|
68
68
|
}>>;
|
|
69
69
|
originNodeId: z.ZodOptional<z.ZodString>;
|
package/lib/dashboard-path.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* the server's suggestion refs), so a link reloads, pastes and opens in a new tab.
|
|
4
4
|
*
|
|
5
5
|
* An id can hold `/` (a page `dashboard /companies/:id`, a route `assistant GET /v1/x`), and both gateways refuse a
|
|
6
|
-
* path holding `%2F`, `%2E`, `%5C`, `%00` or a backslash (
|
|
6
|
+
* path holding `%2F`, `%2E`, `%5C`, `%00` or a backslash (ringwall canonical-path.ts, dev-gateway-11, prod-gateway-2) —
|
|
7
7
|
* so those never go out percent-encoded. `~` escapes them instead: `~s` a slash, `~b` a backslash, `~0` NUL, `~d` a
|
|
8
8
|
* dot of a `.` / `..` id (a dot segment the browser would resolve and the gateway refuse), `~~` a tilde. The rest is
|
|
9
9
|
* `encodeURIComponent`, with `:` and `@` left as they are to read: `dashboard%20~scompanies~s:id`.
|
package/lib/dashboard-path.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var o=Object.defineProperty;var c=(e,t)=>o(e,"name",{value:t,configurable:!0});var d=Object.defineProperty,n=c((e,t)=>d(e,"name",{value:t,configurable:!0}),"t");const a={"~":"~~","/":"~s","\\":"~b","\0":"~0"},p={"~":"~",s:"/",b:"\\",0:"\0",d:"."},g=/%2f|%5c|%2e|%00/i;export function encodeSegment(e){return e==="."||e===".."?e.replace(/\./g,"~d"):encodeURIComponent(e.replace(/[~/\\\0]/g,t=>a[t])).replace(/%3A/g,":").replace(/%40/g,"@")}c(encodeSegment,"encodeSegment"),n(encodeSegment,"encodeSegment");export function decodeSegment(e){let t;try{t=decodeURIComponent(e)}catch{t=e}return g.test(e)?t:t.replace(/~([~sb0d])/g,(l,r)=>p[r])}c(decodeSegment,"decodeSegment"),n(decodeSegment,"decodeSegment");
|
package/lib/dashboard.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ import type { PageVisitNavType, PageVisitRaw, PageVisitReadyBy, PageVisitRequest
|
|
|
16
16
|
import type { WorktreeRunOutcome } from './workspace-actions.js';
|
|
17
17
|
import type { DesignStage } from './goal-design.js';
|
|
18
18
|
import type { DashExternalBefore, DashSqlBefore } from './metrics-reset.js';
|
|
19
|
+
import type { ExpectedFailureMatch } from './expected-failure.js';
|
|
19
20
|
/** Bumped only on a breaking change to the stream framing itself. */
|
|
20
21
|
export declare const DASHBOARD_PROTOCOL = 1;
|
|
21
22
|
/** The swimlane a flow event belongs to (mirrors `FlowArea` in `@lensmcp/core`'s flow-shape). */
|
|
@@ -905,6 +906,49 @@ export interface DashErrorGroup {
|
|
|
905
906
|
/** Who dismissed it — a person here, a person at the CLI, or an agent — and the reason they gave. */
|
|
906
907
|
dismissedBy?: 'dashboard' | 'cli' | 'agent';
|
|
907
908
|
dismissedReason?: string;
|
|
909
|
+
/** Occurrences of it a standing rule held back (overseer-86): not in `count`. On a group in `DashErrors.expected.groups`, all of them. */
|
|
910
|
+
expectedCount?: number;
|
|
911
|
+
/** The rule that holds it back — on a group in `DashErrors.expected.groups`. */
|
|
912
|
+
expectedBy?: string;
|
|
913
|
+
expectedReason?: string;
|
|
914
|
+
}
|
|
915
|
+
/** A standing rule as Errors lists it (overseer-86, expected-failure.ts `ExpectedRuleView`). */
|
|
916
|
+
export interface DashExpectedRule {
|
|
917
|
+
id: string;
|
|
918
|
+
match: ExpectedFailureMatch;
|
|
919
|
+
/** The match in a line: `auth · GET /session/token · 401`. */
|
|
920
|
+
label: string;
|
|
921
|
+
reason: string;
|
|
922
|
+
by: 'dashboard' | 'cli' | 'agent' | 'repository';
|
|
923
|
+
createdAt: number;
|
|
924
|
+
expiresAt?: number;
|
|
925
|
+
title?: string;
|
|
926
|
+
hits: number;
|
|
927
|
+
lastHitAt?: number;
|
|
928
|
+
lastHour: number;
|
|
929
|
+
/** It matches far more than its usual rate: said once, as «this expected failure is now happening much more often». */
|
|
930
|
+
surge?: {
|
|
931
|
+
since: number;
|
|
932
|
+
lastHour: number;
|
|
933
|
+
usualPerHour: number;
|
|
934
|
+
line: string;
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
/** What the standing rules held back from this list — never silent. */
|
|
938
|
+
export interface DashExpected {
|
|
939
|
+
/** «2 rules held back 61 occurrences in the last hour». */
|
|
940
|
+
line: string;
|
|
941
|
+
/** Rules that held something back in the last hour, and those occurrences. */
|
|
942
|
+
rulesHolding: number;
|
|
943
|
+
lastHour: number;
|
|
944
|
+
/** Occurrences held back across the groups the error log keeps (whole groups and parts of shown ones). */
|
|
945
|
+
held: number;
|
|
946
|
+
/** Every rule in effect. */
|
|
947
|
+
rules: DashExpectedRule[];
|
|
948
|
+
/** Groups every occurrence of which is held back — listed on request, marked «expected». */
|
|
949
|
+
groups: DashErrorGroup[];
|
|
950
|
+
/** Problems reading `lensmcp.json` → `config.expectedFailures`, if any. */
|
|
951
|
+
problems?: string[];
|
|
908
952
|
}
|
|
909
953
|
export interface DashErrors {
|
|
910
954
|
at: number;
|
|
@@ -933,6 +977,8 @@ export interface DashErrors {
|
|
|
933
977
|
* plus any the error log itself let go of. Per-cause drops are on each cause (`DashErrorCause.dropped`).
|
|
934
978
|
*/
|
|
935
979
|
dropped?: number;
|
|
980
|
+
/** What standing rules held back, and the rules (overseer-86). Absent when no rule is in effect, and from an older server. */
|
|
981
|
+
expected?: DashExpected;
|
|
936
982
|
}
|
|
937
983
|
/** Where a cause surfaced: one of its groups, as a row of the cause («GET /documents → 500 ×30»). */
|
|
938
984
|
export interface DashErrorSurface {
|
package/lib/edge.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const EdgeAxisSchema: z.ZodEnum<{
|
|
3
|
-
state: "state";
|
|
4
|
-
network: "network";
|
|
5
|
-
data: "data";
|
|
6
3
|
db: "db";
|
|
7
|
-
visual: "visual";
|
|
8
4
|
memory: "memory";
|
|
5
|
+
visual: "visual";
|
|
9
6
|
render: "render";
|
|
7
|
+
state: "state";
|
|
8
|
+
network: "network";
|
|
10
9
|
backend: "backend";
|
|
11
10
|
performance: "performance";
|
|
12
11
|
lifecycle: "lifecycle";
|
|
13
12
|
ownership: "ownership";
|
|
14
13
|
caused: "caused";
|
|
15
14
|
async: "async";
|
|
15
|
+
data: "data";
|
|
16
16
|
}>;
|
|
17
17
|
export type EdgeAxis = z.infer<typeof EdgeAxisSchema>;
|
|
18
18
|
export declare const TraceEdgeSchema: z.ZodObject<{
|
|
@@ -20,19 +20,19 @@ export declare const TraceEdgeSchema: z.ZodObject<{
|
|
|
20
20
|
from: z.ZodString;
|
|
21
21
|
to: z.ZodString;
|
|
22
22
|
axis: z.ZodEnum<{
|
|
23
|
-
state: "state";
|
|
24
|
-
network: "network";
|
|
25
|
-
data: "data";
|
|
26
23
|
db: "db";
|
|
27
|
-
visual: "visual";
|
|
28
24
|
memory: "memory";
|
|
25
|
+
visual: "visual";
|
|
29
26
|
render: "render";
|
|
27
|
+
state: "state";
|
|
28
|
+
network: "network";
|
|
30
29
|
backend: "backend";
|
|
31
30
|
performance: "performance";
|
|
32
31
|
lifecycle: "lifecycle";
|
|
33
32
|
ownership: "ownership";
|
|
34
33
|
caused: "caused";
|
|
35
34
|
async: "async";
|
|
35
|
+
data: "data";
|
|
36
36
|
}>;
|
|
37
37
|
type: z.ZodString;
|
|
38
38
|
timestamp: z.ZodNumber;
|
package/lib/error-cause.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)[0].replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,"<id>").replace(/\b[0-9A-HJKMNP-TV-Z]{26}\b/g,"<id>").replace(/0x[0-9a-f]+/gi,"<hex>").replace(/\b[0-9a-f]{12,}\b/gi,"<id>").replace(/\d+/g,"#").trim().slice(0,140):""}n(foldMessage,"foldMessage"),
|
|
3
|
-
`)[0].trim());return t?{name:t[1],message:t[2].trim()}:void 0}n(
|
|
4
|
-
`)){const o=/^\s*at\s+(.+)$/.exec(t);if(!o||/node_modules|node:internal|node:async_hooks|\(native\)|<anonymous>|\(internal\//.test(o[1]))continue;const
|
|
5
|
-
`)[0].trim();const
|
|
1
|
+
"use strict";var l=Object.defineProperty;var n=(e,t)=>l(e,"name",{value:t,configurable:!0});var p=Object.defineProperty,i=n((e,t)=>p(e,"name",{value:t,configurable:!0}),"n");export function joinId(e,t){const o=i(a=>a.replace(/%/g,"%25").replace(/:/g,"%3A"),"esc");return[e,...t.map(a=>o(a===void 0?"":String(a)))].join(":")}n(joinId,"joinId"),i(joinId,"joinId");export function foldMessage(e){return e?e.split(`
|
|
2
|
+
`)[0].replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,"<id>").replace(/\b[0-9A-HJKMNP-TV-Z]{26}\b/g,"<id>").replace(/0x[0-9a-f]+/gi,"<hex>").replace(/\b[0-9a-f]{12,}\b/gi,"<id>").replace(/\d+/g,"#").trim().slice(0,140):""}n(foldMessage,"foldMessage"),i(foldMessage,"foldMessage");const f=/^(?:Uncaught\s+(?:\(in promise\)\s+)?)?((?:[A-Za-z_$][\w$]*)?(?:Error|Exception|Failure|Fault|Rejection))(?:\s*\[[^\]]*\])?:\s*(.+)$/;function c(e){const t=f.exec((e??"").split(`
|
|
3
|
+
`)[0].trim());return t?{name:t[1],message:t[2].trim()}:void 0}n(c,"r"),i(c,"named");export function appFrameOf(e){for(const t of(e??"").split(`
|
|
4
|
+
`)){const o=/^\s*at\s+(.+)$/.exec(t);if(!o||/node_modules|node:internal|node:async_hooks|\(native\)|<anonymous>|\(internal\//.test(o[1]))continue;const a=/\(?([^()\s]+?):(\d+)(?::\d+)?\)?$/.exec(o[1].trim());return a?`${a[1].replace(/^.*?\/(?=(?:src|apps|libs)\/)/,"")}:${a[2]}`:o[1].trim()}}n(appFrameOf,"appFrameOf"),i(appFrameOf,"appFrameOf");export function errorCause(e){const t=c(e.stack),o=c(e.message),a=c(e.title),r=e.name?.trim()||t?.name||o?.name||a?.name;if(!r)return;let s=(t&&t.name===r?t.message:void 0)??e.message??a?.message??e.title??"";const m=c(s);m&&m.name===r&&(s=m.message),s=s.split(`
|
|
5
|
+
`)[0].trim();const h=appFrameOf(e.stack),u=g.has(errorHeadline({name:r,message:s})?.id??"");return{id:joinId("cause",[r,foldMessage(s),u?void 0:h]),errorName:r,message:s,...h?{frame:h}:{}}}n(errorCause,"errorCause"),i(errorCause,"errorCause");const g=new Set(["missing-column","missing-table","connection-refused","out-of-memory"]);export function causeIdWithoutFrame(e){return joinId("cause",[e.errorName,foldMessage(e.message),void 0])}n(causeIdWithoutFrame,"causeIdWithoutFrame"),i(causeIdWithoutFrame,"causeIdWithoutFrame");const d=i(e=>e?` (\xAB${e}\xBB)`:"","q");export const ERROR_HEADLINES=[{id:"missing-column",match:i(e=>/column "?([\w.]+)"?(?: of relation "?[\w.]+"?)? does not exist|Unknown column '([^']+)'|ER_BAD_FIELD_ERROR/i.exec(e),"match"),say:i(e=>({headline:`The code expects a database column${d(e===!0?void 0:e[1]??e[2])} the database doesn't have`,hint:"Run the migrations, or add the migration the entity change needs."}),"say")},{id:"missing-table",match:i(e=>/relation "?([\w.]+)"? does not exist|Table '([^']+)' doesn't exist|ER_NO_SUCH_TABLE/i.exec(e),"match"),say:i(e=>({headline:`The code expects a database table${d(e===!0?void 0:e[1]??e[2])} the database doesn't have`,hint:"Run the migrations against this database."}),"say")},{id:"unique-violation",match:i((e,t)=>/duplicate key value violates unique constraint "?([\w.]+)"?|Duplicate entry '[^']*' for key '([^']+)'|ER_DUP_ENTRY/i.exec(e)||t.code==="23505","match"),say:i(e=>({headline:`A row with the same unique value already exists${d(e===!0?void 0:e[1]??e[2])}`,hint:"The code inserts a duplicate: look up the existing row first, or upsert."}),"say")},{id:"foreign-key-violation",match:i((e,t)=>/violates foreign key constraint "?([\w.]+)"?|a foreign key constraint fails|ER_NO_REFERENCED_ROW|ER_ROW_IS_REFERENCED/i.exec(e)||t.code==="23503","match"),say:i(e=>({headline:`A row points at a row that doesn't exist, or a row still in use was deleted${d(e===!0?void 0:e[1])}`,hint:"Create the referenced row first, or delete the rows that point at it."}),"say")},{id:"connection-refused",match:i((e,t)=>/ECONNREFUSED|connection refused|connect ECONNREFUSED/i.exec(e)||t.code==="ECONNREFUSED","match"),say:i(()=>({headline:"A service the code connects to is not running, or not listening where the code looks",hint:"Start it (database, cache, broker or API), or fix its host and port."}),"say")},{id:"out-of-memory",match:i((e,t)=>/heap out of memory|JavaScript heap|out of memory|ENOMEM|Allocation failed/i.exec(e)||t.code==="ENOMEM","match"),say:i(()=>({headline:"The process ran out of memory",hint:"Something holds or loads too much at once \u2014 look for an unbounded list, cache or query."}),"say")},{id:"jwt-expired",match:i((e,t)=>/jwt expired|token expired/i.exec(e)||t.name==="TokenExpiredError","match"),say:i(()=>({headline:"A sign-in token expired",hint:"Sign in again; if it keeps happening, the client is not refreshing its token."}),"say")},{id:"jwt-invalid",match:i((e,t)=>/jwt malformed|invalid signature|invalid token|jwt must be provided|jwt audience invalid|jwt issuer invalid/i.exec(e)||t.name==="JsonWebTokenError","match"),say:i(()=>({headline:"A sign-in token is not valid here",hint:"Its signature, audience or issuer does not match what this service expects."}),"say")},{id:"timeout",match:i((e,t)=>/ETIMEDOUT|ESOCKETTIMEDOUT|timed? ?out|timeout exceeded|statement timeout|canceling statement due to|Query read timeout/i.exec(e)||t.name==="TimeoutError"||t.code==="ETIMEDOUT","match"),say:i(()=>({headline:"Something took too long and was cut off",hint:"A slow query, a busy dependency or a lock \u2014 open the failing step to see which."}),"say")},{id:"unauthorized",match:i((e,t)=>t.status===401||t.name==="UnauthorizedException"||/^Unauthorized$/i.test(e.trim()),"match"),say:i(()=>({headline:"The request was not signed in (401)",hint:"It came without a valid session or token."}),"say")},{id:"forbidden",match:i((e,t)=>t.status===403||t.name==="ForbiddenException"||/^Forbidden(?: resource)?$/i.test(e.trim()),"match"),say:i(()=>({headline:"The signed-in user is not allowed to do this (403)",hint:"A role or permission check refused it."}),"say")}];export function errorHeadline(e){const t=[e.code,e.message].filter(Boolean).join(" ");for(const o of ERROR_HEADLINES){const a=o.match(t,e);if(a)return{id:o.id,...o.say(a)}}}n(errorHeadline,"errorHeadline"),i(errorHeadline,"errorHeadline");
|
package/lib/error-dismissal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var f=Object.defineProperty;var s=(t,r)=>f(t,"name",{value:r,configurable:!0});var E=Object.defineProperty,S=s((t,r)=>E(t,"name",{value:r,configurable:!0}),"s");export const ERROR_DISMISSED="error-dismissed",ERROR_RESTORED="error-restored",LENS_EVENT_SOURCE="lens",MAX_DISMISSAL_EVENT_IDS=200;const g=2048;export const MAX_DISMISSAL_REASON_CHARS=500;const m=300,I=new Set(["dashboard","cli","agent"]);export function readErrorDismissal(t){if(t.source!==LENS_EVENT_SOURCE||!t.raw||typeof t.raw!="object")return;const r=t.raw,i=r.groupId;if(typeof i!="string"||i.length===0||i.length>2048)return;if(r.kind===ERROR_RESTORED)return{kind:ERROR_RESTORED,groupId:i};if(r.kind!==ERROR_DISMISSED)return;const n=r.until;if(typeof n!="number"||!Number.isFinite(n))return;const c=Array.isArray(r.eventIds)?r.eventIds.filter(e=>typeof e=="string"&&e.length>0).slice(0,200):[],o=I.has(r.by)?r.by:void 0,a=S((e,l)=>typeof e=="string"&&e.trim()?e.trim().slice(0,l):void 0,"text"),d=a(r.reason,500),u=a(r.title,300);return{kind:ERROR_DISMISSED,groupId:i,until:Math.min(n,t.timestamp),eventIds:c,...o?{by:o}:{},...d?{reason:d}:{},...u?{title:u}:{}}}s(readErrorDismissal,"readErrorDismissal"),S(readErrorDismissal,"readErrorDismissal");
|
package/lib/event-loop.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var f=Object.defineProperty;var
|
|
1
|
+
"use strict";var f=Object.defineProperty;var r=(t,e)=>f(t,"name",{value:e,configurable:!0});var p=Object.defineProperty,a=r((t,e)=>p(t,"name",{value:e,configurable:!0}),"r");export const LENS_CAUSES={"lensmcp-gc":"forced GC","lensmcp-cleanup":"cleanup","lensmcp-write":"writing events","lensmcp-capture":"capturing values"};export function lensOwnWork(t){const e=typeof t.cause=="string"&&t.cause.startsWith("lensmcp-");if(!e&&!(typeof t.lensMs=="number"&&t.durationMs>0&&t.lensMs>=t.durationMs/2))return;const o=e?LENS_CAUSES[t.cause]:void 0;return o?`LensMCP's own work \u2014 ${o}`:"LensMCP's own work"}r(lensOwnWork,"lensOwnWork"),a(lensOwnWork,"lensOwnWork");export function waitedBehind(t){const e=new Set,o=new Set;for(const n of t.evidence)n.relation==="executing"||(n.requestId?n.requestId===t.requestId:!n.flowId||n.flowId===t.flowId)||(e.add(n.requestId??n.flowId),n.flowId&&n.flowId!==t.flowId&&o.add(n.flowId));return{requests:e.size,flows:o.size,atLeast:t.evidenceTruncated}}r(waitedBehind,"waitedBehind"),a(waitedBehind,"waitedBehind");export function waitedLine(t){const e=waitedBehind(t);return e.requests?`${e.atLeast?"at least ":""}${e.requests} request${e.requests===1?"":"s"} waited behind it`:void 0}r(waitedLine,"waitedLine"),a(waitedLine,"waitedLine");export function flowStalls(t,e){const o={ran:[],overlapped:[]};for(const n of t){if(lensOwnWork(n))continue;if(n.flowId===e){o.ran.push(n);continue}const u=n.endAt??n.observedAt,c=n.evidence.filter(s=>s.flowId===e).map(s=>[Math.max(s.startAt,n.startAt),Math.min(s.endAt,u)]).filter(([s,i])=>i>=s).sort((s,i)=>s[0]-i[0]);if(!c.length)continue;let d=0,l=-1/0;for(const[s,i]of c)i>l&&(d+=i-Math.max(s,l)),l=Math.max(l,i);o.overlapped.push({incident:n,overlapMs:Math.round(d*100)/100})}return o}r(flowStalls,"flowStalls"),a(flowStalls,"flowStalls");export function overlapLine(t){if(!t.length)return;const e=[...new Set(t.map(u=>u.incident.loop.project))],o=e.length<=2?e.join(" and "):`${e.length} services`,n=t.length;return{count:n,services:e,longestMs:Math.max(...t.map(u=>u.overlapMs)),text:`${n} pause${n===1?"":"s"} in ${o} while this flow was open \u2014 not this flow\u2019s code`}}r(overlapLine,"overlapLine"),a(overlapLine,"overlapLine");export const LOOP_STARTUP_MS=6e4;export function loopStartedAt(t){if(!t.startsWith("node:"))return;const e=Number(t.slice(t.lastIndexOf(":")+1));return Number.isFinite(e)&&e>0?e:void 0}r(loopStartedAt,"loopStartedAt"),a(loopStartedAt,"loopStartedAt");export function loopPhaseAt(t,e){const o=loopStartedAt(t);if(o===void 0)return;const n=Math.max(0,Math.round(e-o));return{phase:n<LOOP_STARTUP_MS?"startup":"running",sinceStartMs:n}}r(loopPhaseAt,"loopPhaseAt"),a(loopPhaseAt,"loopPhaseAt");
|
package/lib/event.d.ts
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const EventSourceSchema: z.ZodEnum<{
|
|
3
|
-
gateway: "gateway";
|
|
4
|
-
ai: "ai";
|
|
5
|
-
db: "db";
|
|
6
|
-
redis: "redis";
|
|
7
|
-
queue: "queue";
|
|
8
|
-
external: "external";
|
|
9
|
-
visual: "visual";
|
|
10
|
-
react: "react";
|
|
11
|
-
memory: "memory";
|
|
12
|
-
lens: "lens";
|
|
13
3
|
nx: "nx";
|
|
14
4
|
vite: "vite";
|
|
15
5
|
typescript: "typescript";
|
|
@@ -17,41 +7,51 @@ export declare const EventSourceSchema: z.ZodEnum<{
|
|
|
17
7
|
rollup: "rollup";
|
|
18
8
|
"client-runtime": "client-runtime";
|
|
19
9
|
chrome: "chrome";
|
|
10
|
+
react: "react";
|
|
20
11
|
valtio: "valtio";
|
|
21
12
|
nestjs: "nestjs";
|
|
22
13
|
nextjs: "nextjs";
|
|
14
|
+
db: "db";
|
|
15
|
+
redis: "redis";
|
|
16
|
+
queue: "queue";
|
|
17
|
+
memory: "memory";
|
|
18
|
+
visual: "visual";
|
|
23
19
|
perf: "perf";
|
|
24
20
|
security: "security";
|
|
21
|
+
gateway: "gateway";
|
|
22
|
+
external: "external";
|
|
23
|
+
ai: "ai";
|
|
24
|
+
lens: "lens";
|
|
25
25
|
custom: "custom";
|
|
26
26
|
}>;
|
|
27
27
|
export type EventSource = z.infer<typeof EventSourceSchema>;
|
|
28
28
|
export declare const EventCategorySchema: z.ZodEnum<{
|
|
29
|
-
test: "test";
|
|
30
|
-
typecheck: "typecheck";
|
|
31
|
-
lint: "lint";
|
|
32
|
-
build: "build";
|
|
33
|
-
state: "state";
|
|
34
|
-
agent: "agent";
|
|
35
|
-
network: "network";
|
|
36
|
-
ai: "ai";
|
|
37
29
|
db: "db";
|
|
38
|
-
visual: "visual";
|
|
39
30
|
memory: "memory";
|
|
40
|
-
|
|
41
|
-
trace: "trace";
|
|
31
|
+
visual: "visual";
|
|
42
32
|
security: "security";
|
|
33
|
+
ai: "ai";
|
|
34
|
+
build: "build";
|
|
35
|
+
lint: "lint";
|
|
36
|
+
typecheck: "typecheck";
|
|
37
|
+
test: "test";
|
|
43
38
|
runtime: "runtime";
|
|
44
39
|
render: "render";
|
|
40
|
+
trace: "trace";
|
|
41
|
+
state: "state";
|
|
42
|
+
network: "network";
|
|
45
43
|
backend: "backend";
|
|
46
44
|
performance: "performance";
|
|
47
45
|
deps: "deps";
|
|
46
|
+
cluster: "cluster";
|
|
47
|
+
agent: "agent";
|
|
48
48
|
}>;
|
|
49
49
|
export type EventCategory = z.infer<typeof EventCategorySchema>;
|
|
50
50
|
export declare const SeveritySchema: z.ZodEnum<{
|
|
51
51
|
error: "error";
|
|
52
|
+
debug: "debug";
|
|
52
53
|
info: "info";
|
|
53
54
|
warning: "warning";
|
|
54
|
-
debug: "debug";
|
|
55
55
|
fatal: "fatal";
|
|
56
56
|
}>;
|
|
57
57
|
export type Severity = z.infer<typeof SeveritySchema>;
|
|
@@ -60,16 +60,6 @@ export declare const BaseEventSchema: z.ZodObject<{
|
|
|
60
60
|
sessionId: z.ZodString;
|
|
61
61
|
timestamp: z.ZodNumber;
|
|
62
62
|
source: z.ZodEnum<{
|
|
63
|
-
gateway: "gateway";
|
|
64
|
-
ai: "ai";
|
|
65
|
-
db: "db";
|
|
66
|
-
redis: "redis";
|
|
67
|
-
queue: "queue";
|
|
68
|
-
external: "external";
|
|
69
|
-
visual: "visual";
|
|
70
|
-
react: "react";
|
|
71
|
-
memory: "memory";
|
|
72
|
-
lens: "lens";
|
|
73
63
|
nx: "nx";
|
|
74
64
|
vite: "vite";
|
|
75
65
|
typescript: "typescript";
|
|
@@ -77,39 +67,49 @@ export declare const BaseEventSchema: z.ZodObject<{
|
|
|
77
67
|
rollup: "rollup";
|
|
78
68
|
"client-runtime": "client-runtime";
|
|
79
69
|
chrome: "chrome";
|
|
70
|
+
react: "react";
|
|
80
71
|
valtio: "valtio";
|
|
81
72
|
nestjs: "nestjs";
|
|
82
73
|
nextjs: "nextjs";
|
|
74
|
+
db: "db";
|
|
75
|
+
redis: "redis";
|
|
76
|
+
queue: "queue";
|
|
77
|
+
memory: "memory";
|
|
78
|
+
visual: "visual";
|
|
83
79
|
perf: "perf";
|
|
84
80
|
security: "security";
|
|
81
|
+
gateway: "gateway";
|
|
82
|
+
external: "external";
|
|
83
|
+
ai: "ai";
|
|
84
|
+
lens: "lens";
|
|
85
85
|
custom: "custom";
|
|
86
86
|
}>;
|
|
87
87
|
category: z.ZodEnum<{
|
|
88
|
-
test: "test";
|
|
89
|
-
typecheck: "typecheck";
|
|
90
|
-
lint: "lint";
|
|
91
|
-
build: "build";
|
|
92
|
-
state: "state";
|
|
93
|
-
agent: "agent";
|
|
94
|
-
network: "network";
|
|
95
|
-
ai: "ai";
|
|
96
88
|
db: "db";
|
|
97
|
-
visual: "visual";
|
|
98
89
|
memory: "memory";
|
|
99
|
-
|
|
100
|
-
trace: "trace";
|
|
90
|
+
visual: "visual";
|
|
101
91
|
security: "security";
|
|
92
|
+
ai: "ai";
|
|
93
|
+
build: "build";
|
|
94
|
+
lint: "lint";
|
|
95
|
+
typecheck: "typecheck";
|
|
96
|
+
test: "test";
|
|
102
97
|
runtime: "runtime";
|
|
103
98
|
render: "render";
|
|
99
|
+
trace: "trace";
|
|
100
|
+
state: "state";
|
|
101
|
+
network: "network";
|
|
104
102
|
backend: "backend";
|
|
105
103
|
performance: "performance";
|
|
106
104
|
deps: "deps";
|
|
105
|
+
cluster: "cluster";
|
|
106
|
+
agent: "agent";
|
|
107
107
|
}>;
|
|
108
108
|
severity: z.ZodEnum<{
|
|
109
109
|
error: "error";
|
|
110
|
+
debug: "debug";
|
|
110
111
|
info: "info";
|
|
111
112
|
warning: "warning";
|
|
112
|
-
debug: "debug";
|
|
113
113
|
fatal: "fatal";
|
|
114
114
|
}>;
|
|
115
115
|
context: z.ZodObject<{
|
|
@@ -121,7 +121,6 @@ export declare const BaseEventSchema: z.ZodObject<{
|
|
|
121
121
|
url: z.ZodOptional<z.ZodString>;
|
|
122
122
|
flowId: z.ZodOptional<z.ZodString>;
|
|
123
123
|
originType: z.ZodOptional<z.ZodEnum<{
|
|
124
|
-
request: "request";
|
|
125
124
|
"user-click": "user-click";
|
|
126
125
|
"user-input": "user-input";
|
|
127
126
|
keyboard: "keyboard";
|
|
@@ -147,6 +146,7 @@ export declare const BaseEventSchema: z.ZodObject<{
|
|
|
147
146
|
"page-load": "page-load";
|
|
148
147
|
"form-submit": "form-submit";
|
|
149
148
|
"input-change": "input-change";
|
|
149
|
+
request: "request";
|
|
150
150
|
job: "job";
|
|
151
151
|
}>>;
|
|
152
152
|
originNodeId: z.ZodOptional<z.ZodString>;
|