@mastra/code-sdk 1.3.0-alpha.8 → 1.3.0
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 +79 -0
- package/dist/agents/memory.d.ts.map +1 -1
- package/dist/agents/memory.js +21 -3
- package/dist/agents/memory.js.map +1 -1
- package/dist/hooks/executor.d.ts.map +1 -1
- package/dist/hooks/executor.js +1 -0
- package/dist/hooks/executor.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/knowledge-inspector.d.ts +119 -0
- package/dist/knowledge-inspector.d.ts.map +1 -0
- package/dist/knowledge-inspector.js +501 -0
- package/dist/knowledge-inspector.js.map +1 -0
- package/dist/schema.d.ts +3 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +1 -0
- package/dist/schema.js.map +1 -1
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,84 @@
|
|
|
1
1
|
# @mastra/code-sdk
|
|
2
2
|
|
|
3
|
+
## 1.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added foundational support for an upcoming experimental memory capability across storage, runtime, and developer tooling. ([#19538](https://github.com/mastra-ai/mastra/pull/19538))
|
|
8
|
+
|
|
9
|
+
- Added opt-in discovery for MCP servers configured globally in Claude Code and Codex CLI. Enable the sources with `mcp.claudeCodeGlobal` or `mcp.codexGlobal` in Mastra Code settings. ([#21598](https://github.com/mastra-ai/mastra/pull/21598))
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Fixed custom command discovery loading Markdown files from node_modules. ([#21680](https://github.com/mastra-ai/mastra/pull/21680))
|
|
14
|
+
|
|
15
|
+
- Stop an unread hook stdin from crashing the host process. A hook command that exits without reading its stdin closes the pipe mid-write, and the resulting EPIPE arrived as an unhandled socket error rather than a throw, so the surrounding `try/catch` never saw it and Node tore the process down. The socket error is now absorbed; the hook's real outcome still comes from its exit code. ([#21796](https://github.com/mastra-ai/mastra/pull/21796))
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`587f6ef`](https://github.com/mastra-ai/mastra/commit/587f6efcfc25880b93760a8607d1cd381ec612fe), [`7e096f0`](https://github.com/mastra-ai/mastra/commit/7e096f02f0dddbf09b85d306458351245ed2f886), [`d7e6745`](https://github.com/mastra-ai/mastra/commit/d7e67456954863c55440ea9c49bc6ceb9949972d), [`6223446`](https://github.com/mastra-ai/mastra/commit/6223446ddce6166e96e0ba5e00d628b615dee8ca), [`15101bb`](https://github.com/mastra-ai/mastra/commit/15101bb53c0d934f31af6b8813b88191e382a5e5), [`4e7a421`](https://github.com/mastra-ai/mastra/commit/4e7a421dce8a48742f785d1e93ad2f43a572b282), [`c2c3deb`](https://github.com/mastra-ai/mastra/commit/c2c3debcf670c7082d0a5e553aa99818a864698c), [`4077487`](https://github.com/mastra-ai/mastra/commit/407748777c9bc9d5795033f36220e97df5553355), [`d8308a2`](https://github.com/mastra-ai/mastra/commit/d8308a2be3c07e777393d1017a381dcae3890d30), [`b0a2a07`](https://github.com/mastra-ai/mastra/commit/b0a2a07800d42bd9823292e7db832374ed084c9c), [`74e5bd3`](https://github.com/mastra-ai/mastra/commit/74e5bd315b8b3a1e04cb6cf480bb0f5fc4951dc8), [`242e324`](https://github.com/mastra-ai/mastra/commit/242e3241e73cbd5c9bb86a31ebb49ca0256488d4), [`217e967`](https://github.com/mastra-ai/mastra/commit/217e9672d8b3160eb729d8e9f0044949e88da239), [`d774e89`](https://github.com/mastra-ai/mastra/commit/d774e8930c781df8c9effe3763e6b501c099b6cc), [`9c27a53`](https://github.com/mastra-ai/mastra/commit/9c27a53cd9d3de4f3f025bc387d94ce371c33f95), [`8f0a332`](https://github.com/mastra-ai/mastra/commit/8f0a3321bf180368d76fe7b36aa1a8f60f00b6de), [`d6c618f`](https://github.com/mastra-ai/mastra/commit/d6c618f37496f801827d4caa76feab742f1a7383), [`0b4f108`](https://github.com/mastra-ai/mastra/commit/0b4f1089aa8d92e67c2a8e99726822c5ee410784), [`9acb50f`](https://github.com/mastra-ai/mastra/commit/9acb50f71cec9c362f06820033f90ae6b1f8282f), [`46e9e3f`](https://github.com/mastra-ai/mastra/commit/46e9e3f73babe1bc70080a596cf2ac0b9da48519), [`b0a2a07`](https://github.com/mastra-ai/mastra/commit/b0a2a07800d42bd9823292e7db832374ed084c9c), [`3f9a190`](https://github.com/mastra-ai/mastra/commit/3f9a19057c027155867b9317294ee4ca7bd0581a), [`dff25a1`](https://github.com/mastra-ai/mastra/commit/dff25a1103fa72ee082a9b6f805ebeb5ce400753), [`6db7a5d`](https://github.com/mastra-ai/mastra/commit/6db7a5dd3dd2b6f7ef75dcd804fcffef5fa83963), [`217e967`](https://github.com/mastra-ai/mastra/commit/217e9672d8b3160eb729d8e9f0044949e88da239), [`583e235`](https://github.com/mastra-ai/mastra/commit/583e23519c13af16c1746f9c49722d011216611b), [`b098de9`](https://github.com/mastra-ai/mastra/commit/b098de9d7cb9f672e0883a5c716465a3a689693d), [`e8808e3`](https://github.com/mastra-ai/mastra/commit/e8808e3d8eb585a2565be53e56a7e0e1477352a4), [`694bd68`](https://github.com/mastra-ai/mastra/commit/694bd68fb427ee52e59aaab06167617f261b121c), [`a77f8d4`](https://github.com/mastra-ai/mastra/commit/a77f8d4740d2178a74c41e4bf678b4fcd8fa0bb2), [`7f78585`](https://github.com/mastra-ai/mastra/commit/7f785857e401570e2ffb316911f126ed363aa537), [`33374ba`](https://github.com/mastra-ai/mastra/commit/33374ba359e4fb13eaa918ae925fe167a3c55414), [`940bf5c`](https://github.com/mastra-ai/mastra/commit/940bf5ccf04f2c9ebd8a1390431733222a03b1cd), [`c549e2f`](https://github.com/mastra-ai/mastra/commit/c549e2f40edc1cac5d9e74e82f90da22b48df084), [`58c43d3`](https://github.com/mastra-ai/mastra/commit/58c43d3f7cb2eeaeb8ac733ae71dde822348e588), [`ef6e295`](https://github.com/mastra-ai/mastra/commit/ef6e295b59bc25a5b61b633a89c97bcfce9fb465), [`208e1b3`](https://github.com/mastra-ai/mastra/commit/208e1b39f30f4b386e494394e9d71d96f0f90241), [`c938d34`](https://github.com/mastra-ai/mastra/commit/c938d34739936c8ecbabd67ad6a4a4396f41c4c6), [`88ddc7c`](https://github.com/mastra-ai/mastra/commit/88ddc7ce01d40175f13a3228b789a906779680bd), [`f2a4afd`](https://github.com/mastra-ai/mastra/commit/f2a4afd7e37e809669001ed17724b341a5c1f45e), [`f2a4afd`](https://github.com/mastra-ai/mastra/commit/f2a4afd7e37e809669001ed17724b341a5c1f45e), [`d438148`](https://github.com/mastra-ai/mastra/commit/d438148e222c1e2fb3c652725ce75680962ebec4), [`ba05fe0`](https://github.com/mastra-ai/mastra/commit/ba05fe0738f70cb686777546e968237d09269142), [`eede4de`](https://github.com/mastra-ai/mastra/commit/eede4de104f59b391d28aa249659388e9a1cf558), [`40d358e`](https://github.com/mastra-ai/mastra/commit/40d358e29d55543803e64b49241122f598ffabc7), [`d26a8d4`](https://github.com/mastra-ai/mastra/commit/d26a8d4281f28414715b333c85bedaf70d0b2890), [`e80cd7e`](https://github.com/mastra-ai/mastra/commit/e80cd7e7683e7d732e1cc6784bcac1d2640d2ce3), [`ccbbcd9`](https://github.com/mastra-ai/mastra/commit/ccbbcd974eedff4367a54ed0e24c9ee742ab2f61), [`39ba1b9`](https://github.com/mastra-ai/mastra/commit/39ba1b9ce256a9a910a16f125cc6a59588185bfe), [`1d9a0ea`](https://github.com/mastra-ai/mastra/commit/1d9a0ea4a9901baee6cd56737243bd6d1f631ac0), [`677cdc6`](https://github.com/mastra-ai/mastra/commit/677cdc6af564dec29a13464d12b7ab2a4efc22e9), [`c549e2f`](https://github.com/mastra-ai/mastra/commit/c549e2f40edc1cac5d9e74e82f90da22b48df084), [`a7dd322`](https://github.com/mastra-ai/mastra/commit/a7dd32247d95afc539f483ca37f4594af0387f59), [`3f5c6f7`](https://github.com/mastra-ai/mastra/commit/3f5c6f728ea35da344248de9aa070f12849f3aa0), [`eede4de`](https://github.com/mastra-ai/mastra/commit/eede4de104f59b391d28aa249659388e9a1cf558), [`a318490`](https://github.com/mastra-ai/mastra/commit/a318490e17da32f338d50929c770d901a9b3dd72), [`b860493`](https://github.com/mastra-ai/mastra/commit/b86049391100e665d579f700c8a2034c036defc3), [`0e5b1d9`](https://github.com/mastra-ai/mastra/commit/0e5b1d9513399e5ef6f1c114367393abf124a8e2), [`5c3e4d9`](https://github.com/mastra-ai/mastra/commit/5c3e4d9082b483e911c82baf1f3f4d4b27be5bc3), [`d4be8c1`](https://github.com/mastra-ai/mastra/commit/d4be8c1739d22d621e3f78790e1dd5eb5ecc3589), [`a5d2eb1`](https://github.com/mastra-ai/mastra/commit/a5d2eb10347eade1ae2816d88f466c25186c54a5), [`13d49d8`](https://github.com/mastra-ai/mastra/commit/13d49d82f434f319d4bd9a4234369d8186f8e102), [`0f53aeb`](https://github.com/mastra-ai/mastra/commit/0f53aeb119158bd9f83bd8ef667f1f675740e8f0), [`a97044b`](https://github.com/mastra-ai/mastra/commit/a97044b00cc79e189b07509701b2694c728dfeac), [`3667679`](https://github.com/mastra-ai/mastra/commit/3667679db057edfb086846d13369fdda4902ad65), [`49696e8`](https://github.com/mastra-ai/mastra/commit/49696e8e42f870674a0a58f5abcd22cc54dd2864), [`2ef2f23`](https://github.com/mastra-ai/mastra/commit/2ef2f230a7aed342e7dc3b2000cd42e4c43e08a7), [`4c0b961`](https://github.com/mastra-ai/mastra/commit/4c0b9611e89c5097b7a02a28c6816e0adcbcfa09), [`763e0c6`](https://github.com/mastra-ai/mastra/commit/763e0c61e04d76ad9a9efd301aa57525ca0cbea9), [`20504b2`](https://github.com/mastra-ai/mastra/commit/20504b2ecebd0e077acda3d457ab57480a98ed3e), [`0db29ce`](https://github.com/mastra-ai/mastra/commit/0db29ce28d0089e2e0a9a65270321ed08d5d9ce6), [`77e6b1b`](https://github.com/mastra-ai/mastra/commit/77e6b1bc4c46ce94fe501023fb4393c812ec6be3), [`c5f964d`](https://github.com/mastra-ai/mastra/commit/c5f964d3f77064e978f8066ec506eed77ba5c63c), [`23e0be2`](https://github.com/mastra-ai/mastra/commit/23e0be261381e49534b4ff3101c60ee64a946cbf), [`217e967`](https://github.com/mastra-ai/mastra/commit/217e9672d8b3160eb729d8e9f0044949e88da239), [`2d56f92`](https://github.com/mastra-ai/mastra/commit/2d56f922d4090fded13a68029d8eeed1a7857c79), [`7fc8806`](https://github.com/mastra-ai/mastra/commit/7fc880627d3cbf995d31ea0e8b807bf15417e651), [`0e02eac`](https://github.com/mastra-ai/mastra/commit/0e02eacdb2e30e1697a41910b41163742a181dc1), [`4df174c`](https://github.com/mastra-ai/mastra/commit/4df174c32bddf093a82f273070b8380aef7c9e90), [`f7c25b5`](https://github.com/mastra-ai/mastra/commit/f7c25b5106ddfb48e591f98df7a51e0f2dd01dba), [`7aad631`](https://github.com/mastra-ai/mastra/commit/7aad631b43bc10db77d5b8c66b200d7a49d18bf2), [`512100a`](https://github.com/mastra-ai/mastra/commit/512100a7d8b7e9c920f2590c6b3612f5de0d3cff), [`e81744c`](https://github.com/mastra-ai/mastra/commit/e81744cd13c46619c142dc521dc0baac47607a84), [`f8f653f`](https://github.com/mastra-ai/mastra/commit/f8f653f10980d01a73706cc3c8689ca5e40ce808), [`cd19e4c`](https://github.com/mastra-ai/mastra/commit/cd19e4c575e4129cd20e3d881acc75120bfcdde0), [`dc09cc1`](https://github.com/mastra-ai/mastra/commit/dc09cc1083d861cde192c1cd235324dc75b8c731), [`7f78585`](https://github.com/mastra-ai/mastra/commit/7f785857e401570e2ffb316911f126ed363aa537), [`e81744c`](https://github.com/mastra-ai/mastra/commit/e81744cd13c46619c142dc521dc0baac47607a84), [`9ef432b`](https://github.com/mastra-ai/mastra/commit/9ef432b6faa534b57b0d182a610e13dd9a7123ff), [`36b4649`](https://github.com/mastra-ai/mastra/commit/36b4649045a3a380cbab8ceca866db4086223aff), [`b9cf308`](https://github.com/mastra-ai/mastra/commit/b9cf30846f97f99ac1906ee8a68f4f2d117b0378), [`2e1d098`](https://github.com/mastra-ai/mastra/commit/2e1d0984e325fd319d32ea182f596b3170be3847), [`377eb81`](https://github.com/mastra-ai/mastra/commit/377eb81ce43b964e3a6b541df172da74a8ff3716), [`1794a79`](https://github.com/mastra-ai/mastra/commit/1794a79178c418004a7261b1ad9114066f7ef01d), [`0cdc5dc`](https://github.com/mastra-ai/mastra/commit/0cdc5dc69024957815da4f51acc4119eb4f447d7), [`5740ec6`](https://github.com/mastra-ai/mastra/commit/5740ec60c760ffdfbfaa59d603d03b847c864e05)]:
|
|
18
|
+
- @mastra/core@1.60.0
|
|
19
|
+
- @mastra/observability@1.17.1
|
|
20
|
+
- @mastra/memory@1.27.0
|
|
21
|
+
- @mastra/mcp@1.17.0
|
|
22
|
+
- @mastra/pg@1.21.0
|
|
23
|
+
- @mastra/libsql@1.21.0
|
|
24
|
+
- @mastra/duckdb@1.6.2
|
|
25
|
+
|
|
26
|
+
## 1.3.0-alpha.14
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [[`58c43d3`](https://github.com/mastra-ai/mastra/commit/58c43d3f7cb2eeaeb8ac733ae71dde822348e588)]:
|
|
31
|
+
- @mastra/core@1.60.0-alpha.14
|
|
32
|
+
|
|
33
|
+
## 1.3.0-alpha.13
|
|
34
|
+
|
|
35
|
+
### Minor Changes
|
|
36
|
+
|
|
37
|
+
- Added foundational support for an upcoming experimental memory capability across storage, runtime, and developer tooling. ([#19538](https://github.com/mastra-ai/mastra/pull/19538))
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- Stop an unread hook stdin from crashing the host process. A hook command that exits without reading its stdin closes the pipe mid-write, and the resulting EPIPE arrived as an unhandled socket error rather than a throw, so the surrounding `try/catch` never saw it and Node tore the process down. The socket error is now absorbed; the hook's real outcome still comes from its exit code. ([#21796](https://github.com/mastra-ai/mastra/pull/21796))
|
|
42
|
+
|
|
43
|
+
- Updated dependencies [[`c549e2f`](https://github.com/mastra-ai/mastra/commit/c549e2f40edc1cac5d9e74e82f90da22b48df084), [`c549e2f`](https://github.com/mastra-ai/mastra/commit/c549e2f40edc1cac5d9e74e82f90da22b48df084), [`2ef2f23`](https://github.com/mastra-ai/mastra/commit/2ef2f230a7aed342e7dc3b2000cd42e4c43e08a7), [`5740ec6`](https://github.com/mastra-ai/mastra/commit/5740ec60c760ffdfbfaa59d603d03b847c864e05)]:
|
|
44
|
+
- @mastra/core@1.60.0-alpha.13
|
|
45
|
+
- @mastra/memory@1.27.0-alpha.3
|
|
46
|
+
- @mastra/libsql@1.21.0-alpha.1
|
|
47
|
+
- @mastra/pg@1.21.0-alpha.4
|
|
48
|
+
|
|
49
|
+
## 1.3.0-alpha.12
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- Updated dependencies [[`6db7a5d`](https://github.com/mastra-ai/mastra/commit/6db7a5dd3dd2b6f7ef75dcd804fcffef5fa83963), [`0e5b1d9`](https://github.com/mastra-ai/mastra/commit/0e5b1d9513399e5ef6f1c114367393abf124a8e2), [`0cdc5dc`](https://github.com/mastra-ai/mastra/commit/0cdc5dc69024957815da4f51acc4119eb4f447d7)]:
|
|
54
|
+
- @mastra/core@1.60.0-alpha.12
|
|
55
|
+
- @mastra/pg@1.20.1-alpha.3
|
|
56
|
+
|
|
57
|
+
## 1.3.0-alpha.11
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- Updated dependencies [[`6223446`](https://github.com/mastra-ai/mastra/commit/6223446ddce6166e96e0ba5e00d628b615dee8ca), [`583e235`](https://github.com/mastra-ai/mastra/commit/583e23519c13af16c1746f9c49722d011216611b), [`a77f8d4`](https://github.com/mastra-ai/mastra/commit/a77f8d4740d2178a74c41e4bf678b4fcd8fa0bb2), [`40d358e`](https://github.com/mastra-ai/mastra/commit/40d358e29d55543803e64b49241122f598ffabc7), [`e80cd7e`](https://github.com/mastra-ai/mastra/commit/e80cd7e7683e7d732e1cc6784bcac1d2640d2ce3), [`39ba1b9`](https://github.com/mastra-ai/mastra/commit/39ba1b9ce256a9a910a16f125cc6a59588185bfe), [`0f53aeb`](https://github.com/mastra-ai/mastra/commit/0f53aeb119158bd9f83bd8ef667f1f675740e8f0), [`20504b2`](https://github.com/mastra-ai/mastra/commit/20504b2ecebd0e077acda3d457ab57480a98ed3e), [`0db29ce`](https://github.com/mastra-ai/mastra/commit/0db29ce28d0089e2e0a9a65270321ed08d5d9ce6)]:
|
|
62
|
+
- @mastra/core@1.60.0-alpha.11
|
|
63
|
+
- @mastra/mcp@1.17.0-alpha.2
|
|
64
|
+
- @mastra/libsql@1.20.1-alpha.0
|
|
65
|
+
- @mastra/pg@1.20.1-alpha.2
|
|
66
|
+
|
|
67
|
+
## 1.3.0-alpha.10
|
|
68
|
+
|
|
69
|
+
### Patch Changes
|
|
70
|
+
|
|
71
|
+
- Updated dependencies [[`b860493`](https://github.com/mastra-ai/mastra/commit/b86049391100e665d579f700c8a2034c036defc3)]:
|
|
72
|
+
- @mastra/core@1.60.0-alpha.10
|
|
73
|
+
|
|
74
|
+
## 1.3.0-alpha.9
|
|
75
|
+
|
|
76
|
+
### Patch Changes
|
|
77
|
+
|
|
78
|
+
- Updated dependencies [[`b0a2a07`](https://github.com/mastra-ai/mastra/commit/b0a2a07800d42bd9823292e7db832374ed084c9c), [`b0a2a07`](https://github.com/mastra-ai/mastra/commit/b0a2a07800d42bd9823292e7db832374ed084c9c), [`ccbbcd9`](https://github.com/mastra-ai/mastra/commit/ccbbcd974eedff4367a54ed0e24c9ee742ab2f61), [`3f5c6f7`](https://github.com/mastra-ai/mastra/commit/3f5c6f728ea35da344248de9aa070f12849f3aa0), [`77e6b1b`](https://github.com/mastra-ai/mastra/commit/77e6b1bc4c46ce94fe501023fb4393c812ec6be3), [`2e1d098`](https://github.com/mastra-ai/mastra/commit/2e1d0984e325fd319d32ea182f596b3170be3847)]:
|
|
79
|
+
- @mastra/memory@1.27.0-alpha.2
|
|
80
|
+
- @mastra/core@1.60.0-alpha.9
|
|
81
|
+
|
|
3
82
|
## 1.3.0-alpha.8
|
|
4
83
|
|
|
5
84
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/agents/memory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/agents/memory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,MAAM,EAAgB,MAAM,gBAAgB,CAAC;AAkEtD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,EAAE,MAAM,CAAC,EAAE,YAAY,IAM3E,oBAAoB;IAAE,cAAc,EAAE,cAAc,CAAA;CAAE,YAqG/D"}
|
package/dist/agents/memory.js
CHANGED
|
@@ -2,7 +2,7 @@ import { DEFAULT_OM_MODEL_ID } from "../constants.js";
|
|
|
2
2
|
import { getOmScope } from "../utils/project.js";
|
|
3
3
|
import { resolveModel } from "./model.js";
|
|
4
4
|
import { fastembed } from "@mastra/fastembed";
|
|
5
|
-
import { Memory } from "@mastra/memory";
|
|
5
|
+
import { Memory, Subconscious } from "@mastra/memory";
|
|
6
6
|
//#region src/agents/memory.ts
|
|
7
7
|
/**
|
|
8
8
|
* Read controller state from requestContext.
|
|
@@ -63,14 +63,25 @@ function getDynamicMemory(storage, vector) {
|
|
|
63
63
|
let cachedMemory = null;
|
|
64
64
|
let cachedMemoryKey = null;
|
|
65
65
|
return ({ requestContext }) => {
|
|
66
|
-
const
|
|
66
|
+
const controller = requestContext.get("controller");
|
|
67
|
+
const state = controller?.getState();
|
|
68
|
+
const subconsciousEnabled = Boolean(vector) && process.env.MASTRACODE_EXPERIMENTAL_SUBCONSCIOUS === "1";
|
|
69
|
+
const factoryProjectId = state?.factoryProjectId;
|
|
70
|
+
const isFactory = typeof factoryProjectId === "string" && factoryProjectId.trim().length > 0;
|
|
71
|
+
if (subconsciousEnabled) {
|
|
72
|
+
const factoryOrgId = state?.factoryOrgId;
|
|
73
|
+
const ownerId = controller?.session.ownerId;
|
|
74
|
+
if (typeof factoryOrgId === "string" && factoryOrgId.trim()) requestContext.set("organizationId", factoryOrgId);
|
|
75
|
+
else if (ownerId) requestContext.set("organizationId", ownerId);
|
|
76
|
+
if (isFactory) requestContext.set("knowledgeResourceId", factoryProjectId);
|
|
77
|
+
}
|
|
67
78
|
const omScope = state?.omScope ?? getOmScope(state?.projectPath);
|
|
68
79
|
const obsThreshold = state?.observationThreshold ?? 3e4;
|
|
69
80
|
const refThreshold = state?.reflectionThreshold ?? 4e4;
|
|
70
81
|
const caveman = state?.cavemanObservations ?? false;
|
|
71
82
|
const observerPreviousObservationTokens = 1e3;
|
|
72
83
|
const observeAttachments = state?.observeAttachments;
|
|
73
|
-
const cacheKey = `${obsThreshold}:${refThreshold}:${omScope}:${observerPreviousObservationTokens}:${caveman ? 1 : 0}:${observeAttachments}`;
|
|
84
|
+
const cacheKey = `${obsThreshold}:${refThreshold}:${omScope}:${observerPreviousObservationTokens}:${caveman ? 1 : 0}:${observeAttachments}:${isFactory ? 1 : 0}:${subconsciousEnabled ? 1 : 0}`;
|
|
74
85
|
if (cachedMemory && cachedMemoryKey === cacheKey) return cachedMemory;
|
|
75
86
|
const isResourceScope = omScope === "resource";
|
|
76
87
|
const observerInstruction = caveman ? `${DYNAMIC_AGENTS_MD_INSTRUCTION}\n\n${CAVEMAN_OM_INSTRUCTION}` : DYNAMIC_AGENTS_MD_INSTRUCTION;
|
|
@@ -83,6 +94,13 @@ function getDynamicMemory(storage, vector) {
|
|
|
83
94
|
enabled: true,
|
|
84
95
|
temporalMarkers: true,
|
|
85
96
|
retrieval: vector ? { vector: true } : true,
|
|
97
|
+
experimental_subconscious: subconsciousEnabled ? new Subconscious({
|
|
98
|
+
defaultScope: "resource",
|
|
99
|
+
maxScope: "resource",
|
|
100
|
+
pins: isFactory ? { capturePinning: true } : true,
|
|
101
|
+
...isFactory ? { curationCadence: 3 } : {},
|
|
102
|
+
...isFactory ? { maxSteps: 25 } : {}
|
|
103
|
+
}) : void 0,
|
|
86
104
|
scope: omScope,
|
|
87
105
|
activateAfterIdle: "auto",
|
|
88
106
|
activateOnProviderChange: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.js","names":[],"sources":["../../src/agents/memory.ts"],"sourcesContent":["import type { AgentControllerRequestContext } from '@mastra/core/agent-controller';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport type { MastraCompositeStore } from '@mastra/core/storage';\nimport type { MastraVector } from '@mastra/core/vector';\nimport { fastembed } from '@mastra/fastembed';\nimport { Memory } from '@mastra/memory';\nimport { DEFAULT_OM_MODEL_ID, DEFAULT_OBS_THRESHOLD, DEFAULT_REF_THRESHOLD } from '../constants.js';\nimport type { MastraCodeState } from '../schema.js';\nimport { getOmScope } from '../utils/project.js';\nimport { resolveModel } from './model.js';\n\n/**\n * Read controller state from requestContext.\n * Used by both the memory factory and the OM model functions.\n */\nfunction getAgentControllerState(requestContext: RequestContext): MastraCodeState | undefined {\n const ctx = requestContext.get('controller') as AgentControllerRequestContext<MastraCodeState> | undefined;\n return ctx?.getState() as MastraCodeState | undefined;\n}\n\n/**\n * Observer model function — reads the current observer model ID from\n * controller state via requestContext (now propagated by OM's agent.generate).\n */\nfunction getObserverModel({ requestContext }: { requestContext: RequestContext }) {\n const state = getAgentControllerState(requestContext);\n return resolveModel(state?.observerModelId ?? DEFAULT_OM_MODEL_ID, {\n remapForCodexOAuth: true,\n requestContext,\n });\n}\n\n/**\n * Reflector model function — reads the current reflector model ID from\n * controller state via requestContext (now propagated by OM's agent.generate).\n */\nfunction getReflectorModel({ requestContext }: { requestContext: RequestContext }) {\n const state = getAgentControllerState(requestContext);\n return resolveModel(state?.reflectorModelId ?? DEFAULT_OM_MODEL_ID, {\n remapForCodexOAuth: true,\n requestContext,\n });\n}\n\nconst DYNAMIC_AGENTS_MD_INSTRUCTION =\n 'Messages wrapped in <system-reminder type=\"dynamic-agents-md\" ...>...</system-reminder> are ephemeral project-context instructions injected from files on disk. Do NOT observe or extract information from these messages — they are reloaded automatically when needed and should not be stored in memory.';\n\n// Derived from https://github.com/JuliusBrussee/caveman and adapted for OM use with fixed full-level compression.\nconst CAVEMAN_OM_INSTRUCTION = `Respond terse like smart caveman. All technical substance stay. Only fluff die.\n\nUse full caveman compression style.\n\nDrop: articles (a/an/the), filler (just/really/basically/actually/simply), pleasantries (sure/certainly/of course/happy to), hedging. Fragments OK. Short synonyms (big not extensive, fix not \"implement a solution for\"). Technical terms exact. Code blocks unchanged. Errors quoted exact. Leave out the words \"agent\" and \"assistant\" at the start of each observation line, it is assumed each line is referring to the assistant unless it specifically says it was about the user. Leave out parenthesis and other text characters like * that would not contribute to understanding the observations.\n\nPattern: \\`[thing] [action] [reason]. [next step]\\`\n\nNot: \"Sure! I'd be happy to help you with that. The issue you're experiencing is likely caused by...\"\nYes: \"Bug in auth middleware. Token expiry check use < not <=. Fix:\"\n\nExample 1\n🔴 14:31 user asks why React component rerenders\n🟡 14:32 saw inline object prop create new ref each render, cause rerender\n✅ 14:34 fixed render issue by wrap object in useMemo\n\nExample 2\n🟡 15:10 explained pool reuse DB connections, skip repeat handshake overhead\n\nDon't say \"Agent did x\", say \"did x\". It will be assumed the agent did what was observed. The who should only be specified for the user or other third parties: \"user asked x\"\n\nDrop caveman for: security warnings, irreversible action confirmations, multi-step sequences where fragment order risks misread, user asks to clarify or repeats question, and anything that requires remembering verbatim content. Resume caveman after clear part done`;\n\n/**\n * Dynamic memory factory function.\n * Reads OM thresholds from controller state via requestContext.\n * Model functions also read from requestContext (no mutable bridge needed).\n */\nexport function getDynamicMemory(storage: MastraCompositeStore, vector?: MastraVector) {\n // Cache is scoped per storage instance (per getDynamicMemory call) so a\n // Memory bound to one storage is never reused after storage changes.\n let cachedMemory: Memory | null = null;\n let cachedMemoryKey: string | null = null;\n\n return ({ requestContext }: { requestContext: RequestContext }) => {\n const state = getAgentControllerState(requestContext);\n const omScope = state?.omScope ?? getOmScope(state?.projectPath);\n\n const obsThreshold = state?.observationThreshold ?? DEFAULT_OBS_THRESHOLD;\n const refThreshold = state?.reflectionThreshold ?? DEFAULT_REF_THRESHOLD;\n const caveman = state?.cavemanObservations ?? false;\n\n const observerPreviousObservationTokens = 1000;\n const observeAttachments = state?.observeAttachments;\n const cacheKey = `${obsThreshold}:${refThreshold}:${omScope}:${observerPreviousObservationTokens}:${caveman ? 1 : 0}:${observeAttachments}`;\n if (cachedMemory && cachedMemoryKey === cacheKey) {\n return cachedMemory;\n }\n\n // Async buffering is not supported with resource scope — disable it\n const isResourceScope = omScope === 'resource';\n\n const observerInstruction = caveman\n ? `${DYNAMIC_AGENTS_MD_INSTRUCTION}\\n\\n${CAVEMAN_OM_INSTRUCTION}`\n : DYNAMIC_AGENTS_MD_INSTRUCTION;\n const reflectionInstruction = caveman ? CAVEMAN_OM_INSTRUCTION : undefined;\n\n cachedMemory = new Memory({\n storage,\n vector: vector || false,\n embedder: vector ? fastembed.small : undefined,\n options: {\n observationalMemory: {\n enabled: true,\n temporalMarkers: true,\n retrieval: vector ? { vector: true } : true,\n scope: omScope,\n activateAfterIdle: 'auto',\n activateOnProviderChange: true,\n observation: {\n bufferTokens: isResourceScope ? false : 1 / 5,\n bufferActivation: isResourceScope ? undefined : 2000,\n model: getObserverModel,\n messageTokens: obsThreshold,\n blockAfter: 2,\n previousObserverTokens: observerPreviousObservationTokens,\n threadTitle: true,\n instruction: observerInstruction,\n observeAttachments,\n },\n reflection: {\n bufferActivation: isResourceScope ? undefined : 1 / 2,\n blockAfter: 1.1,\n model: getReflectorModel,\n observationTokens: refThreshold,\n instruction: reflectionInstruction,\n },\n },\n },\n });\n cachedMemoryKey = cacheKey;\n\n return cachedMemory;\n };\n}\n"],"mappings":";;;;;;;;;;AAeA,SAAS,wBAAwB,gBAA6D;CAE5F,OADY,eAAe,IAAI,YACtB,CAAC,EAAE,SAAS;AACvB;;;;;AAMA,SAAS,iBAAiB,EAAE,kBAAsD;CAEhF,OAAO,aADO,wBAAwB,cACd,CAAC,EAAE,mBAAmB,qBAAqB;EACjE,oBAAoB;EACpB;CACF,CAAC;AACH;;;;;AAMA,SAAS,kBAAkB,EAAE,kBAAsD;CAEjF,OAAO,aADO,wBAAwB,cACd,CAAC,EAAE,oBAAoB,qBAAqB;EAClE,oBAAoB;EACpB;CACF,CAAC;AACH;AAEA,MAAM,gCACJ;AAGF,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4B/B,SAAgB,iBAAiB,SAA+B,QAAuB;CAGrF,IAAI,eAA8B;CAClC,IAAI,kBAAiC;CAErC,QAAQ,EAAE,qBAAyD;EACjE,MAAM,QAAQ,wBAAwB,cAAc;EACpD,MAAM,UAAU,OAAO,WAAW,WAAW,OAAO,WAAW;EAE/D,MAAM,eAAe,OAAO,wBAAA;EAC5B,MAAM,eAAe,OAAO,uBAAA;EAC5B,MAAM,UAAU,OAAO,uBAAuB;EAE9C,MAAM,oCAAoC;EAC1C,MAAM,qBAAqB,OAAO;EAClC,MAAM,WAAW,GAAG,aAAa,GAAG,aAAa,GAAG,QAAQ,GAAG,kCAAkC,GAAG,UAAU,IAAI,EAAE,GAAG;EACvH,IAAI,gBAAgB,oBAAoB,UACtC,OAAO;EAIT,MAAM,kBAAkB,YAAY;EAEpC,MAAM,sBAAsB,UACxB,GAAG,8BAA8B,MAAM,2BACvC;EACJ,MAAM,wBAAwB,UAAU,yBAAyB,KAAA;EAEjE,eAAe,IAAI,OAAO;GACxB;GACA,QAAQ,UAAU;GAClB,UAAU,SAAS,UAAU,QAAQ,KAAA;GACrC,SAAS,EACP,qBAAqB;IACnB,SAAS;IACT,iBAAiB;IACjB,WAAW,SAAS,EAAE,QAAQ,KAAK,IAAI;IACvC,OAAO;IACP,mBAAmB;IACnB,0BAA0B;IAC1B,aAAa;KACX,cAAc,kBAAkB,QAAQ,IAAI;KAC5C,kBAAkB,kBAAkB,KAAA,IAAY;KAChD,OAAO;KACP,eAAe;KACf,YAAY;KACZ,wBAAwB;KACxB,aAAa;KACb,aAAa;KACb;IACF;IACA,YAAY;KACV,kBAAkB,kBAAkB,KAAA,IAAY,IAAI;KACpD,YAAY;KACZ,OAAO;KACP,mBAAmB;KACnB,aAAa;IACf;GACF,EACF;EACF,CAAC;EACD,kBAAkB;EAElB,OAAO;CACT;AACF"}
|
|
1
|
+
{"version":3,"file":"memory.js","names":[],"sources":["../../src/agents/memory.ts"],"sourcesContent":["import type { AgentControllerRequestContext } from '@mastra/core/agent-controller';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport type { MastraCompositeStore } from '@mastra/core/storage';\nimport type { MastraVector } from '@mastra/core/vector';\nimport { fastembed } from '@mastra/fastembed';\nimport { Memory, Subconscious } from '@mastra/memory';\nimport { DEFAULT_OM_MODEL_ID, DEFAULT_OBS_THRESHOLD, DEFAULT_REF_THRESHOLD } from '../constants.js';\nimport type { MastraCodeState } from '../schema.js';\nimport { getOmScope } from '../utils/project.js';\nimport { resolveModel } from './model.js';\n\n/**\n * Read controller state from requestContext.\n * Used by both the memory factory and the OM model functions.\n */\nfunction getAgentControllerState(requestContext: RequestContext): MastraCodeState | undefined {\n const ctx = requestContext.get('controller') as AgentControllerRequestContext<MastraCodeState> | undefined;\n return ctx?.getState() as MastraCodeState | undefined;\n}\n\n/**\n * Observer model function — reads the current observer model ID from\n * controller state via requestContext (now propagated by OM's agent.generate).\n */\nfunction getObserverModel({ requestContext }: { requestContext: RequestContext }) {\n const state = getAgentControllerState(requestContext);\n return resolveModel(state?.observerModelId ?? DEFAULT_OM_MODEL_ID, {\n remapForCodexOAuth: true,\n requestContext,\n });\n}\n\n/**\n * Reflector model function — reads the current reflector model ID from\n * controller state via requestContext (now propagated by OM's agent.generate).\n */\nfunction getReflectorModel({ requestContext }: { requestContext: RequestContext }) {\n const state = getAgentControllerState(requestContext);\n return resolveModel(state?.reflectorModelId ?? DEFAULT_OM_MODEL_ID, {\n remapForCodexOAuth: true,\n requestContext,\n });\n}\n\nconst DYNAMIC_AGENTS_MD_INSTRUCTION =\n 'Messages wrapped in <system-reminder type=\"dynamic-agents-md\" ...>...</system-reminder> are ephemeral project-context instructions injected from files on disk. Do NOT observe or extract information from these messages — they are reloaded automatically when needed and should not be stored in memory.';\n\n// Derived from https://github.com/JuliusBrussee/caveman and adapted for OM use with fixed full-level compression.\nconst CAVEMAN_OM_INSTRUCTION = `Respond terse like smart caveman. All technical substance stay. Only fluff die.\n\nUse full caveman compression style.\n\nDrop: articles (a/an/the), filler (just/really/basically/actually/simply), pleasantries (sure/certainly/of course/happy to), hedging. Fragments OK. Short synonyms (big not extensive, fix not \"implement a solution for\"). Technical terms exact. Code blocks unchanged. Errors quoted exact. Leave out the words \"agent\" and \"assistant\" at the start of each observation line, it is assumed each line is referring to the assistant unless it specifically says it was about the user. Leave out parenthesis and other text characters like * that would not contribute to understanding the observations.\n\nPattern: \\`[thing] [action] [reason]. [next step]\\`\n\nNot: \"Sure! I'd be happy to help you with that. The issue you're experiencing is likely caused by...\"\nYes: \"Bug in auth middleware. Token expiry check use < not <=. Fix:\"\n\nExample 1\n🔴 14:31 user asks why React component rerenders\n🟡 14:32 saw inline object prop create new ref each render, cause rerender\n✅ 14:34 fixed render issue by wrap object in useMemo\n\nExample 2\n🟡 15:10 explained pool reuse DB connections, skip repeat handshake overhead\n\nDon't say \"Agent did x\", say \"did x\". It will be assumed the agent did what was observed. The who should only be specified for the user or other third parties: \"user asked x\"\n\nDrop caveman for: security warnings, irreversible action confirmations, multi-step sequences where fragment order risks misread, user asks to clarify or repeats question, and anything that requires remembering verbatim content. Resume caveman after clear part done`;\n\n/**\n * Dynamic memory factory function.\n * Reads OM thresholds from controller state via requestContext.\n * Model functions also read from requestContext (no mutable bridge needed).\n */\nexport function getDynamicMemory(storage: MastraCompositeStore, vector?: MastraVector) {\n // Cache is scoped per storage instance (per getDynamicMemory call) so a\n // Memory bound to one storage is never reused after storage changes.\n let cachedMemory: Memory | null = null;\n let cachedMemoryKey: string | null = null;\n\n return ({ requestContext }: { requestContext: RequestContext }) => {\n const controller = requestContext.get('controller') as AgentControllerRequestContext<MastraCodeState> | undefined;\n const state = controller?.getState() as MastraCodeState | undefined;\n const subconsciousEnabled = Boolean(vector) && process.env.MASTRACODE_EXPERIMENTAL_SUBCONSCIOUS === '1';\n const factoryProjectId = state?.factoryProjectId;\n const isFactory = typeof factoryProjectId === 'string' && factoryProjectId.trim().length > 0;\n\n if (subconsciousEnabled) {\n // Factory seeds the authoritative org id into session state; prefer it.\n // The session owner is a USER id — mapping it into organizationId is only\n // the legacy fallback for clients (TUI/studio) that never set factoryOrgId.\n const factoryOrgId = state?.factoryOrgId;\n const ownerId = controller?.session.ownerId;\n if (typeof factoryOrgId === 'string' && factoryOrgId.trim()) {\n requestContext.set('organizationId', factoryOrgId);\n } else if (ownerId) {\n requestContext.set('organizationId', ownerId);\n }\n // Factory runs share one knowledge graph per project: anchor the\n // subconscious knowledge scope's resource rung on the project id.\n if (isFactory) {\n requestContext.set('knowledgeResourceId', factoryProjectId);\n }\n }\n\n const omScope = state?.omScope ?? getOmScope(state?.projectPath);\n\n const obsThreshold = state?.observationThreshold ?? DEFAULT_OBS_THRESHOLD;\n const refThreshold = state?.reflectionThreshold ?? DEFAULT_REF_THRESHOLD;\n const caveman = state?.cavemanObservations ?? false;\n\n const observerPreviousObservationTokens = 1000;\n const observeAttachments = state?.observeAttachments;\n // Factory sessions get a factory-only Subconscious config, so the cache key\n // carries a factory presence bit to keep the two configs from cross-serving.\n const cacheKey = `${obsThreshold}:${refThreshold}:${omScope}:${observerPreviousObservationTokens}:${caveman ? 1 : 0}:${observeAttachments}:${isFactory ? 1 : 0}:${subconsciousEnabled ? 1 : 0}`;\n if (cachedMemory && cachedMemoryKey === cacheKey) {\n return cachedMemory;\n }\n\n // Async buffering is not supported with resource scope — disable it\n const isResourceScope = omScope === 'resource';\n\n const observerInstruction = caveman\n ? `${DYNAMIC_AGENTS_MD_INSTRUCTION}\\n\\n${CAVEMAN_OM_INSTRUCTION}`\n : DYNAMIC_AGENTS_MD_INSTRUCTION;\n const reflectionInstruction = caveman ? CAVEMAN_OM_INSTRUCTION : undefined;\n\n cachedMemory = new Memory({\n storage,\n vector: vector || false,\n embedder: vector ? fastembed.small : undefined,\n options: {\n observationalMemory: {\n enabled: true,\n temporalMarkers: true,\n retrieval: vector ? { vector: true } : true,\n experimental_subconscious: subconsciousEnabled\n ? new Subconscious({\n defaultScope: 'resource',\n maxScope: 'resource',\n // Capture-time pinning is a factory-only opinion; every other\n // client keeps plain curator-maintained pins.\n pins: isFactory ? { capturePinning: true } : true,\n // Factory sessions run the curator every 3 observation runs;\n // other clients leave the cadence trigger dormant.\n ...(isFactory ? { curationCadence: 3 } : {}),\n // Real curation over a factory worklist needs tool room: the\n // default 5-step budget exhausts mid-batch and the curator never\n // reaches its cursor acknowledgment (observed live 2026-08-13).\n ...(isFactory ? { maxSteps: 25 } : {}),\n })\n : undefined,\n scope: omScope,\n activateAfterIdle: 'auto',\n activateOnProviderChange: true,\n observation: {\n bufferTokens: isResourceScope ? false : 1 / 5,\n bufferActivation: isResourceScope ? undefined : 2000,\n model: getObserverModel,\n messageTokens: obsThreshold,\n blockAfter: 2,\n previousObserverTokens: observerPreviousObservationTokens,\n threadTitle: true,\n instruction: observerInstruction,\n observeAttachments,\n },\n reflection: {\n bufferActivation: isResourceScope ? undefined : 1 / 2,\n blockAfter: 1.1,\n model: getReflectorModel,\n observationTokens: refThreshold,\n instruction: reflectionInstruction,\n },\n },\n },\n });\n cachedMemoryKey = cacheKey;\n\n return cachedMemory;\n };\n}\n"],"mappings":";;;;;;;;;;AAeA,SAAS,wBAAwB,gBAA6D;CAE5F,OADY,eAAe,IAAI,YACtB,CAAC,EAAE,SAAS;AACvB;;;;;AAMA,SAAS,iBAAiB,EAAE,kBAAsD;CAEhF,OAAO,aADO,wBAAwB,cACd,CAAC,EAAE,mBAAmB,qBAAqB;EACjE,oBAAoB;EACpB;CACF,CAAC;AACH;;;;;AAMA,SAAS,kBAAkB,EAAE,kBAAsD;CAEjF,OAAO,aADO,wBAAwB,cACd,CAAC,EAAE,oBAAoB,qBAAqB;EAClE,oBAAoB;EACpB;CACF,CAAC;AACH;AAEA,MAAM,gCACJ;AAGF,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4B/B,SAAgB,iBAAiB,SAA+B,QAAuB;CAGrF,IAAI,eAA8B;CAClC,IAAI,kBAAiC;CAErC,QAAQ,EAAE,qBAAyD;EACjE,MAAM,aAAa,eAAe,IAAI,YAAY;EAClD,MAAM,QAAQ,YAAY,SAAS;EACnC,MAAM,sBAAsB,QAAQ,MAAM,KAAK,QAAQ,IAAI,yCAAyC;EACpG,MAAM,mBAAmB,OAAO;EAChC,MAAM,YAAY,OAAO,qBAAqB,YAAY,iBAAiB,KAAK,CAAC,CAAC,SAAS;EAE3F,IAAI,qBAAqB;GAIvB,MAAM,eAAe,OAAO;GAC5B,MAAM,UAAU,YAAY,QAAQ;GACpC,IAAI,OAAO,iBAAiB,YAAY,aAAa,KAAK,GACxD,eAAe,IAAI,kBAAkB,YAAY;QAC5C,IAAI,SACT,eAAe,IAAI,kBAAkB,OAAO;GAI9C,IAAI,WACF,eAAe,I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AAmB;KACnB,aAAa;IACf;GACF,EACF;EACF,CAAC;EACD,kBAAkB;EAElB,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/hooks/executor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAc,eAAe,EAAE,MAAM,YAAY,CAAC;AAKrG,wBAAsB,WAAW,CAAC,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/hooks/executor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAc,eAAe,EAAE,MAAM,YAAY,CAAC;AAKrG,wBAAsB,WAAW,CAAC,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CA8FpG;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAa1F;AAED,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,cAAc,EAAE,EACvB,YAAY,EAAE,SAAS,EACvB,YAAY,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACxC,OAAO,CAAC,eAAe,CAAC,CA8C1B"}
|
package/dist/hooks/executor.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","names":[],"sources":["../../src/hooks/executor.ts"],"sourcesContent":["/**\n * Hook process execution.\n * Spawns shell commands, handles stdin/stdout/exit-code protocol.\n */\n\nimport { spawn } from 'node:child_process';\nimport type { HookDefinition, HookStdin, HookResult, HookStdout, HookEventResult } from './types.js';\nimport { isBlockingEvent } from './types.js';\n\nconst DEFAULT_TIMEOUT = 10_000;\n\nexport async function executeHook(hook: HookDefinition, stdinPayload: HookStdin): Promise<HookResult> {\n const timeout = hook.timeout ?? DEFAULT_TIMEOUT;\n const startTime = Date.now();\n\n return new Promise<HookResult>(resolve => {\n const isWindows = process.platform === 'win32';\n const shell = isWindows ? 'cmd' : '/bin/sh';\n const shellArgs = isWindows ? ['/c', hook.command] : ['-c', hook.command];\n\n const child = spawn(shell, shellArgs, {\n stdio: ['pipe', 'pipe', 'pipe'],\n cwd: stdinPayload.cwd,\n // Without this, Node's default Windows argument escaping re-quotes\n // hook.command before cmd.exe ever sees it, so a quoted path (or any\n // path containing spaces) reaches the child process with literal \"\n // characters embedded in it. mastracode/tui's shell-runner.ts already\n // sets this for its own cmd invocations; this call site just missed it.\n ...(isWindows ? { windowsVerbatimArguments: true } : {}),\n env: {\n ...process.env,\n MASTRA_HOOK_EVENT: stdinPayload.hook_event_name,\n },\n });\n\n let stdout = '';\n let stderr = '';\n let timedOut = false;\n let resolved = false;\n\n const timer = setTimeout(() => {\n timedOut = true;\n child.kill('SIGKILL');\n }, timeout);\n\n child.stdout?.on('data', (data: Buffer) => {\n stdout += data.toString();\n });\n\n child.stderr?.on('data', (data: Buffer) => {\n stderr += data.toString();\n });\n\n child.on('close', exitCode => {\n clearTimeout(timer);\n if (resolved) return;\n resolved = true;\n\n let parsedStdout: HookStdout | undefined;\n if (stdout.trim()) {\n try {\n parsedStdout = JSON.parse(stdout.trim()) as HookStdout;\n } catch {\n // Not valid JSON — ignore\n }\n }\n\n resolve({\n hook,\n exitCode: exitCode ?? 1,\n stdout: parsedStdout,\n stderr: stderr.trim() || undefined,\n timedOut,\n durationMs: Date.now() - startTime,\n });\n });\n\n child.on('error', error => {\n clearTimeout(timer);\n if (resolved) return;\n resolved = true;\n\n resolve({\n hook,\n exitCode: 1,\n stderr: error.message,\n timedOut: false,\n durationMs: Date.now() - startTime,\n });\n });\n\n try {\n child.stdin?.write(JSON.stringify(stdinPayload));\n child.stdin?.end();\n } catch {\n // stdin write failure — process continues\n }\n });\n}\n\nexport function matchesHook(hook: HookDefinition, context: { tool_name?: string }): boolean {\n if (!hook.matcher) return true;\n\n if (hook.matcher.tool_name) {\n if (!context.tool_name) return false;\n try {\n return new RegExp(hook.matcher.tool_name).test(context.tool_name);\n } catch {\n return false;\n }\n }\n\n return true;\n}\n\nexport async function runHooksForEvent(\n hooks: HookDefinition[],\n stdinPayload: HookStdin,\n matchContext: { tool_name?: string } = {},\n): Promise<HookEventResult> {\n const results: HookResult[] = [];\n const warnings: string[] = [];\n let additionalContext: string | undefined;\n\n const applicable = hooks.filter(h => matchesHook(h, matchContext));\n if (applicable.length === 0) {\n return { allowed: true, results: [], warnings: [] };\n }\n\n const blocking = isBlockingEvent(stdinPayload.hook_event_name);\n\n for (const hook of applicable) {\n const result = await executeHook(hook, stdinPayload);\n results.push(result);\n\n if (result.stdout?.additionalContext) {\n additionalContext = additionalContext\n ? `${additionalContext}\\n${result.stdout.additionalContext}`\n : result.stdout.additionalContext;\n }\n\n if (result.timedOut) {\n warnings.push(`Hook timed out after ${hook.timeout ?? DEFAULT_TIMEOUT}ms: ${hook.command}`);\n continue;\n }\n\n if (result.exitCode === 2 && blocking) {\n const reason = result.stdout?.reason || result.stderr || `Blocked by hook: ${hook.description || hook.command}`;\n\n return {\n allowed: false,\n blockReason: reason,\n additionalContext,\n results,\n warnings,\n };\n }\n\n if (result.exitCode === 0) continue;\n\n const warnMsg = result.stderr || `Hook exited with code ${result.exitCode}`;\n warnings.push(`${hook.description || hook.command}: ${warnMsg}`);\n }\n\n return { allowed: true, additionalContext, results, warnings };\n}\n"],"mappings":";;;;;;;AASA,MAAM,kBAAkB;AAExB,eAAsB,YAAY,MAAsB,cAA8C;CACpG,MAAM,UAAU,KAAK,WAAW;CAChC,MAAM,YAAY,KAAK,IAAI;CAE3B,OAAO,IAAI,SAAoB,YAAW;EACxC,MAAM,YAAY,QAAQ,aAAa;EAIvC,MAAM,QAAQ,MAHA,YAAY,QAAQ,WAChB,YAAY,CAAC,MAAM,KAAK,OAAO,IAAI,CAAC,MAAM,KAAK,OAAO,GAElC;GACpC,OAAO;IAAC;IAAQ;IAAQ;GAAM;GAC9B,KAAK,aAAa;GAMlB,GAAI,YAAY,EAAE,0BAA0B,KAAK,IAAI,CAAC;GACtD,KAAK;IACH,GAAG,QAAQ;IACX,mBAAmB,aAAa;GAClC;EACF,CAAC;EAED,IAAI,SAAS;EACb,IAAI,SAAS;EACb,IAAI,WAAW;EACf,IAAI,WAAW;EAEf,MAAM,QAAQ,iBAAiB;GAC7B,WAAW;GACX,MAAM,KAAK,SAAS;EACtB,GAAG,OAAO;EAEV,MAAM,QAAQ,GAAG,SAAS,SAAiB;GACzC,UAAU,KAAK,SAAS;EAC1B,CAAC;EAED,MAAM,QAAQ,GAAG,SAAS,SAAiB;GACzC,UAAU,KAAK,SAAS;EAC1B,CAAC;EAED,MAAM,GAAG,UAAS,aAAY;GAC5B,aAAa,KAAK;GAClB,IAAI,UAAU;GACd,WAAW;GAEX,IAAI;GACJ,IAAI,OAAO,KAAK,GACd,IAAI;IACF,eAAe,KAAK,MAAM,OAAO,KAAK,CAAC;GACzC,QAAQ,CAER;GAGF,QAAQ;IACN;IACA,UAAU,YAAY;IACtB,QAAQ;IACR,QAAQ,OAAO,KAAK,KAAK,KAAA;IACzB;IACA,YAAY,KAAK,IAAI,IAAI;GAC3B,CAAC;EACH,CAAC;EAED,MAAM,GAAG,UAAS,UAAS;GACzB,aAAa,KAAK;GAClB,IAAI,UAAU;GACd,WAAW;GAEX,QAAQ;IACN;IACA,UAAU;IACV,QAAQ,MAAM;IACd,UAAU;IACV,YAAY,KAAK,IAAI,IAAI;GAC3B,CAAC;EACH,CAAC;
|
|
1
|
+
{"version":3,"file":"executor.js","names":[],"sources":["../../src/hooks/executor.ts"],"sourcesContent":["/**\n * Hook process execution.\n * Spawns shell commands, handles stdin/stdout/exit-code protocol.\n */\n\nimport { spawn } from 'node:child_process';\nimport type { HookDefinition, HookStdin, HookResult, HookStdout, HookEventResult } from './types.js';\nimport { isBlockingEvent } from './types.js';\n\nconst DEFAULT_TIMEOUT = 10_000;\n\nexport async function executeHook(hook: HookDefinition, stdinPayload: HookStdin): Promise<HookResult> {\n const timeout = hook.timeout ?? DEFAULT_TIMEOUT;\n const startTime = Date.now();\n\n return new Promise<HookResult>(resolve => {\n const isWindows = process.platform === 'win32';\n const shell = isWindows ? 'cmd' : '/bin/sh';\n const shellArgs = isWindows ? ['/c', hook.command] : ['-c', hook.command];\n\n const child = spawn(shell, shellArgs, {\n stdio: ['pipe', 'pipe', 'pipe'],\n cwd: stdinPayload.cwd,\n // Without this, Node's default Windows argument escaping re-quotes\n // hook.command before cmd.exe ever sees it, so a quoted path (or any\n // path containing spaces) reaches the child process with literal \"\n // characters embedded in it. mastracode/tui's shell-runner.ts already\n // sets this for its own cmd invocations; this call site just missed it.\n ...(isWindows ? { windowsVerbatimArguments: true } : {}),\n env: {\n ...process.env,\n MASTRA_HOOK_EVENT: stdinPayload.hook_event_name,\n },\n });\n\n let stdout = '';\n let stderr = '';\n let timedOut = false;\n let resolved = false;\n\n const timer = setTimeout(() => {\n timedOut = true;\n child.kill('SIGKILL');\n }, timeout);\n\n child.stdout?.on('data', (data: Buffer) => {\n stdout += data.toString();\n });\n\n child.stderr?.on('data', (data: Buffer) => {\n stderr += data.toString();\n });\n\n child.on('close', exitCode => {\n clearTimeout(timer);\n if (resolved) return;\n resolved = true;\n\n let parsedStdout: HookStdout | undefined;\n if (stdout.trim()) {\n try {\n parsedStdout = JSON.parse(stdout.trim()) as HookStdout;\n } catch {\n // Not valid JSON — ignore\n }\n }\n\n resolve({\n hook,\n exitCode: exitCode ?? 1,\n stdout: parsedStdout,\n stderr: stderr.trim() || undefined,\n timedOut,\n durationMs: Date.now() - startTime,\n });\n });\n\n child.on('error', error => {\n clearTimeout(timer);\n if (resolved) return;\n resolved = true;\n\n resolve({\n hook,\n exitCode: 1,\n stderr: error.message,\n timedOut: false,\n durationMs: Date.now() - startTime,\n });\n });\n\n // A hook that never reads stdin (or exits before we finish writing) closes\n // the pipe under us. That surfaces asynchronously as an EPIPE 'error' event\n // on the socket, which Node escalates to an unhandled error — taking the\n // whole host process down — unless something is listening. The hook's real\n // outcome still arrives via 'close', so absorb it.\n child.stdin?.on('error', () => {});\n\n try {\n child.stdin?.write(JSON.stringify(stdinPayload));\n child.stdin?.end();\n } catch {\n // Synchronous stdin write failure — process continues\n }\n });\n}\n\nexport function matchesHook(hook: HookDefinition, context: { tool_name?: string }): boolean {\n if (!hook.matcher) return true;\n\n if (hook.matcher.tool_name) {\n if (!context.tool_name) return false;\n try {\n return new RegExp(hook.matcher.tool_name).test(context.tool_name);\n } catch {\n return false;\n }\n }\n\n return true;\n}\n\nexport async function runHooksForEvent(\n hooks: HookDefinition[],\n stdinPayload: HookStdin,\n matchContext: { tool_name?: string } = {},\n): Promise<HookEventResult> {\n const results: HookResult[] = [];\n const warnings: string[] = [];\n let additionalContext: string | undefined;\n\n const applicable = hooks.filter(h => matchesHook(h, matchContext));\n if (applicable.length === 0) {\n return { allowed: true, results: [], warnings: [] };\n }\n\n const blocking = isBlockingEvent(stdinPayload.hook_event_name);\n\n for (const hook of applicable) {\n const result = await executeHook(hook, stdinPayload);\n results.push(result);\n\n if (result.stdout?.additionalContext) {\n additionalContext = additionalContext\n ? `${additionalContext}\\n${result.stdout.additionalContext}`\n : result.stdout.additionalContext;\n }\n\n if (result.timedOut) {\n warnings.push(`Hook timed out after ${hook.timeout ?? DEFAULT_TIMEOUT}ms: ${hook.command}`);\n continue;\n }\n\n if (result.exitCode === 2 && blocking) {\n const reason = result.stdout?.reason || result.stderr || `Blocked by hook: ${hook.description || hook.command}`;\n\n return {\n allowed: false,\n blockReason: reason,\n additionalContext,\n results,\n warnings,\n };\n }\n\n if (result.exitCode === 0) continue;\n\n const warnMsg = result.stderr || `Hook exited with code ${result.exitCode}`;\n warnings.push(`${hook.description || hook.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AAO,QAAQ,UAAU,OAAO,UAAU,oBAAoB,KAAK,eAAe,KAAK;GAKpG;GACA;GACA;EACF;EAGF,IAAI,OAAO,aAAa,GAAG;EAE3B,MAAM,UAAU,OAAO,UAAU,yBAAyB,OAAO;EACjE,SAAS,KAAK,GAAG,KAAK,eAAe,KAAK,QAAQ,IAAI,SAAS;CACjE;CAEA,OAAO;EAAE,SAAS;EAAM;EAAmB;EAAS;CAAS;AAC/D"}
|
package/dist/index.d.ts
CHANGED
|
@@ -108,6 +108,7 @@ export declare function createMastraCodeAgentController(config?: MastraCodeConfi
|
|
|
108
108
|
controller: AgentController<MastraCodeState>;
|
|
109
109
|
storage: MastraCompositeStore;
|
|
110
110
|
storageMaintenance: StorageMaintenance;
|
|
111
|
+
createKnowledgeInspector: (session: Session<MastraCodeState>) => Promise<import("./knowledge-inspector.js").KnowledgeInspector | undefined>;
|
|
111
112
|
observability: Observability;
|
|
112
113
|
memory: import("@mastra/core/types").DynamicArgument<import("@mastra/core/memory").MastraMemory> | (({ requestContext }: {
|
|
113
114
|
requestContext: RequestContext;
|
|
@@ -188,9 +189,12 @@ export declare function wireSessionConcerns(base: Pick<MastraCodeAgentController
|
|
|
188
189
|
*/
|
|
189
190
|
export declare function bootLocalAgentController(config?: MastraCodeConfig): Promise<{
|
|
190
191
|
session: Session<MastraCodeState>;
|
|
192
|
+
knowledgeInspector: import("./knowledge-inspector.js").KnowledgeInspector | undefined;
|
|
193
|
+
knowledgeInspectorUnavailableReason: string | undefined;
|
|
191
194
|
controller: AgentController<MastraCodeState>;
|
|
192
195
|
storage: MastraCompositeStore;
|
|
193
196
|
storageMaintenance: StorageMaintenance;
|
|
197
|
+
createKnowledgeInspector: (session: Session<MastraCodeState>) => Promise<import("./knowledge-inspector.js").KnowledgeInspector | undefined>;
|
|
194
198
|
observability: Observability;
|
|
195
199
|
memory: import("@mastra/core/types").DynamicArgument<import("@mastra/core/memory").MastraMemory> | (({ requestContext }: {
|
|
196
200
|
requestContext: RequestContext;
|
|
@@ -321,6 +325,7 @@ export declare function prepareAgentControllerMount(config?: MastraCodeConfig &
|
|
|
321
325
|
* case: `bootLocalAgentController` (local) or {@link mountAgentControllerOnMastra} (server).
|
|
322
326
|
*/
|
|
323
327
|
export declare const createMastraCode: typeof bootLocalAgentController;
|
|
328
|
+
export * from './knowledge-inspector.js';
|
|
324
329
|
/**
|
|
325
330
|
* Programmatic headless API. `runMC` runs an already-built controller/session
|
|
326
331
|
* (from {@link createMastraCode}) as an async-iterable run that also resolves to
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EAErB,mBAAmB,EACnB,uBAAuB,EAEvB,OAAO,EACR,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAS7C,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAmB,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EACL,aAAa,EAId,MAAM,uBAAuB,CAAC;AAM/B,OAAO,EAA+D,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAc9G,OAAO,KAAK,EAAE,gBAAgB,E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W,EACX,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,aAAa,EACb,eAAe,EACf,UAAU,EACV,kBAAkB,EAClB,KAAK,EACL,gBAAgB,EAChB,cAAc,GACf,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import { createEfficiencyScorer } from "./evals/scorers/efficiency.js";
|
|
|
23
23
|
import "./evals/scorers/index.js";
|
|
24
24
|
import { HookManager } from "./hooks/manager.js";
|
|
25
25
|
import "./hooks/index.js";
|
|
26
|
+
import { KnowledgeInspectorError, createKnowledgeInspector } from "./knowledge-inspector.js";
|
|
26
27
|
import { createMcpManager } from "./mcp/manager.js";
|
|
27
28
|
import "./mcp/index.js";
|
|
28
29
|
import { hasExplicitOMConfiguration } from "./onboarding/om-settings.js";
|
|
@@ -634,6 +635,10 @@ async function createMastraCodeAgentController(config) {
|
|
|
634
635
|
controller,
|
|
635
636
|
storage,
|
|
636
637
|
storageMaintenance,
|
|
638
|
+
createKnowledgeInspector: (session) => createKnowledgeInspector({
|
|
639
|
+
storage,
|
|
640
|
+
session
|
|
641
|
+
}),
|
|
637
642
|
observability,
|
|
638
643
|
memory,
|
|
639
644
|
mcpManager,
|
|
@@ -770,9 +775,12 @@ async function bootLocalAgentController(config) {
|
|
|
770
775
|
ownerId
|
|
771
776
|
});
|
|
772
777
|
await wireSessionConcerns(base, session);
|
|
778
|
+
const knowledgeInspector = await base.createKnowledgeInspector(session);
|
|
773
779
|
return {
|
|
774
780
|
...base,
|
|
775
|
-
session
|
|
781
|
+
session,
|
|
782
|
+
knowledgeInspector,
|
|
783
|
+
knowledgeInspectorUnavailableReason: knowledgeInspector ? void 0 : "Knowledge inspection requires a configured knowledge storage domain."
|
|
776
784
|
};
|
|
777
785
|
}
|
|
778
786
|
/**
|
|
@@ -869,6 +877,6 @@ async function prepareAgentControllerMount(config) {
|
|
|
869
877
|
*/
|
|
870
878
|
const createMastraCode = bootLocalAgentController;
|
|
871
879
|
//#endregion
|
|
872
|
-
export { autoApprovePolicy, bootLocalAgentController, createAuthStorage, createMastraCode, createMastraCodeAgentController, denyPolicy, formatHuman, formatJsonl, hasHeadlessFlag, mountAgentControllerOnMastra, permissionModeToPolicy, prepareAgentControllerMount, renderJsonResult, renderTextResult, runMC, runMCCli, wireSessionConcerns };
|
|
880
|
+
export { KnowledgeInspectorError, autoApprovePolicy, bootLocalAgentController, createAuthStorage, createKnowledgeInspector, createMastraCode, createMastraCodeAgentController, denyPolicy, formatHuman, formatJsonl, hasHeadlessFlag, mountAgentControllerOnMastra, permissionModeToPolicy, prepareAgentControllerMount, renderJsonResult, renderTextResult, runMC, runMCCli, wireSessionConcerns };
|
|
873
881
|
|
|
874
882
|
//# sourceMappingURL=index.js.map
|