@ai-sdk/google 3.0.138 → 3.0.139

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.
@@ -1425,8 +1425,10 @@ var GoogleJSONAccumulator = class {
1425
1425
  processPartialArgs(partialArgs) {
1426
1426
  let delta = "";
1427
1427
  for (const arg of partialArgs) {
1428
- const rawPath = arg.jsonPath.replace(/^\$\./, "");
1429
- if (!rawPath) continue;
1428
+ const isArrayTerminator = arg.jsonPath.endsWith("[]");
1429
+ const jsonPath = isArrayTerminator ? arg.jsonPath.slice(0, -2) : arg.jsonPath;
1430
+ const rawPath = jsonPath.replace(/^\$\./, "");
1431
+ if (!rawPath || rawPath === "$") continue;
1430
1432
  const segments = parsePath(rawPath);
1431
1433
  const existingValue = getNestedValue(this.accumulatedArgs, segments);
1432
1434
  const isStringContinuation = arg.stringValue != null && existingValue !== void 0;
@@ -1441,7 +1443,16 @@ var GoogleJSONAccumulator = class {
1441
1443
  continue;
1442
1444
  }
1443
1445
  const resolved = resolvePartialArgValue(arg);
1444
- if (resolved == null) continue;
1446
+ if (resolved == null) {
1447
+ if (existingValue !== void 0 || arg.willContinue === true) continue;
1448
+ setNestedValue(
1449
+ this.accumulatedArgs,
1450
+ segments,
1451
+ isArrayTerminator ? [] : {}
1452
+ );
1453
+ delta += this.emitContainer(segments, isArrayTerminator);
1454
+ continue;
1455
+ }
1445
1456
  setNestedValue(this.accumulatedArgs, segments, resolved.value);
1446
1457
  delta += this.emitNavigationTo(segments, arg, resolved.json);
1447
1458
  }
@@ -1493,6 +1504,26 @@ var GoogleJSONAccumulator = class {
1493
1504
  fragment += this.emitLeaf(leafSegment, arg, valueJson);
1494
1505
  return fragment;
1495
1506
  }
1507
+ /**
1508
+ * Navigates to `targetSegments` and opens a container there. The container
1509
+ * stays open so later entries for its children continue inside it; it is
1510
+ * closed by subsequent navigation or by `finalize()`.
1511
+ *
1512
+ * Input: targetSegments=["nested","tags"], isArray=true
1513
+ * Output: '{"nested":{"tags":['
1514
+ */
1515
+ emitContainer(targetSegments, isArray) {
1516
+ let fragment = "";
1517
+ if (this.stringOpen) {
1518
+ fragment += '"';
1519
+ this.stringOpen = false;
1520
+ }
1521
+ fragment += this.ensureRoot();
1522
+ const commonDepth = this.findCommonStackDepth(targetSegments);
1523
+ fragment += this.closeDownTo(commonDepth);
1524
+ fragment += this.openDownTo(targetSegments, isArray ? 0 : "");
1525
+ return fragment;
1526
+ }
1496
1527
  /**
1497
1528
  * Returns the stack depth to preserve when navigating to a new target
1498
1529
  * container path. Always >= 1 (the root is never popped).