@lensmcp/protocol-types 1.0.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/LICENSE +202 -0
- package/README.md +128 -0
- package/index.d.ts +10 -0
- package/index.d.ts.map +1 -0
- package/index.js +9 -0
- package/lib/attributes.d.ts +312 -0
- package/lib/attributes.d.ts.map +1 -0
- package/lib/attributes.js +203 -0
- package/lib/context.d.ts +66 -0
- package/lib/context.d.ts.map +1 -0
- package/lib/context.js +41 -0
- package/lib/edge.d.ts +42 -0
- package/lib/edge.d.ts.map +1 -0
- package/lib/edge.js +25 -0
- package/lib/event.d.ts +160 -0
- package/lib/event.d.ts.map +1 -0
- package/lib/event.js +67 -0
- package/lib/node.d.ts +204 -0
- package/lib/node.d.ts.map +1 -0
- package/lib/node.js +98 -0
- package/lib/resources.d.ts +205 -0
- package/lib/resources.d.ts.map +1 -0
- package/lib/resources.js +94 -0
- package/lib/schema-version.d.ts +3 -0
- package/lib/schema-version.d.ts.map +1 -0
- package/lib/schema-version.js +1 -0
- package/lib/source-location.d.ts +11 -0
- package/lib/source-location.d.ts.map +1 -0
- package/lib/source-location.js +9 -0
- package/lib/tokens.d.ts +14 -0
- package/lib/tokens.d.ts.map +1 -0
- package/lib/tokens.js +12 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# @lensmcp/protocol-types
|
|
2
|
+
|
|
3
|
+
> The shared event protocol for LensMCP — Zod schemas and inferred TypeScript types for the events, trace nodes, edges, and resources that flow between producers and consumers.
|
|
4
|
+
|
|
5
|
+
LensMCP is an observability lens for coding agents. This package is the **wire contract** that keeps every part of the system in sync: a single set of [Zod](https://zod.dev) schemas (and the TypeScript types inferred from them) describing the events emitted by instrumentation, the trace graph (nodes + edges) those events build up, the per-domain attribute shapes, and the MCP resources consumers read.
|
|
6
|
+
|
|
7
|
+
Because the schemas and types are derived from the same definitions, producers (browser/React, Node/Nest taps, the gateway) and consumers (`@lensmcp/core`, the MCP server, the dashboard) share one source of truth — emit-side validation and read-side typing never drift apart.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
yarn add @lensmcp/protocol-types
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Requires Node `>=18`. `zod` is a runtime dependency.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
Validate an event on the producer side, and type it on the consumer side, from the same schema:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import {
|
|
23
|
+
BaseEventSchema,
|
|
24
|
+
type BaseEvent,
|
|
25
|
+
type EventSource,
|
|
26
|
+
} from '@lensmcp/protocol-types';
|
|
27
|
+
|
|
28
|
+
// Producer: parse/validate before emitting (throws on bad shape).
|
|
29
|
+
const event = BaseEventSchema.parse({
|
|
30
|
+
id: 'evt_01',
|
|
31
|
+
sessionId: 'sess_abc',
|
|
32
|
+
timestamp: Date.now(),
|
|
33
|
+
source: 'react',
|
|
34
|
+
category: 'render',
|
|
35
|
+
severity: 'warning',
|
|
36
|
+
context: { sessionId: 'sess_abc', route: '/dashboard' },
|
|
37
|
+
fingerprint: 'render:Slow:/dashboard',
|
|
38
|
+
title: 'Slow render',
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Consumer: the inferred type is the contract.
|
|
42
|
+
function handle(e: BaseEvent) {
|
|
43
|
+
const from: EventSource = e.source;
|
|
44
|
+
console.log(from, e.category, e.severity);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Use `.safeParse()` when you want to branch on validity instead of throwing:
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
const result = BaseEventSchema.safeParse(input);
|
|
52
|
+
if (!result.success) {
|
|
53
|
+
// result.error is a ZodError
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Every schema follows the `XxxSchema` (value) + `Xxx` (inferred type) naming convention, so you can import whichever you need.
|
|
58
|
+
|
|
59
|
+
## What's in here
|
|
60
|
+
|
|
61
|
+
### Event (`event.ts`)
|
|
62
|
+
|
|
63
|
+
- **`BaseEventSchema` / `BaseEvent`** — the common envelope on every emitted event: `id`, `sessionId`, `timestamp`, `source`, `category`, `severity`, `context`, `fingerprint`, `title`, plus optional `message`, `location`, `relatedFiles`, `relatedUrls`, and `raw`.
|
|
64
|
+
- **`EventSourceSchema` / `EventSource`** — where the event came from:
|
|
65
|
+
`nx`, `vite`, `typescript`, `eslint`, `rollup`, `client-runtime`, `chrome`, `react`, `valtio`, `nestjs`, `nextjs`, `db`, `redis`, `queue`, `memory`, `visual`, `perf`, `security`, `gateway`, `external`.
|
|
66
|
+
- **`EventCategorySchema` / `EventCategory`** — what kind of signal it is:
|
|
67
|
+
`build`, `lint`, `typecheck`, `test`, `runtime`, `render`, `visual`, `trace`, `state`, `network`, `backend`, `db`, `memory`, `performance`, `security`, `deps`, `cluster`.
|
|
68
|
+
- **`SeveritySchema` / `Severity`** — `debug`, `info`, `warning`, `error`, `fatal`.
|
|
69
|
+
|
|
70
|
+
### Trace context (`context.ts`)
|
|
71
|
+
|
|
72
|
+
- **`TraceContextSchema` / `TraceContext`** — the correlation envelope carried on events and nodes: `sessionId` plus optional browser identifiers (`browserContextId`, `tabId`, `frameId`, `route`, `url`), flow identifiers (`flowId`, `originType`, `originNodeId`, `causedByNodeId`), request identifiers (`requestId`, `traceparent`), and hashed actor identifiers (`userActionId`, `userIdHash`, `tenantIdHash`).
|
|
73
|
+
- **`FlowOriginTypeSchema` / `FlowOriginType`** — what kicked off a flow (e.g. `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`).
|
|
74
|
+
|
|
75
|
+
### Trace graph — nodes & edges (`node.ts`, `edge.ts`)
|
|
76
|
+
|
|
77
|
+
- **`TraceNodeSchema` / `TraceNode`** — a node in the trace graph: identity (`id`, `parentTraceNodeId`, `logicalId`, `instanceId`, `generation`), `type`, `lifecycle`, `context`, timing (`startTime`, `endTime`, `durationMs`), optional `location`, and an open `attributes` record.
|
|
78
|
+
- **`TraceNodeTypeSchema` / `TraceNodeType`** — the node taxonomy spanning the browser process tree, React UI, user interaction, network/API, backend (Nest app/module/provider, requests, DB/Redis ops, queue jobs, loops, promises), state, visual, memory, and build/dev events.
|
|
79
|
+
- **`LifecycleSchema` / `Lifecycle`** — `created`, `active`, `completed`, `disposed`, `errored`.
|
|
80
|
+
- **`TraceEdgeSchema` / `TraceEdge`** — a directed relationship between nodes: `from`, `to`, `axis`, `type`, `timestamp`, optional `attributes`.
|
|
81
|
+
- **`EdgeAxisSchema` / `EdgeAxis`** — the relationship dimension: `ownership`, `caused`, `async`, `data`, `render`, `state`, `network`, `backend`, `db`, `visual`, `performance`, `memory`, `lifecycle`.
|
|
82
|
+
|
|
83
|
+
### Domain attributes (`attributes.ts`)
|
|
84
|
+
|
|
85
|
+
Typed `attributes` payloads for specific node types, each with its `XxxSchema` + `Xxx` pair:
|
|
86
|
+
|
|
87
|
+
- **Render** — `RenderAttrs`, `RenderPhase` (`mount` | `update`), and the discriminated `RenderWhy` (props / react-state / context / valtio-path / parent-render / hook-dep-changed / force).
|
|
88
|
+
- **Effects & state** — `EffectRunAttrs`, `ValtioUpdateAttrs`.
|
|
89
|
+
- **Backend** — `ServerRequestAttrs`, plus `LoopAttrs` / `LoopPattern` (`N+1`, `sequential-await`, `growing-allocation`).
|
|
90
|
+
- **Memory** — `MemoryOwnerAttrs`, `MemoryMutationAttrs`, with `MemoryContainerKind` and `MemoryMutationOperation` enums.
|
|
91
|
+
- **Visual** — `VisualFrameAttrs` and `VisualViolationAttrs`, plus `Rect`, `VisualFrameCause`, `VisualChangeKind`, `VisualRuleType`, `VisualRuleTiming`, and `VisualViolationSeverity`.
|
|
92
|
+
|
|
93
|
+
### Source location (`source-location.ts`)
|
|
94
|
+
|
|
95
|
+
- **`SourceLocationSchema` / `SourceLocation`** — `file` plus optional `line`, `column`, `symbol`, `componentName`, `hookName`. Reused across events, nodes, and resources to point back at code.
|
|
96
|
+
|
|
97
|
+
### Resources (`resources.ts`)
|
|
98
|
+
|
|
99
|
+
The MCP-facing read models, all built on a shared envelope:
|
|
100
|
+
|
|
101
|
+
- **`ResourceEnvelopeSchema` / `ResourceEnvelope`** — the header on every resource JSON (`schemaVersion`, `revision`, optional `$schema` and `updatedAt`).
|
|
102
|
+
- **`URI_SCHEMES` / `UriScheme`** — the well-known LensMCP resource URI schemes (each maps 1:1 to a FrontMCP `@App` package): `agent`, `events`, `build`, `lint`, `typecheck`, `test`, `runtime`, `render`, `visual`, `flow`, `story`, `trace`, `graph`, `bundle`, `security`, `perf`, `deps`, `memory`, `browser`, `react`, `valtio`, `nest`, `next`, `process`.
|
|
103
|
+
- **`AgentCurrentStatusSchema` / `AgentCurrentStatus`** (`agent://current-status`) — rollup status (`AgentStatusKind`: `starting` | `clean` | `warning` | `failing`), `blocking` / `warnings` items (`AgentBlockingItem`), `suggestedReads`, and per-domain `checks` (`AgentChecks`).
|
|
104
|
+
- **`AgentSessionSchema` / `AgentSession`** (`agent://session`) — session capabilities: supported resources/tools/jobs/channels, default subscriptions, transports, host info, and project info.
|
|
105
|
+
|
|
106
|
+
### DI tokens (`tokens.ts`)
|
|
107
|
+
|
|
108
|
+
`Symbol`-based dependency-injection tokens for FrontMCP `@Provider` registrations — `SessionToken`, `EventBusToken`, `GraphStoreToken`, `ResourceStoreToken`, `StorageToken` (union type `LensmcpToken`). The interfaces stay abstract here; packages like `@lensmcp/core` ship the concrete implementations.
|
|
109
|
+
|
|
110
|
+
### Schema version (`schema-version.ts`)
|
|
111
|
+
|
|
112
|
+
- **`SCHEMA_VERSION`** (currently `1`) and the **`SchemaVersion`** literal type — stamped into `ResourceEnvelope` so consumers can detect protocol drift.
|
|
113
|
+
|
|
114
|
+
## How it fits
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
producers @lensmcp/protocol-types consumers
|
|
118
|
+
───────── ────────────────────── ─────────
|
|
119
|
+
browser / React tap ─┐ ┌─► @lensmcp/core
|
|
120
|
+
node / NestJS taps ─┼──► Zod schemas + inferred types ──────┼─► MCP server
|
|
121
|
+
gateway ─┘ (the wire contract) └─► dashboard
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Every `@lensmcp` instrumentation library and the gateway validate and emit events against these schemas; `@lensmcp/core` and the MCP server consume them with the matching inferred types. One definition, validated on the way out and typed on the way in — so the protocol can't silently drift between producer and consumer.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
Part of [LensMCP](https://github.com/kiwiapps-ltd/lensmcp). Apache-2.0.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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/resources.js';
|
|
9
|
+
export * from './lib/tokens.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
|
package/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
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/resources.js';
|
|
9
|
+
export * from './lib/tokens.js';
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const RenderPhaseSchema: z.ZodEnum<{
|
|
3
|
+
mount: "mount";
|
|
4
|
+
update: "update";
|
|
5
|
+
}>;
|
|
6
|
+
export type RenderPhase = z.infer<typeof RenderPhaseSchema>;
|
|
7
|
+
export declare const RenderWhySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
8
|
+
type: z.ZodLiteral<"props">;
|
|
9
|
+
changedKeys: z.ZodArray<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
11
|
+
type: z.ZodLiteral<"react-state">;
|
|
12
|
+
hookIndex: z.ZodNumber;
|
|
13
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
14
|
+
type: z.ZodLiteral<"context">;
|
|
15
|
+
contextName: z.ZodString;
|
|
16
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
17
|
+
type: z.ZodLiteral<"valtio-path">;
|
|
18
|
+
path: z.ZodString;
|
|
19
|
+
changedKeys: z.ZodArray<z.ZodString>;
|
|
20
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
21
|
+
type: z.ZodLiteral<"parent-render">;
|
|
22
|
+
parentRenderId: z.ZodString;
|
|
23
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
24
|
+
type: z.ZodLiteral<"hook-dep-changed">;
|
|
25
|
+
hookInstanceId: z.ZodString;
|
|
26
|
+
depsHashBefore: z.ZodString;
|
|
27
|
+
depsHashAfter: z.ZodString;
|
|
28
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
29
|
+
type: z.ZodLiteral<"force">;
|
|
30
|
+
reason: z.ZodString;
|
|
31
|
+
}, z.core.$strip>], "type">;
|
|
32
|
+
export type RenderWhy = z.infer<typeof RenderWhySchema>;
|
|
33
|
+
export declare const RenderAttrsSchema: z.ZodObject<{
|
|
34
|
+
phase: z.ZodEnum<{
|
|
35
|
+
mount: "mount";
|
|
36
|
+
update: "update";
|
|
37
|
+
}>;
|
|
38
|
+
actualDurationMs: z.ZodNumber;
|
|
39
|
+
baseDurationMs: z.ZodNumber;
|
|
40
|
+
startTime: z.ZodNumber;
|
|
41
|
+
commitTime: z.ZodNumber;
|
|
42
|
+
why: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
43
|
+
type: z.ZodLiteral<"props">;
|
|
44
|
+
changedKeys: z.ZodArray<z.ZodString>;
|
|
45
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
46
|
+
type: z.ZodLiteral<"react-state">;
|
|
47
|
+
hookIndex: z.ZodNumber;
|
|
48
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
49
|
+
type: z.ZodLiteral<"context">;
|
|
50
|
+
contextName: z.ZodString;
|
|
51
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
52
|
+
type: z.ZodLiteral<"valtio-path">;
|
|
53
|
+
path: z.ZodString;
|
|
54
|
+
changedKeys: z.ZodArray<z.ZodString>;
|
|
55
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
56
|
+
type: z.ZodLiteral<"parent-render">;
|
|
57
|
+
parentRenderId: z.ZodString;
|
|
58
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
59
|
+
type: z.ZodLiteral<"hook-dep-changed">;
|
|
60
|
+
hookInstanceId: z.ZodString;
|
|
61
|
+
depsHashBefore: z.ZodString;
|
|
62
|
+
depsHashAfter: z.ZodString;
|
|
63
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
64
|
+
type: z.ZodLiteral<"force">;
|
|
65
|
+
reason: z.ZodString;
|
|
66
|
+
}, z.core.$strip>], "type">>;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
export type RenderAttrs = z.infer<typeof RenderAttrsSchema>;
|
|
69
|
+
export declare const EffectRunAttrsSchema: z.ZodObject<{
|
|
70
|
+
hookInstanceId: z.ZodString;
|
|
71
|
+
depsHash: z.ZodString;
|
|
72
|
+
prevDepsHash: z.ZodOptional<z.ZodString>;
|
|
73
|
+
durationMs: z.ZodNumber;
|
|
74
|
+
cleanupRan: z.ZodOptional<z.ZodBoolean>;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
export type EffectRunAttrs = z.infer<typeof EffectRunAttrsSchema>;
|
|
77
|
+
export declare const ValtioUpdateAttrsSchema: z.ZodObject<{
|
|
78
|
+
storeId: z.ZodString;
|
|
79
|
+
path: z.ZodString;
|
|
80
|
+
changedKeys: z.ZodArray<z.ZodString>;
|
|
81
|
+
beforeHash: z.ZodString;
|
|
82
|
+
afterHash: z.ZodString;
|
|
83
|
+
preview: z.ZodOptional<z.ZodUnknown>;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
export type ValtioUpdateAttrs = z.infer<typeof ValtioUpdateAttrsSchema>;
|
|
86
|
+
export declare const ServerRequestAttrsSchema: z.ZodObject<{
|
|
87
|
+
method: z.ZodString;
|
|
88
|
+
route: z.ZodString;
|
|
89
|
+
status: z.ZodOptional<z.ZodNumber>;
|
|
90
|
+
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
91
|
+
traceparent: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.core.$strip>;
|
|
93
|
+
export type ServerRequestAttrs = z.infer<typeof ServerRequestAttrsSchema>;
|
|
94
|
+
export declare const LoopPatternSchema: z.ZodEnum<{
|
|
95
|
+
"N+1": "N+1";
|
|
96
|
+
"sequential-await": "sequential-await";
|
|
97
|
+
"growing-allocation": "growing-allocation";
|
|
98
|
+
}>;
|
|
99
|
+
export type LoopPattern = z.infer<typeof LoopPatternSchema>;
|
|
100
|
+
export declare const LoopAttrsSchema: z.ZodObject<{
|
|
101
|
+
iterations: z.ZodNumber;
|
|
102
|
+
durationMs: z.ZodNumber;
|
|
103
|
+
dbCallsInsideLoop: z.ZodNumber;
|
|
104
|
+
redisCallsInsideLoop: z.ZodNumber;
|
|
105
|
+
awaitedOperationsInsideLoop: z.ZodNumber;
|
|
106
|
+
slowestIterations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
107
|
+
index: z.ZodNumber;
|
|
108
|
+
durationMs: z.ZodNumber;
|
|
109
|
+
childNodeIds: z.ZodArray<z.ZodString>;
|
|
110
|
+
}, z.core.$strip>>>;
|
|
111
|
+
patterns: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
112
|
+
"N+1": "N+1";
|
|
113
|
+
"sequential-await": "sequential-await";
|
|
114
|
+
"growing-allocation": "growing-allocation";
|
|
115
|
+
}>>>;
|
|
116
|
+
}, z.core.$strip>;
|
|
117
|
+
export type LoopAttrs = z.infer<typeof LoopAttrsSchema>;
|
|
118
|
+
export declare const MemoryContainerKindSchema: z.ZodEnum<{
|
|
119
|
+
Map: "Map";
|
|
120
|
+
Set: "Set";
|
|
121
|
+
Array: "Array";
|
|
122
|
+
EventEmitter: "EventEmitter";
|
|
123
|
+
Queue: "Queue";
|
|
124
|
+
RxSubject: "RxSubject";
|
|
125
|
+
Timer: "Timer";
|
|
126
|
+
Interval: "Interval";
|
|
127
|
+
Custom: "Custom";
|
|
128
|
+
}>;
|
|
129
|
+
export type MemoryContainerKind = z.infer<typeof MemoryContainerKindSchema>;
|
|
130
|
+
export declare const MemoryOwnerAttrsSchema: z.ZodObject<{
|
|
131
|
+
ownerInstanceId: z.ZodString;
|
|
132
|
+
containerKind: z.ZodEnum<{
|
|
133
|
+
Map: "Map";
|
|
134
|
+
Set: "Set";
|
|
135
|
+
Array: "Array";
|
|
136
|
+
EventEmitter: "EventEmitter";
|
|
137
|
+
Queue: "Queue";
|
|
138
|
+
RxSubject: "RxSubject";
|
|
139
|
+
Timer: "Timer";
|
|
140
|
+
Interval: "Interval";
|
|
141
|
+
Custom: "Custom";
|
|
142
|
+
}>;
|
|
143
|
+
fieldName: z.ZodString;
|
|
144
|
+
itemCount: z.ZodNumber;
|
|
145
|
+
estimatedBytes: z.ZodNumber;
|
|
146
|
+
retainedBytes: z.ZodOptional<z.ZodNumber>;
|
|
147
|
+
growthSinceStart: z.ZodNumber;
|
|
148
|
+
}, z.core.$strip>;
|
|
149
|
+
export type MemoryOwnerAttrs = z.infer<typeof MemoryOwnerAttrsSchema>;
|
|
150
|
+
export declare const MemoryMutationOperationSchema: z.ZodEnum<{
|
|
151
|
+
set: "set";
|
|
152
|
+
push: "push";
|
|
153
|
+
add: "add";
|
|
154
|
+
delete: "delete";
|
|
155
|
+
clear: "clear";
|
|
156
|
+
subscribe: "subscribe";
|
|
157
|
+
listen: "listen";
|
|
158
|
+
schedule: "schedule";
|
|
159
|
+
}>;
|
|
160
|
+
export type MemoryMutationOperation = z.infer<typeof MemoryMutationOperationSchema>;
|
|
161
|
+
export declare const MemoryMutationAttrsSchema: z.ZodObject<{
|
|
162
|
+
ownerNodeId: z.ZodString;
|
|
163
|
+
operation: z.ZodEnum<{
|
|
164
|
+
set: "set";
|
|
165
|
+
push: "push";
|
|
166
|
+
add: "add";
|
|
167
|
+
delete: "delete";
|
|
168
|
+
clear: "clear";
|
|
169
|
+
subscribe: "subscribe";
|
|
170
|
+
listen: "listen";
|
|
171
|
+
schedule: "schedule";
|
|
172
|
+
}>;
|
|
173
|
+
beforeCount: z.ZodNumber;
|
|
174
|
+
afterCount: z.ZodNumber;
|
|
175
|
+
estimatedDeltaBytes: z.ZodNumber;
|
|
176
|
+
keyPreview: z.ZodOptional<z.ZodString>;
|
|
177
|
+
valueType: z.ZodOptional<z.ZodString>;
|
|
178
|
+
}, z.core.$strip>;
|
|
179
|
+
export type MemoryMutationAttrs = z.infer<typeof MemoryMutationAttrsSchema>;
|
|
180
|
+
export declare const RectSchema: z.ZodObject<{
|
|
181
|
+
x: z.ZodNumber;
|
|
182
|
+
y: z.ZodNumber;
|
|
183
|
+
width: z.ZodNumber;
|
|
184
|
+
height: z.ZodNumber;
|
|
185
|
+
}, z.core.$strip>;
|
|
186
|
+
export type Rect = z.infer<typeof RectSchema>;
|
|
187
|
+
export declare const VisualFrameCauseSchema: z.ZodEnum<{
|
|
188
|
+
"hmr-update": "hmr-update";
|
|
189
|
+
"state-update": "state-update";
|
|
190
|
+
"page-load": "page-load";
|
|
191
|
+
"route-change": "route-change";
|
|
192
|
+
"user-action": "user-action";
|
|
193
|
+
"react-commit": "react-commit";
|
|
194
|
+
"api-response": "api-response";
|
|
195
|
+
"animation-tick": "animation-tick";
|
|
196
|
+
}>;
|
|
197
|
+
export type VisualFrameCause = z.infer<typeof VisualFrameCauseSchema>;
|
|
198
|
+
export declare const VisualChangeKindSchema: z.ZodEnum<{
|
|
199
|
+
"computed-style": "computed-style";
|
|
200
|
+
layout: "layout";
|
|
201
|
+
"paint-order": "paint-order";
|
|
202
|
+
}>;
|
|
203
|
+
export type VisualChangeKind = z.infer<typeof VisualChangeKindSchema>;
|
|
204
|
+
export declare const VisualFrameAttrsSchema: z.ZodObject<{
|
|
205
|
+
causedBy: z.ZodEnum<{
|
|
206
|
+
"hmr-update": "hmr-update";
|
|
207
|
+
"state-update": "state-update";
|
|
208
|
+
"page-load": "page-load";
|
|
209
|
+
"route-change": "route-change";
|
|
210
|
+
"user-action": "user-action";
|
|
211
|
+
"react-commit": "react-commit";
|
|
212
|
+
"api-response": "api-response";
|
|
213
|
+
"animation-tick": "animation-tick";
|
|
214
|
+
}>;
|
|
215
|
+
viewport: z.ZodObject<{
|
|
216
|
+
x: z.ZodNumber;
|
|
217
|
+
y: z.ZodNumber;
|
|
218
|
+
width: z.ZodNumber;
|
|
219
|
+
height: z.ZodNumber;
|
|
220
|
+
}, z.core.$strip>;
|
|
221
|
+
layoutSnapshotId: z.ZodString;
|
|
222
|
+
styleSnapshotId: z.ZodString;
|
|
223
|
+
screenshotId: z.ZodOptional<z.ZodString>;
|
|
224
|
+
changedNodes: z.ZodArray<z.ZodObject<{
|
|
225
|
+
uid: z.ZodString;
|
|
226
|
+
component: z.ZodOptional<z.ZodString>;
|
|
227
|
+
change: z.ZodEnum<{
|
|
228
|
+
"computed-style": "computed-style";
|
|
229
|
+
layout: "layout";
|
|
230
|
+
"paint-order": "paint-order";
|
|
231
|
+
}>;
|
|
232
|
+
property: z.ZodOptional<z.ZodString>;
|
|
233
|
+
before: z.ZodOptional<z.ZodUnknown>;
|
|
234
|
+
after: z.ZodOptional<z.ZodUnknown>;
|
|
235
|
+
}, z.core.$strip>>;
|
|
236
|
+
}, z.core.$strip>;
|
|
237
|
+
export type VisualFrameAttrs = z.infer<typeof VisualFrameAttrsSchema>;
|
|
238
|
+
export declare const VisualRuleTypeSchema: z.ZodEnum<{
|
|
239
|
+
custom: "custom";
|
|
240
|
+
"grid-spacing": "grid-spacing";
|
|
241
|
+
alignment: "alignment";
|
|
242
|
+
overflow: "overflow";
|
|
243
|
+
"text-clipping": "text-clipping";
|
|
244
|
+
"color-contrast": "color-contrast";
|
|
245
|
+
"token-usage": "token-usage";
|
|
246
|
+
"z-index": "z-index";
|
|
247
|
+
responsive: "responsive";
|
|
248
|
+
}>;
|
|
249
|
+
export type VisualRuleType = z.infer<typeof VisualRuleTypeSchema>;
|
|
250
|
+
export declare const VisualRuleTimingSchema: z.ZodEnum<{
|
|
251
|
+
always: "always";
|
|
252
|
+
"after-animation": "after-animation";
|
|
253
|
+
"stable-only": "stable-only";
|
|
254
|
+
"during-animation": "during-animation";
|
|
255
|
+
}>;
|
|
256
|
+
export type VisualRuleTiming = z.infer<typeof VisualRuleTimingSchema>;
|
|
257
|
+
export declare const VisualViolationSeveritySchema: z.ZodEnum<{
|
|
258
|
+
error: "error";
|
|
259
|
+
info: "info";
|
|
260
|
+
warning: "warning";
|
|
261
|
+
}>;
|
|
262
|
+
export type VisualViolationSeverity = z.infer<typeof VisualViolationSeveritySchema>;
|
|
263
|
+
export declare const VisualViolationAttrsSchema: z.ZodObject<{
|
|
264
|
+
ruleId: z.ZodString;
|
|
265
|
+
ruleType: z.ZodEnum<{
|
|
266
|
+
custom: "custom";
|
|
267
|
+
"grid-spacing": "grid-spacing";
|
|
268
|
+
alignment: "alignment";
|
|
269
|
+
overflow: "overflow";
|
|
270
|
+
"text-clipping": "text-clipping";
|
|
271
|
+
"color-contrast": "color-contrast";
|
|
272
|
+
"token-usage": "token-usage";
|
|
273
|
+
"z-index": "z-index";
|
|
274
|
+
responsive: "responsive";
|
|
275
|
+
}>;
|
|
276
|
+
severity: z.ZodEnum<{
|
|
277
|
+
error: "error";
|
|
278
|
+
info: "info";
|
|
279
|
+
warning: "warning";
|
|
280
|
+
}>;
|
|
281
|
+
timing: z.ZodEnum<{
|
|
282
|
+
always: "always";
|
|
283
|
+
"after-animation": "after-animation";
|
|
284
|
+
"stable-only": "stable-only";
|
|
285
|
+
"during-animation": "during-animation";
|
|
286
|
+
}>;
|
|
287
|
+
element: z.ZodObject<{
|
|
288
|
+
uid: z.ZodString;
|
|
289
|
+
component: z.ZodOptional<z.ZodString>;
|
|
290
|
+
rect: z.ZodObject<{
|
|
291
|
+
x: z.ZodNumber;
|
|
292
|
+
y: z.ZodNumber;
|
|
293
|
+
width: z.ZodNumber;
|
|
294
|
+
height: z.ZodNumber;
|
|
295
|
+
}, z.core.$strip>;
|
|
296
|
+
}, z.core.$strip>;
|
|
297
|
+
expected: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
298
|
+
actual: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
299
|
+
evidence: z.ZodObject<{
|
|
300
|
+
computedStyle: z.ZodOptional<z.ZodString>;
|
|
301
|
+
screenshotCrop: z.ZodOptional<z.ZodString>;
|
|
302
|
+
trace: z.ZodOptional<z.ZodString>;
|
|
303
|
+
cssCause: z.ZodOptional<z.ZodObject<{
|
|
304
|
+
selector: z.ZodString;
|
|
305
|
+
file: z.ZodOptional<z.ZodString>;
|
|
306
|
+
line: z.ZodOptional<z.ZodNumber>;
|
|
307
|
+
declaration: z.ZodOptional<z.ZodString>;
|
|
308
|
+
}, z.core.$strip>>;
|
|
309
|
+
}, z.core.$strip>;
|
|
310
|
+
}, z.core.$strip>;
|
|
311
|
+
export type VisualViolationAttrs = z.infer<typeof VisualViolationAttrsSchema>;
|
|
312
|
+
//# sourceMappingURL=attributes.d.ts.map
|