@mastra/hono 0.0.0-fix-ai-sdk-dependency-20251124104209 → 0.0.0-fix-issue-10434-concurrent-write-corruption-20251124213939

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @mastra/pg
2
2
 
3
- ## 0.0.0-fix-ai-sdk-dependency-20251124104209
3
+ ## 0.0.0-fix-issue-10434-concurrent-write-corruption-20251124213939
4
4
 
5
5
  ### Patch Changes
6
6
 
@@ -12,9 +12,9 @@
12
12
  These packages support mastra server routes on express and hono respectively.
13
13
  Better abstractions will be built on top of these packages in the near future, enabling users to easily attach mastra routes to any existing server framework.
14
14
 
15
- - Updated dependencies [[`2319326`](https://github.com/mastra-ai/mastra/commit/2319326f8c64e503a09bbcf14be2dd65405445e0), [`39c9743`](https://github.com/mastra-ai/mastra/commit/39c97432d084294f8ba85fbf3ef28098ff21459e), [`f743dbb`](https://github.com/mastra-ai/mastra/commit/f743dbb8b40d1627b5c10c0e6fc154f4ebb6e394), [`3852192`](https://github.com/mastra-ai/mastra/commit/3852192c81b2a4f1f883f17d80ce50e0c60dba55), [`fec5129`](https://github.com/mastra-ai/mastra/commit/fec5129de7fc64423ea03661a56cef31dc747a0d), [`60937c1`](https://github.com/mastra-ai/mastra/commit/60937c14d7ff287b0acd16deb15f5e96516d7880), [`0491e7c`](https://github.com/mastra-ai/mastra/commit/0491e7c9b714cb0ba22187ee062147ec2dd7c712), [`f6f4903`](https://github.com/mastra-ai/mastra/commit/f6f4903397314f73362061dc5a3e8e7c61ea34aa), [`0e8ed46`](https://github.com/mastra-ai/mastra/commit/0e8ed467c54d6901a6a365f270ec15d6faadb36c), [`6c049d9`](https://github.com/mastra-ai/mastra/commit/6c049d94063fdcbd5b81c4912a2bf82a92c9cc0b), [`910db9e`](https://github.com/mastra-ai/mastra/commit/910db9e0312888495eb5617b567f247d03303814), [`2f897df`](https://github.com/mastra-ai/mastra/commit/2f897df208508f46f51b7625e5dd20c37f93e0e3), [`d3e89dd`](https://github.com/mastra-ai/mastra/commit/d3e89dd4fc31ae2804c4c7bd3e98113d069cf780), [`d629361`](https://github.com/mastra-ai/mastra/commit/d629361a60f6565b5bfb11976fdaf7308af858e2), [`08c31c1`](https://github.com/mastra-ai/mastra/commit/08c31c188ebccd598acaf55e888b6397d01f7eae), [`f0f8f12`](https://github.com/mastra-ai/mastra/commit/f0f8f125c308f2d0fd36942ef652fd852df7522f), [`3443770`](https://github.com/mastra-ai/mastra/commit/3443770662df8eb24c9df3589b2792d78cfcb811), [`f0a07e0`](https://github.com/mastra-ai/mastra/commit/f0a07e0111b3307c5fabfa4094c5c2cfb734fbe6), [`aaa40e7`](https://github.com/mastra-ai/mastra/commit/aaa40e788628b319baa8e889407d11ad626547fa), [`1521d71`](https://github.com/mastra-ai/mastra/commit/1521d716e5daedc74690c983fbd961123c56756b), [`9e1911d`](https://github.com/mastra-ai/mastra/commit/9e1911db2b4db85e0e768c3f15e0d61e319869f6), [`c456e01`](https://github.com/mastra-ai/mastra/commit/c456e0149e3c176afcefdbd9bb1d2c5917723725), [`ebac155`](https://github.com/mastra-ai/mastra/commit/ebac15564a590117db7078233f927a7e28a85106), [`dd1c38d`](https://github.com/mastra-ai/mastra/commit/dd1c38d1b75f1b695c27b40d8d9d6ed00d5e0f6f), [`5948e6a`](https://github.com/mastra-ai/mastra/commit/5948e6a5146c83666ba3f294b2be576c82a513fb), [`8940859`](https://github.com/mastra-ai/mastra/commit/89408593658199b4ad67f7b65e888f344e64a442), [`ffd8f1b`](https://github.com/mastra-ai/mastra/commit/ffd8f1b904181c68fcbf5a1974e2b96a9303b042), [`e629310`](https://github.com/mastra-ai/mastra/commit/e629310f1a73fa236d49ec7a1d1cceb6229dc7cc), [`844ea5d`](https://github.com/mastra-ai/mastra/commit/844ea5dc0c248961e7bf73629ae7dcff503e853c), [`5df9cce`](https://github.com/mastra-ai/mastra/commit/5df9cce1a753438413f64c11eeef8f845745c2a8), [`4c6b492`](https://github.com/mastra-ai/mastra/commit/4c6b492c4dd591c6a592520c1f6855d6e936d71f), [`dff01d8`](https://github.com/mastra-ai/mastra/commit/dff01d81ce1f4e4087cfac20fa868e6db138dd14), [`9d819d5`](https://github.com/mastra-ai/mastra/commit/9d819d54b61481639f4008e4694791bddf187edd), [`b7de533`](https://github.com/mastra-ai/mastra/commit/b7de53361667eb51fefd89fcaed924f3c57cee8d), [`f15fb34`](https://github.com/mastra-ai/mastra/commit/f15fb347b76581ef91a16770bc21e2d50dbe3864), [`fd3d338`](https://github.com/mastra-ai/mastra/commit/fd3d338a2c362174ed5b383f1f011ad9fb0302aa), [`71c8d6c`](https://github.com/mastra-ai/mastra/commit/71c8d6c161253207b2b9588bdadb7eed604f7253), [`6179a9b`](https://github.com/mastra-ai/mastra/commit/6179a9ba36ffac326de3cc3c43cdc8028d37c251), [`c30400a`](https://github.com/mastra-ai/mastra/commit/c30400a49b994b1b97256fe785eb6c906fc2b232), [`00f4921`](https://github.com/mastra-ai/mastra/commit/00f4921dd2c91a1e5446799599ef7116a8214a1a), [`70189fc`](https://github.com/mastra-ai/mastra/commit/70189fc9611c3be54e5e655910b672b21ddefb94), [`ca8041c`](https://github.com/mastra-ai/mastra/commit/ca8041cce0379fda22ed293a565bcb5b6ddca68a), [`7051bf3`](https://github.com/mastra-ai/mastra/commit/7051bf38b3b122a069008f861f7bfc004a6d9f6e), [`a8f1494`](https://github.com/mastra-ai/mastra/commit/a8f1494f4bbdc2770bcf327d4c7d869e332183f1), [`69e0a87`](https://github.com/mastra-ai/mastra/commit/69e0a878896a2da9494945d86e056a5f8f05b851), [`352a5d6`](https://github.com/mastra-ai/mastra/commit/352a5d625cfe09849b21e8f52a24c9f0366759d5), [`0793497`](https://github.com/mastra-ai/mastra/commit/079349753620c40246ffd673e3f9d7d9820beff3), [`a97003a`](https://github.com/mastra-ai/mastra/commit/a97003aa1cf2f4022a41912324a1e77263b326b8), [`01f8878`](https://github.com/mastra-ai/mastra/commit/01f88783de25e4de048c1c8aace43e26373c6ea5), [`5df9cce`](https://github.com/mastra-ai/mastra/commit/5df9cce1a753438413f64c11eeef8f845745c2a8), [`4c77209`](https://github.com/mastra-ai/mastra/commit/4c77209e6c11678808b365d545845918c40045c8), [`a854ede`](https://github.com/mastra-ai/mastra/commit/a854ede62bf5ac0945a624ac48913dd69c73aabf), [`c576fc0`](https://github.com/mastra-ai/mastra/commit/c576fc0b100b2085afded91a37c97a0ea0ec09c7), [`8e85939`](https://github.com/mastra-ai/mastra/commit/8e859393c1cda6ff3d11618ac1150ca6f68175b6), [`3defc80`](https://github.com/mastra-ai/mastra/commit/3defc80cf2b88a1b7fc1cc4ddcb91e982a614609), [`00123ba`](https://github.com/mastra-ai/mastra/commit/00123ba96dc9e5cd0b110420ebdba56d8f237b25), [`16153fe`](https://github.com/mastra-ai/mastra/commit/16153fe7eb13c99401f48e6ca32707c965ee28b9), [`9f4a683`](https://github.com/mastra-ai/mastra/commit/9f4a6833e88b52574665c028fd5508ad5c2f6004), [`bc94344`](https://github.com/mastra-ai/mastra/commit/bc943444a1342d8a662151b7bce1df7dae32f59c), [`57d157f`](https://github.com/mastra-ai/mastra/commit/57d157f0b163a95c3e6c9eae31bdb11d1bfc64f9), [`903f67d`](https://github.com/mastra-ai/mastra/commit/903f67d184504a273893818c02b961f5423a79ad), [`d827d08`](https://github.com/mastra-ai/mastra/commit/d827d0808ffe1f3553a84e975806cc989b9735dd), [`2a90c55`](https://github.com/mastra-ai/mastra/commit/2a90c55a86a9210697d5adaab5ee94584b079adc), [`4c6b492`](https://github.com/mastra-ai/mastra/commit/4c6b492c4dd591c6a592520c1f6855d6e936d71f), [`eb09742`](https://github.com/mastra-ai/mastra/commit/eb09742197f66c4c38154c3beec78313e69760b2), [`ebac155`](https://github.com/mastra-ai/mastra/commit/ebac15564a590117db7078233f927a7e28a85106), [`23c10a1`](https://github.com/mastra-ai/mastra/commit/23c10a1efdd9a693c405511ab2dc8a1236603162), [`96d35f6`](https://github.com/mastra-ai/mastra/commit/96d35f61376bc2b1bf148648a2c1985bd51bef55), [`5cbe88a`](https://github.com/mastra-ai/mastra/commit/5cbe88aefbd9f933bca669fd371ea36bf939ac6d), [`a1bd7b8`](https://github.com/mastra-ai/mastra/commit/a1bd7b8571db16b94eb01588f451a74758c96d65), [`d78b38d`](https://github.com/mastra-ai/mastra/commit/d78b38d898fce285260d3bbb4befade54331617f), [`a0a5b4b`](https://github.com/mastra-ai/mastra/commit/a0a5b4bbebe6c701ebbadf744873aa0d5ca01371), [`0633100`](https://github.com/mastra-ai/mastra/commit/0633100a911ad22f5256471bdf753da21c104742), [`c710c16`](https://github.com/mastra-ai/mastra/commit/c710c1652dccfdc4111c8412bca7a6bb1d48b441), [`354ad0b`](https://github.com/mastra-ai/mastra/commit/354ad0b7b1b8183ac567f236a884fc7ede6d7138), [`cfae733`](https://github.com/mastra-ai/mastra/commit/cfae73394f4920635e6c919c8e95ff9a0788e2e5), [`e3dfda7`](https://github.com/mastra-ai/mastra/commit/e3dfda7b11bf3b8c4bb55637028befb5f387fc74), [`69ea758`](https://github.com/mastra-ai/mastra/commit/69ea758358edd7117f191c2e69c8bb5fc79e7a1a), [`651e772`](https://github.com/mastra-ai/mastra/commit/651e772eb1475fb13e126d3fcc01751297a88214), [`993ad98`](https://github.com/mastra-ai/mastra/commit/993ad98d7ad3bebda9ecef5fec5c94349a0d04bc), [`676ccc7`](https://github.com/mastra-ai/mastra/commit/676ccc7fe92468d2d45d39c31a87825c89fd1ea0), [`3ff2c17`](https://github.com/mastra-ai/mastra/commit/3ff2c17a58e312fad5ea37377262c12d92ca0908), [`844ea5d`](https://github.com/mastra-ai/mastra/commit/844ea5dc0c248961e7bf73629ae7dcff503e853c), [`398fde3`](https://github.com/mastra-ai/mastra/commit/398fde3f39e707cda79372cdae8f9870e3b57c8d), [`c10398d`](https://github.com/mastra-ai/mastra/commit/c10398d5b88f1d4af556f4267ff06f1d11e89179), [`f0f8f12`](https://github.com/mastra-ai/mastra/commit/f0f8f125c308f2d0fd36942ef652fd852df7522f), [`b61b93f`](https://github.com/mastra-ai/mastra/commit/b61b93f9e058b11dd2eec169853175d31dbdd567), [`0d7618b`](https://github.com/mastra-ai/mastra/commit/0d7618bc650bf2800934b243eca5648f4aeed9c2), [`7b763e5`](https://github.com/mastra-ai/mastra/commit/7b763e52fc3eaf699c2a99f2adf418dd46e4e9a5), [`d36cfbb`](https://github.com/mastra-ai/mastra/commit/d36cfbbb6565ba5f827883cc9bb648eb14befdc1), [`c63fbba`](https://github.com/mastra-ai/mastra/commit/c63fbba1afdd61a01a994b7a69e52c9881baeaeb), [`3697853`](https://github.com/mastra-ai/mastra/commit/3697853deeb72017d90e0f38a93c1e29221aeca0), [`c23200d`](https://github.com/mastra-ai/mastra/commit/c23200ddfd60830effb39329674ba4ca93be6aac), [`b2e45ec`](https://github.com/mastra-ai/mastra/commit/b2e45eca727a8db01a81ba93f1a5219c7183c839), [`d6d49f7`](https://github.com/mastra-ai/mastra/commit/d6d49f7b8714fa19a52ff9c7cf7fb7e73751901e), [`00c2387`](https://github.com/mastra-ai/mastra/commit/00c2387f5f04a365316f851e58666ac43f8c4edf), [`a534e95`](https://github.com/mastra-ai/mastra/commit/a534e9591f83b3cc1ebff99c67edf4cda7bf81d3), [`9d0e7fe`](https://github.com/mastra-ai/mastra/commit/9d0e7feca8ed98de959f53476ee1456073673348), [`53d927c`](https://github.com/mastra-ai/mastra/commit/53d927cc6f03bff33655b7e2b788da445a08731d), [`ad6250d`](https://github.com/mastra-ai/mastra/commit/ad6250dbdaad927e29f74a27b83f6c468b50a705), [`3f2faf2`](https://github.com/mastra-ai/mastra/commit/3f2faf2e2d685d6c053cc5af1bf9fedf267b2ce5), [`22f64bc`](https://github.com/mastra-ai/mastra/commit/22f64bc1d37149480b58bf2fefe35b79a1e3e7d5), [`363284b`](https://github.com/mastra-ai/mastra/commit/363284bb974e850f06f40f89a28c79d9f432d7e4), [`3a73998`](https://github.com/mastra-ai/mastra/commit/3a73998fa4ebeb7f3dc9301afe78095fc63e7999), [`83d5942`](https://github.com/mastra-ai/mastra/commit/83d5942669ce7bba4a6ca4fd4da697a10eb5ebdc), [`b7959e6`](https://github.com/mastra-ai/mastra/commit/b7959e6e25a46b480f9ea2217c4c6c588c423791), [`bda6370`](https://github.com/mastra-ai/mastra/commit/bda637009360649aaf579919e7873e33553c273e), [`c218bd3`](https://github.com/mastra-ai/mastra/commit/c218bd3759e32423735b04843a09404572631014), [`d7acd8e`](https://github.com/mastra-ai/mastra/commit/d7acd8e987b5d7eff4fd98b0906c17c06a2e83d5), [`c7f1f7d`](https://github.com/mastra-ai/mastra/commit/c7f1f7d24f61f247f018cc2d1f33bf63212959a7), [`0bddc6d`](https://github.com/mastra-ai/mastra/commit/0bddc6d8dbd6f6008c0cba2e4960a2da75a55af1), [`735d8c1`](https://github.com/mastra-ai/mastra/commit/735d8c1c0d19fbc09e6f8b66cf41bc7655993838), [`acf322e`](https://github.com/mastra-ai/mastra/commit/acf322e0f1fd0189684cf529d91c694bea918a45), [`5d7e4dd`](https://github.com/mastra-ai/mastra/commit/5d7e4dd802adcc57d3ac666c2eee044f50c7cee0), [`e16d553`](https://github.com/mastra-ai/mastra/commit/e16d55338403c7553531cc568125c63d53653dff), [`c942802`](https://github.com/mastra-ai/mastra/commit/c942802a477a925b01859a7b8688d4355715caaa), [`a0c8c1b`](https://github.com/mastra-ai/mastra/commit/a0c8c1b87d4fee252aebda73e8637fbe01d761c9), [`cc34739`](https://github.com/mastra-ai/mastra/commit/cc34739c34b6266a91bea561119240a7acf47887), [`c218bd3`](https://github.com/mastra-ai/mastra/commit/c218bd3759e32423735b04843a09404572631014), [`9e67002`](https://github.com/mastra-ai/mastra/commit/9e67002b52c9be19936c420a489dbee9c5fd6a78), [`2c4438b`](https://github.com/mastra-ai/mastra/commit/2c4438b87817ab7eed818c7990fef010475af1a3), [`35edc49`](https://github.com/mastra-ai/mastra/commit/35edc49ac0556db609189641d6341e76771b81fc), [`4d59f58`](https://github.com/mastra-ai/mastra/commit/4d59f58de2d90d6e2810a19d4518e38ddddb9038), [`2b8893c`](https://github.com/mastra-ai/mastra/commit/2b8893cb108ef9acb72ee7835cd625610d2c1a4a), [`8e5c75b`](https://github.com/mastra-ai/mastra/commit/8e5c75bdb1d08a42d45309a4c72def4b6890230f), [`e1bb9c9`](https://github.com/mastra-ai/mastra/commit/e1bb9c94b4eb68b019ae275981be3feb769b5365), [`351a11f`](https://github.com/mastra-ai/mastra/commit/351a11fcaf2ed1008977fa9b9a489fc422e51cd4), [`e59e0d3`](https://github.com/mastra-ai/mastra/commit/e59e0d32afb5fcf2c9f3c00c8f81f6c21d3a63fa), [`465ac05`](https://github.com/mastra-ai/mastra/commit/465ac0526a91d175542091c675181f1a96c98c46), [`fa8409b`](https://github.com/mastra-ai/mastra/commit/fa8409bc39cfd8ba6643b9db5269b90b22e2a2f7), [`e7266a2`](https://github.com/mastra-ai/mastra/commit/e7266a278db02035c97a5e9cd9d1669a6b7a535d), [`173c535`](https://github.com/mastra-ai/mastra/commit/173c535c0645b0da404fe09f003778f0b0d4e019)]:
16
- - @mastra/core@0.0.0-fix-ai-sdk-dependency-20251124104209
17
- - @mastra/server@0.0.0-fix-ai-sdk-dependency-20251124104209
15
+ - Updated dependencies [[`2319326`](https://github.com/mastra-ai/mastra/commit/2319326f8c64e503a09bbcf14be2dd65405445e0), [`39c9743`](https://github.com/mastra-ai/mastra/commit/39c97432d084294f8ba85fbf3ef28098ff21459e), [`f743dbb`](https://github.com/mastra-ai/mastra/commit/f743dbb8b40d1627b5c10c0e6fc154f4ebb6e394), [`3852192`](https://github.com/mastra-ai/mastra/commit/3852192c81b2a4f1f883f17d80ce50e0c60dba55), [`fec5129`](https://github.com/mastra-ai/mastra/commit/fec5129de7fc64423ea03661a56cef31dc747a0d), [`60937c1`](https://github.com/mastra-ai/mastra/commit/60937c14d7ff287b0acd16deb15f5e96516d7880), [`0491e7c`](https://github.com/mastra-ai/mastra/commit/0491e7c9b714cb0ba22187ee062147ec2dd7c712), [`f6f4903`](https://github.com/mastra-ai/mastra/commit/f6f4903397314f73362061dc5a3e8e7c61ea34aa), [`0e8ed46`](https://github.com/mastra-ai/mastra/commit/0e8ed467c54d6901a6a365f270ec15d6faadb36c), [`6c049d9`](https://github.com/mastra-ai/mastra/commit/6c049d94063fdcbd5b81c4912a2bf82a92c9cc0b), [`910db9e`](https://github.com/mastra-ai/mastra/commit/910db9e0312888495eb5617b567f247d03303814), [`2f897df`](https://github.com/mastra-ai/mastra/commit/2f897df208508f46f51b7625e5dd20c37f93e0e3), [`d3e89dd`](https://github.com/mastra-ai/mastra/commit/d3e89dd4fc31ae2804c4c7bd3e98113d069cf780), [`d629361`](https://github.com/mastra-ai/mastra/commit/d629361a60f6565b5bfb11976fdaf7308af858e2), [`feb7ee4`](https://github.com/mastra-ai/mastra/commit/feb7ee4d09a75edb46c6669a3beaceec78811747), [`08c31c1`](https://github.com/mastra-ai/mastra/commit/08c31c188ebccd598acaf55e888b6397d01f7eae), [`f0f8f12`](https://github.com/mastra-ai/mastra/commit/f0f8f125c308f2d0fd36942ef652fd852df7522f), [`3443770`](https://github.com/mastra-ai/mastra/commit/3443770662df8eb24c9df3589b2792d78cfcb811), [`f0a07e0`](https://github.com/mastra-ai/mastra/commit/f0a07e0111b3307c5fabfa4094c5c2cfb734fbe6), [`aaa40e7`](https://github.com/mastra-ai/mastra/commit/aaa40e788628b319baa8e889407d11ad626547fa), [`1521d71`](https://github.com/mastra-ai/mastra/commit/1521d716e5daedc74690c983fbd961123c56756b), [`9e1911d`](https://github.com/mastra-ai/mastra/commit/9e1911db2b4db85e0e768c3f15e0d61e319869f6), [`c456e01`](https://github.com/mastra-ai/mastra/commit/c456e0149e3c176afcefdbd9bb1d2c5917723725), [`ebac155`](https://github.com/mastra-ai/mastra/commit/ebac15564a590117db7078233f927a7e28a85106), [`dd1c38d`](https://github.com/mastra-ai/mastra/commit/dd1c38d1b75f1b695c27b40d8d9d6ed00d5e0f6f), [`5948e6a`](https://github.com/mastra-ai/mastra/commit/5948e6a5146c83666ba3f294b2be576c82a513fb), [`8940859`](https://github.com/mastra-ai/mastra/commit/89408593658199b4ad67f7b65e888f344e64a442), [`ffd8f1b`](https://github.com/mastra-ai/mastra/commit/ffd8f1b904181c68fcbf5a1974e2b96a9303b042), [`e629310`](https://github.com/mastra-ai/mastra/commit/e629310f1a73fa236d49ec7a1d1cceb6229dc7cc), [`844ea5d`](https://github.com/mastra-ai/mastra/commit/844ea5dc0c248961e7bf73629ae7dcff503e853c), [`5df9cce`](https://github.com/mastra-ai/mastra/commit/5df9cce1a753438413f64c11eeef8f845745c2a8), [`4c6b492`](https://github.com/mastra-ai/mastra/commit/4c6b492c4dd591c6a592520c1f6855d6e936d71f), [`dff01d8`](https://github.com/mastra-ai/mastra/commit/dff01d81ce1f4e4087cfac20fa868e6db138dd14), [`9d819d5`](https://github.com/mastra-ai/mastra/commit/9d819d54b61481639f4008e4694791bddf187edd), [`b7de533`](https://github.com/mastra-ai/mastra/commit/b7de53361667eb51fefd89fcaed924f3c57cee8d), [`f15fb34`](https://github.com/mastra-ai/mastra/commit/f15fb347b76581ef91a16770bc21e2d50dbe3864), [`fd3d338`](https://github.com/mastra-ai/mastra/commit/fd3d338a2c362174ed5b383f1f011ad9fb0302aa), [`71c8d6c`](https://github.com/mastra-ai/mastra/commit/71c8d6c161253207b2b9588bdadb7eed604f7253), [`6179a9b`](https://github.com/mastra-ai/mastra/commit/6179a9ba36ffac326de3cc3c43cdc8028d37c251), [`c30400a`](https://github.com/mastra-ai/mastra/commit/c30400a49b994b1b97256fe785eb6c906fc2b232), [`00f4921`](https://github.com/mastra-ai/mastra/commit/00f4921dd2c91a1e5446799599ef7116a8214a1a), [`70189fc`](https://github.com/mastra-ai/mastra/commit/70189fc9611c3be54e5e655910b672b21ddefb94), [`ca8041c`](https://github.com/mastra-ai/mastra/commit/ca8041cce0379fda22ed293a565bcb5b6ddca68a), [`7051bf3`](https://github.com/mastra-ai/mastra/commit/7051bf38b3b122a069008f861f7bfc004a6d9f6e), [`a8f1494`](https://github.com/mastra-ai/mastra/commit/a8f1494f4bbdc2770bcf327d4c7d869e332183f1), [`69e0a87`](https://github.com/mastra-ai/mastra/commit/69e0a878896a2da9494945d86e056a5f8f05b851), [`352a5d6`](https://github.com/mastra-ai/mastra/commit/352a5d625cfe09849b21e8f52a24c9f0366759d5), [`898a972`](https://github.com/mastra-ai/mastra/commit/898a9727d286c2510d6b702dfd367e6aaf5c6b0f), [`0793497`](https://github.com/mastra-ai/mastra/commit/079349753620c40246ffd673e3f9d7d9820beff3), [`a97003a`](https://github.com/mastra-ai/mastra/commit/a97003aa1cf2f4022a41912324a1e77263b326b8), [`01f8878`](https://github.com/mastra-ai/mastra/commit/01f88783de25e4de048c1c8aace43e26373c6ea5), [`5df9cce`](https://github.com/mastra-ai/mastra/commit/5df9cce1a753438413f64c11eeef8f845745c2a8), [`4c77209`](https://github.com/mastra-ai/mastra/commit/4c77209e6c11678808b365d545845918c40045c8), [`a854ede`](https://github.com/mastra-ai/mastra/commit/a854ede62bf5ac0945a624ac48913dd69c73aabf), [`c576fc0`](https://github.com/mastra-ai/mastra/commit/c576fc0b100b2085afded91a37c97a0ea0ec09c7), [`8e85939`](https://github.com/mastra-ai/mastra/commit/8e859393c1cda6ff3d11618ac1150ca6f68175b6), [`3defc80`](https://github.com/mastra-ai/mastra/commit/3defc80cf2b88a1b7fc1cc4ddcb91e982a614609), [`00123ba`](https://github.com/mastra-ai/mastra/commit/00123ba96dc9e5cd0b110420ebdba56d8f237b25), [`16153fe`](https://github.com/mastra-ai/mastra/commit/16153fe7eb13c99401f48e6ca32707c965ee28b9), [`9f4a683`](https://github.com/mastra-ai/mastra/commit/9f4a6833e88b52574665c028fd5508ad5c2f6004), [`bc94344`](https://github.com/mastra-ai/mastra/commit/bc943444a1342d8a662151b7bce1df7dae32f59c), [`57d157f`](https://github.com/mastra-ai/mastra/commit/57d157f0b163a95c3e6c9eae31bdb11d1bfc64f9), [`903f67d`](https://github.com/mastra-ai/mastra/commit/903f67d184504a273893818c02b961f5423a79ad), [`d827d08`](https://github.com/mastra-ai/mastra/commit/d827d0808ffe1f3553a84e975806cc989b9735dd), [`2a90c55`](https://github.com/mastra-ai/mastra/commit/2a90c55a86a9210697d5adaab5ee94584b079adc), [`4c6b492`](https://github.com/mastra-ai/mastra/commit/4c6b492c4dd591c6a592520c1f6855d6e936d71f), [`eb09742`](https://github.com/mastra-ai/mastra/commit/eb09742197f66c4c38154c3beec78313e69760b2), [`ebac155`](https://github.com/mastra-ai/mastra/commit/ebac15564a590117db7078233f927a7e28a85106), [`23c10a1`](https://github.com/mastra-ai/mastra/commit/23c10a1efdd9a693c405511ab2dc8a1236603162), [`96d35f6`](https://github.com/mastra-ai/mastra/commit/96d35f61376bc2b1bf148648a2c1985bd51bef55), [`5cbe88a`](https://github.com/mastra-ai/mastra/commit/5cbe88aefbd9f933bca669fd371ea36bf939ac6d), [`a1bd7b8`](https://github.com/mastra-ai/mastra/commit/a1bd7b8571db16b94eb01588f451a74758c96d65), [`d78b38d`](https://github.com/mastra-ai/mastra/commit/d78b38d898fce285260d3bbb4befade54331617f), [`a0a5b4b`](https://github.com/mastra-ai/mastra/commit/a0a5b4bbebe6c701ebbadf744873aa0d5ca01371), [`0633100`](https://github.com/mastra-ai/mastra/commit/0633100a911ad22f5256471bdf753da21c104742), [`c710c16`](https://github.com/mastra-ai/mastra/commit/c710c1652dccfdc4111c8412bca7a6bb1d48b441), [`354ad0b`](https://github.com/mastra-ai/mastra/commit/354ad0b7b1b8183ac567f236a884fc7ede6d7138), [`cfae733`](https://github.com/mastra-ai/mastra/commit/cfae73394f4920635e6c919c8e95ff9a0788e2e5), [`e3dfda7`](https://github.com/mastra-ai/mastra/commit/e3dfda7b11bf3b8c4bb55637028befb5f387fc74), [`69ea758`](https://github.com/mastra-ai/mastra/commit/69ea758358edd7117f191c2e69c8bb5fc79e7a1a), [`651e772`](https://github.com/mastra-ai/mastra/commit/651e772eb1475fb13e126d3fcc01751297a88214), [`993ad98`](https://github.com/mastra-ai/mastra/commit/993ad98d7ad3bebda9ecef5fec5c94349a0d04bc), [`676ccc7`](https://github.com/mastra-ai/mastra/commit/676ccc7fe92468d2d45d39c31a87825c89fd1ea0), [`3ff2c17`](https://github.com/mastra-ai/mastra/commit/3ff2c17a58e312fad5ea37377262c12d92ca0908), [`844ea5d`](https://github.com/mastra-ai/mastra/commit/844ea5dc0c248961e7bf73629ae7dcff503e853c), [`398fde3`](https://github.com/mastra-ai/mastra/commit/398fde3f39e707cda79372cdae8f9870e3b57c8d), [`c10398d`](https://github.com/mastra-ai/mastra/commit/c10398d5b88f1d4af556f4267ff06f1d11e89179), [`f0f8f12`](https://github.com/mastra-ai/mastra/commit/f0f8f125c308f2d0fd36942ef652fd852df7522f), [`b61b93f`](https://github.com/mastra-ai/mastra/commit/b61b93f9e058b11dd2eec169853175d31dbdd567), [`bae33d9`](https://github.com/mastra-ai/mastra/commit/bae33d91a63fbb64d1e80519e1fc1acaed1e9013), [`0d7618b`](https://github.com/mastra-ai/mastra/commit/0d7618bc650bf2800934b243eca5648f4aeed9c2), [`7b763e5`](https://github.com/mastra-ai/mastra/commit/7b763e52fc3eaf699c2a99f2adf418dd46e4e9a5), [`d36cfbb`](https://github.com/mastra-ai/mastra/commit/d36cfbbb6565ba5f827883cc9bb648eb14befdc1), [`c63fbba`](https://github.com/mastra-ai/mastra/commit/c63fbba1afdd61a01a994b7a69e52c9881baeaeb), [`3697853`](https://github.com/mastra-ai/mastra/commit/3697853deeb72017d90e0f38a93c1e29221aeca0), [`c23200d`](https://github.com/mastra-ai/mastra/commit/c23200ddfd60830effb39329674ba4ca93be6aac), [`b2e45ec`](https://github.com/mastra-ai/mastra/commit/b2e45eca727a8db01a81ba93f1a5219c7183c839), [`43ca8f2`](https://github.com/mastra-ai/mastra/commit/43ca8f2c7334851cc7b4d3d2f037d8784bfbdd5f), [`d6d49f7`](https://github.com/mastra-ai/mastra/commit/d6d49f7b8714fa19a52ff9c7cf7fb7e73751901e), [`00c2387`](https://github.com/mastra-ai/mastra/commit/00c2387f5f04a365316f851e58666ac43f8c4edf), [`a534e95`](https://github.com/mastra-ai/mastra/commit/a534e9591f83b3cc1ebff99c67edf4cda7bf81d3), [`9d0e7fe`](https://github.com/mastra-ai/mastra/commit/9d0e7feca8ed98de959f53476ee1456073673348), [`53d927c`](https://github.com/mastra-ai/mastra/commit/53d927cc6f03bff33655b7e2b788da445a08731d), [`ad6250d`](https://github.com/mastra-ai/mastra/commit/ad6250dbdaad927e29f74a27b83f6c468b50a705), [`3f2faf2`](https://github.com/mastra-ai/mastra/commit/3f2faf2e2d685d6c053cc5af1bf9fedf267b2ce5), [`22f64bc`](https://github.com/mastra-ai/mastra/commit/22f64bc1d37149480b58bf2fefe35b79a1e3e7d5), [`363284b`](https://github.com/mastra-ai/mastra/commit/363284bb974e850f06f40f89a28c79d9f432d7e4), [`3a73998`](https://github.com/mastra-ai/mastra/commit/3a73998fa4ebeb7f3dc9301afe78095fc63e7999), [`83d5942`](https://github.com/mastra-ai/mastra/commit/83d5942669ce7bba4a6ca4fd4da697a10eb5ebdc), [`b7959e6`](https://github.com/mastra-ai/mastra/commit/b7959e6e25a46b480f9ea2217c4c6c588c423791), [`bda6370`](https://github.com/mastra-ai/mastra/commit/bda637009360649aaf579919e7873e33553c273e), [`c218bd3`](https://github.com/mastra-ai/mastra/commit/c218bd3759e32423735b04843a09404572631014), [`d7acd8e`](https://github.com/mastra-ai/mastra/commit/d7acd8e987b5d7eff4fd98b0906c17c06a2e83d5), [`c7f1f7d`](https://github.com/mastra-ai/mastra/commit/c7f1f7d24f61f247f018cc2d1f33bf63212959a7), [`0bddc6d`](https://github.com/mastra-ai/mastra/commit/0bddc6d8dbd6f6008c0cba2e4960a2da75a55af1), [`735d8c1`](https://github.com/mastra-ai/mastra/commit/735d8c1c0d19fbc09e6f8b66cf41bc7655993838), [`acf322e`](https://github.com/mastra-ai/mastra/commit/acf322e0f1fd0189684cf529d91c694bea918a45), [`2ca67cc`](https://github.com/mastra-ai/mastra/commit/2ca67cc3bb1f6a617353fdcab197d9efebe60d6f), [`5d7e4dd`](https://github.com/mastra-ai/mastra/commit/5d7e4dd802adcc57d3ac666c2eee044f50c7cee0), [`e16d553`](https://github.com/mastra-ai/mastra/commit/e16d55338403c7553531cc568125c63d53653dff), [`c942802`](https://github.com/mastra-ai/mastra/commit/c942802a477a925b01859a7b8688d4355715caaa), [`a0c8c1b`](https://github.com/mastra-ai/mastra/commit/a0c8c1b87d4fee252aebda73e8637fbe01d761c9), [`cc34739`](https://github.com/mastra-ai/mastra/commit/cc34739c34b6266a91bea561119240a7acf47887), [`c218bd3`](https://github.com/mastra-ai/mastra/commit/c218bd3759e32423735b04843a09404572631014), [`9e67002`](https://github.com/mastra-ai/mastra/commit/9e67002b52c9be19936c420a489dbee9c5fd6a78), [`2c4438b`](https://github.com/mastra-ai/mastra/commit/2c4438b87817ab7eed818c7990fef010475af1a3), [`35edc49`](https://github.com/mastra-ai/mastra/commit/35edc49ac0556db609189641d6341e76771b81fc), [`4d59f58`](https://github.com/mastra-ai/mastra/commit/4d59f58de2d90d6e2810a19d4518e38ddddb9038), [`2b8893c`](https://github.com/mastra-ai/mastra/commit/2b8893cb108ef9acb72ee7835cd625610d2c1a4a), [`8e5c75b`](https://github.com/mastra-ai/mastra/commit/8e5c75bdb1d08a42d45309a4c72def4b6890230f), [`e1bb9c9`](https://github.com/mastra-ai/mastra/commit/e1bb9c94b4eb68b019ae275981be3feb769b5365), [`351a11f`](https://github.com/mastra-ai/mastra/commit/351a11fcaf2ed1008977fa9b9a489fc422e51cd4), [`e59e0d3`](https://github.com/mastra-ai/mastra/commit/e59e0d32afb5fcf2c9f3c00c8f81f6c21d3a63fa), [`465ac05`](https://github.com/mastra-ai/mastra/commit/465ac0526a91d175542091c675181f1a96c98c46), [`fa8409b`](https://github.com/mastra-ai/mastra/commit/fa8409bc39cfd8ba6643b9db5269b90b22e2a2f7), [`e7266a2`](https://github.com/mastra-ai/mastra/commit/e7266a278db02035c97a5e9cd9d1669a6b7a535d), [`173c535`](https://github.com/mastra-ai/mastra/commit/173c535c0645b0da404fe09f003778f0b0d4e019)]:
16
+ - @mastra/core@0.0.0-fix-issue-10434-concurrent-write-corruption-20251124213939
17
+ - @mastra/server@0.0.0-fix-issue-10434-concurrent-write-corruption-20251124213939
18
18
 
19
19
  ## 0.17.5
20
20
 
package/dist/index.cjs CHANGED
@@ -5,7 +5,7 @@ var serverAdapter = require('@mastra/server/server-adapter');
5
5
 
6
6
  // src/index.ts
7
7
 
8
- // ../../node_modules/.pnpm/hono@4.10.4/node_modules/hono/dist/http-exception.js
8
+ // ../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/http-exception.js
9
9
  var HTTPException = class extends Error {
10
10
  res;
11
11
  status;
@@ -28,7 +28,7 @@ var HTTPException = class extends Error {
28
28
  }
29
29
  };
30
30
 
31
- // ../../node_modules/.pnpm/hono@4.10.4/node_modules/hono/dist/middleware/body-limit/index.js
31
+ // ../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/middleware/body-limit/index.js
32
32
  var ERROR_MESSAGE = "Payload Too Large";
33
33
  var BodyLimitError = class extends Error {
34
34
  constructor(message) {
@@ -85,7 +85,7 @@ var bodyLimit = (options) => {
85
85
  };
86
86
  };
87
87
 
88
- // ../../node_modules/.pnpm/hono@4.10.4/node_modules/hono/dist/utils/stream.js
88
+ // ../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/utils/stream.js
89
89
  var StreamingApi = class {
90
90
  writer;
91
91
  encoder;
@@ -152,7 +152,7 @@ var StreamingApi = class {
152
152
  }
153
153
  };
154
154
 
155
- // ../../node_modules/.pnpm/hono@4.10.4/node_modules/hono/dist/helper/streaming/utils.js
155
+ // ../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/helper/streaming/utils.js
156
156
  var isOldBunVersion = () => {
157
157
  const version = typeof Bun !== "undefined" ? Bun.version : void 0;
158
158
  if (version === void 0) {
@@ -163,7 +163,7 @@ var isOldBunVersion = () => {
163
163
  return result;
164
164
  };
165
165
 
166
- // ../../node_modules/.pnpm/hono@4.10.4/node_modules/hono/dist/helper/streaming/stream.js
166
+ // ../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/helper/streaming/stream.js
167
167
  var contextStash = /* @__PURE__ */ new WeakMap();
168
168
  var stream = (c, cb, onError) => {
169
169
  const { readable, writable } = new TransformStream();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../node_modules/.pnpm/hono@4.10.4/node_modules/hono/dist/http-exception.js","../../../node_modules/.pnpm/hono@4.10.4/node_modules/hono/dist/middleware/body-limit/index.js","../../../node_modules/.pnpm/hono@4.10.4/node_modules/hono/dist/utils/stream.js","../../../node_modules/.pnpm/hono@4.10.4/node_modules/hono/dist/helper/streaming/utils.js","../../../node_modules/.pnpm/hono@4.10.4/node_modules/hono/dist/helper/streaming/stream.js","../src/index.ts"],"names":["MastraServerAdapter","InMemoryTaskStore","stream"],"mappings":";;;;;;;;AACA,IAAI,aAAA,GAAgB,cAAc,KAAA,CAAM;AAAA,EACtC,GAAA;AAAA,EACA,MAAA;AAAA,EACA,WAAA,CAAY,MAAA,GAAS,GAAA,EAAK,OAAA,EAAS;AACjC,IAAA,KAAA,CAAM,SAAS,OAAA,EAAS,EAAE,KAAA,EAAO,OAAA,EAAS,OAAO,CAAA;AACjD,IAAA,IAAA,CAAK,MAAM,OAAA,EAAS,GAAA;AACpB,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AAAA,EACA,WAAA,GAAc;AACZ,IAAA,IAAI,KAAK,GAAA,EAAK;AACZ,MAAA,MAAM,WAAA,GAAc,IAAI,QAAA,CAAS,IAAA,CAAK,IAAI,IAAA,EAAM;AAAA,QAC9C,QAAQ,IAAA,CAAK,MAAA;AAAA,QACb,OAAA,EAAS,KAAK,GAAA,CAAI;AAAA,OACnB,CAAA;AACD,MAAA,OAAO,WAA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error {\n res;\n status;\n constructor(status = 500, options) {\n super(options?.message, { cause: options?.cause });\n this.res = options?.res;\n this.status = status;\n }\n getResponse() {\n if (this.res) {\n const newResponse = new Response(this.res.body, {\n status: this.status,\n headers: this.res.headers\n });\n return newResponse;\n }\n return new Response(this.message, {\n status: this.status\n });\n }\n};\nexport {\n HTTPException\n};\n","// src/middleware/body-limit/index.ts\nimport { HTTPException } from \"../../http-exception.js\";\nvar ERROR_MESSAGE = \"Payload Too Large\";\nvar BodyLimitError = class extends Error {\n constructor(message) {\n super(message);\n this.name = \"BodyLimitError\";\n }\n};\nvar bodyLimit = (options) => {\n const onError = options.onError || (() => {\n const res = new Response(ERROR_MESSAGE, {\n status: 413\n });\n throw new HTTPException(413, { res });\n });\n const maxSize = options.maxSize;\n return async function bodyLimit2(c, next) {\n if (!c.req.raw.body) {\n return next();\n }\n const hasTransferEncoding = c.req.raw.headers.has(\"transfer-encoding\");\n const hasContentLength = c.req.raw.headers.has(\"content-length\");\n if (hasTransferEncoding && hasContentLength) {\n }\n if (hasContentLength && !hasTransferEncoding) {\n const contentLength = parseInt(c.req.raw.headers.get(\"content-length\") || \"0\", 10);\n return contentLength > maxSize ? onError(c) : next();\n }\n let size = 0;\n const rawReader = c.req.raw.body.getReader();\n const reader = new ReadableStream({\n async start(controller) {\n try {\n for (; ; ) {\n const { done, value } = await rawReader.read();\n if (done) {\n break;\n }\n size += value.length;\n if (size > maxSize) {\n controller.error(new BodyLimitError(ERROR_MESSAGE));\n break;\n }\n controller.enqueue(value);\n }\n } finally {\n controller.close();\n }\n }\n });\n const requestInit = { body: reader, duplex: \"half\" };\n c.req.raw = new Request(c.req.raw, requestInit);\n await next();\n if (c.error instanceof BodyLimitError) {\n c.res = await onError(c);\n }\n };\n};\nexport {\n bodyLimit\n};\n","// src/utils/stream.ts\nvar StreamingApi = class {\n writer;\n encoder;\n writable;\n abortSubscribers = [];\n responseReadable;\n aborted = false;\n closed = false;\n constructor(writable, _readable) {\n this.writable = writable;\n this.writer = writable.getWriter();\n this.encoder = new TextEncoder();\n const reader = _readable.getReader();\n this.abortSubscribers.push(async () => {\n await reader.cancel();\n });\n this.responseReadable = new ReadableStream({\n async pull(controller) {\n const { done, value } = await reader.read();\n done ? controller.close() : controller.enqueue(value);\n },\n cancel: () => {\n this.abort();\n }\n });\n }\n async write(input) {\n try {\n if (typeof input === \"string\") {\n input = this.encoder.encode(input);\n }\n await this.writer.write(input);\n } catch {\n }\n return this;\n }\n async writeln(input) {\n await this.write(input + \"\\n\");\n return this;\n }\n sleep(ms) {\n return new Promise((res) => setTimeout(res, ms));\n }\n async close() {\n try {\n await this.writer.close();\n } catch {\n }\n this.closed = true;\n }\n async pipe(body) {\n this.writer.releaseLock();\n await body.pipeTo(this.writable, { preventClose: true });\n this.writer = this.writable.getWriter();\n }\n onAbort(listener) {\n this.abortSubscribers.push(listener);\n }\n abort() {\n if (!this.aborted) {\n this.aborted = true;\n this.abortSubscribers.forEach((subscriber) => subscriber());\n }\n }\n};\nexport {\n StreamingApi\n};\n","// src/helper/streaming/utils.ts\nvar isOldBunVersion = () => {\n const version = typeof Bun !== \"undefined\" ? Bun.version : void 0;\n if (version === void 0) {\n return false;\n }\n const result = version.startsWith(\"1.1\") || version.startsWith(\"1.0\") || version.startsWith(\"0.\");\n isOldBunVersion = () => result;\n return result;\n};\nexport {\n isOldBunVersion\n};\n","// src/helper/streaming/stream.ts\nimport { StreamingApi } from \"../../utils/stream.js\";\nimport { isOldBunVersion } from \"./utils.js\";\nvar contextStash = /* @__PURE__ */ new WeakMap();\nvar stream = (c, cb, onError) => {\n const { readable, writable } = new TransformStream();\n const stream2 = new StreamingApi(writable, readable);\n if (isOldBunVersion()) {\n c.req.raw.signal.addEventListener(\"abort\", () => {\n if (!stream2.closed) {\n stream2.abort();\n }\n });\n }\n contextStash.set(stream2.responseReadable, c);\n (async () => {\n try {\n await cb(stream2);\n } catch (e) {\n if (e === void 0) {\n } else if (e instanceof Error && onError) {\n await onError(e, stream2);\n } else {\n console.error(e);\n }\n } finally {\n stream2.close();\n }\n })();\n return c.newResponse(stream2.responseReadable);\n};\nexport {\n stream\n};\n","import type { Mastra } from '@mastra/core/mastra';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport type { Tool } from '@mastra/core/tools';\nimport { InMemoryTaskStore } from '@mastra/server/a2a/store';\nimport { MastraServerAdapter } from '@mastra/server/server-adapter';\nimport type { BodyLimitOptions, ServerRoute } from '@mastra/server/server-adapter';\nimport type { Context, Env, Hono, HonoRequest, MiddlewareHandler } from 'hono';\nimport { bodyLimit } from 'hono/body-limit';\nimport { stream } from 'hono/streaming';\n\n// Export type definitions for Hono app configuration\nexport type HonoVariables = {\n mastra: Mastra;\n requestContext: RequestContext;\n tools: Record<string, Tool>;\n abortSignal: AbortSignal;\n taskStore: InMemoryTaskStore;\n customRouteAuthConfig?: Map<string, boolean>;\n playground?: boolean;\n isDev?: boolean;\n};\n\nexport type HonoBindings = {};\n\nexport class HonoServerAdapter extends MastraServerAdapter<Hono<any, any, any>, HonoRequest, Context> {\n private taskStore: InMemoryTaskStore;\n private customRouteAuthConfig?: Map<string, boolean>;\n private playground?: boolean;\n private isDev?: boolean;\n\n constructor({\n mastra,\n tools,\n taskStore,\n customRouteAuthConfig,\n playground,\n isDev,\n bodyLimitOptions,\n }: {\n mastra: Mastra;\n tools?: Record<string, Tool>;\n taskStore?: InMemoryTaskStore;\n customRouteAuthConfig?: Map<string, boolean>;\n playground?: boolean;\n isDev?: boolean;\n bodyLimitOptions?: BodyLimitOptions;\n }) {\n super({ mastra, bodyLimitOptions, tools });\n this.taskStore = taskStore || new InMemoryTaskStore();\n this.customRouteAuthConfig = customRouteAuthConfig;\n this.playground = playground;\n this.isDev = isDev;\n }\n\n createContextMiddleware(): MiddlewareHandler {\n return async (c, next) => {\n // Parse request context from request body and add to context\n\n let bodyRequestContext: Record<string, any> | undefined;\n let paramsRequestContext: Record<string, any> | undefined;\n\n // Parse request context from request body (POST/PUT)\n if (c.req.method === 'POST' || c.req.method === 'PUT') {\n const contentType = c.req.header('content-type');\n if (contentType?.includes('application/json')) {\n try {\n const clonedReq = c.req.raw.clone();\n const body = (await clonedReq.json()) as { requestContext?: Record<string, any> };\n if (body.requestContext) {\n bodyRequestContext = body.requestContext;\n }\n } catch {\n // Body parsing failed, continue without body\n }\n }\n }\n\n // Parse request context from query params (GET)\n if (c.req.method === 'GET') {\n try {\n const encodedRequestContext = c.req.query('requestContext');\n if (encodedRequestContext) {\n // Try JSON first\n try {\n paramsRequestContext = JSON.parse(encodedRequestContext);\n } catch {\n // Fallback to base64(JSON)\n try {\n const json = Buffer.from(encodedRequestContext, 'base64').toString('utf-8');\n paramsRequestContext = JSON.parse(json);\n } catch {\n // ignore if still invalid\n }\n }\n }\n } catch {\n // ignore query parsing errors\n }\n }\n\n const requestContext = this.mergeRequestContext({ paramsRequestContext, bodyRequestContext });\n\n // Add relevant contexts to hono context\n c.set('requestContext', requestContext);\n c.set('mastra', this.mastra);\n c.set('tools', this.tools || {});\n c.set('taskStore', this.taskStore);\n c.set('playground', this.playground === true);\n c.set('isDev', this.isDev === true);\n c.set('customRouteAuthConfig', this.customRouteAuthConfig);\n c.set('abortSignal', c.req.raw.signal);\n\n return next();\n };\n }\n async stream(route: ServerRoute, res: Context, result: { fullStream: ReadableStream }): Promise<any> {\n res.header('Content-Type', 'text/plain');\n res.header('Transfer-Encoding', 'chunked');\n\n const streamFormat = route.streamFormat || 'stream';\n\n return stream(\n res,\n async stream => {\n const readableStream = result instanceof ReadableStream ? result : result.fullStream;\n const reader = readableStream.getReader();\n\n stream.onAbort(() => {\n void reader.cancel('request aborted');\n });\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n if (value) {\n if (streamFormat === 'sse') {\n await stream.write(`data: ${JSON.stringify(value)}\\n\\n`);\n } else {\n await stream.write(JSON.stringify(value) + '\\x1E');\n }\n }\n }\n\n await stream.write('data: [DONE]\\n\\n');\n } catch (error) {\n console.error(error);\n } finally {\n await stream.close();\n }\n },\n async err => {\n console.error(err);\n },\n );\n }\n\n async getParams(\n route: ServerRoute,\n request: HonoRequest,\n ): Promise<{ urlParams: Record<string, string>; queryParams: Record<string, string>; body: unknown }> {\n const urlParams = request.param();\n const queryParams = request.query();\n let body: unknown;\n if (route.method === 'POST' || route.method === 'PUT' || route.method === 'PATCH') {\n try {\n body = await request.json();\n } catch {}\n }\n return { urlParams, queryParams: queryParams as Record<string, string>, body };\n }\n\n async sendResponse(route: ServerRoute, response: Context, result: unknown): Promise<any> {\n if (route.responseType === 'json') {\n return response.json(result as any, 200);\n } else if (route.responseType === 'stream') {\n return this.stream(route, response, result as { fullStream: ReadableStream });\n } else if (route.responseType === 'datastream-response') {\n const fetchResponse = result as globalThis.Response;\n return fetchResponse;\n } else {\n return response.status(500);\n }\n }\n\n async registerRoute<E extends Env = any>(\n app: Hono<E, any, any>,\n route: ServerRoute,\n { prefix }: { prefix?: string },\n ): Promise<void> {\n // Determine if body limits should be applied\n const shouldApplyBodyLimit = this.bodyLimitOptions && ['POST', 'PUT', 'PATCH'].includes(route.method.toUpperCase());\n\n // Get the body size limit for this route (route-specific or default)\n const maxSize = route.maxBodySize ?? this.bodyLimitOptions?.maxSize;\n\n // Build middleware array\n const middlewares: MiddlewareHandler[] = [];\n\n if (shouldApplyBodyLimit && maxSize && this.bodyLimitOptions) {\n middlewares.push(\n bodyLimit({\n maxSize,\n onError: this.bodyLimitOptions.onError as any,\n }),\n );\n }\n\n app[route.method.toLowerCase() as 'get' | 'post' | 'put' | 'delete' | 'patch' | 'all'](\n `${prefix}${route.path}`,\n ...middlewares,\n async (c: Context) => {\n const params = await this.getParams(route, c.req);\n\n if (params.queryParams) {\n try {\n params.queryParams = await this.parseQueryParams(route, params.queryParams as Record<string, string>);\n } catch (error) {\n console.error('Error parsing query params', error);\n // Zod validation errors should return 400 Bad Request, not 500\n return c.json(\n {\n error: 'Invalid query parameters',\n details: error instanceof Error ? error.message : 'Unknown error',\n },\n 400,\n );\n }\n }\n\n if (params.body) {\n try {\n params.body = await this.parseBody(route, params.body);\n } catch (error) {\n console.error('Error parsing body', error);\n // Zod validation errors should return 400 Bad Request, not 500\n return c.json(\n {\n error: 'Invalid request body',\n details: error instanceof Error ? error.message : 'Unknown error',\n },\n 400,\n );\n }\n }\n\n const handlerParams = {\n ...params.urlParams,\n ...params.queryParams,\n ...(typeof params.body === 'object' ? params.body : {}),\n requestContext: c.get('requestContext'),\n mastra: this.mastra,\n tools: c.get('tools'),\n taskStore: c.get('taskStore'),\n abortSignal: c.get('abortSignal'),\n };\n\n try {\n const result = await route.handler(handlerParams);\n return this.sendResponse(route, c, result);\n } catch (error) {\n console.error('Error calling handler', error);\n // Check if it's an HTTPException or MastraError with a status code\n if (error && typeof error === 'object') {\n // Check for direct status property (HTTPException)\n if ('status' in error) {\n const status = (error as any).status;\n return c.json({ error: error instanceof Error ? error.message : 'Unknown error' }, status);\n }\n // Check for MastraError with status in details\n if ('details' in error && error.details && typeof error.details === 'object' && 'status' in error.details) {\n const status = (error.details as any).status;\n return c.json({ error: error instanceof Error ? error.message : 'Unknown error' }, status);\n }\n }\n return c.json({ error: error instanceof Error ? error.message : 'Unknown error' }, 500);\n }\n },\n );\n }\n\n registerContextMiddleware<E extends Env = any>(app: Hono<E, any, any>): void {\n app.use('*', this.createContextMiddleware());\n }\n\n async registerRoutes<E extends Env = any>(\n app: Hono<E, any, any>,\n { prefix, openapiPath }: { prefix?: string; openapiPath?: string },\n ): Promise<void> {\n // Cast to base type for super call - safe because registerRoute is generic\n await super.registerRoutes(app as any, { prefix, openapiPath });\n }\n}\n"]}
1
+ {"version":3,"sources":["../../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/http-exception.js","../../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/middleware/body-limit/index.js","../../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/utils/stream.js","../../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/helper/streaming/utils.js","../../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/helper/streaming/stream.js","../src/index.ts"],"names":["MastraServerAdapter","InMemoryTaskStore","stream"],"mappings":";;;;;;;;AACA,IAAI,aAAA,GAAgB,cAAc,KAAA,CAAM;AAAA,EACtC,GAAA;AAAA,EACA,MAAA;AAAA,EACA,WAAA,CAAY,MAAA,GAAS,GAAA,EAAK,OAAA,EAAS;AACjC,IAAA,KAAA,CAAM,SAAS,OAAA,EAAS,EAAE,KAAA,EAAO,OAAA,EAAS,OAAO,CAAA;AACjD,IAAA,IAAA,CAAK,MAAM,OAAA,EAAS,GAAA;AACpB,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AAAA,EACA,WAAA,GAAc;AACZ,IAAA,IAAI,KAAK,GAAA,EAAK;AACZ,MAAA,MAAM,WAAA,GAAc,IAAI,QAAA,CAAS,IAAA,CAAK,IAAI,IAAA,EAAM;AAAA,QAC9C,QAAQ,IAAA,CAAK,MAAA;AAAA,QACb,OAAA,EAAS,KAAK,GAAA,CAAI;AAAA,OACnB,CAAA;AACD,MAAA,OAAO,WAAA;AAAA,IACT;AACA,IAAA,OAAO,IAAI,QAAA,CAAS,IAAA,CAAK,OAAA,EAAS;AAAA,MAChC,QAAQ,IAAA,CAAK;AAAA,KACd,CAAA;AAAA,EACH;AACF,CAAA;;;ACnBA,IAAI,aAAA,GAAgB,mBAAA;AACpB,IAAI,cAAA,GAAiB,cAAc,KAAA,CAAM;AAAA,EACvC,YAAY,OAAA,EAAS;AACnB,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,gBAAA;AAAA,EACd;AACF,CAAA;AACA,IAAI,SAAA,GAAY,CAAC,OAAA,KAAY;AAC3B,EAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,OAAA,KAAY,MAAM;AACxC,IAAA,MAAM,GAAA,GAAM,IAAI,QAAA,CAAS,aAAA,EAAe;AAAA,MACtC,MAAA,EAAQ;AAAA,KACT,CA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cAAA,OAAO,CAAA,CAAE,IAAA,CAAK,EAAE,KAAA,EAAO,KAAA,YAAiB,QAAQ,KAAA,CAAM,OAAA,GAAU,eAAA,EAAgB,EAAG,MAAM,CAAA;AAAA,YAC3F;AAAA,UACF;AACA,UAAA,OAAO,CAAA,CAAE,IAAA,CAAK,EAAE,KAAA,EAAO,KAAA,YAAiB,QAAQ,KAAA,CAAM,OAAA,GAAU,eAAA,EAAgB,EAAG,GAAG,CAAA;AAAA,QACxF;AAAA,MACF;AAAA,KACF;AAAA,EACF;AAAA,EAEA,0BAA+C,GAAA,EAA8B;AAC3E,IAAA,GAAA,CAAI,GAAA,CAAI,GAAA,EAAK,IAAA,CAAK,uBAAA,EAAyB,CAAA;AAAA,EAC7C;AAAA,EAEA,MAAM,cAAA,CACJ,GAAA,EACA,EAAE,MAAA,EAAQ,aAAY,EACP;AAEf,IAAA,MAAM,MAAM,cAAA,CAAe,GAAA,EAAY,EAAE,MAAA,EAAQ,aAAa,CAAA;AAAA,EAChE;AACF","file":"index.cjs","sourcesContent":["// src/http-exception.ts\nvar HTTPException = class extends Error {\n res;\n status;\n constructor(status = 500, options) {\n super(options?.message, { cause: options?.cause });\n this.res = options?.res;\n this.status = status;\n }\n getResponse() {\n if (this.res) {\n const newResponse = new Response(this.res.body, {\n status: this.status,\n headers: this.res.headers\n });\n return newResponse;\n }\n return new Response(this.message, {\n status: this.status\n });\n }\n};\nexport {\n HTTPException\n};\n","// src/middleware/body-limit/index.ts\nimport { HTTPException } from \"../../http-exception.js\";\nvar ERROR_MESSAGE = \"Payload Too Large\";\nvar BodyLimitError = class extends Error {\n constructor(message) {\n super(message);\n this.name = \"BodyLimitError\";\n }\n};\nvar bodyLimit = (options) => {\n const onError = options.onError || (() => {\n const res = new Response(ERROR_MESSAGE, {\n status: 413\n });\n throw new HTTPException(413, { res });\n });\n const maxSize = options.maxSize;\n return async function bodyLimit2(c, next) {\n if (!c.req.raw.body) {\n return next();\n }\n const hasTransferEncoding = c.req.raw.headers.has(\"transfer-encoding\");\n const hasContentLength = c.req.raw.headers.has(\"content-length\");\n if (hasTransferEncoding && hasContentLength) {\n }\n if (hasContentLength && !hasTransferEncoding) {\n const contentLength = parseInt(c.req.raw.headers.get(\"content-length\") || \"0\", 10);\n return contentLength > maxSize ? onError(c) : next();\n }\n let size = 0;\n const rawReader = c.req.raw.body.getReader();\n const reader = new ReadableStream({\n async start(controller) {\n try {\n for (; ; ) {\n const { done, value } = await rawReader.read();\n if (done) {\n break;\n }\n size += value.length;\n if (size > maxSize) {\n controller.error(new BodyLimitError(ERROR_MESSAGE));\n break;\n }\n controller.enqueue(value);\n }\n } finally {\n controller.close();\n }\n }\n });\n const requestInit = { body: reader, duplex: \"half\" };\n c.req.raw = new Request(c.req.raw, requestInit);\n await next();\n if (c.error instanceof BodyLimitError) {\n c.res = await onError(c);\n }\n };\n};\nexport {\n bodyLimit\n};\n","// src/utils/stream.ts\nvar StreamingApi = class {\n writer;\n encoder;\n writable;\n abortSubscribers = [];\n responseReadable;\n aborted = false;\n closed = false;\n constructor(writable, _readable) {\n this.writable = writable;\n this.writer = writable.getWriter();\n this.encoder = new TextEncoder();\n const reader = _readable.getReader();\n this.abortSubscribers.push(async () => {\n await reader.cancel();\n });\n this.responseReadable = new ReadableStream({\n async pull(controller) {\n const { done, value } = await reader.read();\n done ? controller.close() : controller.enqueue(value);\n },\n cancel: () => {\n this.abort();\n }\n });\n }\n async write(input) {\n try {\n if (typeof input === \"string\") {\n input = this.encoder.encode(input);\n }\n await this.writer.write(input);\n } catch {\n }\n return this;\n }\n async writeln(input) {\n await this.write(input + \"\\n\");\n return this;\n }\n sleep(ms) {\n return new Promise((res) => setTimeout(res, ms));\n }\n async close() {\n try {\n await this.writer.close();\n } catch {\n }\n this.closed = true;\n }\n async pipe(body) {\n this.writer.releaseLock();\n await body.pipeTo(this.writable, { preventClose: true });\n this.writer = this.writable.getWriter();\n }\n onAbort(listener) {\n this.abortSubscribers.push(listener);\n }\n abort() {\n if (!this.aborted) {\n this.aborted = true;\n this.abortSubscribers.forEach((subscriber) => subscriber());\n }\n }\n};\nexport {\n StreamingApi\n};\n","// src/helper/streaming/utils.ts\nvar isOldBunVersion = () => {\n const version = typeof Bun !== \"undefined\" ? Bun.version : void 0;\n if (version === void 0) {\n return false;\n }\n const result = version.startsWith(\"1.1\") || version.startsWith(\"1.0\") || version.startsWith(\"0.\");\n isOldBunVersion = () => result;\n return result;\n};\nexport {\n isOldBunVersion\n};\n","// src/helper/streaming/stream.ts\nimport { StreamingApi } from \"../../utils/stream.js\";\nimport { isOldBunVersion } from \"./utils.js\";\nvar contextStash = /* @__PURE__ */ new WeakMap();\nvar stream = (c, cb, onError) => {\n const { readable, writable } = new TransformStream();\n const stream2 = new StreamingApi(writable, readable);\n if (isOldBunVersion()) {\n c.req.raw.signal.addEventListener(\"abort\", () => {\n if (!stream2.closed) {\n stream2.abort();\n }\n });\n }\n contextStash.set(stream2.responseReadable, c);\n (async () => {\n try {\n await cb(stream2);\n } catch (e) {\n if (e === void 0) {\n } else if (e instanceof Error && onError) {\n await onError(e, stream2);\n } else {\n console.error(e);\n }\n } finally {\n stream2.close();\n }\n })();\n return c.newResponse(stream2.responseReadable);\n};\nexport {\n stream\n};\n","import type { Mastra } from '@mastra/core/mastra';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport type { Tool } from '@mastra/core/tools';\nimport { InMemoryTaskStore } from '@mastra/server/a2a/store';\nimport { MastraServerAdapter } from '@mastra/server/server-adapter';\nimport type { BodyLimitOptions, ServerRoute } from '@mastra/server/server-adapter';\nimport type { Context, Env, Hono, HonoRequest, MiddlewareHandler } from 'hono';\nimport { bodyLimit } from 'hono/body-limit';\nimport { stream } from 'hono/streaming';\n\n// Export type definitions for Hono app configuration\nexport type HonoVariables = {\n mastra: Mastra;\n requestContext: RequestContext;\n tools: Record<string, Tool>;\n abortSignal: AbortSignal;\n taskStore: InMemoryTaskStore;\n customRouteAuthConfig?: Map<string, boolean>;\n playground?: boolean;\n isDev?: boolean;\n};\n\nexport type HonoBindings = {};\n\nexport class HonoServerAdapter extends MastraServerAdapter<Hono<any, any, any>, HonoRequest, Context> {\n private taskStore: InMemoryTaskStore;\n private customRouteAuthConfig?: Map<string, boolean>;\n private playground?: boolean;\n private isDev?: boolean;\n\n constructor({\n mastra,\n tools,\n taskStore,\n customRouteAuthConfig,\n playground,\n isDev,\n bodyLimitOptions,\n }: {\n mastra: Mastra;\n tools?: Record<string, Tool>;\n taskStore?: InMemoryTaskStore;\n customRouteAuthConfig?: Map<string, boolean>;\n playground?: boolean;\n isDev?: boolean;\n bodyLimitOptions?: BodyLimitOptions;\n }) {\n super({ mastra, bodyLimitOptions, tools });\n this.taskStore = taskStore || new InMemoryTaskStore();\n this.customRouteAuthConfig = customRouteAuthConfig;\n this.playground = playground;\n this.isDev = isDev;\n }\n\n createContextMiddleware(): MiddlewareHandler {\n return async (c, next) => {\n // Parse request context from request body and add to context\n\n let bodyRequestContext: Record<string, any> | undefined;\n let paramsRequestContext: Record<string, any> | undefined;\n\n // Parse request context from request body (POST/PUT)\n if (c.req.method === 'POST' || c.req.method === 'PUT') {\n const contentType = c.req.header('content-type');\n if (contentType?.includes('application/json')) {\n try {\n const clonedReq = c.req.raw.clone();\n const body = (await clonedReq.json()) as { requestContext?: Record<string, any> };\n if (body.requestContext) {\n bodyRequestContext = body.requestContext;\n }\n } catch {\n // Body parsing failed, continue without body\n }\n }\n }\n\n // Parse request context from query params (GET)\n if (c.req.method === 'GET') {\n try {\n const encodedRequestContext = c.req.query('requestContext');\n if (encodedRequestContext) {\n // Try JSON first\n try {\n paramsRequestContext = JSON.parse(encodedRequestContext);\n } catch {\n // Fallback to base64(JSON)\n try {\n const json = Buffer.from(encodedRequestContext, 'base64').toString('utf-8');\n paramsRequestContext = JSON.parse(json);\n } catch {\n // ignore if still invalid\n }\n }\n }\n } catch {\n // ignore query parsing errors\n }\n }\n\n const requestContext = this.mergeRequestContext({ paramsRequestContext, bodyRequestContext });\n\n // Add relevant contexts to hono context\n c.set('requestContext', requestContext);\n c.set('mastra', this.mastra);\n c.set('tools', this.tools || {});\n c.set('taskStore', this.taskStore);\n c.set('playground', this.playground === true);\n c.set('isDev', this.isDev === true);\n c.set('customRouteAuthConfig', this.customRouteAuthConfig);\n c.set('abortSignal', c.req.raw.signal);\n\n return next();\n };\n }\n async stream(route: ServerRoute, res: Context, result: { fullStream: ReadableStream }): Promise<any> {\n res.header('Content-Type', 'text/plain');\n res.header('Transfer-Encoding', 'chunked');\n\n const streamFormat = route.streamFormat || 'stream';\n\n return stream(\n res,\n async stream => {\n const readableStream = result instanceof ReadableStream ? result : result.fullStream;\n const reader = readableStream.getReader();\n\n stream.onAbort(() => {\n void reader.cancel('request aborted');\n });\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n if (value) {\n if (streamFormat === 'sse') {\n await stream.write(`data: ${JSON.stringify(value)}\\n\\n`);\n } else {\n await stream.write(JSON.stringify(value) + '\\x1E');\n }\n }\n }\n\n await stream.write('data: [DONE]\\n\\n');\n } catch (error) {\n console.error(error);\n } finally {\n await stream.close();\n }\n },\n async err => {\n console.error(err);\n },\n );\n }\n\n async getParams(\n route: ServerRoute,\n request: HonoRequest,\n ): Promise<{ urlParams: Record<string, string>; queryParams: Record<string, string>; body: unknown }> {\n const urlParams = request.param();\n const queryParams = request.query();\n let body: unknown;\n if (route.method === 'POST' || route.method === 'PUT' || route.method === 'PATCH') {\n try {\n body = await request.json();\n } catch {}\n }\n return { urlParams, queryParams: queryParams as Record<string, string>, body };\n }\n\n async sendResponse(route: ServerRoute, response: Context, result: unknown): Promise<any> {\n if (route.responseType === 'json') {\n return response.json(result as any, 200);\n } else if (route.responseType === 'stream') {\n return this.stream(route, response, result as { fullStream: ReadableStream });\n } else if (route.responseType === 'datastream-response') {\n const fetchResponse = result as globalThis.Response;\n return fetchResponse;\n } else {\n return response.status(500);\n }\n }\n\n async registerRoute<E extends Env = any>(\n app: Hono<E, any, any>,\n route: ServerRoute,\n { prefix }: { prefix?: string },\n ): Promise<void> {\n // Determine if body limits should be applied\n const shouldApplyBodyLimit = this.bodyLimitOptions && ['POST', 'PUT', 'PATCH'].includes(route.method.toUpperCase());\n\n // Get the body size limit for this route (route-specific or default)\n const maxSize = route.maxBodySize ?? this.bodyLimitOptions?.maxSize;\n\n // Build middleware array\n const middlewares: MiddlewareHandler[] = [];\n\n if (shouldApplyBodyLimit && maxSize && this.bodyLimitOptions) {\n middlewares.push(\n bodyLimit({\n maxSize,\n onError: this.bodyLimitOptions.onError as any,\n }),\n );\n }\n\n app[route.method.toLowerCase() as 'get' | 'post' | 'put' | 'delete' | 'patch' | 'all'](\n `${prefix}${route.path}`,\n ...middlewares,\n async (c: Context) => {\n const params = await this.getParams(route, c.req);\n\n if (params.queryParams) {\n try {\n params.queryParams = await this.parseQueryParams(route, params.queryParams as Record<string, string>);\n } catch (error) {\n console.error('Error parsing query params', error);\n // Zod validation errors should return 400 Bad Request, not 500\n return c.json(\n {\n error: 'Invalid query parameters',\n details: error instanceof Error ? error.message : 'Unknown error',\n },\n 400,\n );\n }\n }\n\n if (params.body) {\n try {\n params.body = await this.parseBody(route, params.body);\n } catch (error) {\n console.error('Error parsing body', error);\n // Zod validation errors should return 400 Bad Request, not 500\n return c.json(\n {\n error: 'Invalid request body',\n details: error instanceof Error ? error.message : 'Unknown error',\n },\n 400,\n );\n }\n }\n\n const handlerParams = {\n ...params.urlParams,\n ...params.queryParams,\n ...(typeof params.body === 'object' ? params.body : {}),\n requestContext: c.get('requestContext'),\n mastra: this.mastra,\n tools: c.get('tools'),\n taskStore: c.get('taskStore'),\n abortSignal: c.get('abortSignal'),\n };\n\n try {\n const result = await route.handler(handlerParams);\n return this.sendResponse(route, c, result);\n } catch (error) {\n console.error('Error calling handler', error);\n // Check if it's an HTTPException or MastraError with a status code\n if (error && typeof error === 'object') {\n // Check for direct status property (HTTPException)\n if ('status' in error) {\n const status = (error as any).status;\n return c.json({ error: error instanceof Error ? error.message : 'Unknown error' }, status);\n }\n // Check for MastraError with status in details\n if ('details' in error && error.details && typeof error.details === 'object' && 'status' in error.details) {\n const status = (error.details as any).status;\n return c.json({ error: error instanceof Error ? error.message : 'Unknown error' }, status);\n }\n }\n return c.json({ error: error instanceof Error ? error.message : 'Unknown error' }, 500);\n }\n },\n );\n }\n\n registerContextMiddleware<E extends Env = any>(app: Hono<E, any, any>): void {\n app.use('*', this.createContextMiddleware());\n }\n\n async registerRoutes<E extends Env = any>(\n app: Hono<E, any, any>,\n { prefix, openapiPath }: { prefix?: string; openapiPath?: string },\n ): Promise<void> {\n // Cast to base type for super call - safe because registerRoute is generic\n await super.registerRoutes(app as any, { prefix, openapiPath });\n }\n}\n"]}
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { MastraServerAdapter } from '@mastra/server/server-adapter';
3
3
 
4
4
  // src/index.ts
5
5
 
6
- // ../../node_modules/.pnpm/hono@4.10.4/node_modules/hono/dist/http-exception.js
6
+ // ../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/http-exception.js
7
7
  var HTTPException = class extends Error {
8
8
  res;
9
9
  status;
@@ -26,7 +26,7 @@ var HTTPException = class extends Error {
26
26
  }
27
27
  };
28
28
 
29
- // ../../node_modules/.pnpm/hono@4.10.4/node_modules/hono/dist/middleware/body-limit/index.js
29
+ // ../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/middleware/body-limit/index.js
30
30
  var ERROR_MESSAGE = "Payload Too Large";
31
31
  var BodyLimitError = class extends Error {
32
32
  constructor(message) {
@@ -83,7 +83,7 @@ var bodyLimit = (options) => {
83
83
  };
84
84
  };
85
85
 
86
- // ../../node_modules/.pnpm/hono@4.10.4/node_modules/hono/dist/utils/stream.js
86
+ // ../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/utils/stream.js
87
87
  var StreamingApi = class {
88
88
  writer;
89
89
  encoder;
@@ -150,7 +150,7 @@ var StreamingApi = class {
150
150
  }
151
151
  };
152
152
 
153
- // ../../node_modules/.pnpm/hono@4.10.4/node_modules/hono/dist/helper/streaming/utils.js
153
+ // ../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/helper/streaming/utils.js
154
154
  var isOldBunVersion = () => {
155
155
  const version = typeof Bun !== "undefined" ? Bun.version : void 0;
156
156
  if (version === void 0) {
@@ -161,7 +161,7 @@ var isOldBunVersion = () => {
161
161
  return result;
162
162
  };
163
163
 
164
- // ../../node_modules/.pnpm/hono@4.10.4/node_modules/hono/dist/helper/streaming/stream.js
164
+ // ../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/helper/streaming/stream.js
165
165
  var contextStash = /* @__PURE__ */ new WeakMap();
166
166
  var stream = (c, cb, onError) => {
167
167
  const { readable, writable } = new TransformStream();
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../node_modules/.pnpm/hono@4.10.4/node_modules/hono/dist/http-exception.js","../../../node_modules/.pnpm/hono@4.10.4/node_modules/hono/dist/middleware/body-limit/index.js","../../../node_modules/.pnpm/hono@4.10.4/node_modules/hono/dist/utils/stream.js","../../../node_modules/.pnpm/hono@4.10.4/node_modules/hono/dist/helper/streaming/utils.js","../../../node_modules/.pnpm/hono@4.10.4/node_modules/hono/dist/helper/streaming/stream.js","../src/index.ts"],"names":["stream"],"mappings":";;;;;;AACA,IAAI,aAAA,GAAgB,cAAc,KAAA,CAAM;AAAA,EACtC,GAAA;AAAA,EACA,MAAA;AAAA,EACA,WAAA,CAAY,MAAA,GAAS,GAAA,EAAK,OAAA,EAAS;AACjC,IAAA,KAAA,CAAM,SAAS,OAAA,EAAS,EAAE,KAAA,EAAO,OAAA,EAAS,OAAO,CAAA;AACjD,IAAA,IAAA,CAAK,MAAM,OAAA,EAAS,GAAA;AACpB,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AAAA,EACA,WAAA,GAAc;AACZ,IAAA,IAAI,KAAK,GAAA,EAAK;AACZ,MAAA,MAAM,WAAA,GAAc,IAAI,QAAA,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,EACP;AAEf,IAAA,MAAM,MAAM,cAAA,CAAe,GAAA,EAAY,EAAE,MAAA,EAAQ,aAAa,CAAA;AAAA,EAChE;AACF","file":"index.js","sourcesContent":["// src/http-exception.ts\nvar HTTPException = class extends Error {\n res;\n status;\n constructor(status = 500, options) {\n super(options?.message, { cause: options?.cause });\n this.res = options?.res;\n this.status = status;\n }\n getResponse() {\n if (this.res) {\n const newResponse = new Response(this.res.body, {\n status: this.status,\n headers: this.res.headers\n });\n return newResponse;\n }\n return new Response(this.message, {\n status: this.status\n });\n }\n};\nexport {\n HTTPException\n};\n","// src/middleware/body-limit/index.ts\nimport { HTTPException } from \"../../http-exception.js\";\nvar ERROR_MESSAGE = \"Payload Too Large\";\nvar BodyLimitError = class extends Error {\n constructor(message) {\n super(message);\n this.name = \"BodyLimitError\";\n }\n};\nvar bodyLimit = (options) => {\n const onError = options.onError || (() => {\n const res = new Response(ERROR_MESSAGE, {\n status: 413\n });\n throw new HTTPException(413, { res });\n });\n const maxSize = options.maxSize;\n return async function bodyLimit2(c, next) {\n if (!c.req.raw.body) {\n return next();\n }\n const hasTransferEncoding = c.req.raw.headers.has(\"transfer-encoding\");\n const hasContentLength = c.req.raw.headers.has(\"content-length\");\n if (hasTransferEncoding && hasContentLength) {\n }\n if (hasContentLength && !hasTransferEncoding) {\n const contentLength = parseInt(c.req.raw.headers.get(\"content-length\") || \"0\", 10);\n return contentLength > maxSize ? onError(c) : next();\n }\n let size = 0;\n const rawReader = c.req.raw.body.getReader();\n const reader = new ReadableStream({\n async start(controller) {\n try {\n for (; ; ) {\n const { done, value } = await rawReader.read();\n if (done) {\n break;\n }\n size += value.length;\n if (size > maxSize) {\n controller.error(new BodyLimitError(ERROR_MESSAGE));\n break;\n }\n controller.enqueue(value);\n }\n } finally {\n controller.close();\n }\n }\n });\n const requestInit = { body: reader, duplex: \"half\" };\n c.req.raw = new Request(c.req.raw, requestInit);\n await next();\n if (c.error instanceof BodyLimitError) {\n c.res = await onError(c);\n }\n };\n};\nexport {\n bodyLimit\n};\n","// src/utils/stream.ts\nvar StreamingApi = class {\n writer;\n encoder;\n writable;\n abortSubscribers = [];\n responseReadable;\n aborted = false;\n closed = false;\n constructor(writable, _readable) {\n this.writable = writable;\n this.writer = writable.getWriter();\n this.encoder = new TextEncoder();\n const reader = _readable.getReader();\n this.abortSubscribers.push(async () => {\n await reader.cancel();\n });\n this.responseReadable = new ReadableStream({\n async pull(controller) {\n const { done, value } = await reader.read();\n done ? controller.close() : controller.enqueue(value);\n },\n cancel: () => {\n this.abort();\n }\n });\n }\n async write(input) {\n try {\n if (typeof input === \"string\") {\n input = this.encoder.encode(input);\n }\n await this.writer.write(input);\n } catch {\n }\n return this;\n }\n async writeln(input) {\n await this.write(input + \"\\n\");\n return this;\n }\n sleep(ms) {\n return new Promise((res) => setTimeout(res, ms));\n }\n async close() {\n try {\n await this.writer.close();\n } catch {\n }\n this.closed = true;\n }\n async pipe(body) {\n this.writer.releaseLock();\n await body.pipeTo(this.writable, { preventClose: true });\n this.writer = this.writable.getWriter();\n }\n onAbort(listener) {\n this.abortSubscribers.push(listener);\n }\n abort() {\n if (!this.aborted) {\n this.aborted = true;\n this.abortSubscribers.forEach((subscriber) => subscriber());\n }\n }\n};\nexport {\n StreamingApi\n};\n","// src/helper/streaming/utils.ts\nvar isOldBunVersion = () => {\n const version = typeof Bun !== \"undefined\" ? Bun.version : void 0;\n if (version === void 0) {\n return false;\n }\n const result = version.startsWith(\"1.1\") || version.startsWith(\"1.0\") || version.startsWith(\"0.\");\n isOldBunVersion = () => result;\n return result;\n};\nexport {\n isOldBunVersion\n};\n","// src/helper/streaming/stream.ts\nimport { StreamingApi } from \"../../utils/stream.js\";\nimport { isOldBunVersion } from \"./utils.js\";\nvar contextStash = /* @__PURE__ */ new WeakMap();\nvar stream = (c, cb, onError) => {\n const { readable, writable } = new TransformStream();\n const stream2 = new StreamingApi(writable, readable);\n if (isOldBunVersion()) {\n c.req.raw.signal.addEventListener(\"abort\", () => {\n if (!stream2.closed) {\n stream2.abort();\n }\n });\n }\n contextStash.set(stream2.responseReadable, c);\n (async () => {\n try {\n await cb(stream2);\n } catch (e) {\n if (e === void 0) {\n } else if (e instanceof Error && onError) {\n await onError(e, stream2);\n } else {\n console.error(e);\n }\n } finally {\n stream2.close();\n }\n })();\n return c.newResponse(stream2.responseReadable);\n};\nexport {\n stream\n};\n","import type { Mastra } from '@mastra/core/mastra';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport type { Tool } from '@mastra/core/tools';\nimport { InMemoryTaskStore } from '@mastra/server/a2a/store';\nimport { MastraServerAdapter } from '@mastra/server/server-adapter';\nimport type { BodyLimitOptions, ServerRoute } from '@mastra/server/server-adapter';\nimport type { Context, Env, Hono, HonoRequest, MiddlewareHandler } from 'hono';\nimport { bodyLimit } from 'hono/body-limit';\nimport { stream } from 'hono/streaming';\n\n// Export type definitions for Hono app configuration\nexport type HonoVariables = {\n mastra: Mastra;\n requestContext: RequestContext;\n tools: Record<string, Tool>;\n abortSignal: AbortSignal;\n taskStore: InMemoryTaskStore;\n customRouteAuthConfig?: Map<string, boolean>;\n playground?: boolean;\n isDev?: boolean;\n};\n\nexport type HonoBindings = {};\n\nexport class HonoServerAdapter extends MastraServerAdapter<Hono<any, any, any>, HonoRequest, Context> {\n private taskStore: InMemoryTaskStore;\n private customRouteAuthConfig?: Map<string, boolean>;\n private playground?: boolean;\n private isDev?: boolean;\n\n constructor({\n mastra,\n tools,\n taskStore,\n customRouteAuthConfig,\n playground,\n isDev,\n bodyLimitOptions,\n }: {\n mastra: Mastra;\n tools?: Record<string, Tool>;\n taskStore?: InMemoryTaskStore;\n customRouteAuthConfig?: Map<string, boolean>;\n playground?: boolean;\n isDev?: boolean;\n bodyLimitOptions?: BodyLimitOptions;\n }) {\n super({ mastra, bodyLimitOptions, tools });\n this.taskStore = taskStore || new InMemoryTaskStore();\n this.customRouteAuthConfig = customRouteAuthConfig;\n this.playground = playground;\n this.isDev = isDev;\n }\n\n createContextMiddleware(): MiddlewareHandler {\n return async (c, next) => {\n // Parse request context from request body and add to context\n\n let bodyRequestContext: Record<string, any> | undefined;\n let paramsRequestContext: Record<string, any> | undefined;\n\n // Parse request context from request body (POST/PUT)\n if (c.req.method === 'POST' || c.req.method === 'PUT') {\n const contentType = c.req.header('content-type');\n if (contentType?.includes('application/json')) {\n try {\n const clonedReq = c.req.raw.clone();\n const body = (await clonedReq.json()) as { requestContext?: Record<string, any> };\n if (body.requestContext) {\n bodyRequestContext = body.requestContext;\n }\n } catch {\n // Body parsing failed, continue without body\n }\n }\n }\n\n // Parse request context from query params (GET)\n if (c.req.method === 'GET') {\n try {\n const encodedRequestContext = c.req.query('requestContext');\n if (encodedRequestContext) {\n // Try JSON first\n try {\n paramsRequestContext = JSON.parse(encodedRequestContext);\n } catch {\n // Fallback to base64(JSON)\n try {\n const json = Buffer.from(encodedRequestContext, 'base64').toString('utf-8');\n paramsRequestContext = JSON.parse(json);\n } catch {\n // ignore if still invalid\n }\n }\n }\n } catch {\n // ignore query parsing errors\n }\n }\n\n const requestContext = this.mergeRequestContext({ paramsRequestContext, bodyRequestContext });\n\n // Add relevant contexts to hono context\n c.set('requestContext', requestContext);\n c.set('mastra', this.mastra);\n c.set('tools', this.tools || {});\n c.set('taskStore', this.taskStore);\n c.set('playground', this.playground === true);\n c.set('isDev', this.isDev === true);\n c.set('customRouteAuthConfig', this.customRouteAuthConfig);\n c.set('abortSignal', c.req.raw.signal);\n\n return next();\n };\n }\n async stream(route: ServerRoute, res: Context, result: { fullStream: ReadableStream }): Promise<any> {\n res.header('Content-Type', 'text/plain');\n res.header('Transfer-Encoding', 'chunked');\n\n const streamFormat = route.streamFormat || 'stream';\n\n return stream(\n res,\n async stream => {\n const readableStream = result instanceof ReadableStream ? result : result.fullStream;\n const reader = readableStream.getReader();\n\n stream.onAbort(() => {\n void reader.cancel('request aborted');\n });\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n if (value) {\n if (streamFormat === 'sse') {\n await stream.write(`data: ${JSON.stringify(value)}\\n\\n`);\n } else {\n await stream.write(JSON.stringify(value) + '\\x1E');\n }\n }\n }\n\n await stream.write('data: [DONE]\\n\\n');\n } catch (error) {\n console.error(error);\n } finally {\n await stream.close();\n }\n },\n async err => {\n console.error(err);\n },\n );\n }\n\n async getParams(\n route: ServerRoute,\n request: HonoRequest,\n ): Promise<{ urlParams: Record<string, string>; queryParams: Record<string, string>; body: unknown }> {\n const urlParams = request.param();\n const queryParams = request.query();\n let body: unknown;\n if (route.method === 'POST' || route.method === 'PUT' || route.method === 'PATCH') {\n try {\n body = await request.json();\n } catch {}\n }\n return { urlParams, queryParams: queryParams as Record<string, string>, body };\n }\n\n async sendResponse(route: ServerRoute, response: Context, result: unknown): Promise<any> {\n if (route.responseType === 'json') {\n return response.json(result as any, 200);\n } else if (route.responseType === 'stream') {\n return this.stream(route, response, result as { fullStream: ReadableStream });\n } else if (route.responseType === 'datastream-response') {\n const fetchResponse = result as globalThis.Response;\n return fetchResponse;\n } else {\n return response.status(500);\n }\n }\n\n async registerRoute<E extends Env = any>(\n app: Hono<E, any, any>,\n route: ServerRoute,\n { prefix }: { prefix?: string },\n ): Promise<void> {\n // Determine if body limits should be applied\n const shouldApplyBodyLimit = this.bodyLimitOptions && ['POST', 'PUT', 'PATCH'].includes(route.method.toUpperCase());\n\n // Get the body size limit for this route (route-specific or default)\n const maxSize = route.maxBodySize ?? this.bodyLimitOptions?.maxSize;\n\n // Build middleware array\n const middlewares: MiddlewareHandler[] = [];\n\n if (shouldApplyBodyLimit && maxSize && this.bodyLimitOptions) {\n middlewares.push(\n bodyLimit({\n maxSize,\n onError: this.bodyLimitOptions.onError as any,\n }),\n );\n }\n\n app[route.method.toLowerCase() as 'get' | 'post' | 'put' | 'delete' | 'patch' | 'all'](\n `${prefix}${route.path}`,\n ...middlewares,\n async (c: Context) => {\n const params = await this.getParams(route, c.req);\n\n if (params.queryParams) {\n try {\n params.queryParams = await this.parseQueryParams(route, params.queryParams as Record<string, string>);\n } catch (error) {\n console.error('Error parsing query params', error);\n // Zod validation errors should return 400 Bad Request, not 500\n return c.json(\n {\n error: 'Invalid query parameters',\n details: error instanceof Error ? error.message : 'Unknown error',\n },\n 400,\n );\n }\n }\n\n if (params.body) {\n try {\n params.body = await this.parseBody(route, params.body);\n } catch (error) {\n console.error('Error parsing body', error);\n // Zod validation errors should return 400 Bad Request, not 500\n return c.json(\n {\n error: 'Invalid request body',\n details: error instanceof Error ? error.message : 'Unknown error',\n },\n 400,\n );\n }\n }\n\n const handlerParams = {\n ...params.urlParams,\n ...params.queryParams,\n ...(typeof params.body === 'object' ? params.body : {}),\n requestContext: c.get('requestContext'),\n mastra: this.mastra,\n tools: c.get('tools'),\n taskStore: c.get('taskStore'),\n abortSignal: c.get('abortSignal'),\n };\n\n try {\n const result = await route.handler(handlerParams);\n return this.sendResponse(route, c, result);\n } catch (error) {\n console.error('Error calling handler', error);\n // Check if it's an HTTPException or MastraError with a status code\n if (error && typeof error === 'object') {\n // Check for direct status property (HTTPException)\n if ('status' in error) {\n const status = (error as any).status;\n return c.json({ error: error instanceof Error ? error.message : 'Unknown error' }, status);\n }\n // Check for MastraError with status in details\n if ('details' in error && error.details && typeof error.details === 'object' && 'status' in error.details) {\n const status = (error.details as any).status;\n return c.json({ error: error instanceof Error ? error.message : 'Unknown error' }, status);\n }\n }\n return c.json({ error: error instanceof Error ? error.message : 'Unknown error' }, 500);\n }\n },\n );\n }\n\n registerContextMiddleware<E extends Env = any>(app: Hono<E, any, any>): void {\n app.use('*', this.createContextMiddleware());\n }\n\n async registerRoutes<E extends Env = any>(\n app: Hono<E, any, any>,\n { prefix, openapiPath }: { prefix?: string; openapiPath?: string },\n ): Promise<void> {\n // Cast to base type for super call - safe because registerRoute is generic\n await super.registerRoutes(app as any, { prefix, openapiPath });\n }\n}\n"]}
1
+ {"version":3,"sources":["../../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/http-exception.js","../../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/middleware/body-limit/index.js","../../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/utils/stream.js","../../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/helper/streaming/utils.js","../../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/helper/streaming/stream.js","../src/index.ts"],"names":["stream"],"mappings":";;;;;;AACA,IAAI,aAAA,GAAgB,cAAc,KAAA,CAAM;AAAA,EACtC,GAAA;AAAA,EACA,MAAA;AAAA,EACA,WAAA,CAAY,MAAA,GAAS,GAAA,EAAK,OAAA,EAAS;AACjC,IAAA,KAAA,CAAM,SAAS,OAAA,EAAS,EAAE,KAAA,EAAO,OAAA,EAAS,OAAO,CAAA;AACjD,IAAA,IAAA,CAAK,MAAM,OAAA,EAAS,GAAA;AACpB,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AAAA,EACA,WAAA,GAAc;AACZ,IAAA,IAAI,KAAK,GAAA,EAAK;AACZ,MAAA,MAAM,WAAA,GAAc,IAAI,QAAA,CAAS,IAAA,CAAK,IAAI,IAAA,EAAM;AAAA,QAC9C,QAAQ,IAAA,CAAK,MAAA;AAAA,QACb,OAAA,EAAS,KAAK,GAAA,CAAI;AAAA,OACnB,CAAA;AACD,MAAA,OAAO,WAAA;AAAA,IACT;AACA,IAAA,OAAO,IAAI,QAAA,CAAS,IAAA,CAAK,OAAA,EAAS;AAAA,MAChC,QAAQ,IAAA,CAAK;AAAA,KACd,CAAA;AAAA,EACH;AACF,CAAA;;;ACnBA,IAAI,aAAA,GAAgB,mBAAA;AACpB,IAAI,cAAA,GAAiB,cAAc,KAAA,CAAM;AAAA,EACvC,YAAY,OAAA,EAAS;AACnB,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,gBAAA;AAAA,EACd;AACF,CAAA;AACA,IAAI,SAAA,GAAY,CAAC,OAAA,KAAY;AAC3B,EAAA,MAAM,OAAA,GAAU,OAAA,CA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AA,KAAY,QAAA,IAAY,QAAA,IAAY,KAAA,CAAM,OAAA,EAAS;AACzG,cAAA,MAAM,MAAA,GAAU,MAAM,OAAA,CAAgB,MAAA;AACtC,cAAA,OAAO,CAAA,CAAE,IAAA,CAAK,EAAE,KAAA,EAAO,KAAA,YAAiB,QAAQ,KAAA,CAAM,OAAA,GAAU,eAAA,EAAgB,EAAG,MAAM,CAAA;AAAA,YAC3F;AAAA,UACF;AACA,UAAA,OAAO,CAAA,CAAE,IAAA,CAAK,EAAE,KAAA,EAAO,KAAA,YAAiB,QAAQ,KAAA,CAAM,OAAA,GAAU,eAAA,EAAgB,EAAG,GAAG,CAAA;AAAA,QACxF;AAAA,MACF;AAAA,KACF;AAAA,EACF;AAAA,EAEA,0BAA+C,GAAA,EAA8B;AAC3E,IAAA,GAAA,CAAI,GAAA,CAAI,GAAA,EAAK,IAAA,CAAK,uBAAA,EAAyB,CAAA;AAAA,EAC7C;AAAA,EAEA,MAAM,cAAA,CACJ,GAAA,EACA,EAAE,MAAA,EAAQ,aAAY,EACP;AAEf,IAAA,MAAM,MAAM,cAAA,CAAe,GAAA,EAAY,EAAE,MAAA,EAAQ,aAAa,CAAA;AAAA,EAChE;AACF","file":"index.js","sourcesContent":["// src/http-exception.ts\nvar HTTPException = class extends Error {\n res;\n status;\n constructor(status = 500, options) {\n super(options?.message, { cause: options?.cause });\n this.res = options?.res;\n this.status = status;\n }\n getResponse() {\n if (this.res) {\n const newResponse = new Response(this.res.body, {\n status: this.status,\n headers: this.res.headers\n });\n return newResponse;\n }\n return new Response(this.message, {\n status: this.status\n });\n }\n};\nexport {\n HTTPException\n};\n","// src/middleware/body-limit/index.ts\nimport { HTTPException } from \"../../http-exception.js\";\nvar ERROR_MESSAGE = \"Payload Too Large\";\nvar BodyLimitError = class extends Error {\n constructor(message) {\n super(message);\n this.name = \"BodyLimitError\";\n }\n};\nvar bodyLimit = (options) => {\n const onError = options.onError || (() => {\n const res = new Response(ERROR_MESSAGE, {\n status: 413\n });\n throw new HTTPException(413, { res });\n });\n const maxSize = options.maxSize;\n return async function bodyLimit2(c, next) {\n if (!c.req.raw.body) {\n return next();\n }\n const hasTransferEncoding = c.req.raw.headers.has(\"transfer-encoding\");\n const hasContentLength = c.req.raw.headers.has(\"content-length\");\n if (hasTransferEncoding && hasContentLength) {\n }\n if (hasContentLength && !hasTransferEncoding) {\n const contentLength = parseInt(c.req.raw.headers.get(\"content-length\") || \"0\", 10);\n return contentLength > maxSize ? onError(c) : next();\n }\n let size = 0;\n const rawReader = c.req.raw.body.getReader();\n const reader = new ReadableStream({\n async start(controller) {\n try {\n for (; ; ) {\n const { done, value } = await rawReader.read();\n if (done) {\n break;\n }\n size += value.length;\n if (size > maxSize) {\n controller.error(new BodyLimitError(ERROR_MESSAGE));\n break;\n }\n controller.enqueue(value);\n }\n } finally {\n controller.close();\n }\n }\n });\n const requestInit = { body: reader, duplex: \"half\" };\n c.req.raw = new Request(c.req.raw, requestInit);\n await next();\n if (c.error instanceof BodyLimitError) {\n c.res = await onError(c);\n }\n };\n};\nexport {\n bodyLimit\n};\n","// src/utils/stream.ts\nvar StreamingApi = class {\n writer;\n encoder;\n writable;\n abortSubscribers = [];\n responseReadable;\n aborted = false;\n closed = false;\n constructor(writable, _readable) {\n this.writable = writable;\n this.writer = writable.getWriter();\n this.encoder = new TextEncoder();\n const reader = _readable.getReader();\n this.abortSubscribers.push(async () => {\n await reader.cancel();\n });\n this.responseReadable = new ReadableStream({\n async pull(controller) {\n const { done, value } = await reader.read();\n done ? controller.close() : controller.enqueue(value);\n },\n cancel: () => {\n this.abort();\n }\n });\n }\n async write(input) {\n try {\n if (typeof input === \"string\") {\n input = this.encoder.encode(input);\n }\n await this.writer.write(input);\n } catch {\n }\n return this;\n }\n async writeln(input) {\n await this.write(input + \"\\n\");\n return this;\n }\n sleep(ms) {\n return new Promise((res) => setTimeout(res, ms));\n }\n async close() {\n try {\n await this.writer.close();\n } catch {\n }\n this.closed = true;\n }\n async pipe(body) {\n this.writer.releaseLock();\n await body.pipeTo(this.writable, { preventClose: true });\n this.writer = this.writable.getWriter();\n }\n onAbort(listener) {\n this.abortSubscribers.push(listener);\n }\n abort() {\n if (!this.aborted) {\n this.aborted = true;\n this.abortSubscribers.forEach((subscriber) => subscriber());\n }\n }\n};\nexport {\n StreamingApi\n};\n","// src/helper/streaming/utils.ts\nvar isOldBunVersion = () => {\n const version = typeof Bun !== \"undefined\" ? Bun.version : void 0;\n if (version === void 0) {\n return false;\n }\n const result = version.startsWith(\"1.1\") || version.startsWith(\"1.0\") || version.startsWith(\"0.\");\n isOldBunVersion = () => result;\n return result;\n};\nexport {\n isOldBunVersion\n};\n","// src/helper/streaming/stream.ts\nimport { StreamingApi } from \"../../utils/stream.js\";\nimport { isOldBunVersion } from \"./utils.js\";\nvar contextStash = /* @__PURE__ */ new WeakMap();\nvar stream = (c, cb, onError) => {\n const { readable, writable } = new TransformStream();\n const stream2 = new StreamingApi(writable, readable);\n if (isOldBunVersion()) {\n c.req.raw.signal.addEventListener(\"abort\", () => {\n if (!stream2.closed) {\n stream2.abort();\n }\n });\n }\n contextStash.set(stream2.responseReadable, c);\n (async () => {\n try {\n await cb(stream2);\n } catch (e) {\n if (e === void 0) {\n } else if (e instanceof Error && onError) {\n await onError(e, stream2);\n } else {\n console.error(e);\n }\n } finally {\n stream2.close();\n }\n })();\n return c.newResponse(stream2.responseReadable);\n};\nexport {\n stream\n};\n","import type { Mastra } from '@mastra/core/mastra';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport type { Tool } from '@mastra/core/tools';\nimport { InMemoryTaskStore } from '@mastra/server/a2a/store';\nimport { MastraServerAdapter } from '@mastra/server/server-adapter';\nimport type { BodyLimitOptions, ServerRoute } from '@mastra/server/server-adapter';\nimport type { Context, Env, Hono, HonoRequest, MiddlewareHandler } from 'hono';\nimport { bodyLimit } from 'hono/body-limit';\nimport { stream } from 'hono/streaming';\n\n// Export type definitions for Hono app configuration\nexport type HonoVariables = {\n mastra: Mastra;\n requestContext: RequestContext;\n tools: Record<string, Tool>;\n abortSignal: AbortSignal;\n taskStore: InMemoryTaskStore;\n customRouteAuthConfig?: Map<string, boolean>;\n playground?: boolean;\n isDev?: boolean;\n};\n\nexport type HonoBindings = {};\n\nexport class HonoServerAdapter extends MastraServerAdapter<Hono<any, any, any>, HonoRequest, Context> {\n private taskStore: InMemoryTaskStore;\n private customRouteAuthConfig?: Map<string, boolean>;\n private playground?: boolean;\n private isDev?: boolean;\n\n constructor({\n mastra,\n tools,\n taskStore,\n customRouteAuthConfig,\n playground,\n isDev,\n bodyLimitOptions,\n }: {\n mastra: Mastra;\n tools?: Record<string, Tool>;\n taskStore?: InMemoryTaskStore;\n customRouteAuthConfig?: Map<string, boolean>;\n playground?: boolean;\n isDev?: boolean;\n bodyLimitOptions?: BodyLimitOptions;\n }) {\n super({ mastra, bodyLimitOptions, tools });\n this.taskStore = taskStore || new InMemoryTaskStore();\n this.customRouteAuthConfig = customRouteAuthConfig;\n this.playground = playground;\n this.isDev = isDev;\n }\n\n createContextMiddleware(): MiddlewareHandler {\n return async (c, next) => {\n // Parse request context from request body and add to context\n\n let bodyRequestContext: Record<string, any> | undefined;\n let paramsRequestContext: Record<string, any> | undefined;\n\n // Parse request context from request body (POST/PUT)\n if (c.req.method === 'POST' || c.req.method === 'PUT') {\n const contentType = c.req.header('content-type');\n if (contentType?.includes('application/json')) {\n try {\n const clonedReq = c.req.raw.clone();\n const body = (await clonedReq.json()) as { requestContext?: Record<string, any> };\n if (body.requestContext) {\n bodyRequestContext = body.requestContext;\n }\n } catch {\n // Body parsing failed, continue without body\n }\n }\n }\n\n // Parse request context from query params (GET)\n if (c.req.method === 'GET') {\n try {\n const encodedRequestContext = c.req.query('requestContext');\n if (encodedRequestContext) {\n // Try JSON first\n try {\n paramsRequestContext = JSON.parse(encodedRequestContext);\n } catch {\n // Fallback to base64(JSON)\n try {\n const json = Buffer.from(encodedRequestContext, 'base64').toString('utf-8');\n paramsRequestContext = JSON.parse(json);\n } catch {\n // ignore if still invalid\n }\n }\n }\n } catch {\n // ignore query parsing errors\n }\n }\n\n const requestContext = this.mergeRequestContext({ paramsRequestContext, bodyRequestContext });\n\n // Add relevant contexts to hono context\n c.set('requestContext', requestContext);\n c.set('mastra', this.mastra);\n c.set('tools', this.tools || {});\n c.set('taskStore', this.taskStore);\n c.set('playground', this.playground === true);\n c.set('isDev', this.isDev === true);\n c.set('customRouteAuthConfig', this.customRouteAuthConfig);\n c.set('abortSignal', c.req.raw.signal);\n\n return next();\n };\n }\n async stream(route: ServerRoute, res: Context, result: { fullStream: ReadableStream }): Promise<any> {\n res.header('Content-Type', 'text/plain');\n res.header('Transfer-Encoding', 'chunked');\n\n const streamFormat = route.streamFormat || 'stream';\n\n return stream(\n res,\n async stream => {\n const readableStream = result instanceof ReadableStream ? result : result.fullStream;\n const reader = readableStream.getReader();\n\n stream.onAbort(() => {\n void reader.cancel('request aborted');\n });\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n if (value) {\n if (streamFormat === 'sse') {\n await stream.write(`data: ${JSON.stringify(value)}\\n\\n`);\n } else {\n await stream.write(JSON.stringify(value) + '\\x1E');\n }\n }\n }\n\n await stream.write('data: [DONE]\\n\\n');\n } catch (error) {\n console.error(error);\n } finally {\n await stream.close();\n }\n },\n async err => {\n console.error(err);\n },\n );\n }\n\n async getParams(\n route: ServerRoute,\n request: HonoRequest,\n ): Promise<{ urlParams: Record<string, string>; queryParams: Record<string, string>; body: unknown }> {\n const urlParams = request.param();\n const queryParams = request.query();\n let body: unknown;\n if (route.method === 'POST' || route.method === 'PUT' || route.method === 'PATCH') {\n try {\n body = await request.json();\n } catch {}\n }\n return { urlParams, queryParams: queryParams as Record<string, string>, body };\n }\n\n async sendResponse(route: ServerRoute, response: Context, result: unknown): Promise<any> {\n if (route.responseType === 'json') {\n return response.json(result as any, 200);\n } else if (route.responseType === 'stream') {\n return this.stream(route, response, result as { fullStream: ReadableStream });\n } else if (route.responseType === 'datastream-response') {\n const fetchResponse = result as globalThis.Response;\n return fetchResponse;\n } else {\n return response.status(500);\n }\n }\n\n async registerRoute<E extends Env = any>(\n app: Hono<E, any, any>,\n route: ServerRoute,\n { prefix }: { prefix?: string },\n ): Promise<void> {\n // Determine if body limits should be applied\n const shouldApplyBodyLimit = this.bodyLimitOptions && ['POST', 'PUT', 'PATCH'].includes(route.method.toUpperCase());\n\n // Get the body size limit for this route (route-specific or default)\n const maxSize = route.maxBodySize ?? this.bodyLimitOptions?.maxSize;\n\n // Build middleware array\n const middlewares: MiddlewareHandler[] = [];\n\n if (shouldApplyBodyLimit && maxSize && this.bodyLimitOptions) {\n middlewares.push(\n bodyLimit({\n maxSize,\n onError: this.bodyLimitOptions.onError as any,\n }),\n );\n }\n\n app[route.method.toLowerCase() as 'get' | 'post' | 'put' | 'delete' | 'patch' | 'all'](\n `${prefix}${route.path}`,\n ...middlewares,\n async (c: Context) => {\n const params = await this.getParams(route, c.req);\n\n if (params.queryParams) {\n try {\n params.queryParams = await this.parseQueryParams(route, params.queryParams as Record<string, string>);\n } catch (error) {\n console.error('Error parsing query params', error);\n // Zod validation errors should return 400 Bad Request, not 500\n return c.json(\n {\n error: 'Invalid query parameters',\n details: error instanceof Error ? error.message : 'Unknown error',\n },\n 400,\n );\n }\n }\n\n if (params.body) {\n try {\n params.body = await this.parseBody(route, params.body);\n } catch (error) {\n console.error('Error parsing body', error);\n // Zod validation errors should return 400 Bad Request, not 500\n return c.json(\n {\n error: 'Invalid request body',\n details: error instanceof Error ? error.message : 'Unknown error',\n },\n 400,\n );\n }\n }\n\n const handlerParams = {\n ...params.urlParams,\n ...params.queryParams,\n ...(typeof params.body === 'object' ? params.body : {}),\n requestContext: c.get('requestContext'),\n mastra: this.mastra,\n tools: c.get('tools'),\n taskStore: c.get('taskStore'),\n abortSignal: c.get('abortSignal'),\n };\n\n try {\n const result = await route.handler(handlerParams);\n return this.sendResponse(route, c, result);\n } catch (error) {\n console.error('Error calling handler', error);\n // Check if it's an HTTPException or MastraError with a status code\n if (error && typeof error === 'object') {\n // Check for direct status property (HTTPException)\n if ('status' in error) {\n const status = (error as any).status;\n return c.json({ error: error instanceof Error ? error.message : 'Unknown error' }, status);\n }\n // Check for MastraError with status in details\n if ('details' in error && error.details && typeof error.details === 'object' && 'status' in error.details) {\n const status = (error.details as any).status;\n return c.json({ error: error instanceof Error ? error.message : 'Unknown error' }, status);\n }\n }\n return c.json({ error: error instanceof Error ? error.message : 'Unknown error' }, 500);\n }\n },\n );\n }\n\n registerContextMiddleware<E extends Env = any>(app: Hono<E, any, any>): void {\n app.use('*', this.createContextMiddleware());\n }\n\n async registerRoutes<E extends Env = any>(\n app: Hono<E, any, any>,\n { prefix, openapiPath }: { prefix?: string; openapiPath?: string },\n ): Promise<void> {\n // Cast to base type for super call - safe because registerRoute is generic\n await super.registerRoutes(app as any, { prefix, openapiPath });\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/hono",
3
- "version": "0.0.0-fix-ai-sdk-dependency-20251124104209",
3
+ "version": "0.0.0-fix-issue-10434-concurrent-write-corruption-20251124213939",
4
4
  "description": "Mastra Hono adapter for the server",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "license": "Apache-2.0",
22
22
  "dependencies": {
23
- "@mastra/server": "0.0.0-fix-ai-sdk-dependency-20251124104209"
23
+ "@mastra/server": "0.0.0-fix-issue-10434-concurrent-write-corruption-20251124213939"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/node": "^20.19.0",
@@ -33,19 +33,19 @@
33
33
  "@hono/swagger-ui": "^0.5.2",
34
34
  "@ai-sdk/openai": "^2.0.62",
35
35
  "zod": "^3.25.0",
36
- "@internal/lint": "0.0.0-fix-ai-sdk-dependency-20251124104209",
37
- "@internal/server-adapter-test-utils": "0.0.1",
36
+ "@internal/lint": "0.0.0-fix-issue-10434-concurrent-write-corruption-20251124213939",
38
37
  "@internal/storage-test-utils": "0.0.49",
39
- "@mastra/libsql": "0.0.0-fix-ai-sdk-dependency-20251124104209",
40
- "@mastra/observability": "0.0.0-fix-ai-sdk-dependency-20251124104209",
41
- "@mastra/core": "0.0.0-fix-ai-sdk-dependency-20251124104209",
42
- "@mastra/memory": "0.0.0-fix-ai-sdk-dependency-20251124104209",
43
- "@internal/types-builder": "0.0.0-fix-ai-sdk-dependency-20251124104209"
38
+ "@internal/server-adapter-test-utils": "0.0.1",
39
+ "@mastra/libsql": "0.0.0-fix-issue-10434-concurrent-write-corruption-20251124213939",
40
+ "@mastra/core": "0.0.0-fix-issue-10434-concurrent-write-corruption-20251124213939",
41
+ "@mastra/observability": "0.0.0-fix-issue-10434-concurrent-write-corruption-20251124213939",
42
+ "@mastra/memory": "0.0.0-fix-issue-10434-concurrent-write-corruption-20251124213939",
43
+ "@internal/types-builder": "0.0.0-fix-issue-10434-concurrent-write-corruption-20251124213939"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "express": "^5.1.0",
47
47
  "@types/express": "^5.0.5",
48
- "@mastra/core": "0.0.0-fix-ai-sdk-dependency-20251124104209"
48
+ "@mastra/core": "0.0.0-fix-issue-10434-concurrent-write-corruption-20251124213939"
49
49
  },
50
50
  "engines": {
51
51
  "node": ">=22.13.0"