@ai-sdk/google 4.0.103 → 4.0.105

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google",
3
- "version": "4.0.103",
3
+ "version": "4.0.105",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -35,8 +35,8 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@ai-sdk/provider": "4.0.32",
39
- "@ai-sdk/provider-utils": "5.0.66"
38
+ "@ai-sdk/provider": "4.0.34",
39
+ "@ai-sdk/provider-utils": "5.0.68"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@ai-sdk/test-server": "2.0.4",
@@ -51,8 +51,14 @@ export class GoogleJSONAccumulator {
51
51
  let delta = '';
52
52
 
53
53
  for (const arg of partialArgs) {
54
- const rawPath = arg.jsonPath.replace(/^\$\./, '');
55
- if (!rawPath) continue;
54
+ // Vertex terminates an array with a value-less `$.path[]` entry. For an
55
+ // empty array, that terminator is the only entry sent for the path.
56
+ const isArrayTerminator = arg.jsonPath.endsWith('[]');
57
+ const jsonPath = isArrayTerminator
58
+ ? arg.jsonPath.slice(0, -2)
59
+ : arg.jsonPath;
60
+ const rawPath = jsonPath.replace(/^\$\./, '');
61
+ if (!rawPath || rawPath === '$') continue;
56
62
 
57
63
  const segments = parsePath(rawPath);
58
64
 
@@ -72,7 +78,20 @@ export class GoogleJSONAccumulator {
72
78
  }
73
79
 
74
80
  const resolved = resolvePartialArgValue(arg);
75
- if (resolved == null) continue;
81
+ if (resolved == null) {
82
+ // A value-less entry for a path without a value is an empty container
83
+ // (an empty container has no leaves to stream). Value-less entries for
84
+ // existing paths are string or array terminators and are ignored.
85
+ if (existingValue !== undefined || arg.willContinue === true) continue;
86
+
87
+ setNestedValue(
88
+ this.accumulatedArgs,
89
+ segments,
90
+ isArrayTerminator ? [] : {},
91
+ );
92
+ delta += this.emitContainer(segments, isArrayTerminator);
93
+ continue;
94
+ }
76
95
 
77
96
  setNestedValue(this.accumulatedArgs, segments, resolved.value);
78
97
  delta += this.emitNavigationTo(segments, arg, resolved.json);
@@ -141,6 +160,36 @@ export class GoogleJSONAccumulator {
141
160
  return fragment;
142
161
  }
143
162
 
163
+ /**
164
+ * Navigates to `targetSegments` and opens a container there. The container
165
+ * stays open so later entries for its children continue inside it; it is
166
+ * closed by subsequent navigation or by `finalize()`.
167
+ *
168
+ * Input: targetSegments=["nested","tags"], isArray=true
169
+ * Output: '{"nested":{"tags":['
170
+ */
171
+ private emitContainer(
172
+ targetSegments: PathSegment[],
173
+ isArray: boolean,
174
+ ): string {
175
+ let fragment = '';
176
+
177
+ if (this.stringOpen) {
178
+ fragment += '"';
179
+ this.stringOpen = false;
180
+ }
181
+
182
+ fragment += this.ensureRoot();
183
+
184
+ const commonDepth = this.findCommonStackDepth(targetSegments);
185
+
186
+ fragment += this.closeDownTo(commonDepth);
187
+ // openDownTo infers the innermost container type from the leaf segment type
188
+ fragment += this.openDownTo(targetSegments, isArray ? 0 : '');
189
+
190
+ return fragment;
191
+ }
192
+
144
193
  /**
145
194
  * Returns the stack depth to preserve when navigating to a new target
146
195
  * container path. Always >= 1 (the root is never popped).