@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,7 +1,7 @@
|
|
|
1
1
|
import { MessageList } from './chunk-SLZ3WO42.js';
|
|
2
|
-
import { TABLE_SCHEMAS, TABLE_SCORERS, listTracesArgsSchema, toTraceSpans, TABLE_WORKFLOW_SNAPSHOT } from './chunk-
|
|
3
|
-
import { deepEqual } from './chunk-
|
|
4
|
-
import { EntityType, listMetricsArgsSchema, listLogsArgsSchema, listScoresArgsSchema, listFeedbackArgsSchema } from './chunk-
|
|
2
|
+
import { TABLE_SCHEMAS, TABLE_SCORERS, listTracesArgsSchema, toTraceSpans, TABLE_WORKFLOW_SNAPSHOT } from './chunk-PMWMEK4T.js';
|
|
3
|
+
import { deepEqual } from './chunk-4FMKWOPC.js';
|
|
4
|
+
import { EntityType, listMetricsArgsSchema, listLogsArgsSchema, listScoresArgsSchema, listFeedbackArgsSchema } from './chunk-KRFGPA2H.js';
|
|
5
5
|
import { MastraError } from './chunk-FJEVLHJT.js';
|
|
6
6
|
import { MastraBase } from './chunk-WCAFTXGK.js';
|
|
7
7
|
import { jsonSchemaToZod } from '@mastra/schema-compat/json-to-zod';
|
|
@@ -492,6 +492,38 @@ var ObservabilityStorage = class extends StorageDomain {
|
|
|
492
492
|
text: "This storage provider does not support listing scores"
|
|
493
493
|
});
|
|
494
494
|
}
|
|
495
|
+
async getScoreAggregate(_args) {
|
|
496
|
+
throw new MastraError({
|
|
497
|
+
id: "OBSERVABILITY_STORAGE_GET_SCORE_AGGREGATE_NOT_IMPLEMENTED",
|
|
498
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
499
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
500
|
+
text: "This storage provider does not support score aggregation"
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
async getScoreBreakdown(_args) {
|
|
504
|
+
throw new MastraError({
|
|
505
|
+
id: "OBSERVABILITY_STORAGE_GET_SCORE_BREAKDOWN_NOT_IMPLEMENTED",
|
|
506
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
507
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
508
|
+
text: "This storage provider does not support score breakdown"
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
async getScoreTimeSeries(_args) {
|
|
512
|
+
throw new MastraError({
|
|
513
|
+
id: "OBSERVABILITY_STORAGE_GET_SCORE_TIME_SERIES_NOT_IMPLEMENTED",
|
|
514
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
515
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
516
|
+
text: "This storage provider does not support score time series"
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
async getScorePercentiles(_args) {
|
|
520
|
+
throw new MastraError({
|
|
521
|
+
id: "OBSERVABILITY_STORAGE_GET_SCORE_PERCENTILES_NOT_IMPLEMENTED",
|
|
522
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
523
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
524
|
+
text: "This storage provider does not support score percentiles"
|
|
525
|
+
});
|
|
526
|
+
}
|
|
495
527
|
// ============================================================================
|
|
496
528
|
// Feedback
|
|
497
529
|
// ============================================================================
|
|
@@ -528,6 +560,38 @@ var ObservabilityStorage = class extends StorageDomain {
|
|
|
528
560
|
text: "This storage provider does not support listing feedback"
|
|
529
561
|
});
|
|
530
562
|
}
|
|
563
|
+
async getFeedbackAggregate(_args) {
|
|
564
|
+
throw new MastraError({
|
|
565
|
+
id: "OBSERVABILITY_STORAGE_GET_FEEDBACK_AGGREGATE_NOT_IMPLEMENTED",
|
|
566
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
567
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
568
|
+
text: "This storage provider does not support feedback aggregation"
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
async getFeedbackBreakdown(_args) {
|
|
572
|
+
throw new MastraError({
|
|
573
|
+
id: "OBSERVABILITY_STORAGE_GET_FEEDBACK_BREAKDOWN_NOT_IMPLEMENTED",
|
|
574
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
575
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
576
|
+
text: "This storage provider does not support feedback breakdown"
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
async getFeedbackTimeSeries(_args) {
|
|
580
|
+
throw new MastraError({
|
|
581
|
+
id: "OBSERVABILITY_STORAGE_GET_FEEDBACK_TIME_SERIES_NOT_IMPLEMENTED",
|
|
582
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
583
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
584
|
+
text: "This storage provider does not support feedback time series"
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
async getFeedbackPercentiles(_args) {
|
|
588
|
+
throw new MastraError({
|
|
589
|
+
id: "OBSERVABILITY_STORAGE_GET_FEEDBACK_PERCENTILES_NOT_IMPLEMENTED",
|
|
590
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
591
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
592
|
+
text: "This storage provider does not support feedback percentiles"
|
|
593
|
+
});
|
|
594
|
+
}
|
|
531
595
|
};
|
|
532
596
|
|
|
533
597
|
// src/storage/utils.ts
|
|
@@ -1078,7 +1142,7 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1078
1142
|
return true;
|
|
1079
1143
|
});
|
|
1080
1144
|
}
|
|
1081
|
-
aggregate(values, type) {
|
|
1145
|
+
aggregate(values, type, timestamps) {
|
|
1082
1146
|
if (values.length === 0) return null;
|
|
1083
1147
|
switch (type) {
|
|
1084
1148
|
case "sum":
|
|
@@ -1091,12 +1155,37 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1091
1155
|
return Math.max(...values);
|
|
1092
1156
|
case "count":
|
|
1093
1157
|
return values.length;
|
|
1094
|
-
case "last":
|
|
1095
|
-
|
|
1158
|
+
case "last": {
|
|
1159
|
+
if (!timestamps || timestamps.length !== values.length) {
|
|
1160
|
+
return values[values.length - 1];
|
|
1161
|
+
}
|
|
1162
|
+
let latestIndex = 0;
|
|
1163
|
+
let latestTimestamp = timestamps[0];
|
|
1164
|
+
for (let i = 1; i < timestamps.length; i++) {
|
|
1165
|
+
const timestamp = timestamps[i];
|
|
1166
|
+
if (timestamp >= latestTimestamp) {
|
|
1167
|
+
latestTimestamp = timestamp;
|
|
1168
|
+
latestIndex = i;
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
return values[latestIndex];
|
|
1172
|
+
}
|
|
1096
1173
|
default:
|
|
1097
1174
|
return values.reduce((a, b) => a + b, 0);
|
|
1098
1175
|
}
|
|
1099
1176
|
}
|
|
1177
|
+
interpolatePercentile(sortedValues, percentile) {
|
|
1178
|
+
if (sortedValues.length === 0) return 0;
|
|
1179
|
+
const position = percentile * (sortedValues.length - 1);
|
|
1180
|
+
const lowerIndex = Math.floor(position);
|
|
1181
|
+
const upperIndex = Math.ceil(position);
|
|
1182
|
+
const lowerValue = sortedValues[lowerIndex];
|
|
1183
|
+
const upperValue = sortedValues[upperIndex];
|
|
1184
|
+
if (lowerIndex === upperIndex) {
|
|
1185
|
+
return lowerValue;
|
|
1186
|
+
}
|
|
1187
|
+
return lowerValue + (upperValue - lowerValue) * (position - lowerIndex);
|
|
1188
|
+
}
|
|
1100
1189
|
/**
|
|
1101
1190
|
* Cost is returned alongside value-based OLAP results so callers can derive
|
|
1102
1191
|
* token and monetary views from the same filtered scan.
|
|
@@ -1526,6 +1615,178 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1526
1615
|
}
|
|
1527
1616
|
return true;
|
|
1528
1617
|
}
|
|
1618
|
+
async getScoreAggregate(args) {
|
|
1619
|
+
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);
|
|
1620
|
+
const value = this.aggregate(
|
|
1621
|
+
filtered.map((score) => score.score),
|
|
1622
|
+
args.aggregation,
|
|
1623
|
+
filtered.map((score) => score.timestamp.getTime())
|
|
1624
|
+
);
|
|
1625
|
+
if (args.comparePeriod && args.filters?.timestamp) {
|
|
1626
|
+
const previousRange = this.getComparisonDateRange(args.comparePeriod, args.filters.timestamp);
|
|
1627
|
+
if (previousRange) {
|
|
1628
|
+
const previousFiltered = this.db.scoreRecords.filter(
|
|
1629
|
+
(score) => this.scoreMatchesFilters(score, {
|
|
1630
|
+
...args.filters ?? {},
|
|
1631
|
+
timestamp: previousRange
|
|
1632
|
+
})
|
|
1633
|
+
).filter((score) => score.scorerId === args.scorerId).filter(
|
|
1634
|
+
(score) => args.scoreSource ? (score.scoreSource ?? score.source ?? null) === args.scoreSource : true
|
|
1635
|
+
);
|
|
1636
|
+
const previousValue = this.aggregate(
|
|
1637
|
+
previousFiltered.map((score) => score.score),
|
|
1638
|
+
args.aggregation,
|
|
1639
|
+
previousFiltered.map((score) => score.timestamp.getTime())
|
|
1640
|
+
);
|
|
1641
|
+
let changePercent = null;
|
|
1642
|
+
if (previousValue !== null && previousValue !== 0 && value !== null) {
|
|
1643
|
+
changePercent = (value - previousValue) / Math.abs(previousValue) * 100;
|
|
1644
|
+
}
|
|
1645
|
+
return { value, previousValue, changePercent };
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
return { value };
|
|
1649
|
+
}
|
|
1650
|
+
async getScoreBreakdown(args) {
|
|
1651
|
+
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);
|
|
1652
|
+
const groupMap = /* @__PURE__ */ new Map();
|
|
1653
|
+
for (const score of filtered) {
|
|
1654
|
+
const dims = {};
|
|
1655
|
+
for (const col of args.groupBy) {
|
|
1656
|
+
const value = score[col];
|
|
1657
|
+
dims[col] = value === null || value === void 0 ? null : String(value);
|
|
1658
|
+
}
|
|
1659
|
+
const key = JSON.stringify(dims);
|
|
1660
|
+
if (!groupMap.has(key)) groupMap.set(key, []);
|
|
1661
|
+
groupMap.get(key).push(score);
|
|
1662
|
+
}
|
|
1663
|
+
const groups = Array.from(groupMap.entries()).map(([key, records]) => ({
|
|
1664
|
+
dimensions: JSON.parse(key),
|
|
1665
|
+
value: this.aggregate(
|
|
1666
|
+
records.map((record) => record.score),
|
|
1667
|
+
args.aggregation,
|
|
1668
|
+
records.map((record) => record.timestamp.getTime())
|
|
1669
|
+
) ?? 0
|
|
1670
|
+
}));
|
|
1671
|
+
groups.sort((a, b) => b.value - a.value);
|
|
1672
|
+
return { groups };
|
|
1673
|
+
}
|
|
1674
|
+
async getScoreTimeSeries(args) {
|
|
1675
|
+
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);
|
|
1676
|
+
const intervalMs = this.intervalToMs(args.interval);
|
|
1677
|
+
if (args.groupBy && args.groupBy.length > 0) {
|
|
1678
|
+
const seriesMap = /* @__PURE__ */ new Map();
|
|
1679
|
+
const seriesNames = /* @__PURE__ */ new Map();
|
|
1680
|
+
for (const score of filtered) {
|
|
1681
|
+
const values = args.groupBy.map((col) => score[col] ?? "");
|
|
1682
|
+
const key = JSON.stringify(values);
|
|
1683
|
+
if (!seriesMap.has(key)) seriesMap.set(key, /* @__PURE__ */ new Map());
|
|
1684
|
+
if (!seriesNames.has(key)) {
|
|
1685
|
+
seriesNames.set(
|
|
1686
|
+
key,
|
|
1687
|
+
values.map((value) => value === null || value === void 0 ? "" : String(value)).join("|")
|
|
1688
|
+
);
|
|
1689
|
+
}
|
|
1690
|
+
const bucket = Math.floor(score.timestamp.getTime() / intervalMs) * intervalMs;
|
|
1691
|
+
const bucketMap2 = seriesMap.get(key);
|
|
1692
|
+
if (!bucketMap2.has(bucket)) bucketMap2.set(bucket, []);
|
|
1693
|
+
bucketMap2.get(bucket).push(score);
|
|
1694
|
+
}
|
|
1695
|
+
return {
|
|
1696
|
+
series: Array.from(seriesMap.entries()).map(([key, bucketMap2]) => ({
|
|
1697
|
+
name: seriesNames.get(key),
|
|
1698
|
+
points: Array.from(bucketMap2.entries()).sort(([a], [b]) => a - b).map(([ts, records]) => ({
|
|
1699
|
+
timestamp: new Date(ts),
|
|
1700
|
+
value: this.aggregate(
|
|
1701
|
+
records.map((record) => record.score),
|
|
1702
|
+
args.aggregation,
|
|
1703
|
+
records.map((record) => record.timestamp.getTime())
|
|
1704
|
+
) ?? 0
|
|
1705
|
+
}))
|
|
1706
|
+
}))
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1709
|
+
const bucketMap = /* @__PURE__ */ new Map();
|
|
1710
|
+
for (const score of filtered) {
|
|
1711
|
+
const bucket = Math.floor(score.timestamp.getTime() / intervalMs) * intervalMs;
|
|
1712
|
+
if (!bucketMap.has(bucket)) bucketMap.set(bucket, []);
|
|
1713
|
+
bucketMap.get(bucket).push(score);
|
|
1714
|
+
}
|
|
1715
|
+
return {
|
|
1716
|
+
series: [
|
|
1717
|
+
{
|
|
1718
|
+
name: args.scoreSource ? `${args.scorerId}|${args.scoreSource}` : args.scorerId,
|
|
1719
|
+
points: Array.from(bucketMap.entries()).sort(([a], [b]) => a - b).map(([ts, records]) => ({
|
|
1720
|
+
timestamp: new Date(ts),
|
|
1721
|
+
value: this.aggregate(
|
|
1722
|
+
records.map((record) => record.score),
|
|
1723
|
+
args.aggregation,
|
|
1724
|
+
records.map((record) => record.timestamp.getTime())
|
|
1725
|
+
) ?? 0
|
|
1726
|
+
}))
|
|
1727
|
+
}
|
|
1728
|
+
]
|
|
1729
|
+
};
|
|
1730
|
+
}
|
|
1731
|
+
async getScorePercentiles(args) {
|
|
1732
|
+
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);
|
|
1733
|
+
const intervalMs = this.intervalToMs(args.interval);
|
|
1734
|
+
const bucketMap = /* @__PURE__ */ new Map();
|
|
1735
|
+
for (const score of filtered) {
|
|
1736
|
+
const bucket = Math.floor(score.timestamp.getTime() / intervalMs) * intervalMs;
|
|
1737
|
+
if (!bucketMap.has(bucket)) bucketMap.set(bucket, []);
|
|
1738
|
+
bucketMap.get(bucket).push(score.score);
|
|
1739
|
+
}
|
|
1740
|
+
const sortedBuckets = Array.from(bucketMap.entries()).sort(([a], [b]) => a - b);
|
|
1741
|
+
return {
|
|
1742
|
+
series: args.percentiles.map((percentile) => ({
|
|
1743
|
+
percentile,
|
|
1744
|
+
points: sortedBuckets.map(([ts, values]) => {
|
|
1745
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
1746
|
+
return { timestamp: new Date(ts), value: this.interpolatePercentile(sorted, percentile) };
|
|
1747
|
+
})
|
|
1748
|
+
}))
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
getNumericFeedbackValue(value) {
|
|
1752
|
+
if (typeof value === "number") {
|
|
1753
|
+
return Number.isFinite(value) ? value : null;
|
|
1754
|
+
}
|
|
1755
|
+
if (typeof value === "string") {
|
|
1756
|
+
const trimmed = value.trim();
|
|
1757
|
+
if (trimmed.length === 0) return null;
|
|
1758
|
+
const numeric = Number(trimmed);
|
|
1759
|
+
return Number.isFinite(numeric) ? numeric : null;
|
|
1760
|
+
}
|
|
1761
|
+
return null;
|
|
1762
|
+
}
|
|
1763
|
+
getComparisonDateRange(comparePeriod, timestamp) {
|
|
1764
|
+
if (!timestamp.start || !timestamp.end) return null;
|
|
1765
|
+
const duration = timestamp.end.getTime() - timestamp.start.getTime();
|
|
1766
|
+
switch (comparePeriod) {
|
|
1767
|
+
case "previous_period":
|
|
1768
|
+
return {
|
|
1769
|
+
start: new Date(timestamp.start.getTime() - duration),
|
|
1770
|
+
end: new Date(timestamp.end.getTime() - duration),
|
|
1771
|
+
startExclusive: timestamp.startExclusive,
|
|
1772
|
+
endExclusive: timestamp.endExclusive
|
|
1773
|
+
};
|
|
1774
|
+
case "previous_day":
|
|
1775
|
+
return {
|
|
1776
|
+
start: new Date(timestamp.start.getTime() - 864e5),
|
|
1777
|
+
end: new Date(timestamp.end.getTime() - 864e5),
|
|
1778
|
+
startExclusive: timestamp.startExclusive,
|
|
1779
|
+
endExclusive: timestamp.endExclusive
|
|
1780
|
+
};
|
|
1781
|
+
case "previous_week":
|
|
1782
|
+
return {
|
|
1783
|
+
start: new Date(timestamp.start.getTime() - 6048e5),
|
|
1784
|
+
end: new Date(timestamp.end.getTime() - 6048e5),
|
|
1785
|
+
startExclusive: timestamp.startExclusive,
|
|
1786
|
+
endExclusive: timestamp.endExclusive
|
|
1787
|
+
};
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1529
1790
|
// ============================================================================
|
|
1530
1791
|
// Feedback
|
|
1531
1792
|
// ============================================================================
|
|
@@ -1561,6 +1822,174 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1561
1822
|
pagination: { total, page, perPage, hasMore: start + perPage < total }
|
|
1562
1823
|
};
|
|
1563
1824
|
}
|
|
1825
|
+
async getFeedbackAggregate(args) {
|
|
1826
|
+
const filtered = this.db.feedbackRecords.filter((feedback) => this.feedbackMatchesFilters(feedback, args.filters)).filter((feedback) => feedback.feedbackType === args.feedbackType).filter(
|
|
1827
|
+
(feedback) => args.feedbackSource ? (feedback.feedbackSource ?? feedback.source ?? "") === args.feedbackSource : true
|
|
1828
|
+
);
|
|
1829
|
+
const numericEntries = filtered.flatMap((feedback) => {
|
|
1830
|
+
const numericValue = this.getNumericFeedbackValue(feedback.value);
|
|
1831
|
+
return numericValue === null ? [] : [{ numericValue, timestamp: feedback.timestamp.getTime() }];
|
|
1832
|
+
});
|
|
1833
|
+
const value = this.aggregate(
|
|
1834
|
+
numericEntries.map((entry) => entry.numericValue),
|
|
1835
|
+
args.aggregation,
|
|
1836
|
+
numericEntries.map((entry) => entry.timestamp)
|
|
1837
|
+
);
|
|
1838
|
+
if (args.comparePeriod && args.filters?.timestamp) {
|
|
1839
|
+
const previousRange = this.getComparisonDateRange(args.comparePeriod, args.filters.timestamp);
|
|
1840
|
+
if (previousRange) {
|
|
1841
|
+
const previousNumericEntries = this.db.feedbackRecords.filter(
|
|
1842
|
+
(feedback) => this.feedbackMatchesFilters(feedback, {
|
|
1843
|
+
...args.filters ?? {},
|
|
1844
|
+
timestamp: previousRange
|
|
1845
|
+
})
|
|
1846
|
+
).filter((feedback) => feedback.feedbackType === args.feedbackType).filter(
|
|
1847
|
+
(feedback) => args.feedbackSource ? (feedback.feedbackSource ?? feedback.source ?? "") === args.feedbackSource : true
|
|
1848
|
+
).flatMap((feedback) => {
|
|
1849
|
+
const numericValue = this.getNumericFeedbackValue(feedback.value);
|
|
1850
|
+
return numericValue === null ? [] : [{ numericValue, timestamp: feedback.timestamp.getTime() }];
|
|
1851
|
+
});
|
|
1852
|
+
const previousValue = this.aggregate(
|
|
1853
|
+
previousNumericEntries.map((entry) => entry.numericValue),
|
|
1854
|
+
args.aggregation,
|
|
1855
|
+
previousNumericEntries.map((entry) => entry.timestamp)
|
|
1856
|
+
);
|
|
1857
|
+
let changePercent = null;
|
|
1858
|
+
if (previousValue !== null && previousValue !== 0 && value !== null) {
|
|
1859
|
+
changePercent = (value - previousValue) / Math.abs(previousValue) * 100;
|
|
1860
|
+
}
|
|
1861
|
+
return { value, previousValue, changePercent };
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
return { value };
|
|
1865
|
+
}
|
|
1866
|
+
async getFeedbackBreakdown(args) {
|
|
1867
|
+
const filtered = this.db.feedbackRecords.filter((feedback) => this.feedbackMatchesFilters(feedback, args.filters)).filter((feedback) => feedback.feedbackType === args.feedbackType).filter(
|
|
1868
|
+
(feedback) => args.feedbackSource ? (feedback.feedbackSource ?? feedback.source ?? "") === args.feedbackSource : true
|
|
1869
|
+
).filter((feedback) => this.getNumericFeedbackValue(feedback.value) !== null);
|
|
1870
|
+
const groupMap = /* @__PURE__ */ new Map();
|
|
1871
|
+
for (const feedback of filtered) {
|
|
1872
|
+
const dims = {};
|
|
1873
|
+
for (const col of args.groupBy) {
|
|
1874
|
+
const rawValue = feedback[col];
|
|
1875
|
+
dims[col] = rawValue === null || rawValue === void 0 ? null : String(rawValue);
|
|
1876
|
+
}
|
|
1877
|
+
const key = JSON.stringify(dims);
|
|
1878
|
+
if (!groupMap.has(key)) groupMap.set(key, []);
|
|
1879
|
+
groupMap.get(key).push(feedback);
|
|
1880
|
+
}
|
|
1881
|
+
const groups = Array.from(groupMap.entries()).map(([key, records]) => ({
|
|
1882
|
+
dimensions: JSON.parse(key),
|
|
1883
|
+
value: (() => {
|
|
1884
|
+
const numericEntries = records.flatMap((record) => {
|
|
1885
|
+
const numericValue = this.getNumericFeedbackValue(record.value);
|
|
1886
|
+
return numericValue === null ? [] : [{ numericValue, timestamp: record.timestamp.getTime() }];
|
|
1887
|
+
});
|
|
1888
|
+
return this.aggregate(
|
|
1889
|
+
numericEntries.map((entry) => entry.numericValue),
|
|
1890
|
+
args.aggregation,
|
|
1891
|
+
numericEntries.map((entry) => entry.timestamp)
|
|
1892
|
+
) ?? 0;
|
|
1893
|
+
})()
|
|
1894
|
+
}));
|
|
1895
|
+
groups.sort((a, b) => b.value - a.value);
|
|
1896
|
+
return { groups };
|
|
1897
|
+
}
|
|
1898
|
+
async getFeedbackTimeSeries(args) {
|
|
1899
|
+
const filtered = this.db.feedbackRecords.filter((feedback) => this.feedbackMatchesFilters(feedback, args.filters)).filter((feedback) => feedback.feedbackType === args.feedbackType).filter(
|
|
1900
|
+
(feedback) => args.feedbackSource ? (feedback.feedbackSource ?? feedback.source ?? "") === args.feedbackSource : true
|
|
1901
|
+
).filter((feedback) => this.getNumericFeedbackValue(feedback.value) !== null);
|
|
1902
|
+
const intervalMs = this.intervalToMs(args.interval);
|
|
1903
|
+
if (args.groupBy && args.groupBy.length > 0) {
|
|
1904
|
+
const seriesMap = /* @__PURE__ */ new Map();
|
|
1905
|
+
const seriesNames = /* @__PURE__ */ new Map();
|
|
1906
|
+
for (const feedback of filtered) {
|
|
1907
|
+
const values = args.groupBy.map((col) => feedback[col] ?? "");
|
|
1908
|
+
const key = JSON.stringify(values);
|
|
1909
|
+
if (!seriesMap.has(key)) seriesMap.set(key, /* @__PURE__ */ new Map());
|
|
1910
|
+
if (!seriesNames.has(key)) {
|
|
1911
|
+
seriesNames.set(
|
|
1912
|
+
key,
|
|
1913
|
+
values.map((value) => value === null || value === void 0 ? "" : String(value)).join("|")
|
|
1914
|
+
);
|
|
1915
|
+
}
|
|
1916
|
+
const bucket = Math.floor(feedback.timestamp.getTime() / intervalMs) * intervalMs;
|
|
1917
|
+
const bucketMap2 = seriesMap.get(key);
|
|
1918
|
+
if (!bucketMap2.has(bucket)) bucketMap2.set(bucket, []);
|
|
1919
|
+
bucketMap2.get(bucket).push(feedback);
|
|
1920
|
+
}
|
|
1921
|
+
return {
|
|
1922
|
+
series: Array.from(seriesMap.entries()).map(([key, bucketMap2]) => ({
|
|
1923
|
+
name: seriesNames.get(key),
|
|
1924
|
+
points: Array.from(bucketMap2.entries()).sort(([a], [b]) => a - b).map(([ts, records]) => ({
|
|
1925
|
+
timestamp: new Date(ts),
|
|
1926
|
+
value: (() => {
|
|
1927
|
+
const numericEntries = records.flatMap((record) => {
|
|
1928
|
+
const numericValue = this.getNumericFeedbackValue(record.value);
|
|
1929
|
+
return numericValue === null ? [] : [{ numericValue, timestamp: record.timestamp.getTime() }];
|
|
1930
|
+
});
|
|
1931
|
+
return this.aggregate(
|
|
1932
|
+
numericEntries.map((entry) => entry.numericValue),
|
|
1933
|
+
args.aggregation,
|
|
1934
|
+
numericEntries.map((entry) => entry.timestamp)
|
|
1935
|
+
) ?? 0;
|
|
1936
|
+
})()
|
|
1937
|
+
}))
|
|
1938
|
+
}))
|
|
1939
|
+
};
|
|
1940
|
+
}
|
|
1941
|
+
const bucketMap = /* @__PURE__ */ new Map();
|
|
1942
|
+
for (const feedback of filtered) {
|
|
1943
|
+
const bucket = Math.floor(feedback.timestamp.getTime() / intervalMs) * intervalMs;
|
|
1944
|
+
if (!bucketMap.has(bucket)) bucketMap.set(bucket, []);
|
|
1945
|
+
bucketMap.get(bucket).push(feedback);
|
|
1946
|
+
}
|
|
1947
|
+
return {
|
|
1948
|
+
series: [
|
|
1949
|
+
{
|
|
1950
|
+
name: args.feedbackSource ? `${args.feedbackType}|${args.feedbackSource}` : args.feedbackType,
|
|
1951
|
+
points: Array.from(bucketMap.entries()).sort(([a], [b]) => a - b).map(([ts, records]) => ({
|
|
1952
|
+
timestamp: new Date(ts),
|
|
1953
|
+
value: (() => {
|
|
1954
|
+
const numericEntries = records.flatMap((record) => {
|
|
1955
|
+
const numericValue = this.getNumericFeedbackValue(record.value);
|
|
1956
|
+
return numericValue === null ? [] : [{ numericValue, timestamp: record.timestamp.getTime() }];
|
|
1957
|
+
});
|
|
1958
|
+
return this.aggregate(
|
|
1959
|
+
numericEntries.map((entry) => entry.numericValue),
|
|
1960
|
+
args.aggregation,
|
|
1961
|
+
numericEntries.map((entry) => entry.timestamp)
|
|
1962
|
+
) ?? 0;
|
|
1963
|
+
})()
|
|
1964
|
+
}))
|
|
1965
|
+
}
|
|
1966
|
+
]
|
|
1967
|
+
};
|
|
1968
|
+
}
|
|
1969
|
+
async getFeedbackPercentiles(args) {
|
|
1970
|
+
const filtered = this.db.feedbackRecords.filter((feedback) => this.feedbackMatchesFilters(feedback, args.filters)).filter((feedback) => feedback.feedbackType === args.feedbackType).filter(
|
|
1971
|
+
(feedback) => args.feedbackSource ? (feedback.feedbackSource ?? feedback.source ?? "") === args.feedbackSource : true
|
|
1972
|
+
);
|
|
1973
|
+
const intervalMs = this.intervalToMs(args.interval);
|
|
1974
|
+
const bucketMap = /* @__PURE__ */ new Map();
|
|
1975
|
+
for (const feedback of filtered) {
|
|
1976
|
+
const numericValue = this.getNumericFeedbackValue(feedback.value);
|
|
1977
|
+
if (numericValue === null) continue;
|
|
1978
|
+
const bucket = Math.floor(feedback.timestamp.getTime() / intervalMs) * intervalMs;
|
|
1979
|
+
if (!bucketMap.has(bucket)) bucketMap.set(bucket, []);
|
|
1980
|
+
bucketMap.get(bucket).push(numericValue);
|
|
1981
|
+
}
|
|
1982
|
+
const sortedBuckets = Array.from(bucketMap.entries()).sort(([a], [b]) => a - b);
|
|
1983
|
+
return {
|
|
1984
|
+
series: args.percentiles.map((percentile) => ({
|
|
1985
|
+
percentile,
|
|
1986
|
+
points: sortedBuckets.map(([ts, values]) => {
|
|
1987
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
1988
|
+
return { timestamp: new Date(ts), value: this.interpolatePercentile(sorted, percentile) };
|
|
1989
|
+
})
|
|
1990
|
+
}))
|
|
1991
|
+
};
|
|
1992
|
+
}
|
|
1564
1993
|
feedbackMatchesFilters(fb, filters) {
|
|
1565
1994
|
if (!filters) return true;
|
|
1566
1995
|
if (filters.timestamp) {
|
|
@@ -8206,5 +8635,5 @@ var StoreOperationsInMemory = class extends StoreOperations {
|
|
|
8206
8635
|
};
|
|
8207
8636
|
|
|
8208
8637
|
export { AgentsStorage, BlobStore, DatasetsInMemory, DatasetsStorage, EDITOR_DOMAINS, ExperimentsInMemory, ExperimentsStorage, FilesystemAgentsStorage, FilesystemDB, FilesystemMCPClientsStorage, FilesystemMCPServersStorage, FilesystemPromptBlocksStorage, FilesystemScorerDefinitionsStorage, FilesystemSkillsStorage, FilesystemStore, FilesystemVersionedHelpers, FilesystemWorkspacesStorage, GitHistory, InMemoryAgentsStorage, InMemoryBlobStore, InMemoryDB, InMemoryMCPClientsStorage, InMemoryMCPServersStorage, InMemoryMemory, InMemoryPromptBlocksStorage, InMemoryScorerDefinitionsStorage, InMemorySkillsStorage, InMemoryStore, InMemoryWorkspacesStorage, MCPClientsStorage, MCPServersStorage, MastraCompositeStore, MastraStorage, MemoryStorage, MockStore, ObservabilityInMemory, ObservabilityStorage, PromptBlocksStorage, SchemaUpdateValidationError, SchemaValidationError, SchemaValidator, ScorerDefinitionsStorage, ScoresInMemory, ScoresStorage, SkillsStorage, StorageDomain, StoreOperations, StoreOperationsInMemory, VersionedStorageDomain, WorkflowsInMemory, WorkflowsStorage, WorkspacesStorage, buildCreateSpanRecord, buildFeedbackRecord, buildLogRecord, buildMetricRecord, buildScoreRecord, buildUpdateSpanRecord, calculatePagination, createPendingMarker, createStorageErrorId, createStoreErrorId, createValidator, createVectorErrorId, ensureDate, filterByDateRange, getDefaultValue, getObjectOrNull, getSchemaValidator, getSqlType, getStringOrNull, jsonValueEquals, normalizePerPage, safelyParseJSON, serializeDate, serializeSpanAttributes, toEntityType, transformRow, transformScoreRow };
|
|
8209
|
-
//# sourceMappingURL=chunk-
|
|
8210
|
-
//# sourceMappingURL=chunk-
|
|
8638
|
+
//# sourceMappingURL=chunk-MJF7NZEF.js.map
|
|
8639
|
+
//# sourceMappingURL=chunk-MJF7NZEF.js.map
|