@openrouter/ai-sdk-provider 2.4.2 → 2.4.3

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.
@@ -3828,6 +3828,13 @@ var OpenRouterChatLanguageModel = class {
3828
3828
  id: toolCall.id,
3829
3829
  toolName: toolCall.function.name
3830
3830
  });
3831
+ if (toolCall.function.arguments) {
3832
+ controller.enqueue({
3833
+ type: "tool-input-delta",
3834
+ id: toolCall.id,
3835
+ delta: toolCall.function.arguments
3836
+ });
3837
+ }
3831
3838
  }
3832
3839
  if (((_o = toolCallDelta.function) == null ? void 0 : _o.arguments) != null) {
3833
3840
  toolCall.function.arguments += (_q = (_p = toolCallDelta.function) == null ? void 0 : _p.arguments) != null ? _q : "";
@@ -3838,6 +3845,10 @@ var OpenRouterChatLanguageModel = class {
3838
3845
  delta: (_r = toolCallDelta.function.arguments) != null ? _r : ""
3839
3846
  });
3840
3847
  if (((_s = toolCall.function) == null ? void 0 : _s.name) != null && ((_t = toolCall.function) == null ? void 0 : _t.arguments) != null && isParsableJson(toolCall.function.arguments)) {
3848
+ controller.enqueue({
3849
+ type: "tool-input-end",
3850
+ id: toolCall.id
3851
+ });
3841
3852
  controller.enqueue({
3842
3853
  type: "tool-call",
3843
3854
  toolCallId: (_u = toolCall.id) != null ? _u : generateId(),
@@ -3883,12 +3894,28 @@ var OpenRouterChatLanguageModel = class {
3883
3894
  if (finishReason.unified === "tool-calls") {
3884
3895
  for (const toolCall of toolCalls) {
3885
3896
  if (toolCall && !toolCall.sent) {
3897
+ const input = isParsableJson(toolCall.function.arguments) ? toolCall.function.arguments : "{}";
3898
+ if (!toolCall.inputStarted) {
3899
+ controller.enqueue({
3900
+ type: "tool-input-start",
3901
+ id: toolCall.id,
3902
+ toolName: toolCall.function.name
3903
+ });
3904
+ controller.enqueue({
3905
+ type: "tool-input-delta",
3906
+ id: toolCall.id,
3907
+ delta: input
3908
+ });
3909
+ }
3910
+ controller.enqueue({
3911
+ type: "tool-input-end",
3912
+ id: toolCall.id
3913
+ });
3886
3914
  controller.enqueue({
3887
3915
  type: "tool-call",
3888
3916
  toolCallId: (_a17 = toolCall.id) != null ? _a17 : generateId(),
3889
3917
  toolName: toolCall.function.name,
3890
- // Coerce invalid arguments to an empty JSON object
3891
- input: isParsableJson(toolCall.function.arguments) ? toolCall.function.arguments : "{}",
3918
+ input,
3892
3919
  providerMetadata: !reasoningDetailsAttachedToToolCall ? {
3893
3920
  openrouter: {
3894
3921
  reasoning_details: accumulatedReasoningDetails