@mastra/server 1.23.0 → 1.24.0-alpha.1
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 +32 -0
- package/dist/{chunk-TX3IIDZN.js → chunk-3CXXUF4P.js} +137 -45
- package/dist/chunk-3CXXUF4P.js.map +1 -0
- package/dist/{chunk-7TKB6WYH.js → chunk-6NY3T42O.js} +5 -3
- package/dist/chunk-6NY3T42O.js.map +1 -0
- package/dist/{chunk-IGUQV25I.js → chunk-7K4TRBNS.js} +10 -4
- package/dist/chunk-7K4TRBNS.js.map +1 -0
- package/dist/{chunk-XO5PXSFC.js → chunk-GIIEDO2K.js} +3 -3
- package/dist/{chunk-XO5PXSFC.js.map → chunk-GIIEDO2K.js.map} +1 -1
- package/dist/{chunk-MO3ZKWYY.js → chunk-J4VUM7GK.js} +547 -389
- package/dist/chunk-J4VUM7GK.js.map +1 -0
- package/dist/{chunk-KU4DBPKJ.cjs → chunk-JYST3GVF.cjs} +10 -4
- package/dist/chunk-JYST3GVF.cjs.map +1 -0
- package/dist/{chunk-3D2IBKF6.cjs → chunk-KAIOMGUE.cjs} +51 -25
- package/dist/chunk-KAIOMGUE.cjs.map +1 -0
- package/dist/{chunk-WZ6XPWVK.js → chunk-LUSXAYXR.js} +45 -19
- package/dist/chunk-LUSXAYXR.js.map +1 -0
- package/dist/{chunk-2KF7EWOT.cjs → chunk-MPLSILC4.cjs} +149 -57
- package/dist/chunk-MPLSILC4.cjs.map +1 -0
- package/dist/{chunk-4HHL4C6V.cjs → chunk-NYZJMFML.cjs} +11 -11
- package/dist/{chunk-4HHL4C6V.cjs.map → chunk-NYZJMFML.cjs.map} +1 -1
- package/dist/{chunk-UI3SS2JO.cjs → chunk-P6CD6Y4Z.cjs} +4 -4
- package/dist/{chunk-UI3SS2JO.cjs.map → chunk-P6CD6Y4Z.cjs.map} +1 -1
- package/dist/{chunk-UHWF2UKO.cjs → chunk-QOTVR5LN.cjs} +546 -388
- package/dist/chunk-QOTVR5LN.cjs.map +1 -0
- package/dist/{chunk-GNVZDFY5.cjs → chunk-SAOJYYFE.cjs} +5 -3
- package/dist/chunk-SAOJYYFE.cjs.map +1 -0
- package/dist/{chunk-T4RZ3X4I.js → chunk-SLPNFGM2.js} +3 -3
- package/dist/{chunk-T4RZ3X4I.js.map → chunk-SLPNFGM2.js.map} +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/{observational-memory-OVRHDQRG-OCHV6RZ7.cjs → observational-memory-S6YN56D3-FSYUYFQG.cjs} +26 -26
- package/dist/{observational-memory-OVRHDQRG-OCHV6RZ7.cjs.map → observational-memory-S6YN56D3-FSYUYFQG.cjs.map} +1 -1
- package/dist/{observational-memory-OVRHDQRG-RC3PRA65.js → observational-memory-S6YN56D3-UNZI7MEB.js} +3 -3
- package/dist/{observational-memory-OVRHDQRG-RC3PRA65.js.map → observational-memory-S6YN56D3-UNZI7MEB.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/agent-versions.cjs +8 -8
- package/dist/server/handlers/agent-versions.d.ts.map +1 -1
- package/dist/server/handlers/agent-versions.js +1 -1
- package/dist/server/handlers/conversations.cjs +5 -5
- package/dist/server/handlers/conversations.js +1 -1
- package/dist/server/handlers/responses.cjs +4 -4
- package/dist/server/handlers/responses.d.ts +2 -2
- package/dist/server/handlers/responses.d.ts.map +1 -1
- package/dist/server/handlers/responses.js +1 -1
- package/dist/server/handlers.cjs +6 -6
- package/dist/server/handlers.js +3 -3
- package/dist/server/schemas/index.cjs +25 -25
- package/dist/server/schemas/index.js +2 -2
- package/dist/server/schemas/responses.d.ts +1 -1
- package/dist/server/schemas/responses.d.ts.map +1 -1
- package/dist/server/server-adapter/index.cjs +31 -31
- package/dist/server/server-adapter/index.js +4 -4
- package/dist/server/server-adapter/routes/responses.d.ts +2 -2
- package/package.json +5 -5
- package/dist/chunk-2KF7EWOT.cjs.map +0 -1
- package/dist/chunk-3D2IBKF6.cjs.map +0 -1
- package/dist/chunk-7TKB6WYH.js.map +0 -1
- package/dist/chunk-GNVZDFY5.cjs.map +0 -1
- package/dist/chunk-IGUQV25I.js.map +0 -1
- package/dist/chunk-KU4DBPKJ.cjs.map +0 -1
- package/dist/chunk-MO3ZKWYY.js.map +0 -1
- package/dist/chunk-TX3IIDZN.js.map +0 -1
- package/dist/chunk-UHWF2UKO.cjs.map +0 -1
- package/dist/chunk-WZ6XPWVK.js.map +0 -1
|
@@ -10,8 +10,8 @@ var path = require('path');
|
|
|
10
10
|
var crypto$1 = require('crypto');
|
|
11
11
|
var agent = require('@mastra/core/agent');
|
|
12
12
|
var observability = require('@mastra/core/observability');
|
|
13
|
-
var async_hooks = require('async_hooks');
|
|
14
13
|
var util = require('util');
|
|
14
|
+
var async_hooks = require('async_hooks');
|
|
15
15
|
|
|
16
16
|
// ../../node_modules/.pnpm/xxhash-wasm@1.1.0/node_modules/xxhash-wasm/esm/xxhash-wasm.js
|
|
17
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,6 +1041,8 @@ function imageSize(input) {
|
|
|
1041
1041
|
}
|
|
1042
1042
|
throw new TypeError(`unsupported file type: ${type}`);
|
|
1043
1043
|
}
|
|
1044
|
+
|
|
1045
|
+
// ../memory/dist/chunk-ZEKCVX4E.js
|
|
1044
1046
|
var OM_DEBUG_LOG = process.env.OM_DEBUG ? path.join(process.cwd(), "om-debug.log") : null;
|
|
1045
1047
|
function omDebug(msg) {
|
|
1046
1048
|
if (!OM_DEBUG_LOG) return;
|
|
@@ -3925,11 +3927,13 @@ var OBSERVER_IMAGE_FILE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
3925
3927
|
"heif",
|
|
3926
3928
|
"avif"
|
|
3927
3929
|
]);
|
|
3928
|
-
function
|
|
3929
|
-
return createdAt ?
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3930
|
+
function formatObserverDate(createdAt) {
|
|
3931
|
+
return createdAt ? `${createdAt.toLocaleDateString("en-US", {
|
|
3932
|
+
month: "short"
|
|
3933
|
+
})} ${createdAt.getDate()} ${createdAt.getFullYear()}` : "";
|
|
3934
|
+
}
|
|
3935
|
+
function formatObserverTime(createdAt) {
|
|
3936
|
+
return createdAt ? createdAt.toLocaleTimeString("en-US", {
|
|
3933
3937
|
hour: "numeric",
|
|
3934
3938
|
minute: "2-digit",
|
|
3935
3939
|
hour12: true
|
|
@@ -4020,19 +4024,72 @@ function formatObserverAttachmentPlaceholder(part, counter) {
|
|
|
4020
4024
|
const label = resolveObserverAttachmentLabel(part);
|
|
4021
4025
|
return label ? `[${attachmentType} #${attachmentId}: ${label}]` : `[${attachmentType} #${attachmentId}]`;
|
|
4022
4026
|
}
|
|
4027
|
+
function formatObserverPartLine(title, body, time, previousTime) {
|
|
4028
|
+
const timeLabel = time && time !== previousTime ? ` (${time})` : "";
|
|
4029
|
+
return `${title}${timeLabel}: ${body}`;
|
|
4030
|
+
}
|
|
4031
|
+
function normalizeObserverCreatedAt(createdAt) {
|
|
4032
|
+
if (createdAt instanceof Date) {
|
|
4033
|
+
if (Number.isNaN(createdAt.getTime())) {
|
|
4034
|
+
return void 0;
|
|
4035
|
+
}
|
|
4036
|
+
return createdAt;
|
|
4037
|
+
}
|
|
4038
|
+
if (typeof createdAt === "number" || typeof createdAt === "string") {
|
|
4039
|
+
const date = new Date(createdAt);
|
|
4040
|
+
if (Number.isNaN(date.getTime())) {
|
|
4041
|
+
return void 0;
|
|
4042
|
+
}
|
|
4043
|
+
return date;
|
|
4044
|
+
}
|
|
4045
|
+
return void 0;
|
|
4046
|
+
}
|
|
4047
|
+
function formatObserverLines(lines, context = {}) {
|
|
4048
|
+
const output = [];
|
|
4049
|
+
let previousDate = context.previousDate;
|
|
4050
|
+
let previousTime = context.previousTime;
|
|
4051
|
+
for (const line of lines) {
|
|
4052
|
+
if (line.date && line.date !== previousDate) {
|
|
4053
|
+
output.push(`${line.date}:`);
|
|
4054
|
+
previousDate = line.date;
|
|
4055
|
+
previousTime = void 0;
|
|
4056
|
+
}
|
|
4057
|
+
output.push(formatObserverPartLine(line.title, line.body, line.time, previousTime));
|
|
4058
|
+
previousTime = line.time || previousTime;
|
|
4059
|
+
}
|
|
4060
|
+
return {
|
|
4061
|
+
text: output.join("\n"),
|
|
4062
|
+
context: { previousDate, previousTime }
|
|
4063
|
+
};
|
|
4064
|
+
}
|
|
4023
4065
|
function formatObserverMessage(msg, counter, options) {
|
|
4024
4066
|
const maxLen = options?.maxPartLength;
|
|
4025
4067
|
const maxToolResultTokens = options?.maxToolResultTokens ?? DEFAULT_OBSERVER_TOOL_RESULT_MAX_TOKENS;
|
|
4026
|
-
const timestamp = formatObserverTimestamp(msg.createdAt);
|
|
4027
4068
|
const role = msg.role.charAt(0).toUpperCase() + msg.role.slice(1);
|
|
4028
|
-
const timestampStr = timestamp ? ` (${timestamp})` : "";
|
|
4029
4069
|
const attachments = [];
|
|
4030
|
-
|
|
4070
|
+
const messageCreatedAt = normalizeObserverCreatedAt(msg.createdAt);
|
|
4071
|
+
let lines = [];
|
|
4072
|
+
const pushLine = (title, body, createdAt) => {
|
|
4073
|
+
if (!body) {
|
|
4074
|
+
return;
|
|
4075
|
+
}
|
|
4076
|
+
const normalizedCreatedAt = normalizeObserverCreatedAt(createdAt) ?? messageCreatedAt;
|
|
4077
|
+
lines.push({
|
|
4078
|
+
date: formatObserverDate(normalizedCreatedAt),
|
|
4079
|
+
time: formatObserverTime(normalizedCreatedAt),
|
|
4080
|
+
title,
|
|
4081
|
+
body
|
|
4082
|
+
});
|
|
4083
|
+
};
|
|
4031
4084
|
if (typeof msg.content === "string") {
|
|
4032
|
-
|
|
4085
|
+
pushLine(role, maybeTruncate(msg.content, maxLen), messageCreatedAt);
|
|
4033
4086
|
} else if (msg.content?.parts && Array.isArray(msg.content.parts) && msg.content.parts.length > 0) {
|
|
4034
|
-
|
|
4035
|
-
|
|
4087
|
+
msg.content.parts.forEach((part) => {
|
|
4088
|
+
const partCreatedAt = normalizeObserverCreatedAt(part.createdAt) ?? messageCreatedAt;
|
|
4089
|
+
if (part.type === "text") {
|
|
4090
|
+
pushLine(role, maybeTruncate(part.text, maxLen), partCreatedAt);
|
|
4091
|
+
return;
|
|
4092
|
+
}
|
|
4036
4093
|
if (part.type === "tool-invocation") {
|
|
4037
4094
|
const inv = part.toolInvocation;
|
|
4038
4095
|
if (inv.state === "result") {
|
|
@@ -4040,19 +4097,24 @@ function formatObserverMessage(msg, counter, options) {
|
|
|
4040
4097
|
part,
|
|
4041
4098
|
inv.result
|
|
4042
4099
|
);
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4100
|
+
pushLine(
|
|
4101
|
+
`Tool Result ${inv.toolName}`,
|
|
4102
|
+
maybeTruncate(formatToolResultForObserver(resultForObserver, { maxTokens: maxToolResultTokens }), maxLen),
|
|
4103
|
+
partCreatedAt
|
|
4104
|
+
);
|
|
4105
|
+
return;
|
|
4046
4106
|
}
|
|
4047
|
-
|
|
4048
|
-
return
|
|
4049
|
-
${maybeTruncate(argsStr, maxLen)}`;
|
|
4107
|
+
pushLine(`Tool Call ${inv.toolName}`, maybeTruncate(JSON.stringify(inv.args, null, 2), maxLen), partCreatedAt);
|
|
4108
|
+
return;
|
|
4050
4109
|
}
|
|
4051
4110
|
const partType = part.type;
|
|
4052
4111
|
if (partType === "reasoning") {
|
|
4053
4112
|
const reasoning = part.reasoning;
|
|
4054
|
-
if (reasoning)
|
|
4055
|
-
|
|
4113
|
+
if (!reasoning) {
|
|
4114
|
+
return;
|
|
4115
|
+
}
|
|
4116
|
+
pushLine("Reasoning", maybeTruncate(reasoning, maxLen), partCreatedAt);
|
|
4117
|
+
return;
|
|
4056
4118
|
}
|
|
4057
4119
|
if (partType === "image" || partType === "file") {
|
|
4058
4120
|
const attachment = part;
|
|
@@ -4060,40 +4122,58 @@ ${maybeTruncate(argsStr, maxLen)}`;
|
|
|
4060
4122
|
if (inputAttachment) {
|
|
4061
4123
|
attachments.push(inputAttachment);
|
|
4062
4124
|
}
|
|
4063
|
-
|
|
4125
|
+
pushLine(
|
|
4126
|
+
partType === "image" ? "Image" : "File",
|
|
4127
|
+
formatObserverAttachmentPlaceholder(attachment, counter),
|
|
4128
|
+
partCreatedAt
|
|
4129
|
+
);
|
|
4064
4130
|
}
|
|
4065
|
-
|
|
4066
|
-
return "";
|
|
4067
|
-
}).filter(Boolean).join("\n");
|
|
4131
|
+
});
|
|
4068
4132
|
} else if (msg.content?.content) {
|
|
4069
|
-
|
|
4133
|
+
pushLine(role, maybeTruncate(msg.content.content, maxLen), messageCreatedAt);
|
|
4070
4134
|
}
|
|
4071
|
-
if (
|
|
4072
|
-
return {
|
|
4135
|
+
if (lines.length === 0 && attachments.length === 0) {
|
|
4136
|
+
return { lines: [], attachments };
|
|
4073
4137
|
}
|
|
4074
4138
|
return {
|
|
4075
|
-
|
|
4076
|
-
${content}`,
|
|
4139
|
+
lines,
|
|
4077
4140
|
attachments
|
|
4078
4141
|
};
|
|
4079
4142
|
}
|
|
4080
4143
|
function formatMessagesForObserver(messages, options) {
|
|
4081
4144
|
const counter = { nextImageId: 1, nextFileId: 1 };
|
|
4082
|
-
|
|
4145
|
+
const sections = [];
|
|
4146
|
+
let context = {};
|
|
4147
|
+
for (const message of messages) {
|
|
4148
|
+
const formatted = formatObserverMessage(message, counter, options);
|
|
4149
|
+
if (formatted.lines.length === 0) {
|
|
4150
|
+
continue;
|
|
4151
|
+
}
|
|
4152
|
+
const rendered = formatObserverLines(formatted.lines, context);
|
|
4153
|
+
if (!rendered.text) {
|
|
4154
|
+
continue;
|
|
4155
|
+
}
|
|
4156
|
+
sections.push(rendered.text);
|
|
4157
|
+
context = rendered.context;
|
|
4158
|
+
}
|
|
4159
|
+
return sections.join("\n");
|
|
4160
|
+
}
|
|
4161
|
+
function appendFormattedObserverMessage(content, formatted, context) {
|
|
4162
|
+
const rendered = formatObserverLines(formatted.lines, context);
|
|
4163
|
+
if (rendered.text) {
|
|
4164
|
+
content.push({ type: "text", text: rendered.text });
|
|
4165
|
+
}
|
|
4166
|
+
content.push(...formatted.attachments);
|
|
4167
|
+
return rendered.context;
|
|
4083
4168
|
}
|
|
4084
4169
|
function buildObserverHistoryMessage(messages, options) {
|
|
4085
4170
|
const counter = { nextImageId: 1, nextFileId: 1 };
|
|
4086
4171
|
const content = [{ type: "text", text: "## New Message History to Observe\n\n" }];
|
|
4087
|
-
let
|
|
4172
|
+
let context = {};
|
|
4088
4173
|
messages.forEach((message) => {
|
|
4089
4174
|
const formatted = formatObserverMessage(message, counter, options);
|
|
4090
|
-
if (
|
|
4091
|
-
|
|
4092
|
-
content.push({ type: "text", text: "\n\n---\n\n" });
|
|
4093
|
-
}
|
|
4094
|
-
content.push({ type: "text", text: formatted.text });
|
|
4095
|
-
content.push(...formatted.attachments);
|
|
4096
|
-
visibleCount++;
|
|
4175
|
+
if (formatted.lines.length === 0 && formatted.attachments.length === 0) return;
|
|
4176
|
+
context = appendFormattedObserverMessage(content, formatted, context);
|
|
4097
4177
|
});
|
|
4098
4178
|
return {
|
|
4099
4179
|
role: "user",
|
|
@@ -4123,18 +4203,15 @@ The following messages are from ${threadOrder.length} different conversation thr
|
|
|
4123
4203
|
const messages = messagesByThread.get(threadId);
|
|
4124
4204
|
if (!messages || messages.length === 0) return;
|
|
4125
4205
|
const threadContent = [];
|
|
4126
|
-
let
|
|
4206
|
+
let context = {};
|
|
4207
|
+
let hasVisibleContent = false;
|
|
4127
4208
|
messages.forEach((message) => {
|
|
4128
4209
|
const formatted = formatObserverMessage(message, counter, options);
|
|
4129
|
-
if (
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
}
|
|
4133
|
-
threadContent.push({ type: "text", text: formatted.text });
|
|
4134
|
-
threadContent.push(...formatted.attachments);
|
|
4135
|
-
visibleCount++;
|
|
4210
|
+
if (formatted.lines.length === 0 && formatted.attachments.length === 0) return;
|
|
4211
|
+
context = appendFormattedObserverMessage(threadContent, formatted, context);
|
|
4212
|
+
hasVisibleContent = true;
|
|
4136
4213
|
});
|
|
4137
|
-
if (
|
|
4214
|
+
if (!hasVisibleContent) return;
|
|
4138
4215
|
content.push({ type: "text", text: `<thread id="${threadId}">
|
|
4139
4216
|
` });
|
|
4140
4217
|
content.push(...threadContent);
|
|
@@ -5584,100 +5661,422 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
|
|
|
5584
5661
|
}
|
|
5585
5662
|
}
|
|
5586
5663
|
};
|
|
5587
|
-
|
|
5588
|
-
"
|
|
5589
|
-
"jpg",
|
|
5590
|
-
"jpeg",
|
|
5591
|
-
"webp",
|
|
5592
|
-
"gif",
|
|
5593
|
-
"bmp",
|
|
5594
|
-
"tiff",
|
|
5595
|
-
"tif",
|
|
5596
|
-
"heic",
|
|
5597
|
-
"heif",
|
|
5598
|
-
"avif"
|
|
5599
|
-
]);
|
|
5600
|
-
var TOKEN_ESTIMATE_CACHE_VERSION = 6;
|
|
5601
|
-
var DEFAULT_IMAGE_ESTIMATOR = {
|
|
5602
|
-
baseTokens: 85,
|
|
5603
|
-
tileTokens: 170,
|
|
5604
|
-
fallbackTiles: 4
|
|
5605
|
-
};
|
|
5606
|
-
var GOOGLE_LEGACY_IMAGE_TOKENS_PER_TILE = 258;
|
|
5607
|
-
var GOOGLE_GEMINI_3_IMAGE_TOKENS_BY_RESOLUTION = {
|
|
5608
|
-
low: 280,
|
|
5609
|
-
medium: 560,
|
|
5610
|
-
high: 1120,
|
|
5611
|
-
ultra_high: 2240,
|
|
5612
|
-
unspecified: 1120
|
|
5613
|
-
};
|
|
5614
|
-
var ANTHROPIC_IMAGE_TOKENS_PER_PIXEL = 1 / 750;
|
|
5615
|
-
var ANTHROPIC_IMAGE_MAX_LONG_EDGE = 1568;
|
|
5616
|
-
var GOOGLE_MEDIA_RESOLUTION_VALUES = /* @__PURE__ */ new Set([
|
|
5617
|
-
"low",
|
|
5618
|
-
"medium",
|
|
5619
|
-
"high",
|
|
5620
|
-
"ultra_high",
|
|
5621
|
-
"unspecified"
|
|
5622
|
-
]);
|
|
5623
|
-
var ATTACHMENT_COUNT_TIMEOUT_MS = 2e4;
|
|
5624
|
-
var REMOTE_IMAGE_PROBE_TIMEOUT_MS = 2500;
|
|
5625
|
-
var PROVIDER_API_KEY_ENV_VARS = {
|
|
5626
|
-
openai: ["OPENAI_API_KEY"],
|
|
5627
|
-
google: ["GOOGLE_GENERATIVE_AI_API_KEY", "GOOGLE_API_KEY"],
|
|
5628
|
-
anthropic: ["ANTHROPIC_API_KEY"]
|
|
5629
|
-
};
|
|
5630
|
-
function getPartMastraMetadata(part) {
|
|
5631
|
-
return part.providerMetadata?.mastra;
|
|
5664
|
+
function getOmReproCaptureDir() {
|
|
5665
|
+
return process.env.OM_REPRO_CAPTURE_DIR ?? ".mastra-om-repro";
|
|
5632
5666
|
}
|
|
5633
|
-
function
|
|
5634
|
-
const
|
|
5635
|
-
|
|
5636
|
-
typedPart.providerMetadata.mastra ??= {};
|
|
5637
|
-
return typedPart.providerMetadata.mastra;
|
|
5667
|
+
function sanitizeCapturePathSegment(value) {
|
|
5668
|
+
const sanitized = value.replace(/[\\/]+/g, "_").replace(/\.{2,}/g, "_").trim();
|
|
5669
|
+
return sanitized.length > 0 ? sanitized : "unknown-thread";
|
|
5638
5670
|
}
|
|
5639
|
-
function
|
|
5640
|
-
|
|
5641
|
-
|
|
5671
|
+
function isOmReproCaptureEnabled() {
|
|
5672
|
+
return process.env.OM_REPRO_CAPTURE === "1";
|
|
5673
|
+
}
|
|
5674
|
+
function safeCaptureJson(value) {
|
|
5675
|
+
return JSON.parse(
|
|
5676
|
+
JSON.stringify(value, (_key, current) => {
|
|
5677
|
+
if (typeof current === "bigint") return current.toString();
|
|
5678
|
+
if (typeof current === "function") return "[function]";
|
|
5679
|
+
if (typeof current === "symbol") return current.toString();
|
|
5680
|
+
if (current instanceof Error) return { name: current.name, message: current.message, stack: current.stack };
|
|
5681
|
+
if (current instanceof Set) return { __type: "Set", values: Array.from(current.values()) };
|
|
5682
|
+
if (current instanceof Map) return { __type: "Map", entries: Array.from(current.entries()) };
|
|
5683
|
+
return current;
|
|
5684
|
+
})
|
|
5685
|
+
);
|
|
5686
|
+
}
|
|
5687
|
+
function safeCaptureJsonOrError(value) {
|
|
5688
|
+
try {
|
|
5689
|
+
return { ok: true, value: safeCaptureJson(value) };
|
|
5690
|
+
} catch (error) {
|
|
5691
|
+
return {
|
|
5692
|
+
ok: false,
|
|
5693
|
+
error: safeCaptureJson({
|
|
5694
|
+
message: error instanceof Error ? error.message : String(error),
|
|
5695
|
+
stack: error instanceof Error ? error.stack : void 0,
|
|
5696
|
+
inspected: util.inspect(value, { depth: 3, maxArrayLength: 20, breakLength: 120 })
|
|
5697
|
+
})
|
|
5698
|
+
};
|
|
5642
5699
|
}
|
|
5643
|
-
return content.metadata?.mastra;
|
|
5644
5700
|
}
|
|
5645
|
-
function
|
|
5646
|
-
if (!
|
|
5701
|
+
function formatCaptureDate(value) {
|
|
5702
|
+
if (!value) return void 0;
|
|
5703
|
+
if (value instanceof Date) return value.toISOString();
|
|
5704
|
+
try {
|
|
5705
|
+
return new Date(value).toISOString();
|
|
5706
|
+
} catch {
|
|
5647
5707
|
return void 0;
|
|
5648
5708
|
}
|
|
5649
|
-
const typedContent = content;
|
|
5650
|
-
typedContent.metadata ??= {};
|
|
5651
|
-
typedContent.metadata.mastra ??= {};
|
|
5652
|
-
return typedContent.metadata.mastra;
|
|
5653
5709
|
}
|
|
5654
|
-
function
|
|
5655
|
-
|
|
5710
|
+
function summarizeOmTurn(value) {
|
|
5711
|
+
if (!value || typeof value !== "object") {
|
|
5712
|
+
return value;
|
|
5713
|
+
}
|
|
5714
|
+
const turn = value;
|
|
5715
|
+
return {
|
|
5716
|
+
__type: "ObservationTurn",
|
|
5717
|
+
threadId: turn.threadId,
|
|
5718
|
+
resourceId: turn.resourceId,
|
|
5719
|
+
started: turn._started,
|
|
5720
|
+
ended: turn._ended,
|
|
5721
|
+
generationCountAtStart: turn._generationCountAtStart,
|
|
5722
|
+
record: turn._record ? {
|
|
5723
|
+
id: turn._record.id,
|
|
5724
|
+
scope: turn._record.scope,
|
|
5725
|
+
threadId: turn._record.threadId,
|
|
5726
|
+
resourceId: turn._record.resourceId,
|
|
5727
|
+
createdAt: formatCaptureDate(turn._record.createdAt),
|
|
5728
|
+
updatedAt: formatCaptureDate(turn._record.updatedAt),
|
|
5729
|
+
lastObservedAt: formatCaptureDate(turn._record.lastObservedAt),
|
|
5730
|
+
generationCount: turn._record.generationCount,
|
|
5731
|
+
observationTokenCount: turn._record.observationTokenCount,
|
|
5732
|
+
pendingMessageTokens: turn._record.pendingMessageTokens,
|
|
5733
|
+
isBufferingObservation: turn._record.isBufferingObservation,
|
|
5734
|
+
isBufferingReflection: turn._record.isBufferingReflection
|
|
5735
|
+
} : void 0,
|
|
5736
|
+
context: turn._context ? {
|
|
5737
|
+
messageCount: Array.isArray(turn._context.messages) ? turn._context.messages.length : void 0,
|
|
5738
|
+
hasSystemMessage: Array.isArray(turn._context.systemMessage) ? turn._context.systemMessage.length > 0 : Boolean(turn._context.systemMessage),
|
|
5739
|
+
continuationId: turn._context.continuation?.id,
|
|
5740
|
+
hasOtherThreadsContext: Boolean(turn._context.otherThreadsContext),
|
|
5741
|
+
recordId: turn._context.record?.id
|
|
5742
|
+
} : void 0,
|
|
5743
|
+
currentStep: turn._currentStep ? {
|
|
5744
|
+
stepNumber: turn._currentStep.stepNumber,
|
|
5745
|
+
prepared: turn._currentStep._prepared,
|
|
5746
|
+
context: turn._currentStep._context ? {
|
|
5747
|
+
activated: turn._currentStep._context.activated,
|
|
5748
|
+
observed: turn._currentStep._context.observed,
|
|
5749
|
+
buffered: turn._currentStep._context.buffered,
|
|
5750
|
+
reflected: turn._currentStep._context.reflected,
|
|
5751
|
+
didThresholdCleanup: turn._currentStep._context.didThresholdCleanup,
|
|
5752
|
+
messageCount: Array.isArray(turn._currentStep._context.messages) ? turn._currentStep._context.messages.length : void 0,
|
|
5753
|
+
systemMessageCount: Array.isArray(turn._currentStep._context.systemMessage) ? turn._currentStep._context.systemMessage.length : void 0
|
|
5754
|
+
} : void 0
|
|
5755
|
+
} : void 0
|
|
5756
|
+
};
|
|
5656
5757
|
}
|
|
5657
|
-
function
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5758
|
+
function sanitizeCaptureState(rawState) {
|
|
5759
|
+
return Object.fromEntries(
|
|
5760
|
+
Object.entries(rawState).map(([key, value]) => {
|
|
5761
|
+
if (key === "__omTurn") {
|
|
5762
|
+
return [key, summarizeOmTurn(value)];
|
|
5763
|
+
}
|
|
5764
|
+
return [key, value];
|
|
5765
|
+
})
|
|
5766
|
+
);
|
|
5662
5767
|
}
|
|
5663
|
-
function
|
|
5664
|
-
const
|
|
5665
|
-
return
|
|
5768
|
+
function buildReproMessageFingerprint(message) {
|
|
5769
|
+
const createdAt = message.createdAt instanceof Date ? message.createdAt.toISOString() : message.createdAt ? new Date(message.createdAt).toISOString() : "";
|
|
5770
|
+
return JSON.stringify({
|
|
5771
|
+
role: message.role,
|
|
5772
|
+
createdAt,
|
|
5773
|
+
content: message.content
|
|
5774
|
+
});
|
|
5666
5775
|
}
|
|
5667
|
-
function
|
|
5668
|
-
|
|
5776
|
+
function inferReproIdRemap(preMessages, postMessages) {
|
|
5777
|
+
const preByFingerprint = /* @__PURE__ */ new Map();
|
|
5778
|
+
const postByFingerprint = /* @__PURE__ */ new Map();
|
|
5779
|
+
for (const message of preMessages) {
|
|
5780
|
+
if (!message.id) continue;
|
|
5781
|
+
const fingerprint = buildReproMessageFingerprint(message);
|
|
5782
|
+
const list = preByFingerprint.get(fingerprint) ?? [];
|
|
5783
|
+
list.push(message.id);
|
|
5784
|
+
preByFingerprint.set(fingerprint, list);
|
|
5785
|
+
}
|
|
5786
|
+
for (const message of postMessages) {
|
|
5787
|
+
if (!message.id) continue;
|
|
5788
|
+
const fingerprint = buildReproMessageFingerprint(message);
|
|
5789
|
+
const list = postByFingerprint.get(fingerprint) ?? [];
|
|
5790
|
+
list.push(message.id);
|
|
5791
|
+
postByFingerprint.set(fingerprint, list);
|
|
5792
|
+
}
|
|
5793
|
+
const remap = [];
|
|
5794
|
+
for (const [fingerprint, preIds] of preByFingerprint.entries()) {
|
|
5795
|
+
const postIds = postByFingerprint.get(fingerprint);
|
|
5796
|
+
if (!postIds || preIds.length !== 1 || postIds.length !== 1) continue;
|
|
5797
|
+
const fromId = preIds[0];
|
|
5798
|
+
const toId = postIds[0];
|
|
5799
|
+
if (!fromId || !toId || fromId === toId) {
|
|
5800
|
+
continue;
|
|
5801
|
+
}
|
|
5802
|
+
remap.push({ fromId, toId, fingerprint });
|
|
5803
|
+
}
|
|
5804
|
+
return remap;
|
|
5669
5805
|
}
|
|
5670
|
-
function
|
|
5671
|
-
|
|
5672
|
-
const
|
|
5673
|
-
|
|
5806
|
+
function createOmReproCaptureDir(threadId, label) {
|
|
5807
|
+
const sanitizedThreadId = sanitizeCapturePathSegment(threadId);
|
|
5808
|
+
const captureDir = path.join(
|
|
5809
|
+
process.cwd(),
|
|
5810
|
+
getOmReproCaptureDir(),
|
|
5811
|
+
sanitizedThreadId,
|
|
5812
|
+
`${Date.now()}-${label}-${crypto$1.randomUUID()}`
|
|
5813
|
+
);
|
|
5814
|
+
fs.mkdirSync(captureDir, { recursive: true });
|
|
5815
|
+
return captureDir;
|
|
5674
5816
|
}
|
|
5675
|
-
function
|
|
5676
|
-
if (!
|
|
5677
|
-
|
|
5678
|
-
return cache.key === key ? cache : void 0;
|
|
5817
|
+
function writeObserverExchangeReproCapture(params) {
|
|
5818
|
+
if (!isOmReproCaptureEnabled() || !params.observerExchange) {
|
|
5819
|
+
return;
|
|
5679
5820
|
}
|
|
5680
|
-
|
|
5821
|
+
try {
|
|
5822
|
+
const captureDir = createOmReproCaptureDir(params.threadId, params.label);
|
|
5823
|
+
const payloads = [
|
|
5824
|
+
{
|
|
5825
|
+
fileName: "input.json",
|
|
5826
|
+
data: {
|
|
5827
|
+
threadId: params.threadId,
|
|
5828
|
+
resourceId: params.resourceId,
|
|
5829
|
+
label: params.label
|
|
5830
|
+
}
|
|
5831
|
+
},
|
|
5832
|
+
{
|
|
5833
|
+
fileName: "output.json",
|
|
5834
|
+
data: {
|
|
5835
|
+
details: params.details ?? {}
|
|
5836
|
+
}
|
|
5837
|
+
},
|
|
5838
|
+
{
|
|
5839
|
+
fileName: "observer-exchange.json",
|
|
5840
|
+
data: params.observerExchange
|
|
5841
|
+
}
|
|
5842
|
+
];
|
|
5843
|
+
const captureErrors = [];
|
|
5844
|
+
for (const payload of payloads) {
|
|
5845
|
+
const serialized = safeCaptureJsonOrError(payload.data);
|
|
5846
|
+
if (serialized.ok) {
|
|
5847
|
+
fs.writeFileSync(path.join(captureDir, payload.fileName), `${JSON.stringify(serialized.value, null, 2)}
|
|
5848
|
+
`);
|
|
5849
|
+
continue;
|
|
5850
|
+
}
|
|
5851
|
+
captureErrors.push({ fileName: payload.fileName, error: serialized.error });
|
|
5852
|
+
fs.writeFileSync(
|
|
5853
|
+
path.join(captureDir, payload.fileName),
|
|
5854
|
+
`${JSON.stringify({ __captureError: serialized.error }, null, 2)}
|
|
5855
|
+
`
|
|
5856
|
+
);
|
|
5857
|
+
}
|
|
5858
|
+
if (captureErrors.length > 0) {
|
|
5859
|
+
fs.writeFileSync(path.join(captureDir, "capture-error.json"), `${JSON.stringify(captureErrors, null, 2)}
|
|
5860
|
+
`);
|
|
5861
|
+
params.debug?.(
|
|
5862
|
+
`[OM:repro-capture] wrote ${params.label} capture with ${captureErrors.length} serialization error(s) to ${captureDir}`
|
|
5863
|
+
);
|
|
5864
|
+
return;
|
|
5865
|
+
}
|
|
5866
|
+
params.debug?.(`[OM:repro-capture] wrote ${params.label} capture to ${captureDir}`);
|
|
5867
|
+
} catch (error) {
|
|
5868
|
+
params.debug?.(`[OM:repro-capture] failed to write ${params.label} capture: ${String(error)}`);
|
|
5869
|
+
}
|
|
5870
|
+
}
|
|
5871
|
+
function writeProcessInputStepReproCapture(params) {
|
|
5872
|
+
if (!isOmReproCaptureEnabled()) {
|
|
5873
|
+
return;
|
|
5874
|
+
}
|
|
5875
|
+
try {
|
|
5876
|
+
const captureDir = createOmReproCaptureDir(params.threadId, `step-${params.stepNumber}`);
|
|
5877
|
+
const contextMessages = params.messageList.get.all.db();
|
|
5878
|
+
const memoryContext = memory.parseMemoryRequestContext(params.args.requestContext);
|
|
5879
|
+
const preMessageIds = new Set(params.preMessages.map((message) => message.id));
|
|
5880
|
+
const postMessageIds = new Set(contextMessages.map((message) => message.id));
|
|
5881
|
+
const removedMessageIds = params.preMessages.map((message) => message.id).filter((id) => Boolean(id) && !postMessageIds.has(id));
|
|
5882
|
+
const addedMessageIds = contextMessages.map((message) => message.id).filter((id) => Boolean(id) && !preMessageIds.has(id));
|
|
5883
|
+
const idRemap = inferReproIdRemap(params.preMessages, contextMessages);
|
|
5884
|
+
const rawState = params.args.state ?? {};
|
|
5885
|
+
const sanitizedState = sanitizeCaptureState(rawState);
|
|
5886
|
+
const payloads = [
|
|
5887
|
+
{
|
|
5888
|
+
fileName: "input.json",
|
|
5889
|
+
data: {
|
|
5890
|
+
stepNumber: params.stepNumber,
|
|
5891
|
+
threadId: params.threadId,
|
|
5892
|
+
resourceId: params.resourceId,
|
|
5893
|
+
readOnly: memoryContext?.memoryConfig?.readOnly,
|
|
5894
|
+
messageCount: contextMessages.length,
|
|
5895
|
+
messageIds: contextMessages.map((message) => message.id),
|
|
5896
|
+
stateKeys: Object.keys(rawState),
|
|
5897
|
+
state: sanitizedState,
|
|
5898
|
+
args: {
|
|
5899
|
+
messages: params.args.messages,
|
|
5900
|
+
steps: params.args.steps,
|
|
5901
|
+
systemMessages: params.args.systemMessages,
|
|
5902
|
+
retryCount: params.args.retryCount,
|
|
5903
|
+
toolChoice: params.args.toolChoice,
|
|
5904
|
+
activeTools: params.args.activeTools,
|
|
5905
|
+
modelSettings: params.args.modelSettings,
|
|
5906
|
+
structuredOutput: params.args.structuredOutput
|
|
5907
|
+
}
|
|
5908
|
+
}
|
|
5909
|
+
},
|
|
5910
|
+
{
|
|
5911
|
+
fileName: "pre-state.json",
|
|
5912
|
+
data: {
|
|
5913
|
+
record: params.preRecord,
|
|
5914
|
+
bufferedChunks: params.preBufferedChunks,
|
|
5915
|
+
contextTokenCount: params.preContextTokenCount,
|
|
5916
|
+
messages: params.preMessages,
|
|
5917
|
+
messageList: params.preSerializedMessageList
|
|
5918
|
+
}
|
|
5919
|
+
},
|
|
5920
|
+
{
|
|
5921
|
+
fileName: "output.json",
|
|
5922
|
+
data: {
|
|
5923
|
+
details: params.details,
|
|
5924
|
+
messageDiff: {
|
|
5925
|
+
removedMessageIds,
|
|
5926
|
+
addedMessageIds,
|
|
5927
|
+
idRemap
|
|
5928
|
+
}
|
|
5929
|
+
}
|
|
5930
|
+
},
|
|
5931
|
+
{
|
|
5932
|
+
fileName: "post-state.json",
|
|
5933
|
+
data: {
|
|
5934
|
+
record: params.postRecord,
|
|
5935
|
+
bufferedChunks: params.postBufferedChunks,
|
|
5936
|
+
contextTokenCount: params.postContextTokenCount,
|
|
5937
|
+
messageCount: contextMessages.length,
|
|
5938
|
+
messageIds: contextMessages.map((message) => message.id),
|
|
5939
|
+
messages: contextMessages,
|
|
5940
|
+
messageList: params.messageList.serialize()
|
|
5941
|
+
}
|
|
5942
|
+
}
|
|
5943
|
+
];
|
|
5944
|
+
const captureErrors = [];
|
|
5945
|
+
for (const payload of payloads) {
|
|
5946
|
+
const serialized = safeCaptureJsonOrError(payload.data);
|
|
5947
|
+
if (serialized.ok) {
|
|
5948
|
+
fs.writeFileSync(path.join(captureDir, payload.fileName), `${JSON.stringify(serialized.value, null, 2)}
|
|
5949
|
+
`);
|
|
5950
|
+
continue;
|
|
5951
|
+
}
|
|
5952
|
+
captureErrors.push({ fileName: payload.fileName, error: serialized.error });
|
|
5953
|
+
fs.writeFileSync(
|
|
5954
|
+
path.join(captureDir, payload.fileName),
|
|
5955
|
+
`${JSON.stringify({ __captureError: serialized.error }, null, 2)}
|
|
5956
|
+
`
|
|
5957
|
+
);
|
|
5958
|
+
}
|
|
5959
|
+
if (params.observerExchange) {
|
|
5960
|
+
const serialized = safeCaptureJsonOrError(params.observerExchange);
|
|
5961
|
+
if (serialized.ok) {
|
|
5962
|
+
fs.writeFileSync(path.join(captureDir, "observer-exchange.json"), `${JSON.stringify(serialized.value, null, 2)}
|
|
5963
|
+
`);
|
|
5964
|
+
} else {
|
|
5965
|
+
captureErrors.push({ fileName: "observer-exchange.json", error: serialized.error });
|
|
5966
|
+
fs.writeFileSync(
|
|
5967
|
+
path.join(captureDir, "observer-exchange.json"),
|
|
5968
|
+
`${JSON.stringify({ __captureError: serialized.error }, null, 2)}
|
|
5969
|
+
`
|
|
5970
|
+
);
|
|
5971
|
+
}
|
|
5972
|
+
}
|
|
5973
|
+
if (captureErrors.length > 0) {
|
|
5974
|
+
fs.writeFileSync(path.join(captureDir, "capture-error.json"), `${JSON.stringify(captureErrors, null, 2)}
|
|
5975
|
+
`);
|
|
5976
|
+
params.debug?.(
|
|
5977
|
+
`[OM:repro-capture] wrote processInputStep capture with ${captureErrors.length} serialization error(s) to ${captureDir}`
|
|
5978
|
+
);
|
|
5979
|
+
return;
|
|
5980
|
+
}
|
|
5981
|
+
params.debug?.(`[OM:repro-capture] wrote processInputStep capture to ${captureDir}`);
|
|
5982
|
+
} catch (error) {
|
|
5983
|
+
params.debug?.(`[OM:repro-capture] failed to write processInputStep capture: ${String(error)}`);
|
|
5984
|
+
}
|
|
5985
|
+
}
|
|
5986
|
+
var IMAGE_FILE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
5987
|
+
"png",
|
|
5988
|
+
"jpg",
|
|
5989
|
+
"jpeg",
|
|
5990
|
+
"webp",
|
|
5991
|
+
"gif",
|
|
5992
|
+
"bmp",
|
|
5993
|
+
"tiff",
|
|
5994
|
+
"tif",
|
|
5995
|
+
"heic",
|
|
5996
|
+
"heif",
|
|
5997
|
+
"avif"
|
|
5998
|
+
]);
|
|
5999
|
+
var TOKEN_ESTIMATE_CACHE_VERSION = 6;
|
|
6000
|
+
var DEFAULT_IMAGE_ESTIMATOR = {
|
|
6001
|
+
baseTokens: 85,
|
|
6002
|
+
tileTokens: 170,
|
|
6003
|
+
fallbackTiles: 4
|
|
6004
|
+
};
|
|
6005
|
+
var GOOGLE_LEGACY_IMAGE_TOKENS_PER_TILE = 258;
|
|
6006
|
+
var GOOGLE_GEMINI_3_IMAGE_TOKENS_BY_RESOLUTION = {
|
|
6007
|
+
low: 280,
|
|
6008
|
+
medium: 560,
|
|
6009
|
+
high: 1120,
|
|
6010
|
+
ultra_high: 2240,
|
|
6011
|
+
unspecified: 1120
|
|
6012
|
+
};
|
|
6013
|
+
var ANTHROPIC_IMAGE_TOKENS_PER_PIXEL = 1 / 750;
|
|
6014
|
+
var ANTHROPIC_IMAGE_MAX_LONG_EDGE = 1568;
|
|
6015
|
+
var GOOGLE_MEDIA_RESOLUTION_VALUES = /* @__PURE__ */ new Set([
|
|
6016
|
+
"low",
|
|
6017
|
+
"medium",
|
|
6018
|
+
"high",
|
|
6019
|
+
"ultra_high",
|
|
6020
|
+
"unspecified"
|
|
6021
|
+
]);
|
|
6022
|
+
var ATTACHMENT_COUNT_TIMEOUT_MS = 2e4;
|
|
6023
|
+
var REMOTE_IMAGE_PROBE_TIMEOUT_MS = 2500;
|
|
6024
|
+
var PROVIDER_API_KEY_ENV_VARS = {
|
|
6025
|
+
openai: ["OPENAI_API_KEY"],
|
|
6026
|
+
google: ["GOOGLE_GENERATIVE_AI_API_KEY", "GOOGLE_API_KEY"],
|
|
6027
|
+
anthropic: ["ANTHROPIC_API_KEY"]
|
|
6028
|
+
};
|
|
6029
|
+
function getPartMastraMetadata(part) {
|
|
6030
|
+
return part.providerMetadata?.mastra;
|
|
6031
|
+
}
|
|
6032
|
+
function ensurePartMastraMetadata(part) {
|
|
6033
|
+
const typedPart = part;
|
|
6034
|
+
typedPart.providerMetadata ??= {};
|
|
6035
|
+
typedPart.providerMetadata.mastra ??= {};
|
|
6036
|
+
return typedPart.providerMetadata.mastra;
|
|
6037
|
+
}
|
|
6038
|
+
function getContentMastraMetadata(content) {
|
|
6039
|
+
if (!content || typeof content !== "object") {
|
|
6040
|
+
return void 0;
|
|
6041
|
+
}
|
|
6042
|
+
return content.metadata?.mastra;
|
|
6043
|
+
}
|
|
6044
|
+
function ensureContentMastraMetadata(content) {
|
|
6045
|
+
if (!content || typeof content !== "object") {
|
|
6046
|
+
return void 0;
|
|
6047
|
+
}
|
|
6048
|
+
const typedContent = content;
|
|
6049
|
+
typedContent.metadata ??= {};
|
|
6050
|
+
typedContent.metadata.mastra ??= {};
|
|
6051
|
+
return typedContent.metadata.mastra;
|
|
6052
|
+
}
|
|
6053
|
+
function getMessageMastraMetadata(message) {
|
|
6054
|
+
return message.metadata?.mastra;
|
|
6055
|
+
}
|
|
6056
|
+
function ensureMessageMastraMetadata(message) {
|
|
6057
|
+
const typedMessage = message;
|
|
6058
|
+
typedMessage.metadata ??= {};
|
|
6059
|
+
typedMessage.metadata.mastra ??= {};
|
|
6060
|
+
return typedMessage.metadata.mastra;
|
|
6061
|
+
}
|
|
6062
|
+
function buildEstimateKey(kind, text) {
|
|
6063
|
+
const payloadHash = crypto$1.createHash("sha1").update(text).digest("hex");
|
|
6064
|
+
return `${kind}:${payloadHash}`;
|
|
6065
|
+
}
|
|
6066
|
+
function resolveEstimatorId() {
|
|
6067
|
+
return "tokenx";
|
|
6068
|
+
}
|
|
6069
|
+
function isTokenEstimateEntry(value) {
|
|
6070
|
+
if (!value || typeof value !== "object") return false;
|
|
6071
|
+
const entry = value;
|
|
6072
|
+
return typeof entry.v === "number" && typeof entry.source === "string" && typeof entry.key === "string" && typeof entry.tokens === "number";
|
|
6073
|
+
}
|
|
6074
|
+
function getCacheEntry(cache, key) {
|
|
6075
|
+
if (!cache || typeof cache !== "object") return void 0;
|
|
6076
|
+
if (isTokenEstimateEntry(cache)) {
|
|
6077
|
+
return cache.key === key ? cache : void 0;
|
|
6078
|
+
}
|
|
6079
|
+
const keyedEntry = cache[key];
|
|
5681
6080
|
return isTokenEstimateEntry(keyedEntry) ? keyedEntry : void 0;
|
|
5682
6081
|
}
|
|
5683
6082
|
function mergeCacheEntry(cache, key, entry) {
|
|
@@ -8781,6 +9180,23 @@ ${grouped}` : grouped;
|
|
|
8781
9180
|
requestContext,
|
|
8782
9181
|
observabilityContext
|
|
8783
9182
|
}).run();
|
|
9183
|
+
if (isOmReproCaptureEnabled()) {
|
|
9184
|
+
writeObserverExchangeReproCapture({
|
|
9185
|
+
threadId,
|
|
9186
|
+
resourceId: record.resourceId ?? void 0,
|
|
9187
|
+
label: `buffer-${cycleId}`,
|
|
9188
|
+
observerExchange: this.observer.lastExchange,
|
|
9189
|
+
details: {
|
|
9190
|
+
cycleId,
|
|
9191
|
+
startedAt,
|
|
9192
|
+
buffered: true,
|
|
9193
|
+
candidateMessageIds: candidateMessages.map((message) => message.id),
|
|
9194
|
+
candidateMessageCount: candidateMessages.length,
|
|
9195
|
+
pendingTokens: currentTokens,
|
|
9196
|
+
newTokens
|
|
9197
|
+
}
|
|
9198
|
+
});
|
|
9199
|
+
}
|
|
8784
9200
|
await this.storage.setBufferingObservationFlag(record.id, false, newTokens).catch(() => {
|
|
8785
9201
|
});
|
|
8786
9202
|
flagCleared = true;
|
|
@@ -9176,264 +9592,6 @@ ${grouped}` : grouped;
|
|
|
9176
9592
|
});
|
|
9177
9593
|
}
|
|
9178
9594
|
};
|
|
9179
|
-
var OM_REPRO_CAPTURE_DIR = process.env.OM_REPRO_CAPTURE_DIR ?? ".mastra-om-repro";
|
|
9180
|
-
function sanitizeCapturePathSegment(value) {
|
|
9181
|
-
const sanitized = value.replace(/[\\/]+/g, "_").replace(/\.{2,}/g, "_").trim();
|
|
9182
|
-
return sanitized.length > 0 ? sanitized : "unknown-thread";
|
|
9183
|
-
}
|
|
9184
|
-
function isOmReproCaptureEnabled() {
|
|
9185
|
-
return process.env.OM_REPRO_CAPTURE === "1";
|
|
9186
|
-
}
|
|
9187
|
-
function safeCaptureJson(value) {
|
|
9188
|
-
return JSON.parse(
|
|
9189
|
-
JSON.stringify(value, (_key, current) => {
|
|
9190
|
-
if (typeof current === "bigint") return current.toString();
|
|
9191
|
-
if (typeof current === "function") return "[function]";
|
|
9192
|
-
if (typeof current === "symbol") return current.toString();
|
|
9193
|
-
if (current instanceof Error) return { name: current.name, message: current.message, stack: current.stack };
|
|
9194
|
-
if (current instanceof Set) return { __type: "Set", values: Array.from(current.values()) };
|
|
9195
|
-
if (current instanceof Map) return { __type: "Map", entries: Array.from(current.entries()) };
|
|
9196
|
-
return current;
|
|
9197
|
-
})
|
|
9198
|
-
);
|
|
9199
|
-
}
|
|
9200
|
-
function safeCaptureJsonOrError(value) {
|
|
9201
|
-
try {
|
|
9202
|
-
return { ok: true, value: safeCaptureJson(value) };
|
|
9203
|
-
} catch (error) {
|
|
9204
|
-
return {
|
|
9205
|
-
ok: false,
|
|
9206
|
-
error: safeCaptureJson({
|
|
9207
|
-
message: error instanceof Error ? error.message : String(error),
|
|
9208
|
-
stack: error instanceof Error ? error.stack : void 0,
|
|
9209
|
-
inspected: util.inspect(value, { depth: 3, maxArrayLength: 20, breakLength: 120 })
|
|
9210
|
-
})
|
|
9211
|
-
};
|
|
9212
|
-
}
|
|
9213
|
-
}
|
|
9214
|
-
function formatCaptureDate(value) {
|
|
9215
|
-
if (!value) return void 0;
|
|
9216
|
-
if (value instanceof Date) return value.toISOString();
|
|
9217
|
-
try {
|
|
9218
|
-
return new Date(value).toISOString();
|
|
9219
|
-
} catch {
|
|
9220
|
-
return void 0;
|
|
9221
|
-
}
|
|
9222
|
-
}
|
|
9223
|
-
function summarizeOmTurn(value) {
|
|
9224
|
-
if (!value || typeof value !== "object") {
|
|
9225
|
-
return value;
|
|
9226
|
-
}
|
|
9227
|
-
const turn = value;
|
|
9228
|
-
return {
|
|
9229
|
-
__type: "ObservationTurn",
|
|
9230
|
-
threadId: turn.threadId,
|
|
9231
|
-
resourceId: turn.resourceId,
|
|
9232
|
-
started: turn._started,
|
|
9233
|
-
ended: turn._ended,
|
|
9234
|
-
generationCountAtStart: turn._generationCountAtStart,
|
|
9235
|
-
record: turn._record ? {
|
|
9236
|
-
id: turn._record.id,
|
|
9237
|
-
scope: turn._record.scope,
|
|
9238
|
-
threadId: turn._record.threadId,
|
|
9239
|
-
resourceId: turn._record.resourceId,
|
|
9240
|
-
createdAt: formatCaptureDate(turn._record.createdAt),
|
|
9241
|
-
updatedAt: formatCaptureDate(turn._record.updatedAt),
|
|
9242
|
-
lastObservedAt: formatCaptureDate(turn._record.lastObservedAt),
|
|
9243
|
-
generationCount: turn._record.generationCount,
|
|
9244
|
-
observationTokenCount: turn._record.observationTokenCount,
|
|
9245
|
-
pendingMessageTokens: turn._record.pendingMessageTokens,
|
|
9246
|
-
isBufferingObservation: turn._record.isBufferingObservation,
|
|
9247
|
-
isBufferingReflection: turn._record.isBufferingReflection
|
|
9248
|
-
} : void 0,
|
|
9249
|
-
context: turn._context ? {
|
|
9250
|
-
messageCount: Array.isArray(turn._context.messages) ? turn._context.messages.length : void 0,
|
|
9251
|
-
hasSystemMessage: Array.isArray(turn._context.systemMessage) ? turn._context.systemMessage.length > 0 : Boolean(turn._context.systemMessage),
|
|
9252
|
-
continuationId: turn._context.continuation?.id,
|
|
9253
|
-
hasOtherThreadsContext: Boolean(turn._context.otherThreadsContext),
|
|
9254
|
-
recordId: turn._context.record?.id
|
|
9255
|
-
} : void 0,
|
|
9256
|
-
currentStep: turn._currentStep ? {
|
|
9257
|
-
stepNumber: turn._currentStep.stepNumber,
|
|
9258
|
-
prepared: turn._currentStep._prepared,
|
|
9259
|
-
context: turn._currentStep._context ? {
|
|
9260
|
-
activated: turn._currentStep._context.activated,
|
|
9261
|
-
observed: turn._currentStep._context.observed,
|
|
9262
|
-
buffered: turn._currentStep._context.buffered,
|
|
9263
|
-
reflected: turn._currentStep._context.reflected,
|
|
9264
|
-
didThresholdCleanup: turn._currentStep._context.didThresholdCleanup,
|
|
9265
|
-
messageCount: Array.isArray(turn._currentStep._context.messages) ? turn._currentStep._context.messages.length : void 0,
|
|
9266
|
-
systemMessageCount: Array.isArray(turn._currentStep._context.systemMessage) ? turn._currentStep._context.systemMessage.length : void 0
|
|
9267
|
-
} : void 0
|
|
9268
|
-
} : void 0
|
|
9269
|
-
};
|
|
9270
|
-
}
|
|
9271
|
-
function sanitizeCaptureState(rawState) {
|
|
9272
|
-
return Object.fromEntries(
|
|
9273
|
-
Object.entries(rawState).map(([key, value]) => {
|
|
9274
|
-
if (key === "__omTurn") {
|
|
9275
|
-
return [key, summarizeOmTurn(value)];
|
|
9276
|
-
}
|
|
9277
|
-
return [key, value];
|
|
9278
|
-
})
|
|
9279
|
-
);
|
|
9280
|
-
}
|
|
9281
|
-
function buildReproMessageFingerprint(message) {
|
|
9282
|
-
const createdAt = message.createdAt instanceof Date ? message.createdAt.toISOString() : message.createdAt ? new Date(message.createdAt).toISOString() : "";
|
|
9283
|
-
return JSON.stringify({
|
|
9284
|
-
role: message.role,
|
|
9285
|
-
createdAt,
|
|
9286
|
-
content: message.content
|
|
9287
|
-
});
|
|
9288
|
-
}
|
|
9289
|
-
function inferReproIdRemap(preMessages, postMessages) {
|
|
9290
|
-
const preByFingerprint = /* @__PURE__ */ new Map();
|
|
9291
|
-
const postByFingerprint = /* @__PURE__ */ new Map();
|
|
9292
|
-
for (const message of preMessages) {
|
|
9293
|
-
if (!message.id) continue;
|
|
9294
|
-
const fingerprint = buildReproMessageFingerprint(message);
|
|
9295
|
-
const list = preByFingerprint.get(fingerprint) ?? [];
|
|
9296
|
-
list.push(message.id);
|
|
9297
|
-
preByFingerprint.set(fingerprint, list);
|
|
9298
|
-
}
|
|
9299
|
-
for (const message of postMessages) {
|
|
9300
|
-
if (!message.id) continue;
|
|
9301
|
-
const fingerprint = buildReproMessageFingerprint(message);
|
|
9302
|
-
const list = postByFingerprint.get(fingerprint) ?? [];
|
|
9303
|
-
list.push(message.id);
|
|
9304
|
-
postByFingerprint.set(fingerprint, list);
|
|
9305
|
-
}
|
|
9306
|
-
const remap = [];
|
|
9307
|
-
for (const [fingerprint, preIds] of preByFingerprint.entries()) {
|
|
9308
|
-
const postIds = postByFingerprint.get(fingerprint);
|
|
9309
|
-
if (!postIds || preIds.length !== 1 || postIds.length !== 1) continue;
|
|
9310
|
-
const fromId = preIds[0];
|
|
9311
|
-
const toId = postIds[0];
|
|
9312
|
-
if (!fromId || !toId || fromId === toId) {
|
|
9313
|
-
continue;
|
|
9314
|
-
}
|
|
9315
|
-
remap.push({ fromId, toId, fingerprint });
|
|
9316
|
-
}
|
|
9317
|
-
return remap;
|
|
9318
|
-
}
|
|
9319
|
-
function writeProcessInputStepReproCapture(params) {
|
|
9320
|
-
if (!isOmReproCaptureEnabled()) {
|
|
9321
|
-
return;
|
|
9322
|
-
}
|
|
9323
|
-
try {
|
|
9324
|
-
const sanitizedThreadId = sanitizeCapturePathSegment(params.threadId);
|
|
9325
|
-
const runId = `${Date.now()}-step-${params.stepNumber}-${crypto$1.randomUUID()}`;
|
|
9326
|
-
const captureDir = path.join(process.cwd(), OM_REPRO_CAPTURE_DIR, sanitizedThreadId, runId);
|
|
9327
|
-
fs.mkdirSync(captureDir, { recursive: true });
|
|
9328
|
-
const contextMessages = params.messageList.get.all.db();
|
|
9329
|
-
const memoryContext = memory.parseMemoryRequestContext(params.args.requestContext);
|
|
9330
|
-
const preMessageIds = new Set(params.preMessages.map((message) => message.id));
|
|
9331
|
-
const postMessageIds = new Set(contextMessages.map((message) => message.id));
|
|
9332
|
-
const removedMessageIds = params.preMessages.map((message) => message.id).filter((id) => Boolean(id) && !postMessageIds.has(id));
|
|
9333
|
-
const addedMessageIds = contextMessages.map((message) => message.id).filter((id) => Boolean(id) && !preMessageIds.has(id));
|
|
9334
|
-
const idRemap = inferReproIdRemap(params.preMessages, contextMessages);
|
|
9335
|
-
const rawState = params.args.state ?? {};
|
|
9336
|
-
const sanitizedState = sanitizeCaptureState(rawState);
|
|
9337
|
-
const payloads = [
|
|
9338
|
-
{
|
|
9339
|
-
fileName: "input.json",
|
|
9340
|
-
data: {
|
|
9341
|
-
stepNumber: params.stepNumber,
|
|
9342
|
-
threadId: params.threadId,
|
|
9343
|
-
resourceId: params.resourceId,
|
|
9344
|
-
readOnly: memoryContext?.memoryConfig?.readOnly,
|
|
9345
|
-
messageCount: contextMessages.length,
|
|
9346
|
-
messageIds: contextMessages.map((message) => message.id),
|
|
9347
|
-
stateKeys: Object.keys(rawState),
|
|
9348
|
-
state: sanitizedState,
|
|
9349
|
-
args: {
|
|
9350
|
-
messages: params.args.messages,
|
|
9351
|
-
steps: params.args.steps,
|
|
9352
|
-
systemMessages: params.args.systemMessages,
|
|
9353
|
-
retryCount: params.args.retryCount,
|
|
9354
|
-
toolChoice: params.args.toolChoice,
|
|
9355
|
-
activeTools: params.args.activeTools,
|
|
9356
|
-
modelSettings: params.args.modelSettings,
|
|
9357
|
-
structuredOutput: params.args.structuredOutput
|
|
9358
|
-
}
|
|
9359
|
-
}
|
|
9360
|
-
},
|
|
9361
|
-
{
|
|
9362
|
-
fileName: "pre-state.json",
|
|
9363
|
-
data: {
|
|
9364
|
-
record: params.preRecord,
|
|
9365
|
-
bufferedChunks: params.preBufferedChunks,
|
|
9366
|
-
contextTokenCount: params.preContextTokenCount,
|
|
9367
|
-
messages: params.preMessages,
|
|
9368
|
-
messageList: params.preSerializedMessageList
|
|
9369
|
-
}
|
|
9370
|
-
},
|
|
9371
|
-
{
|
|
9372
|
-
fileName: "output.json",
|
|
9373
|
-
data: {
|
|
9374
|
-
details: params.details,
|
|
9375
|
-
messageDiff: {
|
|
9376
|
-
removedMessageIds,
|
|
9377
|
-
addedMessageIds,
|
|
9378
|
-
idRemap
|
|
9379
|
-
}
|
|
9380
|
-
}
|
|
9381
|
-
},
|
|
9382
|
-
{
|
|
9383
|
-
fileName: "post-state.json",
|
|
9384
|
-
data: {
|
|
9385
|
-
record: params.postRecord,
|
|
9386
|
-
bufferedChunks: params.postBufferedChunks,
|
|
9387
|
-
contextTokenCount: params.postContextTokenCount,
|
|
9388
|
-
messageCount: contextMessages.length,
|
|
9389
|
-
messageIds: contextMessages.map((message) => message.id),
|
|
9390
|
-
messages: contextMessages,
|
|
9391
|
-
messageList: params.messageList.serialize()
|
|
9392
|
-
}
|
|
9393
|
-
}
|
|
9394
|
-
];
|
|
9395
|
-
const captureErrors = [];
|
|
9396
|
-
for (const payload of payloads) {
|
|
9397
|
-
const serialized = safeCaptureJsonOrError(payload.data);
|
|
9398
|
-
if (serialized.ok) {
|
|
9399
|
-
fs.writeFileSync(path.join(captureDir, payload.fileName), `${JSON.stringify(serialized.value, null, 2)}
|
|
9400
|
-
`);
|
|
9401
|
-
continue;
|
|
9402
|
-
}
|
|
9403
|
-
captureErrors.push({ fileName: payload.fileName, error: serialized.error });
|
|
9404
|
-
fs.writeFileSync(
|
|
9405
|
-
path.join(captureDir, payload.fileName),
|
|
9406
|
-
`${JSON.stringify({ __captureError: serialized.error }, null, 2)}
|
|
9407
|
-
`
|
|
9408
|
-
);
|
|
9409
|
-
}
|
|
9410
|
-
if (params.observerExchange) {
|
|
9411
|
-
const serialized = safeCaptureJsonOrError(params.observerExchange);
|
|
9412
|
-
if (serialized.ok) {
|
|
9413
|
-
fs.writeFileSync(path.join(captureDir, "observer-exchange.json"), `${JSON.stringify(serialized.value, null, 2)}
|
|
9414
|
-
`);
|
|
9415
|
-
} else {
|
|
9416
|
-
captureErrors.push({ fileName: "observer-exchange.json", error: serialized.error });
|
|
9417
|
-
fs.writeFileSync(
|
|
9418
|
-
path.join(captureDir, "observer-exchange.json"),
|
|
9419
|
-
`${JSON.stringify({ __captureError: serialized.error }, null, 2)}
|
|
9420
|
-
`
|
|
9421
|
-
);
|
|
9422
|
-
}
|
|
9423
|
-
}
|
|
9424
|
-
if (captureErrors.length > 0) {
|
|
9425
|
-
fs.writeFileSync(path.join(captureDir, "capture-error.json"), `${JSON.stringify(captureErrors, null, 2)}
|
|
9426
|
-
`);
|
|
9427
|
-
params.debug?.(
|
|
9428
|
-
`[OM:repro-capture] wrote processInputStep capture with ${captureErrors.length} serialization error(s) to ${captureDir}`
|
|
9429
|
-
);
|
|
9430
|
-
return;
|
|
9431
|
-
}
|
|
9432
|
-
params.debug?.(`[OM:repro-capture] wrote processInputStep capture to ${captureDir}`);
|
|
9433
|
-
} catch (error) {
|
|
9434
|
-
params.debug?.(`[OM:repro-capture] failed to write processInputStep capture: ${String(error)}`);
|
|
9435
|
-
}
|
|
9436
|
-
}
|
|
9437
9595
|
function getOmObservabilityContext(args) {
|
|
9438
9596
|
if (!args.tracing || !args.tracingContext || !args.loggerVNext || !args.metrics) {
|
|
9439
9597
|
return void 0;
|
|
@@ -9672,5 +9830,5 @@ exports.stripEphemeralAnchorIds = stripEphemeralAnchorIds;
|
|
|
9672
9830
|
exports.stripObservationGroups = stripObservationGroups;
|
|
9673
9831
|
exports.truncateStringByTokens = truncateStringByTokens;
|
|
9674
9832
|
exports.wrapInObservationGroup = wrapInObservationGroup;
|
|
9675
|
-
//# sourceMappingURL=chunk-
|
|
9676
|
-
//# sourceMappingURL=chunk-
|
|
9833
|
+
//# sourceMappingURL=chunk-QOTVR5LN.cjs.map
|
|
9834
|
+
//# sourceMappingURL=chunk-QOTVR5LN.cjs.map
|