@mastra/ai-sdk 0.0.0-netlify-no-bundle-20251127120354 → 0.0.0-partial-response-backport-20251204204441

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.cjs CHANGED
@@ -1202,15 +1202,15 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
1202
1202
  }
1203
1203
  }
1204
1204
 
1205
- // src/convert-streams.ts
1206
- function toAISdkV5Stream(stream, options = {
1205
+ // src/to-ai-sdk-format.ts
1206
+ function toAISdkFormat(stream, options = {
1207
1207
  from: "agent",
1208
1208
  sendStart: true,
1209
1209
  sendFinish: true
1210
1210
  }) {
1211
1211
  const from = options?.from;
1212
1212
  if (from === "workflow") {
1213
- const includeTextStreamParts = options?.includeTextStreamParts ?? true;
1213
+ const includeTextStreamParts = options?.includeTextStreamParts ?? false;
1214
1214
  return stream.pipeThrough(
1215
1215
  WorkflowStreamToAISDKTransformer({ includeTextStreamParts })
1216
1216
  );
@@ -1341,7 +1341,7 @@ function chatRoute({
1341
1341
  handler: async (c) => {
1342
1342
  const { messages, ...rest } = await c.req.json();
1343
1343
  const mastra = c.get("mastra");
1344
- const requestContext = c.get("requestContext");
1344
+ const runtimeContext = c.get("runtimeContext");
1345
1345
  let agentToUse = agent;
1346
1346
  if (!agent) {
1347
1347
  const agentId = c.req.param("agentId");
@@ -1352,8 +1352,8 @@ function chatRoute({
1352
1352
  `Fixed agent ID was set together with an agentId path parameter. This can lead to unexpected behavior.`
1353
1353
  );
1354
1354
  }
1355
- if (requestContext && defaultOptions?.requestContext) {
1356
- mastra.getLogger()?.warn(`"requestContext" set in the route options will be overridden by the request's "requestContext".`);
1355
+ if (runtimeContext && defaultOptions?.runtimeContext) {
1356
+ mastra.getLogger()?.warn(`"runtimeContext" set in the route options will be overridden by the request's "runtimeContext".`);
1357
1357
  }
1358
1358
  if (!agentToUse) {
1359
1359
  throw new Error("Agent ID is required");
@@ -1365,7 +1365,7 @@ function chatRoute({
1365
1365
  const result = await agentObj.stream(messages, {
1366
1366
  ...defaultOptions,
1367
1367
  ...rest,
1368
- requestContext: requestContext || defaultOptions?.requestContext
1368
+ runtimeContext: runtimeContext || defaultOptions?.runtimeContext
1369
1369
  });
1370
1370
  let lastMessageId;
1371
1371
  if (messages.length > 0 && messages[messages.length - 1].role === "assistant") {
@@ -1374,7 +1374,7 @@ function chatRoute({
1374
1374
  const uiMessageStream = ai.createUIMessageStream({
1375
1375
  originalMessages: messages,
1376
1376
  execute: async ({ writer }) => {
1377
- for await (const part of toAISdkV5Stream(result, {
1377
+ for await (const part of toAISdkFormat(result, {
1378
1378
  from: "agent",
1379
1379
  lastMessageId,
1380
1380
  sendStart,
@@ -1395,7 +1395,7 @@ function chatRoute({
1395
1395
  function workflowRoute({
1396
1396
  path = "/api/workflows/:workflowId/stream",
1397
1397
  workflow,
1398
- includeTextStreamParts = true
1398
+ includeTextStreamParts = false
1399
1399
  }) {
1400
1400
  if (!workflow && !path.includes("/:workflowId")) {
1401
1401
  throw new Error("Path must include :workflowId to route to the correct workflow or pass the workflow explicitly");
@@ -1426,7 +1426,7 @@ function workflowRoute({
1426
1426
  resourceId: { type: "string" },
1427
1427
  inputData: { type: "object", additionalProperties: true },
1428
1428
  resumeData: { type: "object", additionalProperties: true },
1429
- requestContext: { type: "object", additionalProperties: true },
1429
+ runtimeContext: { type: "object", additionalProperties: true },
1430
1430
  tracingOptions: { type: "object", additionalProperties: true },
1431
1431
  step: { type: "string" }
1432
1432
  }
@@ -1448,7 +1448,7 @@ function workflowRoute({
1448
1448
  handler: async (c) => {
1449
1449
  const { runId, resourceId, inputData, resumeData, ...rest } = await c.req.json();
1450
1450
  const mastra = c.get("mastra");
1451
- const requestContext = c.get("requestContext");
1451
+ const runtimeContext = c.get("runtimeContext");
1452
1452
  let workflowToUse = workflow;
1453
1453
  if (!workflow) {
1454
1454
  const workflowId = c.req.param("workflowId");
@@ -1466,16 +1466,16 @@ function workflowRoute({
1466
1466
  if (!workflowObj) {
1467
1467
  throw new Error(`Workflow ${workflowToUse} not found`);
1468
1468
  }
1469
- if (requestContext && rest.requestContext) {
1469
+ if (runtimeContext && rest.runtimeContext) {
1470
1470
  mastra.getLogger()?.warn(
1471
- `"requestContext" from the request body will be ignored because "requestContext" is already set in the route options.`
1471
+ `"runtimeContext" from the request body will be ignored because "runtimeContext" is already set in the route options.`
1472
1472
  );
1473
1473
  }
1474
- const run = await workflowObj.createRun({ runId, resourceId, ...rest });
1475
- const stream = resumeData ? run.resumeStream({ resumeData, ...rest, requestContext: requestContext || rest.requestContext }) : run.stream({ inputData, ...rest, requestContext: requestContext || rest.requestContext });
1474
+ const run = await workflowObj.createRunAsync({ runId, resourceId, ...rest });
1475
+ const stream = resumeData ? run.resumeStream({ resumeData, ...rest, runtimeContext: runtimeContext || rest.runtimeContext }) : run.stream({ inputData, ...rest, runtimeContext: runtimeContext || rest.runtimeContext });
1476
1476
  const uiMessageStream = ai.createUIMessageStream({
1477
1477
  execute: async ({ writer }) => {
1478
- for await (const part of toAISdkV5Stream(stream, { from: "workflow", includeTextStreamParts })) {
1478
+ for await (const part of toAISdkFormat(stream, { from: "workflow", includeTextStreamParts })) {
1479
1479
  writer.write(part);
1480
1480
  }
1481
1481
  }
@@ -1515,12 +1515,13 @@ function networkRoute({
1515
1515
  type: "object",
1516
1516
  properties: {
1517
1517
  messages: { type: "array", items: { type: "object" } },
1518
- requestContext: { type: "object", additionalProperties: true },
1518
+ runtimeContext: { type: "object", additionalProperties: true },
1519
1519
  runId: { type: "string" },
1520
1520
  maxSteps: { type: "number" },
1521
1521
  threadId: { type: "string" },
1522
1522
  resourceId: { type: "string" },
1523
1523
  modelSettings: { type: "object", additionalProperties: true },
1524
+ telemetry: { type: "object", additionalProperties: true },
1524
1525
  tools: { type: "array", items: { type: "object" } }
1525
1526
  },
1526
1527
  required: ["messages"]
@@ -1569,7 +1570,7 @@ function networkRoute({
1569
1570
  });
1570
1571
  const uiMessageStream = ai.createUIMessageStream({
1571
1572
  execute: async ({ writer }) => {
1572
- for await (const part of toAISdkV5Stream(result, { from: "network" })) {
1573
+ for await (const part of toAISdkFormat(result, { from: "network" })) {
1573
1574
  writer.write(part);
1574
1575
  }
1575
1576
  }
@@ -1579,17 +1580,9 @@ function networkRoute({
1579
1580
  });
1580
1581
  }
1581
1582
 
1582
- // src/to-ai-sdk-format.ts
1583
- function toAISdkFormat() {
1584
- throw new Error(
1585
- '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.'
1586
- );
1587
- }
1588
-
1589
1583
  exports.chatRoute = chatRoute;
1590
1584
  exports.networkRoute = networkRoute;
1591
1585
  exports.toAISdkFormat = toAISdkFormat;
1592
- exports.toAISdkStream = toAISdkV5Stream;
1593
1586
  exports.workflowRoute = workflowRoute;
1594
1587
  //# sourceMappingURL=index.cjs.map
1595
1588
  //# sourceMappingURL=index.cjs.map