@mastra/ai-sdk 1.5.1 → 1.6.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
@@ -8,6 +8,7 @@ export type { NetworkRouteOptions, NetworkStreamHandlerParams, NetworkStreamHand
8
8
  export type { NetworkDataPart } from './transformers.js';
9
9
  export type { AgentDataPart } from './transformers.js';
10
10
  export { toAISdkStream, toAISdkV5Stream } from './convert-streams.js';
11
+ export { workflowSnapshotToStream } from './convert-snapshot.js';
11
12
  export { withMastra } from './middleware.js';
12
13
  export type { WithMastraOptions, WithMastraMemoryOptions, WithMastraSemanticRecallOptions } from './middleware.js';
13
14
  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,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,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGnE,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"}
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,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,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAG9D,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
@@ -14496,6 +14496,69 @@ function networkRoute({
14496
14496
  }
14497
14497
  });
14498
14498
  }
14499
+
14500
+ // src/convert-snapshot.ts
14501
+ function workflowSnapshotToStream(workflowRun) {
14502
+ const steps = workflowStateToSteps(workflowRun.steps ?? {});
14503
+ const current = { name: workflowRun.workflowName, steps };
14504
+ const runId = workflowRun.runId;
14505
+ const status = workflowRun.status;
14506
+ return new ReadableStream({
14507
+ start(controller) {
14508
+ controller.enqueue({ type: "start" });
14509
+ controller.enqueue(
14510
+ createWorkflowDataPart({
14511
+ current,
14512
+ runId,
14513
+ status,
14514
+ includeOutputs: true,
14515
+ output: null
14516
+ })
14517
+ );
14518
+ for (const stepId of Object.keys(steps)) {
14519
+ controller.enqueue(
14520
+ createWorkflowStepDataPart({
14521
+ current,
14522
+ runId,
14523
+ status,
14524
+ stepId
14525
+ })
14526
+ );
14527
+ }
14528
+ controller.enqueue({ type: "finish" });
14529
+ controller.close();
14530
+ }
14531
+ });
14532
+ }
14533
+ function workflowStateToSteps(stateSteps) {
14534
+ const steps = {};
14535
+ for (const [key, value] of Object.entries(stateSteps)) {
14536
+ const stepResult = Array.isArray(value) ? mergeForEachStepResult(value) : value;
14537
+ if (!stepResult || typeof stepResult !== "object" || !("status" in stepResult)) continue;
14538
+ steps[key] = {
14539
+ name: key,
14540
+ status: stepResult.status,
14541
+ input: stepResult.payload ?? null,
14542
+ output: stepResult.output ?? null,
14543
+ suspendPayload: stepResult.suspendPayload ?? null,
14544
+ resumePayload: stepResult.resumePayload ?? null
14545
+ };
14546
+ }
14547
+ return steps;
14548
+ }
14549
+ function mergeForEachStepResult(results) {
14550
+ const stepResults = results.filter(
14551
+ (result) => !!result && typeof result === "object" && "status" in result
14552
+ );
14553
+ if (stepResults.length === 0) return void 0;
14554
+ const representative = stepResults.find((result) => result.status === "suspended") ?? stepResults.find((result) => result.status === "failed") ?? stepResults[0];
14555
+ if (!representative) return void 0;
14556
+ return {
14557
+ ...representative,
14558
+ payload: stepResults.map((result) => result.payload),
14559
+ output: stepResults.map((result) => result.output)
14560
+ };
14561
+ }
14499
14562
  function withMastra(model, options = {}) {
14500
14563
  const { memory, inputProcessors = [], outputProcessors = [] } = options;
14501
14564
  const allInputProcessors = [...inputProcessors];
@@ -15185,6 +15248,6 @@ function toAISdkFormat() {
15185
15248
  );
15186
15249
  }
15187
15250
 
15188
- export { chatRoute, handleChatStream, handleNetworkStream, handleWorkflowStream, networkRoute, toAISdkFormat, toAISdkStream, toAISdkV5Stream, withMastra, workflowRoute };
15251
+ export { chatRoute, handleChatStream, handleNetworkStream, handleWorkflowStream, networkRoute, toAISdkFormat, toAISdkStream, toAISdkV5Stream, withMastra, workflowRoute, workflowSnapshotToStream };
15189
15252
  //# sourceMappingURL=index.js.map
15190
15253
  //# sourceMappingURL=index.js.map