@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,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()));
|
|
@@ -1058,7 +1122,9 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1058
1122
|
if (filters.experimentId !== void 0 && m.experimentId !== filters.experimentId) return false;
|
|
1059
1123
|
if (filters.serviceName !== void 0 && m.serviceName !== filters.serviceName) return false;
|
|
1060
1124
|
if (filters.environment !== void 0 && m.environment !== filters.environment) return false;
|
|
1061
|
-
|
|
1125
|
+
const metricExecutionSource = m.executionSource ?? m.source ?? null;
|
|
1126
|
+
if (filters.executionSource !== void 0 && metricExecutionSource !== filters.executionSource) return false;
|
|
1127
|
+
if (filters.source !== void 0 && metricExecutionSource !== filters.source) return false;
|
|
1062
1128
|
if (filters.parentEntityType !== void 0 && m.parentEntityType !== filters.parentEntityType) return false;
|
|
1063
1129
|
if (filters.parentEntityName !== void 0 && m.parentEntityName !== filters.parentEntityName) return false;
|
|
1064
1130
|
if (filters.rootEntityType !== void 0 && m.rootEntityType !== filters.rootEntityType) return false;
|
|
@@ -1078,7 +1144,7 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1078
1144
|
return true;
|
|
1079
1145
|
});
|
|
1080
1146
|
}
|
|
1081
|
-
aggregate(values, type) {
|
|
1147
|
+
aggregate(values, type, timestamps) {
|
|
1082
1148
|
if (values.length === 0) return null;
|
|
1083
1149
|
switch (type) {
|
|
1084
1150
|
case "sum":
|
|
@@ -1091,12 +1157,37 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1091
1157
|
return Math.max(...values);
|
|
1092
1158
|
case "count":
|
|
1093
1159
|
return values.length;
|
|
1094
|
-
case "last":
|
|
1095
|
-
|
|
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
|
+
}
|
|
1096
1175
|
default:
|
|
1097
1176
|
return values.reduce((a, b) => a + b, 0);
|
|
1098
1177
|
}
|
|
1099
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
|
+
}
|
|
1100
1191
|
/**
|
|
1101
1192
|
* Cost is returned alongside value-based OLAP results so callers can derive
|
|
1102
1193
|
* token and monetary views from the same filtered scan.
|
|
@@ -1329,7 +1420,7 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1329
1420
|
return { values };
|
|
1330
1421
|
}
|
|
1331
1422
|
async getEntityTypes(_args) {
|
|
1332
|
-
const validTypes = new Set(Object.values(
|
|
1423
|
+
const validTypes = new Set(Object.values(chunkBF7IH4JU_cjs.EntityType));
|
|
1333
1424
|
const typeSet = /* @__PURE__ */ new Set();
|
|
1334
1425
|
for (const [, traceEntry] of this.db.traces) {
|
|
1335
1426
|
for (const span of Object.values(traceEntry.spans)) {
|
|
@@ -1391,7 +1482,7 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1391
1482
|
}
|
|
1392
1483
|
}
|
|
1393
1484
|
async listLogs(args) {
|
|
1394
|
-
const { filters, pagination, orderBy } =
|
|
1485
|
+
const { filters, pagination, orderBy } = chunkBF7IH4JU_cjs.listLogsArgsSchema.parse(args);
|
|
1395
1486
|
let matching = this.db.logRecords.filter((log) => this.logMatchesFilters(log, filters));
|
|
1396
1487
|
const dir = orderBy.direction === "DESC" ? -1 : 1;
|
|
1397
1488
|
matching.sort((a, b) => dir * (a.timestamp.getTime() - b.timestamp.getTime()));
|
|
@@ -1435,7 +1526,9 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1435
1526
|
if (filters.rootEntityName !== void 0 && log.rootEntityName !== filters.rootEntityName) return false;
|
|
1436
1527
|
if (filters.serviceName !== void 0 && log.serviceName !== filters.serviceName) return false;
|
|
1437
1528
|
if (filters.environment !== void 0 && log.environment !== filters.environment) return false;
|
|
1438
|
-
|
|
1529
|
+
const logExecutionSource = log.executionSource ?? log.source ?? null;
|
|
1530
|
+
if (filters.executionSource !== void 0 && logExecutionSource !== filters.executionSource) return false;
|
|
1531
|
+
if (filters.source !== void 0 && logExecutionSource !== filters.source) return false;
|
|
1439
1532
|
if (filters.experimentId !== void 0 && log.experimentId !== filters.experimentId) return false;
|
|
1440
1533
|
if (filters.tags != null && filters.tags.length > 0) {
|
|
1441
1534
|
if (log.tags == null) return false;
|
|
@@ -1449,15 +1542,25 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1449
1542
|
// Scores
|
|
1450
1543
|
// ============================================================================
|
|
1451
1544
|
async createScore(args) {
|
|
1452
|
-
|
|
1545
|
+
const scoreSource = args.score.scoreSource ?? args.score.source ?? null;
|
|
1546
|
+
this.db.scoreRecords.push({
|
|
1547
|
+
...args.score,
|
|
1548
|
+
scoreSource,
|
|
1549
|
+
source: scoreSource
|
|
1550
|
+
});
|
|
1453
1551
|
}
|
|
1454
1552
|
async batchCreateScores(args) {
|
|
1455
1553
|
for (const score of args.scores) {
|
|
1456
|
-
|
|
1554
|
+
const scoreSource = score.scoreSource ?? score.source ?? null;
|
|
1555
|
+
this.db.scoreRecords.push({
|
|
1556
|
+
...score,
|
|
1557
|
+
scoreSource,
|
|
1558
|
+
source: scoreSource
|
|
1559
|
+
});
|
|
1457
1560
|
}
|
|
1458
1561
|
}
|
|
1459
1562
|
async listScores(args) {
|
|
1460
|
-
const { filters, pagination, orderBy } =
|
|
1563
|
+
const { filters, pagination, orderBy } = chunkBF7IH4JU_cjs.listScoresArgsSchema.parse(args);
|
|
1461
1564
|
let matching = this.db.scoreRecords.filter((score) => this.scoreMatchesFilters(score, filters));
|
|
1462
1565
|
const dir = orderBy.direction === "DESC" ? -1 : 1;
|
|
1463
1566
|
if (orderBy.field === "score") {
|
|
@@ -1482,26 +1585,233 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1482
1585
|
}
|
|
1483
1586
|
if (filters.traceId !== void 0 && score.traceId !== filters.traceId) return false;
|
|
1484
1587
|
if (filters.spanId !== void 0 && score.spanId !== filters.spanId) return false;
|
|
1588
|
+
if (filters.entityType !== void 0 && score.entityType !== filters.entityType) return false;
|
|
1589
|
+
if (filters.entityName !== void 0 && score.entityName !== filters.entityName) return false;
|
|
1590
|
+
if (filters.userId !== void 0 && score.userId !== filters.userId) return false;
|
|
1591
|
+
if (filters.organizationId !== void 0 && score.organizationId !== filters.organizationId) return false;
|
|
1592
|
+
if (filters.resourceId !== void 0 && score.resourceId !== filters.resourceId) return false;
|
|
1593
|
+
if (filters.runId !== void 0 && score.runId !== filters.runId) return false;
|
|
1594
|
+
if (filters.sessionId !== void 0 && score.sessionId !== filters.sessionId) return false;
|
|
1595
|
+
if (filters.threadId !== void 0 && score.threadId !== filters.threadId) return false;
|
|
1596
|
+
if (filters.requestId !== void 0 && score.requestId !== filters.requestId) return false;
|
|
1597
|
+
if (filters.parentEntityType !== void 0 && score.parentEntityType !== filters.parentEntityType) return false;
|
|
1598
|
+
if (filters.parentEntityName !== void 0 && score.parentEntityName !== filters.parentEntityName) return false;
|
|
1599
|
+
if (filters.rootEntityType !== void 0 && score.rootEntityType !== filters.rootEntityType) return false;
|
|
1600
|
+
if (filters.rootEntityName !== void 0 && score.rootEntityName !== filters.rootEntityName) return false;
|
|
1601
|
+
if (filters.serviceName !== void 0 && score.serviceName !== filters.serviceName) return false;
|
|
1602
|
+
if (filters.environment !== void 0 && score.environment !== filters.environment) return false;
|
|
1603
|
+
if (filters.executionSource !== void 0 && score.executionSource !== filters.executionSource) return false;
|
|
1485
1604
|
if (filters.scorerId !== void 0) {
|
|
1486
1605
|
const names = Array.isArray(filters.scorerId) ? filters.scorerId : [filters.scorerId];
|
|
1487
1606
|
if (!names.includes(score.scorerId)) return false;
|
|
1488
1607
|
}
|
|
1608
|
+
const scoreSource = score.scoreSource ?? score.source ?? null;
|
|
1609
|
+
if (filters.scoreSource !== void 0 && scoreSource !== filters.scoreSource) return false;
|
|
1610
|
+
if (filters.source !== void 0 && scoreSource !== filters.source) return false;
|
|
1489
1611
|
if (filters.experimentId !== void 0 && score.experimentId !== filters.experimentId) return false;
|
|
1612
|
+
if (filters.tags != null && filters.tags.length > 0) {
|
|
1613
|
+
if (score.tags == null) return false;
|
|
1614
|
+
for (const tag of filters.tags) {
|
|
1615
|
+
if (!score.tags.includes(tag)) return false;
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1490
1618
|
return true;
|
|
1491
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
|
+
}
|
|
1492
1792
|
// ============================================================================
|
|
1493
1793
|
// Feedback
|
|
1494
1794
|
// ============================================================================
|
|
1495
1795
|
async createFeedback(args) {
|
|
1496
|
-
this.db.feedbackRecords.push(
|
|
1796
|
+
this.db.feedbackRecords.push({
|
|
1797
|
+
...args.feedback,
|
|
1798
|
+
feedbackSource: args.feedback.feedbackSource ?? args.feedback.source ?? "",
|
|
1799
|
+
source: args.feedback.feedbackSource ?? args.feedback.source ?? "",
|
|
1800
|
+
feedbackUserId: args.feedback.feedbackUserId ?? args.feedback.userId ?? (typeof args.feedback.metadata?.userId === "string" ? args.feedback.metadata.userId : null)
|
|
1801
|
+
});
|
|
1497
1802
|
}
|
|
1498
1803
|
async batchCreateFeedback(args) {
|
|
1499
1804
|
for (const fb of args.feedbacks) {
|
|
1500
|
-
this.db.feedbackRecords.push(
|
|
1805
|
+
this.db.feedbackRecords.push({
|
|
1806
|
+
...fb,
|
|
1807
|
+
feedbackSource: fb.feedbackSource ?? fb.source ?? "",
|
|
1808
|
+
source: fb.feedbackSource ?? fb.source ?? "",
|
|
1809
|
+
feedbackUserId: fb.feedbackUserId ?? fb.userId ?? (typeof fb.metadata?.userId === "string" ? fb.metadata.userId : null)
|
|
1810
|
+
});
|
|
1501
1811
|
}
|
|
1502
1812
|
}
|
|
1503
1813
|
async listFeedback(args) {
|
|
1504
|
-
const { filters, pagination, orderBy } =
|
|
1814
|
+
const { filters, pagination, orderBy } = chunkBF7IH4JU_cjs.listFeedbackArgsSchema.parse(args);
|
|
1505
1815
|
let matching = this.db.feedbackRecords.filter((fb) => this.feedbackMatchesFilters(fb, filters));
|
|
1506
1816
|
const dir = orderBy.direction === "DESC" ? -1 : 1;
|
|
1507
1817
|
matching.sort((a, b) => dir * (a.timestamp.getTime() - b.timestamp.getTime()));
|
|
@@ -1514,6 +1824,174 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1514
1824
|
pagination: { total, page, perPage, hasMore: start + perPage < total }
|
|
1515
1825
|
};
|
|
1516
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
|
+
}
|
|
1517
1995
|
feedbackMatchesFilters(fb, filters) {
|
|
1518
1996
|
if (!filters) return true;
|
|
1519
1997
|
if (filters.timestamp) {
|
|
@@ -1522,19 +2000,43 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1522
2000
|
}
|
|
1523
2001
|
if (filters.traceId !== void 0 && fb.traceId !== filters.traceId) return false;
|
|
1524
2002
|
if (filters.spanId !== void 0 && fb.spanId !== filters.spanId) return false;
|
|
2003
|
+
if (filters.entityType !== void 0 && fb.entityType !== filters.entityType) return false;
|
|
2004
|
+
if (filters.entityName !== void 0 && fb.entityName !== filters.entityName) return false;
|
|
2005
|
+
if (filters.userId !== void 0 && fb.userId !== filters.userId) return false;
|
|
2006
|
+
if (filters.organizationId !== void 0 && fb.organizationId !== filters.organizationId) return false;
|
|
2007
|
+
if (filters.resourceId !== void 0 && fb.resourceId !== filters.resourceId) return false;
|
|
2008
|
+
if (filters.runId !== void 0 && fb.runId !== filters.runId) return false;
|
|
2009
|
+
if (filters.sessionId !== void 0 && fb.sessionId !== filters.sessionId) return false;
|
|
2010
|
+
if (filters.threadId !== void 0 && fb.threadId !== filters.threadId) return false;
|
|
2011
|
+
if (filters.requestId !== void 0 && fb.requestId !== filters.requestId) return false;
|
|
2012
|
+
if (filters.parentEntityType !== void 0 && fb.parentEntityType !== filters.parentEntityType) return false;
|
|
2013
|
+
if (filters.parentEntityName !== void 0 && fb.parentEntityName !== filters.parentEntityName) return false;
|
|
2014
|
+
if (filters.rootEntityType !== void 0 && fb.rootEntityType !== filters.rootEntityType) return false;
|
|
2015
|
+
if (filters.rootEntityName !== void 0 && fb.rootEntityName !== filters.rootEntityName) return false;
|
|
2016
|
+
if (filters.serviceName !== void 0 && fb.serviceName !== filters.serviceName) return false;
|
|
2017
|
+
if (filters.environment !== void 0 && fb.environment !== filters.environment) return false;
|
|
2018
|
+
if (filters.executionSource !== void 0 && fb.executionSource !== filters.executionSource) return false;
|
|
1525
2019
|
if (filters.feedbackType !== void 0) {
|
|
1526
2020
|
const types = Array.isArray(filters.feedbackType) ? filters.feedbackType : [filters.feedbackType];
|
|
1527
2021
|
if (!types.includes(fb.feedbackType)) return false;
|
|
1528
2022
|
}
|
|
1529
|
-
|
|
2023
|
+
const feedbackSource = fb.feedbackSource ?? fb.source ?? "";
|
|
2024
|
+
if (filters.feedbackSource !== void 0 && feedbackSource !== filters.feedbackSource) return false;
|
|
2025
|
+
if (filters.source !== void 0 && feedbackSource !== filters.source) return false;
|
|
1530
2026
|
if (filters.experimentId !== void 0 && fb.experimentId !== filters.experimentId) return false;
|
|
1531
|
-
if (filters.
|
|
2027
|
+
if (filters.feedbackUserId !== void 0 && fb.feedbackUserId !== filters.feedbackUserId) return false;
|
|
2028
|
+
if (filters.tags != null && filters.tags.length > 0) {
|
|
2029
|
+
if (fb.tags == null) return false;
|
|
2030
|
+
for (const tag of filters.tags) {
|
|
2031
|
+
if (!fb.tags.includes(tag)) return false;
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
1532
2034
|
return true;
|
|
1533
2035
|
}
|
|
1534
2036
|
};
|
|
1535
2037
|
|
|
1536
2038
|
// src/storage/domains/observability/record-builders.ts
|
|
1537
|
-
var entityTypeValues = new Set(Object.values(
|
|
2039
|
+
var entityTypeValues = new Set(Object.values(chunkBF7IH4JU_cjs.EntityType));
|
|
1538
2040
|
function toEntityType(value) {
|
|
1539
2041
|
if (value && entityTypeValues.has(value)) {
|
|
1540
2042
|
return value;
|
|
@@ -1566,8 +2068,6 @@ function serializeSpanAttributes(span) {
|
|
|
1566
2068
|
}
|
|
1567
2069
|
function buildCorrelationRecordFields(context) {
|
|
1568
2070
|
return {
|
|
1569
|
-
traceId: context?.traceId ?? null,
|
|
1570
|
-
spanId: context?.spanId ?? null,
|
|
1571
2071
|
tags: context?.tags ?? null,
|
|
1572
2072
|
entityType: context?.entityType ?? null,
|
|
1573
2073
|
entityId: context?.entityId ?? null,
|
|
@@ -1586,7 +2086,7 @@ function buildCorrelationRecordFields(context) {
|
|
|
1586
2086
|
threadId: context?.threadId ?? null,
|
|
1587
2087
|
requestId: context?.requestId ?? null,
|
|
1588
2088
|
environment: context?.environment ?? null,
|
|
1589
|
-
|
|
2089
|
+
executionSource: context?.source ?? null,
|
|
1590
2090
|
serviceName: context?.serviceName ?? null,
|
|
1591
2091
|
experimentId: context?.experimentId ?? null
|
|
1592
2092
|
};
|
|
@@ -1618,7 +2118,7 @@ function buildLegacyLogMetadataCorrelationFields(metadata) {
|
|
|
1618
2118
|
rootEntityType: toEntityType(getStringOrNull(metadata?.root_type) ?? void 0),
|
|
1619
2119
|
rootEntityName: getStringOrNull(metadata?.root_name),
|
|
1620
2120
|
environment: getStringOrNull(metadata?.environment),
|
|
1621
|
-
|
|
2121
|
+
executionSource: getStringOrNull(metadata?.source),
|
|
1622
2122
|
serviceName: getStringOrNull(metadata?.service_name)
|
|
1623
2123
|
};
|
|
1624
2124
|
}
|
|
@@ -1688,6 +2188,8 @@ function buildMetricRecord(event) {
|
|
|
1688
2188
|
name: m.name,
|
|
1689
2189
|
value: m.value,
|
|
1690
2190
|
labels,
|
|
2191
|
+
traceId: m.traceId ?? m.correlationContext?.traceId ?? null,
|
|
2192
|
+
spanId: m.spanId ?? m.correlationContext?.spanId ?? null,
|
|
1691
2193
|
...correlationFields,
|
|
1692
2194
|
scope: null,
|
|
1693
2195
|
entityType: correlationFields.entityType ?? legacyCorrelationFields.entityType ?? null,
|
|
@@ -1713,8 +2215,8 @@ function buildLogRecord(event) {
|
|
|
1713
2215
|
message: l.message,
|
|
1714
2216
|
data: l.data ?? null,
|
|
1715
2217
|
...correlationFields,
|
|
1716
|
-
traceId:
|
|
1717
|
-
spanId:
|
|
2218
|
+
traceId: l.traceId ?? l.correlationContext?.traceId ?? null,
|
|
2219
|
+
spanId: l.spanId ?? l.correlationContext?.spanId ?? null,
|
|
1718
2220
|
tags: correlationFields.tags ?? l.tags ?? null,
|
|
1719
2221
|
entityType: correlationFields.entityType ?? legacyCorrelationFields.entityType ?? null,
|
|
1720
2222
|
entityName: correlationFields.entityName ?? legacyCorrelationFields.entityName ?? null,
|
|
@@ -1723,7 +2225,7 @@ function buildLogRecord(event) {
|
|
|
1723
2225
|
rootEntityType: correlationFields.rootEntityType ?? legacyCorrelationFields.rootEntityType ?? null,
|
|
1724
2226
|
rootEntityName: correlationFields.rootEntityName ?? legacyCorrelationFields.rootEntityName ?? null,
|
|
1725
2227
|
environment: correlationFields.environment ?? legacyCorrelationFields.environment ?? null,
|
|
1726
|
-
|
|
2228
|
+
executionSource: correlationFields.executionSource ?? legacyCorrelationFields.executionSource ?? null,
|
|
1727
2229
|
serviceName: correlationFields.serviceName ?? legacyCorrelationFields.serviceName ?? null,
|
|
1728
2230
|
scope: null,
|
|
1729
2231
|
metadata: l.metadata ?? null
|
|
@@ -1731,33 +2233,41 @@ function buildLogRecord(event) {
|
|
|
1731
2233
|
}
|
|
1732
2234
|
function buildScoreRecord(event) {
|
|
1733
2235
|
const s = event.score;
|
|
2236
|
+
const correlationFields = buildCorrelationRecordFields(s.correlationContext);
|
|
1734
2237
|
return {
|
|
1735
2238
|
timestamp: s.timestamp,
|
|
1736
|
-
traceId: s.traceId,
|
|
1737
|
-
spanId: s.spanId ?? null,
|
|
2239
|
+
traceId: s.traceId ?? s.correlationContext?.traceId ?? null,
|
|
2240
|
+
spanId: s.spanId ?? s.correlationContext?.spanId ?? null,
|
|
1738
2241
|
scorerId: s.scorerId,
|
|
1739
2242
|
scorerVersion: s.scorerVersion ?? null,
|
|
1740
|
-
|
|
2243
|
+
scoreSource: s.scoreSource ?? s.source ?? null,
|
|
2244
|
+
source: s.scoreSource ?? s.source ?? null,
|
|
1741
2245
|
score: s.score,
|
|
1742
2246
|
reason: s.reason ?? null,
|
|
1743
|
-
|
|
2247
|
+
...correlationFields,
|
|
2248
|
+
experimentId: correlationFields.experimentId ?? s.experimentId ?? null,
|
|
2249
|
+
scope: null,
|
|
1744
2250
|
scoreTraceId: s.scoreTraceId ?? null,
|
|
1745
2251
|
metadata: s.metadata ?? null
|
|
1746
2252
|
};
|
|
1747
2253
|
}
|
|
1748
2254
|
function buildFeedbackRecord(event) {
|
|
1749
2255
|
const fb = event.feedback;
|
|
1750
|
-
const
|
|
2256
|
+
const correlationFields = buildCorrelationRecordFields(fb.correlationContext);
|
|
1751
2257
|
return {
|
|
1752
2258
|
timestamp: fb.timestamp,
|
|
1753
|
-
traceId: fb.traceId,
|
|
1754
|
-
spanId: fb.spanId ?? null,
|
|
1755
|
-
|
|
2259
|
+
traceId: fb.traceId ?? fb.correlationContext?.traceId ?? null,
|
|
2260
|
+
spanId: fb.spanId ?? fb.correlationContext?.spanId ?? null,
|
|
2261
|
+
feedbackSource: fb.feedbackSource ?? fb.source ?? "",
|
|
2262
|
+
source: fb.feedbackSource ?? fb.source ?? "",
|
|
1756
2263
|
feedbackType: fb.feedbackType,
|
|
1757
2264
|
value: fb.value,
|
|
1758
2265
|
comment: fb.comment ?? null,
|
|
1759
|
-
|
|
1760
|
-
|
|
2266
|
+
...correlationFields,
|
|
2267
|
+
experimentId: correlationFields.experimentId ?? fb.experimentId ?? null,
|
|
2268
|
+
feedbackUserId: fb.feedbackUserId ?? fb.userId ?? (typeof fb.metadata?.userId === "string" ? fb.metadata.userId : null),
|
|
2269
|
+
scope: null,
|
|
2270
|
+
sourceId: fb.sourceId ?? null,
|
|
1761
2271
|
metadata: fb.metadata ?? null
|
|
1762
2272
|
};
|
|
1763
2273
|
}
|
|
@@ -1990,7 +2500,7 @@ var InMemoryAgentsStorage = class extends AgentsStorage {
|
|
|
1990
2500
|
if (metadata && Object.keys(metadata).length > 0) {
|
|
1991
2501
|
agents = agents.filter((agent) => {
|
|
1992
2502
|
if (!agent.metadata) return false;
|
|
1993
|
-
return Object.entries(metadata).every(([key, value]) =>
|
|
2503
|
+
return Object.entries(metadata).every(([key, value]) => chunkXQRTJIC7_cjs.deepEqual(agent.metadata[key], value));
|
|
1994
2504
|
});
|
|
1995
2505
|
}
|
|
1996
2506
|
const sortedAgents = this.sortAgents(agents, field, direction);
|
|
@@ -2475,6 +2985,7 @@ var DatasetsInMemory = class extends DatasetsStorage {
|
|
|
2475
2985
|
requestContextSchema: input.requestContextSchema,
|
|
2476
2986
|
targetType: input.targetType,
|
|
2477
2987
|
targetIds: input.targetIds,
|
|
2988
|
+
scorerIds: input.scorerIds ?? null,
|
|
2478
2989
|
version: 0,
|
|
2479
2990
|
createdAt: now,
|
|
2480
2991
|
updatedAt: now
|
|
@@ -2502,6 +3013,7 @@ var DatasetsInMemory = class extends DatasetsStorage {
|
|
|
2502
3013
|
tags: args.tags !== void 0 ? args.tags : existing.tags,
|
|
2503
3014
|
targetType: args.targetType !== void 0 ? args.targetType : existing.targetType,
|
|
2504
3015
|
targetIds: args.targetIds !== void 0 ? args.targetIds : existing.targetIds,
|
|
3016
|
+
scorerIds: args.scorerIds !== void 0 ? args.scorerIds : existing.scorerIds,
|
|
2505
3017
|
updatedAt: /* @__PURE__ */ new Date()
|
|
2506
3018
|
};
|
|
2507
3019
|
this.db.datasets.set(args.id, updated);
|
|
@@ -3181,7 +3693,7 @@ var InMemoryMCPClientsStorage = class extends MCPClientsStorage {
|
|
|
3181
3693
|
if (metadata && Object.keys(metadata).length > 0) {
|
|
3182
3694
|
configs = configs.filter((config) => {
|
|
3183
3695
|
if (!config.metadata) return false;
|
|
3184
|
-
return Object.entries(metadata).every(([key, value]) =>
|
|
3696
|
+
return Object.entries(metadata).every(([key, value]) => chunkXQRTJIC7_cjs.deepEqual(config.metadata[key], value));
|
|
3185
3697
|
});
|
|
3186
3698
|
}
|
|
3187
3699
|
const sortedConfigs = this.sortConfigs(configs, field, direction);
|
|
@@ -3449,7 +3961,7 @@ var InMemoryMCPServersStorage = class extends MCPServersStorage {
|
|
|
3449
3961
|
if (metadata && Object.keys(metadata).length > 0) {
|
|
3450
3962
|
configs = configs.filter((config) => {
|
|
3451
3963
|
if (!config.metadata) return false;
|
|
3452
|
-
return Object.entries(metadata).every(([key, value]) =>
|
|
3964
|
+
return Object.entries(metadata).every(([key, value]) => chunkXQRTJIC7_cjs.deepEqual(config.metadata[key], value));
|
|
3453
3965
|
});
|
|
3454
3966
|
}
|
|
3455
3967
|
const sortedConfigs = this.sortConfigs(configs, field, direction);
|
|
@@ -4914,7 +5426,7 @@ var InMemoryPromptBlocksStorage = class extends PromptBlocksStorage {
|
|
|
4914
5426
|
if (metadata && Object.keys(metadata).length > 0) {
|
|
4915
5427
|
blocks = blocks.filter((block) => {
|
|
4916
5428
|
if (!block.metadata) return false;
|
|
4917
|
-
return Object.entries(metadata).every(([key, value]) =>
|
|
5429
|
+
return Object.entries(metadata).every(([key, value]) => chunkXQRTJIC7_cjs.deepEqual(block.metadata[key], value));
|
|
4918
5430
|
});
|
|
4919
5431
|
}
|
|
4920
5432
|
const sortedBlocks = this.sortBlocks(blocks, field, direction);
|
|
@@ -5180,7 +5692,7 @@ var InMemoryScorerDefinitionsStorage = class extends ScorerDefinitionsStorage {
|
|
|
5180
5692
|
if (metadata && Object.keys(metadata).length > 0) {
|
|
5181
5693
|
scorers = scorers.filter((scorer) => {
|
|
5182
5694
|
if (!scorer.metadata) return false;
|
|
5183
|
-
return Object.entries(metadata).every(([key, value]) =>
|
|
5695
|
+
return Object.entries(metadata).every(([key, value]) => chunkXQRTJIC7_cjs.deepEqual(scorer.metadata[key], value));
|
|
5184
5696
|
});
|
|
5185
5697
|
}
|
|
5186
5698
|
const sortedScorers = this.sortScorers(scorers, field, direction);
|
|
@@ -6228,7 +6740,7 @@ var InMemoryWorkspacesStorage = class extends WorkspacesStorage {
|
|
|
6228
6740
|
if (metadata && Object.keys(metadata).length > 0) {
|
|
6229
6741
|
configs = configs.filter((config) => {
|
|
6230
6742
|
if (!config.metadata) return false;
|
|
6231
|
-
return Object.entries(metadata).every(([key, value]) =>
|
|
6743
|
+
return Object.entries(metadata).every(([key, value]) => chunkXQRTJIC7_cjs.deepEqual(config.metadata[key], value));
|
|
6232
6744
|
});
|
|
6233
6745
|
}
|
|
6234
6746
|
const sortedConfigs = this.sortConfigs(configs, field, direction);
|
|
@@ -8068,7 +8580,7 @@ var StoreOperationsInMemory = class extends StoreOperations {
|
|
|
8068
8580
|
async insert({ tableName, record }) {
|
|
8069
8581
|
const table = this.data[tableName];
|
|
8070
8582
|
let key = record.id;
|
|
8071
|
-
if ([
|
|
8583
|
+
if ([chunk4BZRWJBH_cjs.TABLE_WORKFLOW_SNAPSHOT].includes(tableName) && !record.id && record.run_id) {
|
|
8072
8584
|
key = record.workflow_name ? `${record.workflow_name}-${record.run_id}` : record.run_id;
|
|
8073
8585
|
record.id = key;
|
|
8074
8586
|
} else if (!record.id) {
|
|
@@ -8081,7 +8593,7 @@ var StoreOperationsInMemory = class extends StoreOperations {
|
|
|
8081
8593
|
const table = this.data[tableName];
|
|
8082
8594
|
for (const record of records) {
|
|
8083
8595
|
let key = record.id;
|
|
8084
|
-
if ([
|
|
8596
|
+
if ([chunk4BZRWJBH_cjs.TABLE_WORKFLOW_SNAPSHOT].includes(tableName) && !record.id && record.run_id) {
|
|
8085
8597
|
key = record.run_id;
|
|
8086
8598
|
record.id = key;
|
|
8087
8599
|
} else if (!record.id) {
|
|
@@ -8203,5 +8715,5 @@ exports.serializeSpanAttributes = serializeSpanAttributes;
|
|
|
8203
8715
|
exports.toEntityType = toEntityType;
|
|
8204
8716
|
exports.transformRow = transformRow;
|
|
8205
8717
|
exports.transformScoreRow = transformScoreRow;
|
|
8206
|
-
//# sourceMappingURL=chunk-
|
|
8207
|
-
//# sourceMappingURL=chunk-
|
|
8718
|
+
//# sourceMappingURL=chunk-V2NQOABM.cjs.map
|
|
8719
|
+
//# sourceMappingURL=chunk-V2NQOABM.cjs.map
|