@mastra/ai-sdk 1.9.1 → 1.10.0-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/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;AAE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,oBAAoB,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
@@ -13648,8 +13648,14 @@ function assertValidHeartbeatMs(heartbeatMs) {
13648
13648
  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
13649
  }
13650
13650
  /**
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.
13651
+ * Wraps an SSE `Response` so it emits periodic `: heartbeat` comments while the source is idle,
13652
+ * keeping connections alive through proxies that close idle streams.
13653
+ *
13654
+ * Heartbeats are only inserted between complete SSE frames. AI SDK serialization uses LF-delimited
13655
+ * frames, which this wrapper preserves and relies on.
13656
+ *
13657
+ * Returns the input response unchanged when `heartbeatMs` is omitted, is `<= 0`, or the response has
13658
+ * no body. Throws a `RangeError` when `heartbeatMs` is enabled but cannot be scheduled with a timer.
13653
13659
  */
13654
13660
  function withSseHeartbeat(response, heartbeatMs) {
13655
13661
  assertValidHeartbeatMs(heartbeatMs);
@@ -15241,6 +15247,6 @@ function toAISdkFormat() {
15241
15247
  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
15248
  }
15243
15249
  //#endregion
15244
- export { chatRoute, handleChatStream, handleNetworkStream, handleWorkflowStream, networkRoute, smoothStream, toAISdkFormat, toAISdkStream, toAISdkV5Stream, withMastra, workflowRoute, workflowSnapshotToStream };
15250
+ export { assertValidHeartbeatMs, chatRoute, handleChatStream, handleNetworkStream, handleWorkflowStream, networkRoute, smoothStream, toAISdkFormat, toAISdkStream, toAISdkV5Stream, withMastra, withSseHeartbeat, workflowRoute, workflowSnapshotToStream };
15245
15251
 
15246
15252
  //# sourceMappingURL=index.js.map