@lensmcp/protocol-types 1.24.4 → 1.25.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.
- package/index.d.ts +2 -0
- package/index.js +1 -1
- package/lib/capture-demand.d.ts +13 -0
- package/lib/capture-demand.js +1 -1
- package/lib/dashboard.d.ts +1973 -0
- package/lib/dashboard.js +1 -1
- package/lib/event.d.ts +2 -0
- package/lib/event.js +1 -1
- package/lib/http-exchange.d.ts +80 -0
- package/lib/http-exchange.js +1 -0
- package/lib/log-query.d.ts +30 -0
- package/lib/log-query.js +1 -0
- package/lib/resources.d.ts +12 -12
- package/package.json +1 -1
package/lib/dashboard.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export const DASHBOARD_PROTOCOL=1;
|
|
1
|
+
"use strict";export const DASHBOARD_PROTOCOL=1,DASH_PERF_KINDS=["n-plus-one","db-in-loop","render-storm","slow-path","slow-route","slow-query","missing-index","leak","egress-slow","duplicate-requests","perf-rule","other"];
|
package/lib/event.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export declare const EventCategorySchema: z.ZodEnum<{
|
|
|
43
43
|
performance: "performance";
|
|
44
44
|
deps: "deps";
|
|
45
45
|
cluster: "cluster";
|
|
46
|
+
agent: "agent";
|
|
46
47
|
}>;
|
|
47
48
|
export type EventCategory = z.infer<typeof EventCategorySchema>;
|
|
48
49
|
export declare const SeveritySchema: z.ZodEnum<{
|
|
@@ -100,6 +101,7 @@ export declare const BaseEventSchema: z.ZodObject<{
|
|
|
100
101
|
performance: "performance";
|
|
101
102
|
deps: "deps";
|
|
102
103
|
cluster: "cluster";
|
|
104
|
+
agent: "agent";
|
|
103
105
|
}>;
|
|
104
106
|
severity: z.ZodEnum<{
|
|
105
107
|
debug: "debug";
|
package/lib/event.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{z as e}from"zod";import{SourceLocationSchema as t}from"./source-location.js";import{TraceContextSchema as r}from"./context.js";export const EventSourceSchema=e.enum(["nx","vite","typescript","eslint","rollup","client-runtime","chrome","react","valtio","nestjs","nextjs","db","redis","queue","memory","visual","perf","security","gateway","external","ai","lens"]),EventCategorySchema=e.enum(["build","lint","typecheck","test","runtime","render","visual","trace","state","network","backend","db","memory","performance","security","deps","cluster","ai"]),SeveritySchema=e.enum(["debug","info","warning","error","fatal"]),BaseEventSchema=e.object({id:e.string(),sessionId:e.string(),timestamp:e.number().int().nonnegative(),source:EventSourceSchema,category:EventCategorySchema,severity:SeveritySchema,context:r,fingerprint:e.string(),title:e.string(),message:e.string().optional(),location:t.optional(),relatedFiles:e.array(e.string()).optional(),relatedUrls:e.array(e.string()).optional(),raw:e.unknown().optional()});
|
|
1
|
+
"use strict";import{z as e}from"zod";import{SourceLocationSchema as t}from"./source-location.js";import{TraceContextSchema as r}from"./context.js";export const EventSourceSchema=e.enum(["nx","vite","typescript","eslint","rollup","client-runtime","chrome","react","valtio","nestjs","nextjs","db","redis","queue","memory","visual","perf","security","gateway","external","ai","lens"]),EventCategorySchema=e.enum(["build","lint","typecheck","test","runtime","render","visual","trace","state","network","backend","db","memory","performance","security","deps","cluster","ai","agent"]),SeveritySchema=e.enum(["debug","info","warning","error","fatal"]),BaseEventSchema=e.object({id:e.string(),sessionId:e.string(),timestamp:e.number().int().nonnegative(),source:EventSourceSchema,category:EventCategorySchema,severity:SeveritySchema,context:r,fingerprint:e.string(),title:e.string(),message:e.string().optional(),location:t.optional(),relatedFiles:e.array(e.string()).optional(),relatedUrls:e.array(e.string()).optional(),raw:e.unknown().optional()});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One HTTP exchange the lens captured (R6): a service's outbound call as it went over the wire — its request and
|
|
3
|
+
* response headers (redacted), the query string and the bodies (redacted, the first 64 KB of each), and for a
|
|
4
|
+
* server-sent-events response every event with the moment it arrived. Kept OFF the bus, one file per exchange under
|
|
5
|
+
* `.lensmcp/http/`; the bus event carries its `exchangeId`. Capture: `LENSMCP_HTTP_CAPTURE=off | headers | bodies`.
|
|
6
|
+
*
|
|
7
|
+
* An AI provider's call keeps its conversation out of here: its headers, sizes and stream timing are captured, its
|
|
8
|
+
* prompt and completion only by the AI tap, opt-in (`LENSMCP_AI_CAPTURE=content`).
|
|
9
|
+
*/
|
|
10
|
+
export interface HttpExchangeBody {
|
|
11
|
+
contentType: string;
|
|
12
|
+
/** Every byte it had, kept or not. */
|
|
13
|
+
size: number;
|
|
14
|
+
/** The bytes kept as text (the first 64 KB). */
|
|
15
|
+
kept: number;
|
|
16
|
+
text?: string;
|
|
17
|
+
/** A binary body: its digest instead of its bytes (when it was small enough to hash). */
|
|
18
|
+
sha256?: string;
|
|
19
|
+
truncated: boolean;
|
|
20
|
+
/** Why there is no text: `binary`, `form-data`, `stream` (a request body sent as a stream), `ai`. */
|
|
21
|
+
omitted?: 'binary' | 'form-data' | 'stream' | 'ai';
|
|
22
|
+
}
|
|
23
|
+
export interface HttpExchangeStreamEvent {
|
|
24
|
+
/** Since the request started. */
|
|
25
|
+
atMs: number;
|
|
26
|
+
event: string;
|
|
27
|
+
bytes: number;
|
|
28
|
+
/** Its data, redacted, at most 4 KB — absent for an AI provider's stream. */
|
|
29
|
+
data?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface HttpExchange {
|
|
32
|
+
schemaVersion: 1;
|
|
33
|
+
id: string;
|
|
34
|
+
capturedAt: number;
|
|
35
|
+
side: 'egress';
|
|
36
|
+
service?: string;
|
|
37
|
+
flowId?: string;
|
|
38
|
+
requestId?: string;
|
|
39
|
+
method: string;
|
|
40
|
+
/** Scheme, host and path — the query is in `request.query`, redacted. */
|
|
41
|
+
url: string;
|
|
42
|
+
host: string;
|
|
43
|
+
path: string;
|
|
44
|
+
status?: number;
|
|
45
|
+
statusText?: string;
|
|
46
|
+
/** A transport error: refused, reset, timed out, aborted. */
|
|
47
|
+
error?: string;
|
|
48
|
+
startedAt: number;
|
|
49
|
+
/** When the response headers arrived. */
|
|
50
|
+
ttfbMs?: number;
|
|
51
|
+
/** When the body ended (or the call failed). */
|
|
52
|
+
durationMs?: number;
|
|
53
|
+
capture: 'headers' | 'bodies';
|
|
54
|
+
request: {
|
|
55
|
+
headers: Array<[string, string]>;
|
|
56
|
+
query?: Array<[string, string]>;
|
|
57
|
+
body?: HttpExchangeBody;
|
|
58
|
+
};
|
|
59
|
+
response: {
|
|
60
|
+
headers: Array<[string, string]>;
|
|
61
|
+
body?: HttpExchangeBody;
|
|
62
|
+
stream?: {
|
|
63
|
+
protocol: 'sse';
|
|
64
|
+
firstEventMs?: number;
|
|
65
|
+
events: HttpExchangeStreamEvent[];
|
|
66
|
+
bytes: number;
|
|
67
|
+
total: number;
|
|
68
|
+
cut?: boolean;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
/** What the lens removed before storing: header names, and body fields (paths). */
|
|
72
|
+
redacted: {
|
|
73
|
+
headers: string[];
|
|
74
|
+
bodyFields: string[];
|
|
75
|
+
};
|
|
76
|
+
/** An AI provider's call: no conversation here (see above). */
|
|
77
|
+
ai?: {
|
|
78
|
+
provider: string;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export{};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { DashLogLine } from './dashboard.js';
|
|
2
|
+
/**
|
|
3
|
+
* The Logs query language, shared by the dashboard server (`/api/logs?query=`) and the UI, so a query
|
|
4
|
+
* means the same thing whether the ring is filtered on the server or a live tail in the browser.
|
|
5
|
+
*
|
|
6
|
+
* level:error service:engine -category:sql trace:mvc8tc6 ms:>500 timeout
|
|
7
|
+
*
|
|
8
|
+
* `key:value` tokens and free text. The same key twice is OR (`level:error level:warning`), different
|
|
9
|
+
* keys are AND; `-key:value` excludes. Values with spaces are quoted (`service:"my api"`). Free text
|
|
10
|
+
* matches the title, message, service and flow id, case-insensitively. A token with an unknown key is
|
|
11
|
+
* free text, so a URL like `GET:/x` is still searchable.
|
|
12
|
+
*/
|
|
13
|
+
export type LogQueryKey = 'level' | 'service' | 'flow' | 'trace' | 'category' | 'ms';
|
|
14
|
+
export interface LogQueryToken {
|
|
15
|
+
key: LogQueryKey;
|
|
16
|
+
value: string;
|
|
17
|
+
negate: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface ParsedLogQuery {
|
|
20
|
+
tokens: LogQueryToken[];
|
|
21
|
+
/** The free text, words joined by single spaces. */
|
|
22
|
+
text: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function parseLogQuery(input: string): ParsedLogQuery;
|
|
25
|
+
export declare function formatLogQuery(q: ParsedLogQuery): string;
|
|
26
|
+
/**
|
|
27
|
+
* Whether a line passes the query. `textMatch` replaces the plain substring test of the free text —
|
|
28
|
+
* the UI passes a compiled regex there in its Regex mode.
|
|
29
|
+
*/
|
|
30
|
+
export declare function matchesLogQuery(line: DashLogLine, q: ParsedLogQuery, textMatch?: (haystack: string) => boolean): boolean;
|
package/lib/log-query.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var m=Object.defineProperty;var a=(e,r)=>m(e,"name",{value:r,configurable:!0});var L=Object.defineProperty,c=a((e,r)=>L(e,"name",{value:r,configurable:!0}),"c");const d={level:"level",severity:"level",service:"service",svc:"service",src:"service",source:"service",flow:"flow",trace:"trace",request:"trace",category:"category",cat:"category",ms:"ms"},h={warn:"warning",err:"error"},p=/(-?)(?:([A-Za-z]+):)?(?:"([^"]*)"|(\S+))/g;export function parseLogQuery(e){const r=[],t=[];for(const s of e.matchAll(p)){const[o,n,f,w,g]=s,u=(w??g??"").trim(),i=f?d[f.toLowerCase()]:void 0;if(i&&u){const y=i==="level"?h[u.toLowerCase()]??u.toLowerCase():u;r.push({key:i,value:y,negate:n==="-"})}else o.trim()&&t.push(o.trim())}return{tokens:r,text:t.join(" ")}}a(parseLogQuery,"parseLogQuery"),c(parseLogQuery,"parseLogQuery");export function formatLogQuery(e){const r=c(t=>/\s/.test(t)?`"${t}"`:t,"quote");return[...e.tokens.map(t=>`${t.negate?"-":""}${t.key}:${r(t.value)}`),e.text].filter(Boolean).join(" ")}a(formatLogQuery,"formatLogQuery"),c(formatLogQuery,"formatLogQuery");function v(e,r){if(e===void 0)return!1;const t=/^(>=|<=|>|<|=)?\s*(\d+(?:\.\d+)?)$/.exec(r);if(!t)return!1;const s=Number(t[2]);switch(t[1]){case">":return e>s;case"<":return e<s;case"<=":return e<=s;case"=":return e===s;default:return e>=s}}a(v,"h"),c(v,"msMatches");function l(e,r){const t=r.value.toLowerCase();switch(r.key){case"level":return e.severity.toLowerCase()===t;case"service":return e.source.toLowerCase()===t;case"flow":return!!e.flowId&&e.flowId.toLowerCase().startsWith(t);case"trace":return!!e.requestId&&e.requestId.toLowerCase().startsWith(t);case"category":return e.category.toLowerCase()===t;case"ms":return v(e.durationMs,r.value)}}a(l,"i"),c(l,"tokenMatches");export function matchesLogQuery(e,r,t){const s=new Map;for(const o of r.tokens){if(o.negate){if(l(e,o))return!1;continue}const n=s.get(o.key);n?n.push(o):s.set(o.key,[o])}for(const o of s.values())if(!o.some(n=>l(e,n)))return!1;if(r.text){const o=`${e.title} ${e.message??""} ${e.source} ${e.flowId??""}`;return t?t(o):o.toLowerCase().includes(r.text.toLowerCase())}return!0}a(matchesLogQuery,"matchesLogQuery"),c(matchesLogQuery,"matchesLogQuery");
|
package/lib/resources.d.ts
CHANGED
|
@@ -50,36 +50,36 @@ export type AgentBlockingItem = z.infer<typeof AgentBlockingItemSchema>;
|
|
|
50
50
|
export declare const AgentChecksSchema: z.ZodObject<{
|
|
51
51
|
typecheck: z.ZodOptional<z.ZodEnum<{
|
|
52
52
|
unknown: "unknown";
|
|
53
|
-
passed: "passed";
|
|
54
53
|
failed: "failed";
|
|
54
|
+
passed: "passed";
|
|
55
55
|
}>>;
|
|
56
56
|
lint: z.ZodOptional<z.ZodEnum<{
|
|
57
57
|
unknown: "unknown";
|
|
58
|
-
passed: "passed";
|
|
59
58
|
failed: "failed";
|
|
59
|
+
passed: "passed";
|
|
60
60
|
}>>;
|
|
61
61
|
build: z.ZodOptional<z.ZodEnum<{
|
|
62
62
|
unknown: "unknown";
|
|
63
|
-
passed: "passed";
|
|
64
63
|
failed: "failed";
|
|
64
|
+
passed: "passed";
|
|
65
65
|
}>>;
|
|
66
66
|
runtime: z.ZodOptional<z.ZodEnum<{
|
|
67
67
|
warning: "warning";
|
|
68
68
|
unknown: "unknown";
|
|
69
|
-
passed: "passed";
|
|
70
69
|
failed: "failed";
|
|
70
|
+
passed: "passed";
|
|
71
71
|
}>>;
|
|
72
72
|
visual: z.ZodOptional<z.ZodEnum<{
|
|
73
73
|
warning: "warning";
|
|
74
74
|
unknown: "unknown";
|
|
75
|
-
passed: "passed";
|
|
76
75
|
failed: "failed";
|
|
76
|
+
passed: "passed";
|
|
77
77
|
}>>;
|
|
78
78
|
memory: z.ZodOptional<z.ZodEnum<{
|
|
79
79
|
warning: "warning";
|
|
80
80
|
unknown: "unknown";
|
|
81
|
-
passed: "passed";
|
|
82
81
|
failed: "failed";
|
|
82
|
+
passed: "passed";
|
|
83
83
|
}>>;
|
|
84
84
|
}, z.core.$strip>;
|
|
85
85
|
/**
|
|
@@ -178,36 +178,36 @@ export declare const AgentCurrentStatusSchema: z.ZodObject<{
|
|
|
178
178
|
checks: z.ZodOptional<z.ZodObject<{
|
|
179
179
|
typecheck: z.ZodOptional<z.ZodEnum<{
|
|
180
180
|
unknown: "unknown";
|
|
181
|
-
passed: "passed";
|
|
182
181
|
failed: "failed";
|
|
182
|
+
passed: "passed";
|
|
183
183
|
}>>;
|
|
184
184
|
lint: z.ZodOptional<z.ZodEnum<{
|
|
185
185
|
unknown: "unknown";
|
|
186
|
-
passed: "passed";
|
|
187
186
|
failed: "failed";
|
|
187
|
+
passed: "passed";
|
|
188
188
|
}>>;
|
|
189
189
|
build: z.ZodOptional<z.ZodEnum<{
|
|
190
190
|
unknown: "unknown";
|
|
191
|
-
passed: "passed";
|
|
192
191
|
failed: "failed";
|
|
192
|
+
passed: "passed";
|
|
193
193
|
}>>;
|
|
194
194
|
runtime: z.ZodOptional<z.ZodEnum<{
|
|
195
195
|
warning: "warning";
|
|
196
196
|
unknown: "unknown";
|
|
197
|
-
passed: "passed";
|
|
198
197
|
failed: "failed";
|
|
198
|
+
passed: "passed";
|
|
199
199
|
}>>;
|
|
200
200
|
visual: z.ZodOptional<z.ZodEnum<{
|
|
201
201
|
warning: "warning";
|
|
202
202
|
unknown: "unknown";
|
|
203
|
-
passed: "passed";
|
|
204
203
|
failed: "failed";
|
|
204
|
+
passed: "passed";
|
|
205
205
|
}>>;
|
|
206
206
|
memory: z.ZodOptional<z.ZodEnum<{
|
|
207
207
|
warning: "warning";
|
|
208
208
|
unknown: "unknown";
|
|
209
|
-
passed: "passed";
|
|
210
209
|
failed: "failed";
|
|
210
|
+
passed: "passed";
|
|
211
211
|
}>>;
|
|
212
212
|
}, z.core.$strip>>;
|
|
213
213
|
server: z.ZodOptional<z.ZodObject<{
|