@mastra/core 1.18.0-alpha.4 → 1.18.0-alpha.5
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/CHANGELOG.md +23 -0
- package/dist/_types/@internal_core/dist/index.d.ts +502 -29
- package/dist/agent/agent-legacy.d.ts +2 -0
- package/dist/agent/agent-legacy.d.ts.map +1 -1
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/index.cjs +8 -8
- package/dist/agent/index.js +1 -1
- package/dist/{chunk-Z5FE6LBA.js → chunk-27EVOYQC.js} +3 -3
- package/dist/{chunk-Z5FE6LBA.js.map → chunk-27EVOYQC.js.map} +1 -1
- package/dist/{chunk-T3TFXXGP.js → chunk-3CTQJRNS.js} +12 -9
- package/dist/chunk-3CTQJRNS.js.map +1 -0
- package/dist/{chunk-UZ426KMJ.cjs → chunk-4BZRWJBH.cjs} +32 -32
- package/dist/{chunk-UZ426KMJ.cjs.map → chunk-4BZRWJBH.cjs.map} +1 -1
- package/dist/{chunk-LQHNR4L7.js → chunk-4FMKWOPC.js} +3 -3
- package/dist/{chunk-LQHNR4L7.js.map → chunk-4FMKWOPC.js.map} +1 -1
- package/dist/{chunk-CEWIMGYP.js → chunk-5LA5TY63.js} +4 -4
- package/dist/{chunk-CEWIMGYP.js.map → chunk-5LA5TY63.js.map} +1 -1
- package/dist/{chunk-E7LJ7F56.cjs → chunk-7456ZWIM.cjs} +5 -5
- package/dist/{chunk-E7LJ7F56.cjs.map → chunk-7456ZWIM.cjs.map} +1 -1
- package/dist/{chunk-6DDSP6ZE.js → chunk-7IKOVR4F.js} +5 -5
- package/dist/{chunk-6DDSP6ZE.js.map → chunk-7IKOVR4F.js.map} +1 -1
- package/dist/{chunk-B5LIMU4I.js → chunk-AYVJ4EXL.js} +3 -3
- package/dist/{chunk-B5LIMU4I.js.map → chunk-AYVJ4EXL.js.map} +1 -1
- package/dist/{chunk-VYVPUH6H.cjs → chunk-BF7IH4JU.cjs} +189 -35
- package/dist/chunk-BF7IH4JU.cjs.map +1 -0
- package/dist/{chunk-A2FSD2KN.cjs → chunk-BL7DAQXE.cjs} +7 -7
- package/dist/{chunk-A2FSD2KN.cjs.map → chunk-BL7DAQXE.cjs.map} +1 -1
- package/dist/{chunk-5M3CKUAS.cjs → chunk-BZUTYPXP.cjs} +185 -185
- package/dist/{chunk-5M3CKUAS.cjs.map → chunk-BZUTYPXP.cjs.map} +1 -1
- package/dist/{chunk-JYVH24UY.js → chunk-DBHNKGT2.js} +5 -5
- package/dist/{chunk-JYVH24UY.js.map → chunk-DBHNKGT2.js.map} +1 -1
- package/dist/{chunk-4LDFFARO.cjs → chunk-H3DHOME4.cjs} +6 -6
- package/dist/{chunk-4LDFFARO.cjs.map → chunk-H3DHOME4.cjs.map} +1 -1
- package/dist/{chunk-QOFOOVPM.js → chunk-IM6BRUQI.js} +9 -9
- package/dist/{chunk-QOFOOVPM.js.map → chunk-IM6BRUQI.js.map} +1 -1
- package/dist/{chunk-ULPWI6DN.cjs → chunk-INENOZKZ.cjs} +9 -9
- package/dist/{chunk-ULPWI6DN.cjs.map → chunk-INENOZKZ.cjs.map} +1 -1
- package/dist/{chunk-SMWXSQXP.cjs → chunk-JVL4ANDA.cjs} +19 -19
- package/dist/{chunk-SMWXSQXP.cjs.map → chunk-JVL4ANDA.cjs.map} +1 -1
- package/dist/{chunk-IKYWIQB2.cjs → chunk-JWE3L5J2.cjs} +20 -20
- package/dist/{chunk-IKYWIQB2.cjs.map → chunk-JWE3L5J2.cjs.map} +1 -1
- package/dist/{chunk-DJ2RXLO3.js → chunk-K7AE4BHR.js} +4 -4
- package/dist/{chunk-DJ2RXLO3.js.map → chunk-K7AE4BHR.js.map} +1 -1
- package/dist/{chunk-2OZQLYLM.cjs → chunk-KCRQQDEF.cjs} +176 -173
- package/dist/chunk-KCRQQDEF.cjs.map +1 -0
- package/dist/{chunk-QE7OKYS3.js → chunk-KRFGPA2H.js} +174 -36
- package/dist/chunk-KRFGPA2H.js.map +1 -0
- package/dist/{chunk-OJQCLQK7.cjs → chunk-LKZQG2ZZ.cjs} +13 -13
- package/dist/{chunk-OJQCLQK7.cjs.map → chunk-LKZQG2ZZ.cjs.map} +1 -1
- package/dist/{chunk-ERAZTMF6.js → chunk-MJF7NZEF.js} +437 -8
- package/dist/chunk-MJF7NZEF.js.map +1 -0
- package/dist/{chunk-RHQHBU6R.js → chunk-PMWMEK4T.js} +3 -3
- package/dist/{chunk-RHQHBU6R.js.map → chunk-PMWMEK4T.js.map} +1 -1
- package/dist/{chunk-CGDV5YUS.cjs → chunk-V2NQOABM.cjs} +455 -26
- package/dist/chunk-V2NQOABM.cjs.map +1 -0
- package/dist/{chunk-F77BL7Z7.js → chunk-W4I7AX2S.js} +4 -4
- package/dist/{chunk-F77BL7Z7.js.map → chunk-W4I7AX2S.js.map} +1 -1
- package/dist/{chunk-HJVPOP5S.js → chunk-W6QY3O3X.js} +4 -4
- package/dist/{chunk-HJVPOP5S.js.map → chunk-W6QY3O3X.js.map} +1 -1
- package/dist/{chunk-WINCOFML.js → chunk-WNI6ACXE.js} +3 -3
- package/dist/{chunk-WINCOFML.js.map → chunk-WNI6ACXE.js.map} +1 -1
- package/dist/{chunk-2RGBP3A3.cjs → chunk-XC6ZFHUA.cjs} +68 -68
- package/dist/{chunk-2RGBP3A3.cjs.map → chunk-XC6ZFHUA.cjs.map} +1 -1
- package/dist/{chunk-RIUDLIP3.cjs → chunk-XNWKYVLQ.cjs} +3 -3
- package/dist/{chunk-RIUDLIP3.cjs.map → chunk-XNWKYVLQ.cjs.map} +1 -1
- package/dist/{chunk-ATKRXBCX.cjs → chunk-XQRTJIC7.cjs} +9 -9
- package/dist/{chunk-ATKRXBCX.cjs.map → chunk-XQRTJIC7.cjs.map} +1 -1
- package/dist/{chunk-4QLIPOI7.cjs → chunk-XRW4AYLH.cjs} +82 -82
- package/dist/{chunk-4QLIPOI7.cjs.map → chunk-XRW4AYLH.cjs.map} +1 -1
- package/dist/{chunk-GIBIKVUG.js → chunk-YIBYKN6M.js} +7 -7
- package/dist/{chunk-GIBIKVUG.js.map → chunk-YIBYKN6M.js.map} +1 -1
- package/dist/datasets/index.cjs +17 -17
- package/dist/datasets/index.js +2 -2
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +560 -496
- package/dist/evals/index.cjs +23 -23
- package/dist/evals/index.js +3 -3
- package/dist/evals/scoreTraces/index.cjs +7 -7
- package/dist/evals/scoreTraces/index.js +3 -3
- package/dist/harness/index.cjs +7 -7
- package/dist/harness/index.js +5 -5
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/llm/index.cjs +16 -16
- package/dist/llm/index.js +5 -5
- package/dist/loop/index.cjs +14 -14
- package/dist/loop/index.js +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +14 -14
- package/dist/memory/index.js +1 -1
- package/dist/models-dev-5X6CFNIO.cjs +12 -0
- package/dist/{models-dev-THY3NOPF.cjs.map → models-dev-5X6CFNIO.cjs.map} +1 -1
- package/dist/models-dev-NFYFNV6D.js +3 -0
- package/dist/{models-dev-JGKQCSEN.js.map → models-dev-NFYFNV6D.js.map} +1 -1
- package/dist/netlify-EYSCS3HJ.js +3 -0
- package/dist/{netlify-6TILQFDV.js.map → netlify-EYSCS3HJ.js.map} +1 -1
- package/dist/netlify-MZJ7FN5B.cjs +12 -0
- package/dist/{netlify-NL6O2R7M.cjs.map → netlify-MZJ7FN5B.cjs.map} +1 -1
- package/dist/observability/index.cjs +18 -18
- package/dist/observability/index.js +1 -1
- package/dist/observability/types/tracing.d.ts +2 -0
- package/dist/observability/types/tracing.d.ts.map +1 -1
- package/dist/processor-provider/index.cjs +10 -10
- package/dist/processor-provider/index.js +1 -1
- package/dist/processors/index.cjs +44 -44
- package/dist/processors/index.js +1 -1
- package/dist/provider-registry-ODJKK7NU.js +3 -0
- package/dist/{provider-registry-CRD5YYZY.js.map → provider-registry-ODJKK7NU.js.map} +1 -1
- package/dist/provider-registry-YGVNXVGE.cjs +40 -0
- package/dist/{provider-registry-KXOHTVQF.cjs.map → provider-registry-YGVNXVGE.cjs.map} +1 -1
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/storage/constants.cjs +56 -56
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/observability/base.d.ts +10 -2
- package/dist/storage/domains/observability/base.d.ts.map +1 -1
- package/dist/storage/domains/observability/feedback.d.ts +1 -1
- package/dist/storage/domains/observability/feedback.d.ts.map +1 -1
- package/dist/storage/domains/observability/inmemory.d.ts +13 -2
- package/dist/storage/domains/observability/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/observability/scores.d.ts +1 -1
- package/dist/storage/domains/observability/scores.d.ts.map +1 -1
- package/dist/storage/index.cjs +334 -270
- package/dist/storage/index.js +3 -3
- package/dist/stream/index.cjs +8 -8
- package/dist/stream/index.js +1 -1
- package/dist/test-utils/llm-mock.cjs +4 -4
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/utils.cjs +23 -23
- package/dist/utils.js +1 -1
- package/dist/vector/index.cjs +7 -7
- package/dist/vector/index.js +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +24 -24
- package/dist/workflows/index.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-2OZQLYLM.cjs.map +0 -1
- package/dist/chunk-CGDV5YUS.cjs.map +0 -1
- package/dist/chunk-ERAZTMF6.js.map +0 -1
- package/dist/chunk-QE7OKYS3.js.map +0 -1
- package/dist/chunk-T3TFXXGP.js.map +0 -1
- package/dist/chunk-VYVPUH6H.cjs.map +0 -1
- package/dist/models-dev-JGKQCSEN.js +0 -3
- package/dist/models-dev-THY3NOPF.cjs +0 -12
- package/dist/netlify-6TILQFDV.js +0 -3
- package/dist/netlify-NL6O2R7M.cjs +0 -12
- package/dist/provider-registry-CRD5YYZY.js +0 -3
- package/dist/provider-registry-KXOHTVQF.cjs +0 -40
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkANLO4VM2_cjs = require('./chunk-ANLO4VM2.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
4
|
+
var chunk4BZRWJBH_cjs = require('./chunk-4BZRWJBH.cjs');
|
|
5
|
+
var chunkXQRTJIC7_cjs = require('./chunk-XQRTJIC7.cjs');
|
|
6
|
+
var chunkBF7IH4JU_cjs = require('./chunk-BF7IH4JU.cjs');
|
|
7
7
|
var chunk4U7ZLI36_cjs = require('./chunk-4U7ZLI36.cjs');
|
|
8
8
|
var chunkRO47SMI7_cjs = require('./chunk-RO47SMI7.cjs');
|
|
9
9
|
var jsonToZod = require('@mastra/schema-compat/json-to-zod');
|
|
@@ -494,6 +494,38 @@ var ObservabilityStorage = class extends StorageDomain {
|
|
|
494
494
|
text: "This storage provider does not support listing scores"
|
|
495
495
|
});
|
|
496
496
|
}
|
|
497
|
+
async getScoreAggregate(_args) {
|
|
498
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
499
|
+
id: "OBSERVABILITY_STORAGE_GET_SCORE_AGGREGATE_NOT_IMPLEMENTED",
|
|
500
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
501
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
502
|
+
text: "This storage provider does not support score aggregation"
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
async getScoreBreakdown(_args) {
|
|
506
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
507
|
+
id: "OBSERVABILITY_STORAGE_GET_SCORE_BREAKDOWN_NOT_IMPLEMENTED",
|
|
508
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
509
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
510
|
+
text: "This storage provider does not support score breakdown"
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
async getScoreTimeSeries(_args) {
|
|
514
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
515
|
+
id: "OBSERVABILITY_STORAGE_GET_SCORE_TIME_SERIES_NOT_IMPLEMENTED",
|
|
516
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
517
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
518
|
+
text: "This storage provider does not support score time series"
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
async getScorePercentiles(_args) {
|
|
522
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
523
|
+
id: "OBSERVABILITY_STORAGE_GET_SCORE_PERCENTILES_NOT_IMPLEMENTED",
|
|
524
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
525
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
526
|
+
text: "This storage provider does not support score percentiles"
|
|
527
|
+
});
|
|
528
|
+
}
|
|
497
529
|
// ============================================================================
|
|
498
530
|
// Feedback
|
|
499
531
|
// ============================================================================
|
|
@@ -530,6 +562,38 @@ var ObservabilityStorage = class extends StorageDomain {
|
|
|
530
562
|
text: "This storage provider does not support listing feedback"
|
|
531
563
|
});
|
|
532
564
|
}
|
|
565
|
+
async getFeedbackAggregate(_args) {
|
|
566
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
567
|
+
id: "OBSERVABILITY_STORAGE_GET_FEEDBACK_AGGREGATE_NOT_IMPLEMENTED",
|
|
568
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
569
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
570
|
+
text: "This storage provider does not support feedback aggregation"
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
async getFeedbackBreakdown(_args) {
|
|
574
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
575
|
+
id: "OBSERVABILITY_STORAGE_GET_FEEDBACK_BREAKDOWN_NOT_IMPLEMENTED",
|
|
576
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
577
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
578
|
+
text: "This storage provider does not support feedback breakdown"
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
async getFeedbackTimeSeries(_args) {
|
|
582
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
583
|
+
id: "OBSERVABILITY_STORAGE_GET_FEEDBACK_TIME_SERIES_NOT_IMPLEMENTED",
|
|
584
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
585
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
586
|
+
text: "This storage provider does not support feedback time series"
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
async getFeedbackPercentiles(_args) {
|
|
590
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
591
|
+
id: "OBSERVABILITY_STORAGE_GET_FEEDBACK_PERCENTILES_NOT_IMPLEMENTED",
|
|
592
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
593
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
594
|
+
text: "This storage provider does not support feedback percentiles"
|
|
595
|
+
});
|
|
596
|
+
}
|
|
533
597
|
};
|
|
534
598
|
|
|
535
599
|
// src/storage/utils.ts
|
|
@@ -547,7 +611,7 @@ function safelyParseJSON(input) {
|
|
|
547
611
|
}
|
|
548
612
|
function transformRow(row, tableName, options = {}) {
|
|
549
613
|
const { preferredTimestampFields = {}, convertTimestamps = false, nullValuePattern, fieldMappings = {} } = options;
|
|
550
|
-
const tableSchema =
|
|
614
|
+
const tableSchema = chunk4BZRWJBH_cjs.TABLE_SCHEMAS[tableName];
|
|
551
615
|
const result = {};
|
|
552
616
|
for (const [key, columnSchema] of Object.entries(tableSchema)) {
|
|
553
617
|
const sourceKey = fieldMappings[key] ?? key;
|
|
@@ -578,7 +642,7 @@ function transformRow(row, tableName, options = {}) {
|
|
|
578
642
|
return result;
|
|
579
643
|
}
|
|
580
644
|
function transformScoreRow(row, options = {}) {
|
|
581
|
-
return transformRow(row,
|
|
645
|
+
return transformRow(row, chunk4BZRWJBH_cjs.TABLE_SCORERS, options);
|
|
582
646
|
}
|
|
583
647
|
function toUpperSnakeCase(str) {
|
|
584
648
|
return str.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/([A-Z])([A-Z][a-z])/g, "$1_$2").toUpperCase().replace(/[^A-Z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
@@ -830,7 +894,7 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
830
894
|
};
|
|
831
895
|
}
|
|
832
896
|
async listTraces(args) {
|
|
833
|
-
const { filters, pagination, orderBy } =
|
|
897
|
+
const { filters, pagination, orderBy } = chunk4BZRWJBH_cjs.listTracesArgsSchema.parse(args);
|
|
834
898
|
const matchingRootSpans = [];
|
|
835
899
|
for (const [, traceEntry] of this.db.traces) {
|
|
836
900
|
if (!traceEntry.rootSpan) continue;
|
|
@@ -859,7 +923,7 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
859
923
|
const end = start + perPage;
|
|
860
924
|
const paged = matchingRootSpans.slice(start, end);
|
|
861
925
|
return {
|
|
862
|
-
spans:
|
|
926
|
+
spans: chunk4BZRWJBH_cjs.toTraceSpans(paged),
|
|
863
927
|
pagination: { total, page, perPage, hasMore: end < total }
|
|
864
928
|
};
|
|
865
929
|
}
|
|
@@ -1017,7 +1081,7 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1017
1081
|
}
|
|
1018
1082
|
}
|
|
1019
1083
|
async listMetrics(args) {
|
|
1020
|
-
const { filters, pagination, orderBy } =
|
|
1084
|
+
const { filters, pagination, orderBy } = chunkBF7IH4JU_cjs.listMetricsArgsSchema.parse(args);
|
|
1021
1085
|
let matching = this.filterMetrics(filters);
|
|
1022
1086
|
const dir = orderBy.direction === "DESC" ? -1 : 1;
|
|
1023
1087
|
matching.sort((a, b) => dir * (a.timestamp.getTime() - b.timestamp.getTime()));
|
|
@@ -1080,7 +1144,7 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1080
1144
|
return true;
|
|
1081
1145
|
});
|
|
1082
1146
|
}
|
|
1083
|
-
aggregate(values, type) {
|
|
1147
|
+
aggregate(values, type, timestamps) {
|
|
1084
1148
|
if (values.length === 0) return null;
|
|
1085
1149
|
switch (type) {
|
|
1086
1150
|
case "sum":
|
|
@@ -1093,12 +1157,37 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1093
1157
|
return Math.max(...values);
|
|
1094
1158
|
case "count":
|
|
1095
1159
|
return values.length;
|
|
1096
|
-
case "last":
|
|
1097
|
-
|
|
1160
|
+
case "last": {
|
|
1161
|
+
if (!timestamps || timestamps.length !== values.length) {
|
|
1162
|
+
return values[values.length - 1];
|
|
1163
|
+
}
|
|
1164
|
+
let latestIndex = 0;
|
|
1165
|
+
let latestTimestamp = timestamps[0];
|
|
1166
|
+
for (let i = 1; i < timestamps.length; i++) {
|
|
1167
|
+
const timestamp = timestamps[i];
|
|
1168
|
+
if (timestamp >= latestTimestamp) {
|
|
1169
|
+
latestTimestamp = timestamp;
|
|
1170
|
+
latestIndex = i;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
return values[latestIndex];
|
|
1174
|
+
}
|
|
1098
1175
|
default:
|
|
1099
1176
|
return values.reduce((a, b) => a + b, 0);
|
|
1100
1177
|
}
|
|
1101
1178
|
}
|
|
1179
|
+
interpolatePercentile(sortedValues, percentile) {
|
|
1180
|
+
if (sortedValues.length === 0) return 0;
|
|
1181
|
+
const position = percentile * (sortedValues.length - 1);
|
|
1182
|
+
const lowerIndex = Math.floor(position);
|
|
1183
|
+
const upperIndex = Math.ceil(position);
|
|
1184
|
+
const lowerValue = sortedValues[lowerIndex];
|
|
1185
|
+
const upperValue = sortedValues[upperIndex];
|
|
1186
|
+
if (lowerIndex === upperIndex) {
|
|
1187
|
+
return lowerValue;
|
|
1188
|
+
}
|
|
1189
|
+
return lowerValue + (upperValue - lowerValue) * (position - lowerIndex);
|
|
1190
|
+
}
|
|
1102
1191
|
/**
|
|
1103
1192
|
* Cost is returned alongside value-based OLAP results so callers can derive
|
|
1104
1193
|
* token and monetary views from the same filtered scan.
|
|
@@ -1331,7 +1420,7 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1331
1420
|
return { values };
|
|
1332
1421
|
}
|
|
1333
1422
|
async getEntityTypes(_args) {
|
|
1334
|
-
const validTypes = new Set(Object.values(
|
|
1423
|
+
const validTypes = new Set(Object.values(chunkBF7IH4JU_cjs.EntityType));
|
|
1335
1424
|
const typeSet = /* @__PURE__ */ new Set();
|
|
1336
1425
|
for (const [, traceEntry] of this.db.traces) {
|
|
1337
1426
|
for (const span of Object.values(traceEntry.spans)) {
|
|
@@ -1393,7 +1482,7 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1393
1482
|
}
|
|
1394
1483
|
}
|
|
1395
1484
|
async listLogs(args) {
|
|
1396
|
-
const { filters, pagination, orderBy } =
|
|
1485
|
+
const { filters, pagination, orderBy } = chunkBF7IH4JU_cjs.listLogsArgsSchema.parse(args);
|
|
1397
1486
|
let matching = this.db.logRecords.filter((log) => this.logMatchesFilters(log, filters));
|
|
1398
1487
|
const dir = orderBy.direction === "DESC" ? -1 : 1;
|
|
1399
1488
|
matching.sort((a, b) => dir * (a.timestamp.getTime() - b.timestamp.getTime()));
|
|
@@ -1471,7 +1560,7 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1471
1560
|
}
|
|
1472
1561
|
}
|
|
1473
1562
|
async listScores(args) {
|
|
1474
|
-
const { filters, pagination, orderBy } =
|
|
1563
|
+
const { filters, pagination, orderBy } = chunkBF7IH4JU_cjs.listScoresArgsSchema.parse(args);
|
|
1475
1564
|
let matching = this.db.scoreRecords.filter((score) => this.scoreMatchesFilters(score, filters));
|
|
1476
1565
|
const dir = orderBy.direction === "DESC" ? -1 : 1;
|
|
1477
1566
|
if (orderBy.field === "score") {
|
|
@@ -1528,6 +1617,178 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1528
1617
|
}
|
|
1529
1618
|
return true;
|
|
1530
1619
|
}
|
|
1620
|
+
async getScoreAggregate(args) {
|
|
1621
|
+
const filtered = this.db.scoreRecords.filter((score) => this.scoreMatchesFilters(score, args.filters)).filter((score) => score.scorerId === args.scorerId).filter((score) => args.scoreSource ? (score.scoreSource ?? score.source ?? null) === args.scoreSource : true);
|
|
1622
|
+
const value = this.aggregate(
|
|
1623
|
+
filtered.map((score) => score.score),
|
|
1624
|
+
args.aggregation,
|
|
1625
|
+
filtered.map((score) => score.timestamp.getTime())
|
|
1626
|
+
);
|
|
1627
|
+
if (args.comparePeriod && args.filters?.timestamp) {
|
|
1628
|
+
const previousRange = this.getComparisonDateRange(args.comparePeriod, args.filters.timestamp);
|
|
1629
|
+
if (previousRange) {
|
|
1630
|
+
const previousFiltered = this.db.scoreRecords.filter(
|
|
1631
|
+
(score) => this.scoreMatchesFilters(score, {
|
|
1632
|
+
...args.filters ?? {},
|
|
1633
|
+
timestamp: previousRange
|
|
1634
|
+
})
|
|
1635
|
+
).filter((score) => score.scorerId === args.scorerId).filter(
|
|
1636
|
+
(score) => args.scoreSource ? (score.scoreSource ?? score.source ?? null) === args.scoreSource : true
|
|
1637
|
+
);
|
|
1638
|
+
const previousValue = this.aggregate(
|
|
1639
|
+
previousFiltered.map((score) => score.score),
|
|
1640
|
+
args.aggregation,
|
|
1641
|
+
previousFiltered.map((score) => score.timestamp.getTime())
|
|
1642
|
+
);
|
|
1643
|
+
let changePercent = null;
|
|
1644
|
+
if (previousValue !== null && previousValue !== 0 && value !== null) {
|
|
1645
|
+
changePercent = (value - previousValue) / Math.abs(previousValue) * 100;
|
|
1646
|
+
}
|
|
1647
|
+
return { value, previousValue, changePercent };
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
return { value };
|
|
1651
|
+
}
|
|
1652
|
+
async getScoreBreakdown(args) {
|
|
1653
|
+
const filtered = this.db.scoreRecords.filter((score) => this.scoreMatchesFilters(score, args.filters)).filter((score) => score.scorerId === args.scorerId).filter((score) => args.scoreSource ? (score.scoreSource ?? score.source ?? null) === args.scoreSource : true);
|
|
1654
|
+
const groupMap = /* @__PURE__ */ new Map();
|
|
1655
|
+
for (const score of filtered) {
|
|
1656
|
+
const dims = {};
|
|
1657
|
+
for (const col of args.groupBy) {
|
|
1658
|
+
const value = score[col];
|
|
1659
|
+
dims[col] = value === null || value === void 0 ? null : String(value);
|
|
1660
|
+
}
|
|
1661
|
+
const key = JSON.stringify(dims);
|
|
1662
|
+
if (!groupMap.has(key)) groupMap.set(key, []);
|
|
1663
|
+
groupMap.get(key).push(score);
|
|
1664
|
+
}
|
|
1665
|
+
const groups = Array.from(groupMap.entries()).map(([key, records]) => ({
|
|
1666
|
+
dimensions: JSON.parse(key),
|
|
1667
|
+
value: this.aggregate(
|
|
1668
|
+
records.map((record) => record.score),
|
|
1669
|
+
args.aggregation,
|
|
1670
|
+
records.map((record) => record.timestamp.getTime())
|
|
1671
|
+
) ?? 0
|
|
1672
|
+
}));
|
|
1673
|
+
groups.sort((a, b) => b.value - a.value);
|
|
1674
|
+
return { groups };
|
|
1675
|
+
}
|
|
1676
|
+
async getScoreTimeSeries(args) {
|
|
1677
|
+
const filtered = this.db.scoreRecords.filter((score) => this.scoreMatchesFilters(score, args.filters)).filter((score) => score.scorerId === args.scorerId).filter((score) => args.scoreSource ? (score.scoreSource ?? score.source ?? null) === args.scoreSource : true);
|
|
1678
|
+
const intervalMs = this.intervalToMs(args.interval);
|
|
1679
|
+
if (args.groupBy && args.groupBy.length > 0) {
|
|
1680
|
+
const seriesMap = /* @__PURE__ */ new Map();
|
|
1681
|
+
const seriesNames = /* @__PURE__ */ new Map();
|
|
1682
|
+
for (const score of filtered) {
|
|
1683
|
+
const values = args.groupBy.map((col) => score[col] ?? "");
|
|
1684
|
+
const key = JSON.stringify(values);
|
|
1685
|
+
if (!seriesMap.has(key)) seriesMap.set(key, /* @__PURE__ */ new Map());
|
|
1686
|
+
if (!seriesNames.has(key)) {
|
|
1687
|
+
seriesNames.set(
|
|
1688
|
+
key,
|
|
1689
|
+
values.map((value) => value === null || value === void 0 ? "" : String(value)).join("|")
|
|
1690
|
+
);
|
|
1691
|
+
}
|
|
1692
|
+
const bucket = Math.floor(score.timestamp.getTime() / intervalMs) * intervalMs;
|
|
1693
|
+
const bucketMap2 = seriesMap.get(key);
|
|
1694
|
+
if (!bucketMap2.has(bucket)) bucketMap2.set(bucket, []);
|
|
1695
|
+
bucketMap2.get(bucket).push(score);
|
|
1696
|
+
}
|
|
1697
|
+
return {
|
|
1698
|
+
series: Array.from(seriesMap.entries()).map(([key, bucketMap2]) => ({
|
|
1699
|
+
name: seriesNames.get(key),
|
|
1700
|
+
points: Array.from(bucketMap2.entries()).sort(([a], [b]) => a - b).map(([ts, records]) => ({
|
|
1701
|
+
timestamp: new Date(ts),
|
|
1702
|
+
value: this.aggregate(
|
|
1703
|
+
records.map((record) => record.score),
|
|
1704
|
+
args.aggregation,
|
|
1705
|
+
records.map((record) => record.timestamp.getTime())
|
|
1706
|
+
) ?? 0
|
|
1707
|
+
}))
|
|
1708
|
+
}))
|
|
1709
|
+
};
|
|
1710
|
+
}
|
|
1711
|
+
const bucketMap = /* @__PURE__ */ new Map();
|
|
1712
|
+
for (const score of filtered) {
|
|
1713
|
+
const bucket = Math.floor(score.timestamp.getTime() / intervalMs) * intervalMs;
|
|
1714
|
+
if (!bucketMap.has(bucket)) bucketMap.set(bucket, []);
|
|
1715
|
+
bucketMap.get(bucket).push(score);
|
|
1716
|
+
}
|
|
1717
|
+
return {
|
|
1718
|
+
series: [
|
|
1719
|
+
{
|
|
1720
|
+
name: args.scoreSource ? `${args.scorerId}|${args.scoreSource}` : args.scorerId,
|
|
1721
|
+
points: Array.from(bucketMap.entries()).sort(([a], [b]) => a - b).map(([ts, records]) => ({
|
|
1722
|
+
timestamp: new Date(ts),
|
|
1723
|
+
value: this.aggregate(
|
|
1724
|
+
records.map((record) => record.score),
|
|
1725
|
+
args.aggregation,
|
|
1726
|
+
records.map((record) => record.timestamp.getTime())
|
|
1727
|
+
) ?? 0
|
|
1728
|
+
}))
|
|
1729
|
+
}
|
|
1730
|
+
]
|
|
1731
|
+
};
|
|
1732
|
+
}
|
|
1733
|
+
async getScorePercentiles(args) {
|
|
1734
|
+
const filtered = this.db.scoreRecords.filter((score) => this.scoreMatchesFilters(score, args.filters)).filter((score) => score.scorerId === args.scorerId).filter((score) => args.scoreSource ? (score.scoreSource ?? score.source ?? null) === args.scoreSource : true);
|
|
1735
|
+
const intervalMs = this.intervalToMs(args.interval);
|
|
1736
|
+
const bucketMap = /* @__PURE__ */ new Map();
|
|
1737
|
+
for (const score of filtered) {
|
|
1738
|
+
const bucket = Math.floor(score.timestamp.getTime() / intervalMs) * intervalMs;
|
|
1739
|
+
if (!bucketMap.has(bucket)) bucketMap.set(bucket, []);
|
|
1740
|
+
bucketMap.get(bucket).push(score.score);
|
|
1741
|
+
}
|
|
1742
|
+
const sortedBuckets = Array.from(bucketMap.entries()).sort(([a], [b]) => a - b);
|
|
1743
|
+
return {
|
|
1744
|
+
series: args.percentiles.map((percentile) => ({
|
|
1745
|
+
percentile,
|
|
1746
|
+
points: sortedBuckets.map(([ts, values]) => {
|
|
1747
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
1748
|
+
return { timestamp: new Date(ts), value: this.interpolatePercentile(sorted, percentile) };
|
|
1749
|
+
})
|
|
1750
|
+
}))
|
|
1751
|
+
};
|
|
1752
|
+
}
|
|
1753
|
+
getNumericFeedbackValue(value) {
|
|
1754
|
+
if (typeof value === "number") {
|
|
1755
|
+
return Number.isFinite(value) ? value : null;
|
|
1756
|
+
}
|
|
1757
|
+
if (typeof value === "string") {
|
|
1758
|
+
const trimmed = value.trim();
|
|
1759
|
+
if (trimmed.length === 0) return null;
|
|
1760
|
+
const numeric = Number(trimmed);
|
|
1761
|
+
return Number.isFinite(numeric) ? numeric : null;
|
|
1762
|
+
}
|
|
1763
|
+
return null;
|
|
1764
|
+
}
|
|
1765
|
+
getComparisonDateRange(comparePeriod, timestamp) {
|
|
1766
|
+
if (!timestamp.start || !timestamp.end) return null;
|
|
1767
|
+
const duration = timestamp.end.getTime() - timestamp.start.getTime();
|
|
1768
|
+
switch (comparePeriod) {
|
|
1769
|
+
case "previous_period":
|
|
1770
|
+
return {
|
|
1771
|
+
start: new Date(timestamp.start.getTime() - duration),
|
|
1772
|
+
end: new Date(timestamp.end.getTime() - duration),
|
|
1773
|
+
startExclusive: timestamp.startExclusive,
|
|
1774
|
+
endExclusive: timestamp.endExclusive
|
|
1775
|
+
};
|
|
1776
|
+
case "previous_day":
|
|
1777
|
+
return {
|
|
1778
|
+
start: new Date(timestamp.start.getTime() - 864e5),
|
|
1779
|
+
end: new Date(timestamp.end.getTime() - 864e5),
|
|
1780
|
+
startExclusive: timestamp.startExclusive,
|
|
1781
|
+
endExclusive: timestamp.endExclusive
|
|
1782
|
+
};
|
|
1783
|
+
case "previous_week":
|
|
1784
|
+
return {
|
|
1785
|
+
start: new Date(timestamp.start.getTime() - 6048e5),
|
|
1786
|
+
end: new Date(timestamp.end.getTime() - 6048e5),
|
|
1787
|
+
startExclusive: timestamp.startExclusive,
|
|
1788
|
+
endExclusive: timestamp.endExclusive
|
|
1789
|
+
};
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1531
1792
|
// ============================================================================
|
|
1532
1793
|
// Feedback
|
|
1533
1794
|
// ============================================================================
|
|
@@ -1550,7 +1811,7 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1550
1811
|
}
|
|
1551
1812
|
}
|
|
1552
1813
|
async listFeedback(args) {
|
|
1553
|
-
const { filters, pagination, orderBy } =
|
|
1814
|
+
const { filters, pagination, orderBy } = chunkBF7IH4JU_cjs.listFeedbackArgsSchema.parse(args);
|
|
1554
1815
|
let matching = this.db.feedbackRecords.filter((fb) => this.feedbackMatchesFilters(fb, filters));
|
|
1555
1816
|
const dir = orderBy.direction === "DESC" ? -1 : 1;
|
|
1556
1817
|
matching.sort((a, b) => dir * (a.timestamp.getTime() - b.timestamp.getTime()));
|
|
@@ -1563,6 +1824,174 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1563
1824
|
pagination: { total, page, perPage, hasMore: start + perPage < total }
|
|
1564
1825
|
};
|
|
1565
1826
|
}
|
|
1827
|
+
async getFeedbackAggregate(args) {
|
|
1828
|
+
const filtered = this.db.feedbackRecords.filter((feedback) => this.feedbackMatchesFilters(feedback, args.filters)).filter((feedback) => feedback.feedbackType === args.feedbackType).filter(
|
|
1829
|
+
(feedback) => args.feedbackSource ? (feedback.feedbackSource ?? feedback.source ?? "") === args.feedbackSource : true
|
|
1830
|
+
);
|
|
1831
|
+
const numericEntries = filtered.flatMap((feedback) => {
|
|
1832
|
+
const numericValue = this.getNumericFeedbackValue(feedback.value);
|
|
1833
|
+
return numericValue === null ? [] : [{ numericValue, timestamp: feedback.timestamp.getTime() }];
|
|
1834
|
+
});
|
|
1835
|
+
const value = this.aggregate(
|
|
1836
|
+
numericEntries.map((entry) => entry.numericValue),
|
|
1837
|
+
args.aggregation,
|
|
1838
|
+
numericEntries.map((entry) => entry.timestamp)
|
|
1839
|
+
);
|
|
1840
|
+
if (args.comparePeriod && args.filters?.timestamp) {
|
|
1841
|
+
const previousRange = this.getComparisonDateRange(args.comparePeriod, args.filters.timestamp);
|
|
1842
|
+
if (previousRange) {
|
|
1843
|
+
const previousNumericEntries = this.db.feedbackRecords.filter(
|
|
1844
|
+
(feedback) => this.feedbackMatchesFilters(feedback, {
|
|
1845
|
+
...args.filters ?? {},
|
|
1846
|
+
timestamp: previousRange
|
|
1847
|
+
})
|
|
1848
|
+
).filter((feedback) => feedback.feedbackType === args.feedbackType).filter(
|
|
1849
|
+
(feedback) => args.feedbackSource ? (feedback.feedbackSource ?? feedback.source ?? "") === args.feedbackSource : true
|
|
1850
|
+
).flatMap((feedback) => {
|
|
1851
|
+
const numericValue = this.getNumericFeedbackValue(feedback.value);
|
|
1852
|
+
return numericValue === null ? [] : [{ numericValue, timestamp: feedback.timestamp.getTime() }];
|
|
1853
|
+
});
|
|
1854
|
+
const previousValue = this.aggregate(
|
|
1855
|
+
previousNumericEntries.map((entry) => entry.numericValue),
|
|
1856
|
+
args.aggregation,
|
|
1857
|
+
previousNumericEntries.map((entry) => entry.timestamp)
|
|
1858
|
+
);
|
|
1859
|
+
let changePercent = null;
|
|
1860
|
+
if (previousValue !== null && previousValue !== 0 && value !== null) {
|
|
1861
|
+
changePercent = (value - previousValue) / Math.abs(previousValue) * 100;
|
|
1862
|
+
}
|
|
1863
|
+
return { value, previousValue, changePercent };
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
return { value };
|
|
1867
|
+
}
|
|
1868
|
+
async getFeedbackBreakdown(args) {
|
|
1869
|
+
const filtered = this.db.feedbackRecords.filter((feedback) => this.feedbackMatchesFilters(feedback, args.filters)).filter((feedback) => feedback.feedbackType === args.feedbackType).filter(
|
|
1870
|
+
(feedback) => args.feedbackSource ? (feedback.feedbackSource ?? feedback.source ?? "") === args.feedbackSource : true
|
|
1871
|
+
).filter((feedback) => this.getNumericFeedbackValue(feedback.value) !== null);
|
|
1872
|
+
const groupMap = /* @__PURE__ */ new Map();
|
|
1873
|
+
for (const feedback of filtered) {
|
|
1874
|
+
const dims = {};
|
|
1875
|
+
for (const col of args.groupBy) {
|
|
1876
|
+
const rawValue = feedback[col];
|
|
1877
|
+
dims[col] = rawValue === null || rawValue === void 0 ? null : String(rawValue);
|
|
1878
|
+
}
|
|
1879
|
+
const key = JSON.stringify(dims);
|
|
1880
|
+
if (!groupMap.has(key)) groupMap.set(key, []);
|
|
1881
|
+
groupMap.get(key).push(feedback);
|
|
1882
|
+
}
|
|
1883
|
+
const groups = Array.from(groupMap.entries()).map(([key, records]) => ({
|
|
1884
|
+
dimensions: JSON.parse(key),
|
|
1885
|
+
value: (() => {
|
|
1886
|
+
const numericEntries = records.flatMap((record) => {
|
|
1887
|
+
const numericValue = this.getNumericFeedbackValue(record.value);
|
|
1888
|
+
return numericValue === null ? [] : [{ numericValue, timestamp: record.timestamp.getTime() }];
|
|
1889
|
+
});
|
|
1890
|
+
return this.aggregate(
|
|
1891
|
+
numericEntries.map((entry) => entry.numericValue),
|
|
1892
|
+
args.aggregation,
|
|
1893
|
+
numericEntries.map((entry) => entry.timestamp)
|
|
1894
|
+
) ?? 0;
|
|
1895
|
+
})()
|
|
1896
|
+
}));
|
|
1897
|
+
groups.sort((a, b) => b.value - a.value);
|
|
1898
|
+
return { groups };
|
|
1899
|
+
}
|
|
1900
|
+
async getFeedbackTimeSeries(args) {
|
|
1901
|
+
const filtered = this.db.feedbackRecords.filter((feedback) => this.feedbackMatchesFilters(feedback, args.filters)).filter((feedback) => feedback.feedbackType === args.feedbackType).filter(
|
|
1902
|
+
(feedback) => args.feedbackSource ? (feedback.feedbackSource ?? feedback.source ?? "") === args.feedbackSource : true
|
|
1903
|
+
).filter((feedback) => this.getNumericFeedbackValue(feedback.value) !== null);
|
|
1904
|
+
const intervalMs = this.intervalToMs(args.interval);
|
|
1905
|
+
if (args.groupBy && args.groupBy.length > 0) {
|
|
1906
|
+
const seriesMap = /* @__PURE__ */ new Map();
|
|
1907
|
+
const seriesNames = /* @__PURE__ */ new Map();
|
|
1908
|
+
for (const feedback of filtered) {
|
|
1909
|
+
const values = args.groupBy.map((col) => feedback[col] ?? "");
|
|
1910
|
+
const key = JSON.stringify(values);
|
|
1911
|
+
if (!seriesMap.has(key)) seriesMap.set(key, /* @__PURE__ */ new Map());
|
|
1912
|
+
if (!seriesNames.has(key)) {
|
|
1913
|
+
seriesNames.set(
|
|
1914
|
+
key,
|
|
1915
|
+
values.map((value) => value === null || value === void 0 ? "" : String(value)).join("|")
|
|
1916
|
+
);
|
|
1917
|
+
}
|
|
1918
|
+
const bucket = Math.floor(feedback.timestamp.getTime() / intervalMs) * intervalMs;
|
|
1919
|
+
const bucketMap2 = seriesMap.get(key);
|
|
1920
|
+
if (!bucketMap2.has(bucket)) bucketMap2.set(bucket, []);
|
|
1921
|
+
bucketMap2.get(bucket).push(feedback);
|
|
1922
|
+
}
|
|
1923
|
+
return {
|
|
1924
|
+
series: Array.from(seriesMap.entries()).map(([key, bucketMap2]) => ({
|
|
1925
|
+
name: seriesNames.get(key),
|
|
1926
|
+
points: Array.from(bucketMap2.entries()).sort(([a], [b]) => a - b).map(([ts, records]) => ({
|
|
1927
|
+
timestamp: new Date(ts),
|
|
1928
|
+
value: (() => {
|
|
1929
|
+
const numericEntries = records.flatMap((record) => {
|
|
1930
|
+
const numericValue = this.getNumericFeedbackValue(record.value);
|
|
1931
|
+
return numericValue === null ? [] : [{ numericValue, timestamp: record.timestamp.getTime() }];
|
|
1932
|
+
});
|
|
1933
|
+
return this.aggregate(
|
|
1934
|
+
numericEntries.map((entry) => entry.numericValue),
|
|
1935
|
+
args.aggregation,
|
|
1936
|
+
numericEntries.map((entry) => entry.timestamp)
|
|
1937
|
+
) ?? 0;
|
|
1938
|
+
})()
|
|
1939
|
+
}))
|
|
1940
|
+
}))
|
|
1941
|
+
};
|
|
1942
|
+
}
|
|
1943
|
+
const bucketMap = /* @__PURE__ */ new Map();
|
|
1944
|
+
for (const feedback of filtered) {
|
|
1945
|
+
const bucket = Math.floor(feedback.timestamp.getTime() / intervalMs) * intervalMs;
|
|
1946
|
+
if (!bucketMap.has(bucket)) bucketMap.set(bucket, []);
|
|
1947
|
+
bucketMap.get(bucket).push(feedback);
|
|
1948
|
+
}
|
|
1949
|
+
return {
|
|
1950
|
+
series: [
|
|
1951
|
+
{
|
|
1952
|
+
name: args.feedbackSource ? `${args.feedbackType}|${args.feedbackSource}` : args.feedbackType,
|
|
1953
|
+
points: Array.from(bucketMap.entries()).sort(([a], [b]) => a - b).map(([ts, records]) => ({
|
|
1954
|
+
timestamp: new Date(ts),
|
|
1955
|
+
value: (() => {
|
|
1956
|
+
const numericEntries = records.flatMap((record) => {
|
|
1957
|
+
const numericValue = this.getNumericFeedbackValue(record.value);
|
|
1958
|
+
return numericValue === null ? [] : [{ numericValue, timestamp: record.timestamp.getTime() }];
|
|
1959
|
+
});
|
|
1960
|
+
return this.aggregate(
|
|
1961
|
+
numericEntries.map((entry) => entry.numericValue),
|
|
1962
|
+
args.aggregation,
|
|
1963
|
+
numericEntries.map((entry) => entry.timestamp)
|
|
1964
|
+
) ?? 0;
|
|
1965
|
+
})()
|
|
1966
|
+
}))
|
|
1967
|
+
}
|
|
1968
|
+
]
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1971
|
+
async getFeedbackPercentiles(args) {
|
|
1972
|
+
const filtered = this.db.feedbackRecords.filter((feedback) => this.feedbackMatchesFilters(feedback, args.filters)).filter((feedback) => feedback.feedbackType === args.feedbackType).filter(
|
|
1973
|
+
(feedback) => args.feedbackSource ? (feedback.feedbackSource ?? feedback.source ?? "") === args.feedbackSource : true
|
|
1974
|
+
);
|
|
1975
|
+
const intervalMs = this.intervalToMs(args.interval);
|
|
1976
|
+
const bucketMap = /* @__PURE__ */ new Map();
|
|
1977
|
+
for (const feedback of filtered) {
|
|
1978
|
+
const numericValue = this.getNumericFeedbackValue(feedback.value);
|
|
1979
|
+
if (numericValue === null) continue;
|
|
1980
|
+
const bucket = Math.floor(feedback.timestamp.getTime() / intervalMs) * intervalMs;
|
|
1981
|
+
if (!bucketMap.has(bucket)) bucketMap.set(bucket, []);
|
|
1982
|
+
bucketMap.get(bucket).push(numericValue);
|
|
1983
|
+
}
|
|
1984
|
+
const sortedBuckets = Array.from(bucketMap.entries()).sort(([a], [b]) => a - b);
|
|
1985
|
+
return {
|
|
1986
|
+
series: args.percentiles.map((percentile) => ({
|
|
1987
|
+
percentile,
|
|
1988
|
+
points: sortedBuckets.map(([ts, values]) => {
|
|
1989
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
1990
|
+
return { timestamp: new Date(ts), value: this.interpolatePercentile(sorted, percentile) };
|
|
1991
|
+
})
|
|
1992
|
+
}))
|
|
1993
|
+
};
|
|
1994
|
+
}
|
|
1566
1995
|
feedbackMatchesFilters(fb, filters) {
|
|
1567
1996
|
if (!filters) return true;
|
|
1568
1997
|
if (filters.timestamp) {
|
|
@@ -1607,7 +2036,7 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1607
2036
|
};
|
|
1608
2037
|
|
|
1609
2038
|
// src/storage/domains/observability/record-builders.ts
|
|
1610
|
-
var entityTypeValues = new Set(Object.values(
|
|
2039
|
+
var entityTypeValues = new Set(Object.values(chunkBF7IH4JU_cjs.EntityType));
|
|
1611
2040
|
function toEntityType(value) {
|
|
1612
2041
|
if (value && entityTypeValues.has(value)) {
|
|
1613
2042
|
return value;
|
|
@@ -2071,7 +2500,7 @@ var InMemoryAgentsStorage = class extends AgentsStorage {
|
|
|
2071
2500
|
if (metadata && Object.keys(metadata).length > 0) {
|
|
2072
2501
|
agents = agents.filter((agent) => {
|
|
2073
2502
|
if (!agent.metadata) return false;
|
|
2074
|
-
return Object.entries(metadata).every(([key, value]) =>
|
|
2503
|
+
return Object.entries(metadata).every(([key, value]) => chunkXQRTJIC7_cjs.deepEqual(agent.metadata[key], value));
|
|
2075
2504
|
});
|
|
2076
2505
|
}
|
|
2077
2506
|
const sortedAgents = this.sortAgents(agents, field, direction);
|
|
@@ -3264,7 +3693,7 @@ var InMemoryMCPClientsStorage = class extends MCPClientsStorage {
|
|
|
3264
3693
|
if (metadata && Object.keys(metadata).length > 0) {
|
|
3265
3694
|
configs = configs.filter((config) => {
|
|
3266
3695
|
if (!config.metadata) return false;
|
|
3267
|
-
return Object.entries(metadata).every(([key, value]) =>
|
|
3696
|
+
return Object.entries(metadata).every(([key, value]) => chunkXQRTJIC7_cjs.deepEqual(config.metadata[key], value));
|
|
3268
3697
|
});
|
|
3269
3698
|
}
|
|
3270
3699
|
const sortedConfigs = this.sortConfigs(configs, field, direction);
|
|
@@ -3532,7 +3961,7 @@ var InMemoryMCPServersStorage = class extends MCPServersStorage {
|
|
|
3532
3961
|
if (metadata && Object.keys(metadata).length > 0) {
|
|
3533
3962
|
configs = configs.filter((config) => {
|
|
3534
3963
|
if (!config.metadata) return false;
|
|
3535
|
-
return Object.entries(metadata).every(([key, value]) =>
|
|
3964
|
+
return Object.entries(metadata).every(([key, value]) => chunkXQRTJIC7_cjs.deepEqual(config.metadata[key], value));
|
|
3536
3965
|
});
|
|
3537
3966
|
}
|
|
3538
3967
|
const sortedConfigs = this.sortConfigs(configs, field, direction);
|
|
@@ -4997,7 +5426,7 @@ var InMemoryPromptBlocksStorage = class extends PromptBlocksStorage {
|
|
|
4997
5426
|
if (metadata && Object.keys(metadata).length > 0) {
|
|
4998
5427
|
blocks = blocks.filter((block) => {
|
|
4999
5428
|
if (!block.metadata) return false;
|
|
5000
|
-
return Object.entries(metadata).every(([key, value]) =>
|
|
5429
|
+
return Object.entries(metadata).every(([key, value]) => chunkXQRTJIC7_cjs.deepEqual(block.metadata[key], value));
|
|
5001
5430
|
});
|
|
5002
5431
|
}
|
|
5003
5432
|
const sortedBlocks = this.sortBlocks(blocks, field, direction);
|
|
@@ -5263,7 +5692,7 @@ var InMemoryScorerDefinitionsStorage = class extends ScorerDefinitionsStorage {
|
|
|
5263
5692
|
if (metadata && Object.keys(metadata).length > 0) {
|
|
5264
5693
|
scorers = scorers.filter((scorer) => {
|
|
5265
5694
|
if (!scorer.metadata) return false;
|
|
5266
|
-
return Object.entries(metadata).every(([key, value]) =>
|
|
5695
|
+
return Object.entries(metadata).every(([key, value]) => chunkXQRTJIC7_cjs.deepEqual(scorer.metadata[key], value));
|
|
5267
5696
|
});
|
|
5268
5697
|
}
|
|
5269
5698
|
const sortedScorers = this.sortScorers(scorers, field, direction);
|
|
@@ -6311,7 +6740,7 @@ var InMemoryWorkspacesStorage = class extends WorkspacesStorage {
|
|
|
6311
6740
|
if (metadata && Object.keys(metadata).length > 0) {
|
|
6312
6741
|
configs = configs.filter((config) => {
|
|
6313
6742
|
if (!config.metadata) return false;
|
|
6314
|
-
return Object.entries(metadata).every(([key, value]) =>
|
|
6743
|
+
return Object.entries(metadata).every(([key, value]) => chunkXQRTJIC7_cjs.deepEqual(config.metadata[key], value));
|
|
6315
6744
|
});
|
|
6316
6745
|
}
|
|
6317
6746
|
const sortedConfigs = this.sortConfigs(configs, field, direction);
|
|
@@ -8151,7 +8580,7 @@ var StoreOperationsInMemory = class extends StoreOperations {
|
|
|
8151
8580
|
async insert({ tableName, record }) {
|
|
8152
8581
|
const table = this.data[tableName];
|
|
8153
8582
|
let key = record.id;
|
|
8154
|
-
if ([
|
|
8583
|
+
if ([chunk4BZRWJBH_cjs.TABLE_WORKFLOW_SNAPSHOT].includes(tableName) && !record.id && record.run_id) {
|
|
8155
8584
|
key = record.workflow_name ? `${record.workflow_name}-${record.run_id}` : record.run_id;
|
|
8156
8585
|
record.id = key;
|
|
8157
8586
|
} else if (!record.id) {
|
|
@@ -8164,7 +8593,7 @@ var StoreOperationsInMemory = class extends StoreOperations {
|
|
|
8164
8593
|
const table = this.data[tableName];
|
|
8165
8594
|
for (const record of records) {
|
|
8166
8595
|
let key = record.id;
|
|
8167
|
-
if ([
|
|
8596
|
+
if ([chunk4BZRWJBH_cjs.TABLE_WORKFLOW_SNAPSHOT].includes(tableName) && !record.id && record.run_id) {
|
|
8168
8597
|
key = record.run_id;
|
|
8169
8598
|
record.id = key;
|
|
8170
8599
|
} else if (!record.id) {
|
|
@@ -8286,5 +8715,5 @@ exports.serializeSpanAttributes = serializeSpanAttributes;
|
|
|
8286
8715
|
exports.toEntityType = toEntityType;
|
|
8287
8716
|
exports.transformRow = transformRow;
|
|
8288
8717
|
exports.transformScoreRow = transformScoreRow;
|
|
8289
|
-
//# sourceMappingURL=chunk-
|
|
8290
|
-
//# sourceMappingURL=chunk-
|
|
8718
|
+
//# sourceMappingURL=chunk-V2NQOABM.cjs.map
|
|
8719
|
+
//# sourceMappingURL=chunk-V2NQOABM.cjs.map
|