@floless/app 0.168.0 → 0.169.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.
Files changed (49) hide show
  1. package/cli-actions.mjs +8 -1
  2. package/dist/floless-server.cjs +83100 -68895
  3. package/dist/skills/floless-app-rfi/SKILL.md +4 -2
  4. package/dist/templates/college-phase-exporter.flo +7 -2
  5. package/dist/templates/trimble-list-projects.flo +10 -2
  6. package/dist/web/agent-steps.js +2 -2
  7. package/dist/web/agents.js +49 -13
  8. package/dist/web/app.css +44 -3
  9. package/dist/web/app.js +47 -4
  10. package/dist/web/aware-update-client.js +4 -4
  11. package/dist/web/aware.js +401 -31
  12. package/dist/web/chat.css +10 -0
  13. package/dist/web/chat.js +223 -22
  14. package/dist/web/commands-drawing-check.js +3 -0
  15. package/dist/web/commands-shell.js +111 -4
  16. package/dist/web/commands-steel.js +9 -2
  17. package/dist/web/commands-vector.js +69 -0
  18. package/dist/web/drawing-check-editor.html +10 -0
  19. package/dist/web/drawing-check-editor.js +502 -182
  20. package/dist/web/failure-copy.js +20 -2
  21. package/dist/web/flo-3d.js +310 -0
  22. package/dist/web/flo-card.js +72 -0
  23. package/dist/web/guide.js +3 -1
  24. package/dist/web/index.html +26 -4
  25. package/dist/web/instructor.js +3 -0
  26. package/dist/web/model-editor-steel-adapter.js +41 -1
  27. package/dist/web/model-viewport-toolbar.js +11 -0
  28. package/dist/web/pages.js +17 -14
  29. package/dist/web/panels.js +1 -1
  30. package/dist/web/project-history.js +2 -2
  31. package/dist/web/project-modules.js +3 -3
  32. package/dist/web/project-reconciliation.js +1 -1
  33. package/dist/web/project-rfis.js +2 -2
  34. package/dist/web/project-workflows.js +6 -4
  35. package/dist/web/renderers.js +6 -0
  36. package/dist/web/report-csp.js +68 -0
  37. package/dist/web/revit-editor.js +1 -1
  38. package/dist/web/run-history.js +2 -3
  39. package/dist/web/steel-3d-flo.js +309 -0
  40. package/dist/web/steel-3d-view.js +159 -0
  41. package/dist/web/steel-editor.html +130 -9
  42. package/dist/web/terminal-requests.js +78 -0
  43. package/dist/web/tool-updates.js +3 -2
  44. package/dist/web/vector-3d.html +1 -1
  45. package/dist/web/vector-editor.html +50 -8
  46. package/dist/web/workspace-root-management.js +1 -1
  47. package/dist/web/workspaces.js +626 -140
  48. package/launch.mjs +5 -0
  49. package/package.json +8 -8
package/dist/web/pages.js CHANGED
@@ -21,10 +21,12 @@
21
21
  if (!res.ok || body.ok === false) {
22
22
  // #3097: the server's own sentence when it wrote one, else the shared one; never "HTTP <status>".
23
23
  const readOnly = /^(GET|HEAD)$/.test(String(opts.method || 'GET').toUpperCase());
24
- const err = new Error(body.error || failureCopy({ status: res.status, body }, { retrySafe: readOnly }).text); err.status = res.status; err.body = body; throw err;
24
+ const err = new Error(personText(body) || failureCopy({ status: res.status, body }, { retrySafe: readOnly }).text); err.status = res.status; err.body = body; throw err;
25
25
  }
26
26
  return body;
27
27
  });
28
+ // #3097: a change that failed without a sentence for the person may still have gone through, so never "Try again".
29
+ const UNSURE_WRITE = 'FloLess can’t tell whether it went through, so check before trying again.';
28
30
  const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
29
31
  const toast = (msg, kind) => { if (typeof window.showToast === 'function') window.showToast(msg, kind); };
30
32
  const AI_TIP = 'Made by AI. FloLess doesn’t check its figures or statements — check them before you rely on it or share it.';
@@ -165,7 +167,7 @@
165
167
  if (container.dataset.pagesToken !== token) return;
166
168
  // A failed list is said out loud, on the landing too: an empty-looking section would read as "no Pages".
167
169
  console.warn('Pages list could not be read', err);
168
- container.innerHTML = `${opts.headHtml || ''}<p class="pg-empty">FloLess couldn’t read this list of Pages. ${esc(err?.body?.error || 'Try opening it again in a moment.')}</p>`;
170
+ container.innerHTML = `${opts.headHtml || ''}<p class="pg-empty">FloLess couldn’t read this list of Pages. ${esc(personText(err?.body) || 'Try opening it again in a moment.')}</p>`;
169
171
  return;
170
172
  }
171
173
  if (container.dataset.pagesToken !== token) return;
@@ -355,7 +357,7 @@
355
357
  announceDeleted(home, id);
356
358
  toast('Page deleted.', 'ok');
357
359
  } catch (err) {
358
- toast(`FloLess couldn’t delete it. ${err?.body?.error || 'Try again in a moment.'}`, 'warn');
360
+ toast(`FloLess couldn’t delete it. ${personText(err?.body) || UNSURE_WRITE}`, 'warn');
359
361
  }
360
362
  refreshLists();
361
363
  }
@@ -386,7 +388,7 @@
386
388
  } else toast('Page deleted.', 'ok');
387
389
  }
388
390
  } catch (err) {
389
- toast(`FloLess couldn’t ${act === 'cancel' ? 'cancel publishing' : 'delete it'}. ${err?.body?.error || 'Try again in a moment.'}`, 'warn');
391
+ toast(`FloLess couldn’t ${act === 'cancel' ? 'cancel publishing' : 'delete it'}. ${personText(err?.body) || UNSURE_WRITE}`, 'warn');
390
392
  }
391
393
  refreshLists();
392
394
  }
@@ -515,7 +517,7 @@
515
517
  : `Version ${n} isn't in this Page's history any more, so you're now seeing the latest.`;
516
518
  }
517
519
  function failedNote(n, err) {
518
- return `FloLess couldn’t load version ${n}, so you're seeing the latest. ${err?.body?.error || 'The Page could not be read just now.'} Choose the version again from the list to retry.`;
520
+ return `FloLess couldn’t load version ${n}, so you're seeing the latest. ${personText(err?.body) || 'The Page could not be read just now.'} Choose the version again from the list to retry.`;
519
521
  }
520
522
 
521
523
  /** A response replaced the record (a site change, a refresh): keep the person's version selected and its labels —
@@ -629,7 +631,7 @@
629
631
  if (typeof window.flolessWorkspaces?.openPagesHome === 'function' && await window.flolessWorkspaces.openPagesHome(home, id, closeViewer)) return true;
630
632
  return false;
631
633
  }
632
- toast(`FloLess couldn’t open this Page. ${err?.body?.error || 'Try again in a moment.'}`, 'warn');
634
+ toast(`FloLess couldn’t open this Page. ${personText(err?.body) || 'Try again in a moment.'}`, 'warn');
633
635
  return false;
634
636
  }
635
637
  // Another Page: a share action still out for the previous one no longer owns the Share button.
@@ -803,7 +805,7 @@
803
805
  let found;
804
806
  try { found = await ensureKnown(Math.max(1, before - 200)); }
805
807
  catch (err) {
806
- toast(`FloLess couldn’t show older versions. ${err?.body?.error || 'Try again in a moment.'}`, 'warn');
808
+ toast(`FloLess couldn’t show older versions. ${personText(err?.body) || 'Try again in a moment.'}`, 'warn');
807
809
  if (!$versionPop.hidden) openVersionPicker();
808
810
  return;
809
811
  } finally { view.pagingOlder = false; }
@@ -878,7 +880,7 @@
878
880
  loadFrame();
879
881
  return true;
880
882
  } catch (err) {
881
- toast(`FloLess couldn’t change that. ${err?.body?.error || 'Try again in a moment.'}`, 'warn');
883
+ toast(`FloLess couldn’t change that. ${personText(err?.body) || UNSURE_WRITE}`, 'warn');
882
884
  return false;
883
885
  }
884
886
  }
@@ -1063,7 +1065,7 @@
1063
1065
  const body = await api(`/api/pages/${encodeURIComponent(view.home)}/${encodeURIComponent(p.id)}`, { method: 'DELETE' });
1064
1066
  revokePending = body?.revokePending === true;
1065
1067
  } catch (err) {
1066
- toast(`FloLess couldn’t delete this Page. ${err?.body?.error || 'Try again in a moment.'}`, 'warn');
1068
+ toast(`FloLess couldn’t delete this Page. ${personText(err?.body) || UNSURE_WRITE}`, 'warn');
1067
1069
  return;
1068
1070
  }
1069
1071
  announceDeleted(view.home, p.id);
@@ -1235,7 +1237,7 @@
1235
1237
  if (seq !== view.openSeq || shareSeq !== view.shareSeq) return;
1236
1238
  // Said, not swallowed: the Page's own record still shows its link, and the banner says why the rest is missing.
1237
1239
  view.share = { share: view.page?.share ?? null, eligibility: null,
1238
- error: { code: err?.body?.code || 'offline', message: err?.body?.error || 'FloLess couldn’t check this Page’s link just now. Close the Page and open it again to retry.', path: null } };
1240
+ error: { code: err?.body?.code || 'offline', message: personText(err?.body) || 'FloLess couldn’t check this Page’s link just now. Close the Page and open it again to retry.', path: null } };
1239
1241
  }
1240
1242
  paintShareButton();
1241
1243
  // Painted while closed too: the Instructor reaches Revoke, Copy and the rest by opening this menu (data-reveal-by).
@@ -1322,7 +1324,8 @@
1322
1324
  const code = err?.body?.code || 'offline';
1323
1325
  view.shareQuota = err?.body?.quota || null;
1324
1326
  const path = code === 'share-too-large' && (payload?.version ?? latestN()) === latestN() ? view.share?.eligibility?.path || null : null;
1325
- view.share = { ...(view.share || {}), error: { code, message: err?.body?.error || outcomeSentence('offline'), path } };
1327
+ // A server that answered without a sentence for the person is not "offline": say it can't tell (UNSURE_WRITE).
1328
+ view.share = { ...(view.share || {}), error: { code, message: personText(err?.body) || (err?.status ? UNSURE_WRITE : outcomeSentence('offline')), path } };
1326
1329
  return null;
1327
1330
  } finally {
1328
1331
  // Only the newest action owns the busy mark (even after the viewer moved to another Page, so nothing is left busy),
@@ -1473,7 +1476,7 @@
1473
1476
  const path = view.share?.error?.path;
1474
1477
  if (!path) return;
1475
1478
  try { await api('/api/reveal', { method: 'POST', body: JSON.stringify({ path }) }); }
1476
- catch (err) { toast(`FloLess couldn’t show the file. ${err?.body?.error || 'Try again in a moment.'}`, 'warn'); }
1479
+ catch (err) { toast(`FloLess couldn’t show the file. ${personText(err?.body) || 'Try again in a moment.'}`, 'warn'); }
1477
1480
  return;
1478
1481
  }
1479
1482
  if (act === 'dismiss') { view.share = { ...(view.share || {}), error: null }; view.shareBannerDismissed = true; paintBanner(); $frame.focus(); return; }
@@ -1606,7 +1609,7 @@
1606
1609
  if (gen !== sl.gen) return;
1607
1610
  slPaintUsage(null);
1608
1611
  $slNote.hidden = false;
1609
- $slNote.textContent = `FloLess couldn’t list your shared links. ${err?.body?.error || 'Try again in a moment.'}`;
1612
+ $slNote.textContent = `FloLess couldn’t list your shared links. ${personText(err?.body) || 'Try again in a moment.'}`;
1610
1613
  } finally {
1611
1614
  if (gen === sl.gen) {
1612
1615
  sl.loading = false;
@@ -1671,7 +1674,7 @@
1671
1674
  else if (body.outcome === 'revoke-pending') toast('FloLess will revoke the link as soon as it can reach floless.io.', 'warn');
1672
1675
  else toast(outcomeSentence(body.outcome) || 'FloLess couldn’t revoke the link just now. Try again in a moment.', 'warn');
1673
1676
  } catch (err) {
1674
- toast(`FloLess couldn’t revoke the link. ${err?.body?.error || 'Try again in a moment.'}`, 'warn');
1677
+ toast(`FloLess couldn’t revoke the link. ${personText(err?.body) || UNSURE_WRITE}`, 'warn');
1675
1678
  }
1676
1679
  await slLoad(false);
1677
1680
  // The Pages lists' chips and an open viewer's Share button read the same link: repaint them too.
@@ -24,7 +24,7 @@
24
24
  if (!res.ok || body.ok === false) {
25
25
  // #3097: the server's own sentence when it wrote one, else the shared one; never "HTTP <status>".
26
26
  const readOnly = /^(GET|HEAD)$/.test(String(requestOptions.method || 'GET').toUpperCase());
27
- const err = new Error(body.error || failureCopy({ status: res.status, body }, { retrySafe: readOnly }).text);
27
+ const err = new Error(personText(body) || failureCopy({ status: res.status, body }, { retrySafe: readOnly }).text);
28
28
  err.body = body;
29
29
  err.status = res.status;
30
30
  throw err;
@@ -12,7 +12,7 @@
12
12
  return fetch(path).then(async (res) => {
13
13
  const body = await res.json().catch(() => ({}));
14
14
  // #3097: the server's own sentence when it wrote one, else the shared one (this only reads); never "HTTP <status>".
15
- if (!res.ok || body.ok === false) { const err = new Error(body.error || failureCopy({ status: res.status, body }, { retrySafe: true }).text); err.status = res.status; err.body = body; throw err; }
15
+ if (!res.ok || body.ok === false) { const err = new Error(personText(body) || failureCopy({ status: res.status, body }, { retrySafe: true }).text); err.status = res.status; err.body = body; throw err; }
16
16
  return body;
17
17
  });
18
18
  };
@@ -345,7 +345,7 @@
345
345
  // Keep what is shown, and say it may be out of date.
346
346
  if (st.loaded && !st.unavailable) { st.stale = true; paint(pane); return; }
347
347
  st.loaded = false;
348
- st.error = typeof err?.body?.error === 'string' && err.body.error ? err.body.error : VARIANTS[st.variant].failed;
348
+ st.error = personText(err?.body) || VARIANTS[st.variant].failed;
349
349
  paint(pane);
350
350
  return;
351
351
  }
@@ -17,15 +17,15 @@
17
17
  const body = await res.json().catch(() => ({}));
18
18
  // #3097: the server's own sentence when it wrote one, else the shared one; never "HTTP <status>".
19
19
  const readOnly = /^(GET|HEAD)$/.test(String(init?.method || 'GET').toUpperCase());
20
- if (!res.ok || body.ok === false) { const err = new Error(body.error || failureCopy({ status: res.status, body }, { retrySafe: readOnly }).text); err.status = res.status; err.body = body; throw err; }
20
+ if (!res.ok || body.ok === false) { const err = new Error(personText(body) || failureCopy({ status: res.status, body }, { retrySafe: readOnly }).text); err.status = res.status; err.body = body; throw err; }
21
21
  return body;
22
22
  });
23
23
  };
24
24
  const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
25
25
  const toast = (msg, kind, options) => (typeof window.showToast === 'function' ? window.showToast(msg, kind, options) : null);
26
26
  // A sentence the server wrote for the person is shown as written; anything else gets the fixed line.
27
- const said = (error, fallback) => (typeof error?.body?.error === 'string' && error.body.error ? error.body.error
28
- : !error?.status && typeof error?.message === 'string' && /^FloLess /.test(error.message) ? error.message : fallback);
27
+ const said = (error, fallback) => (personText(error?.body)
28
+ || (!error?.status && typeof error?.message === 'string' && /^FloLess /.test(error.message) ? error.message : fallback));
29
29
 
30
30
  /** The module names a person knows, by template id (LINKABLE_APPS on the server). */
31
31
  const MODULE_NAMES = {
@@ -59,7 +59,7 @@
59
59
  ...(body === undefined ? {} : { method: 'POST', body: JSON.stringify(body) }) });
60
60
  const result = await response.json();
61
61
  if (!response.ok || result.ok === false) {
62
- const message = [result.userMessage, result.message, result.error].find((value) => typeof value === 'string' && value.trim());
62
+ const message = [result.userMessage, result.message, personText(result)].find((value) => typeof value === 'string' && value.trim());
63
63
  throw new Error(message || 'FloLess could not finish this folder review. Check the folder and try again.');
64
64
  }
65
65
  return result;
@@ -21,13 +21,13 @@
21
21
  const body = await res.json().catch(() => ({}));
22
22
  // #3097: the server's own sentence when it wrote one, else the shared one; never "HTTP <status>".
23
23
  const readOnly = /^(GET|HEAD)$/.test(String(init?.method || 'GET').toUpperCase());
24
- if (!res.ok || body.ok === false) { const err = new Error(body.error || failureCopy({ status: res.status, body }, { retrySafe: readOnly }).text); err.status = res.status; err.body = body; throw err; }
24
+ if (!res.ok || body.ok === false) { const err = new Error(personText(body) || failureCopy({ status: res.status, body }, { retrySafe: readOnly }).text); err.status = res.status; err.body = body; throw err; }
25
25
  return body;
26
26
  });
27
27
  };
28
28
  const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
29
29
  const toast = (msg, kind, options) => (typeof window.showToast === 'function' ? window.showToast(msg, kind, options) : null);
30
- const said = (error, fallback) => (typeof error?.body?.error === 'string' && error.body.error ? error.body.error : fallback);
30
+ const said = (error, fallback) => (personText(error?.body) || fallback);
31
31
  /** A refusal the server wrote (a 4xx with a sentence) — as opposed to an outcome nobody confirmed. */
32
32
  const refused = (error) => !!error?.status && error.status >= 400 && error.status < 500 && typeof error?.body?.error === 'string';
33
33
  const newKey = () => `rfi-${crypto.randomUUID()}`;
@@ -14,7 +14,7 @@
14
14
  return fetch(path).then(async (res) => {
15
15
  const body = await res.json().catch(() => ({}));
16
16
  // #3097: the server's own sentence when it wrote one, else the shared one (this only reads); never "HTTP <status>".
17
- if (!res.ok || body.ok === false) { const err = new Error(body.error || failureCopy({ status: res.status, body }, { retrySafe: true }).text); err.status = res.status; err.body = body; throw err; }
17
+ if (!res.ok || body.ok === false) { const err = new Error(personText(body) || failureCopy({ status: res.status, body }, { retrySafe: true }).text); err.status = res.status; err.body = body; throw err; }
18
18
  return body;
19
19
  });
20
20
  };
@@ -310,7 +310,7 @@
310
310
  .then(async (res) => {
311
311
  const answer = await res.json().catch(() => ({}));
312
312
  // #3097: a POST, so the shared sentence never tells the person to retry blindly; never "HTTP <status>".
313
- if (!res.ok || answer.ok === false) { const err = new Error(answer.error || failureCopy({ status: res.status, body: answer }, { retrySafe: false }).text); err.status = res.status; err.body = answer; throw err; }
313
+ if (!res.ok || answer.ok === false) { const err = new Error(personText(answer) || failureCopy({ status: res.status, body: answer }, { retrySafe: false }).text); err.status = res.status; err.body = answer; throw err; }
314
314
  return answer;
315
315
  });
316
316
 
@@ -344,9 +344,11 @@
344
344
  const code = error?.body?.code;
345
345
  const unreadable = code === 'source-unreadable';
346
346
  // The server's own sentence when it wrote one (it says what changed); a fixed one only when nothing answered.
347
- const said = typeof error?.body?.error === 'string' && error.body.error ? error.body.error : null;
347
+ const said = personText(error?.body) || null;
348
348
  if (!said) console.error('[project-workflows] a set-apart folder could not be answered', error);
349
- const message = unreadable ? null : said || 'FloLess couldn’t reach the server just now. Look at the list again before trying once more.';
349
+ const message = unreadable ? null : said || (error?.status
350
+ ? 'FloLess couldn’t tell whether that went through. Look at the list again before trying once more.'
351
+ : 'FloLess couldn’t reach the server just now. Look at the list again before trying once more.');
350
352
  if (!ctx.alive()) return;
351
353
  ctx.setRow(id, { unreadable: unreadable || !!ctx.rows()[id]?.unreadable, error: message });
352
354
  ctx.repaint();
@@ -27,6 +27,12 @@ window.CONTRACT_RENDERERS = {
27
27
  // Local read-only 3D reconstruction viewer (views-to-scene) — NOT the AWARE exporter chain
28
28
  // (`scene`), which only steel supports; extrusion bodies render floless-side only for now.
29
29
  viewerUrl: (appId) => '/vector-3d.html?app=' + encodeURIComponent(appId),
30
+ // What the shell's close question calls it (#3143) — the same name the leave guard uses.
31
+ name: 'the drawing editor',
32
+ // It autosaves to the server and keeps no copy on this computer, so closing the overlay over a
33
+ // write that is unfinished, failed or refused as a conflict loses those edits: Close asks first.
34
+ // (The steel editor keeps such edits as a local draft, so it does not set this.)
35
+ asksBeforeClose: true,
30
36
  },
31
37
  };
32
38
 
@@ -0,0 +1,68 @@
1
+ /**
2
+ * The report viewer's own content rules (#3130, audit 1 F3).
3
+ *
4
+ * A static report is painted into `#report-frame` through `srcdoc`. That frame has no `allow-scripts`, but nothing else
5
+ * limited what the report could ask for: a picture or stylesheet at any `http:` address — FloLess's own loopback API
6
+ * included, which the frame's `allow-same-origin` makes a same-origin request — a form, a `<base>`. `withReportCsp` puts
7
+ * the policy FloLess already gives a report's browser copy (#2476, `INERT_REPORT_CSP` in server/report-files-inert.ts) at
8
+ * the very top of the report: no script, no form, no `<base>`, nothing from FloLess or any `http:` address, while pictures,
9
+ * styles, fonts and media from `data:` or `https:` keep working as the report was written. A report cannot loosen it — a
10
+ * second policy only narrows.
11
+ *
12
+ * `openDocument` is what ↗ Open shows in a new tab. It used to be the report itself as a blob: URL, and a blob: URL has
13
+ * the ORIGIN OF THE PAGE THAT MADE IT — so the report ran as FloLess, and any script in it (the interactive 3D view runs
14
+ * scripts by design) could call the local API as the app. Now the tab is always a script-free page holding the report in
15
+ * a sandboxed frame with no `allow-same-origin`, so the browser itself keeps the report away from FloLess: the policy
16
+ * cannot stop a `<meta http-equiv="refresh">` navigating an unsandboxed tab, and no parse of the report on FloLess's side
17
+ * can be sure to find one the way the browser does (Codex, PR review), but a sandbox stops it whatever the markup.
18
+ * The cost: printing that tab prints only the frame's one screen (follow-up listed in epic #3137).
19
+ *
20
+ * Loaded as a classic script before aware.js; tested by server/report-csp-ui.test.ts.
21
+ */
22
+ (function (root) {
23
+ 'use strict';
24
+
25
+ var POLICY = "default-src 'none'; img-src data: https:; style-src 'unsafe-inline' https:; font-src data: https:; media-src data: https:; form-action 'none'; base-uri 'none'";
26
+ var META = '<meta http-equiv="Content-Security-Policy" content="' + POLICY + '">';
27
+ // Whether the report asks for standards mode. This only ever chooses the rendering mode, never where the policy goes:
28
+ // the policy is the first thing in the document either way, ahead of anything the report says, so no markup in the
29
+ // report — a comment the browser closes early, a `>` inside a quoted doctype — can put an element before it.
30
+ var LOOKS_LIKE_DOCTYPE = /^\s*(?:<!--[\s\S]*?-->\s*)*<!doctype/i;
31
+
32
+ function withReportCsp(html) {
33
+ var text = String(html == null ? '' : html).replace(/^/, '');
34
+ // With a doctype, ours comes first (the report's own, now later, is ignored by the parser): a policy placed before a
35
+ // doctype would put the report into quirks mode. Without one the report keeps the mode it always had.
36
+ return (LOOKS_LIKE_DOCTYPE.test(text) ? '<!doctype html>' : '') + META + text;
37
+ }
38
+
39
+ function escapeAttr(value) {
40
+ return String(value).replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
41
+ }
42
+
43
+ function page(title, frame) {
44
+ return '<!doctype html><html><head><meta charset="utf-8"><title>' + escapeAttr(title) + '</title>'
45
+ + '<style>html,body{margin:0;height:100%}iframe{display:block;border:0;width:100%;height:100%}</style></head><body>'
46
+ + frame + '</body></html>';
47
+ }
48
+
49
+ /** What ↗ Open puts in a new tab: a page with no script and no policy of its own (a frame inherits its parent's, which
50
+ * would stop the 3D view's scripts), holding the report in an opaque-origin frame. A static report goes in like
51
+ * #report-frame, with its policy first, but without `allow-same-origin` — no script, no automatic navigation, links
52
+ * still open in a new tab. The interactive 3D view goes in like #report-frame-3d, as a `data:` frame with only
53
+ * `allow-scripts`: its scripts run, but their requests carry `Origin: null`, which the server's origin guard refuses.
54
+ * `name` (the workflow's) titles the tab. */
55
+ function openDocument(html, interactive, name) {
56
+ var text = String(html == null ? '' : html);
57
+ if (!interactive) {
58
+ return page(name ? 'FloLess report – ' + name : 'FloLess report',
59
+ '<iframe sandbox="allow-popups allow-popups-to-escape-sandbox" title="Report" srcdoc="'
60
+ + escapeAttr(withReportCsp(text)) + '"></iframe>');
61
+ }
62
+ return page(name ? 'FloLess 3D view – ' + name : 'FloLess 3D view',
63
+ '<iframe sandbox="allow-scripts" title="3D view" src="data:text/html;charset=utf-8,'
64
+ + escapeAttr(encodeURIComponent(text)) + '"></iframe>');
65
+ }
66
+
67
+ root.FlolessReportCsp = { POLICY: POLICY, withReportCsp: withReportCsp, openDocument: openDocument };
68
+ })(typeof window !== 'undefined' ? window : globalThis);
@@ -220,7 +220,7 @@ function sharedFailureText(response, value, ctx, thrown) {
220
220
  if (typeof copy === 'function') return copy(thrown && !thrown.status ? thrown : { status: response.status, body: value }, ctx).text;
221
221
  return `Couldn’t ${ctx?.action || 'finish that'}. Reload this window, then try again.`;
222
222
  }
223
- async function json(url, options) { const response = await fetch(url, { credentials: 'same-origin', ...options }); const value = await response.json().catch(() => ({})); if (!response.ok || value.ok === false) throw Object.assign(new Error(value.message || value.error || sharedFailureText(response, value, { retrySafe: /^(GET|HEAD)$/.test(String(options?.method || 'GET').toUpperCase()) })), { status: response.status, body: value }); return value; }
223
+ async function json(url, options) { const response = await fetch(url, { credentials: 'same-origin', ...options }); const value = await response.json().catch(() => ({})); if (!response.ok || value.ok === false) throw Object.assign(new Error(value.message || (typeof globalThis.personText === 'function' ? globalThis.personText(value) : '') || sharedFailureText(response, value, { retrySafe: /^(GET|HEAD)$/.test(String(options?.method || 'GET').toUpperCase()) })), { status: response.status, body: value }); return value; }
224
224
 
225
225
  function propertySection(heading, rows) {
226
226
  return { id: heading.toLowerCase().replace(/\W+/g, '-'), heading, editable: false, render(host) {
@@ -8,7 +8,7 @@
8
8
  const api = bridge.api || (async (path) => {
9
9
  const res = await fetch(path);
10
10
  const body = await res.json().catch(() => ({}));
11
- if (!res.ok) throw Object.assign(new Error(body.error || 'request failed'), { status: res.status, body });
11
+ if (!res.ok) throw Object.assign(new Error(personText(body) || failureCopy({ status: res.status, body }, { action: 'load the run history', retrySafe: true }).text), { status: res.status, body });
12
12
  return body;
13
13
  });
14
14
  const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
@@ -145,8 +145,7 @@
145
145
  console.warn('The run history could not be read', err);
146
146
  cache = null;
147
147
  container.dataset.rhState = 'error';
148
- const said = typeof err?.body?.error === 'string' && err.body.error ? err.body.error
149
- : 'FloLess couldn’t read the run history. Check that FloLess is running, then try again.';
148
+ const said = personText(err?.body) || 'FloLess couldn’t read the run history. Check that FloLess is running, then try again.';
150
149
  container.innerHTML = `<div class="pg-empty" role="alert"><p>${esc(said)}</p>`
151
150
  + `<p><button type="button" class="ghost rh-act" data-rh-act="retry" data-command-id="shell.workflows-history-retry">Try again</button></p></div>`;
152
151
  return;