@mastra/core 1.18.0-alpha.3 → 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 +74 -0
- package/dist/_types/@internal_core/dist/index.d.ts +1078 -256
- 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/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
- package/dist/{chunk-ZFH5KWHO.js → chunk-27EVOYQC.js} +3 -3
- package/dist/{chunk-ZFH5KWHO.js.map → chunk-27EVOYQC.js.map} +1 -1
- package/dist/{chunk-32NEFSTI.js → chunk-3CTQJRNS.js} +17 -12
- package/dist/chunk-3CTQJRNS.js.map +1 -0
- package/dist/{chunk-QXPUTX3W.cjs → chunk-4BZRWJBH.cjs} +33 -32
- package/dist/chunk-4BZRWJBH.cjs.map +1 -0
- package/dist/{chunk-AHFHYQS6.js → chunk-4FMKWOPC.js} +4 -4
- package/dist/{chunk-AHFHYQS6.js.map → chunk-4FMKWOPC.js.map} +1 -1
- package/dist/{chunk-BFRUEBG3.js → chunk-5LA5TY63.js} +4 -4
- package/dist/{chunk-BFRUEBG3.js.map → chunk-5LA5TY63.js.map} +1 -1
- package/dist/{chunk-OKKJRRSS.cjs → chunk-7456ZWIM.cjs} +32 -14
- package/dist/chunk-7456ZWIM.cjs.map +1 -0
- package/dist/{chunk-D5VCCQ4L.js → chunk-7IKOVR4F.js} +5 -5
- package/dist/{chunk-D5VCCQ4L.js.map → chunk-7IKOVR4F.js.map} +1 -1
- package/dist/{chunk-K4NN2KQQ.cjs → chunk-AV4YSAZL.cjs} +6 -2
- package/dist/chunk-AV4YSAZL.cjs.map +1 -0
- package/dist/{chunk-7USX5P3I.js → chunk-AYVJ4EXL.js} +28 -5
- package/dist/chunk-AYVJ4EXL.js.map +1 -0
- package/dist/{chunk-B6D4D2CY.cjs → chunk-BF7IH4JU.cjs} +297 -68
- package/dist/chunk-BF7IH4JU.cjs.map +1 -0
- package/dist/{chunk-5IZ346TV.cjs → chunk-BL7DAQXE.cjs} +7 -7
- package/dist/{chunk-5IZ346TV.cjs.map → chunk-BL7DAQXE.cjs.map} +1 -1
- package/dist/{chunk-ZFZ6HQFT.cjs → chunk-BZUTYPXP.cjs} +210 -187
- package/dist/chunk-BZUTYPXP.cjs.map +1 -0
- package/dist/{chunk-UORUVXKY.js → chunk-DBHNKGT2.js} +6 -6
- package/dist/{chunk-UORUVXKY.js.map → chunk-DBHNKGT2.js.map} +1 -1
- package/dist/{chunk-GRMC2OYN.js → chunk-FA4PTEBK.js} +6 -3
- package/dist/chunk-FA4PTEBK.js.map +1 -0
- package/dist/{chunk-QVVWKMFM.cjs → chunk-GXXNF6NF.cjs} +25 -25
- package/dist/{chunk-QVVWKMFM.cjs.map → chunk-GXXNF6NF.cjs.map} +1 -1
- package/dist/{chunk-GVHBM6VU.cjs → chunk-H3DHOME4.cjs} +29 -11
- package/dist/chunk-H3DHOME4.cjs.map +1 -0
- package/dist/{chunk-ABA3KD3X.js → chunk-HRT662B6.js} +3 -3
- package/dist/{chunk-ABA3KD3X.js.map → chunk-HRT662B6.js.map} +1 -1
- package/dist/chunk-IHVB4C5U.cjs +4 -0
- package/dist/{chunk-ROOVGRNA.cjs.map → chunk-IHVB4C5U.cjs.map} +1 -1
- package/dist/{chunk-FB6O7FNK.js → chunk-IM6BRUQI.js} +9 -9
- package/dist/{chunk-FB6O7FNK.js.map → chunk-IM6BRUQI.js.map} +1 -1
- package/dist/{chunk-6LHF5UDX.cjs → chunk-INENOZKZ.cjs} +9 -9
- package/dist/{chunk-6LHF5UDX.cjs.map → chunk-INENOZKZ.cjs.map} +1 -1
- package/dist/{chunk-PYNUWPGW.cjs → chunk-JVL4ANDA.cjs} +19 -19
- package/dist/{chunk-PYNUWPGW.cjs.map → chunk-JVL4ANDA.cjs.map} +1 -1
- package/dist/{chunk-OVWOD5GI.cjs → chunk-JWE3L5J2.cjs} +20 -20
- package/dist/{chunk-OVWOD5GI.cjs.map → chunk-JWE3L5J2.cjs.map} +1 -1
- package/dist/{chunk-HDPQ3LEE.js → chunk-K7AE4BHR.js} +4 -4
- package/dist/{chunk-HDPQ3LEE.js.map → chunk-K7AE4BHR.js.map} +1 -1
- package/dist/{chunk-4K2NKQGN.cjs → chunk-KCRQQDEF.cjs} +201 -196
- package/dist/chunk-KCRQQDEF.cjs.map +1 -0
- package/dist/{chunk-CX5I6VS4.js → chunk-KRFGPA2H.js} +280 -69
- package/dist/chunk-KRFGPA2H.js.map +1 -0
- package/dist/{chunk-OXS5X7PW.cjs → chunk-LKZQG2ZZ.cjs} +13 -13
- package/dist/{chunk-OXS5X7PW.cjs.map → chunk-LKZQG2ZZ.cjs.map} +1 -1
- package/dist/{chunk-W2QYKEBN.js → chunk-MJF7NZEF.js} +545 -33
- package/dist/chunk-MJF7NZEF.js.map +1 -0
- package/dist/{chunk-SLHDZJ4B.js → chunk-PMWMEK4T.js} +5 -4
- package/dist/chunk-PMWMEK4T.js.map +1 -0
- package/dist/chunk-S43VACTO.js +3 -0
- package/dist/{chunk-DMX7MC4N.js.map → chunk-S43VACTO.js.map} +1 -1
- package/dist/{chunk-X36INADV.cjs → chunk-V2NQOABM.cjs} +563 -51
- package/dist/chunk-V2NQOABM.cjs.map +1 -0
- package/dist/{chunk-IR4WRS3N.js → chunk-W4I7AX2S.js} +31 -13
- package/dist/chunk-W4I7AX2S.js.map +1 -0
- package/dist/{chunk-OYAHOEQP.js → chunk-W6QY3O3X.js} +27 -9
- package/dist/chunk-W6QY3O3X.js.map +1 -0
- package/dist/{chunk-MP2VGF73.js → chunk-WNI6ACXE.js} +3 -3
- package/dist/{chunk-MP2VGF73.js.map → chunk-WNI6ACXE.js.map} +1 -1
- package/dist/{chunk-VVR3SFKH.cjs → chunk-XC6ZFHUA.cjs} +70 -70
- package/dist/{chunk-VVR3SFKH.cjs.map → chunk-XC6ZFHUA.cjs.map} +1 -1
- package/dist/{chunk-3UM5VCQ5.cjs → chunk-XNWKYVLQ.cjs} +3 -3
- package/dist/{chunk-3UM5VCQ5.cjs.map → chunk-XNWKYVLQ.cjs.map} +1 -1
- package/dist/{chunk-64565EZF.cjs → chunk-XQRTJIC7.cjs} +22 -22
- package/dist/{chunk-64565EZF.cjs.map → chunk-XQRTJIC7.cjs.map} +1 -1
- package/dist/{chunk-T5XU5TAV.cjs → chunk-XRW4AYLH.cjs} +82 -82
- package/dist/{chunk-T5XU5TAV.cjs.map → chunk-XRW4AYLH.cjs.map} +1 -1
- package/dist/{chunk-YBVRBNRY.js → chunk-YIBYKN6M.js} +7 -7
- package/dist/{chunk-YBVRBNRY.js.map → chunk-YIBYKN6M.js.map} +1 -1
- package/dist/datasets/dataset.d.ts +1 -0
- package/dist/datasets/dataset.d.ts.map +1 -1
- package/dist/datasets/experiment/index.d.ts.map +1 -1
- package/dist/datasets/index.cjs +17 -17
- package/dist/datasets/index.js +2 -2
- package/dist/datasets/manager.d.ts +1 -0
- package/dist/datasets/manager.d.ts.map +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +611 -534
- package/dist/docs/references/reference-configuration.md +24 -0
- package/dist/docs/references/reference-core-mastra-model-gateway.md +2 -0
- 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 +17 -17
- package/dist/harness/index.js +7 -7
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/integration/index.cjs +2 -2
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.cjs +16 -16
- package/dist/llm/index.js +5 -5
- package/dist/llm/model/gateways/models-dev.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +11 -2
- 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-MIC2CW43.cjs.map → models-dev-5X6CFNIO.cjs.map} +1 -1
- package/dist/models-dev-NFYFNV6D.js +3 -0
- package/dist/{models-dev-VDZIOMAC.js.map → models-dev-NFYFNV6D.js.map} +1 -1
- package/dist/netlify-EYSCS3HJ.js +3 -0
- package/dist/{netlify-2CGMKEKT.js.map → netlify-EYSCS3HJ.js.map} +1 -1
- package/dist/netlify-MZJ7FN5B.cjs +12 -0
- package/dist/{netlify-KZ4HQR5N.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/no-op.d.ts +14 -1
- package/dist/observability/no-op.d.ts.map +1 -1
- package/dist/observability/types/core.d.ts +35 -4
- package/dist/observability/types/core.d.ts.map +1 -1
- package/dist/observability/types/feedback.d.ts +42 -11
- package/dist/observability/types/feedback.d.ts.map +1 -1
- package/dist/observability/types/logging.d.ts +6 -9
- package/dist/observability/types/logging.d.ts.map +1 -1
- package/dist/observability/types/metrics.d.ts +6 -4
- package/dist/observability/types/metrics.d.ts.map +1 -1
- package/dist/observability/types/scores.d.ts +25 -10
- package/dist/observability/types/scores.d.ts.map +1 -1
- package/dist/observability/types/tracing.d.ts +14 -5
- 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/processors/runner.d.ts.map +1 -1
- package/dist/provider-registry-ODJKK7NU.js +3 -0
- package/dist/{provider-registry-QRWUBN5N.js.map → provider-registry-ODJKK7NU.js.map} +1 -1
- package/dist/provider-registry-YGVNXVGE.cjs +40 -0
- package/dist/{provider-registry-HGWTTWCL.cjs.map → provider-registry-YGVNXVGE.cjs.map} +1 -1
- package/dist/provider-registry.json +27 -9
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/server/types.d.ts +16 -0
- package/dist/server/types.d.ts.map +1 -1
- package/dist/storage/constants.cjs +56 -56
- package/dist/storage/constants.d.ts.map +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/datasets/inmemory.d.ts.map +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/record-builders.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/domains/observability/tracing.d.ts +8 -8
- package/dist/storage/domains/shared.d.ts +1 -1
- package/dist/storage/domains/shared.d.ts.map +1 -1
- package/dist/storage/index.cjs +340 -268
- package/dist/storage/index.js +3 -3
- package/dist/storage/types.d.ts +3 -0
- package/dist/storage/types.d.ts.map +1 -1
- 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/tools/index.cjs +11 -7
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/is-vercel-tool.cjs +2 -2
- package/dist/tools/is-vercel-tool.js +1 -1
- package/dist/tools/validation.d.ts +1 -0
- package/dist/tools/validation.d.ts.map +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/dist/workspace/index.cjs +68 -68
- package/dist/workspace/index.js +1 -1
- package/package.json +4 -4
- package/src/llm/model/provider-types.generated.d.ts +11 -2
- package/dist/chunk-32NEFSTI.js.map +0 -1
- package/dist/chunk-4K2NKQGN.cjs.map +0 -1
- package/dist/chunk-7USX5P3I.js.map +0 -1
- package/dist/chunk-B6D4D2CY.cjs.map +0 -1
- package/dist/chunk-CX5I6VS4.js.map +0 -1
- package/dist/chunk-DMX7MC4N.js +0 -3
- package/dist/chunk-GRMC2OYN.js.map +0 -1
- package/dist/chunk-GVHBM6VU.cjs.map +0 -1
- package/dist/chunk-IR4WRS3N.js.map +0 -1
- package/dist/chunk-K4NN2KQQ.cjs.map +0 -1
- package/dist/chunk-OKKJRRSS.cjs.map +0 -1
- package/dist/chunk-OYAHOEQP.js.map +0 -1
- package/dist/chunk-QXPUTX3W.cjs.map +0 -1
- package/dist/chunk-ROOVGRNA.cjs +0 -4
- package/dist/chunk-SLHDZJ4B.js.map +0 -1
- package/dist/chunk-W2QYKEBN.js.map +0 -1
- package/dist/chunk-X36INADV.cjs.map +0 -1
- package/dist/chunk-ZFZ6HQFT.cjs.map +0 -1
- package/dist/models-dev-MIC2CW43.cjs +0 -12
- package/dist/models-dev-VDZIOMAC.js +0 -3
- package/dist/netlify-2CGMKEKT.js +0 -3
- package/dist/netlify-KZ4HQR5N.cjs +0 -12
- package/dist/provider-registry-HGWTTWCL.cjs +0 -40
- package/dist/provider-registry-QRWUBN5N.js +0 -3
|
@@ -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
|
|
@@ -1056,7 +1120,9 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1056
1120
|
if (filters.experimentId !== void 0 && m.experimentId !== filters.experimentId) return false;
|
|
1057
1121
|
if (filters.serviceName !== void 0 && m.serviceName !== filters.serviceName) return false;
|
|
1058
1122
|
if (filters.environment !== void 0 && m.environment !== filters.environment) return false;
|
|
1059
|
-
|
|
1123
|
+
const metricExecutionSource = m.executionSource ?? m.source ?? null;
|
|
1124
|
+
if (filters.executionSource !== void 0 && metricExecutionSource !== filters.executionSource) return false;
|
|
1125
|
+
if (filters.source !== void 0 && metricExecutionSource !== filters.source) return false;
|
|
1060
1126
|
if (filters.parentEntityType !== void 0 && m.parentEntityType !== filters.parentEntityType) return false;
|
|
1061
1127
|
if (filters.parentEntityName !== void 0 && m.parentEntityName !== filters.parentEntityName) return false;
|
|
1062
1128
|
if (filters.rootEntityType !== void 0 && m.rootEntityType !== filters.rootEntityType) return false;
|
|
@@ -1076,7 +1142,7 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1076
1142
|
return true;
|
|
1077
1143
|
});
|
|
1078
1144
|
}
|
|
1079
|
-
aggregate(values, type) {
|
|
1145
|
+
aggregate(values, type, timestamps) {
|
|
1080
1146
|
if (values.length === 0) return null;
|
|
1081
1147
|
switch (type) {
|
|
1082
1148
|
case "sum":
|
|
@@ -1089,12 +1155,37 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1089
1155
|
return Math.max(...values);
|
|
1090
1156
|
case "count":
|
|
1091
1157
|
return values.length;
|
|
1092
|
-
case "last":
|
|
1093
|
-
|
|
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
|
+
}
|
|
1094
1173
|
default:
|
|
1095
1174
|
return values.reduce((a, b) => a + b, 0);
|
|
1096
1175
|
}
|
|
1097
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
|
+
}
|
|
1098
1189
|
/**
|
|
1099
1190
|
* Cost is returned alongside value-based OLAP results so callers can derive
|
|
1100
1191
|
* token and monetary views from the same filtered scan.
|
|
@@ -1433,7 +1524,9 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1433
1524
|
if (filters.rootEntityName !== void 0 && log.rootEntityName !== filters.rootEntityName) return false;
|
|
1434
1525
|
if (filters.serviceName !== void 0 && log.serviceName !== filters.serviceName) return false;
|
|
1435
1526
|
if (filters.environment !== void 0 && log.environment !== filters.environment) return false;
|
|
1436
|
-
|
|
1527
|
+
const logExecutionSource = log.executionSource ?? log.source ?? null;
|
|
1528
|
+
if (filters.executionSource !== void 0 && logExecutionSource !== filters.executionSource) return false;
|
|
1529
|
+
if (filters.source !== void 0 && logExecutionSource !== filters.source) return false;
|
|
1437
1530
|
if (filters.experimentId !== void 0 && log.experimentId !== filters.experimentId) return false;
|
|
1438
1531
|
if (filters.tags != null && filters.tags.length > 0) {
|
|
1439
1532
|
if (log.tags == null) return false;
|
|
@@ -1447,11 +1540,21 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1447
1540
|
// Scores
|
|
1448
1541
|
// ============================================================================
|
|
1449
1542
|
async createScore(args) {
|
|
1450
|
-
|
|
1543
|
+
const scoreSource = args.score.scoreSource ?? args.score.source ?? null;
|
|
1544
|
+
this.db.scoreRecords.push({
|
|
1545
|
+
...args.score,
|
|
1546
|
+
scoreSource,
|
|
1547
|
+
source: scoreSource
|
|
1548
|
+
});
|
|
1451
1549
|
}
|
|
1452
1550
|
async batchCreateScores(args) {
|
|
1453
1551
|
for (const score of args.scores) {
|
|
1454
|
-
|
|
1552
|
+
const scoreSource = score.scoreSource ?? score.source ?? null;
|
|
1553
|
+
this.db.scoreRecords.push({
|
|
1554
|
+
...score,
|
|
1555
|
+
scoreSource,
|
|
1556
|
+
source: scoreSource
|
|
1557
|
+
});
|
|
1455
1558
|
}
|
|
1456
1559
|
}
|
|
1457
1560
|
async listScores(args) {
|
|
@@ -1480,22 +1583,229 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1480
1583
|
}
|
|
1481
1584
|
if (filters.traceId !== void 0 && score.traceId !== filters.traceId) return false;
|
|
1482
1585
|
if (filters.spanId !== void 0 && score.spanId !== filters.spanId) return false;
|
|
1586
|
+
if (filters.entityType !== void 0 && score.entityType !== filters.entityType) return false;
|
|
1587
|
+
if (filters.entityName !== void 0 && score.entityName !== filters.entityName) return false;
|
|
1588
|
+
if (filters.userId !== void 0 && score.userId !== filters.userId) return false;
|
|
1589
|
+
if (filters.organizationId !== void 0 && score.organizationId !== filters.organizationId) return false;
|
|
1590
|
+
if (filters.resourceId !== void 0 && score.resourceId !== filters.resourceId) return false;
|
|
1591
|
+
if (filters.runId !== void 0 && score.runId !== filters.runId) return false;
|
|
1592
|
+
if (filters.sessionId !== void 0 && score.sessionId !== filters.sessionId) return false;
|
|
1593
|
+
if (filters.threadId !== void 0 && score.threadId !== filters.threadId) return false;
|
|
1594
|
+
if (filters.requestId !== void 0 && score.requestId !== filters.requestId) return false;
|
|
1595
|
+
if (filters.parentEntityType !== void 0 && score.parentEntityType !== filters.parentEntityType) return false;
|
|
1596
|
+
if (filters.parentEntityName !== void 0 && score.parentEntityName !== filters.parentEntityName) return false;
|
|
1597
|
+
if (filters.rootEntityType !== void 0 && score.rootEntityType !== filters.rootEntityType) return false;
|
|
1598
|
+
if (filters.rootEntityName !== void 0 && score.rootEntityName !== filters.rootEntityName) return false;
|
|
1599
|
+
if (filters.serviceName !== void 0 && score.serviceName !== filters.serviceName) return false;
|
|
1600
|
+
if (filters.environment !== void 0 && score.environment !== filters.environment) return false;
|
|
1601
|
+
if (filters.executionSource !== void 0 && score.executionSource !== filters.executionSource) return false;
|
|
1483
1602
|
if (filters.scorerId !== void 0) {
|
|
1484
1603
|
const names = Array.isArray(filters.scorerId) ? filters.scorerId : [filters.scorerId];
|
|
1485
1604
|
if (!names.includes(score.scorerId)) return false;
|
|
1486
1605
|
}
|
|
1606
|
+
const scoreSource = score.scoreSource ?? score.source ?? null;
|
|
1607
|
+
if (filters.scoreSource !== void 0 && scoreSource !== filters.scoreSource) return false;
|
|
1608
|
+
if (filters.source !== void 0 && scoreSource !== filters.source) return false;
|
|
1487
1609
|
if (filters.experimentId !== void 0 && score.experimentId !== filters.experimentId) return false;
|
|
1610
|
+
if (filters.tags != null && filters.tags.length > 0) {
|
|
1611
|
+
if (score.tags == null) return false;
|
|
1612
|
+
for (const tag of filters.tags) {
|
|
1613
|
+
if (!score.tags.includes(tag)) return false;
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1488
1616
|
return true;
|
|
1489
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
|
+
}
|
|
1490
1790
|
// ============================================================================
|
|
1491
1791
|
// Feedback
|
|
1492
1792
|
// ============================================================================
|
|
1493
1793
|
async createFeedback(args) {
|
|
1494
|
-
this.db.feedbackRecords.push(
|
|
1794
|
+
this.db.feedbackRecords.push({
|
|
1795
|
+
...args.feedback,
|
|
1796
|
+
feedbackSource: args.feedback.feedbackSource ?? args.feedback.source ?? "",
|
|
1797
|
+
source: args.feedback.feedbackSource ?? args.feedback.source ?? "",
|
|
1798
|
+
feedbackUserId: args.feedback.feedbackUserId ?? args.feedback.userId ?? (typeof args.feedback.metadata?.userId === "string" ? args.feedback.metadata.userId : null)
|
|
1799
|
+
});
|
|
1495
1800
|
}
|
|
1496
1801
|
async batchCreateFeedback(args) {
|
|
1497
1802
|
for (const fb of args.feedbacks) {
|
|
1498
|
-
this.db.feedbackRecords.push(
|
|
1803
|
+
this.db.feedbackRecords.push({
|
|
1804
|
+
...fb,
|
|
1805
|
+
feedbackSource: fb.feedbackSource ?? fb.source ?? "",
|
|
1806
|
+
source: fb.feedbackSource ?? fb.source ?? "",
|
|
1807
|
+
feedbackUserId: fb.feedbackUserId ?? fb.userId ?? (typeof fb.metadata?.userId === "string" ? fb.metadata.userId : null)
|
|
1808
|
+
});
|
|
1499
1809
|
}
|
|
1500
1810
|
}
|
|
1501
1811
|
async listFeedback(args) {
|
|
@@ -1512,6 +1822,174 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1512
1822
|
pagination: { total, page, perPage, hasMore: start + perPage < total }
|
|
1513
1823
|
};
|
|
1514
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
|
+
}
|
|
1515
1993
|
feedbackMatchesFilters(fb, filters) {
|
|
1516
1994
|
if (!filters) return true;
|
|
1517
1995
|
if (filters.timestamp) {
|
|
@@ -1520,13 +1998,37 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1520
1998
|
}
|
|
1521
1999
|
if (filters.traceId !== void 0 && fb.traceId !== filters.traceId) return false;
|
|
1522
2000
|
if (filters.spanId !== void 0 && fb.spanId !== filters.spanId) return false;
|
|
2001
|
+
if (filters.entityType !== void 0 && fb.entityType !== filters.entityType) return false;
|
|
2002
|
+
if (filters.entityName !== void 0 && fb.entityName !== filters.entityName) return false;
|
|
2003
|
+
if (filters.userId !== void 0 && fb.userId !== filters.userId) return false;
|
|
2004
|
+
if (filters.organizationId !== void 0 && fb.organizationId !== filters.organizationId) return false;
|
|
2005
|
+
if (filters.resourceId !== void 0 && fb.resourceId !== filters.resourceId) return false;
|
|
2006
|
+
if (filters.runId !== void 0 && fb.runId !== filters.runId) return false;
|
|
2007
|
+
if (filters.sessionId !== void 0 && fb.sessionId !== filters.sessionId) return false;
|
|
2008
|
+
if (filters.threadId !== void 0 && fb.threadId !== filters.threadId) return false;
|
|
2009
|
+
if (filters.requestId !== void 0 && fb.requestId !== filters.requestId) return false;
|
|
2010
|
+
if (filters.parentEntityType !== void 0 && fb.parentEntityType !== filters.parentEntityType) return false;
|
|
2011
|
+
if (filters.parentEntityName !== void 0 && fb.parentEntityName !== filters.parentEntityName) return false;
|
|
2012
|
+
if (filters.rootEntityType !== void 0 && fb.rootEntityType !== filters.rootEntityType) return false;
|
|
2013
|
+
if (filters.rootEntityName !== void 0 && fb.rootEntityName !== filters.rootEntityName) return false;
|
|
2014
|
+
if (filters.serviceName !== void 0 && fb.serviceName !== filters.serviceName) return false;
|
|
2015
|
+
if (filters.environment !== void 0 && fb.environment !== filters.environment) return false;
|
|
2016
|
+
if (filters.executionSource !== void 0 && fb.executionSource !== filters.executionSource) return false;
|
|
1523
2017
|
if (filters.feedbackType !== void 0) {
|
|
1524
2018
|
const types = Array.isArray(filters.feedbackType) ? filters.feedbackType : [filters.feedbackType];
|
|
1525
2019
|
if (!types.includes(fb.feedbackType)) return false;
|
|
1526
2020
|
}
|
|
1527
|
-
|
|
2021
|
+
const feedbackSource = fb.feedbackSource ?? fb.source ?? "";
|
|
2022
|
+
if (filters.feedbackSource !== void 0 && feedbackSource !== filters.feedbackSource) return false;
|
|
2023
|
+
if (filters.source !== void 0 && feedbackSource !== filters.source) return false;
|
|
1528
2024
|
if (filters.experimentId !== void 0 && fb.experimentId !== filters.experimentId) return false;
|
|
1529
|
-
if (filters.
|
|
2025
|
+
if (filters.feedbackUserId !== void 0 && fb.feedbackUserId !== filters.feedbackUserId) return false;
|
|
2026
|
+
if (filters.tags != null && filters.tags.length > 0) {
|
|
2027
|
+
if (fb.tags == null) return false;
|
|
2028
|
+
for (const tag of filters.tags) {
|
|
2029
|
+
if (!fb.tags.includes(tag)) return false;
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
1530
2032
|
return true;
|
|
1531
2033
|
}
|
|
1532
2034
|
};
|
|
@@ -1564,8 +2066,6 @@ function serializeSpanAttributes(span) {
|
|
|
1564
2066
|
}
|
|
1565
2067
|
function buildCorrelationRecordFields(context) {
|
|
1566
2068
|
return {
|
|
1567
|
-
traceId: context?.traceId ?? null,
|
|
1568
|
-
spanId: context?.spanId ?? null,
|
|
1569
2069
|
tags: context?.tags ?? null,
|
|
1570
2070
|
entityType: context?.entityType ?? null,
|
|
1571
2071
|
entityId: context?.entityId ?? null,
|
|
@@ -1584,7 +2084,7 @@ function buildCorrelationRecordFields(context) {
|
|
|
1584
2084
|
threadId: context?.threadId ?? null,
|
|
1585
2085
|
requestId: context?.requestId ?? null,
|
|
1586
2086
|
environment: context?.environment ?? null,
|
|
1587
|
-
|
|
2087
|
+
executionSource: context?.source ?? null,
|
|
1588
2088
|
serviceName: context?.serviceName ?? null,
|
|
1589
2089
|
experimentId: context?.experimentId ?? null
|
|
1590
2090
|
};
|
|
@@ -1616,7 +2116,7 @@ function buildLegacyLogMetadataCorrelationFields(metadata) {
|
|
|
1616
2116
|
rootEntityType: toEntityType(getStringOrNull(metadata?.root_type) ?? void 0),
|
|
1617
2117
|
rootEntityName: getStringOrNull(metadata?.root_name),
|
|
1618
2118
|
environment: getStringOrNull(metadata?.environment),
|
|
1619
|
-
|
|
2119
|
+
executionSource: getStringOrNull(metadata?.source),
|
|
1620
2120
|
serviceName: getStringOrNull(metadata?.service_name)
|
|
1621
2121
|
};
|
|
1622
2122
|
}
|
|
@@ -1686,6 +2186,8 @@ function buildMetricRecord(event) {
|
|
|
1686
2186
|
name: m.name,
|
|
1687
2187
|
value: m.value,
|
|
1688
2188
|
labels,
|
|
2189
|
+
traceId: m.traceId ?? m.correlationContext?.traceId ?? null,
|
|
2190
|
+
spanId: m.spanId ?? m.correlationContext?.spanId ?? null,
|
|
1689
2191
|
...correlationFields,
|
|
1690
2192
|
scope: null,
|
|
1691
2193
|
entityType: correlationFields.entityType ?? legacyCorrelationFields.entityType ?? null,
|
|
@@ -1711,8 +2213,8 @@ function buildLogRecord(event) {
|
|
|
1711
2213
|
message: l.message,
|
|
1712
2214
|
data: l.data ?? null,
|
|
1713
2215
|
...correlationFields,
|
|
1714
|
-
traceId:
|
|
1715
|
-
spanId:
|
|
2216
|
+
traceId: l.traceId ?? l.correlationContext?.traceId ?? null,
|
|
2217
|
+
spanId: l.spanId ?? l.correlationContext?.spanId ?? null,
|
|
1716
2218
|
tags: correlationFields.tags ?? l.tags ?? null,
|
|
1717
2219
|
entityType: correlationFields.entityType ?? legacyCorrelationFields.entityType ?? null,
|
|
1718
2220
|
entityName: correlationFields.entityName ?? legacyCorrelationFields.entityName ?? null,
|
|
@@ -1721,7 +2223,7 @@ function buildLogRecord(event) {
|
|
|
1721
2223
|
rootEntityType: correlationFields.rootEntityType ?? legacyCorrelationFields.rootEntityType ?? null,
|
|
1722
2224
|
rootEntityName: correlationFields.rootEntityName ?? legacyCorrelationFields.rootEntityName ?? null,
|
|
1723
2225
|
environment: correlationFields.environment ?? legacyCorrelationFields.environment ?? null,
|
|
1724
|
-
|
|
2226
|
+
executionSource: correlationFields.executionSource ?? legacyCorrelationFields.executionSource ?? null,
|
|
1725
2227
|
serviceName: correlationFields.serviceName ?? legacyCorrelationFields.serviceName ?? null,
|
|
1726
2228
|
scope: null,
|
|
1727
2229
|
metadata: l.metadata ?? null
|
|
@@ -1729,33 +2231,41 @@ function buildLogRecord(event) {
|
|
|
1729
2231
|
}
|
|
1730
2232
|
function buildScoreRecord(event) {
|
|
1731
2233
|
const s = event.score;
|
|
2234
|
+
const correlationFields = buildCorrelationRecordFields(s.correlationContext);
|
|
1732
2235
|
return {
|
|
1733
2236
|
timestamp: s.timestamp,
|
|
1734
|
-
traceId: s.traceId,
|
|
1735
|
-
spanId: s.spanId ?? null,
|
|
2237
|
+
traceId: s.traceId ?? s.correlationContext?.traceId ?? null,
|
|
2238
|
+
spanId: s.spanId ?? s.correlationContext?.spanId ?? null,
|
|
1736
2239
|
scorerId: s.scorerId,
|
|
1737
2240
|
scorerVersion: s.scorerVersion ?? null,
|
|
1738
|
-
|
|
2241
|
+
scoreSource: s.scoreSource ?? s.source ?? null,
|
|
2242
|
+
source: s.scoreSource ?? s.source ?? null,
|
|
1739
2243
|
score: s.score,
|
|
1740
2244
|
reason: s.reason ?? null,
|
|
1741
|
-
|
|
2245
|
+
...correlationFields,
|
|
2246
|
+
experimentId: correlationFields.experimentId ?? s.experimentId ?? null,
|
|
2247
|
+
scope: null,
|
|
1742
2248
|
scoreTraceId: s.scoreTraceId ?? null,
|
|
1743
2249
|
metadata: s.metadata ?? null
|
|
1744
2250
|
};
|
|
1745
2251
|
}
|
|
1746
2252
|
function buildFeedbackRecord(event) {
|
|
1747
2253
|
const fb = event.feedback;
|
|
1748
|
-
const
|
|
2254
|
+
const correlationFields = buildCorrelationRecordFields(fb.correlationContext);
|
|
1749
2255
|
return {
|
|
1750
2256
|
timestamp: fb.timestamp,
|
|
1751
|
-
traceId: fb.traceId,
|
|
1752
|
-
spanId: fb.spanId ?? null,
|
|
1753
|
-
|
|
2257
|
+
traceId: fb.traceId ?? fb.correlationContext?.traceId ?? null,
|
|
2258
|
+
spanId: fb.spanId ?? fb.correlationContext?.spanId ?? null,
|
|
2259
|
+
feedbackSource: fb.feedbackSource ?? fb.source ?? "",
|
|
2260
|
+
source: fb.feedbackSource ?? fb.source ?? "",
|
|
1754
2261
|
feedbackType: fb.feedbackType,
|
|
1755
2262
|
value: fb.value,
|
|
1756
2263
|
comment: fb.comment ?? null,
|
|
1757
|
-
|
|
1758
|
-
|
|
2264
|
+
...correlationFields,
|
|
2265
|
+
experimentId: correlationFields.experimentId ?? fb.experimentId ?? null,
|
|
2266
|
+
feedbackUserId: fb.feedbackUserId ?? fb.userId ?? (typeof fb.metadata?.userId === "string" ? fb.metadata.userId : null),
|
|
2267
|
+
scope: null,
|
|
2268
|
+
sourceId: fb.sourceId ?? null,
|
|
1759
2269
|
metadata: fb.metadata ?? null
|
|
1760
2270
|
};
|
|
1761
2271
|
}
|
|
@@ -2473,6 +2983,7 @@ var DatasetsInMemory = class extends DatasetsStorage {
|
|
|
2473
2983
|
requestContextSchema: input.requestContextSchema,
|
|
2474
2984
|
targetType: input.targetType,
|
|
2475
2985
|
targetIds: input.targetIds,
|
|
2986
|
+
scorerIds: input.scorerIds ?? null,
|
|
2476
2987
|
version: 0,
|
|
2477
2988
|
createdAt: now,
|
|
2478
2989
|
updatedAt: now
|
|
@@ -2500,6 +3011,7 @@ var DatasetsInMemory = class extends DatasetsStorage {
|
|
|
2500
3011
|
tags: args.tags !== void 0 ? args.tags : existing.tags,
|
|
2501
3012
|
targetType: args.targetType !== void 0 ? args.targetType : existing.targetType,
|
|
2502
3013
|
targetIds: args.targetIds !== void 0 ? args.targetIds : existing.targetIds,
|
|
3014
|
+
scorerIds: args.scorerIds !== void 0 ? args.scorerIds : existing.scorerIds,
|
|
2503
3015
|
updatedAt: /* @__PURE__ */ new Date()
|
|
2504
3016
|
};
|
|
2505
3017
|
this.db.datasets.set(args.id, updated);
|
|
@@ -8123,5 +8635,5 @@ var StoreOperationsInMemory = class extends StoreOperations {
|
|
|
8123
8635
|
};
|
|
8124
8636
|
|
|
8125
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 };
|
|
8126
|
-
//# sourceMappingURL=chunk-
|
|
8127
|
-
//# sourceMappingURL=chunk-
|
|
8638
|
+
//# sourceMappingURL=chunk-MJF7NZEF.js.map
|
|
8639
|
+
//# sourceMappingURL=chunk-MJF7NZEF.js.map
|