@mastra/server 1.16.0-alpha.3 → 1.16.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 +42 -0
- package/dist/{chunk-TVGJFK3J.js → chunk-57IWHVDZ.js} +9 -6
- package/dist/chunk-57IWHVDZ.js.map +1 -0
- package/dist/{chunk-PIORYI6S.js → chunk-645P6ZAV.js} +11 -3
- package/dist/chunk-645P6ZAV.js.map +1 -0
- package/dist/{chunk-YIVUZPOV.cjs → chunk-ALMN74MG.cjs} +80 -76
- package/dist/chunk-ALMN74MG.cjs.map +1 -0
- package/dist/{chunk-ZPHHURXX.cjs → chunk-B4RWYKPG.cjs} +22 -19
- package/dist/chunk-B4RWYKPG.cjs.map +1 -0
- package/dist/{chunk-4Y4RMTIA.cjs → chunk-OCSZZ5UK.cjs} +11 -3
- package/dist/chunk-OCSZZ5UK.cjs.map +1 -0
- package/dist/{chunk-457RSMZH.cjs → chunk-UTQV3JAT.cjs} +338 -117
- package/dist/chunk-UTQV3JAT.cjs.map +1 -0
- package/dist/{chunk-7DAVYYZ6.js → chunk-V4IWGD6S.js} +9 -5
- package/dist/chunk-V4IWGD6S.js.map +1 -0
- package/dist/{chunk-ZRUDCNFS.js → chunk-W2QMKHBI.js} +338 -118
- package/dist/chunk-W2QMKHBI.js.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/{observational-memory-OZ7TG4DZ-COUORCVN.cjs → observational-memory-K2U3QQIO-MBBXGVVG.cjs} +32 -28
- package/dist/{observational-memory-OZ7TG4DZ-COUORCVN.cjs.map → observational-memory-K2U3QQIO-MBBXGVVG.cjs.map} +1 -1
- package/dist/observational-memory-K2U3QQIO-MOPJN5M7.js +3 -0
- package/dist/{observational-memory-OZ7TG4DZ-MYYBYEP6.js.map → observational-memory-K2U3QQIO-MOPJN5M7.js.map} +1 -1
- package/dist/server/handlers/agent-builder.cjs +16 -16
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/memory.cjs +27 -27
- package/dist/server/handlers/memory.d.ts +16 -0
- package/dist/server/handlers/memory.d.ts.map +1 -1
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers.cjs +4 -4
- package/dist/server/handlers.js +2 -2
- package/dist/server/schemas/index.cjs +44 -44
- package/dist/server/schemas/index.js +1 -1
- package/dist/server/schemas/memory.d.ts +8 -0
- package/dist/server/schemas/memory.d.ts.map +1 -1
- package/dist/server/server-adapter/index.cjs +42 -42
- package/dist/server/server-adapter/index.js +2 -2
- package/dist/server/server-adapter/routes/memory.d.ts +16 -0
- package/dist/server/server-adapter/routes/memory.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/chunk-457RSMZH.cjs.map +0 -1
- package/dist/chunk-4Y4RMTIA.cjs.map +0 -1
- package/dist/chunk-7DAVYYZ6.js.map +0 -1
- package/dist/chunk-PIORYI6S.js.map +0 -1
- package/dist/chunk-TVGJFK3J.js.map +0 -1
- package/dist/chunk-YIVUZPOV.cjs.map +0 -1
- package/dist/chunk-ZPHHURXX.cjs.map +0 -1
- package/dist/chunk-ZRUDCNFS.js.map +0 -1
- package/dist/observational-memory-OZ7TG4DZ-MYYBYEP6.js +0 -3
|
@@ -6,11 +6,12 @@ var agent = require('@mastra/core/agent');
|
|
|
6
6
|
var features = require('@mastra/core/features');
|
|
7
7
|
var llm = require('@mastra/core/llm');
|
|
8
8
|
var memory = require('@mastra/core/memory');
|
|
9
|
+
var observability = require('@mastra/core/observability');
|
|
9
10
|
var processors = require('@mastra/core/processors');
|
|
10
11
|
var crypto$1 = require('crypto');
|
|
11
12
|
var async_hooks = require('async_hooks');
|
|
12
13
|
|
|
13
|
-
// ../memory/dist/chunk-
|
|
14
|
+
// ../memory/dist/chunk-7A3UGAXY.js
|
|
14
15
|
|
|
15
16
|
// ../../node_modules/.pnpm/xxhash-wasm@1.1.0/node_modules/xxhash-wasm/esm/xxhash-wasm.js
|
|
16
17
|
var t = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 48, 8, 96, 3, 127, 127, 127, 1, 127, 96, 3, 127, 127, 127, 0, 96, 2, 127, 127, 0, 96, 1, 127, 1, 127, 96, 3, 127, 127, 126, 1, 126, 96, 3, 126, 127, 127, 1, 126, 96, 2, 127, 126, 0, 96, 1, 127, 1, 126, 3, 11, 10, 0, 0, 2, 1, 3, 4, 5, 6, 1, 7, 5, 3, 1, 0, 1, 7, 85, 9, 3, 109, 101, 109, 2, 0, 5, 120, 120, 104, 51, 50, 0, 0, 6, 105, 110, 105, 116, 51, 50, 0, 2, 8, 117, 112, 100, 97, 116, 101, 51, 50, 0, 3, 8, 100, 105, 103, 101, 115, 116, 51, 50, 0, 4, 5, 120, 120, 104, 54, 52, 0, 5, 6, 105, 110, 105, 116, 54, 52, 0, 7, 8, 117, 112, 100, 97, 116, 101, 54, 52, 0, 8, 8, 100, 105, 103, 101, 115, 116, 54, 52, 0, 9, 10, 251, 22, 10, 242, 1, 1, 4, 127, 32, 0, 32, 1, 106, 33, 3, 32, 1, 65, 16, 79, 4, 127, 32, 3, 65, 16, 107, 33, 6, 32, 2, 65, 168, 136, 141, 161, 2, 106, 33, 3, 32, 2, 65, 137, 235, 208, 208, 7, 107, 33, 4, 32, 2, 65, 207, 140, 162, 142, 6, 106, 33, 5, 3, 64, 32, 3, 32, 0, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 3, 32, 4, 32, 0, 65, 4, 106, 34, 0, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 4, 32, 2, 32, 0, 65, 4, 106, 34, 0, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 2, 32, 5, 32, 0, 65, 4, 106, 34, 0, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 5, 32, 6, 32, 0, 65, 4, 106, 34, 0, 79, 13, 0, 11, 32, 2, 65, 12, 119, 32, 5, 65, 18, 119, 106, 32, 4, 65, 7, 119, 106, 32, 3, 65, 1, 119, 106, 5, 32, 2, 65, 177, 207, 217, 178, 1, 106, 11, 32, 1, 106, 32, 0, 32, 1, 65, 15, 113, 16, 1, 11, 146, 1, 0, 32, 1, 32, 2, 106, 33, 2, 3, 64, 32, 1, 65, 4, 106, 32, 2, 75, 69, 4, 64, 32, 0, 32, 1, 40, 2, 0, 65, 189, 220, 202, 149, 124, 108, 106, 65, 17, 119, 65, 175, 214, 211, 190, 2, 108, 33, 0, 32, 1, 65, 4, 106, 33, 1, 12, 1, 11, 11, 3, 64, 32, 1, 32, 2, 79, 69, 4, 64, 32, 0, 32, 1, 45, 0, 0, 65, 177, 207, 217, 178, 1, 108, 106, 65, 11, 119, 65, 177, 243, 221, 241, 121, 108, 33, 0, 32, 1, 65, 1, 106, 33, 1, 12, 1, 11, 11, 32, 0, 32, 0, 65, 15, 118, 115, 65, 247, 148, 175, 175, 120, 108, 34, 0, 65, 13, 118, 32, 0, 115, 65, 189, 220, 202, 149, 124, 108, 34, 0, 65, 16, 118, 32, 0, 115, 11, 63, 0, 32, 0, 65, 8, 106, 32, 1, 65, 168, 136, 141, 161, 2, 106, 54, 2, 0, 32, 0, 65, 12, 106, 32, 1, 65, 137, 235, 208, 208, 7, 107, 54, 2, 0, 32, 0, 65, 16, 106, 32, 1, 54, 2, 0, 32, 0, 65, 20, 106, 32, 1, 65, 207, 140, 162, 142, 6, 106, 54, 2, 0, 11, 195, 4, 1, 6, 127, 32, 1, 32, 2, 106, 33, 6, 32, 0, 65, 24, 106, 33, 4, 32, 0, 65, 40, 106, 40, 2, 0, 33, 3, 32, 0, 32, 0, 40, 2, 0, 32, 2, 106, 54, 2, 0, 32, 0, 65, 4, 106, 34, 5, 32, 5, 40, 2, 0, 32, 2, 65, 16, 79, 32, 0, 40, 2, 0, 65, 16, 79, 114, 114, 54, 2, 0, 32, 2, 32, 3, 106, 65, 16, 73, 4, 64, 32, 3, 32, 4, 106, 32, 1, 32, 2, 252, 10, 0, 0, 32, 0, 65, 40, 106, 32, 2, 32, 3, 106, 54, 2, 0, 15, 11, 32, 3, 4, 64, 32, 3, 32, 4, 106, 32, 1, 65, 16, 32, 3, 107, 34, 2, 252, 10, 0, 0, 32, 0, 65, 8, 106, 34, 3, 32, 3, 40, 2, 0, 32, 4, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 54, 2, 0, 32, 0, 65, 12, 106, 34, 3, 32, 3, 40, 2, 0, 32, 4, 65, 4, 106, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 54, 2, 0, 32, 0, 65, 16, 106, 34, 3, 32, 3, 40, 2, 0, 32, 4, 65, 8, 106, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 54, 2, 0, 32, 0, 65, 20, 106, 34, 3, 32, 3, 40, 2, 0, 32, 4, 65, 12, 106, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 54, 2, 0, 32, 0, 65, 40, 106, 65, 0, 54, 2, 0, 32, 1, 32, 2, 106, 33, 1, 11, 32, 1, 32, 6, 65, 16, 107, 77, 4, 64, 32, 6, 65, 16, 107, 33, 8, 32, 0, 65, 8, 106, 40, 2, 0, 33, 2, 32, 0, 65, 12, 106, 40, 2, 0, 33, 3, 32, 0, 65, 16, 106, 40, 2, 0, 33, 5, 32, 0, 65, 20, 106, 40, 2, 0, 33, 7, 3, 64, 32, 2, 32, 1, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 2, 32, 3, 32, 1, 65, 4, 106, 34, 1, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 3, 32, 5, 32, 1, 65, 4, 106, 34, 1, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 5, 32, 7, 32, 1, 65, 4, 106, 34, 1, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 7, 32, 8, 32, 1, 65, 4, 106, 34, 1, 79, 13, 0, 11, 32, 0, 65, 8, 106, 32, 2, 54, 2, 0, 32, 0, 65, 12, 106, 32, 3, 54, 2, 0, 32, 0, 65, 16, 106, 32, 5, 54, 2, 0, 32, 0, 65, 20, 106, 32, 7, 54, 2, 0, 11, 32, 1, 32, 6, 73, 4, 64, 32, 4, 32, 1, 32, 6, 32, 1, 107, 34, 1, 252, 10, 0, 0, 32, 0, 65, 40, 106, 32, 1, 54, 2, 0, 11, 11, 97, 1, 1, 127, 32, 0, 65, 16, 106, 40, 2, 0, 33, 1, 32, 0, 65, 4, 106, 40, 2, 0, 4, 127, 32, 1, 65, 12, 119, 32, 0, 65, 20, 106, 40, 2, 0, 65, 18, 119, 106, 32, 0, 65, 12, 106, 40, 2, 0, 65, 7, 119, 106, 32, 0, 65, 8, 106, 40, 2, 0, 65, 1, 119, 106, 5, 32, 1, 65, 177, 207, 217, 178, 1, 106, 11, 32, 0, 40, 2, 0, 106, 32, 0, 65, 24, 106, 32, 0, 65, 40, 106, 40, 2, 0, 16, 1, 11, 255, 3, 2, 3, 126, 1, 127, 32, 0, 32, 1, 106, 33, 6, 32, 1, 65, 32, 79, 4, 126, 32, 6, 65, 32, 107, 33, 6, 32, 2, 66, 214, 235, 130, 238, 234, 253, 137, 245, 224, 0, 124, 33, 3, 32, 2, 66, 177, 169, 172, 193, 173, 184, 212, 166, 61, 125, 33, 4, 32, 2, 66, 249, 234, 208, 208, 231, 201, 161, 228, 225, 0, 124, 33, 5, 3, 64, 32, 3, 32, 0, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 3, 32, 4, 32, 0, 65, 8, 106, 34, 0, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 4, 32, 2, 32, 0, 65, 8, 106, 34, 0, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 2, 32, 5, 32, 0, 65, 8, 106, 34, 0, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 5, 32, 6, 32, 0, 65, 8, 106, 34, 0, 79, 13, 0, 11, 32, 2, 66, 12, 137, 32, 5, 66, 18, 137, 124, 32, 4, 66, 7, 137, 124, 32, 3, 66, 1, 137, 124, 32, 3, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 32, 4, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 32, 2, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 32, 5, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 5, 32, 2, 66, 197, 207, 217, 178, 241, 229, 186, 234, 39, 124, 11, 32, 1, 173, 124, 32, 0, 32, 1, 65, 31, 113, 16, 6, 11, 134, 2, 0, 32, 1, 32, 2, 106, 33, 2, 3, 64, 32, 2, 32, 1, 65, 8, 106, 79, 4, 64, 32, 1, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 32, 0, 133, 66, 27, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 33, 0, 32, 1, 65, 8, 106, 33, 1, 12, 1, 11, 11, 32, 1, 65, 4, 106, 32, 2, 77, 4, 64, 32, 0, 32, 1, 53, 2, 0, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 23, 137, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 249, 243, 221, 241, 153, 246, 153, 171, 22, 124, 33, 0, 32, 1, 65, 4, 106, 33, 1, 11, 3, 64, 32, 1, 32, 2, 73, 4, 64, 32, 0, 32, 1, 49, 0, 0, 66, 197, 207, 217, 178, 241, 229, 186, 234, 39, 126, 133, 66, 11, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 0, 32, 1, 65, 1, 106, 33, 1, 12, 1, 11, 11, 32, 0, 32, 0, 66, 33, 136, 133, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 34, 0, 32, 0, 66, 29, 136, 133, 66, 249, 243, 221, 241, 153, 246, 153, 171, 22, 126, 34, 0, 32, 0, 66, 32, 136, 133, 11, 77, 0, 32, 0, 65, 8, 106, 32, 1, 66, 214, 235, 130, 238, 234, 253, 137, 245, 224, 0, 124, 55, 3, 0, 32, 0, 65, 16, 106, 32, 1, 66, 177, 169, 172, 193, 173, 184, 212, 166, 61, 125, 55, 3, 0, 32, 0, 65, 24, 106, 32, 1, 55, 3, 0, 32, 0, 65, 32, 106, 32, 1, 66, 249, 234, 208, 208, 231, 201, 161, 228, 225, 0, 124, 55, 3, 0, 11, 244, 4, 2, 3, 127, 4, 126, 32, 1, 32, 2, 106, 33, 5, 32, 0, 65, 40, 106, 33, 4, 32, 0, 65, 200, 0, 106, 40, 2, 0, 33, 3, 32, 0, 32, 0, 41, 3, 0, 32, 2, 173, 124, 55, 3, 0, 32, 2, 32, 3, 106, 65, 32, 73, 4, 64, 32, 3, 32, 4, 106, 32, 1, 32, 2, 252, 10, 0, 0, 32, 0, 65, 200, 0, 106, 32, 2, 32, 3, 106, 54, 2, 0, 15, 11, 32, 3, 4, 64, 32, 3, 32, 4, 106, 32, 1, 65, 32, 32, 3, 107, 34, 2, 252, 10, 0, 0, 32, 0, 65, 8, 106, 34, 3, 32, 3, 41, 3, 0, 32, 4, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 55, 3, 0, 32, 0, 65, 16, 106, 34, 3, 32, 3, 41, 3, 0, 32, 4, 65, 8, 106, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 55, 3, 0, 32, 0, 65, 24, 106, 34, 3, 32, 3, 41, 3, 0, 32, 4, 65, 16, 106, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 55, 3, 0, 32, 0, 65, 32, 106, 34, 3, 32, 3, 41, 3, 0, 32, 4, 65, 24, 106, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 55, 3, 0, 32, 0, 65, 200, 0, 106, 65, 0, 54, 2, 0, 32, 1, 32, 2, 106, 33, 1, 11, 32, 1, 65, 32, 106, 32, 5, 77, 4, 64, 32, 5, 65, 32, 107, 33, 2, 32, 0, 65, 8, 106, 41, 3, 0, 33, 6, 32, 0, 65, 16, 106, 41, 3, 0, 33, 7, 32, 0, 65, 24, 106, 41, 3, 0, 33, 8, 32, 0, 65, 32, 106, 41, 3, 0, 33, 9, 3, 64, 32, 6, 32, 1, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 6, 32, 7, 32, 1, 65, 8, 106, 34, 1, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 7, 32, 8, 32, 1, 65, 8, 106, 34, 1, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 8, 32, 9, 32, 1, 65, 8, 106, 34, 1, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 9, 32, 2, 32, 1, 65, 8, 106, 34, 1, 79, 13, 0, 11, 32, 0, 65, 8, 106, 32, 6, 55, 3, 0, 32, 0, 65, 16, 106, 32, 7, 55, 3, 0, 32, 0, 65, 24, 106, 32, 8, 55, 3, 0, 32, 0, 65, 32, 106, 32, 9, 55, 3, 0, 11, 32, 1, 32, 5, 73, 4, 64, 32, 4, 32, 1, 32, 5, 32, 1, 107, 34, 1, 252, 10, 0, 0, 32, 0, 65, 200, 0, 106, 32, 1, 54, 2, 0, 11, 11, 188, 2, 1, 5, 126, 32, 0, 65, 24, 106, 41, 3, 0, 33, 1, 32, 0, 41, 3, 0, 34, 2, 66, 32, 90, 4, 126, 32, 0, 65, 8, 106, 41, 3, 0, 34, 3, 66, 1, 137, 32, 0, 65, 16, 106, 41, 3, 0, 34, 4, 66, 7, 137, 124, 32, 1, 66, 12, 137, 32, 0, 65, 32, 106, 41, 3, 0, 34, 5, 66, 18, 137, 124, 124, 32, 3, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 32, 4, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 32, 1, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 32, 5, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 5, 32, 1, 66, 197, 207, 217, 178, 241, 229, 186, 234, 39, 124, 11, 32, 2, 124, 32, 0, 65, 40, 106, 32, 2, 66, 31, 131, 167, 16, 6, 11]);
|
|
@@ -1041,7 +1042,7 @@ function imageSize(input) {
|
|
|
1041
1042
|
throw new TypeError(`unsupported file type: ${type}`);
|
|
1042
1043
|
}
|
|
1043
1044
|
|
|
1044
|
-
// ../memory/dist/chunk-
|
|
1045
|
+
// ../memory/dist/chunk-7A3UGAXY.js
|
|
1045
1046
|
function formatRelativeTime(date, currentDate) {
|
|
1046
1047
|
const diffMs = currentDate.getTime() - date.getTime();
|
|
1047
1048
|
const diffDays = Math.floor(diffMs / (1e3 * 60 * 60 * 24));
|
|
@@ -1338,6 +1339,51 @@ function createThreadUpdateMarker(params) {
|
|
|
1338
1339
|
}
|
|
1339
1340
|
};
|
|
1340
1341
|
}
|
|
1342
|
+
function isTieredModelTarget(model) {
|
|
1343
|
+
if (typeof model === "string") {
|
|
1344
|
+
return true;
|
|
1345
|
+
}
|
|
1346
|
+
if (!model || typeof model !== "object") {
|
|
1347
|
+
return false;
|
|
1348
|
+
}
|
|
1349
|
+
return "modelId" in model || "id" in model || "providerId" in model || "provider" in model || "doGenerate" in model && "doStream" in model;
|
|
1350
|
+
}
|
|
1351
|
+
function normalizeThresholds(config) {
|
|
1352
|
+
const entries = Object.entries(config.upTo);
|
|
1353
|
+
if (entries.length === 0) {
|
|
1354
|
+
throw new Error('ModelByInputTokens requires at least one threshold in "upTo"');
|
|
1355
|
+
}
|
|
1356
|
+
for (const [limitStr, model] of entries) {
|
|
1357
|
+
const limit = Number(limitStr);
|
|
1358
|
+
if (!Number.isFinite(limit) || limit <= 0) {
|
|
1359
|
+
throw new Error(`ModelByInputTokens threshold keys must be positive numbers. Got: ${limitStr}`);
|
|
1360
|
+
}
|
|
1361
|
+
if (!isTieredModelTarget(model)) {
|
|
1362
|
+
throw new Error(`ModelByInputTokens requires a valid model target for threshold ${limitStr}`);
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
return entries.map(([limitStr, model]) => ({ limit: Number(limitStr), model })).sort((a, b) => a.limit - b.limit);
|
|
1366
|
+
}
|
|
1367
|
+
var ModelByInputTokens = class {
|
|
1368
|
+
thresholds;
|
|
1369
|
+
constructor(config) {
|
|
1370
|
+
this.thresholds = normalizeThresholds(config);
|
|
1371
|
+
}
|
|
1372
|
+
resolve(inputTokens) {
|
|
1373
|
+
for (const { limit, model } of this.thresholds) {
|
|
1374
|
+
if (inputTokens <= limit) {
|
|
1375
|
+
return model;
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
const maxLimit = this.thresholds[this.thresholds.length - 1].limit;
|
|
1379
|
+
throw new Error(
|
|
1380
|
+
`ModelByInputTokens: input token count (${inputTokens}) exceeds the largest configured threshold (${maxLimit}). Please configure a higher threshold or use a larger model.`
|
|
1381
|
+
);
|
|
1382
|
+
}
|
|
1383
|
+
getThresholds() {
|
|
1384
|
+
return this.thresholds.map((t2) => t2.limit);
|
|
1385
|
+
}
|
|
1386
|
+
};
|
|
1341
1387
|
var OBSERVATION_GROUP_PATTERN = /<observation-group\s([^>]*)>([\s\S]*?)<\/observation-group>/g;
|
|
1342
1388
|
var ATTRIBUTE_PATTERN = /([\w][\w-]*)="([^"]*)"/g;
|
|
1343
1389
|
var REFLECTION_GROUP_SPLIT_PATTERN = /^##\s+Group\s+/m;
|
|
@@ -4480,8 +4526,10 @@ var ObservationalMemory = class _ObservationalMemory {
|
|
|
4480
4526
|
onDebugEvent;
|
|
4481
4527
|
/** Internal Observer agent - created lazily */
|
|
4482
4528
|
observerAgent;
|
|
4529
|
+
observerAgentModel;
|
|
4483
4530
|
/** Internal Reflector agent - created lazily */
|
|
4484
4531
|
reflectorAgent;
|
|
4532
|
+
reflectorAgentModel;
|
|
4485
4533
|
shouldObscureThreadIds = false;
|
|
4486
4534
|
hasher = e();
|
|
4487
4535
|
threadIdCache = /* @__PURE__ */ new Map();
|
|
@@ -4788,7 +4836,15 @@ var ObservationalMemory = class _ObservationalMemory {
|
|
|
4788
4836
|
this.storage = config.storage;
|
|
4789
4837
|
this.scope = config.scope ?? "thread";
|
|
4790
4838
|
this.retrieval = this.scope === "thread" && (config.retrieval ?? OBSERVATIONAL_MEMORY_DEFAULTS.retrieval);
|
|
4791
|
-
const resolveModel = (m) =>
|
|
4839
|
+
const resolveModel = (m) => {
|
|
4840
|
+
if (m === "default") {
|
|
4841
|
+
return OBSERVATIONAL_MEMORY_DEFAULTS.observation.model;
|
|
4842
|
+
}
|
|
4843
|
+
if (m instanceof ModelByInputTokens) {
|
|
4844
|
+
return m;
|
|
4845
|
+
}
|
|
4846
|
+
return m;
|
|
4847
|
+
};
|
|
4792
4848
|
const observationModel = resolveModel(config.model) ?? resolveModel(config.observation?.model) ?? resolveModel(config.reflection?.model);
|
|
4793
4849
|
const reflectionModel = resolveModel(config.model) ?? resolveModel(config.reflection?.model) ?? resolveModel(config.observation?.model);
|
|
4794
4850
|
if (!observationModel || !reflectionModel) {
|
|
@@ -4805,7 +4861,9 @@ See https://mastra.ai/docs/memory/observational-memory#models for model recommen
|
|
|
4805
4861
|
const messageTokens = config.observation?.messageTokens ?? OBSERVATIONAL_MEMORY_DEFAULTS.observation.messageTokens;
|
|
4806
4862
|
const observationTokens = config.reflection?.observationTokens ?? OBSERVATIONAL_MEMORY_DEFAULTS.reflection.observationTokens;
|
|
4807
4863
|
const isSharedBudget = config.shareTokenBudget ?? false;
|
|
4808
|
-
const isDefaultModelSelection = (model) =>
|
|
4864
|
+
const isDefaultModelSelection = (model) => {
|
|
4865
|
+
return model === void 0 || model === "default";
|
|
4866
|
+
};
|
|
4809
4867
|
const observationSelectedModel = config.model ?? config.observation?.model ?? config.reflection?.model;
|
|
4810
4868
|
const reflectionSelectedModel = config.model ?? config.reflection?.model ?? config.observation?.model;
|
|
4811
4869
|
const observationDefaultMaxOutputTokens = config.observation?.modelSettings?.maxOutputTokens ?? (isDefaultModelSelection(observationSelectedModel) ? OBSERVATIONAL_MEMORY_DEFAULTS.observation.modelSettings.maxOutputTokens : void 0);
|
|
@@ -4908,6 +4966,15 @@ Async buffering is enabled by default \u2014 this opt-out is only needed when us
|
|
|
4908
4966
|
async waitForBuffering(threadId, resourceId, timeoutMs = 3e4) {
|
|
4909
4967
|
return _ObservationalMemory.awaitBuffering(threadId, resourceId, this.scope, timeoutMs);
|
|
4910
4968
|
}
|
|
4969
|
+
getConcreteModel(model, inputTokens) {
|
|
4970
|
+
if (model instanceof ModelByInputTokens) {
|
|
4971
|
+
if (inputTokens === void 0) {
|
|
4972
|
+
throw new Error("ModelByInputTokens requires inputTokens for resolution");
|
|
4973
|
+
}
|
|
4974
|
+
return model.resolve(inputTokens);
|
|
4975
|
+
}
|
|
4976
|
+
return model;
|
|
4977
|
+
}
|
|
4911
4978
|
getModelToResolve(model) {
|
|
4912
4979
|
if (Array.isArray(model)) {
|
|
4913
4980
|
return model[0]?.model ?? "unknown";
|
|
@@ -4946,7 +5013,11 @@ Async buffering is enabled by default \u2014 this opt-out is only needed when us
|
|
|
4946
5013
|
*/
|
|
4947
5014
|
async getCompressionStartLevel(requestContext) {
|
|
4948
5015
|
try {
|
|
4949
|
-
const
|
|
5016
|
+
const modelConfig = this.getConcreteModel(
|
|
5017
|
+
this.reflectionConfig.model,
|
|
5018
|
+
this.reflectionConfig.model instanceof ModelByInputTokens ? 1 : void 0
|
|
5019
|
+
);
|
|
5020
|
+
const resolved = await this.resolveModelContext(modelConfig, requestContext);
|
|
4950
5021
|
const modelId = resolved?.modelId ?? "";
|
|
4951
5022
|
if (modelId.includes("gemini-2.5-flash")) {
|
|
4952
5023
|
return 2;
|
|
@@ -4968,34 +5039,97 @@ Async buffering is enabled by default \u2014 this opt-out is only needed when us
|
|
|
4968
5039
|
runWithTokenCounterModelContext(modelContext, fn) {
|
|
4969
5040
|
return this.tokenCounter.runWithModelContext(modelContext, fn);
|
|
4970
5041
|
}
|
|
5042
|
+
async formatRoutingModel(model, requestContext) {
|
|
5043
|
+
if (!model) {
|
|
5044
|
+
return void 0;
|
|
5045
|
+
}
|
|
5046
|
+
if (typeof model === "string") {
|
|
5047
|
+
return model;
|
|
5048
|
+
}
|
|
5049
|
+
const resolvedModel = await this.resolveModelContext(model, requestContext);
|
|
5050
|
+
if (resolvedModel) {
|
|
5051
|
+
return this.formatModelName(resolvedModel);
|
|
5052
|
+
}
|
|
5053
|
+
const runtimeModel = this.getRuntimeModelContext(model);
|
|
5054
|
+
return runtimeModel ? this.formatModelName(runtimeModel) : void 0;
|
|
5055
|
+
}
|
|
5056
|
+
async withOmTracingSpan(options) {
|
|
5057
|
+
const { phase, inputTokens, resolvedModel, selectedThreshold, routingModel, requestContext, tracingContext, fn } = options;
|
|
5058
|
+
const selectedModel = await this.formatRoutingModel(resolvedModel, requestContext) ?? "(unknown)";
|
|
5059
|
+
if (!tracingContext) {
|
|
5060
|
+
return fn();
|
|
5061
|
+
}
|
|
5062
|
+
const span = observability.getOrCreateSpan({
|
|
5063
|
+
type: observability.SpanType.GENERIC,
|
|
5064
|
+
name: `om.${phase}`,
|
|
5065
|
+
attributes: {
|
|
5066
|
+
omPhase: phase,
|
|
5067
|
+
omInputTokens: inputTokens,
|
|
5068
|
+
omSelectedModel: selectedModel,
|
|
5069
|
+
...selectedThreshold !== void 0 ? { omSelectedThreshold: selectedThreshold } : {},
|
|
5070
|
+
...routingModel ? {
|
|
5071
|
+
omRoutingStrategy: "model-by-input-tokens",
|
|
5072
|
+
omRoutingThresholds: routingModel.getThresholds().join(",")
|
|
5073
|
+
} : {}
|
|
5074
|
+
},
|
|
5075
|
+
tracingContext,
|
|
5076
|
+
requestContext
|
|
5077
|
+
});
|
|
5078
|
+
if (!span) {
|
|
5079
|
+
return fn();
|
|
5080
|
+
}
|
|
5081
|
+
const observabilityContext = observability.createObservabilityContext({ currentSpan: span });
|
|
5082
|
+
return span.executeInContext(() => fn(observabilityContext));
|
|
5083
|
+
}
|
|
4971
5084
|
/**
|
|
4972
5085
|
* Get the full config including resolved model names.
|
|
4973
5086
|
* This is async because it needs to resolve the model configs.
|
|
4974
5087
|
*/
|
|
4975
5088
|
async getResolvedConfig(requestContext) {
|
|
4976
|
-
const
|
|
5089
|
+
const resolveRouting = async (modelConfig) => {
|
|
4977
5090
|
try {
|
|
5091
|
+
if (modelConfig instanceof ModelByInputTokens) {
|
|
5092
|
+
const routing = await Promise.all(
|
|
5093
|
+
modelConfig.getThresholds().map(async (upTo) => {
|
|
5094
|
+
const resolvedModel = modelConfig.resolve(upTo);
|
|
5095
|
+
const resolved2 = await this.resolveModelContext(resolvedModel, requestContext);
|
|
5096
|
+
return {
|
|
5097
|
+
upTo,
|
|
5098
|
+
model: resolved2?.modelId ? this.formatModelName(resolved2) : "(unknown)"
|
|
5099
|
+
};
|
|
5100
|
+
})
|
|
5101
|
+
);
|
|
5102
|
+
return {
|
|
5103
|
+
model: routing[0]?.model ?? "(unknown)",
|
|
5104
|
+
routing
|
|
5105
|
+
};
|
|
5106
|
+
}
|
|
4978
5107
|
const resolved = await this.resolveModelContext(modelConfig, requestContext);
|
|
4979
|
-
return
|
|
5108
|
+
return {
|
|
5109
|
+
model: resolved?.modelId ? this.formatModelName(resolved) : "(unknown)"
|
|
5110
|
+
};
|
|
4980
5111
|
} catch (error) {
|
|
4981
5112
|
omError("[OM] Failed to resolve model config", error);
|
|
4982
|
-
return "(unknown)";
|
|
5113
|
+
return { model: "(unknown)" };
|
|
4983
5114
|
}
|
|
4984
5115
|
};
|
|
4985
|
-
const [
|
|
4986
|
-
|
|
4987
|
-
|
|
5116
|
+
const [observationResolved, reflectionResolved] = await Promise.all([
|
|
5117
|
+
resolveRouting(this.observationConfig.model),
|
|
5118
|
+
resolveRouting(this.reflectionConfig.model)
|
|
4988
5119
|
]);
|
|
4989
5120
|
return {
|
|
4990
5121
|
scope: this.scope,
|
|
5122
|
+
shareTokenBudget: this.observationConfig.shareTokenBudget,
|
|
4991
5123
|
observation: {
|
|
4992
5124
|
messageTokens: this.observationConfig.messageTokens,
|
|
4993
|
-
model:
|
|
4994
|
-
previousObserverTokens: this.observationConfig.previousObserverTokens
|
|
5125
|
+
model: observationResolved.model,
|
|
5126
|
+
previousObserverTokens: this.observationConfig.previousObserverTokens,
|
|
5127
|
+
routing: observationResolved.routing
|
|
4995
5128
|
},
|
|
4996
5129
|
reflection: {
|
|
4997
5130
|
observationTokens: this.reflectionConfig.observationTokens,
|
|
4998
|
-
model:
|
|
5131
|
+
model: reflectionResolved.model,
|
|
5132
|
+
routing: reflectionResolved.routing
|
|
4999
5133
|
}
|
|
5000
5134
|
};
|
|
5001
5135
|
}
|
|
@@ -5097,8 +5231,11 @@ Async buffering is enabled by default \u2014 this opt-out is only needed when us
|
|
|
5097
5231
|
/**
|
|
5098
5232
|
* Get or create the Observer agent
|
|
5099
5233
|
*/
|
|
5100
|
-
getObserverAgent() {
|
|
5101
|
-
if (
|
|
5234
|
+
getObserverAgent(model) {
|
|
5235
|
+
if (this.observerAgent && this.observerAgentModel === void 0) {
|
|
5236
|
+
return this.observerAgent;
|
|
5237
|
+
}
|
|
5238
|
+
if (!this.observerAgent || this.observerAgentModel !== model) {
|
|
5102
5239
|
const systemPrompt = buildObserverSystemPrompt(
|
|
5103
5240
|
false,
|
|
5104
5241
|
this.observationConfig.instruction,
|
|
@@ -5108,23 +5245,28 @@ Async buffering is enabled by default \u2014 this opt-out is only needed when us
|
|
|
5108
5245
|
id: "observational-memory-observer",
|
|
5109
5246
|
name: "Observer",
|
|
5110
5247
|
instructions: systemPrompt,
|
|
5111
|
-
model
|
|
5248
|
+
model
|
|
5112
5249
|
});
|
|
5250
|
+
this.observerAgentModel = model;
|
|
5113
5251
|
}
|
|
5114
5252
|
return this.observerAgent;
|
|
5115
5253
|
}
|
|
5116
5254
|
/**
|
|
5117
5255
|
* Get or create the Reflector agent
|
|
5118
5256
|
*/
|
|
5119
|
-
getReflectorAgent() {
|
|
5120
|
-
if (
|
|
5257
|
+
getReflectorAgent(model) {
|
|
5258
|
+
if (this.reflectorAgent && this.reflectorAgentModel === void 0) {
|
|
5259
|
+
return this.reflectorAgent;
|
|
5260
|
+
}
|
|
5261
|
+
if (!this.reflectorAgent || this.reflectorAgentModel !== model) {
|
|
5121
5262
|
const systemPrompt = buildReflectorSystemPrompt(this.reflectionConfig.instruction);
|
|
5122
5263
|
this.reflectorAgent = new agent.Agent({
|
|
5123
5264
|
id: "observational-memory-reflector",
|
|
5124
5265
|
name: "Reflector",
|
|
5125
5266
|
instructions: systemPrompt,
|
|
5126
|
-
model
|
|
5267
|
+
model
|
|
5127
5268
|
});
|
|
5269
|
+
this.reflectorAgentModel = model;
|
|
5128
5270
|
}
|
|
5129
5271
|
return this.reflectorAgent;
|
|
5130
5272
|
}
|
|
@@ -5604,7 +5746,6 @@ ${unreflectedContent}` : bufferedReflection;
|
|
|
5604
5746
|
* Call the Observer agent to extract observations.
|
|
5605
5747
|
*/
|
|
5606
5748
|
async callObserver(existingObservations, messagesToObserve, abortSignal, options) {
|
|
5607
|
-
const agent = this.getObserverAgent();
|
|
5608
5749
|
const observerMessages = [
|
|
5609
5750
|
{
|
|
5610
5751
|
role: "user",
|
|
@@ -5619,18 +5760,35 @@ ${unreflectedContent}` : bufferedReflection;
|
|
|
5619
5760
|
},
|
|
5620
5761
|
buildObserverHistoryMessage(messagesToObserve)
|
|
5621
5762
|
];
|
|
5763
|
+
const inputTokens = this.tokenCounter.countMessages(messagesToObserve);
|
|
5764
|
+
const requestContext = options?.requestContext;
|
|
5765
|
+
const tracingContext = options?.tracingContext;
|
|
5766
|
+
const routingModel = this.observationConfig.model instanceof ModelByInputTokens ? this.observationConfig.model : void 0;
|
|
5767
|
+
const selectedThreshold = routingModel?.getThresholds().find((threshold) => inputTokens <= threshold);
|
|
5768
|
+
const resolvedModel = this.getConcreteModel(this.observationConfig.model, inputTokens);
|
|
5769
|
+
const agent = this.getObserverAgent(resolvedModel);
|
|
5622
5770
|
const doGenerate = async () => {
|
|
5623
|
-
const result2 = await this.
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5771
|
+
const result2 = await this.withOmTracingSpan({
|
|
5772
|
+
phase: "observer",
|
|
5773
|
+
inputTokens,
|
|
5774
|
+
resolvedModel,
|
|
5775
|
+
selectedThreshold,
|
|
5776
|
+
routingModel,
|
|
5777
|
+
requestContext,
|
|
5778
|
+
tracingContext,
|
|
5779
|
+
fn: async (observabilityContext) => this.withAbortCheck(async () => {
|
|
5780
|
+
const streamResult = await agent.stream(observerMessages, {
|
|
5781
|
+
...observabilityContext,
|
|
5782
|
+
modelSettings: {
|
|
5783
|
+
...this.observationConfig.modelSettings
|
|
5784
|
+
},
|
|
5785
|
+
providerOptions: this.observationConfig.providerOptions,
|
|
5786
|
+
...abortSignal ? { abortSignal } : {},
|
|
5787
|
+
...requestContext ? { requestContext } : {}
|
|
5788
|
+
});
|
|
5789
|
+
return streamResult.getFullOutput();
|
|
5790
|
+
}, abortSignal)
|
|
5791
|
+
});
|
|
5634
5792
|
return result2;
|
|
5635
5793
|
};
|
|
5636
5794
|
let result = await doGenerate();
|
|
@@ -5663,18 +5821,12 @@ ${unreflectedContent}` : bufferedReflection;
|
|
|
5663
5821
|
* Returns per-thread results with observations, currentTask, and suggestedContinuation,
|
|
5664
5822
|
* plus the total usage for the batch.
|
|
5665
5823
|
*/
|
|
5666
|
-
async callMultiThreadObserver(existingObservations, messagesByThread, threadOrder, priorMetadataByThread, abortSignal, requestContext, wasTruncated) {
|
|
5824
|
+
async callMultiThreadObserver(existingObservations, messagesByThread, threadOrder, priorMetadataByThread, abortSignal, requestContext, wasTruncated, tracingContext) {
|
|
5667
5825
|
const systemPrompt = buildObserverSystemPrompt(
|
|
5668
5826
|
true,
|
|
5669
5827
|
this.observationConfig.instruction,
|
|
5670
5828
|
this.observationConfig.threadTitle
|
|
5671
5829
|
);
|
|
5672
|
-
const agent$1 = new agent.Agent({
|
|
5673
|
-
id: "multi-thread-observer",
|
|
5674
|
-
name: "multi-thread-observer",
|
|
5675
|
-
model: this.observationConfig.model,
|
|
5676
|
-
instructions: systemPrompt
|
|
5677
|
-
});
|
|
5678
5830
|
const observerMessages = [
|
|
5679
5831
|
{
|
|
5680
5832
|
role: "user",
|
|
@@ -5695,18 +5847,38 @@ ${unreflectedContent}` : bufferedReflection;
|
|
|
5695
5847
|
for (const msg of allMessages) {
|
|
5696
5848
|
this.observedMessageIds.add(msg.id);
|
|
5697
5849
|
}
|
|
5850
|
+
const inputTokens = this.tokenCounter.countMessages(allMessages);
|
|
5851
|
+
const routingModel = this.observationConfig.model instanceof ModelByInputTokens ? this.observationConfig.model : void 0;
|
|
5852
|
+
const selectedThreshold = routingModel?.getThresholds().find((threshold) => inputTokens <= threshold);
|
|
5853
|
+
const resolvedModel = this.getConcreteModel(this.observationConfig.model, inputTokens);
|
|
5854
|
+
const agent$1 = new agent.Agent({
|
|
5855
|
+
id: "multi-thread-observer",
|
|
5856
|
+
name: "multi-thread-observer",
|
|
5857
|
+
model: resolvedModel,
|
|
5858
|
+
instructions: systemPrompt
|
|
5859
|
+
});
|
|
5698
5860
|
const doGenerate = async () => {
|
|
5699
|
-
const result2 = await this.
|
|
5700
|
-
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5861
|
+
const result2 = await this.withOmTracingSpan({
|
|
5862
|
+
phase: "observer",
|
|
5863
|
+
inputTokens,
|
|
5864
|
+
resolvedModel,
|
|
5865
|
+
selectedThreshold,
|
|
5866
|
+
routingModel,
|
|
5867
|
+
requestContext,
|
|
5868
|
+
tracingContext,
|
|
5869
|
+
fn: async (observabilityContext) => this.withAbortCheck(async () => {
|
|
5870
|
+
const streamResult = await agent$1.stream(observerMessages, {
|
|
5871
|
+
...observabilityContext,
|
|
5872
|
+
modelSettings: {
|
|
5873
|
+
...this.observationConfig.modelSettings
|
|
5874
|
+
},
|
|
5875
|
+
providerOptions: this.observationConfig.providerOptions,
|
|
5876
|
+
...abortSignal ? { abortSignal } : {},
|
|
5877
|
+
...requestContext ? { requestContext } : {}
|
|
5878
|
+
});
|
|
5879
|
+
return streamResult.getFullOutput();
|
|
5880
|
+
}, abortSignal)
|
|
5881
|
+
});
|
|
5710
5882
|
return result2;
|
|
5711
5883
|
};
|
|
5712
5884
|
let result = await doGenerate();
|
|
@@ -5748,9 +5920,12 @@ ${unreflectedContent}` : bufferedReflection;
|
|
|
5748
5920
|
* Call the Reflector agent to condense observations.
|
|
5749
5921
|
* Includes compression validation and retry logic.
|
|
5750
5922
|
*/
|
|
5751
|
-
async callReflector(observations, manualPrompt, streamContext, observationTokensThreshold, abortSignal, skipContinuationHints, compressionStartLevel, requestContext) {
|
|
5752
|
-
const agent = this.getReflectorAgent();
|
|
5923
|
+
async callReflector(observations, manualPrompt, streamContext, observationTokensThreshold, abortSignal, skipContinuationHints, compressionStartLevel, requestContext, tracingContext) {
|
|
5753
5924
|
const originalTokens = this.tokenCounter.countObservations(observations);
|
|
5925
|
+
const routingModel = this.reflectionConfig.model instanceof ModelByInputTokens ? this.reflectionConfig.model : void 0;
|
|
5926
|
+
const selectedThreshold = routingModel?.getThresholds().find((threshold) => originalTokens <= threshold);
|
|
5927
|
+
const resolvedModel = this.getConcreteModel(this.reflectionConfig.model, originalTokens);
|
|
5928
|
+
const agent = this.getReflectorAgent(resolvedModel);
|
|
5754
5929
|
const targetThreshold = observationTokensThreshold ?? getMaxThreshold(this.reflectionConfig.observationTokens);
|
|
5755
5930
|
let totalUsage = { inputTokens: 0, outputTokens: 0, totalTokens: 0 };
|
|
5756
5931
|
const startLevel = compressionStartLevel ?? 0;
|
|
@@ -5767,37 +5942,47 @@ ${unreflectedContent}` : bufferedReflection;
|
|
|
5767
5942
|
`[OM:callReflector] ${isRetry ? `retry #${attemptNumber - 1}` : "first attempt"}: level=${currentLevel}, originalTokens=${originalTokens}, targetThreshold=${targetThreshold}, promptLen=${prompt.length}, skipContinuationHints=${skipContinuationHints}`
|
|
5768
5943
|
);
|
|
5769
5944
|
let chunkCount = 0;
|
|
5770
|
-
const result = await this.
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
omDebug(`[OM:callReflector] chunk#${chunkCount}: type=${chunk.type}${preview}`);
|
|
5784
|
-
}
|
|
5785
|
-
},
|
|
5786
|
-
onFinish(event) {
|
|
5787
|
-
omDebug(
|
|
5788
|
-
`[OM:callReflector] onFinish: chunks=${chunkCount}, finishReason=${event.finishReason}, inputTokens=${event.usage?.inputTokens}, outputTokens=${event.usage?.outputTokens}, textLen=${event.text?.length}`
|
|
5789
|
-
);
|
|
5790
|
-
},
|
|
5791
|
-
onAbort(event) {
|
|
5792
|
-
omDebug(`[OM:callReflector] onAbort: chunks=${chunkCount}, reason=${event?.reason ?? "unknown"}`);
|
|
5945
|
+
const result = await this.withOmTracingSpan({
|
|
5946
|
+
phase: "reflector",
|
|
5947
|
+
inputTokens: originalTokens,
|
|
5948
|
+
resolvedModel,
|
|
5949
|
+
selectedThreshold,
|
|
5950
|
+
routingModel,
|
|
5951
|
+
requestContext,
|
|
5952
|
+
tracingContext,
|
|
5953
|
+
fn: async (observabilityContext) => this.withAbortCheck(async () => {
|
|
5954
|
+
const streamResult = await agent.stream(prompt, {
|
|
5955
|
+
...observabilityContext,
|
|
5956
|
+
modelSettings: {
|
|
5957
|
+
...this.reflectionConfig.modelSettings
|
|
5793
5958
|
},
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
}
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5959
|
+
providerOptions: this.reflectionConfig.providerOptions,
|
|
5960
|
+
...abortSignal ? { abortSignal } : {},
|
|
5961
|
+
...requestContext ? { requestContext } : {},
|
|
5962
|
+
...attemptNumber === 1 ? {
|
|
5963
|
+
onChunk(chunk) {
|
|
5964
|
+
chunkCount++;
|
|
5965
|
+
if (chunkCount === 1 || chunkCount % 50 === 0) {
|
|
5966
|
+
const preview = chunk.type === "text-delta" ? ` text="${chunk.textDelta?.slice(0, 80)}..."` : chunk.type === "tool-call" ? ` tool=${chunk.toolName}` : "";
|
|
5967
|
+
omDebug(`[OM:callReflector] chunk#${chunkCount}: type=${chunk.type}${preview}`);
|
|
5968
|
+
}
|
|
5969
|
+
},
|
|
5970
|
+
onFinish(event) {
|
|
5971
|
+
omDebug(
|
|
5972
|
+
`[OM:callReflector] onFinish: chunks=${chunkCount}, finishReason=${event.finishReason}, inputTokens=${event.usage?.inputTokens}, outputTokens=${event.usage?.outputTokens}, textLen=${event.text?.length}`
|
|
5973
|
+
);
|
|
5974
|
+
},
|
|
5975
|
+
onAbort(event) {
|
|
5976
|
+
omDebug(`[OM:callReflector] onAbort: chunks=${chunkCount}, reason=${event?.reason ?? "unknown"}`);
|
|
5977
|
+
},
|
|
5978
|
+
onError({ error }) {
|
|
5979
|
+
omError(`[OM:callReflector] onError after ${chunkCount} chunks`, error);
|
|
5980
|
+
}
|
|
5981
|
+
} : {}
|
|
5982
|
+
});
|
|
5983
|
+
return streamResult.getFullOutput();
|
|
5984
|
+
}, abortSignal)
|
|
5985
|
+
});
|
|
5801
5986
|
omDebug(
|
|
5802
5987
|
`[OM:callReflector] attempt #${attemptNumber} returned: textLen=${result.text?.length}, textPreview="${result.text?.slice(0, 120)}...", inputTokens=${result.usage?.inputTokens ?? result.totalUsage?.inputTokens}, outputTokens=${result.usage?.outputTokens ?? result.totalUsage?.outputTokens}`
|
|
5803
5988
|
);
|
|
@@ -6102,7 +6287,7 @@ ${suggestedResponse}
|
|
|
6102
6287
|
* Tries async activation first if enabled, then falls back to sync observation.
|
|
6103
6288
|
* Returns whether observation succeeded.
|
|
6104
6289
|
*/
|
|
6105
|
-
async handleThresholdReached(messageList, record, threadId, resourceId, threshold, lockKey, writer, abortSignal, abort, requestContext) {
|
|
6290
|
+
async handleThresholdReached(messageList, record, threadId, resourceId, threshold, lockKey, writer, abortSignal, abort, requestContext, tracingContext) {
|
|
6106
6291
|
let observationSucceeded = false;
|
|
6107
6292
|
let updatedRecord = record;
|
|
6108
6293
|
let activatedMessageIds;
|
|
@@ -6201,7 +6386,8 @@ ${suggestedResponse}
|
|
|
6201
6386
|
currentThreadMessages: freshUnobservedMessages,
|
|
6202
6387
|
writer,
|
|
6203
6388
|
abortSignal,
|
|
6204
|
-
requestContext
|
|
6389
|
+
requestContext,
|
|
6390
|
+
tracingContext
|
|
6205
6391
|
});
|
|
6206
6392
|
} else {
|
|
6207
6393
|
await this.doSynchronousObservation({
|
|
@@ -6210,7 +6396,8 @@ ${suggestedResponse}
|
|
|
6210
6396
|
unobservedMessages: freshUnobservedMessages,
|
|
6211
6397
|
writer,
|
|
6212
6398
|
abortSignal,
|
|
6213
|
-
requestContext
|
|
6399
|
+
requestContext,
|
|
6400
|
+
tracingContext
|
|
6214
6401
|
});
|
|
6215
6402
|
}
|
|
6216
6403
|
updatedRecord = await this.getOrCreateRecord(threadId, resourceId);
|
|
@@ -6480,7 +6667,17 @@ ${suggestedResponse}
|
|
|
6480
6667
|
* 5. Filter out already-observed messages
|
|
6481
6668
|
*/
|
|
6482
6669
|
async processInputStep(args) {
|
|
6483
|
-
const {
|
|
6670
|
+
const {
|
|
6671
|
+
messageList,
|
|
6672
|
+
requestContext,
|
|
6673
|
+
tracingContext,
|
|
6674
|
+
stepNumber,
|
|
6675
|
+
state: _state,
|
|
6676
|
+
writer,
|
|
6677
|
+
abortSignal,
|
|
6678
|
+
abort,
|
|
6679
|
+
model
|
|
6680
|
+
} = args;
|
|
6484
6681
|
const state = _state ?? {};
|
|
6485
6682
|
omDebug(
|
|
6486
6683
|
`[OM:processInputStep:ENTER] step=${stepNumber}, hasMastraMemory=${!!requestContext?.get("MastraMemory")}, hasMemoryInfo=${!!messageList?.serialize()?.memoryInfo?.threadId}`
|
|
@@ -6602,7 +6799,8 @@ ${suggestedResponse}
|
|
|
6602
6799
|
threadId,
|
|
6603
6800
|
writer,
|
|
6604
6801
|
messageList,
|
|
6605
|
-
requestContext
|
|
6802
|
+
requestContext,
|
|
6803
|
+
tracingContext
|
|
6606
6804
|
});
|
|
6607
6805
|
record = await this.getOrCreateRecord(threadId, resourceId);
|
|
6608
6806
|
}
|
|
@@ -6619,7 +6817,8 @@ ${suggestedResponse}
|
|
|
6619
6817
|
threadId,
|
|
6620
6818
|
writer,
|
|
6621
6819
|
messageList,
|
|
6622
|
-
requestContext
|
|
6820
|
+
requestContext,
|
|
6821
|
+
tracingContext
|
|
6623
6822
|
});
|
|
6624
6823
|
record = await this.getOrCreateRecord(threadId, resourceId);
|
|
6625
6824
|
} else if (this.isAsyncReflectionEnabled()) {
|
|
@@ -6675,7 +6874,8 @@ ${suggestedResponse}
|
|
|
6675
6874
|
lockKey,
|
|
6676
6875
|
writer,
|
|
6677
6876
|
unbufferedPendingTokens,
|
|
6678
|
-
requestContext
|
|
6877
|
+
requestContext,
|
|
6878
|
+
tracingContext
|
|
6679
6879
|
);
|
|
6680
6880
|
}
|
|
6681
6881
|
} else if (this.isAsyncObservationEnabled()) {
|
|
@@ -6691,7 +6891,8 @@ ${suggestedResponse}
|
|
|
6691
6891
|
lockKey,
|
|
6692
6892
|
writer,
|
|
6693
6893
|
unbufferedPendingTokens,
|
|
6694
|
-
requestContext
|
|
6894
|
+
requestContext,
|
|
6895
|
+
tracingContext
|
|
6695
6896
|
);
|
|
6696
6897
|
}
|
|
6697
6898
|
}
|
|
@@ -6710,7 +6911,8 @@ ${suggestedResponse}
|
|
|
6710
6911
|
writer,
|
|
6711
6912
|
abortSignal,
|
|
6712
6913
|
abort,
|
|
6713
|
-
requestContext
|
|
6914
|
+
requestContext,
|
|
6915
|
+
tracingContext
|
|
6714
6916
|
);
|
|
6715
6917
|
if (observationSucceeded) {
|
|
6716
6918
|
const observedIds = activatedMessageIds?.length ? activatedMessageIds : Array.isArray(updatedRecord.observedMessageIds) ? updatedRecord.observedMessageIds : void 0;
|
|
@@ -7119,7 +7321,16 @@ ${threadClose}`;
|
|
|
7119
7321
|
* Do synchronous observation (fallback when no buffering)
|
|
7120
7322
|
*/
|
|
7121
7323
|
async doSynchronousObservation(opts) {
|
|
7122
|
-
const {
|
|
7324
|
+
const {
|
|
7325
|
+
record,
|
|
7326
|
+
threadId,
|
|
7327
|
+
unobservedMessages,
|
|
7328
|
+
writer,
|
|
7329
|
+
abortSignal,
|
|
7330
|
+
reflectionHooks,
|
|
7331
|
+
requestContext,
|
|
7332
|
+
tracingContext
|
|
7333
|
+
} = opts;
|
|
7123
7334
|
this.emitDebugEvent({
|
|
7124
7335
|
type: "observation_triggered",
|
|
7125
7336
|
timestamp: /* @__PURE__ */ new Date(),
|
|
@@ -7178,6 +7389,7 @@ ${threadClose}`;
|
|
|
7178
7389
|
const threadOMMetadata = memory.getThreadOMMetadata(thread?.metadata);
|
|
7179
7390
|
const result = await this.callObserver(observerContext, messagesToObserve, abortSignal, {
|
|
7180
7391
|
requestContext,
|
|
7392
|
+
tracingContext,
|
|
7181
7393
|
priorCurrentTask: threadOMMetadata?.currentTask,
|
|
7182
7394
|
priorSuggestedResponse: threadOMMetadata?.suggestedResponse,
|
|
7183
7395
|
priorThreadTitle: thread?.title,
|
|
@@ -7285,7 +7497,8 @@ ${threadClose}`;
|
|
|
7285
7497
|
writer,
|
|
7286
7498
|
abortSignal,
|
|
7287
7499
|
reflectionHooks,
|
|
7288
|
-
requestContext
|
|
7500
|
+
requestContext,
|
|
7501
|
+
tracingContext
|
|
7289
7502
|
});
|
|
7290
7503
|
} catch (error) {
|
|
7291
7504
|
if (lastMessage?.id) {
|
|
@@ -7303,10 +7516,7 @@ ${threadClose}`;
|
|
|
7303
7516
|
});
|
|
7304
7517
|
}
|
|
7305
7518
|
}
|
|
7306
|
-
|
|
7307
|
-
throw error;
|
|
7308
|
-
}
|
|
7309
|
-
omError("[OM] Observation failed", error);
|
|
7519
|
+
throw error;
|
|
7310
7520
|
} finally {
|
|
7311
7521
|
await this.storage.setObservingFlag(record.id, false);
|
|
7312
7522
|
unregisterOp(record.id, "observing");
|
|
@@ -7326,7 +7536,7 @@ ${threadClose}`;
|
|
|
7326
7536
|
* @param lockKey - Lock key for this scope
|
|
7327
7537
|
* @param writer - Optional stream writer for emitting buffering markers
|
|
7328
7538
|
*/
|
|
7329
|
-
async startAsyncBufferedObservation(record, threadId, unobservedMessages, lockKey, writer, contextWindowTokens, requestContext) {
|
|
7539
|
+
async startAsyncBufferedObservation(record, threadId, unobservedMessages, lockKey, writer, contextWindowTokens, requestContext, tracingContext) {
|
|
7330
7540
|
const bufferKey = this.getObservationBufferKey(lockKey);
|
|
7331
7541
|
const currentTokens = contextWindowTokens ?? await this.tokenCounter.countMessagesAsync(unobservedMessages) + (record.pendingMessageTokens ?? 0);
|
|
7332
7542
|
_ObservationalMemory.lastBufferedBoundary.set(bufferKey, currentTokens);
|
|
@@ -7340,7 +7550,8 @@ ${threadClose}`;
|
|
|
7340
7550
|
unobservedMessages,
|
|
7341
7551
|
bufferKey,
|
|
7342
7552
|
writer,
|
|
7343
|
-
requestContext
|
|
7553
|
+
requestContext,
|
|
7554
|
+
tracingContext
|
|
7344
7555
|
).finally(() => {
|
|
7345
7556
|
_ObservationalMemory.asyncBufferingOps.delete(bufferKey);
|
|
7346
7557
|
unregisterOp(record.id, "bufferingObservation");
|
|
@@ -7354,7 +7565,7 @@ ${threadClose}`;
|
|
|
7354
7565
|
* Internal method that waits for existing buffering operation and then runs new buffering.
|
|
7355
7566
|
* This implements the mutex-wait behavior.
|
|
7356
7567
|
*/
|
|
7357
|
-
async runAsyncBufferedObservation(record, threadId, unobservedMessages, bufferKey, writer, requestContext) {
|
|
7568
|
+
async runAsyncBufferedObservation(record, threadId, unobservedMessages, bufferKey, writer, requestContext, tracingContext) {
|
|
7358
7569
|
const existingOp = _ObservationalMemory.asyncBufferingOps.get(bufferKey);
|
|
7359
7570
|
if (existingOp) {
|
|
7360
7571
|
try {
|
|
@@ -7434,7 +7645,8 @@ ${threadClose}`;
|
|
|
7434
7645
|
cycleId,
|
|
7435
7646
|
startedAt,
|
|
7436
7647
|
writer,
|
|
7437
|
-
requestContext
|
|
7648
|
+
requestContext,
|
|
7649
|
+
tracingContext
|
|
7438
7650
|
);
|
|
7439
7651
|
const maxTs = this.getMaxMessageTimestamp(messagesToBuffer);
|
|
7440
7652
|
const cursor = new Date(maxTs.getTime() + 1);
|
|
@@ -7464,7 +7676,7 @@ ${threadClose}`;
|
|
|
7464
7676
|
* The observer sees: active observations + existing buffered observations + message history
|
|
7465
7677
|
* (excluding already-buffered messages).
|
|
7466
7678
|
*/
|
|
7467
|
-
async doAsyncBufferedObservation(record, threadId, messagesToBuffer, cycleId, startedAt, writer, requestContext) {
|
|
7679
|
+
async doAsyncBufferedObservation(record, threadId, messagesToBuffer, cycleId, startedAt, writer, requestContext, tracingContext) {
|
|
7468
7680
|
const bufferedChunks = this.getBufferedChunks(record);
|
|
7469
7681
|
const bufferedChunksText = bufferedChunks.map((c) => c.observations).join("\n\n");
|
|
7470
7682
|
const combinedObservations = this.combineObservationsForBuffering(record.activeObservations, bufferedChunksText);
|
|
@@ -7479,6 +7691,7 @@ ${threadClose}`;
|
|
|
7479
7691
|
{
|
|
7480
7692
|
skipContinuationHints: true,
|
|
7481
7693
|
requestContext,
|
|
7694
|
+
tracingContext,
|
|
7482
7695
|
priorCurrentTask: threadOMMetadata?.currentTask,
|
|
7483
7696
|
priorSuggestedResponse: threadOMMetadata?.suggestedResponse,
|
|
7484
7697
|
priorThreadTitle: thread?.title,
|
|
@@ -7919,7 +8132,8 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
|
|
|
7919
8132
|
writer,
|
|
7920
8133
|
abortSignal,
|
|
7921
8134
|
reflectionHooks,
|
|
7922
|
-
requestContext
|
|
8135
|
+
requestContext,
|
|
8136
|
+
tracingContext
|
|
7923
8137
|
} = opts;
|
|
7924
8138
|
const { threads: allThreads } = await this.storage.listThreads({ filter: { resourceId } });
|
|
7925
8139
|
const threadMetadataMap = /* @__PURE__ */ new Map();
|
|
@@ -8097,7 +8311,8 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
|
|
|
8097
8311
|
batchPriorMetadata,
|
|
8098
8312
|
abortSignal,
|
|
8099
8313
|
requestContext,
|
|
8100
|
-
wasTruncated
|
|
8314
|
+
wasTruncated,
|
|
8315
|
+
tracingContext
|
|
8101
8316
|
);
|
|
8102
8317
|
return batchResult;
|
|
8103
8318
|
});
|
|
@@ -8225,7 +8440,8 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
|
|
|
8225
8440
|
writer,
|
|
8226
8441
|
abortSignal,
|
|
8227
8442
|
reflectionHooks,
|
|
8228
|
-
requestContext
|
|
8443
|
+
requestContext,
|
|
8444
|
+
tracingContext
|
|
8229
8445
|
});
|
|
8230
8446
|
} catch (error) {
|
|
8231
8447
|
for (const [threadId, msgs] of threadsWithMessages) {
|
|
@@ -8247,10 +8463,7 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
|
|
|
8247
8463
|
}
|
|
8248
8464
|
}
|
|
8249
8465
|
}
|
|
8250
|
-
|
|
8251
|
-
throw error;
|
|
8252
|
-
}
|
|
8253
|
-
omError("[OM] Resource-scoped observation failed", error);
|
|
8466
|
+
throw error;
|
|
8254
8467
|
} finally {
|
|
8255
8468
|
await this.storage.setObservingFlag(record.id, false);
|
|
8256
8469
|
unregisterOp(record.id, "observing");
|
|
@@ -8298,7 +8511,16 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
|
|
|
8298
8511
|
* in the background at intervals, and activated when the threshold is reached.
|
|
8299
8512
|
*/
|
|
8300
8513
|
async maybeReflect(opts) {
|
|
8301
|
-
const {
|
|
8514
|
+
const {
|
|
8515
|
+
record,
|
|
8516
|
+
observationTokens,
|
|
8517
|
+
writer,
|
|
8518
|
+
abortSignal,
|
|
8519
|
+
messageList,
|
|
8520
|
+
reflectionHooks,
|
|
8521
|
+
requestContext,
|
|
8522
|
+
tracingContext
|
|
8523
|
+
} = opts;
|
|
8302
8524
|
const lockKey = this.getLockKey(record.threadId, record.resourceId);
|
|
8303
8525
|
const reflectThreshold = getMaxThreshold(this.reflectionConfig.observationTokens);
|
|
8304
8526
|
if (this.isAsyncReflectionEnabled() && observationTokens < reflectThreshold) {
|
|
@@ -8377,7 +8599,8 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
|
|
|
8377
8599
|
abortSignal,
|
|
8378
8600
|
void 0,
|
|
8379
8601
|
void 0,
|
|
8380
|
-
requestContext
|
|
8602
|
+
requestContext,
|
|
8603
|
+
tracingContext
|
|
8381
8604
|
);
|
|
8382
8605
|
const reflectionTokenCount = this.tokenCounter.countObservations(reflectResult.observations);
|
|
8383
8606
|
await this.storage.createReflectionGeneration({
|
|
@@ -8423,10 +8646,7 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
|
|
|
8423
8646
|
await writer.custom(failedMarker).catch(() => {
|
|
8424
8647
|
});
|
|
8425
8648
|
}
|
|
8426
|
-
|
|
8427
|
-
throw error;
|
|
8428
|
-
}
|
|
8429
|
-
omError("[OM] Reflection failed", error);
|
|
8649
|
+
throw error;
|
|
8430
8650
|
} finally {
|
|
8431
8651
|
await this.storage.setReflectingFlag(record.id, false);
|
|
8432
8652
|
reflectionHooks?.onReflectionEnd?.();
|
|
@@ -8616,6 +8836,7 @@ function getObservationsAsOf(activeObservations, asOf) {
|
|
|
8616
8836
|
return chunks.join("\n\n");
|
|
8617
8837
|
}
|
|
8618
8838
|
|
|
8839
|
+
exports.ModelByInputTokens = ModelByInputTokens;
|
|
8619
8840
|
exports.OBSERVATIONAL_MEMORY_DEFAULTS = OBSERVATIONAL_MEMORY_DEFAULTS;
|
|
8620
8841
|
exports.OBSERVATION_CONTEXT_INSTRUCTIONS = OBSERVATION_CONTEXT_INSTRUCTIONS;
|
|
8621
8842
|
exports.OBSERVATION_CONTEXT_PROMPT = OBSERVATION_CONTEXT_PROMPT;
|
|
@@ -8646,5 +8867,5 @@ exports.stripEphemeralAnchorIds = stripEphemeralAnchorIds;
|
|
|
8646
8867
|
exports.stripObservationGroups = stripObservationGroups;
|
|
8647
8868
|
exports.truncateStringByTokens = truncateStringByTokens;
|
|
8648
8869
|
exports.wrapInObservationGroup = wrapInObservationGroup;
|
|
8649
|
-
//# sourceMappingURL=chunk-
|
|
8650
|
-
//# sourceMappingURL=chunk-
|
|
8870
|
+
//# sourceMappingURL=chunk-UTQV3JAT.cjs.map
|
|
8871
|
+
//# sourceMappingURL=chunk-UTQV3JAT.cjs.map
|