@agent-device/proxy 0.21.26 → 0.21.28-nightly.20261013.49
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 +11 -3
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -116,6 +116,8 @@ const FORWARDED_RESPONSE_HEADERS = [
|
|
|
116
116
|
"x-request-id",
|
|
117
117
|
DAEMON_HTTP_INSTANCE_MISMATCH_HEADER
|
|
118
118
|
];
|
|
119
|
+
const FORWARDED_UPLOAD_CHUNK_RESPONSE_HEADERS = ["range", "x-upload-offset"];
|
|
120
|
+
const FORWARDED_ARTIFACT_DOWNLOAD_RESPONSE_HEADERS = ["content-length"];
|
|
119
121
|
function createDaemonProxy(options) {
|
|
120
122
|
const normalized = normalizeProxyOptions(options);
|
|
121
123
|
const instanceId = randomUUID();
|
|
@@ -201,7 +203,7 @@ async function forwardProxyRequest(params) {
|
|
|
201
203
|
duplex: "half"
|
|
202
204
|
} : {}
|
|
203
205
|
}));
|
|
204
|
-
const headers = copyProxyResponseHeaders(upstreamResponse, request);
|
|
206
|
+
const headers = copyProxyResponseHeaders(upstreamResponse, request, route);
|
|
205
207
|
if (isUploadPreflightRoute(route)) return await rewrittenUploadPreflightResponse({
|
|
206
208
|
request,
|
|
207
209
|
upstreamResponse,
|
|
@@ -220,15 +222,21 @@ async function forwardProxyRequest(params) {
|
|
|
220
222
|
function upstreamSignal(request, options) {
|
|
221
223
|
return AbortSignal.any([request.signal, AbortSignal.timeout(options.upstreamTimeoutMs)]);
|
|
222
224
|
}
|
|
223
|
-
function copyProxyResponseHeaders(upstreamResponse, request) {
|
|
225
|
+
function copyProxyResponseHeaders(upstreamResponse, request, route) {
|
|
224
226
|
const headers = new Headers();
|
|
225
|
-
for (const name of FORWARDED_RESPONSE_HEADERS) {
|
|
227
|
+
for (const name of [...FORWARDED_RESPONSE_HEADERS, ...routeResponseHeaders(route)]) {
|
|
226
228
|
const value = upstreamResponse.headers.get(name);
|
|
227
229
|
if (value) headers.set(name, value);
|
|
228
230
|
}
|
|
229
231
|
if (!headers.has("x-request-id")) headers.set("x-request-id", resolveRequestId(request));
|
|
230
232
|
return headers;
|
|
231
233
|
}
|
|
234
|
+
/** `content-length` stays off the preflight route because the proxy rewrites that body. */
|
|
235
|
+
function routeResponseHeaders(route) {
|
|
236
|
+
if (route.startsWith("/upload/direct/")) return FORWARDED_UPLOAD_CHUNK_RESPONSE_HEADERS;
|
|
237
|
+
if (route.startsWith("/artifacts/")) return FORWARDED_ARTIFACT_DOWNLOAD_RESPONSE_HEADERS;
|
|
238
|
+
return [];
|
|
239
|
+
}
|
|
232
240
|
async function rewrittenUploadPreflightResponse(params) {
|
|
233
241
|
const { request, upstreamResponse, headers, clientToken } = params;
|
|
234
242
|
const text = await upstreamResponse.text();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-device/proxy",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.28-nightly.20261013.49",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Transport-neutral authenticating proxy in front of an agent-device daemon.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@agent-device/kernel": "0.0.0",
|
|
29
28
|
"@agent-device/host-kit": "0.0.0",
|
|
30
|
-
"@agent-device/contracts": "0.0.0"
|
|
29
|
+
"@agent-device/contracts": "0.0.0",
|
|
30
|
+
"@agent-device/kernel": "0.0.0"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "tsdown --config tsdown.config.ts"
|