behavior-wrapped 0.2.16 → 0.2.18

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/server/store.mjs CHANGED
@@ -2,6 +2,7 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import os from "node:os";
4
4
  import crypto from "node:crypto";
5
+ import { canonicalBehaviorWrappedUrl } from "./origins.mjs";
5
6
 
6
7
  export const storeRoot = process.env.BEHAVIOR_WRAPPED_STORE_ROOT || path.join(os.homedir(), ".agent-behavior-wrapped");
7
8
  export const reportsRoot = path.join(storeRoot, "reports");
@@ -61,7 +62,14 @@ export function loadReport(id) {
61
62
  if (!/^[A-Za-z0-9_-]{8,32}$/.test(id)) return null;
62
63
  const file = path.join(reportsRoot, `${id}.json`);
63
64
  if (!fs.existsSync(file)) return null;
64
- try { return JSON.parse(fs.readFileSync(file, "utf8")); } catch { return null; }
65
+ try {
66
+ const report = JSON.parse(fs.readFileSync(file, "utf8"));
67
+ return {
68
+ ...report,
69
+ ...(report.publicUrl ? { publicUrl: canonicalBehaviorWrappedUrl(report.publicUrl) } : {}),
70
+ ...(report.managementUrl ? { managementUrl: canonicalBehaviorWrappedUrl(report.managementUrl) } : {}),
71
+ };
72
+ } catch { return null; }
65
73
  }
66
74
 
67
75
  export function listReports() {