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/dist/index.mjs CHANGED
@@ -1225,7 +1225,7 @@ import {
1225
1225
  } from "@ai-sdk/provider-utils";
1226
1226
 
1227
1227
  // src/version.ts
1228
- var VERSION = true ? "6.0.332" : "0.0.0-test";
1228
+ var VERSION = true ? "6.0.336" : "0.0.0-test";
1229
1229
 
1230
1230
  // src/util/download/download.ts
1231
1231
  var download = async ({
@@ -2601,6 +2601,19 @@ function redactToolDefinition(tool2) {
2601
2601
  }
2602
2602
  };
2603
2603
  }
2604
+ if (tool2.id === "google.mcp_server") {
2605
+ if (!isRecord(args.headers))
2606
+ return tool2;
2607
+ return {
2608
+ ...tool2,
2609
+ args: {
2610
+ ...args,
2611
+ headers: Object.fromEntries(
2612
+ Object.keys(args.headers).map((name23) => [name23, "[redacted]"])
2613
+ )
2614
+ }
2615
+ };
2616
+ }
2604
2617
  const containerKey = tool2.id === "openai.code_interpreter" ? "container" : tool2.id === "openai.shell" ? "environment" : void 0;
2605
2618
  if (containerKey == null)
2606
2619
  return tool2;
@@ -3364,7 +3377,7 @@ async function validateApprovedToolApprovals({
3364
3377
  var _a23;
3365
3378
  const approved = [];
3366
3379
  const denied = [];
3367
- const invalid = [];
3380
+ const invalid2 = [];
3368
3381
  for (const approval of approvedToolApprovals) {
3369
3382
  const { toolCall, approvalRequest } = approval;
3370
3383
  const tool2 = tools == null ? void 0 : tools[toolCall.toolName];
@@ -3410,7 +3423,7 @@ async function validateApprovedToolApprovals({
3410
3423
  );
3411
3424
  }
3412
3425
  if (validationError != null) {
3413
- invalid.push({
3426
+ invalid2.push({
3414
3427
  ...approval,
3415
3428
  error: new InvalidToolInputError({
3416
3429
  toolName: toolCall.toolName,
@@ -3443,7 +3456,7 @@ async function validateApprovedToolApprovals({
3443
3456
  return {
3444
3457
  approvedToolApprovals: approved,
3445
3458
  deniedToolApprovals: denied,
3446
- invalidToolApprovals: invalid
3459
+ invalidToolApprovals: invalid2
3447
3460
  };
3448
3461
  }
3449
3462
 
@@ -10180,62 +10193,127 @@ import {
10180
10193
  zodSchema as zodSchema2
10181
10194
  } from "@ai-sdk/provider-utils";
10182
10195
  import { z as z8 } from "zod/v4";
10183
- function findInvalidJsonValuePath(value, path = [], visited = /* @__PURE__ */ new WeakSet()) {
10196
+
10197
+ // src/util/normalize-json-value.ts
10198
+ var invalid = Symbol("invalid");
10199
+ function normalizeJsonValue(value) {
10200
+ const path = [];
10201
+ const normalized = normalize(value, path, /* @__PURE__ */ new Set());
10202
+ return normalized === invalid ? { success: false, path } : { success: true, value: normalized };
10203
+ }
10204
+ function normalize(value, path, ancestors) {
10184
10205
  switch (typeof value) {
10206
+ case "string":
10207
+ case "boolean":
10208
+ return value;
10185
10209
  case "number":
10186
- return Number.isFinite(value) ? void 0 : [...path];
10187
- case "bigint":
10188
- case "symbol":
10189
- case "function":
10190
- return [...path];
10210
+ return Number.isFinite(value) ? value : invalid;
10191
10211
  case "object": {
10192
- if (value === null || visited.has(value)) {
10193
- return void 0;
10194
- }
10195
- visited.add(value);
10196
- const keys = Array.isArray(value) ? value.keys() : Object.keys(value);
10197
- for (const key of keys) {
10198
- if (key === "__proto__")
10199
- continue;
10200
- path.push(key);
10201
- const invalidPath = findInvalidJsonValuePath(
10202
- value[key],
10203
- path,
10204
- visited
10205
- );
10206
- if (invalidPath != null)
10207
- return invalidPath;
10208
- path.pop();
10209
- }
10210
- return void 0;
10212
+ if (value === null)
10213
+ return value;
10214
+ if (ancestors.has(value))
10215
+ return invalid;
10216
+ ancestors.add(value);
10217
+ const normalized = Array.isArray(value) ? normalizeArray(value, path, ancestors) : normalizeObject(value, path, ancestors);
10218
+ ancestors.delete(value);
10219
+ return normalized;
10211
10220
  }
10212
10221
  default:
10213
- return void 0;
10222
+ return invalid;
10223
+ }
10224
+ }
10225
+ function normalizeArray(array2, path, ancestors) {
10226
+ let copy;
10227
+ for (let index = 0; index < array2.length; index++) {
10228
+ const element = array2[index];
10229
+ path.push(index);
10230
+ const normalized = normalize(element, path, ancestors);
10231
+ if (normalized === invalid)
10232
+ return invalid;
10233
+ path.pop();
10234
+ if (copy != null) {
10235
+ copy.push(normalized);
10236
+ } else if (normalized !== element) {
10237
+ copy = array2.slice(0, index);
10238
+ copy.push(normalized);
10239
+ }
10240
+ }
10241
+ return copy != null ? copy : array2;
10242
+ }
10243
+ function normalizeObject(object2, path, ancestors) {
10244
+ if (!isPlainObject(object2) || hasEnumerableSymbolKey(object2))
10245
+ return invalid;
10246
+ const keys = Object.keys(object2);
10247
+ let copy;
10248
+ for (let index = 0; index < keys.length; index++) {
10249
+ const key = keys[index];
10250
+ if (key === "__proto__") {
10251
+ copy != null ? copy : copy = copyProperties(object2, keys, index);
10252
+ continue;
10253
+ }
10254
+ const property = object2[key];
10255
+ let normalized = property;
10256
+ if (property !== void 0) {
10257
+ path.push(key);
10258
+ normalized = normalize(property, path, ancestors);
10259
+ if (normalized === invalid)
10260
+ return invalid;
10261
+ path.pop();
10262
+ }
10263
+ if (copy != null) {
10264
+ copy[key] = normalized;
10265
+ } else if (normalized !== property) {
10266
+ copy = copyProperties(object2, keys, index);
10267
+ copy[key] = normalized;
10268
+ }
10214
10269
  }
10270
+ return copy != null ? copy : object2;
10215
10271
  }
10216
- function withJsonValueCheck(schema, jsonValuePath = []) {
10217
- return z8.unknown().check((context2) => {
10218
- let jsonValue = context2.value;
10219
- for (const key of jsonValuePath) {
10220
- jsonValue = jsonValue != null && typeof jsonValue === "object" ? jsonValue[key] : void 0;
10221
- }
10222
- const invalidPath = findInvalidJsonValuePath(jsonValue);
10223
- if (invalidPath != null) {
10224
- context2.issues.push({
10225
- code: "custom",
10226
- message: "Invalid JSON value. Expected null, a string, a finite number, a boolean, an array, or an object.",
10227
- input: context2.value,
10228
- path: [...jsonValuePath, ...invalidPath]
10229
- });
10272
+ function copyProperties(object2, keys, count) {
10273
+ const copy = {};
10274
+ for (let index = 0; index < count; index++) {
10275
+ copy[keys[index]] = object2[keys[index]];
10276
+ }
10277
+ return copy;
10278
+ }
10279
+ function isPlainObject(object2) {
10280
+ const constructor = object2.constructor;
10281
+ if (typeof constructor !== "function")
10282
+ return true;
10283
+ const prototype = constructor.prototype;
10284
+ return prototype !== null && typeof prototype === "object" && Object.prototype.hasOwnProperty.call(prototype, "isPrototypeOf");
10285
+ }
10286
+ function hasEnumerableSymbolKey(object2) {
10287
+ const symbols = Object.getOwnPropertySymbols(object2);
10288
+ for (let index = 0; index < symbols.length; index++) {
10289
+ if (Object.prototype.propertyIsEnumerable.call(object2, symbols[index])) {
10290
+ return true;
10230
10291
  }
10231
- }).pipe(schema);
10292
+ }
10293
+ return false;
10232
10294
  }
10233
- var toolMetadataRecordSchema = z8.record(
10234
- z8.string(),
10235
- jsonValueSchema.optional()
10295
+
10296
+ // src/ui/validate-ui-messages.ts
10297
+ var jsonValueSchema2 = z8.unknown().transform((value, context2) => {
10298
+ const result = normalizeJsonValue(value);
10299
+ if (!result.success) {
10300
+ context2.issues.push({
10301
+ code: "custom",
10302
+ message: "Invalid JSON value. Expected null, a string, a finite number, a boolean, an array, or an object.",
10303
+ input: value,
10304
+ path: result.path
10305
+ });
10306
+ return z8.NEVER;
10307
+ }
10308
+ return result.value;
10309
+ });
10310
+ var validatedJsonValueSchema = z8.custom();
10311
+ var toolMetadataSchema2 = jsonValueSchema2.pipe(
10312
+ z8.record(z8.string(), validatedJsonValueSchema)
10313
+ );
10314
+ var providerMetadataSchema2 = jsonValueSchema2.pipe(
10315
+ z8.record(z8.string(), z8.record(z8.string(), validatedJsonValueSchema))
10236
10316
  );
10237
- var toolMetadataSchema2 = withJsonValueCheck(toolMetadataRecordSchema);
10238
- var providerMetadataSchema2 = withJsonValueCheck(providerMetadataSchema);
10239
10317
  function isEmptyObject(value) {
10240
10318
  return value != null && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 0;
10241
10319
  }