ai 7.0.164 → 7.0.166

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.
@@ -220,7 +220,11 @@ If they no longer match, leave the newer tokens in storage. The SDK retries
220
220
  authorization and reads the stored tokens again.
221
221
 
222
222
  The SDK also provides this context when invalidating stored tokens that lack an
223
- authorization server pin. Other invalidations can omit the context.
223
+ authorization server pin. These tokens must be cleared before the SDK saves a new
224
+ client registration or authorization server pin. If the invalidation hook is
225
+ missing or refresh tokens remain in storage, authorization stops with an error;
226
+ clear the stored tokens and start authorization again. Other invalidations can
227
+ omit the context.
224
228
 
225
229
  If an authorization-code exchange returns `invalid_grant`, the SDK propagates
226
230
  the error without invalidating stored credentials or retrying the rejected code.
@@ -239,14 +239,16 @@ to retain its experimental `decisionModel` method.
239
239
  descriptions can be strings, JSON objects, or JSON arrays. Descriptions can also
240
240
  be `null` when the provider supports it.
241
241
 
242
- For Choice, Score, and Boolean, `instructions` may be omitted or `null`. A Boolean
242
+ For every question type, `instructions` may be omitted or `null` when supported
243
+ by the provider. Boolean `criteria` may also be `null`. A Boolean
243
244
  question without instructions must describe at least one of its `true` or `false`
244
- criteria. Box questions always require instructions. Provider APIs can impose
245
+ criteria. Provider APIs can impose
245
246
  additional requirements; see the provider's documentation.
246
247
 
247
- Score rubrics require at least one level in Core. Perplexity accepts a single
248
- level, which returns score `0` with probability `1`; other providers may require
249
- more levels. See [Perplexity's examples](/providers/ai-sdk-providers/perplexity#single-level-score-rubrics).
248
+ Score rubrics require at least one level in Core. TypeSafe and Perplexity accept
249
+ a single level, which returns score `0` with probability `1`; other providers may
250
+ require more levels. See the [TypeSafe provider documentation](/providers/ai-sdk-providers/typesafe-ai)
251
+ and [Perplexity's examples](/providers/ai-sdk-providers/perplexity#single-level-score-rubrics).
250
252
 
251
253
  Functions, class instances, cycles, undefined values inside JSON content, and
252
254
  nonfinite numbers are not JSON-compatible.
@@ -277,6 +279,9 @@ their API probabilities. Provider-specific confidence statistics belong
277
279
  in `providerMetadata`. TypeSafe exposes its separate Choice/Score/Box confidence
278
280
  statistic at `result.providerMetadata?.typesafe?.confidence`, keyed by question
279
281
  ID. It is not the selected option's probability or a portable confidence measure.
282
+ TypeSafe Score legends are available at
283
+ `result.providerMetadata?.typesafe?.legend`, also keyed by question ID, with
284
+ structured descriptions preserved.
280
285
  Perplexity exposes Choice/Score confidence at
281
286
  `result.providerMetadata?.perplexity?.confidence` and Score legends at
282
287
  `result.providerMetadata?.perplexity?.legend`, also keyed by question ID.
@@ -32,6 +32,10 @@ When the SDK fetches a URL taken from a provider response, it:
32
32
  `.internal` hostnames. Non-`http(s)` schemes are rejected too.
33
33
  - **Re-validates every redirect hop** — a URL that passes but then redirects to
34
34
  an internal address is blocked; the redirect is never followed blindly.
35
+ - **Rejects HTTPS downgrades on server-side downloads** — a redirect from HTTPS
36
+ to HTTP is blocked before requesting the insecure target, even when that target
37
+ matches `trustedOrigin`. Initial HTTP URLs and HTTP-to-HTTPS upgrades remain
38
+ supported.
35
39
  - **Validates DNS at connection time on Node.js** — every resolved address is
36
40
  checked, and the socket is pinned to the validated DNS result so DNS
37
41
  rebinding cannot introduce a different address between validation and
@@ -43,15 +43,15 @@ described below.
43
43
  Instructions and criterion descriptions accept strings, JSON objects, or JSON
44
44
  arrays.
45
45
 
46
- | Type | Instructions | Criteria |
47
- | --------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------- |
48
- | `choice` | Optional; may be `null` | Required nonempty map of option names to descriptions |
49
- | `score` | Optional; may be `null` | Required nonempty array of levels, indexed from zero |
50
- | `boolean` | Optional; may be `null` | Optional object with `true` and/or `false` descriptions; at least one must be non-null when instructions are absent |
51
- | `box` | Required and non-null | None |
46
+ | Type | Instructions | Criteria |
47
+ | --------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
48
+ | `choice` | Optional; may be `null` | Required nonempty map of option names to descriptions |
49
+ | `score` | Optional; may be `null` | Required nonempty array of levels, indexed from zero |
50
+ | `boolean` | Optional; may be `null` | Optional object or `null`, with `true` and/or `false` descriptions; at least one must be non-null when instructions are absent |
51
+ | `box` | Optional; may be `null` | None |
52
52
 
53
53
  Criterion descriptions may be `null` in the shared type, but providers can impose
54
- stricter limits. Perplexity requires non-null Score levels and accepts 1–10 levels;
54
+ stricter limits. TypeSafe and Perplexity require non-null Score levels and accept 1–10 levels;
55
55
  a single level yields score `0` and probability `1`. Other providers may require
56
56
  at least two levels. Optional instructions also remain subject to the provider's
57
57
  API contract.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "7.0.164",
3
+ "version": "7.0.166",
4
4
  "type": "module",
5
5
  "description": "AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.",
6
6
  "license": "Apache-2.0",
@@ -42,20 +42,20 @@
42
42
  }
43
43
  },
44
44
  "dependencies": {
45
- "@ai-sdk/gateway": "4.0.137",
46
- "@ai-sdk/provider": "4.0.36",
47
- "@ai-sdk/provider-utils": "5.0.75"
45
+ "@ai-sdk/gateway": "4.0.139",
46
+ "@ai-sdk/provider": "4.0.37",
47
+ "@ai-sdk/provider-utils": "5.0.76"
48
48
  },
49
49
  "devDependencies": {
50
- "@ai-sdk/amazon-bedrock": "5.0.134",
51
- "@ai-sdk/deepseek": "3.0.80",
52
- "@ai-sdk/google": "4.0.113",
53
- "@ai-sdk/groq": "4.0.77",
54
- "@ai-sdk/huggingface": "2.0.86",
55
- "@ai-sdk/moonshotai": "3.0.86",
56
- "@ai-sdk/openai": "4.0.110",
50
+ "@ai-sdk/amazon-bedrock": "5.0.135",
51
+ "@ai-sdk/deepseek": "3.0.81",
52
+ "@ai-sdk/google": "4.0.114",
53
+ "@ai-sdk/groq": "4.0.78",
54
+ "@ai-sdk/huggingface": "2.0.87",
55
+ "@ai-sdk/moonshotai": "3.0.87",
56
+ "@ai-sdk/openai": "4.0.111",
57
57
  "@ai-sdk/test-server": "2.0.4",
58
- "@ai-sdk/xai": "5.0.39",
58
+ "@ai-sdk/xai": "5.0.40",
59
59
  "@edge-runtime/vm": "^5.0.0",
60
60
  "@smithy/eventstream-codec": "^4.3.3",
61
61
  "@smithy/util-utf8": "^4.3.3",
@@ -1213,8 +1213,8 @@ async function generateTextInternal<
1213
1213
  const result = await executeLanguageModelCallInTelemetryContext(
1214
1214
  {
1215
1215
  ...languageModelCallStartEvent,
1216
- execute: async () =>
1217
- await stepModel.doGenerate({
1216
+ execute: async () => {
1217
+ const result = await stepModel.doGenerate({
1218
1218
  ...stepCallSettings,
1219
1219
  tools: stepTools,
1220
1220
  toolChoice: stepToolChoice,
@@ -1223,24 +1223,26 @@ async function generateTextInternal<
1223
1223
  providerOptions: stepProviderOptions,
1224
1224
  abortSignal: mergedAbortSignal,
1225
1225
  headers: headersWithUserAgent,
1226
- }),
1226
+ });
1227
+ return {
1228
+ ...result,
1229
+ ...(result.request && {
1230
+ request: sanitizeRequestMetadata(result.request),
1231
+ }),
1232
+ };
1233
+ },
1227
1234
  },
1228
1235
  );
1229
1236
 
1230
- const responseData = {
1231
- id: result.response?.id ?? generateId(),
1232
- timestamp: result.response?.timestamp ?? new Date(),
1233
- modelId: result.response?.modelId ?? stepModel.modelId,
1234
- headers: result.response?.headers,
1235
- body: result.response?.body,
1236
- };
1237
-
1238
1237
  return {
1239
1238
  ...result,
1240
- ...(result.request != null
1241
- ? { request: sanitizeRequestMetadata(result.request) }
1242
- : {}),
1243
- response: responseData,
1239
+ response: {
1240
+ id: result.response?.id ?? generateId(),
1241
+ timestamp: result.response?.timestamp ?? new Date(),
1242
+ modelId: result.response?.modelId ?? stepModel.modelId,
1243
+ headers: result.response?.headers,
1244
+ body: result.response?.body,
1245
+ },
1244
1246
  };
1245
1247
  });
1246
1248
  const responseTimeMs = now() - stepStartTimestampMs;
@@ -360,11 +360,11 @@ export async function streamLanguageModelCall<
360
360
  const {
361
361
  stream: languageModelStream,
362
362
  response,
363
- request: rawRequest,
363
+ request,
364
364
  } = await executeLanguageModelCallInTelemetryContext({
365
365
  ...languageModelCallStartEvent,
366
- execute: async () =>
367
- await resolvedModel.doStream({
366
+ execute: async () => {
367
+ const result = await resolvedModel.doStream({
368
368
  ...callSettings,
369
369
  tools: stepTools,
370
370
  toolChoice: stepToolChoice,
@@ -374,11 +374,16 @@ export async function streamLanguageModelCall<
374
374
  abortSignal,
375
375
  headers,
376
376
  includeRawChunks,
377
- }),
377
+ });
378
+ return {
379
+ ...result,
380
+ ...(result.request && {
381
+ request: sanitizeRequestMetadata(result.request),
382
+ }),
383
+ };
384
+ },
378
385
  });
379
386
 
380
- const request = sanitizeRequestMetadata(rawRequest);
381
-
382
387
  const standardizedStream = languageModelStream.pipeThrough(
383
388
  createLanguageModelV4StreamPartToLanguageModelStreamPartTransform({
384
389
  tools,
@@ -95,6 +95,7 @@ export function filterTelemetryEvent<EVENT>(
95
95
  ranking: [],
96
96
  answers: {},
97
97
  segments: [],
98
+ words: [],
98
99
  });
99
100
  if (filtered.toolOutput != null) {
100
101
  filtered.toolOutput = {