@lensmcp/protocol-types 1.23.3 → 1.23.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -0
- package/index.js +1 -1
- package/lib/ai-content.d.ts +59 -0
- package/lib/ai-content.js +1 -0
- package/lib/dashboard.d.ts +94 -0
- 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";
|
|
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/ai-content.js";
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shape of one captured AI call's conversation — the sidecar file `.lensmcp/ai/<callId>.json`.
|
|
3
|
+
*
|
|
4
|
+
* Types only, so the dashboard UI can name them without pulling in the node-side reader. The writer
|
|
5
|
+
* lives in `@lensmcp/node-instrumentation`, the readers in `@lensmcp/core/ai-content`; see that module
|
|
6
|
+
* for why the conversation is kept off the event bus.
|
|
7
|
+
*/
|
|
8
|
+
export interface AiMessageContent {
|
|
9
|
+
role: string;
|
|
10
|
+
/** Flattened to text. Images and other binary parts are replaced by a `[image]` marker, never inlined. */
|
|
11
|
+
content: string;
|
|
12
|
+
}
|
|
13
|
+
export interface AiToolCallContent {
|
|
14
|
+
id?: string;
|
|
15
|
+
name: string;
|
|
16
|
+
/** The raw JSON string the model produced, redacted and clipped. */
|
|
17
|
+
arguments?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface AiUsageContent {
|
|
20
|
+
promptTokens?: number;
|
|
21
|
+
completionTokens?: number;
|
|
22
|
+
totalTokens?: number;
|
|
23
|
+
cachedTokens?: number;
|
|
24
|
+
reasoningTokens?: number;
|
|
25
|
+
}
|
|
26
|
+
export interface AiCallContent {
|
|
27
|
+
schemaVersion: 1;
|
|
28
|
+
id: string;
|
|
29
|
+
capturedAt: number;
|
|
30
|
+
flowId?: string;
|
|
31
|
+
requestId?: string;
|
|
32
|
+
project?: string;
|
|
33
|
+
provider: string;
|
|
34
|
+
api: string;
|
|
35
|
+
model?: string;
|
|
36
|
+
host: string;
|
|
37
|
+
endpoint: string;
|
|
38
|
+
stream: boolean;
|
|
39
|
+
status?: number;
|
|
40
|
+
request: {
|
|
41
|
+
system?: string;
|
|
42
|
+
messages: AiMessageContent[];
|
|
43
|
+
tools?: Array<{
|
|
44
|
+
name: string;
|
|
45
|
+
description?: string;
|
|
46
|
+
}>;
|
|
47
|
+
params?: Record<string, unknown>;
|
|
48
|
+
};
|
|
49
|
+
response?: {
|
|
50
|
+
completion?: string;
|
|
51
|
+
reasoning?: string;
|
|
52
|
+
toolCalls?: AiToolCallContent[];
|
|
53
|
+
finishReason?: string;
|
|
54
|
+
usage?: AiUsageContent;
|
|
55
|
+
error?: string;
|
|
56
|
+
};
|
|
57
|
+
/** True when any field was clipped to fit the per-call cap — the reader should say so. */
|
|
58
|
+
truncated?: boolean;
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export{};
|
package/lib/dashboard.d.ts
CHANGED
|
@@ -248,7 +248,22 @@ export interface DashFlowSummary {
|
|
|
248
248
|
* still finds a flow that shows it.
|
|
249
249
|
*/
|
|
250
250
|
touches?: string[];
|
|
251
|
+
/** What kind of flow this is: `page-load`, `user-action`, `api`… or one of the workspace's own categories. */
|
|
252
|
+
category?: string;
|
|
253
|
+
/** Where the category sits in the built-in order (`CATEGORY_ORDER` in core); a custom category sorts after every built-in one. */
|
|
254
|
+
categoryRank?: number;
|
|
255
|
+
/** Which layer decided the category: a workspace rule, the test detector, how the flow started, or its shape. */
|
|
256
|
+
decidedBy?: DashCategoryDecision;
|
|
257
|
+
/** What the flow is about, below its category: the templated page, the component, the root route… */
|
|
258
|
+
subject?: string;
|
|
259
|
+
/** Cheap orthogonal facts a person filters on: `fan-out`, `has-error`, `storm`, `slow`… Sorted. */
|
|
260
|
+
tags?: string[];
|
|
261
|
+
/** How many units the flow was cut into, how many phases they fall in, and how many events were signal. */
|
|
262
|
+
segmentCount?: number;
|
|
263
|
+
phaseCount?: number;
|
|
264
|
+
signalCount?: number;
|
|
251
265
|
}
|
|
266
|
+
export type DashCategoryDecision = 'rule' | 'test' | 'origin' | 'shape';
|
|
252
267
|
/**
|
|
253
268
|
* One display node of a flow — the output of `buildFlowDetail` in `@lensmcp/core`. Every field
|
|
254
269
|
* beyond the first block is optional: which appear depends on the event kind and on the folds
|
|
@@ -303,6 +318,76 @@ export interface DashFlowNode {
|
|
|
303
318
|
}>;
|
|
304
319
|
memberIds?: string[];
|
|
305
320
|
selfMs?: number;
|
|
321
|
+
/** The segment this step belongs to (see `DashFlowSegment`). Absent on a flow that was not segmented. */
|
|
322
|
+
segmentId?: string;
|
|
323
|
+
}
|
|
324
|
+
/** What a segment is: one backend call, a burst of UI work, the burst that started the flow, or backend noise. */
|
|
325
|
+
export type DashSegmentKind = 'origin' | 'request' | 'ui' | 'ambient';
|
|
326
|
+
export interface DashSegmentCounts {
|
|
327
|
+
total: number;
|
|
328
|
+
/** Everything that is not registry bookkeeping. */
|
|
329
|
+
signal: number;
|
|
330
|
+
bookkeeping: number;
|
|
331
|
+
errors: number;
|
|
332
|
+
warnings: number;
|
|
333
|
+
}
|
|
334
|
+
/** Which slice of an over-cap unit a segment is: `index` of `total`, 1-based. */
|
|
335
|
+
export interface DashSegmentPart {
|
|
336
|
+
index: number;
|
|
337
|
+
total: number;
|
|
338
|
+
}
|
|
339
|
+
export interface DashFlowSegment {
|
|
340
|
+
/** Stable while the flow grows: `<flowId>~r:<requestId>`, `~u:<firstEventId>`, `~o:…`, `~a:…`; parts add `#n`. */
|
|
341
|
+
id: string;
|
|
342
|
+
kind: DashSegmentKind;
|
|
343
|
+
label: string;
|
|
344
|
+
/** 1-based, in time order: units in the same phase happened in the same burst of activity. */
|
|
345
|
+
phase: number;
|
|
346
|
+
start: number;
|
|
347
|
+
end: number;
|
|
348
|
+
durationMs: number;
|
|
349
|
+
counts: DashSegmentCounts;
|
|
350
|
+
projects: string[];
|
|
351
|
+
/** `METHOD /route` of the request, when there is one. */
|
|
352
|
+
method?: string;
|
|
353
|
+
route?: string;
|
|
354
|
+
requestId?: string;
|
|
355
|
+
/** For a UI burst that followed several fetches: which requests it may belong to. */
|
|
356
|
+
after?: string[];
|
|
357
|
+
/** For a UI burst: what churned most (`ProductTable ×40`), busiest first. */
|
|
358
|
+
hot?: string[];
|
|
359
|
+
part?: DashSegmentPart;
|
|
360
|
+
worstSeverity: 'debug' | 'info' | 'warning' | 'error' | 'fatal';
|
|
361
|
+
/** `api` for a request, `ui` for a burst, `system` for noise — or one of the workspace's own route/project rules. */
|
|
362
|
+
category: string;
|
|
363
|
+
}
|
|
364
|
+
export interface DashFlowPhase {
|
|
365
|
+
index: number;
|
|
366
|
+
start: number;
|
|
367
|
+
end: number;
|
|
368
|
+
segmentIds: string[];
|
|
369
|
+
}
|
|
370
|
+
/** The flow's own origin: what started it, in the same words the flow-origin event used. */
|
|
371
|
+
export interface DashFlowOrigin {
|
|
372
|
+
type?: string;
|
|
373
|
+
nodeId?: string;
|
|
374
|
+
}
|
|
375
|
+
export interface DashFlowClassification {
|
|
376
|
+
category: string;
|
|
377
|
+
decidedBy: DashCategoryDecision;
|
|
378
|
+
/** Index into the workspace's `lensmcp.flows.categories` when `decidedBy` is `rule`. */
|
|
379
|
+
ruleIndex?: number;
|
|
380
|
+
subject?: string;
|
|
381
|
+
tags: string[];
|
|
382
|
+
origin: DashFlowOrigin;
|
|
383
|
+
}
|
|
384
|
+
export interface DashSegmentStats {
|
|
385
|
+
events: number;
|
|
386
|
+
signal: number;
|
|
387
|
+
bookkeeping: number;
|
|
388
|
+
segments: number;
|
|
389
|
+
phases: number;
|
|
390
|
+
largestSegment: number;
|
|
306
391
|
}
|
|
307
392
|
export interface DashFlowDetail {
|
|
308
393
|
flowId: string;
|
|
@@ -311,6 +396,15 @@ export interface DashFlowDetail {
|
|
|
311
396
|
events: DashFlowNode[];
|
|
312
397
|
/** Same counter as `DashFlowSummary.rev` at the time of the read. */
|
|
313
398
|
rev?: number;
|
|
399
|
+
/** The flow cut into units. Always the WHOLE flow's segments, also when `focus` narrows `events`. */
|
|
400
|
+
segments?: DashFlowSegment[];
|
|
401
|
+
phases?: DashFlowPhase[];
|
|
402
|
+
classification?: DashFlowClassification;
|
|
403
|
+
/** segment id → its category (also on each segment; kept as a map for lookups by id). */
|
|
404
|
+
segmentCategories?: Record<string, string>;
|
|
405
|
+
segmentStats?: DashSegmentStats;
|
|
406
|
+
/** Present when the read asked for one segment (`?segment=`): `events` then holds only that segment. */
|
|
407
|
+
focus?: DashFlowSegment;
|
|
314
408
|
}
|
|
315
409
|
export interface DashLogLine {
|
|
316
410
|
seq: number;
|