@openrouter/ai-sdk-provider 1.0.0-beta.5 → 1.0.0-beta.6

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.
@@ -1584,21 +1584,6 @@ var OpenRouterChatLanguageModel = class {
1584
1584
  return;
1585
1585
  }
1586
1586
  const delta = choice.delta;
1587
- if (delta.content != null) {
1588
- if (!textStarted) {
1589
- textId = openrouterResponseId || generateId();
1590
- controller.enqueue({
1591
- type: "text-start",
1592
- id: textId
1593
- });
1594
- textStarted = true;
1595
- }
1596
- controller.enqueue({
1597
- type: "text-delta",
1598
- delta: delta.content,
1599
- id: textId || generateId()
1600
- });
1601
- }
1602
1587
  const emitReasoningChunk = (chunkText) => {
1603
1588
  if (!reasoningStarted) {
1604
1589
  reasoningId = openrouterResponseId || generateId();
@@ -1614,9 +1599,6 @@ var OpenRouterChatLanguageModel = class {
1614
1599
  id: reasoningId || generateId()
1615
1600
  });
1616
1601
  };
1617
- if (delta.reasoning != null) {
1618
- emitReasoningChunk(delta.reasoning);
1619
- }
1620
1602
  if (delta.reasoning_details && delta.reasoning_details.length > 0) {
1621
1603
  for (const detail of delta.reasoning_details) {
1622
1604
  switch (detail.type) {
@@ -1644,6 +1626,23 @@ var OpenRouterChatLanguageModel = class {
1644
1626
  }
1645
1627
  }
1646
1628
  }
1629
+ } else if (delta.reasoning != null) {
1630
+ emitReasoningChunk(delta.reasoning);
1631
+ }
1632
+ if (delta.content != null) {
1633
+ if (!textStarted) {
1634
+ textId = openrouterResponseId || generateId();
1635
+ controller.enqueue({
1636
+ type: "text-start",
1637
+ id: textId
1638
+ });
1639
+ textStarted = true;
1640
+ }
1641
+ controller.enqueue({
1642
+ type: "text-delta",
1643
+ delta: delta.content,
1644
+ id: textId || generateId()
1645
+ });
1647
1646
  }
1648
1647
  if (delta.tool_calls != null) {
1649
1648
  for (const toolCallDelta of delta.tool_calls) {
@@ -1743,7 +1742,7 @@ var OpenRouterChatLanguageModel = class {
1743
1742
  var _a16;
1744
1743
  if (finishReason === "tool-calls") {
1745
1744
  for (const toolCall of toolCalls) {
1746
- if (!toolCall.sent) {
1745
+ if (toolCall && !toolCall.sent) {
1747
1746
  controller.enqueue({
1748
1747
  type: "tool-call",
1749
1748
  toolCallId: (_a16 = toolCall.id) != null ? _a16 : generateId(),