site-agent-pro 1.0.1 → 1.0.2

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.
@@ -2,14 +2,12 @@ import fs from "node:fs";
2
2
  import http from "node:http";
3
3
  import path from "node:path";
4
4
  import dotenv from "dotenv";
5
- import ts from "typescript";
6
5
  import { buildRunDetail, buildStandaloneReportHtml, listVisibleRunSummaries } from "../backend/dashboardData.js";
7
6
  import { artifactContentType, isAllowedDashboardArtifact, isImageArtifact, isVideoArtifact } from "../backend/runArtifacts.js";
8
7
  import { createLocalRunRepository } from "../backend/runRepository.js";
9
8
  import { config } from "../config.js";
10
9
  import { buildDefaultTradeRunOptions } from "../trade/policy.js";
11
10
  import { TradeStrategySchema } from "../trade/types.js";
12
- import { readUtf8 } from "../utils/files.js";
13
11
  import { info, warn } from "../utils/log.js";
14
12
  import { canAccessPublicReport, renderExpiredReportPage, renderLandingPage, renderReportUnavailablePage, renderSubmissionStatusPage } from "../submissions/html.js";
15
13
  import { readSubmittedInstructionSource, SUBMISSION_TASKS_REQUIRED_MESSAGE } from "../submissions/customTasks.js";
@@ -19,9 +17,6 @@ import { SubmissionService } from "../submissions/service.js";
19
17
  import { DASHBOARD_CSS as SHARED_DASHBOARD_CSS, DASHBOARD_HEAD_TAGS } from "./theme.js";
20
18
  import { handleWebhook } from "../paystack/index.js";
21
19
  dotenv.config();
22
- const DASHBOARD_SRC_DIR = path.join(process.cwd(), "src", "dashboard");
23
- const CLIENT_ENTRY = path.join(DASHBOARD_SRC_DIR, "client.ts");
24
- const NARRATIVE_ENTRY = path.join(DASHBOARD_SRC_DIR, "narrative.ts");
25
20
  const DEFAULT_PORT = 4173;
26
21
  const DEFAULT_HOST = "127.0.0.1";
27
22
  const RENDER_HOST = "0.0.0.0";
@@ -36,24 +31,24 @@ function resolveDashboardHost() {
36
31
  }
37
32
  return process.env.RENDER === "true" ? RENDER_HOST : DEFAULT_HOST;
38
33
  }
39
- function transpileDashboardModule(entryPath) {
40
- const source = readUtf8(entryPath);
41
- const transpiled = ts.transpileModule(source, {
42
- compilerOptions: {
43
- target: ts.ScriptTarget.ES2022,
44
- module: ts.ModuleKind.ES2022,
45
- importsNotUsedAsValues: ts.ImportsNotUsedAsValues.Remove,
46
- isolatedModules: true
47
- },
48
- fileName: entryPath
49
- });
50
- return transpiled.outputText;
51
- }
52
34
  function getClientScript() {
53
- return transpileDashboardModule(CLIENT_ENTRY);
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.";
54
45
  }
55
46
  function getNarrativeScript() {
56
- return transpileDashboardModule(NARRATIVE_ENTRY);
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.";
57
52
  }
58
53
  function renderDashboardHtml() {
59
54
  return `<!doctype html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "site-agent-pro",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
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": {