site-agent-pro 1.0.3 → 1.0.5

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/bin.js CHANGED
File without changes
@@ -1,7 +1,10 @@
1
1
  import fs from "node:fs";
2
2
  import http from "node:http";
3
3
  import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
4
5
  import dotenv from "dotenv";
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
5
8
  import { buildRunDetail, buildStandaloneReportHtml, listVisibleRunSummaries } from "../backend/dashboardData.js";
6
9
  import { artifactContentType, isAllowedDashboardArtifact, isImageArtifact, isVideoArtifact } from "../backend/runArtifacts.js";
7
10
  import { createLocalRunRepository } from "../backend/runRepository.js";
@@ -31,25 +34,6 @@ function resolveDashboardHost() {
31
34
  }
32
35
  return process.env.RENDER === "true" ? RENDER_HOST : DEFAULT_HOST;
33
36
  }
34
- function getClientScript() {
35
- // In production, we serve the pre-compiled .js file from the dist directory.
36
- // We look for it relative to the current file's location.
37
- const distPath = path.join(process.cwd(), "dist", "dashboard", "client.js");
38
- const srcPath = path.join(process.cwd(), "src", "dashboard", "client.ts");
39
- if (fs.existsSync(distPath)) {
40
- return fs.readFileSync(distPath, "utf8");
41
- }
42
- // Fallback for development if dist doesn't exist yet
43
- warn("Dashboard client.js not found in dist. Dashboard may not function correctly in production without a build.");
44
- return "// Dashboard client not found. Run 'npm run build' first.";
45
- }
46
- function getNarrativeScript() {
47
- const distPath = path.join(process.cwd(), "dist", "dashboard", "narrative.js");
48
- if (fs.existsSync(distPath)) {
49
- return fs.readFileSync(distPath, "utf8");
50
- }
51
- return "// Narrative script not found.";
52
- }
53
37
  function renderDashboardHtml() {
54
38
  return `<!doctype html>
55
39
  <html lang="en">
@@ -208,13 +192,17 @@ async function handleRequest(req, res, args) {
208
192
  sendText(res, 200, renderDashboardHtml(), "text/html");
209
193
  return;
210
194
  }
211
- if (requestUrl.pathname === "/app.js") {
212
- sendText(res, 200, getClientScript(), "application/javascript");
213
- return;
214
- }
215
- if (requestUrl.pathname === "/narrative.js") {
216
- sendText(res, 200, getNarrativeScript(), "application/javascript");
217
- return;
195
+ // Dynamic Static Asset Loader for Dashboard
196
+ // This allows the browser to fetch any .js files needed by the dashboard
197
+ const dashboardScripts = ["app.js", "narrative.js", "contracts.js", "theme.js"];
198
+ if (dashboardScripts.includes(pathParts[0] || "")) {
199
+ const requestedName = pathParts[0];
200
+ const diskName = requestedName === "app.js" ? "client.js" : requestedName;
201
+ const distPath = path.join(__dirname, diskName);
202
+ if (fs.existsSync(distPath)) {
203
+ sendText(res, 200, fs.readFileSync(distPath, "utf8"), "application/javascript");
204
+ return;
205
+ }
218
206
  }
219
207
  if (pathParts[0] === "submissions" && pathParts[1] && pathParts.length === 2) {
220
208
  const submission = await args.submissionService.getSubmission(decodeURIComponent(pathParts[1]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "site-agent-pro",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "type": "module",
5
5
  "description": "AI-powered browser agent that tests websites like a real user and produces evidence-based, scored reports.",
6
6
  "bin": {