@depup/ai-sdk__google 4.0.47-depup.0 → 4.0.48-depup.0

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 4.0.48
4
+
5
+ ### Patch Changes
6
+
7
+ - 6c5a1ed: Inline local JSON Schema references in Google tool and structured-output schemas.
8
+
3
9
  ## 4.0.47
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -13,8 +13,8 @@ npm install @depup/ai-sdk__google
13
13
 
14
14
  | Field | Value |
15
15
  |-------|-------|
16
- | Original | [@ai-sdk/google](https://www.npmjs.com/package/@ai-sdk/google) @ 4.0.47 |
17
- | Processed | 2026-08-20 |
16
+ | Original | [@ai-sdk/google](https://www.npmjs.com/package/@ai-sdk/google) @ 4.0.48 |
17
+ | Processed | 2026-08-21 |
18
18
  | Smoke test | failed |
19
19
  | Deps updated | 0 |
20
20
 
package/changes.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "bumped": {},
3
- "timestamp": "2026-08-20T00:14:59.736Z",
3
+ "timestamp": "2026-08-21T00:15:47.264Z",
4
4
  "totalUpdated": 0
5
5
  }
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  } from "@ai-sdk/provider-utils";
8
8
 
9
9
  // src/version.ts
10
- var VERSION = true ? "4.0.47" : "0.0.0-test";
10
+ var VERSION = true ? "4.0.48" : "0.0.0-test";
11
11
 
12
12
  // src/google-embedding-model.ts
13
13
  import {
@@ -303,21 +303,37 @@ import {
303
303
  UnsupportedFunctionalityError
304
304
  } from "@ai-sdk/provider";
305
305
  function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
306
+ const rootSchema = typeof jsonSchema === "object" ? jsonSchema : void 0;
307
+ return convertJSONSchemaDefinition(jsonSchema, isRoot, {
308
+ definitions: rootSchema == null ? void 0 : rootSchema.definitions,
309
+ dollarDefinitions: rootSchema == null ? void 0 : rootSchema.$defs,
310
+ resolvingReferences: /* @__PURE__ */ new Set()
311
+ });
312
+ }
313
+ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
306
314
  if (jsonSchema == null) {
307
315
  return void 0;
308
316
  }
317
+ if (typeof jsonSchema === "boolean") {
318
+ return { type: "boolean", properties: {} };
319
+ }
320
+ if (jsonSchema.$ref != null) {
321
+ return convertJSONSchemaReference({
322
+ jsonSchema,
323
+ reference: jsonSchema.$ref,
324
+ isRoot,
325
+ referenceContext
326
+ });
327
+ }
309
328
  if (isEmptyObjectSchema(jsonSchema)) {
310
329
  if (isRoot) {
311
330
  return void 0;
312
331
  }
313
- if (typeof jsonSchema === "object" && jsonSchema.description) {
332
+ if (jsonSchema.description) {
314
333
  return { type: "object", description: jsonSchema.description };
315
334
  }
316
335
  return { type: "object" };
317
336
  }
318
- if (typeof jsonSchema === "boolean") {
319
- return { type: "boolean", properties: {} };
320
- }
321
337
  const {
322
338
  type,
323
339
  description,
@@ -359,18 +375,20 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
359
375
  if (properties != null) {
360
376
  result.properties = Object.entries(properties).reduce(
361
377
  (acc, [key, value]) => {
362
- acc[key] = convertJSONSchemaToOpenAPISchema(value, false);
378
+ acc[key] = convertJSONSchemaDefinition(value, false, referenceContext);
363
379
  return acc;
364
380
  },
365
381
  {}
366
382
  );
367
383
  }
368
384
  if (items) {
369
- result.items = Array.isArray(items) ? items.map((item) => convertJSONSchemaToOpenAPISchema(item, false)) : convertJSONSchemaToOpenAPISchema(items, false);
385
+ result.items = Array.isArray(items) ? items.map(
386
+ (item) => convertJSONSchemaDefinition(item, false, referenceContext)
387
+ ) : convertJSONSchemaDefinition(items, false, referenceContext);
370
388
  }
371
389
  if (allOf) {
372
390
  result.allOf = allOf.map(
373
- (item) => convertJSONSchemaToOpenAPISchema(item, false)
391
+ (item) => convertJSONSchemaDefinition(item, false, referenceContext)
374
392
  );
375
393
  }
376
394
  if (anyOf) {
@@ -381,9 +399,10 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
381
399
  (schema) => !(typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null")
382
400
  );
383
401
  if (nonNullSchemas.length === 1) {
384
- const converted = convertJSONSchemaToOpenAPISchema(
402
+ const converted = convertJSONSchemaDefinition(
385
403
  nonNullSchemas[0],
386
- false
404
+ false,
405
+ referenceContext
387
406
  );
388
407
  if (typeof converted === "object") {
389
408
  result.nullable = true;
@@ -391,19 +410,19 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
391
410
  }
392
411
  } else {
393
412
  result.anyOf = nonNullSchemas.map(
394
- (item) => convertJSONSchemaToOpenAPISchema(item, false)
413
+ (item) => convertJSONSchemaDefinition(item, false, referenceContext)
395
414
  );
396
415
  result.nullable = true;
397
416
  }
398
417
  } else {
399
418
  result.anyOf = anyOf.map(
400
- (item) => convertJSONSchemaToOpenAPISchema(item, false)
419
+ (item) => convertJSONSchemaDefinition(item, false, referenceContext)
401
420
  );
402
421
  }
403
422
  }
404
423
  if (oneOf) {
405
424
  result.oneOf = oneOf.map(
406
- (item) => convertJSONSchemaToOpenAPISchema(item, false)
425
+ (item) => convertJSONSchemaDefinition(item, false, referenceContext)
407
426
  );
408
427
  }
409
428
  if (minLength !== void 0) {
@@ -411,6 +430,76 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
411
430
  }
412
431
  return result;
413
432
  }
433
+ function convertJSONSchemaReference({
434
+ jsonSchema,
435
+ reference,
436
+ isRoot,
437
+ referenceContext
438
+ }) {
439
+ const { definition, referenceKey } = getReferencedDefinition(
440
+ reference,
441
+ referenceContext
442
+ );
443
+ if (referenceContext.resolvingReferences.has(referenceKey)) {
444
+ throw new UnsupportedFunctionalityError({
445
+ functionality: `recursive JSON Schema reference: ${reference}`,
446
+ message: "Google schema conversion does not support recursive JSON Schema references."
447
+ });
448
+ }
449
+ const resolvingReferences = new Set(referenceContext.resolvingReferences);
450
+ resolvingReferences.add(referenceKey);
451
+ const { $ref: _reference, ...siblingSchema } = jsonSchema;
452
+ const resolvedSchema = typeof definition === "boolean" ? definition ? siblingSchema : false : { ...definition, ...siblingSchema };
453
+ return convertJSONSchemaDefinition(resolvedSchema, isRoot, {
454
+ ...referenceContext,
455
+ resolvingReferences
456
+ });
457
+ }
458
+ function getReferencedDefinition(reference, referenceContext) {
459
+ const definitionSources = [
460
+ {
461
+ prefix: "#/$defs/",
462
+ definitions: referenceContext.dollarDefinitions
463
+ },
464
+ {
465
+ prefix: "#/definitions/",
466
+ definitions: referenceContext.definitions
467
+ }
468
+ ];
469
+ const source = definitionSources.find(
470
+ ({ prefix }) => reference.startsWith(prefix)
471
+ );
472
+ const encodedDefinitionName = source ? reference.slice(source.prefix.length) : void 0;
473
+ if (source == null || encodedDefinitionName == null || encodedDefinitionName.length === 0 || encodedDefinitionName.includes("/")) {
474
+ throwUnsupportedReference(reference);
475
+ }
476
+ let decodedDefinitionName;
477
+ try {
478
+ decodedDefinitionName = decodeURIComponent(encodedDefinitionName);
479
+ } catch (e) {
480
+ throwUnsupportedReference(reference);
481
+ }
482
+ if (decodedDefinitionName.includes("/") || /~(?![01])/u.test(decodedDefinitionName) || source.definitions == null) {
483
+ throwUnsupportedReference(reference);
484
+ }
485
+ const definitionName = decodedDefinitionName.replace(
486
+ /~[01]/g,
487
+ (match) => match === "~1" ? "/" : "~"
488
+ );
489
+ if (!Object.prototype.hasOwnProperty.call(source.definitions, definitionName)) {
490
+ throwUnsupportedReference(reference);
491
+ }
492
+ return {
493
+ definition: source.definitions[definitionName],
494
+ referenceKey: `${source.prefix}${definitionName}`
495
+ };
496
+ }
497
+ function throwUnsupportedReference(reference) {
498
+ throw new UnsupportedFunctionalityError({
499
+ functionality: `JSON Schema reference: ${reference}`,
500
+ message: "Google schema conversion only supports references to direct children of root-level $defs or definitions."
501
+ });
502
+ }
414
503
  function addEnumToSchema({
415
504
  values,
416
505
  type,