@mastra/server 1.13.3-alpha.1 → 1.14.0-alpha.3
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 +18 -0
- package/dist/_types/@internal_core/dist/index.d.ts +1333 -0
- package/dist/chunk-2UVJD67W.cjs +136 -0
- package/dist/chunk-2UVJD67W.cjs.map +1 -0
- package/dist/chunk-4VGZOVOI.js +656 -0
- package/dist/chunk-4VGZOVOI.js.map +1 -0
- package/dist/{chunk-A2443FGH.js → chunk-55AD3MAT.js} +24 -18
- package/dist/chunk-55AD3MAT.js.map +1 -0
- package/dist/{observational-memory-XXD6E2SO-RTIRYSYO.cjs → chunk-A6HL3JRC.cjs} +306 -130
- package/dist/chunk-A6HL3JRC.cjs.map +1 -0
- package/dist/{observational-memory-XXD6E2SO-TGAG7QCA.js → chunk-KZAB4IB3.js} +305 -131
- package/dist/chunk-KZAB4IB3.js.map +1 -0
- package/dist/{chunk-4AR4SH3H.cjs → chunk-L6ANZUEK.cjs} +7 -7
- package/dist/{chunk-4AR4SH3H.cjs.map → chunk-L6ANZUEK.cjs.map} +1 -1
- package/dist/{chunk-SFC2UJ2C.js → chunk-LE6IX2DD.js} +6 -6
- package/dist/{chunk-SFC2UJ2C.js.map → chunk-LE6IX2DD.js.map} +1 -1
- package/dist/chunk-LUHJDABR.cjs +675 -0
- package/dist/chunk-LUHJDABR.cjs.map +1 -0
- package/dist/{chunk-7P6XT5WB.cjs → chunk-OXZCCCIJ.cjs} +28 -22
- package/dist/chunk-OXZCCCIJ.cjs.map +1 -0
- package/dist/chunk-RSIZIEPW.js +131 -0
- package/dist/chunk-RSIZIEPW.js.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/observational-memory-UEDVTWS2-COV6JJZK.js +3 -0
- package/dist/observational-memory-UEDVTWS2-COV6JJZK.js.map +1 -0
- package/dist/observational-memory-UEDVTWS2-TU3KK4ZG.cjs +68 -0
- package/dist/observational-memory-UEDVTWS2-TU3KK4ZG.cjs.map +1 -0
- package/dist/server/handlers/agent-builder.cjs +16 -16
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/observability-new-endpoints.cjs +80 -0
- package/dist/server/handlers/observability-new-endpoints.cjs.map +1 -0
- package/dist/server/handlers/observability-new-endpoints.d.ts +1212 -0
- package/dist/server/handlers/observability-new-endpoints.d.ts.map +1 -0
- package/dist/server/handlers/observability-new-endpoints.js +3 -0
- package/dist/server/handlers/observability-new-endpoints.js.map +1 -0
- package/dist/server/handlers/observability-shared.cjs +24 -0
- package/dist/server/handlers/observability-shared.cjs.map +1 -0
- package/dist/server/handlers/observability-shared.d.ts +126 -0
- package/dist/server/handlers/observability-shared.d.ts.map +1 -0
- package/dist/server/handlers/observability-shared.js +3 -0
- package/dist/server/handlers/observability-shared.js.map +1 -0
- package/dist/server/handlers/observability.cjs +78 -5
- package/dist/server/handlers/observability.d.ts +22 -20
- package/dist/server/handlers/observability.d.ts.map +1 -1
- package/dist/server/handlers/observability.js +2 -1
- package/dist/server/handlers.cjs +10 -10
- package/dist/server/handlers.js +3 -3
- package/dist/server/schemas/index.cjs +82 -82
- package/dist/server/schemas/index.js +2 -2
- package/dist/server/server-adapter/index.cjs +43 -24
- package/dist/server/server-adapter/index.cjs.map +1 -1
- package/dist/server/server-adapter/index.js +25 -6
- package/dist/server/server-adapter/index.js.map +1 -1
- package/dist/server/server-adapter/routes/observability.d.ts +531 -21
- package/dist/server/server-adapter/routes/observability.d.ts.map +1 -1
- package/package.json +6 -5
- package/dist/chunk-3NG2FRSI.js +0 -41
- package/dist/chunk-3NG2FRSI.js.map +0 -1
- package/dist/chunk-5ZBS3CWT.cjs +0 -43
- package/dist/chunk-5ZBS3CWT.cjs.map +0 -1
- package/dist/chunk-7P6XT5WB.cjs.map +0 -1
- package/dist/chunk-A2443FGH.js.map +0 -1
- package/dist/observational-memory-XXD6E2SO-RTIRYSYO.cjs.map +0 -1
- package/dist/observational-memory-XXD6E2SO-TGAG7QCA.js.map +0 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var chunk5ZBS3CWT_cjs = require('./chunk-5ZBS3CWT.cjs');
|
|
4
3
|
var fs = require('fs');
|
|
5
4
|
var path = require('path');
|
|
6
5
|
var agent = require('@mastra/core/agent');
|
|
@@ -11,6 +10,99 @@ var processors = require('@mastra/core/processors');
|
|
|
11
10
|
var crypto$1 = require('crypto');
|
|
12
11
|
var async_hooks = require('async_hooks');
|
|
13
12
|
|
|
13
|
+
// ../memory/dist/chunk-4KPXPQX3.js
|
|
14
|
+
|
|
15
|
+
// ../../node_modules/.pnpm/xxhash-wasm@1.1.0/node_modules/xxhash-wasm/esm/xxhash-wasm.js
|
|
16
|
+
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]);
|
|
17
|
+
async function e() {
|
|
18
|
+
return (function(t2) {
|
|
19
|
+
const { exports: { mem: e2, xxh32: n, xxh64: r, init32: i, update32: a, digest32: o, init64: s, update64: u, digest64: c } } = t2;
|
|
20
|
+
let h = new Uint8Array(e2.buffer);
|
|
21
|
+
function g(t3, n2) {
|
|
22
|
+
if (e2.buffer.byteLength < t3 + n2) {
|
|
23
|
+
const r2 = Math.ceil((t3 + n2 - e2.buffer.byteLength) / 65536);
|
|
24
|
+
e2.grow(r2), h = new Uint8Array(e2.buffer);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function f(t3, e3, n2, r2, i2, a2) {
|
|
28
|
+
g(t3);
|
|
29
|
+
const o2 = new Uint8Array(t3);
|
|
30
|
+
return h.set(o2), n2(0, e3), o2.set(h.subarray(0, t3)), { update(e4) {
|
|
31
|
+
let n3;
|
|
32
|
+
return h.set(o2), "string" == typeof e4 ? (g(3 * e4.length, t3), n3 = w.encodeInto(e4, h.subarray(t3)).written) : (g(e4.byteLength, t3), h.set(e4, t3), n3 = e4.byteLength), r2(0, t3, n3), o2.set(h.subarray(0, t3)), this;
|
|
33
|
+
}, digest: () => (h.set(o2), a2(i2(0))) };
|
|
34
|
+
}
|
|
35
|
+
function y(t3) {
|
|
36
|
+
return t3 >>> 0;
|
|
37
|
+
}
|
|
38
|
+
const b = 2n ** 64n - 1n;
|
|
39
|
+
function d(t3) {
|
|
40
|
+
return t3 & b;
|
|
41
|
+
}
|
|
42
|
+
const w = new TextEncoder(), l = 0, p = 0n;
|
|
43
|
+
function x(t3, e3 = l) {
|
|
44
|
+
return g(3 * t3.length, 0), y(n(0, w.encodeInto(t3, h).written, e3));
|
|
45
|
+
}
|
|
46
|
+
function L(t3, e3 = p) {
|
|
47
|
+
return g(3 * t3.length, 0), d(r(0, w.encodeInto(t3, h).written, e3));
|
|
48
|
+
}
|
|
49
|
+
return { h32: x, h32ToString: (t3, e3 = l) => x(t3, e3).toString(16).padStart(8, "0"), h32Raw: (t3, e3 = l) => (g(t3.byteLength, 0), h.set(t3), y(n(0, t3.byteLength, e3))), create32: (t3 = l) => f(48, t3, i, a, o, y), h64: L, h64ToString: (t3, e3 = p) => L(t3, e3).toString(16).padStart(16, "0"), h64Raw: (t3, e3 = p) => (g(t3.byteLength, 0), h.set(t3), d(r(0, t3.byteLength, e3))), create64: (t3 = p) => f(88, t3, s, u, c, d) };
|
|
50
|
+
})((await WebAssembly.instantiate(t)).instance);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ../../node_modules/.pnpm/tokenx@1.3.0/node_modules/tokenx/dist/index.mjs
|
|
54
|
+
var PATTERNS = {
|
|
55
|
+
whitespace: /^\s+$/,
|
|
56
|
+
cjk: /[\u4E00-\u9FFF\u3400-\u4DBF\u3000-\u303F\uFF00-\uFFEF\u30A0-\u30FF\u2E80-\u2EFF\u31C0-\u31EF\u3200-\u32FF\u3300-\u33FF\uAC00-\uD7AF\u1100-\u11FF\u3130-\u318F\uA960-\uA97F\uD7B0-\uD7FF]/,
|
|
57
|
+
numeric: /^\d+(?:[.,]\d+)*$/,
|
|
58
|
+
punctuation: /[.,!?;(){}[\]<>:/\\|@#$%^&*+=`~_-]/,
|
|
59
|
+
alphanumeric: /^[a-zA-Z0-9\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]+$/
|
|
60
|
+
};
|
|
61
|
+
var TOKEN_SPLIT_PATTERN = /* @__PURE__ */ new RegExp(`(\\s+|${PATTERNS.punctuation.source}+)`);
|
|
62
|
+
var DEFAULT_CHARS_PER_TOKEN = 6;
|
|
63
|
+
var SHORT_TOKEN_THRESHOLD = 3;
|
|
64
|
+
var DEFAULT_LANGUAGE_CONFIGS = [
|
|
65
|
+
{
|
|
66
|
+
pattern: /[äöüßẞ]/i,
|
|
67
|
+
averageCharsPerToken: 3
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
pattern: /[éèêëàâîïôûùüÿçœæáíóúñ]/i,
|
|
71
|
+
averageCharsPerToken: 3
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
pattern: /[ąćęłńóśźżěščřžýůúďťň]/i,
|
|
75
|
+
averageCharsPerToken: 3.5
|
|
76
|
+
}
|
|
77
|
+
];
|
|
78
|
+
function estimateTokenCount(text, options = {}) {
|
|
79
|
+
if (!text) return 0;
|
|
80
|
+
const { defaultCharsPerToken = DEFAULT_CHARS_PER_TOKEN, languageConfigs = DEFAULT_LANGUAGE_CONFIGS } = options;
|
|
81
|
+
const segments = text.split(TOKEN_SPLIT_PATTERN).filter(Boolean);
|
|
82
|
+
let tokenCount = 0;
|
|
83
|
+
for (const segment of segments) tokenCount += estimateSegmentTokens(segment, languageConfigs, defaultCharsPerToken);
|
|
84
|
+
return tokenCount;
|
|
85
|
+
}
|
|
86
|
+
function estimateSegmentTokens(segment, languageConfigs, defaultCharsPerToken) {
|
|
87
|
+
if (PATTERNS.whitespace.test(segment)) return 0;
|
|
88
|
+
if (PATTERNS.cjk.test(segment)) return getCharacterCount(segment);
|
|
89
|
+
if (PATTERNS.numeric.test(segment)) return 1;
|
|
90
|
+
if (segment.length <= SHORT_TOKEN_THRESHOLD) return 1;
|
|
91
|
+
if (PATTERNS.punctuation.test(segment)) return segment.length > 1 ? Math.ceil(segment.length / 2) : 1;
|
|
92
|
+
if (PATTERNS.alphanumeric.test(segment)) {
|
|
93
|
+
const charsPerToken$1 = getLanguageSpecificCharsPerToken(segment, languageConfigs) ?? defaultCharsPerToken;
|
|
94
|
+
return Math.ceil(segment.length / charsPerToken$1);
|
|
95
|
+
}
|
|
96
|
+
const charsPerToken = getLanguageSpecificCharsPerToken(segment, languageConfigs) ?? defaultCharsPerToken;
|
|
97
|
+
return Math.ceil(segment.length / charsPerToken);
|
|
98
|
+
}
|
|
99
|
+
function getLanguageSpecificCharsPerToken(segment, languageConfigs) {
|
|
100
|
+
for (const config of languageConfigs) if (config.pattern.test(segment)) return config.averageCharsPerToken;
|
|
101
|
+
}
|
|
102
|
+
function getCharacterCount(text) {
|
|
103
|
+
return Array.from(text).length;
|
|
104
|
+
}
|
|
105
|
+
|
|
14
106
|
// ../../node_modules/.pnpm/image-size@2.0.2/node_modules/image-size/dist/index.mjs
|
|
15
107
|
var decoder = new TextDecoder();
|
|
16
108
|
var toUTF8String = (input, start = 0, end = input.length) => decoder.decode(input.slice(start, end));
|
|
@@ -949,60 +1041,7 @@ function imageSize(input) {
|
|
|
949
1041
|
throw new TypeError(`unsupported file type: ${type}`);
|
|
950
1042
|
}
|
|
951
1043
|
|
|
952
|
-
//
|
|
953
|
-
var PATTERNS = {
|
|
954
|
-
whitespace: /^\s+$/,
|
|
955
|
-
cjk: /[\u4E00-\u9FFF\u3400-\u4DBF\u3000-\u303F\uFF00-\uFFEF\u30A0-\u30FF\u2E80-\u2EFF\u31C0-\u31EF\u3200-\u32FF\u3300-\u33FF\uAC00-\uD7AF\u1100-\u11FF\u3130-\u318F\uA960-\uA97F\uD7B0-\uD7FF]/,
|
|
956
|
-
numeric: /^\d+(?:[.,]\d+)*$/,
|
|
957
|
-
punctuation: /[.,!?;(){}[\]<>:/\\|@#$%^&*+=`~_-]/,
|
|
958
|
-
alphanumeric: /^[a-zA-Z0-9\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]+$/
|
|
959
|
-
};
|
|
960
|
-
var TOKEN_SPLIT_PATTERN = /* @__PURE__ */ new RegExp(`(\\s+|${PATTERNS.punctuation.source}+)`);
|
|
961
|
-
var DEFAULT_CHARS_PER_TOKEN = 6;
|
|
962
|
-
var SHORT_TOKEN_THRESHOLD = 3;
|
|
963
|
-
var DEFAULT_LANGUAGE_CONFIGS = [
|
|
964
|
-
{
|
|
965
|
-
pattern: /[äöüßẞ]/i,
|
|
966
|
-
averageCharsPerToken: 3
|
|
967
|
-
},
|
|
968
|
-
{
|
|
969
|
-
pattern: /[éèêëàâîïôûùüÿçœæáíóúñ]/i,
|
|
970
|
-
averageCharsPerToken: 3
|
|
971
|
-
},
|
|
972
|
-
{
|
|
973
|
-
pattern: /[ąćęłńóśźżěščřžýůúďťň]/i,
|
|
974
|
-
averageCharsPerToken: 3.5
|
|
975
|
-
}
|
|
976
|
-
];
|
|
977
|
-
function estimateTokenCount(text, options = {}) {
|
|
978
|
-
if (!text) return 0;
|
|
979
|
-
const { defaultCharsPerToken = DEFAULT_CHARS_PER_TOKEN, languageConfigs = DEFAULT_LANGUAGE_CONFIGS } = options;
|
|
980
|
-
const segments = text.split(TOKEN_SPLIT_PATTERN).filter(Boolean);
|
|
981
|
-
let tokenCount = 0;
|
|
982
|
-
for (const segment of segments) tokenCount += estimateSegmentTokens(segment, languageConfigs, defaultCharsPerToken);
|
|
983
|
-
return tokenCount;
|
|
984
|
-
}
|
|
985
|
-
function estimateSegmentTokens(segment, languageConfigs, defaultCharsPerToken) {
|
|
986
|
-
if (PATTERNS.whitespace.test(segment)) return 0;
|
|
987
|
-
if (PATTERNS.cjk.test(segment)) return getCharacterCount(segment);
|
|
988
|
-
if (PATTERNS.numeric.test(segment)) return 1;
|
|
989
|
-
if (segment.length <= SHORT_TOKEN_THRESHOLD) return 1;
|
|
990
|
-
if (PATTERNS.punctuation.test(segment)) return segment.length > 1 ? Math.ceil(segment.length / 2) : 1;
|
|
991
|
-
if (PATTERNS.alphanumeric.test(segment)) {
|
|
992
|
-
const charsPerToken$1 = getLanguageSpecificCharsPerToken(segment, languageConfigs) ?? defaultCharsPerToken;
|
|
993
|
-
return Math.ceil(segment.length / charsPerToken$1);
|
|
994
|
-
}
|
|
995
|
-
const charsPerToken = getLanguageSpecificCharsPerToken(segment, languageConfigs) ?? defaultCharsPerToken;
|
|
996
|
-
return Math.ceil(segment.length / charsPerToken);
|
|
997
|
-
}
|
|
998
|
-
function getLanguageSpecificCharsPerToken(segment, languageConfigs) {
|
|
999
|
-
for (const config of languageConfigs) if (config.pattern.test(segment)) return config.averageCharsPerToken;
|
|
1000
|
-
}
|
|
1001
|
-
function getCharacterCount(text) {
|
|
1002
|
-
return Array.from(text).length;
|
|
1003
|
-
}
|
|
1004
|
-
|
|
1005
|
-
// ../memory/dist/chunk-SUU4IAZJ.js
|
|
1044
|
+
// ../memory/dist/chunk-4KPXPQX3.js
|
|
1006
1045
|
function formatRelativeTime(date, currentDate) {
|
|
1007
1046
|
const diffMs = currentDate.getTime() - date.getTime();
|
|
1008
1047
|
const diffDays = Math.floor(diffMs / (1e3 * 60 * 60 * 24));
|
|
@@ -1287,6 +1326,97 @@ function createActivationMarker(params) {
|
|
|
1287
1326
|
}
|
|
1288
1327
|
};
|
|
1289
1328
|
}
|
|
1329
|
+
var ENCRYPTED_CONTENT_KEY = "encryptedContent";
|
|
1330
|
+
var ENCRYPTED_CONTENT_REDACTION_THRESHOLD = 256;
|
|
1331
|
+
var DEFAULT_OBSERVER_TOOL_RESULT_MAX_TOKENS = 1e4;
|
|
1332
|
+
function isObjectLike(value) {
|
|
1333
|
+
return typeof value === "object" && value !== null;
|
|
1334
|
+
}
|
|
1335
|
+
function sanitizeToolResultValue(value, seen = /* @__PURE__ */ new WeakMap()) {
|
|
1336
|
+
if (!isObjectLike(value)) {
|
|
1337
|
+
return value;
|
|
1338
|
+
}
|
|
1339
|
+
if (seen.has(value)) {
|
|
1340
|
+
return seen.get(value);
|
|
1341
|
+
}
|
|
1342
|
+
if (Array.isArray(value)) {
|
|
1343
|
+
const sanitizedArray = [];
|
|
1344
|
+
seen.set(value, sanitizedArray);
|
|
1345
|
+
for (const item of value) {
|
|
1346
|
+
sanitizedArray.push(sanitizeToolResultValue(item, seen));
|
|
1347
|
+
}
|
|
1348
|
+
return sanitizedArray;
|
|
1349
|
+
}
|
|
1350
|
+
const sanitizedObject = {};
|
|
1351
|
+
seen.set(value, sanitizedObject);
|
|
1352
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
1353
|
+
if (key === ENCRYPTED_CONTENT_KEY && typeof entry === "string" && entry.length > ENCRYPTED_CONTENT_REDACTION_THRESHOLD) {
|
|
1354
|
+
sanitizedObject[key] = `[stripped encryptedContent: ${entry.length} characters]`;
|
|
1355
|
+
continue;
|
|
1356
|
+
}
|
|
1357
|
+
sanitizedObject[key] = sanitizeToolResultValue(entry, seen);
|
|
1358
|
+
}
|
|
1359
|
+
return sanitizedObject;
|
|
1360
|
+
}
|
|
1361
|
+
function stringifyToolResult(value) {
|
|
1362
|
+
if (typeof value === "string") {
|
|
1363
|
+
return value;
|
|
1364
|
+
}
|
|
1365
|
+
const sanitized = sanitizeToolResultValue(value);
|
|
1366
|
+
try {
|
|
1367
|
+
return JSON.stringify(sanitized, null, 2);
|
|
1368
|
+
} catch {
|
|
1369
|
+
return String(sanitized);
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
function resolveToolResultValue(part, invocationResult) {
|
|
1373
|
+
const mastraMetadata = part?.providerMetadata?.mastra;
|
|
1374
|
+
if (mastraMetadata && typeof mastraMetadata === "object" && "modelOutput" in mastraMetadata) {
|
|
1375
|
+
return {
|
|
1376
|
+
value: mastraMetadata.modelOutput,
|
|
1377
|
+
usingStoredModelOutput: true
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
return {
|
|
1381
|
+
value: invocationResult,
|
|
1382
|
+
usingStoredModelOutput: false
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
function truncateStringByTokens(text, maxTokens) {
|
|
1386
|
+
if (!text || maxTokens <= 0) {
|
|
1387
|
+
return "";
|
|
1388
|
+
}
|
|
1389
|
+
const totalTokens = estimateTokenCount(text);
|
|
1390
|
+
if (totalTokens <= maxTokens) {
|
|
1391
|
+
return text;
|
|
1392
|
+
}
|
|
1393
|
+
const buildCandidate = (sliceEnd) => {
|
|
1394
|
+
const visible = text.slice(0, sliceEnd);
|
|
1395
|
+
const omittedChars = text.length - sliceEnd;
|
|
1396
|
+
return `${visible}
|
|
1397
|
+
... [truncated ~${totalTokens - estimateTokenCount(visible)} tokens / ${omittedChars} characters]`;
|
|
1398
|
+
};
|
|
1399
|
+
let low = 0;
|
|
1400
|
+
let high = text.length;
|
|
1401
|
+
let best = buildCandidate(0);
|
|
1402
|
+
while (low <= high) {
|
|
1403
|
+
const mid = Math.floor((low + high) / 2);
|
|
1404
|
+
const candidate = buildCandidate(mid);
|
|
1405
|
+
const candidateTokens = estimateTokenCount(candidate);
|
|
1406
|
+
if (candidateTokens <= maxTokens) {
|
|
1407
|
+
best = candidate;
|
|
1408
|
+
low = mid + 1;
|
|
1409
|
+
} else {
|
|
1410
|
+
high = mid - 1;
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
return best;
|
|
1414
|
+
}
|
|
1415
|
+
function formatToolResultForObserver(value, options) {
|
|
1416
|
+
const serialized = stringifyToolResult(value);
|
|
1417
|
+
const maxTokens = options?.maxTokens ?? DEFAULT_OBSERVER_TOOL_RESULT_MAX_TOKENS;
|
|
1418
|
+
return truncateStringByTokens(serialized, maxTokens);
|
|
1419
|
+
}
|
|
1290
1420
|
var OBSERVER_EXTRACTION_INSTRUCTIONS = `CRITICAL: DISTINGUISH USER ASSERTIONS FROM QUESTIONS
|
|
1291
1421
|
|
|
1292
1422
|
When the user TELLS you something about themselves, mark it as an assertion:
|
|
@@ -1759,6 +1889,7 @@ function formatObserverAttachmentPlaceholder(part, counter) {
|
|
|
1759
1889
|
}
|
|
1760
1890
|
function formatObserverMessage(msg, counter, options) {
|
|
1761
1891
|
const maxLen = options?.maxPartLength;
|
|
1892
|
+
const maxToolResultTokens = options?.maxToolResultTokens ?? DEFAULT_OBSERVER_TOOL_RESULT_MAX_TOKENS;
|
|
1762
1893
|
const timestamp = formatObserverTimestamp(msg.createdAt);
|
|
1763
1894
|
const role = msg.role.charAt(0).toUpperCase() + msg.role.slice(1);
|
|
1764
1895
|
const timestampStr = timestamp ? ` (${timestamp})` : "";
|
|
@@ -1772,7 +1903,11 @@ function formatObserverMessage(msg, counter, options) {
|
|
|
1772
1903
|
if (part.type === "tool-invocation") {
|
|
1773
1904
|
const inv = part.toolInvocation;
|
|
1774
1905
|
if (inv.state === "result") {
|
|
1775
|
-
const
|
|
1906
|
+
const { value: resultForObserver } = resolveToolResultValue(
|
|
1907
|
+
part,
|
|
1908
|
+
inv.result
|
|
1909
|
+
);
|
|
1910
|
+
const resultStr = formatToolResultForObserver(resultForObserver, { maxTokens: maxToolResultTokens });
|
|
1776
1911
|
return `[Tool Result: ${inv.toolName}]
|
|
1777
1912
|
${maybeTruncate(resultStr, maxLen)}`;
|
|
1778
1913
|
}
|
|
@@ -1813,12 +1948,12 @@ function formatMessagesForObserver(messages, options) {
|
|
|
1813
1948
|
const counter = { nextImageId: 1, nextFileId: 1 };
|
|
1814
1949
|
return messages.map((msg) => formatObserverMessage(msg, counter, options).text).filter(Boolean).join("\n\n---\n\n");
|
|
1815
1950
|
}
|
|
1816
|
-
function buildObserverHistoryMessage(messages) {
|
|
1951
|
+
function buildObserverHistoryMessage(messages, options) {
|
|
1817
1952
|
const counter = { nextImageId: 1, nextFileId: 1 };
|
|
1818
1953
|
const content = [{ type: "text", text: "## New Message History to Observe\n\n" }];
|
|
1819
1954
|
let visibleCount = 0;
|
|
1820
1955
|
messages.forEach((message) => {
|
|
1821
|
-
const formatted = formatObserverMessage(message, counter);
|
|
1956
|
+
const formatted = formatObserverMessage(message, counter, options);
|
|
1822
1957
|
if (!formatted.text && formatted.attachments.length === 0) return;
|
|
1823
1958
|
if (visibleCount > 0) {
|
|
1824
1959
|
content.push({ type: "text", text: "\n\n---\n\n" });
|
|
@@ -1839,7 +1974,7 @@ function maybeTruncate(str, maxLen) {
|
|
|
1839
1974
|
return `${truncated}
|
|
1840
1975
|
... [truncated ${remaining} characters]`;
|
|
1841
1976
|
}
|
|
1842
|
-
function buildMultiThreadObserverHistoryMessage(messagesByThread, threadOrder) {
|
|
1977
|
+
function buildMultiThreadObserverHistoryMessage(messagesByThread, threadOrder, options) {
|
|
1843
1978
|
const counter = { nextImageId: 1, nextFileId: 1 };
|
|
1844
1979
|
const content = [
|
|
1845
1980
|
{
|
|
@@ -1857,7 +1992,7 @@ The following messages are from ${threadOrder.length} different conversation thr
|
|
|
1857
1992
|
const threadContent = [];
|
|
1858
1993
|
let visibleCount = 0;
|
|
1859
1994
|
messages.forEach((message) => {
|
|
1860
|
-
const formatted = formatObserverMessage(message, counter);
|
|
1995
|
+
const formatted = formatObserverMessage(message, counter, options);
|
|
1861
1996
|
if (!formatted.text && formatted.attachments.length === 0) return;
|
|
1862
1997
|
if (visibleCount > 0) {
|
|
1863
1998
|
threadContent.push({ type: "text", text: "\n\n---\n\n" });
|
|
@@ -3495,17 +3630,7 @@ var TokenCounter = class _TokenCounter {
|
|
|
3495
3630
|
return tokens;
|
|
3496
3631
|
}
|
|
3497
3632
|
resolveToolResultForTokenCounting(part, invocationResult) {
|
|
3498
|
-
|
|
3499
|
-
if (mastraMetadata && typeof mastraMetadata === "object" && "modelOutput" in mastraMetadata) {
|
|
3500
|
-
return {
|
|
3501
|
-
value: mastraMetadata.modelOutput,
|
|
3502
|
-
usingStoredModelOutput: true
|
|
3503
|
-
};
|
|
3504
|
-
}
|
|
3505
|
-
return {
|
|
3506
|
-
value: invocationResult,
|
|
3507
|
-
usingStoredModelOutput: false
|
|
3508
|
-
};
|
|
3633
|
+
return resolveToolResultValue(part, invocationResult);
|
|
3509
3634
|
}
|
|
3510
3635
|
estimateImageAssetTokens(part, asset, kind) {
|
|
3511
3636
|
const modelContext = this.getModelContext();
|
|
@@ -3744,19 +3869,13 @@ var TokenCounter = class _TokenCounter {
|
|
|
3744
3869
|
invocation.result
|
|
3745
3870
|
);
|
|
3746
3871
|
if (resultForCounting !== void 0) {
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
const resultJson = JSON.stringify(resultForCounting);
|
|
3755
|
-
tokens += this.readOrPersistPartEstimate(
|
|
3756
|
-
part,
|
|
3757
|
-
usingStoredModelOutput ? "tool-result-model-output-json" : "tool-result-json",
|
|
3758
|
-
resultJson
|
|
3759
|
-
);
|
|
3872
|
+
const formattedResult = formatToolResultForObserver(resultForCounting);
|
|
3873
|
+
tokens += this.readOrPersistPartEstimate(
|
|
3874
|
+
part,
|
|
3875
|
+
usingStoredModelOutput ? "tool-result-model-output-json" : "tool-result-json",
|
|
3876
|
+
formattedResult
|
|
3877
|
+
);
|
|
3878
|
+
if (typeof resultForCounting !== "string") {
|
|
3760
3879
|
overheadDelta -= 12;
|
|
3761
3880
|
}
|
|
3762
3881
|
}
|
|
@@ -3870,6 +3989,14 @@ function omDebug(msg) {
|
|
|
3870
3989
|
} catch {
|
|
3871
3990
|
}
|
|
3872
3991
|
}
|
|
3992
|
+
function getLatestStepParts(parts) {
|
|
3993
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
3994
|
+
if (parts[i]?.type === "step-start") {
|
|
3995
|
+
return parts.slice(i + 1);
|
|
3996
|
+
}
|
|
3997
|
+
}
|
|
3998
|
+
return parts;
|
|
3999
|
+
}
|
|
3873
4000
|
function omError(msg, err) {
|
|
3874
4001
|
const errStr = err instanceof Error ? err.stack ?? err.message : err !== void 0 ? String(err) : "";
|
|
3875
4002
|
const full = errStr ? `${msg}: ${errStr}` : msg;
|
|
@@ -3954,7 +4081,7 @@ var ObservationalMemory = class _ObservationalMemory {
|
|
|
3954
4081
|
/** Internal Reflector agent - created lazily */
|
|
3955
4082
|
reflectorAgent;
|
|
3956
4083
|
shouldObscureThreadIds = false;
|
|
3957
|
-
hasher =
|
|
4084
|
+
hasher = e();
|
|
3958
4085
|
threadIdCache = /* @__PURE__ */ new Map();
|
|
3959
4086
|
/**
|
|
3960
4087
|
* Track message IDs observed during this instance's lifetime.
|
|
@@ -5316,38 +5443,51 @@ ${unreflectedContent}` : bufferedReflection;
|
|
|
5316
5443
|
if (currentDate) {
|
|
5317
5444
|
optimized = addRelativeTimeToObservations(optimized, currentDate);
|
|
5318
5445
|
}
|
|
5319
|
-
|
|
5320
|
-
${OBSERVATION_CONTEXT_PROMPT}
|
|
5321
|
-
|
|
5322
|
-
<observations>
|
|
5323
|
-
${optimized}
|
|
5324
|
-
</observations>
|
|
5446
|
+
const messages = [`${OBSERVATION_CONTEXT_PROMPT}
|
|
5325
5447
|
|
|
5326
|
-
${OBSERVATION_CONTEXT_INSTRUCTIONS}
|
|
5448
|
+
${OBSERVATION_CONTEXT_INSTRUCTIONS}`];
|
|
5327
5449
|
if (unobservedContextBlocks) {
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
The following content is from OTHER conversations different from the current conversation, they're here for reference, but they're not necessarily your focus:
|
|
5450
|
+
messages.push(
|
|
5451
|
+
`The following content is from OTHER conversations different from the current conversation, they're here for reference, but they're not necessarily your focus:
|
|
5331
5452
|
START_OTHER_CONVERSATIONS_BLOCK
|
|
5332
5453
|
${unobservedContextBlocks}
|
|
5333
|
-
END_OTHER_CONVERSATIONS_BLOCK
|
|
5454
|
+
END_OTHER_CONVERSATIONS_BLOCK`
|
|
5455
|
+
);
|
|
5456
|
+
}
|
|
5457
|
+
const observationChunks = this.splitObservationContextChunks(optimized);
|
|
5458
|
+
if (observationChunks.length > 0) {
|
|
5459
|
+
messages.push("<observations>", ...observationChunks);
|
|
5334
5460
|
}
|
|
5335
5461
|
if (currentTask) {
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
<current-task>
|
|
5462
|
+
messages.push(`<current-task>
|
|
5339
5463
|
${currentTask}
|
|
5340
|
-
</current-task
|
|
5464
|
+
</current-task>`);
|
|
5341
5465
|
}
|
|
5342
5466
|
if (suggestedResponse) {
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
<suggested-response>
|
|
5467
|
+
messages.push(`<suggested-response>
|
|
5346
5468
|
${suggestedResponse}
|
|
5347
|
-
</suggested-response
|
|
5348
|
-
`;
|
|
5469
|
+
</suggested-response>`);
|
|
5349
5470
|
}
|
|
5350
|
-
return
|
|
5471
|
+
return messages;
|
|
5472
|
+
}
|
|
5473
|
+
splitObservationContextChunks(observations) {
|
|
5474
|
+
const trimmed = observations.trim();
|
|
5475
|
+
if (!trimmed) {
|
|
5476
|
+
return [];
|
|
5477
|
+
}
|
|
5478
|
+
return trimmed.split(/\n{2,}--- message boundary \(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z\) ---\n{2,}/).map((chunk) => chunk.trim()).filter(Boolean);
|
|
5479
|
+
}
|
|
5480
|
+
/**
|
|
5481
|
+
* Create a message boundary delimiter with an ISO 8601 date.
|
|
5482
|
+
* The date should be the lastObservedAt timestamp — the latest message
|
|
5483
|
+
* timestamp that was observed to produce the observations following this boundary.
|
|
5484
|
+
*/
|
|
5485
|
+
static createMessageBoundary(date) {
|
|
5486
|
+
return `
|
|
5487
|
+
|
|
5488
|
+
--- message boundary (${date.toISOString()}) ---
|
|
5489
|
+
|
|
5490
|
+
`;
|
|
5351
5491
|
}
|
|
5352
5492
|
/**
|
|
5353
5493
|
* Get threadId and resourceId from either RequestContext or MessageList
|
|
@@ -5785,7 +5925,7 @@ ${suggestedResponse}
|
|
|
5785
5925
|
if (!record.activeObservations) {
|
|
5786
5926
|
return;
|
|
5787
5927
|
}
|
|
5788
|
-
const
|
|
5928
|
+
const observationSystemMessages = this.formatObservationsForContext(
|
|
5789
5929
|
record.activeObservations,
|
|
5790
5930
|
currentTask,
|
|
5791
5931
|
suggestedResponse,
|
|
@@ -5793,7 +5933,7 @@ ${suggestedResponse}
|
|
|
5793
5933
|
currentDate
|
|
5794
5934
|
);
|
|
5795
5935
|
messageList.clearSystemMessages("observational-memory");
|
|
5796
|
-
messageList.addSystem(
|
|
5936
|
+
messageList.addSystem(observationSystemMessages, "observational-memory");
|
|
5797
5937
|
const continuationMessage = {
|
|
5798
5938
|
id: `om-continuation`,
|
|
5799
5939
|
role: "user",
|
|
@@ -6069,12 +6209,20 @@ ${suggestedResponse}
|
|
|
6069
6209
|
const sealedIds = /* @__PURE__ */ new Set([...stateSealedIds, ...staticSealedIds]);
|
|
6070
6210
|
state.sealedIds = sealedIds;
|
|
6071
6211
|
const lockKey = this.getLockKey(threadId, resourceId);
|
|
6212
|
+
const lastMessage = allMessages[allMessages.length - 1];
|
|
6213
|
+
const latestStepParts = getLatestStepParts(lastMessage?.content?.parts ?? []);
|
|
6214
|
+
const hasIncompleteToolCalls = latestStepParts.some(
|
|
6215
|
+
(part) => part?.type === "tool-invocation" && part.toolInvocation?.state === "call"
|
|
6216
|
+
);
|
|
6217
|
+
omDebug(
|
|
6218
|
+
`[OM:deferred-check] hasIncompleteToolCalls=${hasIncompleteToolCalls}, latestStepPartsCount=${latestStepParts.length}`
|
|
6219
|
+
);
|
|
6072
6220
|
if (this.isAsyncObservationEnabled() && totalPendingTokens < threshold) {
|
|
6073
6221
|
const shouldTrigger = this.shouldTriggerAsyncObservation(totalPendingTokens, lockKey, record, threshold);
|
|
6074
6222
|
omDebug(
|
|
6075
|
-
`[OM:async-obs] belowThreshold: pending=${totalPendingTokens}, unbuffered=${unbufferedPendingTokens}, threshold=${threshold}, shouldTrigger=${shouldTrigger}, isBufferingObs=${record.isBufferingObservation}, lastBufferedAt=${record.lastBufferedAtTokens}`
|
|
6223
|
+
`[OM:async-obs] belowThreshold: pending=${totalPendingTokens}, unbuffered=${unbufferedPendingTokens}, threshold=${threshold}, shouldTrigger=${shouldTrigger}, isBufferingObs=${record.isBufferingObservation}, lastBufferedAt=${record.lastBufferedAtTokens}, hasIncompleteToolCalls=${hasIncompleteToolCalls}`
|
|
6076
6224
|
);
|
|
6077
|
-
if (shouldTrigger) {
|
|
6225
|
+
if (shouldTrigger && !hasIncompleteToolCalls) {
|
|
6078
6226
|
void this.startAsyncBufferedObservation(
|
|
6079
6227
|
record,
|
|
6080
6228
|
threadId,
|
|
@@ -6088,9 +6236,9 @@ ${suggestedResponse}
|
|
|
6088
6236
|
} else if (this.isAsyncObservationEnabled()) {
|
|
6089
6237
|
const shouldTrigger = this.shouldTriggerAsyncObservation(totalPendingTokens, lockKey, record, threshold);
|
|
6090
6238
|
omDebug(
|
|
6091
|
-
`[OM:async-obs] atOrAboveThreshold: pending=${totalPendingTokens}, unbuffered=${unbufferedPendingTokens}, threshold=${threshold}, step=${stepNumber}, shouldTrigger=${shouldTrigger}`
|
|
6239
|
+
`[OM:async-obs] atOrAboveThreshold: pending=${totalPendingTokens}, unbuffered=${unbufferedPendingTokens}, threshold=${threshold}, step=${stepNumber}, shouldTrigger=${shouldTrigger}, hasIncompleteToolCalls=${hasIncompleteToolCalls}`
|
|
6092
6240
|
);
|
|
6093
|
-
if (shouldTrigger) {
|
|
6241
|
+
if (shouldTrigger && !hasIncompleteToolCalls) {
|
|
6094
6242
|
void this.startAsyncBufferedObservation(
|
|
6095
6243
|
record,
|
|
6096
6244
|
threadId,
|
|
@@ -6105,7 +6253,7 @@ ${suggestedResponse}
|
|
|
6105
6253
|
if (stepNumber > 0) {
|
|
6106
6254
|
await this.handlePerStepSave(messageList, sealedIds, threadId, resourceId, state);
|
|
6107
6255
|
}
|
|
6108
|
-
if (stepNumber > 0 && totalPendingTokens >= threshold) {
|
|
6256
|
+
if (stepNumber > 0 && !hasIncompleteToolCalls && totalPendingTokens >= threshold) {
|
|
6109
6257
|
reproCaptureDetails.thresholdReached = true;
|
|
6110
6258
|
const { observationSucceeded, updatedRecord, activatedMessageIds } = await this.handleThresholdReached(
|
|
6111
6259
|
messageList,
|
|
@@ -6463,16 +6611,14 @@ ${cleanObservations}
|
|
|
6463
6611
|
* merge the observations into that section to reduce token usage.
|
|
6464
6612
|
* Otherwise, append as a new section.
|
|
6465
6613
|
*/
|
|
6466
|
-
replaceOrAppendThreadSection(existingObservations, _threadId, newThreadSection) {
|
|
6614
|
+
replaceOrAppendThreadSection(existingObservations, _threadId, newThreadSection, lastObservedAt) {
|
|
6467
6615
|
if (!existingObservations) {
|
|
6468
6616
|
return newThreadSection;
|
|
6469
6617
|
}
|
|
6470
6618
|
const threadIdMatch = newThreadSection.match(/<thread id="([^"]+)">/);
|
|
6471
6619
|
const dateMatch = newThreadSection.match(/Date:\s*([A-Za-z]+\s+\d+,\s+\d+)/);
|
|
6472
6620
|
if (!threadIdMatch || !dateMatch) {
|
|
6473
|
-
return `${existingObservations}
|
|
6474
|
-
|
|
6475
|
-
${newThreadSection}`;
|
|
6621
|
+
return `${existingObservations}${_ObservationalMemory.createMessageBoundary(lastObservedAt)}${newThreadSection}`;
|
|
6476
6622
|
}
|
|
6477
6623
|
const newThreadId = threadIdMatch[1];
|
|
6478
6624
|
const newDate = dateMatch[1];
|
|
@@ -6507,9 +6653,7 @@ ${threadClose}`;
|
|
|
6507
6653
|
}
|
|
6508
6654
|
}
|
|
6509
6655
|
}
|
|
6510
|
-
return `${existingObservations}
|
|
6511
|
-
|
|
6512
|
-
${newThreadSection}`;
|
|
6656
|
+
return `${existingObservations}${_ObservationalMemory.createMessageBoundary(lastObservedAt)}${newThreadSection}`;
|
|
6513
6657
|
}
|
|
6514
6658
|
/**
|
|
6515
6659
|
* Sort threads by their oldest unobserved message.
|
|
@@ -6523,7 +6667,7 @@ ${newThreadSection}`;
|
|
|
6523
6667
|
);
|
|
6524
6668
|
return { threadId, oldestTimestamp };
|
|
6525
6669
|
}).sort((a, b) => a.oldestTimestamp - b.oldestTimestamp);
|
|
6526
|
-
return threadOrder.map((
|
|
6670
|
+
return threadOrder.map((t2) => t2.threadId);
|
|
6527
6671
|
}
|
|
6528
6672
|
/**
|
|
6529
6673
|
* Do synchronous observation (fallback when no buffering)
|
|
@@ -6592,19 +6736,22 @@ ${newThreadSection}`;
|
|
|
6592
6736
|
priorSuggestedResponse: threadOMMetadata?.suggestedResponse,
|
|
6593
6737
|
wasTruncated
|
|
6594
6738
|
});
|
|
6739
|
+
const lastObservedAt = this.getMaxMessageTimestamp(messagesToObserve);
|
|
6595
6740
|
const existingObservations = freshRecord?.activeObservations ?? record.activeObservations ?? "";
|
|
6596
6741
|
let newObservations;
|
|
6597
6742
|
if (this.scope === "resource") {
|
|
6598
6743
|
const threadSection = await this.wrapWithThreadTag(threadId, result.observations);
|
|
6599
|
-
newObservations = this.replaceOrAppendThreadSection(
|
|
6744
|
+
newObservations = this.replaceOrAppendThreadSection(
|
|
6745
|
+
existingObservations,
|
|
6746
|
+
threadId,
|
|
6747
|
+
threadSection,
|
|
6748
|
+
lastObservedAt
|
|
6749
|
+
);
|
|
6600
6750
|
} else {
|
|
6601
|
-
newObservations = existingObservations ? `${existingObservations}
|
|
6602
|
-
|
|
6603
|
-
${result.observations}` : result.observations;
|
|
6751
|
+
newObservations = existingObservations ? `${existingObservations}${_ObservationalMemory.createMessageBoundary(lastObservedAt)}${result.observations}` : result.observations;
|
|
6604
6752
|
}
|
|
6605
6753
|
let totalTokenCount = this.tokenCounter.countObservations(newObservations);
|
|
6606
6754
|
const cycleObservationTokens = this.tokenCounter.countObservations(result.observations);
|
|
6607
|
-
const lastObservedAt = this.getMaxMessageTimestamp(messagesToObserve);
|
|
6608
6755
|
const newMessageIds = messagesToObserve.map((m) => m.id);
|
|
6609
6756
|
const existingIds = freshRecord?.observedMessageIds ?? record.observedMessageIds ?? [];
|
|
6610
6757
|
const allObservedIds = [.../* @__PURE__ */ new Set([...Array.isArray(existingIds) ? existingIds : [], ...newMessageIds])];
|
|
@@ -7498,9 +7645,14 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
|
|
|
7498
7645
|
if (!obsResult) continue;
|
|
7499
7646
|
const { threadId, threadMessages, result } = obsResult;
|
|
7500
7647
|
cycleObservationTokens += this.tokenCounter.countObservations(result.observations);
|
|
7501
|
-
const threadSection = await this.wrapWithThreadTag(threadId, result.observations);
|
|
7502
|
-
currentObservations = this.replaceOrAppendThreadSection(currentObservations, threadId, threadSection);
|
|
7503
7648
|
const threadLastObservedAt = this.getMaxMessageTimestamp(threadMessages);
|
|
7649
|
+
const threadSection = await this.wrapWithThreadTag(threadId, result.observations);
|
|
7650
|
+
currentObservations = this.replaceOrAppendThreadSection(
|
|
7651
|
+
currentObservations,
|
|
7652
|
+
threadId,
|
|
7653
|
+
threadSection,
|
|
7654
|
+
threadLastObservedAt
|
|
7655
|
+
);
|
|
7504
7656
|
const thread = await this.storage.getThreadById({ threadId });
|
|
7505
7657
|
if (thread) {
|
|
7506
7658
|
const newMetadata = memory.setThreadOMMetadata(thread.metadata, {
|
|
@@ -7944,6 +8096,28 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
|
|
|
7944
8096
|
return this.reflectionConfig;
|
|
7945
8097
|
}
|
|
7946
8098
|
};
|
|
8099
|
+
var BOUNDARY_WITH_DATE_RE = /\n{2,}--- message boundary \((\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z)\) ---\n{2,}/;
|
|
8100
|
+
function getObservationsAsOf(activeObservations, asOf) {
|
|
8101
|
+
const trimmed = activeObservations.trim();
|
|
8102
|
+
if (!trimmed) return "";
|
|
8103
|
+
const parts = trimmed.split(BOUNDARY_WITH_DATE_RE);
|
|
8104
|
+
const chunks = [];
|
|
8105
|
+
const firstChunk = parts[0]?.trim();
|
|
8106
|
+
if (firstChunk) {
|
|
8107
|
+
chunks.push(firstChunk);
|
|
8108
|
+
}
|
|
8109
|
+
for (let i = 1; i < parts.length; i += 2) {
|
|
8110
|
+
const dateStr = parts[i];
|
|
8111
|
+
const chunk = parts[i + 1]?.trim();
|
|
8112
|
+
if (!chunk) continue;
|
|
8113
|
+
const boundaryDate = new Date(dateStr);
|
|
8114
|
+
if (isNaN(boundaryDate.getTime())) continue;
|
|
8115
|
+
if (boundaryDate <= asOf) {
|
|
8116
|
+
chunks.push(chunk);
|
|
8117
|
+
}
|
|
8118
|
+
}
|
|
8119
|
+
return chunks.join("\n\n");
|
|
8120
|
+
}
|
|
7947
8121
|
|
|
7948
8122
|
exports.OBSERVATIONAL_MEMORY_DEFAULTS = OBSERVATIONAL_MEMORY_DEFAULTS;
|
|
7949
8123
|
exports.OBSERVATION_CONTEXT_INSTRUCTIONS = OBSERVATION_CONTEXT_INSTRUCTIONS;
|
|
@@ -7954,10 +8128,12 @@ exports.ObservationalMemory = ObservationalMemory;
|
|
|
7954
8128
|
exports.TokenCounter = TokenCounter;
|
|
7955
8129
|
exports.buildObserverPrompt = buildObserverPrompt;
|
|
7956
8130
|
exports.buildObserverSystemPrompt = buildObserverSystemPrompt;
|
|
8131
|
+
exports.e = e;
|
|
7957
8132
|
exports.extractCurrentTask = extractCurrentTask;
|
|
7958
8133
|
exports.formatMessagesForObserver = formatMessagesForObserver;
|
|
8134
|
+
exports.getObservationsAsOf = getObservationsAsOf;
|
|
7959
8135
|
exports.hasCurrentTaskSection = hasCurrentTaskSection;
|
|
7960
8136
|
exports.optimizeObservationsForContext = optimizeObservationsForContext;
|
|
7961
8137
|
exports.parseObserverOutput = parseObserverOutput;
|
|
7962
|
-
//# sourceMappingURL=
|
|
7963
|
-
//# sourceMappingURL=
|
|
8138
|
+
//# sourceMappingURL=chunk-A6HL3JRC.cjs.map
|
|
8139
|
+
//# sourceMappingURL=chunk-A6HL3JRC.cjs.map
|