@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.
@@ -3862,6 +3862,13 @@ var OpenRouterChatLanguageModel = class {
3862
3862
  id: toolCall.id,
3863
3863
  toolName: toolCall.function.name
3864
3864
  });
3865
+ if (toolCall.function.arguments) {
3866
+ controller.enqueue({
3867
+ type: "tool-input-delta",
3868
+ id: toolCall.id,
3869
+ delta: toolCall.function.arguments
3870
+ });
3871
+ }
3865
3872
  }
3866
3873
  if (((_o = toolCallDelta.function) == null ? void 0 : _o.arguments) != null) {
3867
3874
  toolCall.function.arguments += (_q = (_p = toolCallDelta.function) == null ? void 0 : _p.arguments) != null ? _q : "";
@@ -3872,6 +3879,10 @@ var OpenRouterChatLanguageModel = class {
3872
3879
  delta: (_r = toolCallDelta.function.arguments) != null ? _r : ""
3873
3880
  });
3874
3881
  if (((_s = toolCall.function) == null ? void 0 : _s.name) != null && ((_t = toolCall.function) == null ? void 0 : _t.arguments) != null && isParsableJson(toolCall.function.arguments)) {
3882
+ controller.enqueue({
3883
+ type: "tool-input-end",
3884
+ id: toolCall.id
3885
+ });
3875
3886
  controller.enqueue({
3876
3887
  type: "tool-call",
3877
3888
  toolCallId: (_u = toolCall.id) != null ? _u : generateId(),
@@ -3917,12 +3928,28 @@ var OpenRouterChatLanguageModel = class {
3917
3928
  if (finishReason.unified === "tool-calls") {
3918
3929
  for (const toolCall of toolCalls) {
3919
3930
  if (toolCall && !toolCall.sent) {
3931
+ const input = isParsableJson(toolCall.function.arguments) ? toolCall.function.arguments : "{}";
3932
+ if (!toolCall.inputStarted) {
3933
+ controller.enqueue({
3934
+ type: "tool-input-start",
3935
+ id: toolCall.id,
3936
+ toolName: toolCall.function.name
3937
+ });
3938
+ controller.enqueue({
3939
+ type: "tool-input-delta",
3940
+ id: toolCall.id,
3941
+ delta: input
3942
+ });
3943
+ }
3944
+ controller.enqueue({
3945
+ type: "tool-input-end",
3946
+ id: toolCall.id
3947
+ });
3920
3948
  controller.enqueue({
3921
3949
  type: "tool-call",
3922
3950
  toolCallId: (_a17 = toolCall.id) != null ? _a17 : generateId(),
3923
3951
  toolName: toolCall.function.name,
3924
- // Coerce invalid arguments to an empty JSON object
3925
- input: isParsableJson(toolCall.function.arguments) ? toolCall.function.arguments : "{}",
3952
+ input,
3926
3953
  providerMetadata: !reasoningDetailsAttachedToToolCall ? {
3927
3954
  openrouter: {
3928
3955
  reasoning_details: accumulatedReasoningDetails