@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.
package/dist/index.js CHANGED
@@ -1630,21 +1630,6 @@ var OpenRouterChatLanguageModel = class {
1630
1630
  return;
1631
1631
  }
1632
1632
  const delta = choice.delta;
1633
- if (delta.content != null) {
1634
- if (!textStarted) {
1635
- textId = openrouterResponseId || generateId();
1636
- controller.enqueue({
1637
- type: "text-start",
1638
- id: textId
1639
- });
1640
- textStarted = true;
1641
- }
1642
- controller.enqueue({
1643
- type: "text-delta",
1644
- delta: delta.content,
1645
- id: textId || generateId()
1646
- });
1647
- }
1648
1633
  const emitReasoningChunk = (chunkText) => {
1649
1634
  if (!reasoningStarted) {
1650
1635
  reasoningId = openrouterResponseId || generateId();
@@ -1660,9 +1645,6 @@ var OpenRouterChatLanguageModel = class {
1660
1645
  id: reasoningId || generateId()
1661
1646
  });
1662
1647
  };
1663
- if (delta.reasoning != null) {
1664
- emitReasoningChunk(delta.reasoning);
1665
- }
1666
1648
  if (delta.reasoning_details && delta.reasoning_details.length > 0) {
1667
1649
  for (const detail of delta.reasoning_details) {
1668
1650
  switch (detail.type) {
@@ -1690,6 +1672,23 @@ var OpenRouterChatLanguageModel = class {
1690
1672
  }
1691
1673
  }
1692
1674
  }
1675
+ } else if (delta.reasoning != null) {
1676
+ emitReasoningChunk(delta.reasoning);
1677
+ }
1678
+ if (delta.content != null) {
1679
+ if (!textStarted) {
1680
+ textId = openrouterResponseId || generateId();
1681
+ controller.enqueue({
1682
+ type: "text-start",
1683
+ id: textId
1684
+ });
1685
+ textStarted = true;
1686
+ }
1687
+ controller.enqueue({
1688
+ type: "text-delta",
1689
+ delta: delta.content,
1690
+ id: textId || generateId()
1691
+ });
1693
1692
  }
1694
1693
  if (delta.tool_calls != null) {
1695
1694
  for (const toolCallDelta of delta.tool_calls) {
@@ -1789,7 +1788,7 @@ var OpenRouterChatLanguageModel = class {
1789
1788
  var _a16;
1790
1789
  if (finishReason === "tool-calls") {
1791
1790
  for (const toolCall of toolCalls) {
1792
- if (!toolCall.sent) {
1791
+ if (toolCall && !toolCall.sent) {
1793
1792
  controller.enqueue({
1794
1793
  type: "tool-call",
1795
1794
  toolCallId: (_a16 = toolCall.id) != null ? _a16 : generateId(),