@lssm/lib.evolution 0.0.0-canary-20251220002821 → 0.0.0-canary-20251220021406
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregator.js","names":[],"sources":["../../../../../observability/dist/intent/aggregator.mjs"],"sourcesContent":["//#region src/intent/aggregator.ts\nconst DEFAULT_WINDOW_MS = 900 * 1e3;\nvar IntentAggregator = class {\n\twindowMs;\n\tsequenceSampleSize;\n\tsamples = [];\n\tconstructor(options = {}) {\n\t\tthis.windowMs = options.windowMs ?? DEFAULT_WINDOW_MS;\n\t\tthis.sequenceSampleSize = options.sequenceSampleSize ?? 1e3;\n\t}\n\tadd(sample) {\n\t\tthis.samples.push(sample);\n\t}\n\tflush(now = /* @__PURE__ */ new Date()) {\n\t\tconst minTimestamp = now.getTime() - this.windowMs;\n\t\tconst windowSamples = this.samples.filter((sample) => sample.timestamp.getTime() >= minTimestamp);\n\t\tthis.samples.length = 0;\n\t\tconst metrics = this.aggregateMetrics(windowSamples);\n\t\tconst sequences = this.buildSequences(windowSamples);\n\t\tconst timestamps = windowSamples.map((sample) => sample.timestamp.getTime());\n\t\treturn {\n\t\t\tmetrics,\n\t\t\tsequences,\n\t\t\tsampleCount: windowSamples.length,\n\t\t\twindowStart: timestamps.length ? new Date(Math.min(...timestamps)) : void 0,\n\t\t\twindowEnd: timestamps.length ? new Date(Math.max(...timestamps)) : void 0\n\t\t};\n\t}\n\taggregateMetrics(samples) {\n\t\tif (!samples.length) return [];\n\t\tconst groups = /* @__PURE__ */ new Map();\n\t\tfor (const sample of samples) {\n\t\t\tconst key = `${sample.operation.name}.v${sample.operation.version}`;\n\t\t\tconst arr = groups.get(key) ?? [];\n\t\t\tarr.push(sample);\n\t\t\tgroups.set(key, arr);\n\t\t}\n\t\treturn [...groups.values()].map((group) => {\n\t\t\tconst durations = group.map((s) => s.durationMs).sort((a, b) => a - b);\n\t\t\tconst errors = group.filter((s) => !s.success);\n\t\t\tconst totalCalls = group.length;\n\t\t\tconst topErrors = errors.reduce((acc, sample) => {\n\t\t\t\tif (!sample.errorCode) return acc;\n\t\t\t\tacc[sample.errorCode] = (acc[sample.errorCode] ?? 0) + 1;\n\t\t\t\treturn acc;\n\t\t\t}, {});\n\t\t\tconst timestamps = group.map((s) => s.timestamp.getTime());\n\t\t\treturn {\n\t\t\t\toperation:
|
|
1
|
+
{"version":3,"file":"aggregator.js","names":[],"sources":["../../../../../observability/dist/intent/aggregator.mjs"],"sourcesContent":["//#region src/intent/aggregator.ts\nconst DEFAULT_WINDOW_MS = 900 * 1e3;\nvar IntentAggregator = class {\n\twindowMs;\n\tsequenceSampleSize;\n\tsamples = [];\n\tconstructor(options = {}) {\n\t\tthis.windowMs = options.windowMs ?? DEFAULT_WINDOW_MS;\n\t\tthis.sequenceSampleSize = options.sequenceSampleSize ?? 1e3;\n\t}\n\tadd(sample) {\n\t\tthis.samples.push(sample);\n\t}\n\tflush(now = /* @__PURE__ */ new Date()) {\n\t\tconst minTimestamp = now.getTime() - this.windowMs;\n\t\tconst windowSamples = this.samples.filter((sample) => sample.timestamp.getTime() >= minTimestamp);\n\t\tthis.samples.length = 0;\n\t\tconst metrics = this.aggregateMetrics(windowSamples);\n\t\tconst sequences = this.buildSequences(windowSamples);\n\t\tconst timestamps = windowSamples.map((sample) => sample.timestamp.getTime());\n\t\treturn {\n\t\t\tmetrics,\n\t\t\tsequences,\n\t\t\tsampleCount: windowSamples.length,\n\t\t\twindowStart: timestamps.length ? new Date(Math.min(...timestamps)) : void 0,\n\t\t\twindowEnd: timestamps.length ? new Date(Math.max(...timestamps)) : void 0\n\t\t};\n\t}\n\taggregateMetrics(samples) {\n\t\tif (!samples.length) return [];\n\t\tconst groups = /* @__PURE__ */ new Map();\n\t\tfor (const sample of samples) {\n\t\t\tconst key = `${sample.operation.name}.v${sample.operation.version}`;\n\t\t\tconst arr = groups.get(key) ?? [];\n\t\t\tarr.push(sample);\n\t\t\tgroups.set(key, arr);\n\t\t}\n\t\treturn [...groups.values()].map((group) => {\n\t\t\tconst first = group[0];\n\t\t\tif (!first) throw new Error(\"Empty group in aggregation\");\n\t\t\tconst durations = group.map((s) => s.durationMs).sort((a, b) => a - b);\n\t\t\tconst errors = group.filter((s) => !s.success);\n\t\t\tconst totalCalls = group.length;\n\t\t\tconst topErrors = errors.reduce((acc, sample) => {\n\t\t\t\tif (!sample.errorCode) return acc;\n\t\t\t\tacc[sample.errorCode] = (acc[sample.errorCode] ?? 0) + 1;\n\t\t\t\treturn acc;\n\t\t\t}, {});\n\t\t\tconst timestamps = group.map((s) => s.timestamp.getTime());\n\t\t\treturn {\n\t\t\t\toperation: first.operation,\n\t\t\t\ttotalCalls,\n\t\t\t\tsuccessRate: (totalCalls - errors.length) / totalCalls,\n\t\t\t\terrorRate: errors.length / totalCalls,\n\t\t\t\taverageLatencyMs: durations.reduce((sum, value) => sum + value, 0) / totalCalls,\n\t\t\t\tp95LatencyMs: percentile(durations, .95),\n\t\t\t\tp99LatencyMs: percentile(durations, .99),\n\t\t\t\tmaxLatencyMs: Math.max(...durations),\n\t\t\t\twindowStart: new Date(Math.min(...timestamps)),\n\t\t\t\twindowEnd: new Date(Math.max(...timestamps)),\n\t\t\t\ttopErrors\n\t\t\t};\n\t\t});\n\t}\n\tbuildSequences(samples) {\n\t\tconst byTrace = /* @__PURE__ */ new Map();\n\t\tfor (const sample of samples.slice(-this.sequenceSampleSize)) {\n\t\t\tif (!sample.traceId) continue;\n\t\t\tconst arr = byTrace.get(sample.traceId) ?? [];\n\t\t\tarr.push(sample);\n\t\t\tbyTrace.set(sample.traceId, arr);\n\t\t}\n\t\tconst sequences = {};\n\t\tfor (const events of byTrace.values()) {\n\t\t\tconst ordered = events.sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime());\n\t\t\tconst steps = ordered.map((event) => event.operation.name);\n\t\t\tif (steps.length < 2) continue;\n\t\t\tconst key = `${steps.join(\">\")}@${ordered[0]?.tenantId ?? \"global\"}`;\n\t\t\tconst existing = sequences[key];\n\t\t\tif (existing) existing.count += 1;\n\t\t\telse sequences[key] = {\n\t\t\t\tsteps,\n\t\t\t\ttenantId: ordered[0]?.tenantId,\n\t\t\t\tcount: 1\n\t\t\t};\n\t\t}\n\t\treturn Object.values(sequences).sort((a, b) => b.count - a.count);\n\t}\n};\nfunction percentile(values, ratio) {\n\tif (!values.length) return 0;\n\tif (values.length === 1) return values[0] ?? 0;\n\treturn values[Math.min(values.length - 1, Math.floor(ratio * values.length))] ?? 0;\n}\n\n//#endregion\nexport { IntentAggregator };\n//# sourceMappingURL=aggregator.mjs.map"],"mappings":";AACA,MAAM,oBAAoB,MAAM"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm/lib.evolution",
|
|
3
|
-
"version": "0.0.0-canary-
|
|
3
|
+
"version": "0.0.0-canary-20251220021406",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"ai": "beta",
|
|
27
27
|
"zod": "^4.1.13",
|
|
28
|
-
"@lssm/lib.ai-agent": "0.0.0-canary-
|
|
29
|
-
"@lssm/lib.contracts": "0.0.0-canary-
|
|
30
|
-
"@lssm/lib.lifecycle": "0.0.0-canary-
|
|
31
|
-
"@lssm/lib.observability": "0.0.0-canary-
|
|
32
|
-
"@lssm/lib.schema": "0.0.0-canary-
|
|
28
|
+
"@lssm/lib.ai-agent": "0.0.0-canary-20251220021406",
|
|
29
|
+
"@lssm/lib.contracts": "0.0.0-canary-20251220021406",
|
|
30
|
+
"@lssm/lib.lifecycle": "0.0.0-canary-20251220021406",
|
|
31
|
+
"@lssm/lib.observability": "0.0.0-canary-20251220021406",
|
|
32
|
+
"@lssm/lib.schema": "0.0.0-canary-20251220021406"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@prisma/client": "7.2.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@lssm/tool.tsdown": "0.0.0-canary-
|
|
39
|
-
"@lssm/tool.typescript": "0.0.0-canary-
|
|
38
|
+
"@lssm/tool.tsdown": "0.0.0-canary-20251220021406",
|
|
39
|
+
"@lssm/tool.typescript": "0.0.0-canary-20251220021406",
|
|
40
40
|
"tsdown": "^0.18.1",
|
|
41
41
|
"typescript": "^5.9.3"
|
|
42
42
|
},
|