ai 7.0.40 → 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 +22 -0
- package/dist/index.d.ts +12 -5
- package/dist/index.js +54 -13
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +2 -1
- package/dist/internal/index.js +19 -9
- package/dist/internal/index.js.map +1 -1
- package/docs/03-agents/02-building-agents.mdx +4 -0
- package/docs/03-agents/04-loop-control.mdx +40 -0
- package/docs/03-ai-sdk-core/36-transcription.mdx +1 -0
- package/docs/03-ai-sdk-core/65-devtools.mdx +47 -1
- package/docs/06-advanced/11-secure-url-fetching.mdx +18 -24
- package/docs/07-reference/01-ai-sdk-core/01-generate-text.mdx +68 -3
- package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +64 -1
- package/docs/07-reference/01-ai-sdk-core/16-tool-loop-agent.mdx +1 -1
- package/package.json +3 -3
- package/src/generate-text/generate-text-result.ts +3 -1
- package/src/generate-text/generate-text.ts +8 -2
- package/src/generate-text/prepare-step-call-settings.ts +31 -0
- package/src/generate-text/prepare-step.ts +8 -3
- package/src/generate-text/step-result.ts +2 -1
- package/src/generate-text/stream-text.ts +16 -2
- package/src/logger/log-warnings.ts +25 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
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
|
+
|
|
17
|
+
## 7.0.41
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- 2e2224b: Route the warning system information banner to stderr so it does not corrupt application output written to stdout.
|
|
22
|
+
- Updated dependencies [bf216b3]
|
|
23
|
+
- @ai-sdk/gateway@4.0.31
|
|
24
|
+
|
|
3
25
|
## 7.0.40
|
|
4
26
|
|
|
5
27
|
### 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
|
|
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,
|
|
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
|
|
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
|
@@ -598,6 +598,16 @@ function formatWarning({
|
|
|
598
598
|
}
|
|
599
599
|
var FIRST_WARNING_INFO_MESSAGE = "AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.";
|
|
600
600
|
var hasLoggedBefore = false;
|
|
601
|
+
function emitWarning({
|
|
602
|
+
message,
|
|
603
|
+
type
|
|
604
|
+
}) {
|
|
605
|
+
if (typeof process !== "undefined" && typeof process.emitWarning === "function") {
|
|
606
|
+
process.emitWarning(message, { type });
|
|
607
|
+
} else {
|
|
608
|
+
console.warn(message);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
601
611
|
var logWarnings = (options) => {
|
|
602
612
|
if (options.warnings.length === 0) {
|
|
603
613
|
return;
|
|
@@ -612,7 +622,10 @@ var logWarnings = (options) => {
|
|
|
612
622
|
}
|
|
613
623
|
if (!hasLoggedBefore) {
|
|
614
624
|
hasLoggedBefore = true;
|
|
615
|
-
|
|
625
|
+
emitWarning({
|
|
626
|
+
message: FIRST_WARNING_INFO_MESSAGE,
|
|
627
|
+
type: "Warning"
|
|
628
|
+
});
|
|
616
629
|
}
|
|
617
630
|
for (const warning of options.warnings) {
|
|
618
631
|
const message = formatWarning({
|
|
@@ -620,13 +633,10 @@ var logWarnings = (options) => {
|
|
|
620
633
|
provider: options.provider,
|
|
621
634
|
model: options.model
|
|
622
635
|
});
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
} else {
|
|
628
|
-
console.warn(message);
|
|
629
|
-
}
|
|
636
|
+
emitWarning({
|
|
637
|
+
message,
|
|
638
|
+
type: warning.type === "deprecated" ? "DeprecationWarning" : "Warning"
|
|
639
|
+
});
|
|
630
640
|
}
|
|
631
641
|
};
|
|
632
642
|
|
|
@@ -1132,7 +1142,7 @@ import {
|
|
|
1132
1142
|
} from "@ai-sdk/provider-utils";
|
|
1133
1143
|
|
|
1134
1144
|
// src/version.ts
|
|
1135
|
-
var VERSION = true ? "7.0.
|
|
1145
|
+
var VERSION = true ? "7.0.42" : "0.0.0-test";
|
|
1136
1146
|
|
|
1137
1147
|
// src/util/download/download.ts
|
|
1138
1148
|
var download = async ({
|
|
@@ -3945,6 +3955,25 @@ async function doParseToolCall({
|
|
|
3945
3955
|
};
|
|
3946
3956
|
}
|
|
3947
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
|
+
|
|
3948
3977
|
// src/generate-text/reasoning-output.ts
|
|
3949
3978
|
function unwrapReasoningFileData(data) {
|
|
3950
3979
|
if (typeof data === "object" && data !== null && "type" in data) {
|
|
@@ -5372,6 +5401,10 @@ async function generateText({
|
|
|
5372
5401
|
providerOptions,
|
|
5373
5402
|
prepareStepResult == null ? void 0 : prepareStepResult.providerOptions
|
|
5374
5403
|
);
|
|
5404
|
+
const stepCallSettings = prepareStepCallSettings({
|
|
5405
|
+
callSettings: callSettings2,
|
|
5406
|
+
stepSettings: prepareStepResult
|
|
5407
|
+
});
|
|
5375
5408
|
await notify({
|
|
5376
5409
|
event: {
|
|
5377
5410
|
callId,
|
|
@@ -5404,7 +5437,7 @@ async function generateText({
|
|
|
5404
5437
|
instructions: stepInstructions,
|
|
5405
5438
|
messages: stepMessages,
|
|
5406
5439
|
tools: stepTools,
|
|
5407
|
-
...
|
|
5440
|
+
...stepCallSettings
|
|
5408
5441
|
};
|
|
5409
5442
|
const languageModelCallStartEvent = {
|
|
5410
5443
|
callId,
|
|
@@ -5425,7 +5458,7 @@ async function generateText({
|
|
|
5425
5458
|
{
|
|
5426
5459
|
...languageModelCallStartEvent,
|
|
5427
5460
|
execute: async () => await stepModel.doGenerate({
|
|
5428
|
-
...
|
|
5461
|
+
...stepCallSettings,
|
|
5429
5462
|
tools: stepTools,
|
|
5430
5463
|
toolChoice: stepToolChoice,
|
|
5431
5464
|
responseFormat: await (output == null ? void 0 : output.responseFormat),
|
|
@@ -8767,6 +8800,10 @@ function createOutputTransformStream(output) {
|
|
|
8767
8800
|
text2 += chunk.text;
|
|
8768
8801
|
textChunk += chunk.text;
|
|
8769
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
|
+
}
|
|
8770
8807
|
const result = await output.parsePartialOutput({ text: text2 });
|
|
8771
8808
|
if (result !== void 0) {
|
|
8772
8809
|
const currentValue = typeof result.partial === "string" ? result.partial : JSON.stringify(result.partial);
|
|
@@ -9470,6 +9507,10 @@ var DefaultStreamTextResult = class {
|
|
|
9470
9507
|
providerOptions,
|
|
9471
9508
|
prepareStepResult == null ? void 0 : prepareStepResult.providerOptions
|
|
9472
9509
|
);
|
|
9510
|
+
const stepCallSettings = prepareStepCallSettings({
|
|
9511
|
+
callSettings,
|
|
9512
|
+
stepSettings: prepareStepResult
|
|
9513
|
+
});
|
|
9473
9514
|
const stepStartTimestampMs = now2();
|
|
9474
9515
|
const { retry } = prepareRetries({ maxRetries, abortSignal });
|
|
9475
9516
|
const {
|
|
@@ -9537,7 +9578,7 @@ var DefaultStreamTextResult = class {
|
|
|
9537
9578
|
_internal: {
|
|
9538
9579
|
now: now2
|
|
9539
9580
|
},
|
|
9540
|
-
...
|
|
9581
|
+
...stepCallSettings
|
|
9541
9582
|
});
|
|
9542
9583
|
}
|
|
9543
9584
|
)
|
|
@@ -9654,7 +9695,7 @@ var DefaultStreamTextResult = class {
|
|
|
9654
9695
|
break;
|
|
9655
9696
|
}
|
|
9656
9697
|
case "text-delta": {
|
|
9657
|
-
if (chunk.text.length > 0) {
|
|
9698
|
+
if (chunk.text.length > 0 || chunk.providerMetadata != null) {
|
|
9658
9699
|
controller.enqueue(chunk);
|
|
9659
9700
|
}
|
|
9660
9701
|
break;
|