@mastra/ai-sdk 1.9.1 → 1.10.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/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export { toAISdkStream, toAISdkV5Stream } from './convert-streams.js';
11
11
  export { workflowSnapshotToStream } from './convert-snapshot.js';
12
12
  export { smoothStream } from './smooth-stream.js';
13
13
  export type { MastraStreamTransform, MastraStreamTransformOptions } from './smooth-stream.js';
14
+ export { withSseHeartbeat, assertValidHeartbeatMs } from './sse-heartbeat.js';
14
15
  export { withMastra } from './middleware.js';
15
16
  export type { WithMastraOptions, WithMastraMemoryOptions, WithMastraSemanticRecallOptions } from './middleware.js';
16
17
  export { toAISdkFormat } from './to-ai-sdk-format.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC3D,YAAY,EACV,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACvE,YAAY,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AACxH,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACpE,YAAY,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AACpH,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEvE,OAA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B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAG3E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,+BAA+B,EAAE,MAAM,cAAc,CAAC;AAGhH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import { MASTRA_RESOURCE_ID_KEY } from "@mastra/core/request-context";
9
9
  import { MessageList, TripWire, aiV5ModelMessageToV2PromptMessage } from "@mastra/core/agent";
10
10
  import { RequestContext } from "@mastra/core/di";
11
11
  import { MessageHistory, SemanticRecall, WorkingMemory } from "@mastra/core/processors";
12
- //#region ../../packages/_vendored/ai_v5/dist/dist-BuEMdYEn.js
12
+ //#region ../../packages/_vendored/ai_v5/dist/dist-nVfjvSbw.js
13
13
  var marker$1$6 = "vercel.ai.error";
14
14
  var symbol$1$7 = Symbol.for(marker$1$6);
15
15
  var _a$1$7;
@@ -536,6 +536,7 @@ async function cancelResponseBody$2(response) {
536
536
  var initialGlobalFetch$2 = globalThis.fetch;
537
537
  isNodeDefaultFetch$2(initialGlobalFetch$2);
538
538
  function isNodeDefaultFetch$2(fetch) {
539
+ if (typeof fetch !== "function") return false;
539
540
  const source = Function.prototype.toString.call(fetch);
540
541
  return source.includes("internal/deps/undici") || source.includes("lazy loading of undici");
541
542
  }
@@ -5026,7 +5027,7 @@ function createUIMessageStream$2({ execute, onError = () => "An error occurred."
5026
5027
  });
5027
5028
  }
5028
5029
  //#endregion
5029
- //#region ../../packages/_vendored/ai_v6/dist/dist-BTWHzT8H.js
5030
+ //#region ../../packages/_vendored/ai_v6/dist/dist-Gd4EIxPM.js
5030
5031
  var marker$1$4 = "vercel.ai.error";
5031
5032
  var symbol$1$4 = Symbol.for(marker$1$4);
5032
5033
  var _a$1$4;
@@ -5369,6 +5370,7 @@ var _b$2;
5369
5370
  var initialGlobalFetch$1 = globalThis.fetch;
5370
5371
  isNodeDefaultFetch$1(initialGlobalFetch$1);
5371
5372
  function isNodeDefaultFetch$1(fetch) {
5373
+ if (typeof fetch !== "function") return false;
5372
5374
  const source = Function.prototype.toString.call(fetch);
5373
5375
  return source.includes("internal/deps/undici") || source.includes("lazy loading of undici");
5374
5376
  }
@@ -13648,8 +13650,14 @@ function assertValidHeartbeatMs(heartbeatMs) {
13648
13650
  if (heartbeatMs !== void 0 && !(heartbeatMs <= 0) && (!Number.isFinite(heartbeatMs) || heartbeatMs > MAX_TIMEOUT_MS)) throw new RangeError(`heartbeatMs must be a finite number no greater than ${MAX_TIMEOUT_MS}`);
13649
13651
  }
13650
13652
  /**
13651
- * Adds periodic SSE comment heartbeats to an AI SDK response body.
13652
- * AI SDK serialization uses LF-delimited frames, which this private wrapper preserves and relies on.
13653
+ * Wraps an SSE `Response` so it emits periodic `: heartbeat` comments while the source is idle,
13654
+ * keeping connections alive through proxies that close idle streams.
13655
+ *
13656
+ * Heartbeats are only inserted between complete SSE frames. AI SDK serialization uses LF-delimited
13657
+ * frames, which this wrapper preserves and relies on.
13658
+ *
13659
+ * Returns the input response unchanged when `heartbeatMs` is omitted, is `<= 0`, or the response has
13660
+ * no body. Throws a `RangeError` when `heartbeatMs` is enabled but cannot be scheduled with a timer.
13653
13661
  */
13654
13662
  function withSseHeartbeat(response, heartbeatMs) {
13655
13663
  assertValidHeartbeatMs(heartbeatMs);
@@ -15241,6 +15249,6 @@ function toAISdkFormat() {
15241
15249
  throw new Error("toAISdkFormat() has been deprecated. Please use toAISdkStream() instead.\n\nMigration:\n import { toAISdkFormat } from \"@mastra/ai-sdk\";\n // Change to:\n import { toAISdkStream } from \"@mastra/ai-sdk\";\n\nThe function signature remains the same.");
15242
15250
  }
15243
15251
  //#endregion
15244
- export { chatRoute, handleChatStream, handleNetworkStream, handleWorkflowStream, networkRoute, smoothStream, toAISdkFormat, toAISdkStream, toAISdkV5Stream, withMastra, workflowRoute, workflowSnapshotToStream };
15252
+ export { assertValidHeartbeatMs, chatRoute, handleChatStream, handleNetworkStream, handleWorkflowStream, networkRoute, smoothStream, toAISdkFormat, toAISdkStream, toAISdkV5Stream, withMastra, withSseHeartbeat, workflowRoute, workflowSnapshotToStream };
15245
15253
 
15246
15254
  //# sourceMappingURL=index.js.map