ai 7.0.113 → 7.0.114
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 +9 -0
- package/README.md +6 -6
- package/dist/index.js +64 -44
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +78 -51
- package/dist/internal/index.js.map +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +3 -0
- package/docs/02-foundations/03-prompts.mdx +1 -1
- package/docs/02-foundations/04-tools.mdx +2 -2
- package/docs/02-foundations/06-provider-options.mdx +11 -11
- package/docs/02-getting-started/00-choosing-a-provider.mdx +4 -4
- package/docs/02-getting-started/02-nextjs-app-router.mdx +3 -3
- package/docs/02-getting-started/03-nextjs-pages-router.mdx +3 -3
- package/docs/02-getting-started/04-svelte.mdx +7 -7
- package/docs/02-getting-started/05-nuxt.mdx +7 -7
- package/docs/02-getting-started/06-nodejs.mdx +3 -3
- package/docs/02-getting-started/07-expo.mdx +3 -3
- package/docs/02-getting-started/08-tanstack-start.mdx +3 -3
- package/docs/02-getting-started/09-coding-agents.mdx +1 -1
- package/docs/03-agents/03-workflows.mdx +2 -2
- package/docs/03-agents/04-loop-control.mdx +1 -1
- package/docs/03-agents/05-configuring-call-options.mdx +4 -2
- package/docs/03-agents/06-memory.mdx +2 -2
- package/docs/03-agents/06-policy-tool-approvals.mdx +2 -2
- package/docs/03-agents/07-workflow-agent.mdx +11 -11
- package/docs/03-agents/08-terminal-ui.mdx +2 -2
- package/docs/03-ai-sdk-core/05-generating-text.mdx +2 -2
- package/docs/03-ai-sdk-core/17-mcp-apps.mdx +1 -1
- package/docs/03-ai-sdk-core/20-prompt-engineering.mdx +1 -1
- package/docs/03-ai-sdk-core/26-reasoning.mdx +13 -12
- package/docs/03-ai-sdk-core/31-reranking.mdx +12 -10
- package/docs/03-ai-sdk-core/32-evaluation.mdx +1 -1
- package/docs/03-ai-sdk-core/35-image-generation.mdx +2 -2
- package/docs/03-ai-sdk-core/37-speech.mdx +6 -6
- package/docs/03-ai-sdk-core/39-file-uploads.mdx +1 -1
- package/docs/03-ai-sdk-core/41-skill-uploads.mdx +1 -1
- package/docs/03-ai-sdk-core/42-batch.mdx +1 -1
- package/docs/03-ai-sdk-core/45-provider-management.mdx +21 -21
- package/docs/03-ai-sdk-core/60-telemetry.mdx +1 -1
- package/docs/03-ai-sdk-core/65-devtools.mdx +3 -3
- package/docs/03-ai-sdk-core/65-lifecycle-callbacks.mdx +1 -1
- package/docs/04-ai-sdk-ui/02-chatbot.mdx +3 -3
- package/docs/04-ai-sdk-ui/03-chatbot-message-persistence.mdx +3 -3
- package/docs/04-ai-sdk-ui/03-chatbot-resume-streams.mdx +1 -1
- package/docs/05-ai-sdk-rsc/02-streaming-react-components.mdx +5 -5
- package/docs/05-ai-sdk-rsc/04-multistep-interfaces.mdx +1 -1
- package/docs/05-ai-sdk-rsc/06-loading-state.mdx +1 -1
- package/docs/05-ai-sdk-rsc/10-migrating-to-ui.mdx +3 -3
- package/docs/07-reference/01-ai-sdk-core/01-generate-text.mdx +5 -3
- package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +5 -3
- package/docs/07-reference/01-ai-sdk-core/06-rerank.mdx +5 -5
- package/docs/07-reference/01-ai-sdk-core/11-transcribe.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/12-generate-speech.mdx +2 -2
- package/docs/07-reference/01-ai-sdk-core/16-tool-loop-agent.mdx +4 -2
- package/docs/07-reference/01-ai-sdk-core/20-start-batch.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/40-provider-registry.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/42-custom-provider.mdx +4 -4
- package/docs/07-reference/01-ai-sdk-core/60-wrap-language-model.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/61-wrap-image-model.mdx +1 -1
- package/docs/07-reference/02-ai-sdk-ui/50-direct-chat-transport.mdx +3 -3
- package/docs/07-reference/03-ai-sdk-rsc/01-stream-ui.mdx +1 -1
- package/docs/07-reference/04-ai-sdk-workflow/01-workflow-agent.mdx +8 -8
- package/docs/07-reference/06-ai-sdk-tui/01-run-agent-tui.mdx +1 -1
- package/docs/09-troubleshooting/11-use-chat-custom-request-options.mdx +3 -3
- package/docs/09-troubleshooting/13-repeated-assistant-messages.mdx +2 -2
- package/docs/09-troubleshooting/17-use-chat-stale-body-data.mdx +1 -1
- package/docs/09-troubleshooting/70-high-memory-usage-with-images.mdx +2 -2
- package/package.json +6 -6
- package/src/evaluate/evaluate.ts +1 -10
- package/src/generate-text/restricted-telemetry-dispatcher.ts +6 -58
- package/src/prompt/standardize-prompt.ts +2 -0
- package/src/telemetry/create-telemetry-dispatcher.ts +58 -6
- package/src/telemetry/filter-included-context.ts +57 -2
package/dist/internal/index.js
CHANGED
|
@@ -91,7 +91,7 @@ import {
|
|
|
91
91
|
} from "@ai-sdk/provider-utils";
|
|
92
92
|
|
|
93
93
|
// src/version.ts
|
|
94
|
-
var VERSION = true ? "7.0.
|
|
94
|
+
var VERSION = true ? "7.0.114" : "0.0.0-test";
|
|
95
95
|
|
|
96
96
|
// src/util/download/download.ts
|
|
97
97
|
var download = async ({
|
|
@@ -2516,6 +2516,50 @@ function mergeCallbacks(...callbacks) {
|
|
|
2516
2516
|
// src/telemetry/create-telemetry-dispatcher.ts
|
|
2517
2517
|
import { asArray as asArray3 } from "@ai-sdk/provider-utils";
|
|
2518
2518
|
|
|
2519
|
+
// src/telemetry/filter-included-context.ts
|
|
2520
|
+
function filterIncludedContext({
|
|
2521
|
+
context,
|
|
2522
|
+
includeContext
|
|
2523
|
+
}) {
|
|
2524
|
+
if (context == null) {
|
|
2525
|
+
return {};
|
|
2526
|
+
}
|
|
2527
|
+
return Object.fromEntries(
|
|
2528
|
+
Object.entries(context).filter(
|
|
2529
|
+
([key]) => (includeContext == null ? void 0 : includeContext[key]) === true
|
|
2530
|
+
)
|
|
2531
|
+
);
|
|
2532
|
+
}
|
|
2533
|
+
function filterToolsContext({
|
|
2534
|
+
toolsContext,
|
|
2535
|
+
includeToolsContext
|
|
2536
|
+
}) {
|
|
2537
|
+
if (includeToolsContext == null) {
|
|
2538
|
+
return {};
|
|
2539
|
+
}
|
|
2540
|
+
return Object.fromEntries(
|
|
2541
|
+
Object.entries(toolsContext).map(([toolName, toolContext]) => [
|
|
2542
|
+
toolName,
|
|
2543
|
+
filterToolContext({
|
|
2544
|
+
toolName,
|
|
2545
|
+
toolContext,
|
|
2546
|
+
includeToolsContext
|
|
2547
|
+
})
|
|
2548
|
+
])
|
|
2549
|
+
);
|
|
2550
|
+
}
|
|
2551
|
+
function filterToolContext({
|
|
2552
|
+
toolName,
|
|
2553
|
+
toolContext,
|
|
2554
|
+
includeToolsContext
|
|
2555
|
+
}) {
|
|
2556
|
+
const includeToolContext = includeToolsContext == null ? void 0 : includeToolsContext[toolName];
|
|
2557
|
+
return filterIncludedContext({
|
|
2558
|
+
context: toolContext,
|
|
2559
|
+
includeContext: includeToolContext
|
|
2560
|
+
});
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2519
2563
|
// src/telemetry/tracing-channel.ts
|
|
2520
2564
|
var AI_SDK_TELEMETRY_TRACING_CHANNEL = "ai:telemetry";
|
|
2521
2565
|
|
|
@@ -2666,12 +2710,37 @@ function getGlobalTelemetryIntegrations() {
|
|
|
2666
2710
|
}
|
|
2667
2711
|
|
|
2668
2712
|
// src/telemetry/create-telemetry-dispatcher.ts
|
|
2669
|
-
function augmentEvent(event, telemetry) {
|
|
2670
|
-
|
|
2713
|
+
function augmentEvent(event, telemetry, filterContext = false) {
|
|
2714
|
+
const augmentedEvent = Object.assign(
|
|
2671
2715
|
Object.create(Object.getPrototypeOf(event)),
|
|
2672
2716
|
event,
|
|
2673
|
-
|
|
2717
|
+
{
|
|
2718
|
+
recordInputs: telemetry.recordInputs,
|
|
2719
|
+
recordOutputs: telemetry.recordOutputs,
|
|
2720
|
+
functionId: telemetry.functionId
|
|
2721
|
+
}
|
|
2674
2722
|
);
|
|
2723
|
+
if (filterContext && event != null && typeof event === "object" && "runtimeContext" in event) {
|
|
2724
|
+
augmentedEvent.runtimeContext = filterIncludedContext({
|
|
2725
|
+
context: event.runtimeContext,
|
|
2726
|
+
includeContext: telemetry.includeRuntimeContext
|
|
2727
|
+
});
|
|
2728
|
+
}
|
|
2729
|
+
if (filterContext && event != null && typeof event === "object") {
|
|
2730
|
+
if ("toolsContext" in event) {
|
|
2731
|
+
augmentedEvent.toolsContext = filterToolsContext({
|
|
2732
|
+
toolsContext: event.toolsContext,
|
|
2733
|
+
includeToolsContext: telemetry.includeToolsContext
|
|
2734
|
+
});
|
|
2735
|
+
} else if ("toolContext" in event && event.toolContext != null && "toolCall" in event && event.toolCall != null && typeof event.toolCall === "object" && "toolName" in event.toolCall) {
|
|
2736
|
+
augmentedEvent.toolContext = filterToolContext({
|
|
2737
|
+
toolName: event.toolCall.toolName,
|
|
2738
|
+
toolContext: event.toolContext,
|
|
2739
|
+
includeToolsContext: telemetry.includeToolsContext
|
|
2740
|
+
});
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
return augmentedEvent;
|
|
2675
2744
|
}
|
|
2676
2745
|
function createTelemetryDispatcher({
|
|
2677
2746
|
telemetry
|
|
@@ -2684,7 +2753,9 @@ function createTelemetryDispatcher({
|
|
|
2684
2753
|
const telemetryMetadata = {
|
|
2685
2754
|
recordInputs: telemetry == null ? void 0 : telemetry.recordInputs,
|
|
2686
2755
|
recordOutputs: telemetry == null ? void 0 : telemetry.recordOutputs,
|
|
2687
|
-
functionId: telemetry == null ? void 0 : telemetry.functionId
|
|
2756
|
+
functionId: telemetry == null ? void 0 : telemetry.functionId,
|
|
2757
|
+
includeRuntimeContext: telemetry == null ? void 0 : telemetry.includeRuntimeContext,
|
|
2758
|
+
includeToolsContext: telemetry == null ? void 0 : telemetry.includeToolsContext
|
|
2688
2759
|
};
|
|
2689
2760
|
const mergeTelemetryCallback = (key) => {
|
|
2690
2761
|
const integrationCallbacks = integrations.map((integration) => {
|
|
@@ -2710,14 +2781,14 @@ function createTelemetryDispatcher({
|
|
|
2710
2781
|
runInTracingChannelSpan: async ({ type, event, execute }) => await runWithTracingChannelSpan(
|
|
2711
2782
|
{
|
|
2712
2783
|
type,
|
|
2713
|
-
event: augmentEvent(event, telemetryMetadata)
|
|
2784
|
+
event: augmentEvent(event, telemetryMetadata, true)
|
|
2714
2785
|
},
|
|
2715
2786
|
execute
|
|
2716
2787
|
),
|
|
2717
2788
|
startTracingChannelContext: ({ type, event, completion }) => openTelemetryChannelSpanContext({
|
|
2718
2789
|
message: {
|
|
2719
2790
|
type,
|
|
2720
|
-
event: augmentEvent(event, telemetryMetadata)
|
|
2791
|
+
event: augmentEvent(event, telemetryMetadata, true)
|
|
2721
2792
|
},
|
|
2722
2793
|
completion
|
|
2723
2794
|
}),
|
|
@@ -2792,21 +2863,6 @@ function createTelemetryDispatcher({
|
|
|
2792
2863
|
};
|
|
2793
2864
|
}
|
|
2794
2865
|
|
|
2795
|
-
// src/telemetry/filter-included-context.ts
|
|
2796
|
-
function filterIncludedContext({
|
|
2797
|
-
context,
|
|
2798
|
-
includeContext
|
|
2799
|
-
}) {
|
|
2800
|
-
if (context == null) {
|
|
2801
|
-
return {};
|
|
2802
|
-
}
|
|
2803
|
-
return Object.fromEntries(
|
|
2804
|
-
Object.entries(context).filter(
|
|
2805
|
-
([key]) => (includeContext == null ? void 0 : includeContext[key]) === true
|
|
2806
|
-
)
|
|
2807
|
-
);
|
|
2808
|
-
}
|
|
2809
|
-
|
|
2810
2866
|
// src/generate-text/reasoning.ts
|
|
2811
2867
|
function asReasoningText(reasoningParts) {
|
|
2812
2868
|
const reasoningText = reasoningParts.map((part) => "text" in part ? part.text : "").join("");
|
|
@@ -2943,35 +2999,6 @@ function restrictStepResult({
|
|
|
2943
2999
|
providerMetadata: step.providerMetadata
|
|
2944
3000
|
});
|
|
2945
3001
|
}
|
|
2946
|
-
function filterToolsContext({
|
|
2947
|
-
toolsContext,
|
|
2948
|
-
includeToolsContext
|
|
2949
|
-
}) {
|
|
2950
|
-
if (includeToolsContext == null) {
|
|
2951
|
-
return {};
|
|
2952
|
-
}
|
|
2953
|
-
return Object.fromEntries(
|
|
2954
|
-
Object.entries(toolsContext).map(([toolName, toolContext]) => [
|
|
2955
|
-
toolName,
|
|
2956
|
-
filterToolContext({
|
|
2957
|
-
toolName,
|
|
2958
|
-
toolContext,
|
|
2959
|
-
includeToolsContext
|
|
2960
|
-
})
|
|
2961
|
-
])
|
|
2962
|
-
);
|
|
2963
|
-
}
|
|
2964
|
-
function filterToolContext({
|
|
2965
|
-
toolName,
|
|
2966
|
-
toolContext,
|
|
2967
|
-
includeToolsContext
|
|
2968
|
-
}) {
|
|
2969
|
-
const includeToolContext = includeToolsContext == null ? void 0 : includeToolsContext[toolName];
|
|
2970
|
-
return filterIncludedContext({
|
|
2971
|
-
context: toolContext,
|
|
2972
|
-
includeContext: includeToolContext
|
|
2973
|
-
});
|
|
2974
|
-
}
|
|
2975
3002
|
function createRestrictedTelemetryDispatcher({
|
|
2976
3003
|
telemetry,
|
|
2977
3004
|
includeRuntimeContext,
|