@mastra/server 0.16.3-alpha.1 → 0.16.4-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @mastra/server
2
2
 
3
+ ## 0.16.4-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Voice errors that are instance of a MastraError should not throw a 500 ([#7749](https://github.com/mastra-ai/mastra/pull/7749))
8
+
9
+ - Updated dependencies [[`5802bf5`](https://github.com/mastra-ai/mastra/commit/5802bf57f6182e4b67c28d7d91abed349a8d14f3), [`5bda53a`](https://github.com/mastra-ai/mastra/commit/5bda53a9747bfa7d876d754fc92c83a06e503f62), [`f26a8fd`](https://github.com/mastra-ai/mastra/commit/f26a8fd99fcb0497a5d86c28324430d7f6a5fb83), [`1a1fbe6`](https://github.com/mastra-ai/mastra/commit/1a1fbe66efb7d94abc373ed0dd9676adb8122454), [`36f39c0`](https://github.com/mastra-ai/mastra/commit/36f39c00dc794952dc3c11aab91c2fa8bca74b11)]:
10
+ - @mastra/core@0.16.4-alpha.0
11
+
12
+ ## 0.16.3
13
+
14
+ ### Patch Changes
15
+
16
+ - Delayed deprecation notice for streamVNext() replacing stream() until Sept 23rd ([#7739](https://github.com/mastra-ai/mastra/pull/7739))
17
+
18
+ - an part 3 ([#7705](https://github.com/mastra-ai/mastra/pull/7705))
19
+
20
+ - Update peer deps ([#7741](https://github.com/mastra-ai/mastra/pull/7741))
21
+
22
+ - Client SDK Agents, Mastra server - support runtimeContext with GET requests ([#7734](https://github.com/mastra-ai/mastra/pull/7734))
23
+
24
+ - Updated dependencies [[`b4379f7`](https://github.com/mastra-ai/mastra/commit/b4379f703fd74474f253420e8c3a684f2c4b2f8e), [`2a6585f`](https://github.com/mastra-ai/mastra/commit/2a6585f7cb71f023f805d521d1c3c95fb9a3aa59), [`3d26e83`](https://github.com/mastra-ai/mastra/commit/3d26e8353a945719028f087cc6ac4b06f0ce27d2), [`dd9119b`](https://github.com/mastra-ai/mastra/commit/dd9119b175a8f389082f75c12750e51f96d65dca), [`d34aaa1`](https://github.com/mastra-ai/mastra/commit/d34aaa1da5d3c5f991740f59e2fe6d28d3e2dd91), [`56e55d1`](https://github.com/mastra-ai/mastra/commit/56e55d1e9eb63e7d9e41aa46e012aae471256812), [`ce1e580`](https://github.com/mastra-ai/mastra/commit/ce1e580f6391e94a0c6816a9c5db0a21566a262f), [`b2babfa`](https://github.com/mastra-ai/mastra/commit/b2babfa9e75b22f2759179e71d8473f6dc5421ed), [`d8c3ba5`](https://github.com/mastra-ai/mastra/commit/d8c3ba516f4173282d293f7e64769cfc8738d360), [`a566c4e`](https://github.com/mastra-ai/mastra/commit/a566c4e92d86c1671707c54359b1d33934f7cc13), [`af333aa`](https://github.com/mastra-ai/mastra/commit/af333aa30fe6d1b127024b03a64736c46eddeca2), [`3863c52`](https://github.com/mastra-ai/mastra/commit/3863c52d44b4e5779968b802d977e87adf939d8e), [`6424c7e`](https://github.com/mastra-ai/mastra/commit/6424c7ec38b6921d66212431db1e0958f441b2a7), [`db94750`](https://github.com/mastra-ai/mastra/commit/db94750a41fd29b43eb1f7ce8e97ba8b9978c91b), [`a66a371`](https://github.com/mastra-ai/mastra/commit/a66a3716b00553d7f01842be9deb34f720b10fab), [`69fc3cd`](https://github.com/mastra-ai/mastra/commit/69fc3cd0fd814901785bdcf49bf536ab1e7fd975)]:
25
+ - @mastra/core@0.16.3
26
+
3
27
  ## 0.16.3-alpha.1
4
28
 
5
29
  ### Patch Changes
@@ -3,6 +3,7 @@ import { handleError } from './chunk-CY4TP3FK.js';
3
3
  import { HTTPException } from './chunk-MMROOK5J.js';
4
4
  import { __export } from './chunk-G3PMV62Z.js';
5
5
  import { Readable } from 'stream';
6
+ import { MastraError } from '@mastra/core/error';
6
7
 
7
8
  // src/server/handlers/voice.ts
8
9
  var voice_exports = {};
@@ -52,7 +53,12 @@ async function generateSpeechHandler({
52
53
  if (!voice) {
53
54
  throw new HTTPException(400, { message: "Agent does not have voice capabilities" });
54
55
  }
55
- const audioStream = await voice.speak(body.text, { speaker: body.speakerId });
56
+ const audioStream = await Promise.resolve().then(() => voice.speak(body.text, { speaker: body.speakerId })).catch((err) => {
57
+ if (err instanceof MastraError) {
58
+ throw new HTTPException(400, { message: err.message });
59
+ }
60
+ throw err;
61
+ });
56
62
  if (!audioStream) {
57
63
  throw new HTTPException(500, { message: "Failed to generate speech" });
58
64
  }
@@ -112,5 +118,5 @@ async function getListenerHandler({ mastra, agentId, runtimeContext }) {
112
118
  }
113
119
 
114
120
  export { generateSpeechHandler, getListenerHandler, getSpeakersHandler, transcribeSpeechHandler, voice_exports };
115
- //# sourceMappingURL=chunk-J373SDWK.js.map
116
- //# sourceMappingURL=chunk-J373SDWK.js.map
121
+ //# sourceMappingURL=chunk-JRDEOHAJ.js.map
122
+ //# sourceMappingURL=chunk-JRDEOHAJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/handlers/voice.ts"],"names":[],"mappings":";;;;;;;;AAAA,IAAA,aAAA,GAAA;AAAA,QAAA,CAAA,aAAA,EAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,kBAAA,EAAA,MAAA,kBAAA;AAAA,EAAA,kBAAA,EAAA,MAAA,kBAAA;AAAA,EAAA,uBAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAkBA,eAAsB,kBAAA,CAAmB,EAAE,MAAA,EAAQ,OAAA,EAAS,gBAAe,EAAiB;AAC1F,EAAA,IAAI;AACF,IAAA,IAAI,CAAC,OAAA,EAAS;AACZ,MAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,wBAAwB,CAAA;AAAA,IAClE;AAEA,IAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,QAAA,CAAS,OAAO,CAAA;AAErC,IAAA,IAAI,CAAC,KAAA,EAAO;AACV,MAAA,MAAM,IAAI,aAAA,CAA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A,CAAY,OAAO,yBAAyB,CAAA;AAAA,EACrD;AACF","file":"chunk-JRDEOHAJ.js","sourcesContent":["import { Readable } from 'stream';\nimport type { Agent } from '@mastra/core/agent';\nimport { MastraError } from '@mastra/core/error';\nimport type { RuntimeContext } from '@mastra/core/runtime-context';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\n\nimport { handleError } from './error';\nimport { validateBody } from './utils';\n\ninterface VoiceContext extends Context {\n agentId?: string;\n runtimeContext?: RuntimeContext;\n}\n\n/**\n * Get available speakers for an agent\n */\nexport async function getSpeakersHandler({ mastra, agentId, runtimeContext }: VoiceContext) {\n try {\n if (!agentId) {\n throw new HTTPException(400, { message: 'Agent ID is required' });\n }\n\n const agent = mastra.getAgent(agentId);\n\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const voice = await agent.getVoice({ runtimeContext });\n\n if (!voice) {\n throw new HTTPException(400, { message: 'Agent does not have voice capabilities' });\n }\n\n const speakers = await voice.getSpeakers();\n return speakers;\n } catch (error) {\n return handleError(error, 'Error getting speakers');\n }\n}\n\n/**\n * Generate speech from text\n */\nexport async function generateSpeechHandler({\n mastra,\n agentId,\n body,\n runtimeContext,\n}: VoiceContext & {\n body?: {\n text?: string;\n speakerId?: string;\n };\n}) {\n try {\n if (!agentId) {\n throw new HTTPException(400, { message: 'Agent ID is required' });\n }\n\n validateBody({\n text: body?.text,\n });\n\n const agent = mastra.getAgent(agentId);\n\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const voice = await agent.getVoice({ runtimeContext });\n\n if (!voice) {\n throw new HTTPException(400, { message: 'Agent does not have voice capabilities' });\n }\n\n const audioStream = await Promise.resolve()\n .then(() => voice.speak(body!.text!, { speaker: body!.speakerId! }))\n .catch(err => {\n if (err instanceof MastraError) {\n throw new HTTPException(400, { message: err.message });\n }\n\n throw err;\n });\n\n if (!audioStream) {\n throw new HTTPException(500, { message: 'Failed to generate speech' });\n }\n\n return audioStream;\n } catch (error) {\n return handleError(error, 'Error generating speech');\n }\n}\n\n/**\n * Transcribe speech to text\n */\nexport async function transcribeSpeechHandler({\n mastra,\n agentId,\n body,\n runtimeContext,\n}: VoiceContext & {\n body?: {\n audioData?: Buffer;\n options?: Parameters<NonNullable<Agent['voice']>['listen']>[1];\n };\n}) {\n try {\n if (!agentId) {\n throw new HTTPException(400, { message: 'Agent ID is required' });\n }\n\n if (!body?.audioData) {\n throw new HTTPException(400, { message: 'Audio data is required' });\n }\n\n const agent = mastra.getAgent(agentId);\n\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const voice = await agent.getVoice({ runtimeContext });\n\n if (!voice) {\n throw new HTTPException(400, { message: 'Agent does not have voice capabilities' });\n }\n\n const audioStream = new Readable();\n audioStream.push(body.audioData);\n audioStream.push(null);\n\n const text = await voice.listen(audioStream, body.options);\n return { text };\n } catch (error) {\n return handleError(error, 'Error transcribing speech');\n }\n}\n\n/**\n * Get available listeners for an agent\n */\nexport async function getListenerHandler({ mastra, agentId, runtimeContext }: VoiceContext) {\n try {\n if (!agentId) {\n throw new HTTPException(400, { message: 'Agent ID is required' });\n }\n\n const agent = mastra.getAgent(agentId);\n\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const voice = await agent.getVoice({ runtimeContext });\n\n if (!voice) {\n throw new HTTPException(400, { message: 'Agent does not have voice capabilities' });\n }\n\n const listeners = await voice.getListener();\n return listeners;\n } catch (error) {\n return handleError(error, 'Error getting listeners');\n }\n}\n"]}
@@ -5,6 +5,7 @@ var chunkRE4RPXT2_cjs = require('./chunk-RE4RPXT2.cjs');
5
5
  var chunk7NADHFD2_cjs = require('./chunk-7NADHFD2.cjs');
6
6
  var chunkEMMSS5I5_cjs = require('./chunk-EMMSS5I5.cjs');
7
7
  var stream = require('stream');
8
+ var error = require('@mastra/core/error');
8
9
 
9
10
  // src/server/handlers/voice.ts
10
11
  var voice_exports = {};
@@ -54,7 +55,12 @@ async function generateSpeechHandler({
54
55
  if (!voice) {
55
56
  throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
56
57
  }
57
- const audioStream = await voice.speak(body.text, { speaker: body.speakerId });
58
+ const audioStream = await Promise.resolve().then(() => voice.speak(body.text, { speaker: body.speakerId })).catch((err) => {
59
+ if (err instanceof error.MastraError) {
60
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: err.message });
61
+ }
62
+ throw err;
63
+ });
58
64
  if (!audioStream) {
59
65
  throw new chunk7NADHFD2_cjs.HTTPException(500, { message: "Failed to generate speech" });
60
66
  }
@@ -118,5 +124,5 @@ exports.getListenerHandler = getListenerHandler;
118
124
  exports.getSpeakersHandler = getSpeakersHandler;
119
125
  exports.transcribeSpeechHandler = transcribeSpeechHandler;
120
126
  exports.voice_exports = voice_exports;
121
- //# sourceMappingURL=chunk-YOPL5HWA.cjs.map
122
- //# sourceMappingURL=chunk-YOPL5HWA.cjs.map
127
+ //# sourceMappingURL=chunk-NLWACBE7.cjs.map
128
+ //# sourceMappingURL=chunk-NLWACBE7.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/handlers/voice.ts"],"names":["__export","HTTPException","handleError","validateBody","MastraError","Readable"],"mappings":";;;;;;;;;;AAAA,IAAA,aAAA,GAAA;AAAAA,0BAAA,CAAA,aAAA,EAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,kBAAA,EAAA,MAAA,kBAAA;AAAA,EAAA,kBAAA,EAAA,MAAA,kBAAA;AAAA,EAAA,uBAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAkBA,eAAsB,kBAAA,CAAmB,EAAE,MAAA,EAAQ,OAAA,EAAS,gBAAe,EAAiB;AAC1F,EAAA,IAAI;AACF,IAAA,IAAI,CAAC,OAAA,EAAS;AACZ,MAAA,MAAM,IAAIC,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,wBAAwB,CAAA;AAAA,IAClE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EAAE,OAAA,EAAS,0CAA0C,CAAA;AAAA,IACpF;AAEA,IAAA,MAAM,SAAA,GAAY,MAAM,KAAA,CAAM,WAAA,EAAY;AAC1C,IAAA,OAAO,SAAA;AAAA,EACT,SAAS,KAAA,EAAO;AACd,IAAA,OAAOC,6BAAA,CAAY,OAAO,yBAAyB,CAAA;AAAA,EACrD;AACF","file":"chunk-NLWACBE7.cjs","sourcesContent":["import { Readable } from 'stream';\nimport type { Agent } from '@mastra/core/agent';\nimport { MastraError } from '@mastra/core/error';\nimport type { RuntimeContext } from '@mastra/core/runtime-context';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\n\nimport { handleError } from './error';\nimport { validateBody } from './utils';\n\ninterface VoiceContext extends Context {\n agentId?: string;\n runtimeContext?: RuntimeContext;\n}\n\n/**\n * Get available speakers for an agent\n */\nexport async function getSpeakersHandler({ mastra, agentId, runtimeContext }: VoiceContext) {\n try {\n if (!agentId) {\n throw new HTTPException(400, { message: 'Agent ID is required' });\n }\n\n const agent = mastra.getAgent(agentId);\n\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const voice = await agent.getVoice({ runtimeContext });\n\n if (!voice) {\n throw new HTTPException(400, { message: 'Agent does not have voice capabilities' });\n }\n\n const speakers = await voice.getSpeakers();\n return speakers;\n } catch (error) {\n return handleError(error, 'Error getting speakers');\n }\n}\n\n/**\n * Generate speech from text\n */\nexport async function generateSpeechHandler({\n mastra,\n agentId,\n body,\n runtimeContext,\n}: VoiceContext & {\n body?: {\n text?: string;\n speakerId?: string;\n };\n}) {\n try {\n if (!agentId) {\n throw new HTTPException(400, { message: 'Agent ID is required' });\n }\n\n validateBody({\n text: body?.text,\n });\n\n const agent = mastra.getAgent(agentId);\n\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const voice = await agent.getVoice({ runtimeContext });\n\n if (!voice) {\n throw new HTTPException(400, { message: 'Agent does not have voice capabilities' });\n }\n\n const audioStream = await Promise.resolve()\n .then(() => voice.speak(body!.text!, { speaker: body!.speakerId! }))\n .catch(err => {\n if (err instanceof MastraError) {\n throw new HTTPException(400, { message: err.message });\n }\n\n throw err;\n });\n\n if (!audioStream) {\n throw new HTTPException(500, { message: 'Failed to generate speech' });\n }\n\n return audioStream;\n } catch (error) {\n return handleError(error, 'Error generating speech');\n }\n}\n\n/**\n * Transcribe speech to text\n */\nexport async function transcribeSpeechHandler({\n mastra,\n agentId,\n body,\n runtimeContext,\n}: VoiceContext & {\n body?: {\n audioData?: Buffer;\n options?: Parameters<NonNullable<Agent['voice']>['listen']>[1];\n };\n}) {\n try {\n if (!agentId) {\n throw new HTTPException(400, { message: 'Agent ID is required' });\n }\n\n if (!body?.audioData) {\n throw new HTTPException(400, { message: 'Audio data is required' });\n }\n\n const agent = mastra.getAgent(agentId);\n\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const voice = await agent.getVoice({ runtimeContext });\n\n if (!voice) {\n throw new HTTPException(400, { message: 'Agent does not have voice capabilities' });\n }\n\n const audioStream = new Readable();\n audioStream.push(body.audioData);\n audioStream.push(null);\n\n const text = await voice.listen(audioStream, body.options);\n return { text };\n } catch (error) {\n return handleError(error, 'Error transcribing speech');\n }\n}\n\n/**\n * Get available listeners for an agent\n */\nexport async function getListenerHandler({ mastra, agentId, runtimeContext }: VoiceContext) {\n try {\n if (!agentId) {\n throw new HTTPException(400, { message: 'Agent ID is required' });\n }\n\n const agent = mastra.getAgent(agentId);\n\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const voice = await agent.getVoice({ runtimeContext });\n\n if (!voice) {\n throw new HTTPException(400, { message: 'Agent does not have voice capabilities' });\n }\n\n const listeners = await voice.getListener();\n return listeners;\n } catch (error) {\n return handleError(error, 'Error getting listeners');\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"agent-builder.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/agent-builder.ts"],"names":[],"mappings":"AAC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AS,MAAM,aAAa,CAAC;AAEzC,UAAU,mBAAoB,SAAQ,OAAO;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAoDD,eAAO,MAAM,6BAA6B,6EAcP,CAAC;AAEpC,eAAO,MAAM,gCAAgC,yFAG5C,CAAC;AAEF,eAAO,MAAM,mCAAmC,wKAG/C,CAAC;AAEF,eAAO,MAAM,8CAA8C;;;;cA2Dgd,CAAC;eAA8C,CAAC;qBAAoD,CAAC;aAA4C,CAAC;;;mBAAiH,CAAC;iBAAmC,CAAC;;;;;EAxDlzB,CAAC;AAEF,eAAO,MAAM,kCAAkC;;EAG9C,CAAC;AAEF,eAAO,MAAM,mCAAmC;;;qMAG/C,CAAC;AAEF,eAAO,MAAM,iCAAiC;;;;;EAG7C,CAAC;AAEF,eAAO,MAAM,8BAA8B;;gFAG1C,CAAC;AAEF,eAAO,MAAM,+BAA+B;;;;;;EAG3C,CAAC;AAEF,eAAO,MAAM,oCAAoC;;;gFAGhD,CAAC;AAEF,eAAO,MAAM,oCAAoC;;;kBAwBisL,CAAC;;;qMArBlvL,CAAC;AAEF,eAAO,MAAM,+BAA+B;;;kBAmBo3N,CAAC;;;;;EAhBh6N,CAAC;AAEF,eAAO,MAAM,gCAAgC;;;;;;wEAG5C,CAAC;AAEF,eAAO,MAAM,kCAAkC;;EAG9C,CAAC;AAEF,eAAO,MAAM,qCAAqC;;;;;EAGjD,CAAC"}
@@ -1,24 +1,24 @@
1
1
  'use strict';
2
2
 
3
- var chunkYOPL5HWA_cjs = require('../../chunk-YOPL5HWA.cjs');
3
+ var chunkNLWACBE7_cjs = require('../../chunk-NLWACBE7.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "generateSpeechHandler", {
8
8
  enumerable: true,
9
- get: function () { return chunkYOPL5HWA_cjs.generateSpeechHandler; }
9
+ get: function () { return chunkNLWACBE7_cjs.generateSpeechHandler; }
10
10
  });
11
11
  Object.defineProperty(exports, "getListenerHandler", {
12
12
  enumerable: true,
13
- get: function () { return chunkYOPL5HWA_cjs.getListenerHandler; }
13
+ get: function () { return chunkNLWACBE7_cjs.getListenerHandler; }
14
14
  });
15
15
  Object.defineProperty(exports, "getSpeakersHandler", {
16
16
  enumerable: true,
17
- get: function () { return chunkYOPL5HWA_cjs.getSpeakersHandler; }
17
+ get: function () { return chunkNLWACBE7_cjs.getSpeakersHandler; }
18
18
  });
19
19
  Object.defineProperty(exports, "transcribeSpeechHandler", {
20
20
  enumerable: true,
21
- get: function () { return chunkYOPL5HWA_cjs.transcribeSpeechHandler; }
21
+ get: function () { return chunkNLWACBE7_cjs.transcribeSpeechHandler; }
22
22
  });
23
23
  //# sourceMappingURL=voice.cjs.map
24
24
  //# sourceMappingURL=voice.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"voice.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/voice.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAKxC,UAAU,YAAa,SAAQ,OAAO;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,YAAY;;KAuBzF;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,EAC1C,MAAM,EACN,OAAO,EACP,IAAI,EACJ,cAAc,GACf,EAAE,YAAY,GAAG;IAChB,IAAI,CAAC,EAAE;QACL,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,kCAgCA;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,EAC5C,MAAM,EACN,O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AAO,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAChE,CAAC;CACH;;GA+BA;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,YAAY;;GAuBzF"}
@@ -1,3 +1,3 @@
1
- export { generateSpeechHandler, getListenerHandler, getSpeakersHandler, transcribeSpeechHandler } from '../../chunk-J373SDWK.js';
1
+ export { generateSpeechHandler, getListenerHandler, getSpeakersHandler, transcribeSpeechHandler } from '../../chunk-JRDEOHAJ.js';
2
2
  //# sourceMappingURL=voice.js.map
3
3
  //# sourceMappingURL=voice.js.map
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkT3TIA3O6_cjs = require('../chunk-T3TIA3O6.cjs');
4
- var chunkYOPL5HWA_cjs = require('../chunk-YOPL5HWA.cjs');
4
+ var chunkNLWACBE7_cjs = require('../chunk-NLWACBE7.cjs');
5
5
  var chunkSPLSYTYW_cjs = require('../chunk-SPLSYTYW.cjs');
6
6
  var chunkOZLRIVC4_cjs = require('../chunk-OZLRIVC4.cjs');
7
7
  var chunkIY34NOLA_cjs = require('../chunk-IY34NOLA.cjs');
@@ -23,7 +23,7 @@ Object.defineProperty(exports, "vector", {
23
23
  });
24
24
  Object.defineProperty(exports, "voice", {
25
25
  enumerable: true,
26
- get: function () { return chunkYOPL5HWA_cjs.voice_exports; }
26
+ get: function () { return chunkNLWACBE7_cjs.voice_exports; }
27
27
  });
28
28
  Object.defineProperty(exports, "logs", {
29
29
  enumerable: true,
@@ -1,5 +1,5 @@
1
1
  export { vector_exports as vector } from '../chunk-WHN4VX55.js';
2
- export { voice_exports as voice } from '../chunk-J373SDWK.js';
2
+ export { voice_exports as voice } from '../chunk-JRDEOHAJ.js';
3
3
  export { logs_exports as logs } from '../chunk-A3AL7EWJ.js';
4
4
  export { memory_exports as memory } from '../chunk-SQY4T6EJ.js';
5
5
  export { network_exports as network } from '../chunk-U46VIX2V.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/server",
3
- "version": "0.16.3-alpha.1",
3
+ "version": "0.16.4-alpha.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -78,11 +78,11 @@
78
78
  "typescript": "^5.8.3",
79
79
  "vitest": "^3.2.4",
80
80
  "zod": "^3.25.76",
81
- "@internal/lint": "0.0.38",
82
- "@internal/storage-test-utils": "0.0.34",
83
- "@internal/types-builder": "0.0.13",
84
- "@mastra/core": "0.16.3-alpha.1",
85
- "@mastra/agent-builder": "0.0.4-alpha.0"
81
+ "@internal/lint": "0.0.39",
82
+ "@mastra/core": "0.16.4-alpha.0",
83
+ "@mastra/agent-builder": "0.0.4",
84
+ "@internal/types-builder": "0.0.14",
85
+ "@internal/storage-test-utils": "0.0.35"
86
86
  },
87
87
  "homepage": "https://mastra.ai",
88
88
  "repository": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/server/handlers/voice.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,aAAA,GAAA;AAAA,QAAA,CAAA,aAAA,EAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,kBAAA,EAAA,MAAA,kBAAA;AAAA,EAAA,kBAAA,EAAA,MAAA,kBAAA;AAAA,EAAA,uBAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAiBA,eAAsB,kBAAA,CAAmB,EAAE,MAAA,EAAQ,OAAA,EAAS,gBAAe,EAAiB;AAC1F,EAAA,IAAI;AACF,IAAA,IAAI,CAAC,OAAA,EAAS;AACZ,MAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,wBAAwB,CAAA;AAAA,IAClE;AAEA,IAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,QAAA,CAAS,OAAO,CAAA;AAEr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AAA,CAAK,KAAK,SAAS,CAAA;AAC/B,IAAA,WAAA,CAAY,KAAK,IAAI,CAAA;AAErB,IAAA,MAAM,OAAO,MAAM,KAAA,CAAM,MAAA,CAAO,WAAA,EAAa,KAAK,OAAO,CAAA;AACzD,IAAA,OAAO,EAAE,IAAA,EAAK;AAAA,EAChB,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,WAAA,CAAY,OAAO,2BAA2B,CAAA;AAAA,EACvD;AACF;AAKA,eAAsB,kBAAA,CAAmB,EAAE,MAAA,EAAQ,OAAA,EAAS,gBAAe,EAAiB;AAC1F,EAAA,IAAI;AACF,IAAA,IAAI,CAAC,OAAA,EAAS;AACZ,MAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,wBAAwB,CAAA;AAAA,IAClE;AAEA,IAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,QAAA,CAAS,OAAO,CAAA;AAErC,IAAA,IAAI,CAAC,KAAA,EAAO;AACV,MAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,mBAAmB,CAAA;AAAA,IAC7D;AAEA,IAAA,MAAM,QAAQ,MAAM,KAAA,CAAM,QAAA,CAAS,EAAE,gBAAgB,CAAA;AAErD,IAAA,IAAI,CAAC,KAAA,EAAO;AACV,MAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,0CAA0C,CAAA;AAAA,IACpF;AAEA,IAAA,MAAM,SAAA,GAAY,MAAM,KAAA,CAAM,WAAA,EAAY;AAC1C,IAAA,OAAO,SAAA;AAAA,EACT,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,WAAA,CAAY,OAAO,yBAAyB,CAAA;AAAA,EACrD;AACF","file":"chunk-J373SDWK.js","sourcesContent":["import { Readable } from 'stream';\nimport type { Agent } from '@mastra/core/agent';\nimport type { RuntimeContext } from '@mastra/core/runtime-context';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\n\nimport { handleError } from './error';\nimport { validateBody } from './utils';\n\ninterface VoiceContext extends Context {\n agentId?: string;\n runtimeContext?: RuntimeContext;\n}\n\n/**\n * Get available speakers for an agent\n */\nexport async function getSpeakersHandler({ mastra, agentId, runtimeContext }: VoiceContext) {\n try {\n if (!agentId) {\n throw new HTTPException(400, { message: 'Agent ID is required' });\n }\n\n const agent = mastra.getAgent(agentId);\n\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const voice = await agent.getVoice({ runtimeContext });\n\n if (!voice) {\n throw new HTTPException(400, { message: 'Agent does not have voice capabilities' });\n }\n\n const speakers = await voice.getSpeakers();\n return speakers;\n } catch (error) {\n return handleError(error, 'Error getting speakers');\n }\n}\n\n/**\n * Generate speech from text\n */\nexport async function generateSpeechHandler({\n mastra,\n agentId,\n body,\n runtimeContext,\n}: VoiceContext & {\n body?: {\n text?: string;\n speakerId?: string;\n };\n}) {\n try {\n if (!agentId) {\n throw new HTTPException(400, { message: 'Agent ID is required' });\n }\n\n validateBody({\n text: body?.text,\n });\n\n const agent = mastra.getAgent(agentId);\n\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const voice = await agent.getVoice({ runtimeContext });\n\n if (!voice) {\n throw new HTTPException(400, { message: 'Agent does not have voice capabilities' });\n }\n\n const audioStream = await voice.speak(body!.text!, { speaker: body!.speakerId! });\n\n if (!audioStream) {\n throw new HTTPException(500, { message: 'Failed to generate speech' });\n }\n\n return audioStream;\n } catch (error) {\n return handleError(error, 'Error generating speech');\n }\n}\n\n/**\n * Transcribe speech to text\n */\nexport async function transcribeSpeechHandler({\n mastra,\n agentId,\n body,\n runtimeContext,\n}: VoiceContext & {\n body?: {\n audioData?: Buffer;\n options?: Parameters<NonNullable<Agent['voice']>['listen']>[1];\n };\n}) {\n try {\n if (!agentId) {\n throw new HTTPException(400, { message: 'Agent ID is required' });\n }\n\n if (!body?.audioData) {\n throw new HTTPException(400, { message: 'Audio data is required' });\n }\n\n const agent = mastra.getAgent(agentId);\n\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const voice = await agent.getVoice({ runtimeContext });\n\n if (!voice) {\n throw new HTTPException(400, { message: 'Agent does not have voice capabilities' });\n }\n\n const audioStream = new Readable();\n audioStream.push(body.audioData);\n audioStream.push(null);\n\n const text = await voice.listen(audioStream, body.options);\n return { text };\n } catch (error) {\n return handleError(error, 'Error transcribing speech');\n }\n}\n\n/**\n * Get available listeners for an agent\n */\nexport async function getListenerHandler({ mastra, agentId, runtimeContext }: VoiceContext) {\n try {\n if (!agentId) {\n throw new HTTPException(400, { message: 'Agent ID is required' });\n }\n\n const agent = mastra.getAgent(agentId);\n\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const voice = await agent.getVoice({ runtimeContext });\n\n if (!voice) {\n throw new HTTPException(400, { message: 'Agent does not have voice capabilities' });\n }\n\n const listeners = await voice.getListener();\n return listeners;\n } catch (error) {\n return handleError(error, 'Error getting listeners');\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/server/handlers/voice.ts"],"names":["__export","HTTPException","handleError","validateBody","Readable"],"mappings":";;;;;;;;;AAAA,IAAA,aAAA,GAAA;AAAAA,0BAAA,CAAA,aAAA,EAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,kBAAA,EAAA,MAAA,kBAAA;AAAA,EAAA,kBAAA,EAAA,MAAA,kBAAA;AAAA,EAAA,uBAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAiBA,eAAsB,kBAAA,CAAmB,EAAE,MAAA,EAAQ,OAAA,EAAS,gBAAe,EAAiB;AAC1F,EAAA,IAAI;AACF,IAAA,IAAI,CAAC,OAAA,EAAS;AACZ,MAAA,MAAM,IAAIC,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,wBAAwB,CAAA;AAAA,IAClE;AAEA,IAAA,MAAM,KAAA,GAAQ,MAAA,CAA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ent';\nimport type { RuntimeContext } from '@mastra/core/runtime-context';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\n\nimport { handleError } from './error';\nimport { validateBody } from './utils';\n\ninterface VoiceContext extends Context {\n agentId?: string;\n runtimeContext?: RuntimeContext;\n}\n\n/**\n * Get available speakers for an agent\n */\nexport async function getSpeakersHandler({ mastra, agentId, runtimeContext }: VoiceContext) {\n try {\n if (!agentId) {\n throw new HTTPException(400, { message: 'Agent ID is required' });\n }\n\n const agent = mastra.getAgent(agentId);\n\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const voice = await agent.getVoice({ runtimeContext });\n\n if (!voice) {\n throw new HTTPException(400, { message: 'Agent does not have voice capabilities' });\n }\n\n const speakers = await voice.getSpeakers();\n return speakers;\n } catch (error) {\n return handleError(error, 'Error getting speakers');\n }\n}\n\n/**\n * Generate speech from text\n */\nexport async function generateSpeechHandler({\n mastra,\n agentId,\n body,\n runtimeContext,\n}: VoiceContext & {\n body?: {\n text?: string;\n speakerId?: string;\n };\n}) {\n try {\n if (!agentId) {\n throw new HTTPException(400, { message: 'Agent ID is required' });\n }\n\n validateBody({\n text: body?.text,\n });\n\n const agent = mastra.getAgent(agentId);\n\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const voice = await agent.getVoice({ runtimeContext });\n\n if (!voice) {\n throw new HTTPException(400, { message: 'Agent does not have voice capabilities' });\n }\n\n const audioStream = await voice.speak(body!.text!, { speaker: body!.speakerId! });\n\n if (!audioStream) {\n throw new HTTPException(500, { message: 'Failed to generate speech' });\n }\n\n return audioStream;\n } catch (error) {\n return handleError(error, 'Error generating speech');\n }\n}\n\n/**\n * Transcribe speech to text\n */\nexport async function transcribeSpeechHandler({\n mastra,\n agentId,\n body,\n runtimeContext,\n}: VoiceContext & {\n body?: {\n audioData?: Buffer;\n options?: Parameters<NonNullable<Agent['voice']>['listen']>[1];\n };\n}) {\n try {\n if (!agentId) {\n throw new HTTPException(400, { message: 'Agent ID is required' });\n }\n\n if (!body?.audioData) {\n throw new HTTPException(400, { message: 'Audio data is required' });\n }\n\n const agent = mastra.getAgent(agentId);\n\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const voice = await agent.getVoice({ runtimeContext });\n\n if (!voice) {\n throw new HTTPException(400, { message: 'Agent does not have voice capabilities' });\n }\n\n const audioStream = new Readable();\n audioStream.push(body.audioData);\n audioStream.push(null);\n\n const text = await voice.listen(audioStream, body.options);\n return { text };\n } catch (error) {\n return handleError(error, 'Error transcribing speech');\n }\n}\n\n/**\n * Get available listeners for an agent\n */\nexport async function getListenerHandler({ mastra, agentId, runtimeContext }: VoiceContext) {\n try {\n if (!agentId) {\n throw new HTTPException(400, { message: 'Agent ID is required' });\n }\n\n const agent = mastra.getAgent(agentId);\n\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const voice = await agent.getVoice({ runtimeContext });\n\n if (!voice) {\n throw new HTTPException(400, { message: 'Agent does not have voice capabilities' });\n }\n\n const listeners = await voice.getListener();\n return listeners;\n } catch (error) {\n return handleError(error, 'Error getting listeners');\n }\n}\n"]}