ai 7.0.41 → 7.0.42

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # ai
2
2
 
3
+ ## 7.0.42
4
+
5
+ ### Patch Changes
6
+
7
+ - 1659cd5: Prevent validated downloads on Node.js from reaching private or internal services through DNS aliases or DNS rebinding by validating and pinning every resolved address at connection time.
8
+ - 60f97f6: support overriding model call settings for individual `prepareStep` invocations
9
+ - 6a5bdff: Fix validated Node.js downloads when the HTTP connector requests a single DNS address.
10
+ - 6de2ec1: Preserve provider metadata from empty text deltas in `streamText`.
11
+ - Updated dependencies [1659cd5]
12
+ - Updated dependencies [6a5bdff]
13
+ - Updated dependencies [0012529]
14
+ - @ai-sdk/provider-utils@5.0.15
15
+ - @ai-sdk/gateway@4.0.32
16
+
3
17
  ## 7.0.41
4
18
 
5
19
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1423,7 +1423,8 @@ type StepResult<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context = Context
1423
1423
  */
1424
1424
  readonly content: Array<ContentPart<TOOLS>>;
1425
1425
  /**
1426
- * The generated text. Can be an empty string if the model has not generated any text.
1426
+ * The concatenation of all text parts generated in this step.
1427
+ * It is an empty string if the step contains no text parts.
1427
1428
  */
1428
1429
  readonly text: string;
1429
1430
  /**
@@ -1680,9 +1681,13 @@ type PrepareStepFunction<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context
1680
1681
  }) => PromiseLike<PrepareStepResult<TOOLS, RUNTIME_CONTEXT>> | PrepareStepResult<TOOLS, RUNTIME_CONTEXT>;
1681
1682
  /**
1682
1683
  * The result type returned by a {@link PrepareStepFunction},
1683
- * allowing per-step overrides of model, tools, instructions, or messages.
1684
+ * allowing per-step overrides of model call settings, model, tools,
1685
+ * instructions, or messages.
1686
+ *
1687
+ * Model call setting overrides apply only to the current step. Undefined
1688
+ * settings fall back to the outer call settings.
1684
1689
  */
1685
- type PrepareStepResult<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context = Context> = {
1690
+ type PrepareStepResult<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context = Context> = ({
1686
1691
  /**
1687
1692
  * Optionally override which LanguageModel instance is used for this step.
1688
1693
  */
@@ -1746,7 +1751,7 @@ type PrepareStepResult<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context =
1746
1751
  * container IDs for Anthropic's code execution.
1747
1752
  */
1748
1753
  providerOptions?: ProviderOptions;
1749
- } | undefined;
1754
+ } & LanguageModelCallOptions) | undefined;
1750
1755
 
1751
1756
  /**
1752
1757
  * A predicate that decides whether a tool-calling loop should stop after the
@@ -4337,7 +4342,9 @@ interface GenerateTextResult<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Cont
4337
4342
  */
4338
4343
  readonly content: Array<ContentPart<TOOLS>>;
4339
4344
  /**
4340
- * The text that was generated in the final step.
4345
+ * The concatenation of all text parts generated in the final step.
4346
+ * It is an empty string if the final step contains no text parts.
4347
+ * Inspect `finalStep.content` to distinguish that case.
4341
4348
  */
4342
4349
  readonly text: string;
4343
4350
  /**
package/dist/index.js CHANGED
@@ -1142,7 +1142,7 @@ import {
1142
1142
  } from "@ai-sdk/provider-utils";
1143
1143
 
1144
1144
  // src/version.ts
1145
- var VERSION = true ? "7.0.41" : "0.0.0-test";
1145
+ var VERSION = true ? "7.0.42" : "0.0.0-test";
1146
1146
 
1147
1147
  // src/util/download/download.ts
1148
1148
  var download = async ({
@@ -3955,6 +3955,25 @@ async function doParseToolCall({
3955
3955
  };
3956
3956
  }
3957
3957
 
3958
+ // src/generate-text/prepare-step-call-settings.ts
3959
+ function prepareStepCallSettings({
3960
+ callSettings,
3961
+ stepSettings
3962
+ }) {
3963
+ var _a23, _b, _c, _d, _e, _f, _g, _h, _i;
3964
+ return prepareLanguageModelCallOptions({
3965
+ maxOutputTokens: (_a23 = stepSettings == null ? void 0 : stepSettings.maxOutputTokens) != null ? _a23 : callSettings.maxOutputTokens,
3966
+ temperature: (_b = stepSettings == null ? void 0 : stepSettings.temperature) != null ? _b : callSettings.temperature,
3967
+ topP: (_c = stepSettings == null ? void 0 : stepSettings.topP) != null ? _c : callSettings.topP,
3968
+ topK: (_d = stepSettings == null ? void 0 : stepSettings.topK) != null ? _d : callSettings.topK,
3969
+ presencePenalty: (_e = stepSettings == null ? void 0 : stepSettings.presencePenalty) != null ? _e : callSettings.presencePenalty,
3970
+ frequencyPenalty: (_f = stepSettings == null ? void 0 : stepSettings.frequencyPenalty) != null ? _f : callSettings.frequencyPenalty,
3971
+ stopSequences: (_g = stepSettings == null ? void 0 : stepSettings.stopSequences) != null ? _g : callSettings.stopSequences,
3972
+ seed: (_h = stepSettings == null ? void 0 : stepSettings.seed) != null ? _h : callSettings.seed,
3973
+ reasoning: (_i = stepSettings == null ? void 0 : stepSettings.reasoning) != null ? _i : callSettings.reasoning
3974
+ });
3975
+ }
3976
+
3958
3977
  // src/generate-text/reasoning-output.ts
3959
3978
  function unwrapReasoningFileData(data) {
3960
3979
  if (typeof data === "object" && data !== null && "type" in data) {
@@ -5382,6 +5401,10 @@ async function generateText({
5382
5401
  providerOptions,
5383
5402
  prepareStepResult == null ? void 0 : prepareStepResult.providerOptions
5384
5403
  );
5404
+ const stepCallSettings = prepareStepCallSettings({
5405
+ callSettings: callSettings2,
5406
+ stepSettings: prepareStepResult
5407
+ });
5385
5408
  await notify({
5386
5409
  event: {
5387
5410
  callId,
@@ -5414,7 +5437,7 @@ async function generateText({
5414
5437
  instructions: stepInstructions,
5415
5438
  messages: stepMessages,
5416
5439
  tools: stepTools,
5417
- ...callSettings2
5440
+ ...stepCallSettings
5418
5441
  };
5419
5442
  const languageModelCallStartEvent = {
5420
5443
  callId,
@@ -5435,7 +5458,7 @@ async function generateText({
5435
5458
  {
5436
5459
  ...languageModelCallStartEvent,
5437
5460
  execute: async () => await stepModel.doGenerate({
5438
- ...callSettings2,
5461
+ ...stepCallSettings,
5439
5462
  tools: stepTools,
5440
5463
  toolChoice: stepToolChoice,
5441
5464
  responseFormat: await (output == null ? void 0 : output.responseFormat),
@@ -8777,6 +8800,10 @@ function createOutputTransformStream(output) {
8777
8800
  text2 += chunk.text;
8778
8801
  textChunk += chunk.text;
8779
8802
  textProviderMetadata = (_a23 = chunk.providerMetadata) != null ? _a23 : textProviderMetadata;
8803
+ if (chunk.text.length === 0 && chunk.providerMetadata != null) {
8804
+ controller.enqueue({ part: chunk, partialOutput: void 0 });
8805
+ return;
8806
+ }
8780
8807
  const result = await output.parsePartialOutput({ text: text2 });
8781
8808
  if (result !== void 0) {
8782
8809
  const currentValue = typeof result.partial === "string" ? result.partial : JSON.stringify(result.partial);
@@ -9480,6 +9507,10 @@ var DefaultStreamTextResult = class {
9480
9507
  providerOptions,
9481
9508
  prepareStepResult == null ? void 0 : prepareStepResult.providerOptions
9482
9509
  );
9510
+ const stepCallSettings = prepareStepCallSettings({
9511
+ callSettings,
9512
+ stepSettings: prepareStepResult
9513
+ });
9483
9514
  const stepStartTimestampMs = now2();
9484
9515
  const { retry } = prepareRetries({ maxRetries, abortSignal });
9485
9516
  const {
@@ -9547,7 +9578,7 @@ var DefaultStreamTextResult = class {
9547
9578
  _internal: {
9548
9579
  now: now2
9549
9580
  },
9550
- ...callSettings
9581
+ ...stepCallSettings
9551
9582
  });
9552
9583
  }
9553
9584
  )
@@ -9664,7 +9695,7 @@ var DefaultStreamTextResult = class {
9664
9695
  break;
9665
9696
  }
9666
9697
  case "text-delta": {
9667
- if (chunk.text.length > 0) {
9698
+ if (chunk.text.length > 0 || chunk.providerMetadata != null) {
9668
9699
  controller.enqueue(chunk);
9669
9700
  }
9670
9701
  break;