ag-common 0.0.779 → 0.0.781
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.
|
@@ -136,15 +136,38 @@ const geminiPromptDirect = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
138
|
exports.geminiPromptDirect = geminiPromptDirect;
|
|
139
|
-
// if url contains "vertexaisearch.cloud.google.com", follow redirect
|
|
140
139
|
const resolveGroundedUrl = (url) => __awaiter(void 0, void 0, void 0, function* () {
|
|
141
|
-
if (url.includes('vertexaisearch.cloud.google.com')) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
140
|
+
if (!url.includes('vertexaisearch.cloud.google.com')) {
|
|
141
|
+
(0, log_1.debug)('not a grounded url', url);
|
|
142
|
+
return url;
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
(0, log_1.debug)('resolving grounded url', url);
|
|
146
|
+
// Fetch the grounded URL with redirect following disabled
|
|
147
|
+
const response = yield fetch(url, {
|
|
148
|
+
method: 'HEAD',
|
|
149
|
+
redirect: 'manual',
|
|
150
|
+
});
|
|
151
|
+
// Check for redirect responses (301, 302, 307, 308)
|
|
152
|
+
if (response.status >= 300 && response.status < 400) {
|
|
153
|
+
const location = response.headers.get('location') || response.headers.get('Location');
|
|
154
|
+
if (location) {
|
|
155
|
+
(0, log_1.debug)('resolved grounded url to', location);
|
|
156
|
+
return location;
|
|
157
|
+
}
|
|
146
158
|
}
|
|
159
|
+
// If no redirect, try a GET request to follow any JavaScript redirects
|
|
160
|
+
const fullResponse = yield fetch(url, {
|
|
161
|
+
redirect: 'follow',
|
|
162
|
+
});
|
|
163
|
+
const finalUrl = fullResponse.url;
|
|
164
|
+
(0, log_1.debug)('resolved grounded url via GET to', finalUrl);
|
|
165
|
+
return finalUrl;
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
(0, log_1.debug)('error resolving grounded url', error);
|
|
169
|
+
// Return original URL if resolution fails
|
|
170
|
+
return url;
|
|
147
171
|
}
|
|
148
|
-
return url;
|
|
149
172
|
});
|
|
150
173
|
exports.resolveGroundedUrl = resolveGroundedUrl;
|
package/package.json
CHANGED