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