agent-relay-server 0.4.39 → 0.6.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/README.md +8 -8
- package/package.json +1 -1
- package/public/dashboard.js +233 -17
- package/public/icons/agent-relay-192.png +0 -0
- package/public/icons/agent-relay-512.png +0 -0
- package/public/icons/agent-relay.svg +14 -0
- package/public/index.html +276 -4
- package/public/manifest.webmanifest +33 -0
- package/public/sw.js +58 -0
- package/src/cli.ts +80 -17
- package/src/connectors.ts +256 -0
- package/src/db.ts +544 -25
- package/src/index.ts +25 -1
- package/src/routes.ts +632 -26
- package/src/security.ts +2 -1
- package/src/sse.ts +21 -1
- package/src/types.ts +152 -3
package/src/index.ts
CHANGED
|
@@ -117,12 +117,36 @@ export function createFetchHandler(
|
|
|
117
117
|
return Response.json({ error: "not found" }, { status: 404 });
|
|
118
118
|
}
|
|
119
119
|
const file = Bun.file(resolved);
|
|
120
|
-
if (await file.exists())
|
|
120
|
+
if (await file.exists()) {
|
|
121
|
+
const headers = staticHeaders(requested);
|
|
122
|
+
return new Response(file, { headers });
|
|
123
|
+
}
|
|
121
124
|
|
|
122
125
|
return Response.json({ error: "not found" }, { status: 404 });
|
|
123
126
|
};
|
|
124
127
|
}
|
|
125
128
|
|
|
129
|
+
function staticHeaders(pathname: string): Headers {
|
|
130
|
+
const headers = new Headers();
|
|
131
|
+
const contentType = staticContentType(pathname);
|
|
132
|
+
if (contentType) headers.set("Content-Type", contentType);
|
|
133
|
+
if (pathname === "/sw.js") {
|
|
134
|
+
headers.set("Cache-Control", "no-cache");
|
|
135
|
+
} else if (pathname === "/manifest.webmanifest") {
|
|
136
|
+
headers.set("Cache-Control", "no-cache");
|
|
137
|
+
}
|
|
138
|
+
return headers;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function staticContentType(pathname: string): string | undefined {
|
|
142
|
+
if (pathname.endsWith(".webmanifest")) return "application/manifest+json; charset=utf-8";
|
|
143
|
+
if (pathname.endsWith(".js")) return "text/javascript; charset=utf-8";
|
|
144
|
+
if (pathname.endsWith(".html")) return "text/html; charset=utf-8";
|
|
145
|
+
if (pathname.endsWith(".svg")) return "image/svg+xml";
|
|
146
|
+
if (pathname.endsWith(".png")) return "image/png";
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
|
|
126
150
|
if (import.meta.main) {
|
|
127
151
|
main().catch((error) => {
|
|
128
152
|
console.error(error instanceof Error ? error.message : String(error));
|