ai 6.0.332 → 6.0.336
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 +43 -0
- package/dist/index.js +128 -50
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +128 -50
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +1 -0
- package/docs/03-ai-sdk-core/36-transcription.mdx +2 -2
- package/docs/03-ai-sdk-core/37-speech.mdx +1 -0
- package/package.json +6 -6
- package/src/telemetry/redact-tool-definition.ts +14 -0
- package/src/ui/validate-ui-messages.ts +36 -87
- package/src/util/normalize-json-value.ts +182 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 6.0.336
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [b2e515b]
|
|
8
|
+
- @ai-sdk/gateway@3.0.241
|
|
9
|
+
|
|
10
|
+
## 6.0.335
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- a6d5850: fix(ai): redact Google MCP server credentials in telemetry tool definitions
|
|
15
|
+
|
|
16
|
+
`google.mcp_server` provider tool definitions accept headers such as
|
|
17
|
+
`Authorization` for the Interactions MCP connector. Telemetry redaction only
|
|
18
|
+
recognized OpenAI tool ids, so those reusable credentials were recorded in the
|
|
19
|
+
`ai.prompt.tools` span attribute of `generateText` and `streamText`. Telemetry
|
|
20
|
+
previews now redact every `google.mcp_server` header value. The tool arguments
|
|
21
|
+
sent to the provider and used by the application are unchanged.
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [eec7bd8]
|
|
24
|
+
- Updated dependencies [8a9bcc8]
|
|
25
|
+
- Updated dependencies [e1a5663]
|
|
26
|
+
- @ai-sdk/gateway@3.0.240
|
|
27
|
+
|
|
28
|
+
## 6.0.334
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- Updated dependencies [4acbcc9]
|
|
33
|
+
- @ai-sdk/gateway@3.0.239
|
|
34
|
+
|
|
35
|
+
## 6.0.333
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- 2771b61: Reduce memory and CPU usage when validating UI messages with deeply nested provider or tool metadata. `validateUIMessages` and `safeValidateUIMessages`, which the agent UI stream helpers also use, validated JSON values in `providerMetadata`, `callProviderMetadata`, `resultProviderMetadata`, and `toolMetadata` with a recursive union schema that needed several times the memory of the value. These values are now validated in a single pass and are no longer copied, except to remove `__proto__` keys.
|
|
40
|
+
- Updated dependencies [9faffa5]
|
|
41
|
+
- Updated dependencies [3cf16af]
|
|
42
|
+
- Updated dependencies [d59eee0]
|
|
43
|
+
- @ai-sdk/gateway@3.0.238
|
|
44
|
+
- @ai-sdk/provider-utils@4.0.67
|
|
45
|
+
|
|
3
46
|
## 6.0.332
|
|
4
47
|
|
|
5
48
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1335,7 +1335,7 @@ function detectMediaType({
|
|
|
1335
1335
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
1336
1336
|
|
|
1337
1337
|
// src/version.ts
|
|
1338
|
-
var VERSION = true ? "6.0.
|
|
1338
|
+
var VERSION = true ? "6.0.336" : "0.0.0-test";
|
|
1339
1339
|
|
|
1340
1340
|
// src/util/download/download.ts
|
|
1341
1341
|
var download = async ({
|
|
@@ -2701,6 +2701,19 @@ function redactToolDefinition(tool2) {
|
|
|
2701
2701
|
}
|
|
2702
2702
|
};
|
|
2703
2703
|
}
|
|
2704
|
+
if (tool2.id === "google.mcp_server") {
|
|
2705
|
+
if (!isRecord(args.headers))
|
|
2706
|
+
return tool2;
|
|
2707
|
+
return {
|
|
2708
|
+
...tool2,
|
|
2709
|
+
args: {
|
|
2710
|
+
...args,
|
|
2711
|
+
headers: Object.fromEntries(
|
|
2712
|
+
Object.keys(args.headers).map((name23) => [name23, "[redacted]"])
|
|
2713
|
+
)
|
|
2714
|
+
}
|
|
2715
|
+
};
|
|
2716
|
+
}
|
|
2704
2717
|
const containerKey = tool2.id === "openai.code_interpreter" ? "container" : tool2.id === "openai.shell" ? "environment" : void 0;
|
|
2705
2718
|
if (containerKey == null)
|
|
2706
2719
|
return tool2;
|
|
@@ -3453,7 +3466,7 @@ async function validateApprovedToolApprovals({
|
|
|
3453
3466
|
var _a23;
|
|
3454
3467
|
const approved = [];
|
|
3455
3468
|
const denied = [];
|
|
3456
|
-
const
|
|
3469
|
+
const invalid2 = [];
|
|
3457
3470
|
for (const approval of approvedToolApprovals) {
|
|
3458
3471
|
const { toolCall, approvalRequest } = approval;
|
|
3459
3472
|
const tool2 = tools == null ? void 0 : tools[toolCall.toolName];
|
|
@@ -3499,7 +3512,7 @@ async function validateApprovedToolApprovals({
|
|
|
3499
3512
|
);
|
|
3500
3513
|
}
|
|
3501
3514
|
if (validationError != null) {
|
|
3502
|
-
|
|
3515
|
+
invalid2.push({
|
|
3503
3516
|
...approval,
|
|
3504
3517
|
error: new InvalidToolInputError({
|
|
3505
3518
|
toolName: toolCall.toolName,
|
|
@@ -3532,7 +3545,7 @@ async function validateApprovedToolApprovals({
|
|
|
3532
3545
|
return {
|
|
3533
3546
|
approvedToolApprovals: approved,
|
|
3534
3547
|
deniedToolApprovals: denied,
|
|
3535
|
-
invalidToolApprovals:
|
|
3548
|
+
invalidToolApprovals: invalid2
|
|
3536
3549
|
};
|
|
3537
3550
|
}
|
|
3538
3551
|
|
|
@@ -10235,62 +10248,127 @@ async function convertToModelMessages(messages, options) {
|
|
|
10235
10248
|
var import_provider31 = require("@ai-sdk/provider");
|
|
10236
10249
|
var import_provider_utils25 = require("@ai-sdk/provider-utils");
|
|
10237
10250
|
var import_v48 = require("zod/v4");
|
|
10238
|
-
|
|
10251
|
+
|
|
10252
|
+
// src/util/normalize-json-value.ts
|
|
10253
|
+
var invalid = Symbol("invalid");
|
|
10254
|
+
function normalizeJsonValue(value) {
|
|
10255
|
+
const path = [];
|
|
10256
|
+
const normalized = normalize(value, path, /* @__PURE__ */ new Set());
|
|
10257
|
+
return normalized === invalid ? { success: false, path } : { success: true, value: normalized };
|
|
10258
|
+
}
|
|
10259
|
+
function normalize(value, path, ancestors) {
|
|
10239
10260
|
switch (typeof value) {
|
|
10261
|
+
case "string":
|
|
10262
|
+
case "boolean":
|
|
10263
|
+
return value;
|
|
10240
10264
|
case "number":
|
|
10241
|
-
return Number.isFinite(value) ?
|
|
10242
|
-
case "bigint":
|
|
10243
|
-
case "symbol":
|
|
10244
|
-
case "function":
|
|
10245
|
-
return [...path];
|
|
10265
|
+
return Number.isFinite(value) ? value : invalid;
|
|
10246
10266
|
case "object": {
|
|
10247
|
-
if (value === null
|
|
10248
|
-
return
|
|
10249
|
-
|
|
10250
|
-
|
|
10251
|
-
|
|
10252
|
-
|
|
10253
|
-
|
|
10254
|
-
|
|
10255
|
-
path.push(key);
|
|
10256
|
-
const invalidPath = findInvalidJsonValuePath(
|
|
10257
|
-
value[key],
|
|
10258
|
-
path,
|
|
10259
|
-
visited
|
|
10260
|
-
);
|
|
10261
|
-
if (invalidPath != null)
|
|
10262
|
-
return invalidPath;
|
|
10263
|
-
path.pop();
|
|
10264
|
-
}
|
|
10265
|
-
return void 0;
|
|
10267
|
+
if (value === null)
|
|
10268
|
+
return value;
|
|
10269
|
+
if (ancestors.has(value))
|
|
10270
|
+
return invalid;
|
|
10271
|
+
ancestors.add(value);
|
|
10272
|
+
const normalized = Array.isArray(value) ? normalizeArray(value, path, ancestors) : normalizeObject(value, path, ancestors);
|
|
10273
|
+
ancestors.delete(value);
|
|
10274
|
+
return normalized;
|
|
10266
10275
|
}
|
|
10267
10276
|
default:
|
|
10268
|
-
return
|
|
10277
|
+
return invalid;
|
|
10278
|
+
}
|
|
10279
|
+
}
|
|
10280
|
+
function normalizeArray(array2, path, ancestors) {
|
|
10281
|
+
let copy;
|
|
10282
|
+
for (let index = 0; index < array2.length; index++) {
|
|
10283
|
+
const element = array2[index];
|
|
10284
|
+
path.push(index);
|
|
10285
|
+
const normalized = normalize(element, path, ancestors);
|
|
10286
|
+
if (normalized === invalid)
|
|
10287
|
+
return invalid;
|
|
10288
|
+
path.pop();
|
|
10289
|
+
if (copy != null) {
|
|
10290
|
+
copy.push(normalized);
|
|
10291
|
+
} else if (normalized !== element) {
|
|
10292
|
+
copy = array2.slice(0, index);
|
|
10293
|
+
copy.push(normalized);
|
|
10294
|
+
}
|
|
10295
|
+
}
|
|
10296
|
+
return copy != null ? copy : array2;
|
|
10297
|
+
}
|
|
10298
|
+
function normalizeObject(object2, path, ancestors) {
|
|
10299
|
+
if (!isPlainObject(object2) || hasEnumerableSymbolKey(object2))
|
|
10300
|
+
return invalid;
|
|
10301
|
+
const keys = Object.keys(object2);
|
|
10302
|
+
let copy;
|
|
10303
|
+
for (let index = 0; index < keys.length; index++) {
|
|
10304
|
+
const key = keys[index];
|
|
10305
|
+
if (key === "__proto__") {
|
|
10306
|
+
copy != null ? copy : copy = copyProperties(object2, keys, index);
|
|
10307
|
+
continue;
|
|
10308
|
+
}
|
|
10309
|
+
const property = object2[key];
|
|
10310
|
+
let normalized = property;
|
|
10311
|
+
if (property !== void 0) {
|
|
10312
|
+
path.push(key);
|
|
10313
|
+
normalized = normalize(property, path, ancestors);
|
|
10314
|
+
if (normalized === invalid)
|
|
10315
|
+
return invalid;
|
|
10316
|
+
path.pop();
|
|
10317
|
+
}
|
|
10318
|
+
if (copy != null) {
|
|
10319
|
+
copy[key] = normalized;
|
|
10320
|
+
} else if (normalized !== property) {
|
|
10321
|
+
copy = copyProperties(object2, keys, index);
|
|
10322
|
+
copy[key] = normalized;
|
|
10323
|
+
}
|
|
10269
10324
|
}
|
|
10325
|
+
return copy != null ? copy : object2;
|
|
10270
10326
|
}
|
|
10271
|
-
function
|
|
10272
|
-
|
|
10273
|
-
|
|
10274
|
-
|
|
10275
|
-
|
|
10276
|
-
|
|
10277
|
-
|
|
10278
|
-
|
|
10279
|
-
|
|
10280
|
-
|
|
10281
|
-
|
|
10282
|
-
|
|
10283
|
-
|
|
10284
|
-
|
|
10327
|
+
function copyProperties(object2, keys, count) {
|
|
10328
|
+
const copy = {};
|
|
10329
|
+
for (let index = 0; index < count; index++) {
|
|
10330
|
+
copy[keys[index]] = object2[keys[index]];
|
|
10331
|
+
}
|
|
10332
|
+
return copy;
|
|
10333
|
+
}
|
|
10334
|
+
function isPlainObject(object2) {
|
|
10335
|
+
const constructor = object2.constructor;
|
|
10336
|
+
if (typeof constructor !== "function")
|
|
10337
|
+
return true;
|
|
10338
|
+
const prototype = constructor.prototype;
|
|
10339
|
+
return prototype !== null && typeof prototype === "object" && Object.prototype.hasOwnProperty.call(prototype, "isPrototypeOf");
|
|
10340
|
+
}
|
|
10341
|
+
function hasEnumerableSymbolKey(object2) {
|
|
10342
|
+
const symbols = Object.getOwnPropertySymbols(object2);
|
|
10343
|
+
for (let index = 0; index < symbols.length; index++) {
|
|
10344
|
+
if (Object.prototype.propertyIsEnumerable.call(object2, symbols[index])) {
|
|
10345
|
+
return true;
|
|
10285
10346
|
}
|
|
10286
|
-
}
|
|
10347
|
+
}
|
|
10348
|
+
return false;
|
|
10287
10349
|
}
|
|
10288
|
-
|
|
10289
|
-
|
|
10290
|
-
|
|
10350
|
+
|
|
10351
|
+
// src/ui/validate-ui-messages.ts
|
|
10352
|
+
var jsonValueSchema2 = import_v48.z.unknown().transform((value, context2) => {
|
|
10353
|
+
const result = normalizeJsonValue(value);
|
|
10354
|
+
if (!result.success) {
|
|
10355
|
+
context2.issues.push({
|
|
10356
|
+
code: "custom",
|
|
10357
|
+
message: "Invalid JSON value. Expected null, a string, a finite number, a boolean, an array, or an object.",
|
|
10358
|
+
input: value,
|
|
10359
|
+
path: result.path
|
|
10360
|
+
});
|
|
10361
|
+
return import_v48.z.NEVER;
|
|
10362
|
+
}
|
|
10363
|
+
return result.value;
|
|
10364
|
+
});
|
|
10365
|
+
var validatedJsonValueSchema = import_v48.z.custom();
|
|
10366
|
+
var toolMetadataSchema2 = jsonValueSchema2.pipe(
|
|
10367
|
+
import_v48.z.record(import_v48.z.string(), validatedJsonValueSchema)
|
|
10368
|
+
);
|
|
10369
|
+
var providerMetadataSchema2 = jsonValueSchema2.pipe(
|
|
10370
|
+
import_v48.z.record(import_v48.z.string(), import_v48.z.record(import_v48.z.string(), validatedJsonValueSchema))
|
|
10291
10371
|
);
|
|
10292
|
-
var toolMetadataSchema2 = withJsonValueCheck(toolMetadataRecordSchema);
|
|
10293
|
-
var providerMetadataSchema2 = withJsonValueCheck(providerMetadataSchema);
|
|
10294
10372
|
function isEmptyObject(value) {
|
|
10295
10373
|
return value != null && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 0;
|
|
10296
10374
|
}
|