solsticestudioai commited on
Commit
adcc1b7
·
verified ·
1 Parent(s): 3f831f4

Export built-in demo as exchange v1

Browse files
Files changed (1) hide show
  1. app.js +2 -2
app.js CHANGED
@@ -1,4 +1,4 @@
1
- import { parseTrace, compareBranch, parseExchange, attachFindings, downloadJson } from "./replay-core.js";
2
  const $ = selector => document.querySelector(selector);
3
  let trace = null; let importedFindings = [];
4
  function esc(value) { return String(value ?? "").replace(/[&<>'"]/g, c => ({"&":"&amp;","<":"&lt;",">":"&gt;","'":"&#39;",'"':"&quot;"}[c])); }
@@ -13,5 +13,5 @@ async function loadText(text) { try { const parsed = JSON.parse(text.trim().spli
13
  $("#file").addEventListener("change", event => event.target.files[0]?.text().then(loadText));
14
  $("#findings-file").addEventListener("change", event => event.target.files[0]?.text().then(text => { try { importedFindings = JSON.parse(text).findings || JSON.parse(text); if (trace?.schema_version === "solstice-agent-trace-exchange/v1") trace = attachFindings(trace, importedFindings); renderTrace(); } catch (error) { $("#error").textContent = error.message; } }));
15
  $("#branch").addEventListener("change", renderComparison);
16
- $("#download").addEventListener("click", () => { if (trace) downloadJson(trace, `${trace.trace_id || "trace"}-exchange.json`); });
17
  fetch("data/traces.jsonl").then(response => response.text()).then(text => loadText(text)).catch(() => { $("#error").textContent = "Load a local trace JSON file to begin."; });
 
1
+ import { parseTrace, compareBranch, parseExchange, toExchange, attachFindings, downloadJson } from "./replay-core.js";
2
  const $ = selector => document.querySelector(selector);
3
  let trace = null; let importedFindings = [];
4
  function esc(value) { return String(value ?? "").replace(/[&<>'"]/g, c => ({"&":"&amp;","<":"&lt;",">":"&gt;","'":"&#39;",'"':"&quot;"}[c])); }
 
13
  $("#file").addEventListener("change", event => event.target.files[0]?.text().then(loadText));
14
  $("#findings-file").addEventListener("change", event => event.target.files[0]?.text().then(text => { try { importedFindings = JSON.parse(text).findings || JSON.parse(text); if (trace?.schema_version === "solstice-agent-trace-exchange/v1") trace = attachFindings(trace, importedFindings); renderTrace(); } catch (error) { $("#error").textContent = error.message; } }));
15
  $("#branch").addEventListener("change", renderComparison);
16
+ $("#download").addEventListener("click", () => { if (trace) downloadJson(trace.schema_version === "solstice-agent-trace-exchange/v1" ? trace : toExchange(trace), `${trace.trace_id || "trace"}-exchange.json`); });
17
  fetch("data/traces.jsonl").then(response => response.text()).then(text => loadText(text)).catch(() => { $("#error").textContent = "Load a local trace JSON file to begin."; });