@lensmcp/protocol-types 1.18.4 → 1.18.7

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.js CHANGED
@@ -1,11 +1 @@
1
- export * from './lib/schema-version.js';
2
- export * from './lib/source-location.js';
3
- export * from './lib/context.js';
4
- export * from './lib/event.js';
5
- export * from './lib/node.js';
6
- export * from './lib/edge.js';
7
- export * from './lib/attributes.js';
8
- export * from './lib/producer-health.js';
9
- export * from './lib/resources.js';
10
- export * from './lib/tokens.js';
11
- export * from './lib/capture-demand.js';
1
+ "use strict";export*from"./lib/schema-version.js";export*from"./lib/source-location.js";export*from"./lib/context.js";export*from"./lib/event.js";export*from"./lib/node.js";export*from"./lib/edge.js";export*from"./lib/attributes.js";export*from"./lib/producer-health.js";export*from"./lib/resources.js";export*from"./lib/tokens.js";export*from"./lib/capture-demand.js";
package/lib/attributes.js CHANGED
@@ -1,203 +1 @@
1
- import { z } from 'zod';
2
- // ---------- render ----------
3
- export const RenderPhaseSchema = z.enum(['mount', 'update']);
4
- export const RenderWhySchema = z.discriminatedUnion('type', [
5
- z.object({ type: z.literal('props'), changedKeys: z.array(z.string()) }),
6
- z.object({ type: z.literal('react-state'), hookIndex: z.number().int() }),
7
- z.object({ type: z.literal('context'), contextName: z.string() }),
8
- z.object({
9
- type: z.literal('valtio-path'),
10
- path: z.string(),
11
- changedKeys: z.array(z.string()),
12
- }),
13
- z.object({
14
- type: z.literal('parent-render'),
15
- parentRenderId: z.string(),
16
- }),
17
- z.object({
18
- type: z.literal('hook-dep-changed'),
19
- hookInstanceId: z.string(),
20
- depsHashBefore: z.string(),
21
- depsHashAfter: z.string(),
22
- }),
23
- z.object({ type: z.literal('force'), reason: z.string() }),
24
- ]);
25
- export const RenderAttrsSchema = z.object({
26
- phase: RenderPhaseSchema,
27
- actualDurationMs: z.number().nonnegative(),
28
- baseDurationMs: z.number().nonnegative(),
29
- startTime: z.number().nonnegative(),
30
- commitTime: z.number().nonnegative(),
31
- why: z.array(RenderWhySchema),
32
- });
33
- // ---------- effect-run ----------
34
- export const EffectRunAttrsSchema = z.object({
35
- hookInstanceId: z.string(),
36
- depsHash: z.string(),
37
- prevDepsHash: z.string().optional(),
38
- durationMs: z.number().nonnegative(),
39
- cleanupRan: z.boolean().optional(),
40
- });
41
- // ---------- valtio update (state-update kind) ----------
42
- export const ValtioUpdateAttrsSchema = z.object({
43
- storeId: z.string(),
44
- path: z.string(),
45
- changedKeys: z.array(z.string()),
46
- beforeHash: z.string(),
47
- afterHash: z.string(),
48
- preview: z.unknown().optional(),
49
- });
50
- // ---------- server-request ----------
51
- export const ServerRequestAttrsSchema = z.object({
52
- method: z.string(),
53
- route: z.string(),
54
- status: z.number().int().optional(),
55
- durationMs: z.number().nonnegative().optional(),
56
- traceparent: z.string().optional(),
57
- });
58
- // ---------- loop ----------
59
- export const LoopPatternSchema = z.enum([
60
- 'N+1',
61
- 'sequential-await',
62
- 'growing-allocation',
63
- ]);
64
- export const LoopAttrsSchema = z.object({
65
- iterations: z.number().int().nonnegative(),
66
- durationMs: z.number().nonnegative(),
67
- dbCallsInsideLoop: z.number().int().nonnegative(),
68
- redisCallsInsideLoop: z.number().int().nonnegative(),
69
- awaitedOperationsInsideLoop: z.number().int().nonnegative(),
70
- slowestIterations: z
71
- .array(z.object({
72
- index: z.number().int().nonnegative(),
73
- durationMs: z.number().nonnegative(),
74
- childNodeIds: z.array(z.string()),
75
- }))
76
- .optional(),
77
- patterns: z.array(LoopPatternSchema).optional(),
78
- });
79
- // ---------- memory ----------
80
- export const MemoryContainerKindSchema = z.enum([
81
- 'Map',
82
- 'Set',
83
- 'Array',
84
- 'EventEmitter',
85
- 'Queue',
86
- 'RxSubject',
87
- 'Timer',
88
- 'Interval',
89
- 'Custom',
90
- ]);
91
- export const MemoryOwnerAttrsSchema = z.object({
92
- ownerInstanceId: z.string(),
93
- containerKind: MemoryContainerKindSchema,
94
- fieldName: z.string(),
95
- itemCount: z.number().int().nonnegative(),
96
- estimatedBytes: z.number().nonnegative(),
97
- retainedBytes: z.number().nonnegative().optional(),
98
- growthSinceStart: z.number(),
99
- });
100
- export const MemoryMutationOperationSchema = z.enum([
101
- 'set',
102
- 'push',
103
- 'add',
104
- 'delete',
105
- 'clear',
106
- 'subscribe',
107
- 'listen',
108
- 'schedule',
109
- ]);
110
- export const MemoryMutationAttrsSchema = z.object({
111
- ownerNodeId: z.string(),
112
- operation: MemoryMutationOperationSchema,
113
- beforeCount: z.number().int().nonnegative(),
114
- afterCount: z.number().int().nonnegative(),
115
- estimatedDeltaBytes: z.number(),
116
- keyPreview: z.string().optional(),
117
- valueType: z.string().optional(),
118
- });
119
- // ---------- visual ----------
120
- export const RectSchema = z.object({
121
- x: z.number(),
122
- y: z.number(),
123
- width: z.number().nonnegative(),
124
- height: z.number().nonnegative(),
125
- });
126
- export const VisualFrameCauseSchema = z.enum([
127
- 'page-load',
128
- 'route-change',
129
- 'user-action',
130
- 'react-commit',
131
- 'state-update',
132
- 'api-response',
133
- 'hmr-update',
134
- 'animation-tick',
135
- ]);
136
- export const VisualChangeKindSchema = z.enum([
137
- 'computed-style',
138
- 'layout',
139
- 'paint-order',
140
- ]);
141
- export const VisualFrameAttrsSchema = z.object({
142
- causedBy: VisualFrameCauseSchema,
143
- viewport: RectSchema,
144
- layoutSnapshotId: z.string(),
145
- styleSnapshotId: z.string(),
146
- screenshotId: z.string().optional(),
147
- changedNodes: z.array(z.object({
148
- uid: z.string(),
149
- component: z.string().optional(),
150
- change: VisualChangeKindSchema,
151
- property: z.string().optional(),
152
- before: z.unknown().optional(),
153
- after: z.unknown().optional(),
154
- })),
155
- });
156
- export const VisualRuleTypeSchema = z.enum([
157
- 'grid-spacing',
158
- 'alignment',
159
- 'overflow',
160
- 'text-clipping',
161
- 'color-contrast',
162
- 'token-usage',
163
- 'z-index',
164
- 'responsive',
165
- 'custom',
166
- ]);
167
- export const VisualRuleTimingSchema = z.enum([
168
- 'always',
169
- 'after-animation',
170
- 'stable-only',
171
- 'during-animation',
172
- ]);
173
- export const VisualViolationSeveritySchema = z.enum([
174
- 'info',
175
- 'warning',
176
- 'error',
177
- ]);
178
- export const VisualViolationAttrsSchema = z.object({
179
- ruleId: z.string(),
180
- ruleType: VisualRuleTypeSchema,
181
- severity: VisualViolationSeveritySchema,
182
- timing: VisualRuleTimingSchema,
183
- element: z.object({
184
- uid: z.string(),
185
- component: z.string().optional(),
186
- rect: RectSchema,
187
- }),
188
- expected: z.record(z.string(), z.unknown()),
189
- actual: z.record(z.string(), z.unknown()),
190
- evidence: z.object({
191
- computedStyle: z.string().optional(),
192
- screenshotCrop: z.string().optional(),
193
- trace: z.string().optional(),
194
- cssCause: z
195
- .object({
196
- selector: z.string(),
197
- file: z.string().optional(),
198
- line: z.number().int().optional(),
199
- declaration: z.string().optional(),
200
- })
201
- .optional(),
202
- }),
203
- });
1
+ "use strict";import{z as e}from"zod";export const RenderPhaseSchema=e.enum(["mount","update"]),RenderWhySchema=e.discriminatedUnion("type",[e.object({type:e.literal("props"),changedKeys:e.array(e.string())}),e.object({type:e.literal("react-state"),hookIndex:e.number().int()}),e.object({type:e.literal("context"),contextName:e.string()}),e.object({type:e.literal("valtio-path"),path:e.string(),changedKeys:e.array(e.string())}),e.object({type:e.literal("parent-render"),parentRenderId:e.string()}),e.object({type:e.literal("hook-dep-changed"),hookInstanceId:e.string(),depsHashBefore:e.string(),depsHashAfter:e.string()}),e.object({type:e.literal("force"),reason:e.string()})]),RenderAttrsSchema=e.object({phase:RenderPhaseSchema,actualDurationMs:e.number().nonnegative(),baseDurationMs:e.number().nonnegative(),startTime:e.number().nonnegative(),commitTime:e.number().nonnegative(),why:e.array(RenderWhySchema)}),EffectRunAttrsSchema=e.object({hookInstanceId:e.string(),depsHash:e.string(),prevDepsHash:e.string().optional(),durationMs:e.number().nonnegative(),cleanupRan:e.boolean().optional()}),ValtioUpdateAttrsSchema=e.object({storeId:e.string(),path:e.string(),changedKeys:e.array(e.string()),beforeHash:e.string(),afterHash:e.string(),preview:e.unknown().optional()}),ServerRequestAttrsSchema=e.object({method:e.string(),route:e.string(),status:e.number().int().optional(),durationMs:e.number().nonnegative().optional(),traceparent:e.string().optional()}),LoopPatternSchema=e.enum(["N+1","sequential-await","growing-allocation"]),LoopAttrsSchema=e.object({iterations:e.number().int().nonnegative(),durationMs:e.number().nonnegative(),dbCallsInsideLoop:e.number().int().nonnegative(),redisCallsInsideLoop:e.number().int().nonnegative(),awaitedOperationsInsideLoop:e.number().int().nonnegative(),slowestIterations:e.array(e.object({index:e.number().int().nonnegative(),durationMs:e.number().nonnegative(),childNodeIds:e.array(e.string())})).optional(),patterns:e.array(LoopPatternSchema).optional()}),MemoryContainerKindSchema=e.enum(["Map","Set","Array","EventEmitter","Queue","RxSubject","Timer","Interval","Custom"]),MemoryOwnerAttrsSchema=e.object({ownerInstanceId:e.string(),containerKind:MemoryContainerKindSchema,fieldName:e.string(),itemCount:e.number().int().nonnegative(),estimatedBytes:e.number().nonnegative(),retainedBytes:e.number().nonnegative().optional(),growthSinceStart:e.number()}),MemoryMutationOperationSchema=e.enum(["set","push","add","delete","clear","subscribe","listen","schedule"]),MemoryMutationAttrsSchema=e.object({ownerNodeId:e.string(),operation:MemoryMutationOperationSchema,beforeCount:e.number().int().nonnegative(),afterCount:e.number().int().nonnegative(),estimatedDeltaBytes:e.number(),keyPreview:e.string().optional(),valueType:e.string().optional()}),RectSchema=e.object({x:e.number(),y:e.number(),width:e.number().nonnegative(),height:e.number().nonnegative()}),VisualFrameCauseSchema=e.enum(["page-load","route-change","user-action","react-commit","state-update","api-response","hmr-update","animation-tick"]),VisualChangeKindSchema=e.enum(["computed-style","layout","paint-order"]),VisualFrameAttrsSchema=e.object({causedBy:VisualFrameCauseSchema,viewport:RectSchema,layoutSnapshotId:e.string(),styleSnapshotId:e.string(),screenshotId:e.string().optional(),changedNodes:e.array(e.object({uid:e.string(),component:e.string().optional(),change:VisualChangeKindSchema,property:e.string().optional(),before:e.unknown().optional(),after:e.unknown().optional()}))}),VisualRuleTypeSchema=e.enum(["grid-spacing","alignment","overflow","text-clipping","color-contrast","token-usage","z-index","responsive","custom"]),VisualRuleTimingSchema=e.enum(["always","after-animation","stable-only","during-animation"]),VisualViolationSeveritySchema=e.enum(["info","warning","error"]),VisualViolationAttrsSchema=e.object({ruleId:e.string(),ruleType:VisualRuleTypeSchema,severity:VisualViolationSeveritySchema,timing:VisualRuleTimingSchema,element:e.object({uid:e.string(),component:e.string().optional(),rect:RectSchema}),expected:e.record(e.string(),e.unknown()),actual:e.record(e.string(),e.unknown()),evidence:e.object({computedStyle:e.string().optional(),screenshotCrop:e.string().optional(),trace:e.string().optional(),cssCause:e.object({selector:e.string(),file:e.string().optional(),line:e.number().int().optional(),declaration:e.string().optional()}).optional()})});
@@ -1,14 +1 @@
1
- /** Request-file name, resolved as a sibling of `LENSMCP_EVENT_FILE`. */
2
- export const CAPTURE_REQUEST_FILENAME = 'capture-request.json';
3
- /**
4
- * Presence-file name (same directory). The runner writes it at startup and
5
- * removes it on a clean stop.
6
- *
7
- * Its job is to keep the requester honest: `visual.capture_frame` now WAITS for
8
- * the fresh frame it asked for (a cold browser needs ~1s), and without a way to
9
- * tell "a runner is warming up" from "no runner exists" that wait would also be
10
- * paid by every workspace running with capture disabled or no Chrome installed
11
- * — an 8s stall for a frame that is never coming. With this, the tool waits
12
- * only when a live runner is actually listening, and can say so when it isn't.
13
- */
14
- export const CAPTURE_PRESENCE_FILENAME = 'capture-runner.json';
1
+ "use strict";export const CAPTURE_REQUEST_FILENAME="capture-request.json",CAPTURE_PRESENCE_FILENAME="capture-runner.json";
package/lib/context.js CHANGED
@@ -1,42 +1 @@
1
- import { z } from 'zod';
2
- export const FlowOriginTypeSchema = z.enum([
3
- 'user-click',
4
- 'user-input',
5
- 'keyboard',
6
- 'route-load',
7
- 'effect',
8
- 'memo-recompute',
9
- 'timer',
10
- 'raf',
11
- 'idle-callback',
12
- 'websocket-message',
13
- 'broadcast-channel',
14
- 'post-message',
15
- 'storage-event',
16
- 'service-worker-message',
17
- 'media-query-change',
18
- 'visibility-change',
19
- 'resize',
20
- 'intersection-observer',
21
- 'mutation-observer',
22
- 'backend-response',
23
- 'hmr-update',
24
- 'ai-turn',
25
- ]);
26
- export const TraceContextSchema = z.object({
27
- sessionId: z.string(),
28
- browserContextId: z.string().optional(),
29
- tabId: z.string().optional(),
30
- frameId: z.string().optional(),
31
- route: z.string().optional(),
32
- url: z.string().optional(),
33
- flowId: z.string().optional(),
34
- originType: FlowOriginTypeSchema.optional(),
35
- originNodeId: z.string().optional(),
36
- causedByNodeId: z.string().optional(),
37
- requestId: z.string().optional(),
38
- traceparent: z.string().optional(),
39
- userActionId: z.string().optional(),
40
- userIdHash: z.string().optional(),
41
- tenantIdHash: z.string().optional(),
42
- });
1
+ "use strict";import{z as e}from"zod";export const FlowOriginTypeSchema=e.enum(["user-click","user-input","keyboard","route-load","effect","memo-recompute","timer","raf","idle-callback","websocket-message","broadcast-channel","post-message","storage-event","service-worker-message","media-query-change","visibility-change","resize","intersection-observer","mutation-observer","backend-response","hmr-update","ai-turn"]),TraceContextSchema=e.object({sessionId:e.string(),browserContextId:e.string().optional(),tabId:e.string().optional(),frameId:e.string().optional(),route:e.string().optional(),url:e.string().optional(),flowId:e.string().optional(),originType:FlowOriginTypeSchema.optional(),originNodeId:e.string().optional(),causedByNodeId:e.string().optional(),requestId:e.string().optional(),traceparent:e.string().optional(),userActionId:e.string().optional(),userIdHash:e.string().optional(),tenantIdHash:e.string().optional()});
package/lib/edge.js CHANGED
@@ -1,25 +1 @@
1
- import { z } from 'zod';
2
- export const EdgeAxisSchema = z.enum([
3
- 'ownership',
4
- 'caused',
5
- 'async',
6
- 'data',
7
- 'render',
8
- 'state',
9
- 'network',
10
- 'backend',
11
- 'db',
12
- 'visual',
13
- 'performance',
14
- 'memory',
15
- 'lifecycle',
16
- ]);
17
- export const TraceEdgeSchema = z.object({
18
- id: z.string(),
19
- from: z.string(),
20
- to: z.string(),
21
- axis: EdgeAxisSchema,
22
- type: z.string(),
23
- timestamp: z.number().int().nonnegative(),
24
- attributes: z.record(z.string(), z.unknown()).optional(),
25
- });
1
+ "use strict";import{z as e}from"zod";export const EdgeAxisSchema=e.enum(["ownership","caused","async","data","render","state","network","backend","db","visual","performance","memory","lifecycle"]),TraceEdgeSchema=e.object({id:e.string(),from:e.string(),to:e.string(),axis:EdgeAxisSchema,type:e.string(),timestamp:e.number().int().nonnegative(),attributes:e.record(e.string(),e.unknown()).optional()});
package/lib/event.js CHANGED
@@ -1,69 +1 @@
1
- import { z } from 'zod';
2
- import { SourceLocationSchema } from './source-location.js';
3
- import { TraceContextSchema } from './context.js';
4
- export const EventSourceSchema = z.enum([
5
- 'nx',
6
- 'vite',
7
- 'typescript',
8
- 'eslint',
9
- 'rollup',
10
- 'client-runtime',
11
- 'chrome',
12
- 'react',
13
- 'valtio',
14
- 'nestjs',
15
- 'nextjs',
16
- 'db',
17
- 'redis',
18
- 'queue',
19
- 'memory',
20
- 'visual',
21
- 'perf',
22
- 'security',
23
- 'gateway',
24
- 'external',
25
- 'ai',
26
- ]);
27
- export const EventCategorySchema = z.enum([
28
- 'build',
29
- 'lint',
30
- 'typecheck',
31
- 'test',
32
- 'runtime',
33
- 'render',
34
- 'visual',
35
- 'trace',
36
- 'state',
37
- 'network',
38
- 'backend',
39
- 'db',
40
- 'memory',
41
- 'performance',
42
- 'security',
43
- 'deps',
44
- 'cluster',
45
- 'ai',
46
- ]);
47
- export const SeveritySchema = z.enum([
48
- 'debug',
49
- 'info',
50
- 'warning',
51
- 'error',
52
- 'fatal',
53
- ]);
54
- export const BaseEventSchema = z.object({
55
- id: z.string(),
56
- sessionId: z.string(),
57
- timestamp: z.number().int().nonnegative(),
58
- source: EventSourceSchema,
59
- category: EventCategorySchema,
60
- severity: SeveritySchema,
61
- context: TraceContextSchema,
62
- fingerprint: z.string(),
63
- title: z.string(),
64
- message: z.string().optional(),
65
- location: SourceLocationSchema.optional(),
66
- relatedFiles: z.array(z.string()).optional(),
67
- relatedUrls: z.array(z.string()).optional(),
68
- raw: z.unknown().optional(),
69
- });
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"]),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()});
package/lib/node.js CHANGED
@@ -1,98 +1 @@
1
- import { z } from 'zod';
2
- import { SourceLocationSchema } from './source-location.js';
3
- import { TraceContextSchema } from './context.js';
4
- export const TraceNodeTypeSchema = z.enum([
5
- // Browser process tree
6
- 'session',
7
- 'browser-context',
8
- 'tab',
9
- 'renderer',
10
- 'router',
11
- 'route',
12
- 'page',
13
- // React UI
14
- 'component',
15
- 'element',
16
- 'slot',
17
- 'render',
18
- 'react-mount',
19
- 'react-unmount',
20
- 'hook',
21
- 'effect',
22
- 'effect-run',
23
- 'memo',
24
- 'memo-compute',
25
- // User interaction
26
- 'ui-event',
27
- 'handler',
28
- 'animation',
29
- 'animation-frame',
30
- 'transition',
31
- 'timer',
32
- // Network / API
33
- 'api-client-call',
34
- 'http-request',
35
- 'http-response',
36
- // Backend
37
- 'server-process',
38
- 'nest-app',
39
- 'nest-module',
40
- 'nest-provider',
41
- 'singleton-instance',
42
- 'server-request',
43
- 'guard',
44
- 'controller',
45
- 'service-method',
46
- 'loop',
47
- 'loop-iteration',
48
- 'queue-job',
49
- 'db-query',
50
- 'redis-op',
51
- 'promise',
52
- 'promise-continuation',
53
- // State
54
- 'state-store',
55
- 'state-update',
56
- 'selector',
57
- 'selector-update',
58
- // Visual
59
- 'visual-frame',
60
- 'visual-violation',
61
- 'style-change',
62
- 'layout-change',
63
- // Memory
64
- 'memory-owner',
65
- 'memory-mutation',
66
- 'memory-retention',
67
- 'heap-snapshot',
68
- // Build / dev
69
- 'build-event',
70
- 'lint-event',
71
- 'typecheck-event',
72
- 'test-event',
73
- 'bundle-report',
74
- 'hmr-update',
75
- ]);
76
- export const LifecycleSchema = z.enum([
77
- 'created',
78
- 'active',
79
- 'completed',
80
- 'disposed',
81
- 'errored',
82
- ]);
83
- export const TraceNodeSchema = z.object({
84
- id: z.string(),
85
- parentTraceNodeId: z.string().optional(),
86
- type: TraceNodeTypeSchema,
87
- logicalId: z.string().optional(),
88
- instanceId: z.string().optional(),
89
- generation: z.number().int().nonnegative().optional(),
90
- lifecycle: LifecycleSchema,
91
- context: TraceContextSchema,
92
- name: z.string(),
93
- startTime: z.number().int().nonnegative(),
94
- endTime: z.number().int().nonnegative().optional(),
95
- durationMs: z.number().nonnegative().optional(),
96
- location: SourceLocationSchema.optional(),
97
- attributes: z.record(z.string(), z.unknown()),
98
- });
1
+ "use strict";import{z as e}from"zod";import{SourceLocationSchema as t}from"./source-location.js";import{TraceContextSchema as n}from"./context.js";export const TraceNodeTypeSchema=e.enum(["session","browser-context","tab","renderer","router","route","page","component","element","slot","render","react-mount","react-unmount","hook","effect","effect-run","memo","memo-compute","ui-event","handler","animation","animation-frame","transition","timer","api-client-call","http-request","http-response","server-process","nest-app","nest-module","nest-provider","singleton-instance","server-request","guard","controller","service-method","loop","loop-iteration","queue-job","db-query","redis-op","promise","promise-continuation","state-store","state-update","selector","selector-update","visual-frame","visual-violation","style-change","layout-change","memory-owner","memory-mutation","memory-retention","heap-snapshot","build-event","lint-event","typecheck-event","test-event","bundle-report","hmr-update"]),LifecycleSchema=e.enum(["created","active","completed","disposed","errored"]),TraceNodeSchema=e.object({id:e.string(),parentTraceNodeId:e.string().optional(),type:TraceNodeTypeSchema,logicalId:e.string().optional(),instanceId:e.string().optional(),generation:e.number().int().nonnegative().optional(),lifecycle:LifecycleSchema,context:n,name:e.string(),startTime:e.number().int().nonnegative(),endTime:e.number().int().nonnegative().optional(),durationMs:e.number().nonnegative().optional(),location:t.optional(),attributes:e.record(e.string(),e.unknown())});
@@ -1,154 +1 @@
1
- import { z } from 'zod';
2
- /**
3
- * Producer health — the "is anybody actually watching?" half of every check
4
- * resource (`typecheck://current`, `lint://current`, `build://current`).
5
- *
6
- * WHY this exists, concretely: `typecheck://current` shipped as
7
- * `{"status":"unknown","errorCount":0,"revision":0}` and `lint://current` as
8
- * `{"status":"unknown","errorCount":0,"warningCount":0,"revision":0}` — and an
9
- * agent reading either one cannot tell those apart from a healthy, silent,
10
- * genuinely-clean system. They were not clean. `startTscCollector` and
11
- * `runEslintOnce` existed, were exported from `@lensmcp/session`, and were
12
- * called by NOTHING; the dev cluster's real type checking (the tsgo plugin)
13
- * printed diagnostics to the console and to no bus at all. So those resources
14
- * had never received a single event in their lives, and said so in a way that
15
- * read exactly like "all good".
16
- *
17
- * `revision: 0` was the only tell, and it is far too subtle to be a contract:
18
- * one empty read teaches a reader to stop asking, which is precisely what
19
- * happened. So every check resource now states, in the body, whether a
20
- * producer has EVER reported (`producer`), which producers are live
21
- * (`producers`), how old the newest report is (`ageMs`/`stale`), and a
22
- * sentence a human or an agent can act on (`detail`).
23
- *
24
- * `status` keeps its original value set (`unknown | clean | …`) so existing
25
- * readers — the MCP resource wrappers and the human dashboard — are unaffected;
26
- * everything here is additive.
27
- */
28
- /**
29
- * Has any producer ever reported into this resource?
30
- *
31
- * - `none` — no producer has ever reported. `status` is NOT evidence of
32
- * health; nothing is watching. This is the state the three
33
- * check resources were silently stuck in.
34
- * - `connected` — at least one producer has reported at least once, so
35
- * `status` reflects a real run.
36
- *
37
- * Deliberately NOT a third `stale` member: staleness is orthogonal (a
38
- * connected producer that has not re-run recently is still connected), and
39
- * folding it in here would force readers to re-derive "did anyone ever
40
- * report?" from a union. Read `stale`/`ageMs` for freshness.
41
- */
42
- export const ProducerStateSchema = z.enum(['none', 'connected']);
43
- /** Outcome of a producer's most recent run. */
44
- export const ProducerRunStatusSchema = z.enum([
45
- /** A run is in flight; its diagnostics have not landed yet. */
46
- 'running',
47
- /** The run completed with zero errors. */
48
- 'clean',
49
- /** The run completed and reported at least one error. */
50
- 'failing',
51
- /** The tool itself failed to run (crash / bad config) — the run produced NO verdict. */
52
- 'error',
53
- ]);
54
- /**
55
- * One reporting producer. Keyed by `id` so a multi-service cluster (13 pods,
56
- * each running its own tsgo check against its own tsconfig, all appending to
57
- * ONE `.lensmcp/events.jsonl`) shows up as 13 rows rather than a single
58
- * last-writer-wins verdict.
59
- */
60
- export const ProducerReportSchema = z.object({
61
- /** Stable identity: `<tool>:<project ?? '*'>`. */
62
- id: z.string(),
63
- /** The tool behind it — `tsgo`, `tsc`, `eslint`, `vite`, … */
64
- tool: z.string(),
65
- /** Nx project the run covered; absent for a workspace-wide producer. */
66
- project: z.string().optional(),
67
- firstReportedAt: z.number().int().nonnegative(),
68
- lastReportedAt: z.number().int().nonnegative(),
69
- lastRunStatus: ProducerRunStatusSchema,
70
- lastRunDurationMs: z.number().int().nonnegative().optional(),
71
- errorCount: z.number().int().nonnegative(),
72
- warningCount: z.number().int().nonnegative().optional(),
73
- /** Set when `lastRunStatus === 'error'` — why the tool could not produce a verdict. */
74
- error: z.string().optional(),
75
- });
76
- /**
77
- * The additive block every check resource carries. Mixed into
78
- * `typecheck://current`, `lint://current` and `build://current`.
79
- */
80
- export const ProducerHealthSchema = z.object({
81
- producer: ProducerStateSchema,
82
- producers: z.array(ProducerReportSchema),
83
- /** Epoch ms of the newest report across all producers. Absent iff `producer === 'none'`. */
84
- lastReportedAt: z.number().int().nonnegative().optional(),
85
- /** Age of `lastReportedAt` at read time. Absent iff `producer === 'none'`. */
86
- ageMs: z.number().int().nonnegative().optional(),
87
- /**
88
- * `true` when connected but the newest report is older than
89
- * {@link PRODUCER_STALE_AFTER_MS}. A stale CLEAN result means "clean as of
90
- * `ageMs` ago, and nothing has re-checked since" — not "clean now".
91
- * Always `false` when `producer === 'none'` (nothing to be stale).
92
- */
93
- stale: z.boolean(),
94
- /** One sentence a reader can act on. Never empty. */
95
- detail: z.string(),
96
- });
97
- /**
98
- * A connected producer whose newest report is older than this is reported
99
- * `stale`. Generous on purpose: these producers are edge-triggered (they run
100
- * on rebuild / on demand), so silence is normal and is NOT evidence of a
101
- * problem — it only means the verdict may predate the current source.
102
- */
103
- export const PRODUCER_STALE_AFTER_MS = 10 * 60_000;
104
- /**
105
- * Fold a producer registry into the {@link ProducerHealth} block.
106
- *
107
- * Lives here rather than in each reducer so `typecheck`, `lint` and `build`
108
- * cannot drift into three different definitions of "nobody is watching" — the
109
- * exact class of divergence that let the original bug hide in two of the three.
110
- *
111
- * `now` is injected so the value is testable and so callers can pin one clock
112
- * across a single resource render.
113
- */
114
- export function summariseProducers(args) {
115
- const now = args.now ?? Date.now();
116
- const producers = [...args.producers].sort((a, b) => b.lastReportedAt - a.lastReportedAt);
117
- if (producers.length === 0) {
118
- return {
119
- producer: 'none',
120
- producers: [],
121
- stale: false,
122
- detail: `No ${args.domain} producer has ever reported into this session — ` +
123
- `this is NOT a clean result, nothing is watching. ${args.noProducerHint}`,
124
- };
125
- }
126
- const lastReportedAt = producers[0].lastReportedAt;
127
- const ageMs = Math.max(0, now - lastReportedAt);
128
- const stale = ageMs > PRODUCER_STALE_AFTER_MS;
129
- const failing = producers.filter((p) => p.lastRunStatus === 'failing');
130
- const errored = producers.filter((p) => p.lastRunStatus === 'error');
131
- const parts = [
132
- `${producers.length} ${args.domain} producer${producers.length === 1 ? '' : 's'} reporting ` +
133
- `(${producers.map((p) => p.id).join(', ')}); newest report ${describeAge(ageMs)}.`,
134
- ];
135
- if (errored.length > 0) {
136
- parts.push(`${errored.length} produced NO verdict (the tool itself failed): ` +
137
- `${errored.map((p) => `${p.id} — ${p.error ?? 'unknown error'}`).join('; ')}.`);
138
- }
139
- if (failing.length > 0)
140
- parts.push(`${failing.length} reporting errors.`);
141
- if (stale) {
142
- parts.push(`Older than ${Math.round(PRODUCER_STALE_AFTER_MS / 60_000)}m — the verdict may predate the current source.`);
143
- }
144
- return { producer: 'connected', producers, lastReportedAt, ageMs, stale, detail: parts.join(' ') };
145
- }
146
- function describeAge(ageMs) {
147
- if (ageMs < 1_000)
148
- return 'just now';
149
- if (ageMs < 60_000)
150
- return `${Math.round(ageMs / 1_000)}s ago`;
151
- if (ageMs < 3_600_000)
152
- return `${Math.round(ageMs / 60_000)}m ago`;
153
- return `${Math.round(ageMs / 3_600_000)}h ago`;
154
- }
1
+ "use strict";var m=Object.defineProperty;var i=(t,o)=>m(t,"name",{value:o,configurable:!0});var R=Object.defineProperty,p=i((t,o)=>R(t,"name",{value:o,configurable:!0}),"u");import{z as e}from"zod";export const ProducerStateSchema=e.enum(["none","connected"]),ProducerRunStatusSchema=e.enum(["running","clean","failing","error"]),ProducerReportSchema=e.object({id:e.string(),tool:e.string(),project:e.string().optional(),firstReportedAt:e.number().int().nonnegative(),lastReportedAt:e.number().int().nonnegative(),lastRunStatus:ProducerRunStatusSchema,lastRunDurationMs:e.number().int().nonnegative().optional(),errorCount:e.number().int().nonnegative(),warningCount:e.number().int().nonnegative().optional(),error:e.string().optional()}),ProducerHealthSchema=e.object({producer:ProducerStateSchema,producers:e.array(ProducerReportSchema),lastReportedAt:e.number().int().nonnegative().optional(),ageMs:e.number().int().nonnegative().optional(),stale:e.boolean(),detail:e.string()}),PRODUCER_STALE_AFTER_MS=10*6e4;export function summariseProducers(t){const o=t.now??Date.now(),n=[...t.producers].sort((r,h)=>h.lastReportedAt-r.lastReportedAt);if(n.length===0)return{producer:"none",producers:[],stale:!1,detail:`No ${t.domain} producer has ever reported into this session \u2014 this is NOT a clean result, nothing is watching. ${t.noProducerHint}`};const d=n[0].lastReportedAt,u=Math.max(0,o-d),l=u>PRODUCER_STALE_AFTER_MS,c=n.filter(r=>r.lastRunStatus==="failing"),s=n.filter(r=>r.lastRunStatus==="error"),a=[`${n.length} ${t.domain} producer${n.length===1?"":"s"} reporting (${n.map(r=>r.id).join(", ")}); newest report ${g(u)}.`];return s.length>0&&a.push(`${s.length} produced NO verdict (the tool itself failed): ${s.map(r=>`${r.id} \u2014 ${r.error??"unknown error"}`).join("; ")}.`),c.length>0&&a.push(`${c.length} reporting errors.`),l&&a.push(`Older than ${Math.round(PRODUCER_STALE_AFTER_MS/6e4)}m \u2014 the verdict may predate the current source.`),{producer:"connected",producers:n,lastReportedAt:d,ageMs:u,stale:l,detail:a.join(" ")}}i(summariseProducers,"summariseProducers"),p(summariseProducers,"summariseProducers");function g(t){return t<1e3?"just now":t<6e4?`${Math.round(t/1e3)}s ago`:t<36e5?`${Math.round(t/6e4)}m ago`:`${Math.round(t/36e5)}h ago`}i(g,"g"),p(g,"describeAge");
@@ -13,19 +13,19 @@ export declare const ResourceEnvelopeSchema: z.ZodObject<{
13
13
  }, z.core.$strip>;
14
14
  export type ResourceEnvelope = z.infer<typeof ResourceEnvelopeSchema>;
15
15
  export declare const AgentStatusKindSchema: z.ZodEnum<{
16
- starting: "starting";
17
- clean: "clean";
18
16
  warning: "warning";
17
+ clean: "clean";
19
18
  failing: "failing";
19
+ starting: "starting";
20
20
  }>;
21
21
  export type AgentStatusKind = z.infer<typeof AgentStatusKindSchema>;
22
22
  export declare const AgentBlockingItemSchema: z.ZodObject<{
23
23
  source: z.ZodString;
24
24
  severity: z.ZodEnum<{
25
25
  error: "error";
26
- warning: "warning";
27
26
  debug: "debug";
28
27
  info: "info";
28
+ warning: "warning";
29
29
  fatal: "fatal";
30
30
  }>;
31
31
  title: z.ZodString;
@@ -45,37 +45,37 @@ export declare const AgentBlockingItemSchema: z.ZodObject<{
45
45
  export type AgentBlockingItem = z.infer<typeof AgentBlockingItemSchema>;
46
46
  export declare const AgentChecksSchema: z.ZodObject<{
47
47
  typecheck: z.ZodOptional<z.ZodEnum<{
48
+ unknown: "unknown";
48
49
  passed: "passed";
49
50
  failed: "failed";
50
- unknown: "unknown";
51
51
  }>>;
52
52
  lint: z.ZodOptional<z.ZodEnum<{
53
+ unknown: "unknown";
53
54
  passed: "passed";
54
55
  failed: "failed";
55
- unknown: "unknown";
56
56
  }>>;
57
57
  build: z.ZodOptional<z.ZodEnum<{
58
+ unknown: "unknown";
58
59
  passed: "passed";
59
60
  failed: "failed";
60
- unknown: "unknown";
61
61
  }>>;
62
62
  runtime: z.ZodOptional<z.ZodEnum<{
63
63
  warning: "warning";
64
+ unknown: "unknown";
64
65
  passed: "passed";
65
66
  failed: "failed";
66
- unknown: "unknown";
67
67
  }>>;
68
68
  visual: z.ZodOptional<z.ZodEnum<{
69
69
  warning: "warning";
70
+ unknown: "unknown";
70
71
  passed: "passed";
71
72
  failed: "failed";
72
- unknown: "unknown";
73
73
  }>>;
74
74
  memory: z.ZodOptional<z.ZodEnum<{
75
75
  warning: "warning";
76
+ unknown: "unknown";
76
77
  passed: "passed";
77
78
  failed: "failed";
78
- unknown: "unknown";
79
79
  }>>;
80
80
  }, z.core.$strip>;
81
81
  /**
@@ -109,10 +109,10 @@ export declare const AgentCurrentStatusSchema: z.ZodObject<{
109
109
  updatedAt: z.ZodOptional<z.ZodString>;
110
110
  sessionId: z.ZodString;
111
111
  status: z.ZodEnum<{
112
- starting: "starting";
113
- clean: "clean";
114
112
  warning: "warning";
113
+ clean: "clean";
115
114
  failing: "failing";
115
+ starting: "starting";
116
116
  }>;
117
117
  activeTab: z.ZodOptional<z.ZodString>;
118
118
  tabsWithIssues: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -120,9 +120,9 @@ export declare const AgentCurrentStatusSchema: z.ZodObject<{
120
120
  source: z.ZodString;
121
121
  severity: z.ZodEnum<{
122
122
  error: "error";
123
- warning: "warning";
124
123
  debug: "debug";
125
124
  info: "info";
125
+ warning: "warning";
126
126
  fatal: "fatal";
127
127
  }>;
128
128
  title: z.ZodString;
@@ -143,9 +143,9 @@ export declare const AgentCurrentStatusSchema: z.ZodObject<{
143
143
  source: z.ZodString;
144
144
  severity: z.ZodEnum<{
145
145
  error: "error";
146
- warning: "warning";
147
146
  debug: "debug";
148
147
  info: "info";
148
+ warning: "warning";
149
149
  fatal: "fatal";
150
150
  }>;
151
151
  title: z.ZodString;
@@ -165,37 +165,37 @@ export declare const AgentCurrentStatusSchema: z.ZodObject<{
165
165
  suggestedReads: z.ZodArray<z.ZodString>;
166
166
  checks: z.ZodOptional<z.ZodObject<{
167
167
  typecheck: z.ZodOptional<z.ZodEnum<{
168
+ unknown: "unknown";
168
169
  passed: "passed";
169
170
  failed: "failed";
170
- unknown: "unknown";
171
171
  }>>;
172
172
  lint: z.ZodOptional<z.ZodEnum<{
173
+ unknown: "unknown";
173
174
  passed: "passed";
174
175
  failed: "failed";
175
- unknown: "unknown";
176
176
  }>>;
177
177
  build: z.ZodOptional<z.ZodEnum<{
178
+ unknown: "unknown";
178
179
  passed: "passed";
179
180
  failed: "failed";
180
- unknown: "unknown";
181
181
  }>>;
182
182
  runtime: z.ZodOptional<z.ZodEnum<{
183
183
  warning: "warning";
184
+ unknown: "unknown";
184
185
  passed: "passed";
185
186
  failed: "failed";
186
- unknown: "unknown";
187
187
  }>>;
188
188
  visual: z.ZodOptional<z.ZodEnum<{
189
189
  warning: "warning";
190
+ unknown: "unknown";
190
191
  passed: "passed";
191
192
  failed: "failed";
192
- unknown: "unknown";
193
193
  }>>;
194
194
  memory: z.ZodOptional<z.ZodEnum<{
195
195
  warning: "warning";
196
+ unknown: "unknown";
196
197
  passed: "passed";
197
198
  failed: "failed";
198
- unknown: "unknown";
199
199
  }>>;
200
200
  }, z.core.$strip>>;
201
201
  server: z.ZodOptional<z.ZodObject<{
@@ -300,9 +300,9 @@ declare const CheckEntrySchema: z.ZodObject<{
300
300
  rule: z.ZodOptional<z.ZodString>;
301
301
  severity: z.ZodOptional<z.ZodEnum<{
302
302
  error: "error";
303
- warning: "warning";
304
303
  debug: "debug";
305
304
  info: "info";
305
+ warning: "warning";
306
306
  fatal: "fatal";
307
307
  }>>;
308
308
  file: z.ZodOptional<z.ZodString>;
@@ -328,9 +328,9 @@ export declare const TypecheckCurrentSchema: z.ZodObject<{
328
328
  lastReportedAt: z.ZodNumber;
329
329
  lastRunStatus: z.ZodEnum<{
330
330
  error: "error";
331
+ running: "running";
331
332
  clean: "clean";
332
333
  failing: "failing";
333
- running: "running";
334
334
  }>;
335
335
  lastRunDurationMs: z.ZodOptional<z.ZodNumber>;
336
336
  errorCount: z.ZodNumber;
@@ -342,9 +342,9 @@ export declare const TypecheckCurrentSchema: z.ZodObject<{
342
342
  stale: z.ZodBoolean;
343
343
  detail: z.ZodString;
344
344
  status: z.ZodEnum<{
345
+ unknown: "unknown";
345
346
  clean: "clean";
346
347
  failing: "failing";
347
- unknown: "unknown";
348
348
  }>;
349
349
  errorCount: z.ZodNumber;
350
350
  lastRunAt: z.ZodOptional<z.ZodNumber>;
@@ -367,9 +367,9 @@ export declare const TypecheckErrorsSchema: z.ZodObject<{
367
367
  lastReportedAt: z.ZodNumber;
368
368
  lastRunStatus: z.ZodEnum<{
369
369
  error: "error";
370
+ running: "running";
370
371
  clean: "clean";
371
372
  failing: "failing";
372
- running: "running";
373
373
  }>;
374
374
  lastRunDurationMs: z.ZodOptional<z.ZodNumber>;
375
375
  errorCount: z.ZodNumber;
@@ -389,9 +389,9 @@ export declare const TypecheckErrorsSchema: z.ZodObject<{
389
389
  rule: z.ZodOptional<z.ZodString>;
390
390
  severity: z.ZodOptional<z.ZodEnum<{
391
391
  error: "error";
392
- warning: "warning";
393
392
  debug: "debug";
394
393
  info: "info";
394
+ warning: "warning";
395
395
  fatal: "fatal";
396
396
  }>>;
397
397
  file: z.ZodOptional<z.ZodString>;
@@ -418,9 +418,9 @@ export declare const LintCurrentSchema: z.ZodObject<{
418
418
  lastReportedAt: z.ZodNumber;
419
419
  lastRunStatus: z.ZodEnum<{
420
420
  error: "error";
421
+ running: "running";
421
422
  clean: "clean";
422
423
  failing: "failing";
423
- running: "running";
424
424
  }>;
425
425
  lastRunDurationMs: z.ZodOptional<z.ZodNumber>;
426
426
  errorCount: z.ZodNumber;
@@ -432,10 +432,10 @@ export declare const LintCurrentSchema: z.ZodObject<{
432
432
  stale: z.ZodBoolean;
433
433
  detail: z.ZodString;
434
434
  status: z.ZodEnum<{
435
- clean: "clean";
436
435
  warning: "warning";
437
- failing: "failing";
438
436
  unknown: "unknown";
437
+ clean: "clean";
438
+ failing: "failing";
439
439
  }>;
440
440
  errorCount: z.ZodNumber;
441
441
  warningCount: z.ZodNumber;
@@ -459,9 +459,9 @@ export declare const BuildCurrentSchema: z.ZodObject<{
459
459
  lastReportedAt: z.ZodNumber;
460
460
  lastRunStatus: z.ZodEnum<{
461
461
  error: "error";
462
+ running: "running";
462
463
  clean: "clean";
463
464
  failing: "failing";
464
- running: "running";
465
465
  }>;
466
466
  lastRunDurationMs: z.ZodOptional<z.ZodNumber>;
467
467
  errorCount: z.ZodNumber;
@@ -473,10 +473,10 @@ export declare const BuildCurrentSchema: z.ZodObject<{
473
473
  stale: z.ZodBoolean;
474
474
  detail: z.ZodString;
475
475
  status: z.ZodEnum<{
476
- clean: "clean";
477
476
  warning: "warning";
478
- failing: "failing";
479
477
  unknown: "unknown";
478
+ clean: "clean";
479
+ failing: "failing";
480
480
  }>;
481
481
  hmrUpdates: z.ZodNumber;
482
482
  lastRunAt: z.ZodOptional<z.ZodNumber>;
package/lib/resources.js CHANGED
@@ -1,205 +1 @@
1
- import { z } from 'zod';
2
- import { SCHEMA_VERSION } from './schema-version.js';
3
- import { SourceLocationSchema } from './source-location.js';
4
- import { SeveritySchema } from './event.js';
5
- import { ProducerHealthSchema } from './producer-health.js';
6
- /**
7
- * Well-known URI schemes used by LensMCP. See `planning/03-mcp-surface.md`.
8
- * Each scheme maps 1:1 to a FrontMCP @App package.
9
- */
10
- export const URI_SCHEMES = [
11
- 'agent',
12
- 'events',
13
- 'build',
14
- 'lint',
15
- 'typecheck',
16
- 'test',
17
- 'runtime',
18
- 'render',
19
- 'visual',
20
- 'flow',
21
- 'story',
22
- 'trace',
23
- 'graph',
24
- 'bundle',
25
- 'security',
26
- 'perf',
27
- 'deps',
28
- 'memory',
29
- 'browser',
30
- 'react',
31
- 'valtio',
32
- 'nest',
33
- 'next',
34
- 'process',
35
- ];
36
- // -------- shared header on every resource JSON --------
37
- export const ResourceEnvelopeSchema = z.object({
38
- $schema: z.string().optional(),
39
- schemaVersion: z.literal(SCHEMA_VERSION),
40
- revision: z.number().int().nonnegative(),
41
- updatedAt: z.string().datetime().optional(),
42
- });
43
- // -------- agent://current-status --------
44
- export const AgentStatusKindSchema = z.enum([
45
- 'starting',
46
- 'clean',
47
- 'warning',
48
- 'failing',
49
- ]);
50
- export const AgentBlockingItemSchema = z.object({
51
- source: z.string(),
52
- severity: SeveritySchema,
53
- title: z.string(),
54
- fingerprint: z.string(),
55
- resource: z.string(),
56
- pageId: z.string().optional(),
57
- flowId: z.string().optional(),
58
- location: SourceLocationSchema.optional(),
59
- });
60
- export const AgentChecksSchema = z.object({
61
- typecheck: z.enum(['passed', 'failed', 'unknown']).optional(),
62
- lint: z.enum(['passed', 'failed', 'unknown']).optional(),
63
- build: z.enum(['passed', 'failed', 'unknown']).optional(),
64
- runtime: z.enum(['passed', 'failed', 'warning', 'unknown']).optional(),
65
- visual: z.enum(['passed', 'failed', 'warning', 'unknown']).optional(),
66
- memory: z.enum(['passed', 'failed', 'warning', 'unknown']).optional(),
67
- });
68
- /**
69
- * How the MCP server answering this read is being served.
70
- *
71
- * `shared` means ONE server for the workspace, reached by every agent session
72
- * through a thin stdio shim — so `sessionId` below is the SHARED lens session
73
- * and other sessions are reading the same state. `embedded` means this server
74
- * belongs to one agent session and dies with it (and therefore keeps serving the
75
- * bundle it started with until that session ends).
76
- */
77
- export const AgentServerModeSchema = z.enum(['embedded', 'shared']);
78
- export const AgentServerInfoSchema = z.object({
79
- mode: AgentServerModeSchema,
80
- /** The server process. Stable across agent sessions in `shared` mode. */
81
- pid: z.number(),
82
- /** ISO timestamp this server process started — how stale its bundle may be. */
83
- startedAt: z.string(),
84
- /** The loopback URL clients reach it on. Only in `shared` mode. */
85
- url: z.string().optional(),
86
- });
87
- export const AgentCurrentStatusSchema = ResourceEnvelopeSchema.extend({
88
- sessionId: z.string(),
89
- status: AgentStatusKindSchema,
90
- activeTab: z.string().optional(),
91
- tabsWithIssues: z.array(z.string()).optional(),
92
- blocking: z.array(AgentBlockingItemSchema),
93
- warnings: z.array(AgentBlockingItemSchema).default([]),
94
- suggestedReads: z.array(z.string()),
95
- checks: AgentChecksSchema.optional(),
96
- /**
97
- * Optional so a bare context (no server env) still validates — and so a
98
- * pre-shim recorded status keeps parsing.
99
- */
100
- server: AgentServerInfoSchema.optional(),
101
- });
102
- // -------- agent://session --------
103
- /**
104
- * Hot-tier retention pressure.
105
- *
106
- * WHY it is on the bootstrap surface: every retention cap used to be a COUNT
107
- * cap over payloads of arbitrary size, so the hot tier could hold hundreds of
108
- * MB while every counter still read "5 000 events" — the growth was
109
- * invisible from the outside (the MCP server was found at 395–720 MB RSS by
110
- * looking at the process, not at any lens surface). These are the numbers
111
- * that make a bounded tier observable: what is resident in BYTES, what was
112
- * evicted to stay inside the budget, and how many producer payloads the
113
- * ingest clamp had to shrink. `truncatedEvents` climbing is the signal that
114
- * some producer is attaching megabytes per event.
115
- */
116
- export const AgentStorageStatsSchema = z.object({
117
- eventsResident: z.number().int().nonnegative(),
118
- eventsResidentBytes: z.number().int().nonnegative(),
119
- eventsIngested: z.number().int().nonnegative(),
120
- eventsDropped: z.number().int().nonnegative(),
121
- /** Of `eventsDropped`, those evicted because the BYTE budget was hit. */
122
- eventsDroppedForBytes: z.number().int().nonnegative().optional(),
123
- eventCap: z.number().int().nonnegative().optional(),
124
- eventByteCap: z.number().int().nonnegative().optional(),
125
- artifactsResident: z.number().int().nonnegative().optional(),
126
- artifactsResidentBytes: z.number().int().nonnegative().optional(),
127
- artifactsDropped: z.number().int().nonnegative().optional(),
128
- artifactByteCap: z.number().int().nonnegative().optional(),
129
- /** Events whose `raw` exceeded the per-event limit and was shrunk. */
130
- truncatedEvents: z.number().int().nonnegative().optional(),
131
- /** Approximate bytes never admitted thanks to that truncation. */
132
- truncatedBytesReclaimed: z.number().int().nonnegative().optional(),
133
- /** The per-event `raw` limit in force. */
134
- rawByteLimit: z.number().int().nonnegative().optional(),
135
- });
136
- // -------- agent://session --------
137
- export const AgentSessionSchema = ResourceEnvelopeSchema.extend({
138
- sessionId: z.string(),
139
- supportedResources: z.array(z.string()),
140
- supportedTools: z.array(z.string()),
141
- supportedJobs: z.array(z.string()),
142
- supportedChannels: z.array(z.string()),
143
- subscribedByDefault: z.array(z.string()),
144
- transports: z.array(z.enum(['stdio', 'http', 'socket'])),
145
- host: z.object({
146
- platform: z.string(),
147
- node: z.string(),
148
- }),
149
- project: z.object({
150
- name: z.string(),
151
- nxVersion: z.string().optional(),
152
- }),
153
- /** Optional — absent when the backend reports no stats. */
154
- storage: AgentStorageStatsSchema.optional(),
155
- });
156
- // -------- the check resources: typecheck:// · lint:// · build:// --------
157
- /**
158
- * The three "is my code OK?" resources: an envelope + a status + counts + the
159
- * {@link ProducerHealthSchema} block.
160
- *
161
- * The producer block is what makes `status` legible. Without it,
162
- * `{"status":"unknown","errorCount":0,"revision":0}` is ambiguous between
163
- * "checked, nothing wrong" and "nothing has ever checked" — and for
164
- * `typecheck://` and `lint://` it was always the second, because neither had a
165
- * producer wired at all. Read `producer` BEFORE trusting `status`.
166
- */
167
- const CheckEntrySchema = z.object({
168
- id: z.string(),
169
- timestamp: z.number().int().nonnegative(),
170
- message: z.string(),
171
- fingerprint: z.string(),
172
- code: z.string().optional(),
173
- rule: z.string().optional(),
174
- severity: SeveritySchema.optional(),
175
- file: z.string().optional(),
176
- line: z.number().int().nonnegative().optional(),
177
- column: z.number().int().nonnegative().optional(),
178
- project: z.string().optional(),
179
- });
180
- export const TypecheckCurrentSchema = ResourceEnvelopeSchema.merge(ProducerHealthSchema).extend({
181
- status: z.enum(['unknown', 'clean', 'failing']),
182
- errorCount: z.number().int().nonnegative(),
183
- lastRunAt: z.number().int().nonnegative().optional(),
184
- });
185
- export const TypecheckErrorsSchema = ResourceEnvelopeSchema.merge(ProducerHealthSchema).extend({
186
- errors: z.array(CheckEntrySchema),
187
- });
188
- export const LintCurrentSchema = ResourceEnvelopeSchema.merge(ProducerHealthSchema).extend({
189
- status: z.enum(['unknown', 'clean', 'warning', 'failing']),
190
- errorCount: z.number().int().nonnegative(),
191
- warningCount: z.number().int().nonnegative(),
192
- lastRunAt: z.number().int().nonnegative().optional(),
193
- });
194
- export const BuildCurrentSchema = ResourceEnvelopeSchema.merge(ProducerHealthSchema).extend({
195
- status: z.enum(['unknown', 'clean', 'warning', 'failing']),
196
- hmrUpdates: z.number().int().nonnegative(),
197
- /**
198
- * When the newest build/typecheck/lint verdict landed. Absent means nothing
199
- * has ever reported — which is NOT the same as clean, and was invisible
200
- * while this field was missing: `build://current` claimed `failing` with 12
201
- * errors accumulated over 49 minutes and no timestamp to expose their age.
202
- * `typecheck://` and `lint://` have always carried it; this aligns the third.
203
- */
204
- lastRunAt: z.number().int().nonnegative().optional(),
205
- });
1
+ "use strict";import{z as n}from"zod";import{SCHEMA_VERSION as i}from"./schema-version.js";import{SourceLocationSchema as o}from"./source-location.js";import{SeveritySchema as t}from"./event.js";import{ProducerHealthSchema as e}from"./producer-health.js";export const URI_SCHEMES=["agent","events","build","lint","typecheck","test","runtime","render","visual","flow","story","trace","graph","bundle","security","perf","deps","memory","browser","react","valtio","nest","next","process"],ResourceEnvelopeSchema=n.object({$schema:n.string().optional(),schemaVersion:n.literal(i),revision:n.number().int().nonnegative(),updatedAt:n.string().datetime().optional()}),AgentStatusKindSchema=n.enum(["starting","clean","warning","failing"]),AgentBlockingItemSchema=n.object({source:n.string(),severity:t,title:n.string(),fingerprint:n.string(),resource:n.string(),pageId:n.string().optional(),flowId:n.string().optional(),location:o.optional()}),AgentChecksSchema=n.object({typecheck:n.enum(["passed","failed","unknown"]).optional(),lint:n.enum(["passed","failed","unknown"]).optional(),build:n.enum(["passed","failed","unknown"]).optional(),runtime:n.enum(["passed","failed","warning","unknown"]).optional(),visual:n.enum(["passed","failed","warning","unknown"]).optional(),memory:n.enum(["passed","failed","warning","unknown"]).optional()}),AgentServerModeSchema=n.enum(["embedded","shared"]),AgentServerInfoSchema=n.object({mode:AgentServerModeSchema,pid:n.number(),startedAt:n.string(),url:n.string().optional()}),AgentCurrentStatusSchema=ResourceEnvelopeSchema.extend({sessionId:n.string(),status:AgentStatusKindSchema,activeTab:n.string().optional(),tabsWithIssues:n.array(n.string()).optional(),blocking:n.array(AgentBlockingItemSchema),warnings:n.array(AgentBlockingItemSchema).default([]),suggestedReads:n.array(n.string()),checks:AgentChecksSchema.optional(),server:AgentServerInfoSchema.optional()}),AgentStorageStatsSchema=n.object({eventsResident:n.number().int().nonnegative(),eventsResidentBytes:n.number().int().nonnegative(),eventsIngested:n.number().int().nonnegative(),eventsDropped:n.number().int().nonnegative(),eventsDroppedForBytes:n.number().int().nonnegative().optional(),eventCap:n.number().int().nonnegative().optional(),eventByteCap:n.number().int().nonnegative().optional(),artifactsResident:n.number().int().nonnegative().optional(),artifactsResidentBytes:n.number().int().nonnegative().optional(),artifactsDropped:n.number().int().nonnegative().optional(),artifactByteCap:n.number().int().nonnegative().optional(),truncatedEvents:n.number().int().nonnegative().optional(),truncatedBytesReclaimed:n.number().int().nonnegative().optional(),rawByteLimit:n.number().int().nonnegative().optional()}),AgentSessionSchema=ResourceEnvelopeSchema.extend({sessionId:n.string(),supportedResources:n.array(n.string()),supportedTools:n.array(n.string()),supportedJobs:n.array(n.string()),supportedChannels:n.array(n.string()),subscribedByDefault:n.array(n.string()),transports:n.array(n.enum(["stdio","http","socket"])),host:n.object({platform:n.string(),node:n.string()}),project:n.object({name:n.string(),nxVersion:n.string().optional()}),storage:AgentStorageStatsSchema.optional()});const r=n.object({id:n.string(),timestamp:n.number().int().nonnegative(),message:n.string(),fingerprint:n.string(),code:n.string().optional(),rule:n.string().optional(),severity:t.optional(),file:n.string().optional(),line:n.number().int().nonnegative().optional(),column:n.number().int().nonnegative().optional(),project:n.string().optional()});export const TypecheckCurrentSchema=ResourceEnvelopeSchema.merge(e).extend({status:n.enum(["unknown","clean","failing"]),errorCount:n.number().int().nonnegative(),lastRunAt:n.number().int().nonnegative().optional()}),TypecheckErrorsSchema=ResourceEnvelopeSchema.merge(e).extend({errors:n.array(r)}),LintCurrentSchema=ResourceEnvelopeSchema.merge(e).extend({status:n.enum(["unknown","clean","warning","failing"]),errorCount:n.number().int().nonnegative(),warningCount:n.number().int().nonnegative(),lastRunAt:n.number().int().nonnegative().optional()}),BuildCurrentSchema=ResourceEnvelopeSchema.merge(e).extend({status:n.enum(["unknown","clean","warning","failing"]),hmrUpdates:n.number().int().nonnegative(),lastRunAt:n.number().int().nonnegative().optional()});
@@ -1 +1 @@
1
- export const SCHEMA_VERSION = 1;
1
+ "use strict";export const SCHEMA_VERSION=1;
@@ -1,9 +1 @@
1
- import { z } from 'zod';
2
- export const SourceLocationSchema = z.object({
3
- file: z.string(),
4
- line: z.number().int().nonnegative().optional(),
5
- column: z.number().int().nonnegative().optional(),
6
- symbol: z.string().optional(),
7
- componentName: z.string().optional(),
8
- hookName: z.string().optional(),
9
- });
1
+ "use strict";import{z as o}from"zod";export const SourceLocationSchema=o.object({file:o.string(),line:o.number().int().nonnegative().optional(),column:o.number().int().nonnegative().optional(),symbol:o.string().optional(),componentName:o.string().optional(),hookName:o.string().optional()});
package/lib/tokens.js CHANGED
@@ -1,12 +1 @@
1
- /**
2
- * DI tokens for FrontMCP `@Provider` registrations. Each token is paired
3
- * with a TypeScript interface declared by the package that owns it, so
4
- * consumers can type the `this.get(Token)` call by importing the
5
- * companion type. We keep the *interfaces* abstract in this package and
6
- * let `@lensmcp/core` etc. ship their concrete classes.
7
- */
8
- export const SessionToken = Symbol.for('@lensmcp/session/Session');
9
- export const EventBusToken = Symbol.for('@lensmcp/core/EventBus');
10
- export const GraphStoreToken = Symbol.for('@lensmcp/core/GraphStore');
11
- export const ResourceStoreToken = Symbol.for('@lensmcp/core/ResourceStore');
12
- export const StorageToken = Symbol.for('@lensmcp/storage/Storage');
1
+ "use strict";export const SessionToken=Symbol.for("@lensmcp/session/Session"),EventBusToken=Symbol.for("@lensmcp/core/EventBus"),GraphStoreToken=Symbol.for("@lensmcp/core/GraphStore"),ResourceStoreToken=Symbol.for("@lensmcp/core/ResourceStore"),StorageToken=Symbol.for("@lensmcp/storage/Storage");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensmcp/protocol-types",
3
- "version": "1.18.4",
3
+ "version": "1.18.7",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",