@lensmcp/protocol-types 1.23.13 → 1.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +2 -0
- package/index.js +1 -1
- package/lib/bounded-map.d.ts +1 -1
- package/lib/bounded-writer.d.ts +14 -1
- package/lib/capture-demand.d.ts +1 -1
- package/lib/dashboard.d.ts +34 -1
- package/lib/flood-guard.d.ts +8 -0
- package/lib/flood-guard.js +1 -1
- package/lib/perf-rules.d.ts +135 -0
- package/lib/perf-rules.js +1 -0
- package/lib/pod-memory.d.ts +104 -0
- package/lib/pod-memory.js +1 -0
- package/lib/resources.d.ts +42 -30
- package/lib/resources.js +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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";export*from"./lib/bounded-clone.js";export*from"./lib/bounded-map.js";export*from"./lib/flood-guard.js";export*from"./lib/dashboard.js";export*from"./lib/error-dismissal.js";export*from"./lib/ai-content.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";export*from"./lib/bounded-clone.js";export*from"./lib/bounded-map.js";export*from"./lib/flood-guard.js";export*from"./lib/dashboard.js";export*from"./lib/error-dismissal.js";export*from"./lib/ai-content.js";export*from"./lib/pod-memory.js";export*from"./lib/perf-rules.js";
|
package/lib/bounded-map.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Several reducers kept a session-lifetime `Map` keyed on a value taken straight off an event —
|
|
5
5
|
* `raw.project`, `raw.tool`, a rule id — with no cap and no eviction. Because the bridge accepts a
|
|
6
6
|
* `publish` envelope with an arbitrary `raw` and no origin check, a page the developer visited could
|
|
7
|
-
* grow those maps one entry per message: `db.analyzeRuns` (issues/codex-security
|
|
7
|
+
* grow those maps one entry per message: `db.analyzeRuns` (issues/closed/codex-security-19), the
|
|
8
8
|
* `producers` registries in typecheck/lint/build (21), `visual.rules` (64), and the memory
|
|
9
9
|
* reducer's `ownerNodeId` map (41).
|
|
10
10
|
*
|
package/lib/bounded-writer.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Per-generation cap. Override with `LENSMCP_EVENT_MAX_BYTES` (default 50 MB); 0/invalid ⇒ default.
|
|
3
|
+
*
|
|
4
|
+
* @deprecated Use `busCapsFromEnv(env).maxBytes` from `@lensmcp/core/bus-rotation`.
|
|
3
5
|
*/
|
|
4
6
|
export declare function eventMaxBytes(env?: NodeJS.ProcessEnv): number;
|
|
5
7
|
/**
|
|
6
8
|
* Rotated generations kept as history (`.1` … `.N`, newest → oldest). With the live file that bounds
|
|
7
9
|
* a workspace to (N+1) × the cap — ~300 MB at defaults. Override with `LENSMCP_EVENT_MAX_FILES`.
|
|
10
|
+
*
|
|
11
|
+
* @deprecated Use `busCapsFromEnv(env).maxFiles` from `@lensmcp/core/bus-rotation`.
|
|
8
12
|
*/
|
|
9
13
|
export declare function eventMaxFiles(env?: NodeJS.ProcessEnv): number;
|
|
10
14
|
/**
|
|
@@ -17,10 +21,19 @@ export declare function eventMaxFiles(env?: NodeJS.ProcessEnv): number;
|
|
|
17
21
|
*
|
|
18
22
|
* `caps` exists for tests, and passing it also bypasses the throttle so a test need not append a
|
|
19
23
|
* megabyte to observe a rotation.
|
|
24
|
+
*
|
|
25
|
+
* @deprecated Use `createBusRotator(file, opts)` from `@lensmcp/core/bus-rotation`: this cascade
|
|
26
|
+
* ignores the `O_EXCL` rotation lock every LensMCP writer takes, so beside a live writer it can
|
|
27
|
+
* reorder or drop history generations (issues/closed/foodguard-42).
|
|
20
28
|
*/
|
|
21
29
|
export declare function maybeRotateEventFile(file: string, addedBytes: number, caps?: {
|
|
22
30
|
maxBytes?: number;
|
|
23
31
|
maxFiles?: number;
|
|
24
32
|
}): void;
|
|
25
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Test seam: forget the throttle state for a path (or all paths).
|
|
35
|
+
*
|
|
36
|
+
* @deprecated With `createBusRotator` from `@lensmcp/core/bus-rotation` each rotator holds its own
|
|
37
|
+
* throttle — make a new one instead.
|
|
38
|
+
*/
|
|
26
39
|
export declare function resetRotationThrottle(file?: string): void;
|
package/lib/capture-demand.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ export interface CaptureRequest {
|
|
|
67
67
|
* reducer heard it. The reducer listed the rule and counted it ("1 rule
|
|
68
68
|
* registered"); the runner — the only process that RUNS rules — never learned
|
|
69
69
|
* it existed. So a registered rule could not produce a violation, and "0
|
|
70
|
-
* violations" read as a pass (issues/foodguard
|
|
70
|
+
* violations" read as a pass (issues/closed/foodguard-27).
|
|
71
71
|
*
|
|
72
72
|
* Same cure: the MCP server writes the registered rules here and the runner
|
|
73
73
|
* reads them before each capture.
|
package/lib/dashboard.d.ts
CHANGED
|
@@ -137,6 +137,33 @@ export interface DashService {
|
|
|
137
137
|
at: number;
|
|
138
138
|
title: string;
|
|
139
139
|
};
|
|
140
|
+
/** What its running pods weigh, from their own post-GC reports (`pod-memory` events). Absent until one reports. */
|
|
141
|
+
memory?: DashServiceMemory;
|
|
142
|
+
}
|
|
143
|
+
/** A service's pods, summed: what the Cluster tab's memory column shows. Bytes throughout. */
|
|
144
|
+
export interface DashServiceMemory {
|
|
145
|
+
/** Heap after each pod's latest full GC. */
|
|
146
|
+
live: number;
|
|
147
|
+
/** Heap V8 holds reserved. */
|
|
148
|
+
reserved: number;
|
|
149
|
+
rss: number;
|
|
150
|
+
/** The boot baseline (the largest of the pods'). */
|
|
151
|
+
baseline?: number;
|
|
152
|
+
/** Hot swaps (the most any pod has done). */
|
|
153
|
+
swaps: number;
|
|
154
|
+
/** Pods that have reported. */
|
|
155
|
+
pods: number;
|
|
156
|
+
/** Closed generations proven still in memory — a leak, not garbage. */
|
|
157
|
+
retained: Array<{
|
|
158
|
+
pod: number;
|
|
159
|
+
gen: number;
|
|
160
|
+
ageMs: number;
|
|
161
|
+
}>;
|
|
162
|
+
/** The latest report. */
|
|
163
|
+
at: number;
|
|
164
|
+
trigger: string;
|
|
165
|
+
/** The cluster service name the pods report under — what `lensmcp mem <service>` takes. */
|
|
166
|
+
service?: string;
|
|
140
167
|
}
|
|
141
168
|
export interface DashRoute {
|
|
142
169
|
host: string;
|
|
@@ -427,7 +454,9 @@ export interface DashLogsFrame {
|
|
|
427
454
|
lines: DashLogLine[];
|
|
428
455
|
}
|
|
429
456
|
export type DashProblemSeverity = 'high' | 'medium' | 'low';
|
|
430
|
-
export type DashProblemKind = 'n-plus-one' | 'db-in-loop' | 'render-storm' | 'slow-path' | 'slow-route' | 'slow-query' | 'missing-index' | 'leak' | 'server-error' | 'browser-error' | 'failed-span' | 'egress-failing' | 'egress-slow' | 'duplicate-requests' | 'build' | 'typecheck' | 'lint' | 'service'
|
|
457
|
+
export type DashProblemKind = 'n-plus-one' | 'db-in-loop' | 'render-storm' | 'slow-path' | 'slow-route' | 'slow-query' | 'missing-index' | 'leak' | 'server-error' | 'browser-error' | 'failed-span' | 'egress-failing' | 'egress-slow' | 'duplicate-requests' | 'build' | 'typecheck' | 'lint' | 'service'
|
|
458
|
+
/** A performance rule's finding (`perf://rules`): build or memory cost, with its fix and how to verify it. */
|
|
459
|
+
| 'perf-rule' | 'other';
|
|
431
460
|
export interface DashProblem {
|
|
432
461
|
/** Stable across updates — the card's identity for the resolved-lifecycle. */
|
|
433
462
|
id: string;
|
|
@@ -441,6 +470,10 @@ export interface DashProblem {
|
|
|
441
470
|
detail?: string;
|
|
442
471
|
/** What to do — only when the detector itself knows; never invented. */
|
|
443
472
|
fix?: string;
|
|
473
|
+
/** How to prove the fix worked — only when the detector says (performance rules). */
|
|
474
|
+
verify?: string;
|
|
475
|
+
/** Where the detector's rule is documented. */
|
|
476
|
+
docs?: string;
|
|
444
477
|
/** The concrete artefact: the SQL, the stack's first frames, the failing URL. */
|
|
445
478
|
code?: string;
|
|
446
479
|
/** How many times it happened, when the detector counts. */
|
package/lib/flood-guard.d.ts
CHANGED
|
@@ -28,5 +28,13 @@ export interface FloodGuardOptions {
|
|
|
28
28
|
perSec?: number;
|
|
29
29
|
/** Max distinct fingerprints tracked before stale buckets are evicted. Default 2048. */
|
|
30
30
|
maxKeys?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Whether `LENSMCP_EVENT_MAX_EPS` may retune (or disable) this guard. Default `true`.
|
|
33
|
+
*
|
|
34
|
+
* That variable is the PER-FINGERPRINT knob. A guard keyed on something else — the bridge's
|
|
35
|
+
* per-connection budget (issues/closed/codex-security-32) — passes `false`, so tuning event grouping
|
|
36
|
+
* cannot silently cap a whole browser tab at 5 events/s, nor `off` disable a connection bound.
|
|
37
|
+
*/
|
|
38
|
+
envOverride?: boolean;
|
|
31
39
|
}
|
|
32
40
|
export declare function createEventFloodGuard(opts?: FloodGuardOptions): FloodGuard;
|
package/lib/flood-guard.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var S=Object.defineProperty;var i=(t,n)=>S(t,"name",{value:n,configurable:!0});var m=Object.defineProperty,u=i((t,n)=>m(t,"name",{value:n,configurable:!0}),"o");function d(){const t=typeof process<"u"?process.env?.LENSMCP_EVENT_MAX_EPS:void 0;if(t===void 0||t==="")return;if(t==="off")return"off";const n=Number(t);if(Number.isFinite(n))return n<=0?"off":n}i(d,"S"),u(d,"envPerSec");export function createEventFloodGuard(t){const n=t?.envOverride===!1?void 0:d();if(n==="off")return{admit:u(()=>({ok:!0,suppressed:0}),"admit")};const l=n??t?.perSec??5,f=Math.max(1,t?.burst??Math.max(30,l*4)),c=t?.maxKeys??2048,r=new Map,p=u(o=>{for(const[s,e]of r)o-e.lastSeenAt>6e4&&r.delete(s);if(r.size>c){const s=[...r.entries()].sort((e,a)=>e[1].lastSeenAt-a[1].lastSeenAt);for(let e=0;e<s.length>>1;e++)r.delete(s[e][0])}},"evictStale");return{admit(o){const s=Date.now();let e=r.get(o);e||(r.size>=c&&p(s),e={tokens:f,lastRefillAt:s,suppressed:0,lastSeenAt:s},r.set(o,e)),e.lastSeenAt=s;const a=s-e.lastRefillAt;if(a>0&&(e.tokens=Math.min(f,e.tokens+a/1e3*l),e.lastRefillAt=s),e.tokens>=1){e.tokens-=1;const v=e.suppressed;return e.suppressed=0,{ok:!0,suppressed:v}}return e.suppressed+=1,{ok:!1,suppressed:0}}}}i(createEventFloodGuard,"createEventFloodGuard"),u(createEventFloodGuard,"createEventFloodGuard");
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance rules — problems that cost memory or compile time, found by a rule with a STABLE id, and handed to a
|
|
3
|
+
* coding agent as something it can act on: the measured evidence, the estimated cost, the FIX (steps it can apply),
|
|
4
|
+
* the VERIFY step (what clears it), and where the rule is documented.
|
|
5
|
+
*
|
|
6
|
+
* The case study behind them is FoodGuard's dev cluster on 2026-10-10: seven NestJS dev pods held 0.65–2.6 GB each
|
|
7
|
+
* and the build side another ~9.4 GB, because every service imported the ROOT barrel of a 905-file shared library,
|
|
8
|
+
* each copy of the app stayed in memory after a hot swap, and the bundle text was kept several times
|
|
9
|
+
* (`docs/lensmcp/concepts/memory-and-build-cost.mdx`).
|
|
10
|
+
*
|
|
11
|
+
* Two kinds of producer:
|
|
12
|
+
* - BUILD rules run where the compilation is (`@lensmcp/cluster`'s dev webpack, `perf/perf-rules-plugin.ts`) and
|
|
13
|
+
* publish `perf-rule-finding` / `perf-rule-retracted` / `perf-rule-scan` events (`source: 'perf'`,
|
|
14
|
+
* `category: 'performance'`). The cluster MIRRORS these shapes (it does not depend on this package); a parity
|
|
15
|
+
* fixture pins both sides.
|
|
16
|
+
* - POD rules are evaluated by the lens itself (`apps/agent`'s `PerfRuleBook`) from the pods' own `pod-memory*`
|
|
17
|
+
* events, which ARE the bus evidence; their verdicts are published on the lens session's bus in the same shape.
|
|
18
|
+
*
|
|
19
|
+
* The FINGERPRINT is the flood bucket (burst 30, then 5/s) — `perf-rule:<rule>:<project>:<subject>` for a finding
|
|
20
|
+
* and its retraction, `perf-rule-scan:<rule>:<project>` for the scan that says which subjects are open. Coarse on
|
|
21
|
+
* purpose; identity and evidence live in `raw`.
|
|
22
|
+
*
|
|
23
|
+
* Additive only.
|
|
24
|
+
*/
|
|
25
|
+
export declare const PERF_RULE_IDS: readonly ["bundle/heavy-barrel-import", "pod/heap-budget", "pod/retained-generation"];
|
|
26
|
+
export type PerfRuleId = (typeof PERF_RULE_IDS)[number];
|
|
27
|
+
export declare const PERF_RULE_EVENT_KINDS: readonly ["perf-rule-finding", "perf-rule-retracted", "perf-rule-scan"];
|
|
28
|
+
export type PerfRuleEventKind = (typeof PERF_RULE_EVENT_KINDS)[number];
|
|
29
|
+
/** The page that documents every rule: the case study, the thresholds, and how to prevent each problem. */
|
|
30
|
+
export declare const PERF_RULES_DOC = "https://github.com/kiwiapps-ltd/lensmcp/blob/main/docs/lensmcp/concepts/memory-and-build-cost.mdx";
|
|
31
|
+
/** Each rule's section of {@link PERF_RULES_DOC}. */
|
|
32
|
+
export declare const PERF_RULE_DOCS: Readonly<Record<PerfRuleId, string>>;
|
|
33
|
+
/** A finding's estimated cost. Every field is optional: a rule states only what it measured or can estimate. */
|
|
34
|
+
export interface PerfRuleCost {
|
|
35
|
+
/** Modules compiled that nothing needs. */
|
|
36
|
+
modules?: number;
|
|
37
|
+
/** Bytes — of those modules, or of heap. */
|
|
38
|
+
bytes?: number;
|
|
39
|
+
/** Compile time they add, ms (estimated). */
|
|
40
|
+
compileMs?: number;
|
|
41
|
+
/** Memory they cost, MB (estimated). */
|
|
42
|
+
memoryMb?: number;
|
|
43
|
+
/** How the estimate was made — so nobody mistakes it for a measurement. */
|
|
44
|
+
basis?: string;
|
|
45
|
+
}
|
|
46
|
+
/** What every perf-rule event names. */
|
|
47
|
+
export interface PerfRuleIdentityRaw {
|
|
48
|
+
/** A rule id (`bundle/heavy-barrel-import`). Unknown ids from a newer producer are kept, not dropped. */
|
|
49
|
+
rule: string;
|
|
50
|
+
/** The Nx project the finding is about. */
|
|
51
|
+
project: string;
|
|
52
|
+
/** What inside the project: a library (`@org/contracts`), a service. */
|
|
53
|
+
subject: string;
|
|
54
|
+
/** Events of this bucket the flood guard dropped since the last admitted one. */
|
|
55
|
+
floodSuppressed?: number;
|
|
56
|
+
}
|
|
57
|
+
/** A rule fired (`raw.kind: 'perf-rule-finding'`). Re-published while it holds; the newest wins. */
|
|
58
|
+
export interface PerfRuleFindingRaw extends PerfRuleIdentityRaw {
|
|
59
|
+
kind: 'perf-rule-finding';
|
|
60
|
+
severity: 'warning' | 'error';
|
|
61
|
+
/** One line: what is wrong. */
|
|
62
|
+
title: string;
|
|
63
|
+
/** One or two sentences: what was measured and why it costs. */
|
|
64
|
+
summary: string;
|
|
65
|
+
/** The measurement behind it — counts, files, symbols — rule-specific. */
|
|
66
|
+
evidence: Record<string, unknown>;
|
|
67
|
+
cost: PerfRuleCost;
|
|
68
|
+
/** Steps an agent can apply, in order. */
|
|
69
|
+
fix: string[];
|
|
70
|
+
/** What to do to prove the fix, and what clears the finding. */
|
|
71
|
+
verify: string;
|
|
72
|
+
/** Where the rule is documented. */
|
|
73
|
+
docs: string;
|
|
74
|
+
detectedAt: number;
|
|
75
|
+
}
|
|
76
|
+
/** The condition cleared (`raw.kind: 'perf-rule-retracted'`). Same fingerprint as the finding it retracts. */
|
|
77
|
+
export interface PerfRuleRetractedRaw extends PerfRuleIdentityRaw {
|
|
78
|
+
kind: 'perf-rule-retracted';
|
|
79
|
+
/** Why: `cleared` (a newer measurement no longer shows it), `pod-exited`, `released`, … */
|
|
80
|
+
reason: string;
|
|
81
|
+
at: number;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* A completed scan of one rule over one project (`raw.kind: 'perf-rule-scan'`): the subjects open NOW. Any finding of
|
|
85
|
+
* that rule and project not listed is gone — which is how a finding published by a producer that has since restarted
|
|
86
|
+
* (and so never retracts it) still clears.
|
|
87
|
+
*/
|
|
88
|
+
export interface PerfRuleScanRaw {
|
|
89
|
+
kind: 'perf-rule-scan';
|
|
90
|
+
rule: string;
|
|
91
|
+
project: string;
|
|
92
|
+
open: string[];
|
|
93
|
+
at: number;
|
|
94
|
+
/** What the analysis behind this scan took, in ms (all the projects it covered). */
|
|
95
|
+
elapsedMs?: number;
|
|
96
|
+
floodSuppressed?: number;
|
|
97
|
+
}
|
|
98
|
+
export type PerfRuleRaw = PerfRuleFindingRaw | PerfRuleRetractedRaw | PerfRuleScanRaw;
|
|
99
|
+
/** The bucket of a finding and of its retraction. */
|
|
100
|
+
export declare function perfRuleFingerprint(rule: string, project: string, subject: string): string;
|
|
101
|
+
/** The bucket of a rule's scans of one project. */
|
|
102
|
+
export declare function perfRuleScanFingerprint(rule: string, project: string): string;
|
|
103
|
+
/** A perf-rule event's `raw`, checked just enough to be read safely (telemetry is only partly trusted). */
|
|
104
|
+
export declare function asPerfRuleRaw(raw: unknown): PerfRuleRaw | undefined;
|
|
105
|
+
/** One open finding, as `perf://rules` lists it. */
|
|
106
|
+
export interface PerfRuleFindingView {
|
|
107
|
+
rule: string;
|
|
108
|
+
project: string;
|
|
109
|
+
subject: string;
|
|
110
|
+
severity: 'warning' | 'error';
|
|
111
|
+
title: string;
|
|
112
|
+
summary: string;
|
|
113
|
+
evidence: Record<string, unknown>;
|
|
114
|
+
cost: PerfRuleCost;
|
|
115
|
+
fix: string[];
|
|
116
|
+
verify: string;
|
|
117
|
+
docs: string;
|
|
118
|
+
/** When this finding first opened (this lens session). */
|
|
119
|
+
firstSeenAt: number;
|
|
120
|
+
/** The newest measurement that still showed it. */
|
|
121
|
+
lastSeenAt: number;
|
|
122
|
+
}
|
|
123
|
+
/** `perf://rules` — every open performance finding, newest measurement first within each severity. */
|
|
124
|
+
export interface PerfRulesReport {
|
|
125
|
+
schemaVersion: number;
|
|
126
|
+
revision: number;
|
|
127
|
+
updatedAt: string;
|
|
128
|
+
/** `connected` once any rule has reported (a finding, a retraction, a scan, or a pod reading it evaluated). */
|
|
129
|
+
producer: 'connected' | 'none';
|
|
130
|
+
/** One sentence: what is open, or why nothing is known. */
|
|
131
|
+
detail: string;
|
|
132
|
+
findings: PerfRuleFindingView[];
|
|
133
|
+
/** Open findings per rule id. */
|
|
134
|
+
counts: Record<string, number>;
|
|
135
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var u=Object.defineProperty;var o=(r,e)=>u(r,"name",{value:e,configurable:!0});var c=Object.defineProperty,a=o((r,e)=>c(r,"name",{value:e,configurable:!0}),"o");export const PERF_RULE_IDS=["bundle/heavy-barrel-import","pod/heap-budget","pod/retained-generation"],PERF_RULE_EVENT_KINDS=["perf-rule-finding","perf-rule-retracted","perf-rule-scan"],PERF_RULES_DOC="https://github.com/kiwiapps-ltd/lensmcp/blob/main/docs/lensmcp/concepts/memory-and-build-cost.mdx",PERF_RULE_DOCS={"bundle/heavy-barrel-import":`${PERF_RULES_DOC}#bundleheavy-barrel-import`,"pod/heap-budget":`${PERF_RULES_DOC}#podheap-budget`,"pod/retained-generation":`${PERF_RULES_DOC}#podretained-generation`};export function perfRuleFingerprint(r,e,n){return`perf-rule:${r}:${e}:${n}`}o(perfRuleFingerprint,"perfRuleFingerprint"),a(perfRuleFingerprint,"perfRuleFingerprint");export function perfRuleScanFingerprint(r,e){return`perf-rule-scan:${r}:${e}`}o(perfRuleScanFingerprint,"perfRuleScanFingerprint"),a(perfRuleScanFingerprint,"perfRuleScanFingerprint");const s=/^[a-z][a-z0-9-]*\/[a-z0-9][a-z0-9-]*$/,l=12,f=4e3,t=a((r,e=f)=>typeof r=="string"&&r.length>0&&r.length<=e,"isText");export function asPerfRuleRaw(r){if(!r||typeof r!="object")return;const e=r;if(!PERF_RULE_EVENT_KINDS.includes(e.kind)||typeof e.rule!="string"||!s.test(e.rule)||!t(e.project,512))return;if(e.kind==="perf-rule-scan"){const i=e.open;return!Array.isArray(i)||i.length>256||!i.every(p=>t(p,512))?void 0:r}if(!t(e.subject,512))return;if(e.kind==="perf-rule-retracted")return r;if(e.severity!=="warning"&&e.severity!=="error"||!t(e.title)||!t(e.summary)||!t(e.verify)||!t(e.docs,1024))return;const n=e.fix;if(!(!Array.isArray(n)||n.length===0||n.length>l||!n.every(i=>t(i)))&&!(!e.evidence||typeof e.evidence!="object"||Array.isArray(e.evidence))&&!(!e.cost||typeof e.cost!="object"||Array.isArray(e.cost)))return r}o(asPerfRuleRaw,"asPerfRuleRaw"),a(asPerfRuleRaw,"asPerfRuleRaw");
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pod memory events — what a dev-cluster pod reports about its own V8 heap (issues/closed/pod-memory-01, pod-memory-02).
|
|
3
|
+
*
|
|
4
|
+
* The devserver parent (`@lensmcp/cluster`'s `main.devserver.ts`) publishes them on the bus as `source: 'memory'`,
|
|
5
|
+
* `category: 'memory'` events whose `raw.kind` is one of {@link POD_MEMORY_KINDS}; `apps/memory` folds them into
|
|
6
|
+
* `memory://pods` and `memory://leaks/suspected`, the dashboard's cluster tab into a memory column.
|
|
7
|
+
*
|
|
8
|
+
* The FINGERPRINT is the flood bucket (burst 30, then 5/s): `pod-memory:<project>` for readings and exits,
|
|
9
|
+
* `pod-memory-retained:<project>` for retention verdicts and their retractions — one per service, never per pod
|
|
10
|
+
* or generation. Identity lives here, in `raw`.
|
|
11
|
+
*
|
|
12
|
+
* `@lensmcp/cluster` does not depend on this package and MIRRORS these shapes (`pod-memory.ts`,
|
|
13
|
+
* `pod-memory-events.ts`); a parity fixture pins both sides. Additive only.
|
|
14
|
+
*/
|
|
15
|
+
export declare const POD_MEMORY_KINDS: readonly ["pod-memory", "pod-memory-retained", "pod-memory-released", "pod-memory-exited"];
|
|
16
|
+
export type PodMemoryKind = (typeof POD_MEMORY_KINDS)[number];
|
|
17
|
+
/** Who reported: stamped on every pod-memory event. */
|
|
18
|
+
export interface PodMemoryIdentityRaw {
|
|
19
|
+
/** The Nx project (`LENSMCP_PROJECT`). */
|
|
20
|
+
project: string;
|
|
21
|
+
/** The cluster service name — what `lensmcp mem <service>` takes. */
|
|
22
|
+
service: string;
|
|
23
|
+
/** The devserver's pod id (`Child#<pod>`). */
|
|
24
|
+
pod: number;
|
|
25
|
+
pid: number;
|
|
26
|
+
/** The pod-tree generation of a rolling recycle (1 normally). */
|
|
27
|
+
podGeneration: number;
|
|
28
|
+
/** Events of this bucket the flood guard dropped since the last admitted one. */
|
|
29
|
+
floodSuppressed?: number;
|
|
30
|
+
}
|
|
31
|
+
/** What made the pod collect: `boot`, `swap-settled`, `swap+<delay>` (`swap+30s`), `idle`, `retention-check`. */
|
|
32
|
+
export type PodMemoryTrigger = string;
|
|
33
|
+
/** One post-GC reading (`raw.kind: 'pod-memory'`). Bytes throughout. */
|
|
34
|
+
export interface PodMemoryReportRaw extends PodMemoryIdentityRaw {
|
|
35
|
+
kind: 'pod-memory';
|
|
36
|
+
trigger: PodMemoryTrigger;
|
|
37
|
+
at: number;
|
|
38
|
+
/** The app generation serving (1 = the one the pod booted with). */
|
|
39
|
+
gen: number;
|
|
40
|
+
/** Hot swaps since boot. */
|
|
41
|
+
swaps: number;
|
|
42
|
+
/** Heap in use after a full GC. */
|
|
43
|
+
live: number;
|
|
44
|
+
/** Heap in use just before it — garbage included. */
|
|
45
|
+
used: number;
|
|
46
|
+
/** Heap V8 holds reserved after the GC (`heapTotal`). */
|
|
47
|
+
reserved: number;
|
|
48
|
+
rss: number;
|
|
49
|
+
external: number;
|
|
50
|
+
/** The young generation's reserved size. */
|
|
51
|
+
youngGen: number;
|
|
52
|
+
/** V8's heap limit. */
|
|
53
|
+
limit: number;
|
|
54
|
+
/** Live heap right after the first app was built. Absent on the boot report itself (its `live` is it). */
|
|
55
|
+
baseline?: number;
|
|
56
|
+
/** How long the collection paused the pod, ms. */
|
|
57
|
+
gcMs: number;
|
|
58
|
+
/** The generation the latest swap replaced. */
|
|
59
|
+
previousGen?: number;
|
|
60
|
+
/** Is it still in memory? `null` when there is none. */
|
|
61
|
+
previousAlive: boolean | null;
|
|
62
|
+
/** Closed generations still in memory, whatever their age. */
|
|
63
|
+
closedAlive: number;
|
|
64
|
+
/** Of them, the ones past the retained bound. */
|
|
65
|
+
retained: number;
|
|
66
|
+
/** Live `NestContainer` instances, when Node could count them. */
|
|
67
|
+
containers?: number;
|
|
68
|
+
/** Whether the pod maps stack traces through source maps. */
|
|
69
|
+
sourceMaps: boolean;
|
|
70
|
+
}
|
|
71
|
+
/** A closed generation proven still in memory (`raw.kind: 'pod-memory-retained'`). */
|
|
72
|
+
export interface PodMemoryRetainedRaw extends PodMemoryIdentityRaw {
|
|
73
|
+
kind: 'pod-memory-retained';
|
|
74
|
+
gen: number;
|
|
75
|
+
closedAt: number;
|
|
76
|
+
ageMs: number;
|
|
77
|
+
swapsSinceClose: number;
|
|
78
|
+
/** Full GCs it survived. */
|
|
79
|
+
gcs: number;
|
|
80
|
+
/** Which of its registered objects are still alive: `module`, `app`, `nestApp`, `container`, `rootModule`. */
|
|
81
|
+
alive: string[];
|
|
82
|
+
/** Live instances of the shared classes a swapped app leaks through (`NestContainer`, `ZodObject`, …). */
|
|
83
|
+
counts?: Record<string, number>;
|
|
84
|
+
/** Heap in use after the GC that proved it. */
|
|
85
|
+
live: number;
|
|
86
|
+
}
|
|
87
|
+
/** The retraction: a generation reported retained is gone (`raw.kind: 'pod-memory-released'`). */
|
|
88
|
+
export interface PodMemoryReleasedRaw extends PodMemoryIdentityRaw {
|
|
89
|
+
kind: 'pod-memory-released';
|
|
90
|
+
gen: number;
|
|
91
|
+
closedAt: number;
|
|
92
|
+
ageMs: number;
|
|
93
|
+
/** Collected after all, or gone with its pod. */
|
|
94
|
+
reason: 'collected' | 'pod-exited';
|
|
95
|
+
}
|
|
96
|
+
/** The pod process is gone (`raw.kind: 'pod-memory-exited'`) — drop it. */
|
|
97
|
+
export interface PodMemoryExitedRaw extends PodMemoryIdentityRaw {
|
|
98
|
+
kind: 'pod-memory-exited';
|
|
99
|
+
code: number | null;
|
|
100
|
+
signal: string | null;
|
|
101
|
+
}
|
|
102
|
+
export type PodMemoryRaw = PodMemoryReportRaw | PodMemoryRetainedRaw | PodMemoryReleasedRaw | PodMemoryExitedRaw;
|
|
103
|
+
/** A pod-memory event's `raw`, checked just enough to be read safely (telemetry is only partly trusted). */
|
|
104
|
+
export declare function asPodMemoryRaw(raw: unknown): PodMemoryRaw | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=Object.defineProperty;var r=(o,e)=>t(o,"name",{value:e,configurable:!0});var d=Object.defineProperty,m=r((o,e)=>d(o,"name",{value:e,configurable:!0}),"r");export const POD_MEMORY_KINDS=["pod-memory","pod-memory-retained","pod-memory-released","pod-memory-exited"];export function asPodMemoryRaw(o){if(!o||typeof o!="object")return;const e=o;if(POD_MEMORY_KINDS.includes(e.kind)&&!(typeof e.project!="string"||!e.project)&&!(typeof e.pod!="number"||typeof e.pid!="number")&&!(e.kind==="pod-memory"&&(typeof e.live!="number"||!Number.isFinite(e.live)))&&!((e.kind==="pod-memory-retained"||e.kind==="pod-memory-released")&&typeof e.gen!="number"))return o}r(asPodMemoryRaw,"asPodMemoryRaw"),m(asPodMemoryRaw,"asPodMemoryRaw");
|
package/lib/resources.d.ts
CHANGED
|
@@ -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
|
-
|
|
16
|
+
starting: "starting";
|
|
17
17
|
clean: "clean";
|
|
18
|
+
warning: "warning";
|
|
18
19
|
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";
|
|
26
27
|
debug: "debug";
|
|
27
28
|
info: "info";
|
|
28
|
-
warning: "warning";
|
|
29
29
|
fatal: "fatal";
|
|
30
30
|
}>;
|
|
31
31
|
title: z.ZodString;
|
|
@@ -41,41 +41,45 @@ export declare const AgentBlockingItemSchema: z.ZodObject<{
|
|
|
41
41
|
componentName: z.ZodOptional<z.ZodString>;
|
|
42
42
|
hookName: z.ZodOptional<z.ZodString>;
|
|
43
43
|
}, z.core.$strip>>;
|
|
44
|
+
rule: z.ZodOptional<z.ZodString>;
|
|
45
|
+
fix: z.ZodOptional<z.ZodString>;
|
|
46
|
+
verify: z.ZodOptional<z.ZodString>;
|
|
47
|
+
docs: z.ZodOptional<z.ZodString>;
|
|
44
48
|
}, z.core.$strip>;
|
|
45
49
|
export type AgentBlockingItem = z.infer<typeof AgentBlockingItemSchema>;
|
|
46
50
|
export declare const AgentChecksSchema: z.ZodObject<{
|
|
47
51
|
typecheck: z.ZodOptional<z.ZodEnum<{
|
|
48
|
-
unknown: "unknown";
|
|
49
52
|
passed: "passed";
|
|
50
53
|
failed: "failed";
|
|
54
|
+
unknown: "unknown";
|
|
51
55
|
}>>;
|
|
52
56
|
lint: z.ZodOptional<z.ZodEnum<{
|
|
53
|
-
unknown: "unknown";
|
|
54
57
|
passed: "passed";
|
|
55
58
|
failed: "failed";
|
|
59
|
+
unknown: "unknown";
|
|
56
60
|
}>>;
|
|
57
61
|
build: z.ZodOptional<z.ZodEnum<{
|
|
58
|
-
unknown: "unknown";
|
|
59
62
|
passed: "passed";
|
|
60
63
|
failed: "failed";
|
|
64
|
+
unknown: "unknown";
|
|
61
65
|
}>>;
|
|
62
66
|
runtime: z.ZodOptional<z.ZodEnum<{
|
|
63
67
|
warning: "warning";
|
|
64
|
-
unknown: "unknown";
|
|
65
68
|
passed: "passed";
|
|
66
69
|
failed: "failed";
|
|
70
|
+
unknown: "unknown";
|
|
67
71
|
}>>;
|
|
68
72
|
visual: z.ZodOptional<z.ZodEnum<{
|
|
69
73
|
warning: "warning";
|
|
70
|
-
unknown: "unknown";
|
|
71
74
|
passed: "passed";
|
|
72
75
|
failed: "failed";
|
|
76
|
+
unknown: "unknown";
|
|
73
77
|
}>>;
|
|
74
78
|
memory: z.ZodOptional<z.ZodEnum<{
|
|
75
79
|
warning: "warning";
|
|
76
|
-
unknown: "unknown";
|
|
77
80
|
passed: "passed";
|
|
78
81
|
failed: "failed";
|
|
82
|
+
unknown: "unknown";
|
|
79
83
|
}>>;
|
|
80
84
|
}, z.core.$strip>;
|
|
81
85
|
/**
|
|
@@ -109,10 +113,10 @@ export declare const AgentCurrentStatusSchema: z.ZodObject<{
|
|
|
109
113
|
updatedAt: z.ZodOptional<z.ZodString>;
|
|
110
114
|
sessionId: z.ZodString;
|
|
111
115
|
status: z.ZodEnum<{
|
|
112
|
-
|
|
116
|
+
starting: "starting";
|
|
113
117
|
clean: "clean";
|
|
118
|
+
warning: "warning";
|
|
114
119
|
failing: "failing";
|
|
115
|
-
starting: "starting";
|
|
116
120
|
}>;
|
|
117
121
|
activeTab: z.ZodOptional<z.ZodString>;
|
|
118
122
|
tabsWithIssues: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -120,9 +124,9 @@ export declare const AgentCurrentStatusSchema: z.ZodObject<{
|
|
|
120
124
|
source: z.ZodString;
|
|
121
125
|
severity: z.ZodEnum<{
|
|
122
126
|
error: "error";
|
|
127
|
+
warning: "warning";
|
|
123
128
|
debug: "debug";
|
|
124
129
|
info: "info";
|
|
125
|
-
warning: "warning";
|
|
126
130
|
fatal: "fatal";
|
|
127
131
|
}>;
|
|
128
132
|
title: z.ZodString;
|
|
@@ -138,14 +142,18 @@ export declare const AgentCurrentStatusSchema: z.ZodObject<{
|
|
|
138
142
|
componentName: z.ZodOptional<z.ZodString>;
|
|
139
143
|
hookName: z.ZodOptional<z.ZodString>;
|
|
140
144
|
}, z.core.$strip>>;
|
|
145
|
+
rule: z.ZodOptional<z.ZodString>;
|
|
146
|
+
fix: z.ZodOptional<z.ZodString>;
|
|
147
|
+
verify: z.ZodOptional<z.ZodString>;
|
|
148
|
+
docs: z.ZodOptional<z.ZodString>;
|
|
141
149
|
}, z.core.$strip>>;
|
|
142
150
|
warnings: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
143
151
|
source: z.ZodString;
|
|
144
152
|
severity: z.ZodEnum<{
|
|
145
153
|
error: "error";
|
|
154
|
+
warning: "warning";
|
|
146
155
|
debug: "debug";
|
|
147
156
|
info: "info";
|
|
148
|
-
warning: "warning";
|
|
149
157
|
fatal: "fatal";
|
|
150
158
|
}>;
|
|
151
159
|
title: z.ZodString;
|
|
@@ -161,41 +169,45 @@ export declare const AgentCurrentStatusSchema: z.ZodObject<{
|
|
|
161
169
|
componentName: z.ZodOptional<z.ZodString>;
|
|
162
170
|
hookName: z.ZodOptional<z.ZodString>;
|
|
163
171
|
}, z.core.$strip>>;
|
|
172
|
+
rule: z.ZodOptional<z.ZodString>;
|
|
173
|
+
fix: z.ZodOptional<z.ZodString>;
|
|
174
|
+
verify: z.ZodOptional<z.ZodString>;
|
|
175
|
+
docs: z.ZodOptional<z.ZodString>;
|
|
164
176
|
}, z.core.$strip>>>;
|
|
165
177
|
suggestedReads: z.ZodArray<z.ZodString>;
|
|
166
178
|
checks: z.ZodOptional<z.ZodObject<{
|
|
167
179
|
typecheck: z.ZodOptional<z.ZodEnum<{
|
|
168
|
-
unknown: "unknown";
|
|
169
180
|
passed: "passed";
|
|
170
181
|
failed: "failed";
|
|
182
|
+
unknown: "unknown";
|
|
171
183
|
}>>;
|
|
172
184
|
lint: z.ZodOptional<z.ZodEnum<{
|
|
173
|
-
unknown: "unknown";
|
|
174
185
|
passed: "passed";
|
|
175
186
|
failed: "failed";
|
|
187
|
+
unknown: "unknown";
|
|
176
188
|
}>>;
|
|
177
189
|
build: z.ZodOptional<z.ZodEnum<{
|
|
178
|
-
unknown: "unknown";
|
|
179
190
|
passed: "passed";
|
|
180
191
|
failed: "failed";
|
|
192
|
+
unknown: "unknown";
|
|
181
193
|
}>>;
|
|
182
194
|
runtime: z.ZodOptional<z.ZodEnum<{
|
|
183
195
|
warning: "warning";
|
|
184
|
-
unknown: "unknown";
|
|
185
196
|
passed: "passed";
|
|
186
197
|
failed: "failed";
|
|
198
|
+
unknown: "unknown";
|
|
187
199
|
}>>;
|
|
188
200
|
visual: z.ZodOptional<z.ZodEnum<{
|
|
189
201
|
warning: "warning";
|
|
190
|
-
unknown: "unknown";
|
|
191
202
|
passed: "passed";
|
|
192
203
|
failed: "failed";
|
|
204
|
+
unknown: "unknown";
|
|
193
205
|
}>>;
|
|
194
206
|
memory: z.ZodOptional<z.ZodEnum<{
|
|
195
207
|
warning: "warning";
|
|
196
|
-
unknown: "unknown";
|
|
197
208
|
passed: "passed";
|
|
198
209
|
failed: "failed";
|
|
210
|
+
unknown: "unknown";
|
|
199
211
|
}>>;
|
|
200
212
|
}, z.core.$strip>>;
|
|
201
213
|
server: z.ZodOptional<z.ZodObject<{
|
|
@@ -316,9 +328,9 @@ declare const CheckEntrySchema: z.ZodObject<{
|
|
|
316
328
|
rule: z.ZodOptional<z.ZodString>;
|
|
317
329
|
severity: z.ZodOptional<z.ZodEnum<{
|
|
318
330
|
error: "error";
|
|
331
|
+
warning: "warning";
|
|
319
332
|
debug: "debug";
|
|
320
333
|
info: "info";
|
|
321
|
-
warning: "warning";
|
|
322
334
|
fatal: "fatal";
|
|
323
335
|
}>>;
|
|
324
336
|
file: z.ZodOptional<z.ZodString>;
|
|
@@ -344,9 +356,9 @@ export declare const TypecheckCurrentSchema: z.ZodObject<{
|
|
|
344
356
|
lastReportedAt: z.ZodNumber;
|
|
345
357
|
lastRunStatus: z.ZodEnum<{
|
|
346
358
|
error: "error";
|
|
347
|
-
running: "running";
|
|
348
359
|
clean: "clean";
|
|
349
360
|
failing: "failing";
|
|
361
|
+
running: "running";
|
|
350
362
|
}>;
|
|
351
363
|
lastRunDurationMs: z.ZodOptional<z.ZodNumber>;
|
|
352
364
|
errorCount: z.ZodNumber;
|
|
@@ -358,9 +370,9 @@ export declare const TypecheckCurrentSchema: z.ZodObject<{
|
|
|
358
370
|
stale: z.ZodBoolean;
|
|
359
371
|
detail: z.ZodString;
|
|
360
372
|
status: z.ZodEnum<{
|
|
361
|
-
unknown: "unknown";
|
|
362
373
|
clean: "clean";
|
|
363
374
|
failing: "failing";
|
|
375
|
+
unknown: "unknown";
|
|
364
376
|
}>;
|
|
365
377
|
errorCount: z.ZodNumber;
|
|
366
378
|
lastRunAt: z.ZodOptional<z.ZodNumber>;
|
|
@@ -383,9 +395,9 @@ export declare const TypecheckErrorsSchema: z.ZodObject<{
|
|
|
383
395
|
lastReportedAt: z.ZodNumber;
|
|
384
396
|
lastRunStatus: z.ZodEnum<{
|
|
385
397
|
error: "error";
|
|
386
|
-
running: "running";
|
|
387
398
|
clean: "clean";
|
|
388
399
|
failing: "failing";
|
|
400
|
+
running: "running";
|
|
389
401
|
}>;
|
|
390
402
|
lastRunDurationMs: z.ZodOptional<z.ZodNumber>;
|
|
391
403
|
errorCount: z.ZodNumber;
|
|
@@ -405,9 +417,9 @@ export declare const TypecheckErrorsSchema: z.ZodObject<{
|
|
|
405
417
|
rule: z.ZodOptional<z.ZodString>;
|
|
406
418
|
severity: z.ZodOptional<z.ZodEnum<{
|
|
407
419
|
error: "error";
|
|
420
|
+
warning: "warning";
|
|
408
421
|
debug: "debug";
|
|
409
422
|
info: "info";
|
|
410
|
-
warning: "warning";
|
|
411
423
|
fatal: "fatal";
|
|
412
424
|
}>>;
|
|
413
425
|
file: z.ZodOptional<z.ZodString>;
|
|
@@ -434,9 +446,9 @@ export declare const LintCurrentSchema: z.ZodObject<{
|
|
|
434
446
|
lastReportedAt: z.ZodNumber;
|
|
435
447
|
lastRunStatus: z.ZodEnum<{
|
|
436
448
|
error: "error";
|
|
437
|
-
running: "running";
|
|
438
449
|
clean: "clean";
|
|
439
450
|
failing: "failing";
|
|
451
|
+
running: "running";
|
|
440
452
|
}>;
|
|
441
453
|
lastRunDurationMs: z.ZodOptional<z.ZodNumber>;
|
|
442
454
|
errorCount: z.ZodNumber;
|
|
@@ -448,10 +460,10 @@ export declare const LintCurrentSchema: z.ZodObject<{
|
|
|
448
460
|
stale: z.ZodBoolean;
|
|
449
461
|
detail: z.ZodString;
|
|
450
462
|
status: z.ZodEnum<{
|
|
451
|
-
warning: "warning";
|
|
452
|
-
unknown: "unknown";
|
|
453
463
|
clean: "clean";
|
|
464
|
+
warning: "warning";
|
|
454
465
|
failing: "failing";
|
|
466
|
+
unknown: "unknown";
|
|
455
467
|
}>;
|
|
456
468
|
errorCount: z.ZodNumber;
|
|
457
469
|
warningCount: z.ZodNumber;
|
|
@@ -475,9 +487,9 @@ export declare const BuildCurrentSchema: z.ZodObject<{
|
|
|
475
487
|
lastReportedAt: z.ZodNumber;
|
|
476
488
|
lastRunStatus: z.ZodEnum<{
|
|
477
489
|
error: "error";
|
|
478
|
-
running: "running";
|
|
479
490
|
clean: "clean";
|
|
480
491
|
failing: "failing";
|
|
492
|
+
running: "running";
|
|
481
493
|
}>;
|
|
482
494
|
lastRunDurationMs: z.ZodOptional<z.ZodNumber>;
|
|
483
495
|
errorCount: z.ZodNumber;
|
|
@@ -489,10 +501,10 @@ export declare const BuildCurrentSchema: z.ZodObject<{
|
|
|
489
501
|
stale: z.ZodBoolean;
|
|
490
502
|
detail: z.ZodString;
|
|
491
503
|
status: z.ZodEnum<{
|
|
492
|
-
warning: "warning";
|
|
493
|
-
unknown: "unknown";
|
|
494
504
|
clean: "clean";
|
|
505
|
+
warning: "warning";
|
|
495
506
|
failing: "failing";
|
|
507
|
+
unknown: "unknown";
|
|
496
508
|
}>;
|
|
497
509
|
hmrUpdates: z.ZodNumber;
|
|
498
510
|
lastRunAt: z.ZodOptional<z.ZodNumber>;
|
package/lib/resources.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{z as n}from"zod";import{SCHEMA_VERSION as i}from"./schema-version.js";import{SourceLocationSchema as
|
|
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(),rule:n.string().optional(),fix:n.string().optional(),verify:n.string().optional(),docs:n.string().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(),reducers:n.record(n.string(),n.object({residentEvents:n.number().int().nonnegative(),residentBytes:n.number().int().nonnegative(),evictedEvents:n.number().int().nonnegative(),evictedForBytes:n.number().int().nonnegative(),eventCap:n.number().int().nonnegative(),byteCap: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()});
|