literally-aeo 0.4.1 → 0.4.3
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/README.md +16 -0
- package/dist/cli.mjs +1505 -549
- package/dist/lib/agents/copy-validation.js +3 -1
- package/dist/lib/agents/methodology.js +3 -3
- package/dist/lib/agents/verifier.js +2 -2
- package/dist/lib/bundle/contracts.js +1 -1
- package/dist/lib/bundle/export.js +13 -13
- package/dist/lib/bundle/journal.js +2 -2
- package/dist/lib/bundle/project-journal.js +5 -5
- package/dist/lib/bundle/project.js +11 -11
- package/dist/lib/bundle/read.js +14 -14
- package/dist/lib/bundle/recorder.js +3 -3
- package/dist/lib/bundle/redact.js +2 -2
- package/dist/lib/bundle/trace-coverage.js +2 -2
- package/dist/lib/bundle/verify-integrity.js +4 -4
- package/dist/lib/bundle/verify-measurement.js +2 -2
- package/dist/lib/bundle/verify-report.js +3 -3
- package/dist/lib/bundle/verify.js +8 -8
- package/dist/lib/checks/run-checks.js +4 -4
- package/dist/lib/chunks/{chunk-4KF5EVLI.js → chunk-2ANSPIUT.js} +2 -2
- package/dist/lib/chunks/{chunk-G22MXBBM.js → chunk-54GMIPWV.js} +1 -1
- package/dist/lib/chunks/{chunk-PI7PZKHP.js → chunk-65OIYOUH.js} +2 -2
- package/dist/lib/chunks/{chunk-2XMVEGQG.js → chunk-6MGXILUJ.js} +1 -1
- package/dist/lib/chunks/chunk-6OURIXQZ.js +472 -0
- package/dist/lib/chunks/{chunk-OBSW2WKF.js → chunk-746643QV.js} +1 -1
- package/dist/lib/chunks/{chunk-7DR2X7SF.js → chunk-74K4E3ZS.js} +1 -1
- package/dist/lib/chunks/{chunk-JVIOWZPG.js → chunk-7HCVSLVG.js} +1 -1
- package/dist/lib/chunks/{chunk-XX2TK6FI.js → chunk-7K2XT3WI.js} +5 -5
- package/dist/lib/chunks/{chunk-ABS5TK73.js → chunk-7K6CXSTL.js} +3 -1
- package/dist/lib/chunks/{chunk-CBOETT4C.js → chunk-7L4Y6N3V.js} +1 -1
- package/dist/lib/chunks/{chunk-FDCM7554.js → chunk-7QWT7LFM.js} +2 -2
- package/dist/lib/chunks/{chunk-4UN3YD5Z.js → chunk-7SA2CRSS.js} +1 -1
- package/dist/lib/chunks/{chunk-P7LGJGDL.js → chunk-ARKZ5PJN.js} +1 -1
- package/dist/lib/chunks/{chunk-4WPG2O2S.js → chunk-B6XGNJUU.js} +1 -1
- package/dist/lib/chunks/{chunk-5OL67GMN.js → chunk-BNX7S4GK.js} +4 -4
- package/dist/lib/chunks/chunk-BWBPEXEU.js +83 -0
- package/dist/lib/chunks/{chunk-U53GT2R7.js → chunk-BZAPAGXM.js} +1 -1
- package/dist/lib/chunks/{chunk-BNPWAQQG.js → chunk-C2Q7YE7Y.js} +6 -6
- package/dist/lib/chunks/{chunk-LYOCWN3R.js → chunk-D2LJMNH3.js} +2 -2
- package/dist/lib/chunks/{chunk-32HYNVPR.js → chunk-EVEJ3MFU.js} +3 -3
- package/dist/lib/chunks/{chunk-DGOFCRZM.js → chunk-GC7DISQO.js} +1 -1
- package/dist/lib/chunks/{chunk-BTRBLG6S.js → chunk-I6PQUKKF.js} +1 -1
- package/dist/lib/chunks/{chunk-6FGVCN4H.js → chunk-J5RYDPGP.js} +1 -1
- package/dist/lib/chunks/{chunk-JIUBLXR7.js → chunk-JHUI2K5X.js} +3 -3
- package/dist/lib/chunks/chunk-JQFLWUCA.js +123 -0
- package/dist/lib/chunks/{chunk-4RB3AOPT.js → chunk-JREYIUNG.js} +5 -5
- package/dist/lib/chunks/{chunk-42QARLUQ.js → chunk-JXQOWHWB.js} +3 -3
- package/dist/lib/chunks/{chunk-66BTHIL3.js → chunk-KFJ5O5CL.js} +2 -2
- package/dist/lib/chunks/{chunk-6P7EZJI7.js → chunk-KSJ3NZIJ.js} +4 -2
- package/dist/lib/chunks/{chunk-3RGUIUKU.js → chunk-L5HFTFFG.js} +2 -2
- package/dist/lib/chunks/{chunk-WBSJVDS2.js → chunk-LJD37WAV.js} +2 -2
- package/dist/lib/chunks/{chunk-QT5GTQGD.js → chunk-MKA2EP7M.js} +1 -1
- package/dist/lib/chunks/{chunk-CZMQ2DVJ.js → chunk-MMJ5UR2E.js} +1 -1
- package/dist/lib/chunks/{chunk-BWUOUP4J.js → chunk-MQFFMD4Q.js} +1 -1
- package/dist/lib/chunks/{chunk-7D7EOET3.js → chunk-NM2LUMQT.js} +4 -4
- package/dist/lib/chunks/{chunk-IJQEQL5Q.js → chunk-P5VVHTZU.js} +1 -1
- package/dist/lib/chunks/{chunk-OJQ66533.js → chunk-PFG3ESJE.js} +9 -9
- package/dist/lib/chunks/{chunk-WSATQQJI.js → chunk-Q7CWM6LZ.js} +6 -6
- package/dist/lib/chunks/{chunk-F6CC4WLO.js → chunk-R4HYBSQB.js} +1 -1
- package/dist/lib/chunks/{chunk-FWH3LYHG.js → chunk-R5NLULQW.js} +1 -1
- package/dist/lib/chunks/{chunk-WUDXMAJS.js → chunk-RM7U5M5L.js} +1 -1
- package/dist/lib/chunks/{chunk-3G6COT6E.js → chunk-RQ6GUJI5.js} +1 -1
- package/dist/lib/chunks/{chunk-TNTTIT2R.js → chunk-RUSMX6JH.js} +16 -7
- package/dist/lib/chunks/{chunk-G4GAGKSG.js → chunk-UNNRLD2U.js} +4 -4
- package/dist/lib/chunks/chunk-VFN2J4Z3.js +626 -0
- package/dist/lib/chunks/{chunk-BLDOQAEW.js → chunk-VPJN2GNC.js} +1 -1
- package/dist/lib/chunks/{chunk-3GDCPD5P.js → chunk-XSOTCSD3.js} +3 -3
- package/dist/lib/chunks/{chunk-WHW3NOG5.js → chunk-YX4EH6FR.js} +1 -1
- package/dist/lib/chunks/{chunk-TXGVQ6CN.js → chunk-ZC4MKS3J.js} +12 -12
- package/dist/lib/chunks/{chunk-VXO5RAR4.js → chunk-ZM4RHMBI.js} +1 -1
- package/dist/lib/cli/bundle-commands.js +60 -35
- package/dist/lib/cli/guide-command.js +1 -1
- package/dist/lib/cli/run-commands.js +40 -40
- package/dist/lib/cli/status-command.js +21 -21
- package/dist/lib/codex-workflow/aggregate.js +2 -2
- package/dist/lib/codex-workflow/author.js +5 -5
- package/dist/lib/codex-workflow/capture.js +5 -5
- package/dist/lib/codex-workflow/copy-editor.js +5 -5
- package/dist/lib/codex-workflow/copy.js +4 -4
- package/dist/lib/codex-workflow/finish.js +5 -5
- package/dist/lib/codex-workflow/loop.js +15 -15
- package/dist/lib/codex-workflow/run-source.js +5 -5
- package/dist/lib/codex-workflow/stage.js +6 -6
- package/dist/lib/engine/audit-file.js +3 -3
- package/dist/lib/engine/author.js +12 -12
- package/dist/lib/engine/cost-estimate.js +3 -3
- package/dist/lib/engine/local-run.js +20 -20
- package/dist/lib/engine/preflight.js +3 -3
- package/dist/lib/engine/rejudge.js +27 -27
- package/dist/lib/engine/resources.js +1 -1
- package/dist/lib/engine/run-bindings.js +3 -3
- package/dist/lib/engine/run-method.js +3 -3
- package/dist/lib/engine/run-models.js +4 -4
- package/dist/lib/engine/run-status.js +21 -21
- package/dist/lib/engine/templates.js +4 -4
- package/dist/lib/grounding/grounding-runtime.js +5 -5
- package/dist/lib/grounding/recorded-tools.js +4 -4
- package/dist/lib/pipeline.js +4 -4
- package/dist/lib/probes/bindings.js +2 -2
- package/dist/lib/probes/charged-trace.js +3 -3
- package/dist/lib/probes/probes.js +3 -3
- package/dist/lib/stores/files.js +3 -3
- package/dist/lib/stores/memory.js +2 -2
- package/dist/lib/stores/publication.js +2 -2
- package/dist/lib/viewer/alternatives.js +8 -0
- package/dist/lib/viewer/cited-domains.js +8 -0
- package/dist/lib/viewer/page.js +3 -1
- package/dist/lib/viewer/presentation.js +41 -0
- package/dist/lib/viewer/server.js +15 -10
- package/dist/types/agents/copy-validation.d.ts +2 -1
- package/dist/types/bundle/contracts.d.ts +1 -1
- package/dist/types/engine/resources.d.ts +2 -0
- package/dist/types/viewer/alternatives.d.ts +16 -0
- package/dist/types/viewer/cited-domains.d.ts +22 -0
- package/dist/types/viewer/page.d.ts +9 -2
- package/dist/types/viewer/presentation.d.ts +112 -0
- package/dist/types/viewer/server.d.ts +7 -3
- package/package.json +2 -1
- package/resources/fonts/Mulish-OFL.txt +93 -0
- package/resources/fonts/Mulish-VariableFont_wght.ttf +0 -0
- package/resources/fonts/SourceCodePro-OFL.txt +93 -0
- package/resources/fonts/SourceCodePro-VariableFont_wght.ttf +0 -0
- package/src/agents/copy-validation.ts +8 -2
- package/src/bundle/contracts.ts +1 -1
- package/src/cli/bundle-commands.ts +21 -0
- package/src/engine/resources.ts +9 -5
- package/src/report/core/rate-interval.ts +1 -2
- package/src/viewer/alternatives.ts +202 -0
- package/src/viewer/cited-domains.ts +127 -0
- package/src/viewer/page.ts +549 -236
- package/src/viewer/presentation.ts +759 -0
- package/src/viewer/server.ts +25 -4
- package/dist/lib/chunks/chunk-3TF4JGQA.js +0 -323
package/dist/cli.mjs
CHANGED
|
@@ -2180,7 +2180,7 @@ var encodeBundleJson = (value) => {
|
|
|
2180
2180
|
|
|
2181
2181
|
// src/bundle/contracts.ts
|
|
2182
2182
|
var toolId = "literally-aeo";
|
|
2183
|
-
var toolVersion = "0.4.
|
|
2183
|
+
var toolVersion = "0.4.3";
|
|
2184
2184
|
var bundleSchemaVersion = 3;
|
|
2185
2185
|
var readableBundleSchemaVersions = [1, 2, 3];
|
|
2186
2186
|
var traceSchemaVersion = 1;
|
|
@@ -2394,7 +2394,8 @@ var predecessorPrefix = (revisionId) => {
|
|
|
2394
2394
|
};
|
|
2395
2395
|
|
|
2396
2396
|
// src/cli/bundle-commands.ts
|
|
2397
|
-
import
|
|
2397
|
+
import { readFile as readFile29 } from "node:fs/promises";
|
|
2398
|
+
import path34 from "node:path";
|
|
2398
2399
|
|
|
2399
2400
|
// src/bundle/export.ts
|
|
2400
2401
|
import {
|
|
@@ -3389,6 +3390,18 @@ var reportSectionTitle = (title) => {
|
|
|
3389
3390
|
});
|
|
3390
3391
|
return sectionTitle;
|
|
3391
3392
|
};
|
|
3393
|
+
var formatReportDate = (iso) => {
|
|
3394
|
+
const date2 = new Date(iso);
|
|
3395
|
+
if (Number.isNaN(date2.getTime())) {
|
|
3396
|
+
return iso;
|
|
3397
|
+
}
|
|
3398
|
+
return date2.toLocaleDateString("en-GB", {
|
|
3399
|
+
year: "numeric",
|
|
3400
|
+
month: "long",
|
|
3401
|
+
day: "numeric",
|
|
3402
|
+
timeZone: "UTC"
|
|
3403
|
+
});
|
|
3404
|
+
};
|
|
3392
3405
|
|
|
3393
3406
|
// src/agents/copy-schema.ts
|
|
3394
3407
|
var catalogFactIdSchema = z15.string().min(1).describe(
|
|
@@ -3948,7 +3961,7 @@ var methodologyNote = (snapshot) => {
|
|
|
3948
3961
|
};
|
|
3949
3962
|
|
|
3950
3963
|
// src/agents/copy-validation.ts
|
|
3951
|
-
var copyCheckerVersion =
|
|
3964
|
+
var copyCheckerVersion = 8;
|
|
3952
3965
|
var premiseVerifierPromptVersion = 4;
|
|
3953
3966
|
var narrativeContextFactIds = [
|
|
3954
3967
|
"scope:report",
|
|
@@ -4461,6 +4474,7 @@ var assertCopyValidation = (args) => {
|
|
|
4461
4474
|
4: 2,
|
|
4462
4475
|
5: 3,
|
|
4463
4476
|
6: 3,
|
|
4477
|
+
7: 3,
|
|
4464
4478
|
[copyCheckerVersion]: premiseVerifierPromptVersion
|
|
4465
4479
|
};
|
|
4466
4480
|
const verifierPromptVersion = receipt ? verifierPromptVersions[receipt.checkerVersion] : void 0;
|
|
@@ -23630,68 +23644,282 @@ var runPreflight = async (args) => {
|
|
|
23630
23644
|
return checks;
|
|
23631
23645
|
};
|
|
23632
23646
|
|
|
23633
|
-
// src/
|
|
23634
|
-
import {
|
|
23635
|
-
import
|
|
23636
|
-
|
|
23637
|
-
|
|
23638
|
-
import {
|
|
23647
|
+
// src/engine/resources.ts
|
|
23648
|
+
import { access as access2 } from "node:fs/promises";
|
|
23649
|
+
import path33 from "node:path";
|
|
23650
|
+
|
|
23651
|
+
// src/engine/package-root.ts
|
|
23652
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
23653
|
+
import path32 from "node:path";
|
|
23654
|
+
import { fileURLToPath } from "node:url";
|
|
23655
|
+
var enginePackageName = "literally-aeo";
|
|
23656
|
+
var isEngineManifest = (file) => {
|
|
23657
|
+
try {
|
|
23658
|
+
const manifest = JSON.parse(readFileSync2(file, "utf8"));
|
|
23659
|
+
return typeof manifest === "object" && manifest !== null && "name" in manifest && manifest.name === enginePackageName;
|
|
23660
|
+
} catch {
|
|
23661
|
+
return false;
|
|
23662
|
+
}
|
|
23663
|
+
};
|
|
23664
|
+
var enginePackageRoot = () => {
|
|
23665
|
+
const start = path32.dirname(fileURLToPath(import.meta.url));
|
|
23666
|
+
let dir = start;
|
|
23667
|
+
for (; ; ) {
|
|
23668
|
+
if (isEngineManifest(path32.join(dir, "package.json"))) {
|
|
23669
|
+
return dir;
|
|
23670
|
+
}
|
|
23671
|
+
const parent = path32.dirname(dir);
|
|
23672
|
+
if (parent === dir) {
|
|
23673
|
+
throw new Error(
|
|
23674
|
+
`No ${enginePackageName} package.json above ${start}; the engine runs from its own package.`
|
|
23675
|
+
);
|
|
23676
|
+
}
|
|
23677
|
+
dir = parent;
|
|
23678
|
+
}
|
|
23679
|
+
};
|
|
23680
|
+
|
|
23681
|
+
// src/engine/resources.ts
|
|
23682
|
+
var exists = async (file) => {
|
|
23683
|
+
return access2(file).then(
|
|
23684
|
+
() => true,
|
|
23685
|
+
() => false
|
|
23686
|
+
);
|
|
23687
|
+
};
|
|
23688
|
+
var engineResources = async () => {
|
|
23689
|
+
const root = enginePackageRoot();
|
|
23690
|
+
const packed = path33.join(root, "resources");
|
|
23691
|
+
if (await exists(path33.join(packed, "author", "COPY_RULES.md"))) {
|
|
23692
|
+
return {
|
|
23693
|
+
root,
|
|
23694
|
+
author: path33.join(packed, "author"),
|
|
23695
|
+
editorial: path33.join(packed, "editorial"),
|
|
23696
|
+
guide: path33.join(packed, "guide", "OPERATOR.md"),
|
|
23697
|
+
fonts: path33.join(packed, "fonts")
|
|
23698
|
+
};
|
|
23699
|
+
}
|
|
23700
|
+
return {
|
|
23701
|
+
root,
|
|
23702
|
+
author: path33.join(root, "src", "author"),
|
|
23703
|
+
editorial: path33.join(root, "src", "engine", "editorial"),
|
|
23704
|
+
guide: path33.join(root, "src", "engine", "guide", "OPERATOR.md"),
|
|
23705
|
+
fonts: path33.join(root, "src", "viewer", "fonts")
|
|
23706
|
+
};
|
|
23707
|
+
};
|
|
23639
23708
|
|
|
23640
23709
|
// src/viewer/page.ts
|
|
23641
23710
|
var styles = `
|
|
23642
23711
|
:root {
|
|
23643
|
-
--
|
|
23644
|
-
--
|
|
23645
|
-
--
|
|
23712
|
+
--darkest: #000; --lightest: #fff; --brand-1: #ffd08a; --brand-1-light: #ffedd2;
|
|
23713
|
+
--neutral-1: #f1f1f1; --neutral-2: #c8c8c8; --positive: #059669;
|
|
23714
|
+
--positive-deep: #065f46; --mention: #8b5cf6; --mention-deep: #5b21b6;
|
|
23715
|
+
--negative: #ef4444; --muted: rgb(0 0 0 / 0.6); --muted-strong: rgb(0 0 0 / 0.7);
|
|
23716
|
+
--backdrop: rgb(0 0 0 / 0.25);
|
|
23717
|
+
--font-body: Mulish, system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
23718
|
+
--font-mono: "Source Code Pro", ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
23719
|
+
/* Light only, as the hosted report is, whatever the system theme. */
|
|
23646
23720
|
color-scheme: light;
|
|
23647
23721
|
}
|
|
23648
|
-
@media (prefers-color-scheme: dark) {
|
|
23649
|
-
:root {
|
|
23650
|
-
--bg: #111317; --fg: #e8eaee; --muted: #9aa1ad; --line: #2a2e36;
|
|
23651
|
-
--panel: #181b21; --accent: #8fa2ff; --pass: #5fd08f; --fail: #ff8a80;
|
|
23652
|
-
--warn: #e5b45a;
|
|
23653
|
-
color-scheme: dark;
|
|
23654
|
-
}
|
|
23655
|
-
}
|
|
23656
23722
|
* { box-sizing: border-box; }
|
|
23657
|
-
|
|
23658
|
-
|
|
23659
|
-
|
|
23660
|
-
h1
|
|
23661
|
-
|
|
23662
|
-
|
|
23723
|
+
html { -webkit-text-size-adjust: 100%; }
|
|
23724
|
+
body { margin: 0; background: var(--lightest); color: var(--darkest);
|
|
23725
|
+
font: 16px/1.5 var(--font-body); }
|
|
23726
|
+
p, h1, h2, h3, ul { margin: 0; }
|
|
23727
|
+
ul { padding: 0; list-style: none; }
|
|
23728
|
+
button { font: inherit; color: inherit; }
|
|
23729
|
+
button:not(:disabled) { cursor: pointer; }
|
|
23730
|
+
:focus-visible { outline: 2px solid var(--darkest); outline-offset: 2px; }
|
|
23731
|
+
.mono { font-family: var(--font-mono); }
|
|
23663
23732
|
.muted { color: var(--muted); }
|
|
23664
|
-
.
|
|
23665
|
-
|
|
23666
|
-
.
|
|
23667
|
-
.
|
|
23668
|
-
|
|
23669
|
-
|
|
23670
|
-
.
|
|
23671
|
-
|
|
23672
|
-
|
|
23673
|
-
|
|
23674
|
-
|
|
23675
|
-
.
|
|
23733
|
+
.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 20px; }
|
|
23734
|
+
.band { background: var(--lightest); }
|
|
23735
|
+
.band.soft { background: var(--neutral-1); }
|
|
23736
|
+
.band > .container > .band-inner { padding: 60px 0; }
|
|
23737
|
+
.banner { background: var(--darkest); color: var(--lightest); padding: 12px 20px;
|
|
23738
|
+
text-align: center; font-size: 14px; }
|
|
23739
|
+
.eyebrow { font-family: var(--font-mono); font-size: 14px; line-height: 20px;
|
|
23740
|
+
font-weight: 500; text-transform: uppercase; }
|
|
23741
|
+
.h1 { font-size: 32px; line-height: 37px; font-weight: 900; text-wrap: balance; }
|
|
23742
|
+
.h2 { font-size: 28px; line-height: 34px; font-weight: 900; text-wrap: balance; }
|
|
23743
|
+
.h5 { font-size: 18px; line-height: 25px; font-weight: 800; }
|
|
23744
|
+
.body-1 { font-size: 20px; line-height: 24px; font-weight: 500; }
|
|
23745
|
+
.body-2 { font-size: 18px; line-height: 22px; font-weight: 500; }
|
|
23746
|
+
.hero { background: var(--brand-1-light); }
|
|
23747
|
+
.hero-grid { display: grid; gap: 40px; padding: 40px 0 60px; }
|
|
23748
|
+
.hero-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 20px; }
|
|
23749
|
+
.hero-copy .body-1 { max-width: 720px; }
|
|
23750
|
+
.measured { font-family: var(--font-mono); font-size: 14px; font-weight: 500; color: var(--muted); }
|
|
23751
|
+
.measurement { border: 1px solid var(--neutral-2); border-radius: 8px; background: var(--lightest);
|
|
23752
|
+
padding: 20px; box-shadow: 8px 8px var(--neutral-2); }
|
|
23753
|
+
.measurement-figure { font-size: 50px; line-height: 56px; font-weight: 900; margin-top: 12px; }
|
|
23754
|
+
.facts { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
|
|
23755
|
+
.facts li { font-family: var(--font-mono); font-size: 14px; line-height: 20px; font-weight: 500;
|
|
23756
|
+
border: 1px solid var(--neutral-2); border-radius: 4px; background: var(--neutral-1); padding: 12px; }
|
|
23757
|
+
.header { display: grid; gap: 16px; }
|
|
23758
|
+
.header-title { display: flex; flex-direction: column; gap: 12px; }
|
|
23759
|
+
.header.center { display: flex; flex-direction: column; align-items: center; text-align: center; }
|
|
23760
|
+
.header.center .body-2 { max-width: 820px; }
|
|
23761
|
+
.scorecards { margin-top: 40px; border-radius: 16px; background: var(--brand-1-light); padding: 30px 20px; }
|
|
23762
|
+
.scorecards-grid { display: grid; grid-template-columns: 1fr; gap: 30px; }
|
|
23763
|
+
.stat { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
|
|
23764
|
+
.stat-figure { font-family: var(--font-mono); font-size: 40px; line-height: 36px;
|
|
23765
|
+
font-variant-numeric: tabular-nums; }
|
|
23766
|
+
.stat-label { font-size: 16px; font-weight: 700; }
|
|
23767
|
+
.stat-detail { font-size: 14px; color: var(--muted-strong); }
|
|
23768
|
+
.interval { display: block; }
|
|
23769
|
+
.tip-trigger { background: none; border: 0; padding: 0; margin: 0; text-align: left;
|
|
23770
|
+
font-size: 14px; color: var(--muted-strong); text-decoration: underline dotted;
|
|
23771
|
+
text-underline-offset: 4px; cursor: help; }
|
|
23772
|
+
.tip { display: block; margin-top: 4px; font-size: 12px; color: var(--muted-strong); }
|
|
23676
23773
|
.tip[hidden] { display: none; }
|
|
23677
|
-
|
|
23678
|
-
|
|
23679
|
-
|
|
23680
|
-
|
|
23681
|
-
|
|
23682
|
-
|
|
23683
|
-
|
|
23684
|
-
|
|
23685
|
-
|
|
23686
|
-
|
|
23687
|
-
|
|
23688
|
-
|
|
23689
|
-
|
|
23690
|
-
|
|
23691
|
-
.
|
|
23692
|
-
|
|
23693
|
-
|
|
23694
|
-
|
|
23774
|
+
.subsection { margin-top: 40px; }
|
|
23775
|
+
.card { margin-top: 20px; border: 1px solid var(--neutral-2); border-radius: 8px;
|
|
23776
|
+
background: var(--lightest); padding: 20px; }
|
|
23777
|
+
.card-title { font-size: 16px; font-weight: 700; }
|
|
23778
|
+
.card-lead { margin-top: 4px; font-size: 14px; color: var(--muted); }
|
|
23779
|
+
.scroll { overflow-x: auto; }
|
|
23780
|
+
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
|
|
23781
|
+
th { font-family: var(--font-mono); font-weight: 500; color: var(--muted); text-align: left;
|
|
23782
|
+
border-bottom: 1px solid var(--neutral-2); padding: 8px 12px; }
|
|
23783
|
+
td { border-bottom: 1px solid var(--neutral-2); padding: 10px 12px; vertical-align: top; }
|
|
23784
|
+
.num { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
|
|
23785
|
+
.rate { font-weight: 600; font-variant-numeric: tabular-nums; }
|
|
23786
|
+
tr.total td { border-bottom: 0; font-weight: 700; color: var(--darkest); }
|
|
23787
|
+
tr.selectable { cursor: pointer; }
|
|
23788
|
+
tr.selectable:hover { background: var(--neutral-1); }
|
|
23789
|
+
.row-button { background: none; border: 0; padding: 0; text-align: left; }
|
|
23790
|
+
.matrix-card { margin-top: 40px; padding: 16px; }
|
|
23791
|
+
.matrix { min-width: 640px; }
|
|
23792
|
+
.matrix th, .matrix td { text-align: center; padding: 8px 12px; }
|
|
23793
|
+
.matrix th.prompt-head, .matrix td.prompt { text-align: left; position: sticky; left: 0;
|
|
23794
|
+
z-index: 1; background: var(--lightest); }
|
|
23795
|
+
.matrix td.prompt { max-width: 280px; }
|
|
23796
|
+
.matrix .group { border-bottom: 0; padding-bottom: 4px; font-size: 11px; letter-spacing: 0.05em;
|
|
23797
|
+
text-transform: uppercase; }
|
|
23798
|
+
.matrix .agents-start { border-left: 1px solid var(--neutral-2); }
|
|
23799
|
+
.prompt-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
|
|
23800
|
+
overflow: hidden; font-size: 12px; line-height: 1.375; }
|
|
23801
|
+
.prompt-category { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.05em;
|
|
23802
|
+
text-transform: uppercase; color: var(--muted); }
|
|
23803
|
+
.cell { display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
|
|
23804
|
+
gap: 2px; min-width: 36px; min-height: 36px; padding: 4px 6px; border: 1px solid transparent;
|
|
23805
|
+
border-radius: 6px; background: none; }
|
|
23806
|
+
.cell:hover { border-color: var(--neutral-2); background: var(--neutral-1); }
|
|
23807
|
+
.cell-count { font-size: 9px; line-height: 1; color: var(--muted); font-variant-numeric: tabular-nums; }
|
|
23808
|
+
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--neutral-2); }
|
|
23809
|
+
.dot.primary { width: 10px; height: 10px; background: var(--positive); }
|
|
23810
|
+
.dot.mentioned { background: var(--mention); }
|
|
23811
|
+
.dot.absent { background: var(--negative); opacity: 0.7; }
|
|
23812
|
+
.legend { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 12px; font-size: 11px; color: var(--muted); }
|
|
23813
|
+
.legend li { display: flex; align-items: center; gap: 8px; }
|
|
23814
|
+
.hint { margin-top: 12px; border: 1px solid var(--brand-1); border-radius: 6px;
|
|
23815
|
+
background: var(--brand-1-light); padding: 8px 12px; font-size: 12px; line-height: 1.625; }
|
|
23816
|
+
.bars { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
|
|
23817
|
+
.bars li { display: grid; grid-template-columns: minmax(0, 11rem) 1fr auto; align-items: center; gap: 12px; }
|
|
23818
|
+
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; }
|
|
23819
|
+
.bar-domain { margin-left: 6px; font-size: 12px; font-weight: 400; color: var(--muted); }
|
|
23820
|
+
.bar { height: 6px; overflow: hidden; border-radius: 999px; background: var(--neutral-1); }
|
|
23821
|
+
.bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--darkest); }
|
|
23822
|
+
.bar-value { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
|
|
23823
|
+
.hosts { margin-left: 8px; font-size: 12px; color: var(--muted); }
|
|
23824
|
+
.more { margin-top: 12px; background: none; border: 0; padding: 0; font-family: var(--font-mono);
|
|
23825
|
+
font-size: 12px; text-decoration: underline; text-decoration-color: var(--brand-1);
|
|
23826
|
+
text-decoration-thickness: 2px; text-underline-offset: 4px; }
|
|
23827
|
+
.label { font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: 0.14em;
|
|
23828
|
+
text-transform: uppercase; color: var(--muted); }
|
|
23829
|
+
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
|
|
23830
|
+
.pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--neutral-2);
|
|
23831
|
+
border-radius: 999px; background: var(--neutral-1); padding: 4px 10px; font-size: 12px; }
|
|
23832
|
+
.pill.plain { background: var(--lightest); }
|
|
23833
|
+
.pill.dashed { border-style: dashed; background: none; color: var(--muted); }
|
|
23834
|
+
.pill.mono { font-family: var(--font-mono); }
|
|
23835
|
+
.pill.pass, .pill.primary { border-color: rgb(5 150 105 / 0.3); background: rgb(5 150 105 / 0.1);
|
|
23836
|
+
color: var(--positive-deep); font-weight: 500; }
|
|
23837
|
+
.pill.mentioned { border-color: rgb(139 92 246 / 0.3); background: rgb(139 92 246 / 0.1);
|
|
23838
|
+
color: var(--mention-deep); font-weight: 500; }
|
|
23839
|
+
.pill.fail, .pill.absent { border-color: rgb(239 68 68 / 0.2); background: rgb(239 68 68 / 0.1);
|
|
23840
|
+
font-weight: 500; }
|
|
23841
|
+
.pill-count { color: var(--muted); font-variant-numeric: tabular-nums; }
|
|
23842
|
+
.verification td:nth-child(2) { white-space: nowrap; }
|
|
23843
|
+
.footer { max-width: 720px; margin: 0 auto; text-align: center; font-size: 14px;
|
|
23844
|
+
line-height: 1.625; color: var(--muted); }
|
|
23845
|
+
.footer > * + * { margin-top: 12px; }
|
|
23846
|
+
.footer h2 { margin-top: 24px; font-size: 14px; font-weight: 700; color: var(--muted-strong); }
|
|
23847
|
+
.footer ul { margin-top: 8px; padding-left: 20px; list-style: disc; text-align: left; }
|
|
23848
|
+
.footer ul li + li { margin-top: 4px; }
|
|
23849
|
+
.footer-note { margin-top: 32px; border-top: 1px solid var(--neutral-2); padding-top: 24px; }
|
|
23850
|
+
.sheet-backdrop { position: fixed; inset: 0; z-index: 1000; background: var(--backdrop); cursor: pointer; }
|
|
23851
|
+
.sheet { position: fixed; top: 0; right: 0; bottom: 0; z-index: 1001; display: flex;
|
|
23852
|
+
flex-direction: column; width: 100%; max-width: 560px; background: var(--lightest);
|
|
23853
|
+
padding: 20px; box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1); }
|
|
23854
|
+
.sheet[hidden], .sheet-backdrop[hidden] { display: none; }
|
|
23855
|
+
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
|
|
23856
|
+
.sheet-description { margin-top: 4px; font-size: 14px; color: var(--muted); }
|
|
23857
|
+
.sheet-close { flex-shrink: 0; border: 1px solid var(--neutral-2); border-radius: 6px;
|
|
23858
|
+
background: none; padding: 4px 10px; font-family: var(--font-mono); font-size: 14px; }
|
|
23859
|
+
.sheet-close:hover { background: var(--neutral-1); }
|
|
23860
|
+
.sheet-body { display: flex; flex-direction: column; gap: 20px; flex: 1; min-height: 0;
|
|
23861
|
+
margin-top: 20px; padding-right: 4px; overflow-y: auto; }
|
|
23862
|
+
.prompt-box { border: 1px solid var(--neutral-2); border-radius: 8px; background: var(--neutral-1); padding: 16px; }
|
|
23863
|
+
.prompt-box p { margin-top: 8px; font-size: 14px; line-height: 1.625; }
|
|
23864
|
+
.prompt-box p.prompt-category { font-size: 11px; letter-spacing: 0.14em; }
|
|
23865
|
+
.run { border: 1px solid var(--neutral-2); border-radius: 8px; background: var(--lightest); padding: 16px; }
|
|
23866
|
+
.run-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
|
|
23867
|
+
.run-head .pills { margin-top: 0; justify-content: flex-end; }
|
|
23868
|
+
.run-title { font-size: 14px; font-weight: 700; }
|
|
23869
|
+
.run-surface { font-size: 12px; color: var(--muted); }
|
|
23870
|
+
.run-block { margin-top: 16px; }
|
|
23871
|
+
.snippet { margin-top: 16px; border-radius: 6px; background: var(--neutral-1); padding: 12px; }
|
|
23872
|
+
.answer { margin-top: 8px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.625; }
|
|
23873
|
+
.answer mark { background: var(--brand-1-light); color: inherit; border-radius: 2px;
|
|
23874
|
+
box-shadow: 0 0 0 1px var(--brand-1); }
|
|
23875
|
+
.links { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
|
|
23876
|
+
.source { max-width: 100%; background: none; border: 0; padding: 0; text-align: left;
|
|
23877
|
+
overflow-wrap: anywhere; font-size: 12px; font-weight: 500; text-decoration: underline;
|
|
23878
|
+
text-decoration-color: var(--brand-1); text-decoration-thickness: 2px; text-underline-offset: 4px; }
|
|
23879
|
+
.source:hover { text-decoration-color: var(--darkest); }
|
|
23880
|
+
.source-meta { margin-top: 2px; font-size: 11px; color: var(--muted); }
|
|
23881
|
+
.empty { border: 1px dashed var(--neutral-2); border-radius: 6px; padding: 12px; font-size: 14px; color: var(--muted); }
|
|
23882
|
+
@media (min-width: 480px) {
|
|
23883
|
+
.h1 { font-size: 40px; line-height: 50px; }
|
|
23884
|
+
.h2 { font-size: 32px; line-height: 38px; }
|
|
23885
|
+
.scorecards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
23886
|
+
.sheet { padding: 32px; }
|
|
23887
|
+
}
|
|
23888
|
+
@media (min-width: 768px) {
|
|
23889
|
+
.container { padding: 0 30px; }
|
|
23890
|
+
.h1 { font-size: 44px; line-height: 56px; }
|
|
23891
|
+
.h2 { font-size: 36px; line-height: 42px; }
|
|
23892
|
+
.h5 { font-size: 20px; }
|
|
23893
|
+
.body-1 { font-size: 22px; line-height: 28px; }
|
|
23894
|
+
.body-2 { font-size: 20px; line-height: 25px; }
|
|
23895
|
+
.hero-grid { padding-top: 80px; }
|
|
23896
|
+
.measurement { padding: 30px; }
|
|
23897
|
+
.header.split { grid-template-columns: 0.8fr 1fr; align-items: start; gap: 40px; }
|
|
23898
|
+
.scorecards { padding: 30px 40px; }
|
|
23899
|
+
.scorecards-grid { gap: 40px; }
|
|
23900
|
+
.matrix-card { padding: 20px; }
|
|
23901
|
+
}
|
|
23902
|
+
@media (min-width: 992px) {
|
|
23903
|
+
.container { padding: 0 40px; }
|
|
23904
|
+
.band > .container > .band-inner { padding: 100px 0; }
|
|
23905
|
+
.eyebrow { font-size: 16px; }
|
|
23906
|
+
.h2 { font-size: 42px; line-height: 50px; }
|
|
23907
|
+
.body-1 { font-size: 24px; line-height: 30px; }
|
|
23908
|
+
.hero-grid { grid-template-columns: minmax(0, 1fr) minmax(340px, 0.62fr); align-items: center;
|
|
23909
|
+
padding: 100px 0; }
|
|
23910
|
+
.measurement-figure { font-size: 72px; line-height: 78px; }
|
|
23911
|
+
.facts li { font-size: 16px; }
|
|
23912
|
+
.scorecards { padding: 40px 60px; }
|
|
23913
|
+
.scorecards-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
|
|
23914
|
+
.scorecards-grid.five { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
23915
|
+
.stat-figure { font-size: 56px; line-height: 48px; }
|
|
23916
|
+
}
|
|
23917
|
+
@media (min-width: 1280px) {
|
|
23918
|
+
.scorecards-grid.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
|
|
23919
|
+
}
|
|
23920
|
+
@media (prefers-reduced-motion: reduce) {
|
|
23921
|
+
* { scroll-behavior: auto; transition: none; }
|
|
23922
|
+
}
|
|
23695
23923
|
`;
|
|
23696
23924
|
var script = `
|
|
23697
23925
|
const token = new URLSearchParams(location.search).get('t');
|
|
@@ -23707,46 +23935,31 @@ const el = (tag, attrs = {}, ...children) => {
|
|
|
23707
23935
|
else if (key.startsWith('on')) node.addEventListener(key.slice(2), value);
|
|
23708
23936
|
else node.setAttribute(key, value);
|
|
23709
23937
|
}
|
|
23710
|
-
for (const child of children) {
|
|
23711
|
-
if (child === null || child === undefined) continue;
|
|
23938
|
+
for (const child of children.flat()) {
|
|
23939
|
+
if (child === null || child === undefined || child === false) continue;
|
|
23712
23940
|
node.append(typeof child === 'string' ? document.createTextNode(child) : child);
|
|
23713
23941
|
}
|
|
23714
23942
|
return node;
|
|
23715
23943
|
};
|
|
23716
|
-
const
|
|
23717
|
-
|
|
23718
|
-
|
|
23719
|
-
const
|
|
23720
|
-
|
|
23721
|
-
|
|
23722
|
-
|
|
23723
|
-
|
|
23724
|
-
evidence && isShare(evidence.low) && isShare(evidence.high) && evidence.low <= evidence.high
|
|
23725
|
-
&& isCount(evidence.count) && isCount(evidence.captured) && isCount(evidence.planned)
|
|
23726
|
-
? evidence : null;
|
|
23727
|
-
// Outward to whole percents, so the range shown always contains the computed
|
|
23728
|
-
// interval. The bounds are stored to 6 decimals; scaling them to an integer
|
|
23729
|
-
// first keeps a bound of 0.07 (7.000000000000001 once multiplied) at 7%.
|
|
23730
|
-
// The rule of report/core/rate-interval.ts, repeated here because this page
|
|
23731
|
-
// is one self-contained script; page.spec.ts holds the two to the same
|
|
23732
|
-
// answers.
|
|
23733
|
-
const intervalText = (evidence) =>
|
|
23734
|
-
Math.floor(Math.round(evidence.low * 1e6) / 1e4) + '\u2013'
|
|
23735
|
-
+ Math.ceil(Math.round(evidence.high * 1e6) / 1e4) + '%';
|
|
23944
|
+
const plural = (count, noun) => count + ' ' + noun + (count === 1 ? '' : 's');
|
|
23945
|
+
|
|
23946
|
+
// Escape closes whatever is open: a tooltip, or the evidence sheet.
|
|
23947
|
+
const dismissals = [];
|
|
23948
|
+
document.addEventListener('keydown', (event) => {
|
|
23949
|
+
if (event.key === 'Escape') for (const dismiss of dismissals) dismiss();
|
|
23950
|
+
});
|
|
23951
|
+
|
|
23736
23952
|
// The counts behind an interval, in a tooltip (WCAG 1.4.13). It opens on
|
|
23737
23953
|
// hover, on keyboard focus and on a tap; it stays open while the pointer is
|
|
23738
23954
|
// over it; Escape closes it; and a screen reader reads it as the interval's
|
|
23739
23955
|
// description. It sits in the flow under the interval, so a scrolling table
|
|
23740
23956
|
// cannot clip it and it hides nothing.
|
|
23741
|
-
const tipDismissals = [];
|
|
23742
|
-
document.addEventListener('keydown', (event) => {
|
|
23743
|
-
if (event.key === 'Escape') for (const dismiss of tipDismissals) dismiss();
|
|
23744
|
-
});
|
|
23745
23957
|
let tipCount = 0;
|
|
23746
|
-
const
|
|
23958
|
+
const intervalOf = (interval) => {
|
|
23959
|
+
if (!interval) return null;
|
|
23747
23960
|
tipCount += 1;
|
|
23748
23961
|
const id = 'tip-' + tipCount;
|
|
23749
|
-
const tip = el('span', { class: 'tip', role: 'tooltip', id, hidden: '' },
|
|
23962
|
+
const tip = el('span', { class: 'tip', role: 'tooltip', id, hidden: '' }, interval.counts);
|
|
23750
23963
|
let hovered = false;
|
|
23751
23964
|
let focused = false;
|
|
23752
23965
|
const sync = () => {
|
|
@@ -23754,193 +23967,351 @@ const withTip = (label, name, text) => {
|
|
|
23754
23967
|
else tip.setAttribute('hidden', '');
|
|
23755
23968
|
};
|
|
23756
23969
|
const trigger = el('button', { type: 'button', class: 'tip-trigger',
|
|
23757
|
-
'aria-label':
|
|
23970
|
+
'aria-label': interval.label, 'aria-describedby': id,
|
|
23758
23971
|
// Safari focuses no button on a click or a tap, and a button that kept
|
|
23759
23972
|
// focus through Escape gets no new focus event: a click (or Enter or
|
|
23760
23973
|
// Space) opens the tip itself, until focus moves on.
|
|
23761
23974
|
onclick: () => { trigger.focus(); focused = true; sync(); },
|
|
23762
23975
|
onfocus: () => { focused = true; sync(); },
|
|
23763
23976
|
onblur: () => { focused = false; sync(); },
|
|
23764
|
-
},
|
|
23765
|
-
|
|
23977
|
+
}, interval.text);
|
|
23978
|
+
dismissals.push(() => { hovered = false; focused = false; sync(); });
|
|
23766
23979
|
return el('span', { class: 'interval',
|
|
23767
23980
|
onmouseenter: () => { hovered = true; sync(); },
|
|
23768
23981
|
onmouseleave: () => { hovered = false; sync(); },
|
|
23769
23982
|
}, trigger, tip);
|
|
23770
23983
|
};
|
|
23771
|
-
|
|
23772
|
-
//
|
|
23773
|
-
|
|
23774
|
-
|
|
23775
|
-
|
|
23776
|
-
|
|
23777
|
-
|
|
23778
|
-
|
|
23779
|
-
|
|
23780
|
-
|
|
23781
|
-
|
|
23782
|
-
|
|
23783
|
-
|
|
23784
|
-
|
|
23785
|
-
|
|
23786
|
-
|
|
23787
|
-
|
|
23788
|
-
|
|
23789
|
-
|
|
23790
|
-
|
|
23791
|
-
|
|
23792
|
-
|
|
23793
|
-
|
|
23794
|
-
|
|
23795
|
-
|
|
23796
|
-
|
|
23797
|
-
|
|
23798
|
-
|
|
23799
|
-
|
|
23800
|
-
|
|
23801
|
-
|
|
23802
|
-
}
|
|
23803
|
-
|
|
23804
|
-
|
|
23805
|
-
|
|
23806
|
-
|
|
23807
|
-
|
|
23808
|
-
|
|
23809
|
-
|
|
23810
|
-
|
|
23811
|
-
}
|
|
23812
|
-
|
|
23813
|
-
|
|
23984
|
+
|
|
23985
|
+
// External sources open only on a deliberate click, in a new context.
|
|
23986
|
+
const sourceLink = (url) => el('button', { class: 'source', type: 'button',
|
|
23987
|
+
onclick: () => { if (/^https?:\\/\\//.test(url)) window.open(url, '_blank', 'noopener,noreferrer'); },
|
|
23988
|
+
}, url);
|
|
23989
|
+
|
|
23990
|
+
// The brand's name marked in a captured answer, every piece of it text.
|
|
23991
|
+
const highlighted = (text, term) => {
|
|
23992
|
+
const needle = term.trim().toLowerCase();
|
|
23993
|
+
if (!needle) return [text];
|
|
23994
|
+
const haystack = text.toLowerCase();
|
|
23995
|
+
const pieces = [];
|
|
23996
|
+
let from = 0;
|
|
23997
|
+
for (let at = haystack.indexOf(needle); at !== -1; at = haystack.indexOf(needle, from)) {
|
|
23998
|
+
pieces.push(text.slice(from, at), el('mark', {}, text.slice(at, at + needle.length)));
|
|
23999
|
+
from = at + needle.length;
|
|
24000
|
+
}
|
|
24001
|
+
pieces.push(text.slice(from));
|
|
24002
|
+
return pieces.filter((piece) => piece !== '');
|
|
24003
|
+
};
|
|
24004
|
+
|
|
24005
|
+
// The side sheet behind a matrix cell or a cited domain.
|
|
24006
|
+
const createSheet = () => {
|
|
24007
|
+
const title = el('h2', { class: 'h5', id: 'sheet-title' });
|
|
24008
|
+
const description = el('p', { class: 'sheet-description' });
|
|
24009
|
+
const body = el('div', { class: 'sheet-body' });
|
|
24010
|
+
let opener = null;
|
|
24011
|
+
let isOpen = false;
|
|
24012
|
+
const backdrop = el('div', { class: 'sheet-backdrop', hidden: '', onclick: () => close() });
|
|
24013
|
+
const closeButton = el('button', { type: 'button', class: 'sheet-close', onclick: () => close() }, 'Close');
|
|
24014
|
+
const panel = el('div', { class: 'sheet', role: 'dialog', 'aria-modal': 'true',
|
|
24015
|
+
'aria-labelledby': 'sheet-title', hidden: '' },
|
|
24016
|
+
el('div', { class: 'sheet-head' }, el('div', {}, title, description), closeButton), body);
|
|
24017
|
+
const close = () => {
|
|
24018
|
+
if (!isOpen) return;
|
|
24019
|
+
isOpen = false;
|
|
24020
|
+
backdrop.setAttribute('hidden', '');
|
|
24021
|
+
panel.setAttribute('hidden', '');
|
|
24022
|
+
// Focus returns to what opened the sheet.
|
|
24023
|
+
opener?.focus();
|
|
24024
|
+
};
|
|
24025
|
+
dismissals.push(close);
|
|
24026
|
+
const open = (from, heading, summary, content) => {
|
|
24027
|
+
opener = from;
|
|
24028
|
+
title.replaceChildren(heading);
|
|
24029
|
+
description.replaceChildren(summary);
|
|
24030
|
+
body.replaceChildren(...content);
|
|
24031
|
+
backdrop.removeAttribute('hidden');
|
|
24032
|
+
panel.removeAttribute('hidden');
|
|
24033
|
+
isOpen = true;
|
|
24034
|
+
closeButton.focus();
|
|
24035
|
+
};
|
|
24036
|
+
return { nodes: [backdrop, panel], open };
|
|
24037
|
+
};
|
|
24038
|
+
|
|
24039
|
+
const band = (tone, ...content) => el('section', { class: tone === 'soft' ? 'band soft' : 'band' },
|
|
24040
|
+
el('div', { class: 'container' }, el('div', { class: 'band-inner' }, ...content)));
|
|
24041
|
+
|
|
24042
|
+
const sectionHeader = (eyebrow, heading, lead, layout) => {
|
|
24043
|
+
const title = el('div', { class: 'header-title' },
|
|
24044
|
+
el('p', { class: 'eyebrow' }, eyebrow), el('h2', { class: 'h2' }, heading));
|
|
24045
|
+
return el('div', { class: 'header ' + (layout || (lead ? 'split' : '')) },
|
|
24046
|
+
title, lead ? el('p', { class: 'body-2' }, lead) : null);
|
|
24047
|
+
};
|
|
24048
|
+
|
|
24049
|
+
const statusLabels = { primary: 'Primary', mentioned: 'Mentioned', absent: 'Absent', no_overview: 'No AI Overview' };
|
|
24050
|
+
const retrievalLabels = { searched: 'searched the web', memory: 'answered from memory', unknown: 'retrieval unknown' };
|
|
24051
|
+
|
|
24052
|
+
const runCard = (run, brandName) => el('article', { class: 'run' },
|
|
24053
|
+
el('div', { class: 'run-head' },
|
|
24054
|
+
el('div', {}, el('p', { class: 'run-title' }, 'Run ' + run.runNumber),
|
|
24055
|
+
el('p', { class: 'run-surface' }, run.surface + (run.cliVersion ? ' \xB7 ' + run.cliVersion : ''))),
|
|
24056
|
+
el('div', { class: 'pills' },
|
|
24057
|
+
run.retrieval ? el('span', { class: 'pill mono' + (run.retrieval === 'unknown' ? ' dashed' : '') },
|
|
24058
|
+
retrievalLabels[run.retrieval]) : null,
|
|
24059
|
+
el('span', { class: 'pill ' + (run.status === 'no_overview' ? 'dashed' : run.status) }, statusLabels[run.status]))),
|
|
24060
|
+
run.snippet ? el('div', { class: 'snippet' }, el('p', { class: 'label' }, 'Detected mention'),
|
|
24061
|
+
el('p', { class: 'answer' }, ...highlighted(run.snippet, brandName))) : null,
|
|
24062
|
+
run.answer ? el('div', { class: 'run-block' }, el('p', { class: 'label' }, 'Full captured answer'),
|
|
24063
|
+
el('p', { class: 'answer' }, ...highlighted(run.answer, brandName)))
|
|
24064
|
+
: el('p', { class: 'empty run-block' }, run.status === 'no_overview'
|
|
24065
|
+
? 'The results page showed no AI Overview: there is no answer to show.'
|
|
24066
|
+
: 'No captured answer in this bundle matches this run.'),
|
|
24067
|
+
run.mentionedBrands.length ? el('div', { class: 'run-block' }, el('p', { class: 'label' }, 'Mentioned companies'),
|
|
24068
|
+
el('ul', { class: 'pills' }, run.mentionedBrands.map((brand) => el('li', {}, el('span', { class: 'pill plain' }, brand))))) : null,
|
|
24069
|
+
run.citedUrls.length ? el('div', { class: 'run-block' }, el('p', { class: 'label' }, 'URLs in response'),
|
|
24070
|
+
el('ul', { class: 'links' }, run.citedUrls.map((url) => el('li', {}, sourceLink(url))))) : null,
|
|
24071
|
+
);
|
|
24072
|
+
|
|
24073
|
+
const scorecards = (cards) => el('div', { class: 'scorecards' },
|
|
24074
|
+
el('div', { class: cards.length >= 5 ? 'scorecards-grid five' : 'scorecards-grid' },
|
|
24075
|
+
cards.map((card) => el('div', { class: 'stat' },
|
|
24076
|
+
el('p', { class: 'stat-figure' }, card.headline),
|
|
24077
|
+
intervalOf(card.headlineInterval),
|
|
24078
|
+
el('p', { class: 'stat-label' }, card.label),
|
|
24079
|
+
card.detail ? el('p', { class: 'stat-detail' }, card.detail) : null,
|
|
24080
|
+
intervalOf(card.detailInterval)))));
|
|
24081
|
+
|
|
24082
|
+
const surfaceRates = (rows) => rows.length === 0 ? null : el('section', { class: 'subsection', 'aria-label': 'Rates by AI surface' },
|
|
24083
|
+
el('p', { class: 'h5' }, 'By AI surface'),
|
|
24084
|
+
el('div', { class: 'scroll' }, el('table', { class: 'by-model' },
|
|
24085
|
+
el('thead', {}, el('tr', {}, el('th', {}, 'AI surface'), el('th', {}, 'Share of voice'), el('th', {}, 'Citation rate'))),
|
|
24086
|
+
el('tbody', {}, rows.map((row) => el('tr', {},
|
|
24087
|
+
el('td', {}, row.surface),
|
|
24088
|
+
el('td', {}, el('span', { class: 'rate' }, row.shareOfVoice.percent), intervalOf(row.shareOfVoice.interval)),
|
|
24089
|
+
el('td', {}, el('span', { class: 'rate' }, row.citationRate.percent), intervalOf(row.citationRate.interval))))))));
|
|
24090
|
+
|
|
24091
|
+
const dot = (status) => el('span', { class: 'dot ' + status, role: 'img',
|
|
24092
|
+
'aria-label': { primary: 'Primary mention', mentioned: 'Secondary mention', absent: 'Not mentioned', no_data: 'No data' }[status] });
|
|
24093
|
+
|
|
24094
|
+
const matrix = (section, brandName, sheet) => {
|
|
24095
|
+
const { assistantSurfaces, agentSurfaces, rows } = section.matrix;
|
|
24096
|
+
const surfaces = [...assistantSurfaces, ...agentSurfaces];
|
|
24097
|
+
const firstAgent = assistantSurfaces.length;
|
|
24098
|
+
const edge = (index, base) => base + (agentSurfaces.length && index === firstAgent ? ' agents-start' : '');
|
|
24099
|
+
const groups = agentSurfaces.length === 0 ? null : el('tr', {},
|
|
24100
|
+
el('td', { class: 'prompt group', 'aria-hidden': 'true' }),
|
|
24101
|
+
assistantSurfaces.length ? el('th', { class: 'group', colspan: String(assistantSurfaces.length), scope: 'colgroup' }, 'AI assistants') : null,
|
|
24102
|
+
el('th', { class: 'group agents-start', colspan: String(agentSurfaces.length), scope: 'colgroup' }, 'Coding agents'));
|
|
24103
|
+
const body = rows.map((row, promptIdx) => el('tr', {},
|
|
24104
|
+
el('td', { class: 'prompt', title: row.prompt },
|
|
24105
|
+
el('span', { class: 'prompt-text' }, row.prompt), el('span', { class: 'prompt-category' }, row.category)),
|
|
24106
|
+
row.cells.map((cell, index) => el('td', { class: edge(index, '') },
|
|
24107
|
+
cell.status === 'no_data' ? dot('no_data') : (() => {
|
|
24108
|
+
const button = el('button', { type: 'button', class: 'cell',
|
|
24109
|
+
'aria-label': surfaces[index] + ', prompt ' + (promptIdx + 1) + ': ' + cell.status + '. Inspect evidence.',
|
|
24110
|
+
onclick: () => sheet.open(button, surfaces[index] + ' evidence',
|
|
24111
|
+
'Prompt ' + (promptIdx + 1) + ' \xB7 ' + cell.mentioned + '/' + cell.runs.length + ' runs mentioned ' + brandName,
|
|
24112
|
+
[el('section', { class: 'prompt-box' }, el('h3', { class: 'label' }, 'Prompt'), el('p', {}, row.prompt),
|
|
24113
|
+
el('p', { class: 'prompt-category' }, row.category)),
|
|
24114
|
+
...cell.runs.map((run) => runCard(run, brandName))]),
|
|
24115
|
+
}, dot(cell.status), el('span', { class: 'cell-count' }, cell.mentioned + '/' + cell.runs.length));
|
|
24116
|
+
return button;
|
|
24117
|
+
})()))));
|
|
24118
|
+
return el('div', { class: 'card matrix-card' },
|
|
24119
|
+
el('div', { class: 'scroll', role: 'group', 'aria-label': 'AI answer evidence matrix', tabindex: '0' },
|
|
24120
|
+
el('table', { class: 'matrix' },
|
|
24121
|
+
el('thead', {}, groups, el('tr', {}, el('th', { class: 'prompt-head' }, 'Prompt'),
|
|
24122
|
+
surfaces.map((surface, index) => el('th', { class: edge(index, '') }, surface)))),
|
|
24123
|
+
el('tbody', {}, body))),
|
|
24124
|
+
el('ul', { class: 'legend' },
|
|
24125
|
+
[['primary', 'Primary recommendation'], ['mentioned', 'Mentioned secondarily'], ['absent', 'Not mentioned'], ['no_data', 'No data']]
|
|
24126
|
+
.map(([status, text]) => el('li', {}, el('span', { class: 'dot ' + status }), text))),
|
|
24127
|
+
el('p', { class: 'hint' }, 'Click any dot with a run count to inspect the captured AI answers, cited URLs, and highlighted mentions behind that result.'));
|
|
24128
|
+
};
|
|
24129
|
+
|
|
24130
|
+
const alternatives = (rows) => rows.length === 0 ? null : el('div', { class: 'card' },
|
|
24131
|
+
el('h3', { class: 'card-title' }, 'Who buyers hear about instead'),
|
|
24132
|
+
el('p', { class: 'card-lead' }, 'Competing companies and products named in the answers, ranked by share of voice (answers that mention them / answers captured).'),
|
|
24133
|
+
el('ul', { class: 'bars' }, rows.map((row) => {
|
|
24134
|
+
const fill = el('span', { class: 'bar-fill' });
|
|
24135
|
+
// CSSOM, which the page's Content Security Policy allows, unlike a style attribute.
|
|
24136
|
+
if (fill.style) fill.style.width = (row.share * 100) + '%';
|
|
24137
|
+
return el('li', {},
|
|
24138
|
+
el('span', { class: 'bar-name', title: row.domain || row.name }, row.name,
|
|
24139
|
+
row.domain && row.domain.toLowerCase() !== row.name.trim().toLowerCase() ? el('span', { class: 'bar-domain' }, row.domain) : null),
|
|
24140
|
+
el('span', { class: 'bar' }, fill),
|
|
24141
|
+
el('span', { class: 'bar-value' }, row.percent + ' ' + row.mentioning + '/' + row.captured));
|
|
24142
|
+
})));
|
|
24143
|
+
|
|
24144
|
+
const citedDomains = (domains, sheet) => {
|
|
24145
|
+
const total = domains.reduce((sum, domain) => sum + domain.count, 0);
|
|
24146
|
+
const shown = 10;
|
|
24147
|
+
const body = el('tbody');
|
|
24148
|
+
const more = el('button', { type: 'button', class: 'more' });
|
|
24149
|
+
let showAll = false;
|
|
24150
|
+
const rowOf = (domain) => {
|
|
24151
|
+
const inspect = (from) => sheet.open(from, domain.domain, plural(domain.count, 'citation') + ' across the captured answers',
|
|
24152
|
+
[el('ul', { class: 'links' }, domain.urls.map((url) => el('li', {}, sourceLink(url.url),
|
|
24153
|
+
el('p', { class: 'source-meta' }, plural(url.count, 'citation') + ' \xB7 ' + url.surfaces.join(', ')),
|
|
24154
|
+
...url.prompts.map((prompt) => el('p', { class: 'source-meta' }, prompt)))))]);
|
|
24155
|
+
const name = el('span', { class: domain.isBrand ? 'rate' : '' }, domain.domain);
|
|
24156
|
+
const hosts = domain.hosts ? el('span', { class: 'hosts' }, domain.hosts.map((host) => host.label + ' ' + host.count).join(' \xB7 ')) : null;
|
|
24157
|
+
if (domain.count === 0) return el('tr', {}, el('td', {}, name, hosts), el('td', { class: 'num' }, '0'));
|
|
24158
|
+
const button = el('button', { type: 'button', class: 'row-button',
|
|
24159
|
+
'aria-label': 'Inspect the ' + domain.count + ' cited URLs behind ' + domain.domain,
|
|
24160
|
+
onclick: (event) => { event.stopPropagation?.(); inspect(button); } }, name, hosts);
|
|
24161
|
+
return el('tr', { class: 'selectable', onclick: () => inspect(button) },
|
|
24162
|
+
el('td', {}, button), el('td', { class: 'num' }, String(domain.count)));
|
|
24163
|
+
};
|
|
24164
|
+
const sync = () => {
|
|
24165
|
+
body.replaceChildren(...(showAll ? domains : domains.slice(0, shown)).map(rowOf));
|
|
24166
|
+
const hidden = domains.length - shown;
|
|
24167
|
+
more.replaceChildren(showAll ? 'Show fewer domains' : '+' + plural(hidden, 'more domain'));
|
|
24168
|
+
if (hidden > 0) more.removeAttribute('hidden'); else more.setAttribute('hidden', '');
|
|
24169
|
+
};
|
|
24170
|
+
more.addEventListener('click', () => { showAll = !showAll; sync(); });
|
|
24171
|
+
sync();
|
|
24172
|
+
return el('div', { class: 'card' },
|
|
24173
|
+
el('h3', { class: 'card-title' }, 'What gets cited'),
|
|
24174
|
+
el('p', { class: 'card-lead' }, 'Domains behind the URLs cited in these answers'
|
|
24175
|
+
+ (total > 0 ? ' (' + total + ' citations captured). Click a domain to inspect the URLs behind it.' : '.')),
|
|
24176
|
+
el('div', { class: 'scroll' }, el('table', {},
|
|
24177
|
+
el('thead', {}, el('tr', {}, el('th', {}, 'Domain'), el('th', { class: 'num' }, 'Citations'))), body)),
|
|
24178
|
+
more);
|
|
24179
|
+
};
|
|
24180
|
+
|
|
24181
|
+
const sourceCategories = [['owned', 'Owned'], ['competitor', 'Competitor'], ['social', 'Social & community'],
|
|
24182
|
+
['institutional', 'Institutional'], ['earned', 'Earned']];
|
|
24183
|
+
|
|
24184
|
+
const sourceMix = (mix) => !mix || mix.rows.length === 0 ? null : el('div', { class: 'card' },
|
|
24185
|
+
el('h3', { class: 'card-title' }, 'Where the citations come from'),
|
|
24186
|
+
el('p', { class: 'card-lead' }, 'Every cited URL classified: the brand\u2019s own pages, competitor pages, social and community threads, institutional references, or earned media. Each surface leans differently.'),
|
|
24187
|
+
el('div', { class: 'scroll', role: 'group', 'aria-label': 'Citation sources by AI surface', tabindex: '0' },
|
|
24188
|
+
el('table', {},
|
|
24189
|
+
el('thead', {}, el('tr', {}, el('th', {}, 'Surface'), sourceCategories.map(([, label]) => el('th', { class: 'num' }, label)))),
|
|
24190
|
+
el('tbody', {},
|
|
24191
|
+
mix.rows.map((row) => el('tr', {}, el('td', { class: 'rate' }, row.surface),
|
|
24192
|
+
sourceCategories.map(([key]) => el('td', { class: 'num' }, row.counts[key] ? String(row.counts[key]) : '\u2014')))),
|
|
24193
|
+
el('tr', { class: 'total' }, el('td', {}, 'All surfaces'),
|
|
24194
|
+
sourceCategories.map(([key]) => el('td', { class: 'num' }, mix.total[key] ? String(mix.total[key]) : '\u2014')))))));
|
|
24195
|
+
|
|
24196
|
+
const perception = (view, brandName) => {
|
|
24197
|
+
if (!view) return null;
|
|
24198
|
+
const mentions = view.positive + view.neutral + view.negative;
|
|
24199
|
+
if (mentions === 0 && view.phrases.length === 0) return null;
|
|
24200
|
+
return el('div', { class: 'card' },
|
|
24201
|
+
el('h3', { class: 'card-title' }, 'How the answers talk about ' + brandName),
|
|
24202
|
+
mentions > 0 ? el('p', { class: 'card-lead' }, 'Across ' + mentions + ' answers that mention ' + brandName + ': '
|
|
24203
|
+
+ view.positive + ' positive, ' + view.neutral + ' neutral, ' + view.negative + ' negative.') : null,
|
|
24204
|
+
view.phrases.length ? el('div', { class: 'run-block' },
|
|
24205
|
+
el('p', { class: 'label' }, 'Phrases the answers attach to ' + brandName),
|
|
24206
|
+
el('ul', { class: 'pills' }, view.phrases.map((phrase) => el('li', {},
|
|
24207
|
+
el('span', { class: 'pill', title: 'Said by ' + phrase.surfaces.join(', ') },
|
|
24208
|
+
el('span', {}, '\u201C' + phrase.text + '\u201D'),
|
|
24209
|
+
phrase.count > 1 ? el('span', { class: 'pill-count' }, '\xD7' + phrase.count) : null))))) : null);
|
|
24210
|
+
};
|
|
24211
|
+
|
|
24212
|
+
const verification = (result) => el('div', { class: 'card' },
|
|
24213
|
+
el('h3', { class: 'card-title' }, 'Checks'),
|
|
24214
|
+
el('p', { class: 'card-lead' }, 'Capture authenticity: self-reported. Checks run on this machine, offline.'),
|
|
24215
|
+
el('div', { class: 'scroll' }, el('table', { class: 'verification' },
|
|
24216
|
+
el('thead', {}, el('tr', {}, el('th', {}, 'Check'), el('th', {}, 'Outcome'), el('th', {}, 'Why'))),
|
|
24217
|
+
el('tbody', {}, result.checks.map((check) => el('tr', {},
|
|
24218
|
+
el('td', {}, check.title),
|
|
24219
|
+
el('td', {}, el('span', { class: 'pill ' + (check.outcome === 'pass' ? 'pass' : check.outcome === 'fail' ? 'fail' : 'dashed') },
|
|
24220
|
+
check.outcome.replace('_', ' '))),
|
|
24221
|
+
el('td', { class: 'muted' }, check.outcome === 'pass' ? '' : check.explanation)))))));
|
|
24222
|
+
|
|
24223
|
+
const hero = (report, info) => el('section', { class: 'hero' }, el('div', { class: 'container' },
|
|
24224
|
+
el('div', { class: 'hero-grid' },
|
|
24225
|
+
el('div', { class: 'hero-copy' },
|
|
24226
|
+
el('p', { class: 'eyebrow' }, 'AI visibility audit'),
|
|
24227
|
+
el('h1', { class: 'h1' }, report.hero.title),
|
|
24228
|
+
el('p', { class: 'body-1' }, report.hero.subtitle),
|
|
24229
|
+
el('p', { class: 'measured' }, 'Measured ' + report.hero.measuredOn + ' \xB7 ' + info.originLabel)),
|
|
24230
|
+
el('div', { class: 'measurement' },
|
|
24231
|
+
el('p', { class: 'eyebrow' }, 'The measurement'),
|
|
24232
|
+
el('p', { class: 'measurement-figure' }, String(report.hero.probeCount)),
|
|
24233
|
+
el('p', { class: 'h5' }, 'captured AI answers'),
|
|
24234
|
+
el('ul', { class: 'facts' }, report.hero.facts.map((fact) => el('li', {}, fact)))))));
|
|
24235
|
+
|
|
24236
|
+
const plainHero = (info) => el('section', { class: 'hero' }, el('div', { class: 'container' },
|
|
24237
|
+
el('div', { class: 'hero-grid' }, el('div', { class: 'hero-copy' },
|
|
24238
|
+
el('p', { class: 'eyebrow' }, 'Literally.dev AEO'),
|
|
24239
|
+
el('h1', { class: 'h1' }, 'AI visibility audit'),
|
|
24240
|
+
el('p', { class: 'measured' }, info.originLabel)))));
|
|
23814
24241
|
|
|
23815
24242
|
const render = async () => {
|
|
23816
24243
|
const root = document.getElementById('app');
|
|
23817
|
-
const [info,
|
|
23818
|
-
get('__viewer'), get('__verification'), get('report/snapshot.json'),
|
|
23819
|
-
get('captures/units.json'), get('inputs/config.json'),
|
|
23820
|
-
]);
|
|
24244
|
+
const [info, result, report] = await Promise.all([get('__viewer'), get('__verification'), get('__report')]);
|
|
23821
24245
|
root.replaceChildren();
|
|
23822
|
-
if (!info) {
|
|
23823
|
-
root.append(el('p', {}, 'This viewer link is not valid. Start it again with literally-aeo view.'));
|
|
24246
|
+
if (!info || !report) {
|
|
24247
|
+
root.append(el('p', { class: 'container' }, 'This viewer link is not valid. Start it again with literally-aeo view.'));
|
|
23824
24248
|
return;
|
|
23825
24249
|
}
|
|
23826
|
-
const
|
|
23827
|
-
|
|
23828
|
-
root.append(
|
|
23829
|
-
el('h1', {}, brand + ': AI visibility audit'),
|
|
23830
|
-
el('p', { class: 'muted' }, info.originLabel + ' \xB7 ' + info.source),
|
|
23831
|
-
);
|
|
24250
|
+
const sheet = createSheet();
|
|
24251
|
+
const shown = report.outcome === 'shown';
|
|
23832
24252
|
if (info.workingState) {
|
|
23833
|
-
root.append(el('div', { class: 'banner
|
|
24253
|
+
root.append(el('div', { class: 'banner' },
|
|
23834
24254
|
'Working state, not a finalized revision: this is not an integrity receipt. Export the run to finalize it.'));
|
|
23835
24255
|
}
|
|
23836
|
-
|
|
23837
|
-
|
|
23838
|
-
|
|
23839
|
-
|
|
23840
|
-
|
|
23841
|
-
|
|
23842
|
-
|
|
23843
|
-
|
|
23844
|
-
|
|
23845
|
-
|
|
23846
|
-
|
|
23847
|
-
|
|
23848
|
-
|
|
23849
|
-
|
|
23850
|
-
}
|
|
23851
|
-
const
|
|
23852
|
-
|
|
23853
|
-
|
|
23854
|
-
|
|
23855
|
-
|
|
23856
|
-
|
|
23857
|
-
|
|
23858
|
-
|
|
23859
|
-
|
|
24256
|
+
root.append(shown ? hero(report, info) : plainHero(info));
|
|
24257
|
+
const bands = [];
|
|
24258
|
+
if (shown && report.intro) {
|
|
24259
|
+
bands.push([sectionHeader('AI search visibility', report.intro.heading, report.intro.lead, 'center')]);
|
|
24260
|
+
}
|
|
24261
|
+
if (result || !shown) {
|
|
24262
|
+
// A working state is not verified: no claim that it was.
|
|
24263
|
+
bands.push([sectionHeader('Evidence', 'Verification', result
|
|
24264
|
+
? 'The bundle re-checked on this machine: its hashes, its event chain and every metric recomputed from its own judgments. A check that cannot run says so.'
|
|
24265
|
+
: undefined),
|
|
24266
|
+
result ? verification(result) : null,
|
|
24267
|
+
shown ? null : el('p', { class: 'card empty' }, report.outcome === 'missing'
|
|
24268
|
+
? 'This run has no report yet: the measurement did not finish.'
|
|
24269
|
+
: 'The report cannot be shown: ' + report.reason)]);
|
|
24270
|
+
}
|
|
24271
|
+
for (const section of shown ? report.sections : []) {
|
|
24272
|
+
bands.push([
|
|
24273
|
+
sectionHeader('AI search visibility', section.title),
|
|
24274
|
+
scorecards(section.scorecards),
|
|
24275
|
+
surfaceRates(section.surfaceRates),
|
|
24276
|
+
matrix(section, report.brand.name, sheet),
|
|
24277
|
+
alternatives(section.alternatives),
|
|
24278
|
+
citedDomains(section.citedDomains, sheet),
|
|
24279
|
+
sourceMix(section.sourceMix),
|
|
24280
|
+
perception(section.perception, report.brand.name),
|
|
24281
|
+
]);
|
|
23860
24282
|
}
|
|
23861
|
-
|
|
23862
|
-
|
|
23863
|
-
|
|
23864
|
-
|
|
23865
|
-
|
|
23866
|
-
|
|
23867
|
-
|
|
23868
|
-
|
|
23869
|
-
|
|
23870
|
-
|
|
23871
|
-
|
|
23872
|
-
root.append(el('div', { class: 'grid' },
|
|
23873
|
-
rateStat('Assistant share of voice', summary.prospectShareOfVoice,
|
|
23874
|
-
summary.prospectShareOfVoiceEvidence, 'Mentioned'),
|
|
23875
|
-
rateStat('Assistant citation rate', summary.prospectCitationRate,
|
|
23876
|
-
summary.prospectCitationRateEvidence, 'Cited'),
|
|
23877
|
-
rateStat('Coding-agent share of voice', summary.agentShareOfVoice,
|
|
23878
|
-
summary.agentShareOfVoiceEvidence, 'Mentioned'),
|
|
23879
|
-
rateStat('Coding-agent citation rate', summary.agentCitationRate,
|
|
23880
|
-
summary.agentCitationRateEvidence, 'Cited'),
|
|
23881
|
-
// The scraped consumer apps, only for a run that planned one.
|
|
23882
|
-
...(summary.consumerShareOfVoice === undefined ? [] : [
|
|
23883
|
-
rateStat('Consumer-app share of voice', summary.consumerShareOfVoice,
|
|
23884
|
-
summary.consumerShareOfVoiceEvidence, 'Mentioned'),
|
|
23885
|
-
rateStat('Consumer-app citation rate', summary.consumerCitationRate,
|
|
23886
|
-
summary.consumerCitationRateEvidence, 'Cited'),
|
|
23887
|
-
]),
|
|
23888
|
-
el('div', { class: 'stat' }, el('b', {}, summary.topCompetitorDomain || 'none'), 'Most mentioned competitor'),
|
|
23889
|
-
));
|
|
23890
|
-
root.append(el('p', { class: 'muted' },
|
|
23891
|
-
'Share of voice is how often the measured answers name the product, not market share.'));
|
|
23892
|
-
root.append(...modelTable(summary.byModel, labelOf));
|
|
23893
|
-
const drawer = el('div', { class: 'drawer', hidden: '' });
|
|
23894
|
-
const body = el('tbody');
|
|
23895
|
-
for (const row of matrix) {
|
|
23896
|
-
const prompt = prompts[row.promptIdx] || { text: '' };
|
|
23897
|
-
const promptId = (promptIds.get(section.key) || [])[row.promptIdx];
|
|
23898
|
-
const record = answers.get(answerKey(section.key, promptId, row.surface, row.runIndex || 0));
|
|
23899
|
-
const open = () => {
|
|
23900
|
-
drawer.removeAttribute('hidden');
|
|
23901
|
-
drawer.replaceChildren(
|
|
23902
|
-
el('h3', {}, labelOf(row.surface) + ', run ' + (row.runIndex || 0)),
|
|
23903
|
-
el('p', {}, prompt.text),
|
|
23904
|
-
record ? el('pre', {}, record.probe.text)
|
|
23905
|
-
: el('p', { class: 'limited' }, 'The answer is not in this bundle.'),
|
|
23906
|
-
...(row.citedUrls && row.citedUrls.length
|
|
23907
|
-
? [el('h3', {}, 'Cited sources'), ...row.citedUrls.map((url) => el('div', {}, sourceLink(url)))]
|
|
23908
|
-
: []),
|
|
23909
|
-
);
|
|
23910
|
-
drawer.scrollIntoView({ block: 'nearest' });
|
|
23911
|
-
};
|
|
23912
|
-
body.append(el('tr', { class: 'row', tabindex: '0', onclick: open,
|
|
23913
|
-
onkeydown: (event) => { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); open(); } } },
|
|
23914
|
-
el('td', {}, prompt.text),
|
|
23915
|
-
el('td', {}, labelOf(row.surface)),
|
|
23916
|
-
el('td', {}, String(row.runIndex || 0)),
|
|
23917
|
-
el('td', {}, row.prospectMentioned ? 'mentioned' + (row.prospectPosition ? ' (' + row.prospectPosition + ')' : '') : 'not mentioned'),
|
|
23918
|
-
el('td', {}, (row.qualifiedCompetitors || []).map((entry) => entry.name).join(', ')),
|
|
23919
|
-
));
|
|
23920
|
-
}
|
|
23921
|
-
root.append(el('div', { class: 'table-wrap' }, el('table', {},
|
|
23922
|
-
el('thead', {}, el('tr', {}, el('th', {}, 'Question'), el('th', {}, 'Surface'),
|
|
23923
|
-
el('th', {}, 'Run'), el('th', {}, 'Product'), el('th', {}, 'Alternatives named'))),
|
|
23924
|
-
body)), drawer);
|
|
23925
|
-
}
|
|
23926
|
-
const methodology = snapshot.meta && Array.isArray(snapshot.meta.methodology)
|
|
23927
|
-
? snapshot.meta.methodology.filter((sentence) => typeof sentence === 'string')
|
|
23928
|
-
: [];
|
|
23929
|
-
if (methodology.length) {
|
|
23930
|
-
root.append(el('h2', {}, 'Methodology'),
|
|
23931
|
-
el('ul', { class: 'methodology' },
|
|
23932
|
-
...methodology.map((sentence) => el('li', {}, sentence))));
|
|
23933
|
-
}
|
|
23934
|
-
root.append(el('footer', {},
|
|
23935
|
-
'Generated with Literally.dev AEO, an open-source AI visibility audit tool. ',
|
|
23936
|
-
info.originLabel + '. Literally.dev did not review this result. Engine ' + info.toolVersion + '.'));
|
|
24283
|
+
bands.push([el('div', { class: 'footer' },
|
|
24284
|
+
shown ? el('p', {}, report.footer.baseline) : null,
|
|
24285
|
+
shown && report.footer.methodology.length ? el('section', { 'aria-labelledby': 'methodology' },
|
|
24286
|
+
el('h2', { id: 'methodology' }, 'Methodology'),
|
|
24287
|
+
el('ul', { class: 'methodology' }, report.footer.methodology.map((sentence) => el('li', {}, sentence)))) : null,
|
|
24288
|
+
...(shown ? report.footer.notes : []).map((note) => el('p', {}, note)),
|
|
24289
|
+
el('p', { class: 'footer-note' },
|
|
24290
|
+
'Generated with Literally.dev AEO ' + info.toolVersion + ', an open-source AI visibility audit tool. '
|
|
24291
|
+
+ info.originLabel + '. Literally.dev did not review this result. Bundle: ' + info.source + '.'))]);
|
|
24292
|
+
bands.forEach((content, index) => root.append(band(index % 2 === 1 ? 'soft' : 'plain', ...content)));
|
|
24293
|
+
root.append(...sheet.nodes);
|
|
23937
24294
|
};
|
|
23938
24295
|
|
|
23939
24296
|
render().catch((error) => {
|
|
23940
24297
|
document.getElementById('app').textContent = 'The viewer could not load this bundle: ' + error.message;
|
|
23941
24298
|
});
|
|
23942
24299
|
`;
|
|
23943
|
-
var
|
|
24300
|
+
var viewerFontFiles = {
|
|
24301
|
+
body: "Mulish-VariableFont_wght.ttf",
|
|
24302
|
+
mono: "SourceCodePro-VariableFont_wght.ttf"
|
|
24303
|
+
};
|
|
24304
|
+
var fontFaces = (token) => {
|
|
24305
|
+
const source = (file) => `url("/fonts/${file}?t=${encodeURIComponent(token)}") format("truetype")`;
|
|
24306
|
+
return `
|
|
24307
|
+
@font-face { font-family: Mulish; font-weight: 200 1000; font-display: swap;
|
|
24308
|
+
src: ${source(viewerFontFiles.body)}; }
|
|
24309
|
+
@font-face { font-family: "Source Code Pro"; font-weight: 200 900; font-display: swap;
|
|
24310
|
+
src: ${source(viewerFontFiles.mono)}; }
|
|
24311
|
+
`;
|
|
24312
|
+
};
|
|
24313
|
+
var viewerPage = (nonce, fontToken) => {
|
|
24314
|
+
const faces = fontToken === void 0 ? "" : fontFaces(fontToken);
|
|
23944
24315
|
return `<!doctype html>
|
|
23945
24316
|
<html lang="en">
|
|
23946
24317
|
<head>
|
|
@@ -23948,23 +24319,649 @@ var viewerPage = (nonce) => {
|
|
|
23948
24319
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
23949
24320
|
<meta name="referrer" content="no-referrer">
|
|
23950
24321
|
<title>Literally.dev AEO</title>
|
|
23951
|
-
<style nonce="${nonce}">${styles}</style>
|
|
24322
|
+
<style nonce="${nonce}">${faces}${styles}</style>
|
|
23952
24323
|
</head>
|
|
23953
24324
|
<body>
|
|
23954
|
-
<main id="app"><p class="
|
|
24325
|
+
<main id="app"><p class="container">Loading the audit\u2026</p></main>
|
|
23955
24326
|
<script nonce="${nonce}">${script}</script>
|
|
23956
24327
|
</body>
|
|
23957
24328
|
</html>`;
|
|
23958
24329
|
};
|
|
23959
24330
|
|
|
24331
|
+
// src/viewer/server.ts
|
|
24332
|
+
import { randomBytes as randomBytes2, timingSafeEqual } from "node:crypto";
|
|
24333
|
+
import {
|
|
24334
|
+
createServer as createServer2
|
|
24335
|
+
} from "node:http";
|
|
24336
|
+
import { z as z64 } from "zod";
|
|
24337
|
+
|
|
24338
|
+
// src/viewer/presentation.ts
|
|
24339
|
+
import { z as z63 } from "zod";
|
|
24340
|
+
|
|
24341
|
+
// src/viewer/alternatives.ts
|
|
24342
|
+
var rankAlternatives = (matrix, prospect) => {
|
|
24343
|
+
const isProspect = matchesProspect(prospect);
|
|
24344
|
+
const ranked = [...foldNameOnlySightings(collectSightings(matrix)).values()].filter((sighting) => !isProspect(sighting)).map((sighting) => ({
|
|
24345
|
+
name: displayName(sighting),
|
|
24346
|
+
...sighting.domain !== void 0 && { domain: sighting.domain },
|
|
24347
|
+
mentioning: sighting.rowIndices.size,
|
|
24348
|
+
captured: matrix.length
|
|
24349
|
+
})).sort(
|
|
24350
|
+
(a, b) => b.mentioning - a.mentioning || a.name.localeCompare(b.name)
|
|
24351
|
+
);
|
|
24352
|
+
return ranked;
|
|
24353
|
+
};
|
|
24354
|
+
var collectSightings = (matrix) => {
|
|
24355
|
+
const sightings = /* @__PURE__ */ new Map();
|
|
24356
|
+
matrix.forEach((row, rowIndex) => {
|
|
24357
|
+
for (const brand of qualifiedCompetitorsForRow(row)) {
|
|
24358
|
+
const name = brand.name.trim();
|
|
24359
|
+
const domain = brand.domain ? normalizeDomain(brand.domain) : void 0;
|
|
24360
|
+
const key2 = domain ?? name.toLowerCase();
|
|
24361
|
+
const sighting = sightings.get(key2) ?? {
|
|
24362
|
+
key: key2,
|
|
24363
|
+
names: /* @__PURE__ */ new Map(),
|
|
24364
|
+
rowIndices: /* @__PURE__ */ new Set()
|
|
24365
|
+
};
|
|
24366
|
+
const nameRows = sighting.names.get(name) ?? /* @__PURE__ */ new Set();
|
|
24367
|
+
sighting.domain ??= domain;
|
|
24368
|
+
nameRows.add(rowIndex);
|
|
24369
|
+
sighting.names.set(name, nameRows);
|
|
24370
|
+
sighting.rowIndices.add(rowIndex);
|
|
24371
|
+
sightings.set(key2, sighting);
|
|
24372
|
+
}
|
|
24373
|
+
});
|
|
24374
|
+
return sightings;
|
|
24375
|
+
};
|
|
24376
|
+
var foldNameOnlySightings = (sightings) => {
|
|
24377
|
+
const domainKeysByName = /* @__PURE__ */ new Map();
|
|
24378
|
+
for (const sighting of sightings.values()) {
|
|
24379
|
+
if (sighting.domain === void 0) {
|
|
24380
|
+
continue;
|
|
24381
|
+
}
|
|
24382
|
+
for (const name of sighting.names.keys()) {
|
|
24383
|
+
const lowered = name.toLowerCase();
|
|
24384
|
+
const keys = domainKeysByName.get(lowered) ?? /* @__PURE__ */ new Set();
|
|
24385
|
+
keys.add(sighting.key);
|
|
24386
|
+
domainKeysByName.set(lowered, keys);
|
|
24387
|
+
}
|
|
24388
|
+
}
|
|
24389
|
+
const folded = new Map(sightings);
|
|
24390
|
+
for (const sighting of sightings.values()) {
|
|
24391
|
+
if (sighting.domain !== void 0) {
|
|
24392
|
+
continue;
|
|
24393
|
+
}
|
|
24394
|
+
const [ownerKey, ...otherKeys] = [
|
|
24395
|
+
...domainKeysByName.get(sighting.key) ?? []
|
|
24396
|
+
];
|
|
24397
|
+
const owner = ownerKey === void 0 ? void 0 : folded.get(ownerKey);
|
|
24398
|
+
if (!owner || otherKeys.length > 0) {
|
|
24399
|
+
continue;
|
|
24400
|
+
}
|
|
24401
|
+
folded.set(owner.key, mergeSightings(owner, sighting));
|
|
24402
|
+
folded.delete(sighting.key);
|
|
24403
|
+
}
|
|
24404
|
+
return folded;
|
|
24405
|
+
};
|
|
24406
|
+
var mergeSightings = (owner, nameOnly) => {
|
|
24407
|
+
const names = new Map(
|
|
24408
|
+
[...owner.names].map(([name, rows]) => [name, new Set(rows)])
|
|
24409
|
+
);
|
|
24410
|
+
for (const [name, rows] of nameOnly.names) {
|
|
24411
|
+
names.set(name, /* @__PURE__ */ new Set([...names.get(name) ?? [], ...rows]));
|
|
24412
|
+
}
|
|
24413
|
+
const merged = {
|
|
24414
|
+
...owner,
|
|
24415
|
+
names,
|
|
24416
|
+
rowIndices: /* @__PURE__ */ new Set([...owner.rowIndices, ...nameOnly.rowIndices])
|
|
24417
|
+
};
|
|
24418
|
+
return merged;
|
|
24419
|
+
};
|
|
24420
|
+
var displayName = (sighting) => {
|
|
24421
|
+
const spellings = [...sighting.names].map(([name, rows]) => ({
|
|
24422
|
+
name,
|
|
24423
|
+
words: name.toLowerCase().split(/\s+/),
|
|
24424
|
+
answers: rows.size
|
|
24425
|
+
}));
|
|
24426
|
+
const [base] = [...spellings].sort(
|
|
24427
|
+
(a, b) => a.words.length - b.words.length || b.answers - a.answers || a.name.localeCompare(b.name)
|
|
24428
|
+
);
|
|
24429
|
+
if (!base) {
|
|
24430
|
+
throw new Error(`Alternative has no recorded name: ${sighting.key}.`);
|
|
24431
|
+
}
|
|
24432
|
+
const isSharedBase = spellings.every(
|
|
24433
|
+
(spelling) => base.words.every((word, index) => spelling.words[index] === word)
|
|
24434
|
+
);
|
|
24435
|
+
if (!isSharedBase && sighting.domain !== void 0) {
|
|
24436
|
+
return sighting.domain;
|
|
24437
|
+
}
|
|
24438
|
+
const [label] = spellings.filter((spelling) => spelling.words.length === base.words.length).sort((a, b) => b.answers - a.answers || a.name.localeCompare(b.name));
|
|
24439
|
+
return (label ?? base).name;
|
|
24440
|
+
};
|
|
24441
|
+
var matchesProspect = (prospect) => {
|
|
24442
|
+
const prospectName = prospect.name.trim().toLowerCase();
|
|
24443
|
+
const prospectDomain = normalizeDomain(prospect.domain);
|
|
24444
|
+
return (sighting) => {
|
|
24445
|
+
const identity2 = sighting.domain ?? sighting.key;
|
|
24446
|
+
const isProspectDomain = identity2 === prospectDomain || identity2.endsWith(`.${prospectDomain}`);
|
|
24447
|
+
const isProspectName = [...sighting.names.keys()].some(
|
|
24448
|
+
(name) => name.toLowerCase() === prospectName
|
|
24449
|
+
);
|
|
24450
|
+
return isProspectDomain || isProspectName;
|
|
24451
|
+
};
|
|
24452
|
+
};
|
|
24453
|
+
|
|
24454
|
+
// src/viewer/cited-domains.ts
|
|
24455
|
+
var groupCitedDomains = (visibility, brandDomain) => {
|
|
24456
|
+
const brand = normalizeDomain(brandDomain);
|
|
24457
|
+
const urlsByDomain = /* @__PURE__ */ new Map();
|
|
24458
|
+
const brandHostCounts = /* @__PURE__ */ new Map();
|
|
24459
|
+
for (const row of visibility.matrix) {
|
|
24460
|
+
for (const url of row.citedUrls ?? []) {
|
|
24461
|
+
const host = isGroundingRedirectUrl(url) ? void 0 : hostOf(url);
|
|
24462
|
+
if (host === void 0) {
|
|
24463
|
+
continue;
|
|
24464
|
+
}
|
|
24465
|
+
const isBrandHost = host === brand || host.endsWith(`.${brand}`);
|
|
24466
|
+
const domain = isBrandHost ? brand : apexOf(host);
|
|
24467
|
+
const urls = urlsByDomain.get(domain) ?? /* @__PURE__ */ new Map();
|
|
24468
|
+
const cited = urls.get(url) ?? {
|
|
24469
|
+
url,
|
|
24470
|
+
count: 0,
|
|
24471
|
+
surfaces: [],
|
|
24472
|
+
prompts: []
|
|
24473
|
+
};
|
|
24474
|
+
const promptText = visibility.prompts[row.promptIdx]?.text;
|
|
24475
|
+
cited.count += 1;
|
|
24476
|
+
if (!cited.surfaces.includes(row.surface)) {
|
|
24477
|
+
cited.surfaces.push(row.surface);
|
|
24478
|
+
}
|
|
24479
|
+
if (promptText !== void 0 && !cited.prompts.includes(promptText)) {
|
|
24480
|
+
cited.prompts.push(promptText);
|
|
24481
|
+
}
|
|
24482
|
+
urls.set(url, cited);
|
|
24483
|
+
urlsByDomain.set(domain, urls);
|
|
24484
|
+
if (isBrandHost) {
|
|
24485
|
+
const label = brandHostLabel(host, brand);
|
|
24486
|
+
brandHostCounts.set(label, (brandHostCounts.get(label) ?? 0) + 1);
|
|
24487
|
+
}
|
|
24488
|
+
}
|
|
24489
|
+
}
|
|
24490
|
+
const domainOf = (domain) => {
|
|
24491
|
+
const urls = [...urlsByDomain.get(domain)?.values() ?? []].sort(
|
|
24492
|
+
(a, b) => b.count - a.count || a.url.localeCompare(b.url)
|
|
24493
|
+
);
|
|
24494
|
+
const cited = {
|
|
24495
|
+
domain,
|
|
24496
|
+
count: urls.reduce((sum, url) => sum + url.count, 0),
|
|
24497
|
+
isBrand: domain === brand,
|
|
24498
|
+
urls
|
|
24499
|
+
};
|
|
24500
|
+
return cited;
|
|
24501
|
+
};
|
|
24502
|
+
const brandRow = {
|
|
24503
|
+
...domainOf(brand),
|
|
24504
|
+
...brandHostCounts.size > 0 && {
|
|
24505
|
+
hosts: [...brandHostCounts].map(([label, count]) => ({ label, count })).sort((a, b) => b.count - a.count)
|
|
24506
|
+
}
|
|
24507
|
+
};
|
|
24508
|
+
const others = [...urlsByDomain.keys()].filter((domain) => domain !== brand).map(domainOf).sort((a, b) => b.count - a.count || a.domain.localeCompare(b.domain));
|
|
24509
|
+
const domains = [brandRow, ...others];
|
|
24510
|
+
return domains;
|
|
24511
|
+
};
|
|
24512
|
+
var hostOf = (url) => {
|
|
24513
|
+
try {
|
|
24514
|
+
return normalizeDomain(new URL(url).hostname);
|
|
24515
|
+
} catch {
|
|
24516
|
+
return void 0;
|
|
24517
|
+
}
|
|
24518
|
+
};
|
|
24519
|
+
var apexOf = (host) => {
|
|
24520
|
+
const labels = host.split(".");
|
|
24521
|
+
return labels.length <= 2 ? host : labels.slice(-2).join(".");
|
|
24522
|
+
};
|
|
24523
|
+
var brandHostLabel = (host, brand) => {
|
|
24524
|
+
return host === brand ? "site" : host.slice(0, -(brand.length + 1));
|
|
24525
|
+
};
|
|
24526
|
+
|
|
24527
|
+
// src/viewer/presentation.ts
|
|
24528
|
+
var viewedSnapshotSchema = z63.object({
|
|
24529
|
+
brand: brandSchema.optional(),
|
|
24530
|
+
sections: aeoSnapshotSchema.shape.sections,
|
|
24531
|
+
sourceMix: aeoSourceMixSchema.optional(),
|
|
24532
|
+
perception: aeoPerceptionSchema.optional(),
|
|
24533
|
+
meta: aeoSnapshotSchema.shape.meta.pick({
|
|
24534
|
+
generatedAt: true,
|
|
24535
|
+
promptCount: true,
|
|
24536
|
+
probeCount: true,
|
|
24537
|
+
partialFailures: true,
|
|
24538
|
+
surfaceLabels: true,
|
|
24539
|
+
methodology: true,
|
|
24540
|
+
reusedProbes: true
|
|
24541
|
+
}).partial({ promptCount: true, probeCount: true, partialFailures: true })
|
|
24542
|
+
});
|
|
24543
|
+
var configBrandSchema = z63.object({
|
|
24544
|
+
brand: z63.object({ name: z63.string().min(1), domain: z63.string().min(1) })
|
|
24545
|
+
});
|
|
24546
|
+
var presentReport = (files) => {
|
|
24547
|
+
const snapshotFile = files.get(bundlePaths.snapshot);
|
|
24548
|
+
if (snapshotFile === void 0) {
|
|
24549
|
+
return { outcome: "missing" };
|
|
24550
|
+
}
|
|
24551
|
+
const snapshot = parseDocument(snapshotFile, viewedSnapshotSchema);
|
|
24552
|
+
if (snapshot === void 0) {
|
|
24553
|
+
return {
|
|
24554
|
+
outcome: "unreadable",
|
|
24555
|
+
reason: `${bundlePaths.snapshot} does not match the report contract of this release.`
|
|
24556
|
+
};
|
|
24557
|
+
}
|
|
24558
|
+
const brand = snapshot.brand ?? parseDocument(files.get(bundlePaths.config), configBrandSchema)?.brand;
|
|
24559
|
+
if (brand === void 0) {
|
|
24560
|
+
return {
|
|
24561
|
+
outcome: "unreadable",
|
|
24562
|
+
reason: `Neither ${bundlePaths.snapshot} nor ${bundlePaths.config} names the audited brand.`
|
|
24563
|
+
};
|
|
24564
|
+
}
|
|
24565
|
+
const copy = parseDocument(
|
|
24566
|
+
files.get(bundlePaths.copy),
|
|
24567
|
+
aeoFinalCopyDraftSchema
|
|
24568
|
+
);
|
|
24569
|
+
const captured = parseDocument(
|
|
24570
|
+
files.get(bundlePaths.captures),
|
|
24571
|
+
capturedRecordsSchema
|
|
24572
|
+
);
|
|
24573
|
+
const answers = new Map(
|
|
24574
|
+
(captured ?? []).map((record) => [answerKey(record), record.probe.text])
|
|
24575
|
+
);
|
|
24576
|
+
const { meta } = snapshot;
|
|
24577
|
+
const measuredOn = measurementPeriod(meta);
|
|
24578
|
+
const labelOf = surfaceLabelFor(meta.surfaceLabels ?? {});
|
|
24579
|
+
const visibilities = snapshot.sections.map((s) => s.visibility);
|
|
24580
|
+
const surfaces = [...new Set(visibilities.flatMap((v) => v.surfaces))];
|
|
24581
|
+
const promptCount = meta.promptCount ?? visibilities.reduce((sum, v) => sum + v.prompts.length, 0);
|
|
24582
|
+
const probeCount = meta.probeCount ?? visibilities.reduce((sum, v) => sum + v.matrix.length, 0);
|
|
24583
|
+
const presentation = {
|
|
24584
|
+
outcome: "shown",
|
|
24585
|
+
brand: { name: brand.name, domain: brand.domain },
|
|
24586
|
+
hero: {
|
|
24587
|
+
title: copy?.hero.title.text ?? `How AI engines see ${brand.name}`,
|
|
24588
|
+
subtitle: copy?.hero.subtitle.text ?? defaultSubtitle(brand.name, surfaces, labelOf),
|
|
24589
|
+
measuredOn,
|
|
24590
|
+
probeCount,
|
|
24591
|
+
facts: [
|
|
24592
|
+
`${promptCount} buyer-style prompts`,
|
|
24593
|
+
`${surfaces.length} AI surfaces${surfaces.some(isAgentSurface) ? ", coding agents included" : ""}`,
|
|
24594
|
+
// Only when the bundle holds them: a redaction can withhold them all.
|
|
24595
|
+
...answers.size > 0 ? ["Raw answers preserved and inspectable"] : []
|
|
24596
|
+
]
|
|
24597
|
+
},
|
|
24598
|
+
...copy?.intro[0] !== void 0 && {
|
|
24599
|
+
intro: {
|
|
24600
|
+
heading: `How AI engines see ${brand.name}`,
|
|
24601
|
+
lead: copy.intro[0].text
|
|
24602
|
+
}
|
|
24603
|
+
},
|
|
24604
|
+
sections: snapshot.sections.map(
|
|
24605
|
+
(section) => presentSection(section, {
|
|
24606
|
+
brand,
|
|
24607
|
+
sourceMix: snapshot.sourceMix?.sections.find(
|
|
24608
|
+
(s) => s.key === section.key
|
|
24609
|
+
),
|
|
24610
|
+
perception: snapshot.perception?.sections.find(
|
|
24611
|
+
(s) => s.key === section.key
|
|
24612
|
+
),
|
|
24613
|
+
labelOf,
|
|
24614
|
+
answers
|
|
24615
|
+
})
|
|
24616
|
+
),
|
|
24617
|
+
footer: {
|
|
24618
|
+
baseline: `Measured ${measuredOn}: ${promptCount} prompts, ${probeCount} captured answers across ${listOf(surfaces.map(labelOf))}.`,
|
|
24619
|
+
methodology: meta.methodology ?? [],
|
|
24620
|
+
notes: [
|
|
24621
|
+
...reusedNote(meta.reusedProbes),
|
|
24622
|
+
...unanalyzedNote(meta.partialFailures ?? [])
|
|
24623
|
+
]
|
|
24624
|
+
}
|
|
24625
|
+
};
|
|
24626
|
+
return presentation;
|
|
24627
|
+
};
|
|
24628
|
+
var presentSection = ({ key: key2, visibility }, { brand, sourceMix, perception, labelOf, answers }) => {
|
|
24629
|
+
const alternatives = rankAlternatives(visibility.matrix, brand);
|
|
24630
|
+
const assistantSurfaces = visibility.surfaces.filter(
|
|
24631
|
+
(s) => !isAgentSurface(s)
|
|
24632
|
+
);
|
|
24633
|
+
const agentSurfaces2 = visibility.surfaces.filter(isAgentSurface);
|
|
24634
|
+
const runViewOf = (row, index) => {
|
|
24635
|
+
const answer = row.runIndex === void 0 ? void 0 : answers.get(
|
|
24636
|
+
answerKey({
|
|
24637
|
+
sectionKey: key2,
|
|
24638
|
+
promptText: visibility.prompts[row.promptIdx]?.text ?? "",
|
|
24639
|
+
surface: row.surface,
|
|
24640
|
+
runIndex: row.runIndex
|
|
24641
|
+
})
|
|
24642
|
+
);
|
|
24643
|
+
return presentRun(row, {
|
|
24644
|
+
runNumber: row.runIndex ?? index + 1,
|
|
24645
|
+
label: labelOf(row.surface),
|
|
24646
|
+
answer
|
|
24647
|
+
});
|
|
24648
|
+
};
|
|
24649
|
+
const section = {
|
|
24650
|
+
key: key2,
|
|
24651
|
+
title: reportSectionTitle(key2.replace(/_/g, " ")),
|
|
24652
|
+
scorecards: presentScorecards(visibility, alternatives[0], labelOf),
|
|
24653
|
+
surfaceRates: visibility.surfaces.flatMap((surface) => {
|
|
24654
|
+
const rates = visibility.summary.byModel[surface];
|
|
24655
|
+
const name = labelOf(surface);
|
|
24656
|
+
return rates?.shareOfVoiceEvidence === void 0 ? [] : [
|
|
24657
|
+
{
|
|
24658
|
+
surface: name,
|
|
24659
|
+
shareOfVoice: rateOf(
|
|
24660
|
+
rates.shareOfVoice,
|
|
24661
|
+
rates.shareOfVoiceEvidence,
|
|
24662
|
+
{ subject: `${name} share of voice`, counted: "Mentioned" }
|
|
24663
|
+
),
|
|
24664
|
+
citationRate: rateOf(
|
|
24665
|
+
rates.citationRate,
|
|
24666
|
+
rates.citationRateEvidence,
|
|
24667
|
+
{ subject: `${name} citation rate`, counted: "Cited" }
|
|
24668
|
+
)
|
|
24669
|
+
}
|
|
24670
|
+
];
|
|
24671
|
+
}),
|
|
24672
|
+
matrix: {
|
|
24673
|
+
assistantSurfaces: assistantSurfaces.map(labelOf),
|
|
24674
|
+
agentSurfaces: agentSurfaces2.map(labelOf),
|
|
24675
|
+
rows: visibility.prompts.map((prompt, promptIdx) => ({
|
|
24676
|
+
prompt: prompt.text,
|
|
24677
|
+
category: prompt.category.replace(/_/g, " "),
|
|
24678
|
+
cells: [...assistantSurfaces, ...agentSurfaces2].map(
|
|
24679
|
+
(surface) => presentCell(
|
|
24680
|
+
visibility.matrix.filter(
|
|
24681
|
+
(row) => row.promptIdx === promptIdx && row.surface === surface
|
|
24682
|
+
).map(runViewOf)
|
|
24683
|
+
)
|
|
24684
|
+
)
|
|
24685
|
+
}))
|
|
24686
|
+
},
|
|
24687
|
+
alternatives: alternatives.slice(0, 10).map((alternative) => {
|
|
24688
|
+
const share = alternative.mentioning / alternative.captured;
|
|
24689
|
+
return { ...alternative, share, percent: percentOf(share) };
|
|
24690
|
+
}),
|
|
24691
|
+
citedDomains: groupCitedDomains(visibility, brand.domain).map((domain) => ({
|
|
24692
|
+
...domain,
|
|
24693
|
+
urls: domain.urls.map((url) => ({
|
|
24694
|
+
...url,
|
|
24695
|
+
surfaces: url.surfaces.map(labelOf)
|
|
24696
|
+
}))
|
|
24697
|
+
})),
|
|
24698
|
+
...sourceMix !== void 0 && {
|
|
24699
|
+
sourceMix: {
|
|
24700
|
+
rows: sourceMix.perSurface.filter(
|
|
24701
|
+
({ counts }) => sourceCategories.some((category) => counts[category] > 0)
|
|
24702
|
+
).map(({ surface, counts }) => ({
|
|
24703
|
+
surface: labelOf(surface),
|
|
24704
|
+
counts
|
|
24705
|
+
})),
|
|
24706
|
+
total: sourceMix.total
|
|
24707
|
+
}
|
|
24708
|
+
},
|
|
24709
|
+
...perception !== void 0 && {
|
|
24710
|
+
perception: {
|
|
24711
|
+
...perception.sentiment,
|
|
24712
|
+
phrases: groupPhrases(perception.narratives, labelOf)
|
|
24713
|
+
}
|
|
24714
|
+
}
|
|
24715
|
+
};
|
|
24716
|
+
return section;
|
|
24717
|
+
};
|
|
24718
|
+
var presentScorecards = (visibility, topAlternative, labelOf) => {
|
|
24719
|
+
const { summary } = visibility;
|
|
24720
|
+
const namesOf = (family) => listOf(
|
|
24721
|
+
visibility.surfaces.filter((s) => surfaceFamilyOf(s) === family).map(labelOf)
|
|
24722
|
+
);
|
|
24723
|
+
const familyCard = (family, scope, rates) => {
|
|
24724
|
+
if (rates.shareOfVoice === null || rates.shareOfVoice === void 0) {
|
|
24725
|
+
return [];
|
|
24726
|
+
}
|
|
24727
|
+
const headline = rateOf(rates.shareOfVoice, rates.shareOfVoiceEvidence, {
|
|
24728
|
+
subject: `share of voice across ${scope}`,
|
|
24729
|
+
counted: "Mentioned"
|
|
24730
|
+
});
|
|
24731
|
+
const detail = rateOf(rates.citationRate ?? 0, rates.citationRateEvidence, {
|
|
24732
|
+
subject: `citation rate across ${scope}`,
|
|
24733
|
+
counted: "Cited"
|
|
24734
|
+
});
|
|
24735
|
+
const card = {
|
|
24736
|
+
headline: headline.percent,
|
|
24737
|
+
...headline.interval !== void 0 && {
|
|
24738
|
+
headlineInterval: headline.interval
|
|
24739
|
+
},
|
|
24740
|
+
label: `Share of voice \u2014 ${scope}`,
|
|
24741
|
+
detail: `${detail.percent} citation rate across ${namesOf(family)}`,
|
|
24742
|
+
...detail.interval !== void 0 && { detailInterval: detail.interval }
|
|
24743
|
+
};
|
|
24744
|
+
return [card];
|
|
24745
|
+
};
|
|
24746
|
+
const cellMentions = /* @__PURE__ */ new Map();
|
|
24747
|
+
for (const row of visibility.matrix) {
|
|
24748
|
+
const cell = `${row.promptIdx}:${row.surface}`;
|
|
24749
|
+
cellMentions.set(
|
|
24750
|
+
cell,
|
|
24751
|
+
(cellMentions.get(cell) ?? false) || row.prospectMentioned
|
|
24752
|
+
);
|
|
24753
|
+
}
|
|
24754
|
+
const absentCells = [...cellMentions.values()].filter(
|
|
24755
|
+
(mentioned) => !mentioned
|
|
24756
|
+
).length;
|
|
24757
|
+
const scorecards = [
|
|
24758
|
+
...familyCard("chat", "AI assistants", {
|
|
24759
|
+
shareOfVoice: summary.prospectShareOfVoice,
|
|
24760
|
+
citationRate: summary.prospectCitationRate,
|
|
24761
|
+
shareOfVoiceEvidence: summary.prospectShareOfVoiceEvidence,
|
|
24762
|
+
citationRateEvidence: summary.prospectCitationRateEvidence
|
|
24763
|
+
}),
|
|
24764
|
+
...familyCard("consumer", "consumer apps", {
|
|
24765
|
+
shareOfVoice: summary.consumerShareOfVoice,
|
|
24766
|
+
citationRate: summary.consumerCitationRate,
|
|
24767
|
+
shareOfVoiceEvidence: summary.consumerShareOfVoiceEvidence,
|
|
24768
|
+
citationRateEvidence: summary.consumerCitationRateEvidence
|
|
24769
|
+
}),
|
|
24770
|
+
...familyCard("agents", "coding agents", {
|
|
24771
|
+
shareOfVoice: summary.agentShareOfVoice,
|
|
24772
|
+
citationRate: summary.agentCitationRate,
|
|
24773
|
+
shareOfVoiceEvidence: summary.agentShareOfVoiceEvidence,
|
|
24774
|
+
citationRateEvidence: summary.agentCitationRateEvidence
|
|
24775
|
+
}),
|
|
24776
|
+
...topAlternative === void 0 ? [] : [
|
|
24777
|
+
{
|
|
24778
|
+
headline: percentOf(
|
|
24779
|
+
topAlternative.mentioning / topAlternative.captured
|
|
24780
|
+
),
|
|
24781
|
+
label: `${topAlternative.name} share of voice`,
|
|
24782
|
+
detail: `Named most often: ${topAlternative.mentioning} of ${topAlternative.captured} captured answers`
|
|
24783
|
+
}
|
|
24784
|
+
],
|
|
24785
|
+
{
|
|
24786
|
+
headline: `${absentCells}/${cellMentions.size}`,
|
|
24787
|
+
label: "Cells with zero mentions",
|
|
24788
|
+
detail: "Prompts and surfaces where the brand was absent"
|
|
24789
|
+
}
|
|
24790
|
+
];
|
|
24791
|
+
return scorecards;
|
|
24792
|
+
};
|
|
24793
|
+
var presentRun = (row, {
|
|
24794
|
+
runNumber,
|
|
24795
|
+
label,
|
|
24796
|
+
answer
|
|
24797
|
+
}) => {
|
|
24798
|
+
const mentionedBrands = [
|
|
24799
|
+
...new Set(
|
|
24800
|
+
(row.mentionedBrands ?? []).map((brand) => brand.domain ?? brand.name)
|
|
24801
|
+
)
|
|
24802
|
+
];
|
|
24803
|
+
const run = {
|
|
24804
|
+
runNumber,
|
|
24805
|
+
surface: label,
|
|
24806
|
+
...row.agentCliVersion !== void 0 && {
|
|
24807
|
+
cliVersion: row.agentCliVersion
|
|
24808
|
+
},
|
|
24809
|
+
status: statusOf(row),
|
|
24810
|
+
...row.usedWebSearch !== void 0 && {
|
|
24811
|
+
retrieval: retrievalOf(row.usedWebSearch)
|
|
24812
|
+
},
|
|
24813
|
+
...row.contextSnippet !== null && { snippet: row.contextSnippet },
|
|
24814
|
+
...answer !== void 0 && { answer },
|
|
24815
|
+
mentionedBrands,
|
|
24816
|
+
citedUrls: row.citedUrls ?? []
|
|
24817
|
+
};
|
|
24818
|
+
return run;
|
|
24819
|
+
};
|
|
24820
|
+
var retrievalOf = (usedWebSearch) => {
|
|
24821
|
+
if (usedWebSearch === null) {
|
|
24822
|
+
return "unknown";
|
|
24823
|
+
}
|
|
24824
|
+
return usedWebSearch ? "searched" : "memory";
|
|
24825
|
+
};
|
|
24826
|
+
var statusOf = (row) => {
|
|
24827
|
+
if (row.noOverview) {
|
|
24828
|
+
return "no_overview";
|
|
24829
|
+
}
|
|
24830
|
+
if (!row.prospectMentioned) {
|
|
24831
|
+
return "absent";
|
|
24832
|
+
}
|
|
24833
|
+
return row.prospectPosition === "primary" ? "primary" : "mentioned";
|
|
24834
|
+
};
|
|
24835
|
+
var presentCell = (runs) => {
|
|
24836
|
+
const mentioned = runs.filter(
|
|
24837
|
+
(run) => run.status === "primary" || run.status === "mentioned"
|
|
24838
|
+
).length;
|
|
24839
|
+
if (runs.length === 0) {
|
|
24840
|
+
return { status: "no_data", mentioned, runs };
|
|
24841
|
+
}
|
|
24842
|
+
if (mentioned === 0) {
|
|
24843
|
+
return { status: "absent", mentioned, runs };
|
|
24844
|
+
}
|
|
24845
|
+
const status = runs.some((run) => run.status === "primary") ? "primary" : "mentioned";
|
|
24846
|
+
return { status, mentioned, runs };
|
|
24847
|
+
};
|
|
24848
|
+
var rateOf = (rate, evidence, {
|
|
24849
|
+
subject,
|
|
24850
|
+
counted
|
|
24851
|
+
}) => {
|
|
24852
|
+
const percent = percentOf(rate);
|
|
24853
|
+
if (evidence === void 0 || evidence.low > evidence.high) {
|
|
24854
|
+
return { percent };
|
|
24855
|
+
}
|
|
24856
|
+
const { low, high } = intervalPercents(evidence);
|
|
24857
|
+
const text = `approx. 95% interval ${low}\u2013${high}%`;
|
|
24858
|
+
const view = {
|
|
24859
|
+
percent,
|
|
24860
|
+
interval: {
|
|
24861
|
+
text,
|
|
24862
|
+
label: `${text} for ${subject}`,
|
|
24863
|
+
counts: `${counted} in ${evidence.count} of ${evidence.planned} planned answers; ${evidence.captured} captured`
|
|
24864
|
+
}
|
|
24865
|
+
};
|
|
24866
|
+
return view;
|
|
24867
|
+
};
|
|
24868
|
+
var groupPhrases = (narratives, labelOf) => {
|
|
24869
|
+
const byPhrase = /* @__PURE__ */ new Map();
|
|
24870
|
+
for (const narrative of narratives) {
|
|
24871
|
+
const text = narrative.phrase.trim();
|
|
24872
|
+
const key2 = text.toLowerCase();
|
|
24873
|
+
if (key2 === "") {
|
|
24874
|
+
continue;
|
|
24875
|
+
}
|
|
24876
|
+
const entry = byPhrase.get(key2) ?? { text, count: 0, surfaces: [] };
|
|
24877
|
+
const surface = labelOf(narrative.surface);
|
|
24878
|
+
entry.count += 1;
|
|
24879
|
+
if (!entry.surfaces.includes(surface)) {
|
|
24880
|
+
entry.surfaces.push(surface);
|
|
24881
|
+
}
|
|
24882
|
+
byPhrase.set(key2, entry);
|
|
24883
|
+
}
|
|
24884
|
+
const phrases = [...byPhrase.values()].sort((a, b) => b.count - a.count).slice(0, 20);
|
|
24885
|
+
return phrases;
|
|
24886
|
+
};
|
|
24887
|
+
var surfaceLabelFor = (runLabels) => (surface) => {
|
|
24888
|
+
return runLabels[surface] ?? surfaceLabels[surface]?.replace(/ \(API\)$/, "") ?? surface;
|
|
24889
|
+
};
|
|
24890
|
+
var defaultSubtitle = (brandName, surfaces, labelOf) => {
|
|
24891
|
+
const assistants = surfaces.filter((s) => !isAgentSurface(s)).map(labelOf);
|
|
24892
|
+
const agents = surfaces.filter(isAgentSurface).map(labelOf);
|
|
24893
|
+
const asked = assistants.length > 0 ? `How often ${listOf(assistants)} mention and cite ${brandName}.` : `How often AI answers mention and cite ${brandName}.`;
|
|
24894
|
+
const subtitle = agents.length > 0 ? `${asked} Plus ${agents.length === 1 ? "one coding agent" : `${agents.length} coding agents`}: ${listOf(agents)}.` : asked;
|
|
24895
|
+
return subtitle;
|
|
24896
|
+
};
|
|
24897
|
+
var measurementPeriod = ({
|
|
24898
|
+
generatedAt,
|
|
24899
|
+
reusedProbes
|
|
24900
|
+
}) => {
|
|
24901
|
+
const generated = formatReportDate(generatedAt);
|
|
24902
|
+
if (reusedProbes === void 0) {
|
|
24903
|
+
return generated;
|
|
24904
|
+
}
|
|
24905
|
+
return reusedProbes.oldestCapturedAt === null ? `by ${generated}` : `${formatReportDate(reusedProbes.oldestCapturedAt)} to ${generated}`;
|
|
24906
|
+
};
|
|
24907
|
+
var reusedNote = (reusedProbes) => {
|
|
24908
|
+
if (reusedProbes === void 0) {
|
|
24909
|
+
return [];
|
|
24910
|
+
}
|
|
24911
|
+
const { count } = reusedProbes;
|
|
24912
|
+
return [
|
|
24913
|
+
`${count} answer${count === 1 ? " was" : "s were"} reused from an earlier capture, not asked again by this run.`
|
|
24914
|
+
];
|
|
24915
|
+
};
|
|
24916
|
+
var unanalyzedNote = (partialFailures) => {
|
|
24917
|
+
const count = partialFailures.filter(
|
|
24918
|
+
(f) => f.step.startsWith("analysis:search:")
|
|
24919
|
+
).length;
|
|
24920
|
+
if (count === 0) {
|
|
24921
|
+
return [];
|
|
24922
|
+
}
|
|
24923
|
+
return [
|
|
24924
|
+
`${count} prompt${count === 1 ? "" : "s"} could not be analyzed in this run and show${count === 1 ? "s" : ""} as no data.`
|
|
24925
|
+
];
|
|
24926
|
+
};
|
|
24927
|
+
var answerKey = ({
|
|
24928
|
+
sectionKey,
|
|
24929
|
+
promptText,
|
|
24930
|
+
surface,
|
|
24931
|
+
runIndex
|
|
24932
|
+
}) => {
|
|
24933
|
+
return JSON.stringify([sectionKey, promptText, surface, runIndex]);
|
|
24934
|
+
};
|
|
24935
|
+
var percentOf = (share) => {
|
|
24936
|
+
return `${(share * 100).toFixed(0)}%`;
|
|
24937
|
+
};
|
|
24938
|
+
var listOf = (names) => {
|
|
24939
|
+
const unique = [...new Set(names)];
|
|
24940
|
+
if (unique.length <= 1) {
|
|
24941
|
+
return unique[0] ?? "the measured surfaces";
|
|
24942
|
+
}
|
|
24943
|
+
return `${unique.slice(0, -1).join(", ")} and ${unique.at(-1) ?? ""}`;
|
|
24944
|
+
};
|
|
24945
|
+
var parseDocument = (file, schema) => {
|
|
24946
|
+
if (file === void 0) {
|
|
24947
|
+
return void 0;
|
|
24948
|
+
}
|
|
24949
|
+
try {
|
|
24950
|
+
const parsed = schema.safeParse(parseBundleJson(file.toString("utf8")));
|
|
24951
|
+
return parsed.success ? parsed.data : void 0;
|
|
24952
|
+
} catch {
|
|
24953
|
+
return void 0;
|
|
24954
|
+
}
|
|
24955
|
+
};
|
|
24956
|
+
|
|
23960
24957
|
// src/viewer/server.ts
|
|
23961
24958
|
var originLabels = {
|
|
23962
24959
|
[RunOrigin.LOCAL]: "Run locally by the report owner",
|
|
23963
24960
|
[RunOrigin.HOSTED]: "Run by Literally.dev",
|
|
23964
24961
|
[RunOrigin.LEGACY_IMPORT]: "Imported from a run without an execution trace"
|
|
23965
24962
|
};
|
|
23966
|
-
var manifestOriginSchema =
|
|
23967
|
-
run:
|
|
24963
|
+
var manifestOriginSchema = z64.looseObject({
|
|
24964
|
+
run: z64.looseObject({ origin: z64.string() })
|
|
23968
24965
|
});
|
|
23969
24966
|
var sameToken = (expected, received) => {
|
|
23970
24967
|
if (received === null) {
|
|
@@ -24011,10 +25008,11 @@ var derivedDocuments = (bundle) => {
|
|
|
24011
25008
|
originLabel: origin === void 0 ? "Run locally by the report owner" : originLabels[origin] ?? "Origin unknown"
|
|
24012
25009
|
}
|
|
24013
25010
|
],
|
|
24014
|
-
["__verification", bundle.workingState ? null : verification]
|
|
25011
|
+
["__verification", bundle.workingState ? null : verification],
|
|
25012
|
+
["__report", presentReport(bundle.files)]
|
|
24015
25013
|
]);
|
|
24016
25014
|
};
|
|
24017
|
-
var startViewer = async (bundle, { port = 0 } = {}) => {
|
|
25015
|
+
var startViewer = async (bundle, { port = 0, fonts = /* @__PURE__ */ new Map() } = {}) => {
|
|
24018
25016
|
const token = randomBytes2(32).toString("hex");
|
|
24019
25017
|
const derived = derivedDocuments(bundle);
|
|
24020
25018
|
let host = "";
|
|
@@ -24032,12 +25030,17 @@ var startViewer = async (bundle, { port = 0 } = {}) => {
|
|
|
24032
25030
|
const nonce = randomBytes2(16).toString("base64");
|
|
24033
25031
|
send(response, {
|
|
24034
25032
|
status: 200,
|
|
24035
|
-
body: viewerPage(nonce),
|
|
25033
|
+
body: viewerPage(nonce, fonts.size > 0 ? token : void 0),
|
|
24036
25034
|
contentType: "text/html; charset=utf-8",
|
|
24037
|
-
csp: `default-src 'none'; script-src 'nonce-${nonce}'; style-src 'nonce-${nonce}'; connect-src 'self'; img-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'`
|
|
25035
|
+
csp: `default-src 'none'; script-src 'nonce-${nonce}'; style-src 'nonce-${nonce}'; font-src 'self'; connect-src 'self'; img-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'`
|
|
24038
25036
|
});
|
|
24039
25037
|
return;
|
|
24040
25038
|
}
|
|
25039
|
+
const font = url.pathname.startsWith("/fonts/") ? fonts.get(url.pathname.slice("/fonts/".length)) : void 0;
|
|
25040
|
+
if (font !== void 0) {
|
|
25041
|
+
send(response, { status: 200, body: font, contentType: "font/ttf" });
|
|
25042
|
+
return;
|
|
25043
|
+
}
|
|
24041
25044
|
const file = decodeURIComponent(url.pathname.replace(/^\/data\//, ""));
|
|
24042
25045
|
const derivedDocument = derived.get(file);
|
|
24043
25046
|
if (url.pathname.startsWith("/data/") && derivedDocument !== void 0) {
|
|
@@ -24187,10 +25190,10 @@ var runExport = async (flags, usage) => {
|
|
|
24187
25190
|
if (dir === void 0) {
|
|
24188
25191
|
throw new Error(usage);
|
|
24189
25192
|
}
|
|
24190
|
-
if (await runDirectoryState(
|
|
25193
|
+
if (await runDirectoryState(path34.resolve(dir)) === "new") {
|
|
24191
25194
|
writeErr(
|
|
24192
25195
|
[
|
|
24193
|
-
`${
|
|
25196
|
+
`${path34.resolve(dir)} holds no run to export (it has no INPUTS.json).`,
|
|
24194
25197
|
` A local run: measure first with literally-aeo run --output ${dir}`,
|
|
24195
25198
|
` A hosted work directory from before INPUTS.json: pnpm aeo:codex prepare --report <reportKey> --workdir ${dir}`
|
|
24196
25199
|
].join("\n")
|
|
@@ -24199,7 +25202,7 @@ var runExport = async (flags, usage) => {
|
|
|
24199
25202
|
}
|
|
24200
25203
|
const settings = await readSettings(flags.options.get("--env-file"));
|
|
24201
25204
|
const redactFile = flags.options.get("--redact");
|
|
24202
|
-
const redactions = redactFile ? await readRedactions(
|
|
25205
|
+
const redactions = redactFile ? await readRedactions(path34.resolve(redactFile)) : void 0;
|
|
24203
25206
|
try {
|
|
24204
25207
|
const result = await exportRun(dir, {
|
|
24205
25208
|
output: flags.options.get("--output"),
|
|
@@ -24260,7 +25263,7 @@ var runVerify = async (flags, usage) => {
|
|
|
24260
25263
|
writeErr(err.message);
|
|
24261
25264
|
return 1;
|
|
24262
25265
|
}
|
|
24263
|
-
verification = refusedVerification(
|
|
25266
|
+
verification = refusedVerification(path34.resolve(target), {
|
|
24264
25267
|
id: "bundle.integrity",
|
|
24265
25268
|
title: "Bundle integrity",
|
|
24266
25269
|
outcome: "fail",
|
|
@@ -24274,12 +25277,26 @@ var runVerify = async (flags, usage) => {
|
|
|
24274
25277
|
);
|
|
24275
25278
|
return verification.exitCode;
|
|
24276
25279
|
};
|
|
25280
|
+
var readViewerFonts = async () => {
|
|
25281
|
+
const { fonts } = await engineResources();
|
|
25282
|
+
const entries = await Promise.all(
|
|
25283
|
+
Object.values(viewerFontFiles).map(
|
|
25284
|
+
async (file) => [file, await readFile29(path34.join(fonts, file))]
|
|
25285
|
+
)
|
|
25286
|
+
).catch((err) => {
|
|
25287
|
+
throw new Error(
|
|
25288
|
+
`The viewer's fonts are missing from ${fonts}. In a checkout, run pnpm build to refresh resources/; otherwise reinstall literally-aeo.`,
|
|
25289
|
+
{ cause: err }
|
|
25290
|
+
);
|
|
25291
|
+
});
|
|
25292
|
+
return new Map(entries);
|
|
25293
|
+
};
|
|
24277
25294
|
var runView = async (flags, usage) => {
|
|
24278
25295
|
const target = flags.positional[0];
|
|
24279
25296
|
if (target === void 0) {
|
|
24280
25297
|
throw new Error(usage);
|
|
24281
25298
|
}
|
|
24282
|
-
const resolved =
|
|
25299
|
+
const resolved = path34.resolve(target);
|
|
24283
25300
|
const revisions = await readFinalizedRevisions(resolved).catch(() => []);
|
|
24284
25301
|
const isRunDirectory = await runDirectoryState(resolved).then(
|
|
24285
25302
|
(state) => state !== "new",
|
|
@@ -24293,7 +25310,8 @@ var runView = async (flags, usage) => {
|
|
|
24293
25310
|
} : { ...await readBundleSource(resolved), workingState: false };
|
|
24294
25311
|
const portOption = flags.options.get("--port");
|
|
24295
25312
|
const viewer = await startViewer(bundle, {
|
|
24296
|
-
port: portOption === void 0 ? 0 : Number(portOption)
|
|
25313
|
+
port: portOption === void 0 ? 0 : Number(portOption),
|
|
25314
|
+
fonts: await readViewerFonts()
|
|
24297
25315
|
});
|
|
24298
25316
|
writeOut(
|
|
24299
25317
|
flags.switches.has("--json") ? JSON.stringify({ resultVersion: 1, command: "view", url: viewer.url }) : `Viewing ${bundle.description}
|
|
@@ -24309,72 +25327,10 @@ Press Ctrl-C to stop.`
|
|
|
24309
25327
|
};
|
|
24310
25328
|
|
|
24311
25329
|
// src/cli/guide-command.ts
|
|
24312
|
-
import { readFile as
|
|
24313
|
-
|
|
24314
|
-
// src/engine/resources.ts
|
|
24315
|
-
import { access as access2 } from "node:fs/promises";
|
|
24316
|
-
import path34 from "node:path";
|
|
24317
|
-
|
|
24318
|
-
// src/engine/package-root.ts
|
|
24319
|
-
import { readFileSync as readFileSync2 } from "node:fs";
|
|
24320
|
-
import path33 from "node:path";
|
|
24321
|
-
import { fileURLToPath } from "node:url";
|
|
24322
|
-
var enginePackageName = "literally-aeo";
|
|
24323
|
-
var isEngineManifest = (file) => {
|
|
24324
|
-
try {
|
|
24325
|
-
const manifest = JSON.parse(readFileSync2(file, "utf8"));
|
|
24326
|
-
return typeof manifest === "object" && manifest !== null && "name" in manifest && manifest.name === enginePackageName;
|
|
24327
|
-
} catch {
|
|
24328
|
-
return false;
|
|
24329
|
-
}
|
|
24330
|
-
};
|
|
24331
|
-
var enginePackageRoot = () => {
|
|
24332
|
-
const start = path33.dirname(fileURLToPath(import.meta.url));
|
|
24333
|
-
let dir = start;
|
|
24334
|
-
for (; ; ) {
|
|
24335
|
-
if (isEngineManifest(path33.join(dir, "package.json"))) {
|
|
24336
|
-
return dir;
|
|
24337
|
-
}
|
|
24338
|
-
const parent = path33.dirname(dir);
|
|
24339
|
-
if (parent === dir) {
|
|
24340
|
-
throw new Error(
|
|
24341
|
-
`No ${enginePackageName} package.json above ${start}; the engine runs from its own package.`
|
|
24342
|
-
);
|
|
24343
|
-
}
|
|
24344
|
-
dir = parent;
|
|
24345
|
-
}
|
|
24346
|
-
};
|
|
24347
|
-
|
|
24348
|
-
// src/engine/resources.ts
|
|
24349
|
-
var exists = async (file) => {
|
|
24350
|
-
return access2(file).then(
|
|
24351
|
-
() => true,
|
|
24352
|
-
() => false
|
|
24353
|
-
);
|
|
24354
|
-
};
|
|
24355
|
-
var engineResources = async () => {
|
|
24356
|
-
const root = enginePackageRoot();
|
|
24357
|
-
const packed = path34.join(root, "resources");
|
|
24358
|
-
if (await exists(path34.join(packed, "author", "COPY_RULES.md"))) {
|
|
24359
|
-
return {
|
|
24360
|
-
root,
|
|
24361
|
-
author: path34.join(packed, "author"),
|
|
24362
|
-
editorial: path34.join(packed, "editorial"),
|
|
24363
|
-
guide: path34.join(packed, "guide", "OPERATOR.md")
|
|
24364
|
-
};
|
|
24365
|
-
}
|
|
24366
|
-
return {
|
|
24367
|
-
root,
|
|
24368
|
-
author: path34.join(root, "src", "author"),
|
|
24369
|
-
editorial: path34.join(root, "src", "engine", "editorial"),
|
|
24370
|
-
guide: path34.join(root, "src", "engine", "guide", "OPERATOR.md")
|
|
24371
|
-
};
|
|
24372
|
-
};
|
|
24373
|
-
|
|
24374
|
-
// src/cli/guide-command.ts
|
|
25330
|
+
import { readFile as readFile30 } from "node:fs/promises";
|
|
24375
25331
|
var readOperatorGuide = async () => {
|
|
24376
25332
|
const { guide } = await engineResources();
|
|
24377
|
-
return
|
|
25333
|
+
return readFile30(guide, "utf8");
|
|
24378
25334
|
};
|
|
24379
25335
|
var runGuide = async (flags) => {
|
|
24380
25336
|
const guide = await readOperatorGuide();
|
|
@@ -24389,34 +25345,34 @@ import { writeFile as writeFile23 } from "node:fs/promises";
|
|
|
24389
25345
|
import path48 from "node:path";
|
|
24390
25346
|
|
|
24391
25347
|
// src/codex-workflow/loop.ts
|
|
24392
|
-
import { mkdir as mkdir20, readFile as
|
|
25348
|
+
import { mkdir as mkdir20, readFile as readFile41, writeFile as writeFile20 } from "node:fs/promises";
|
|
24393
25349
|
import path45 from "node:path";
|
|
24394
|
-
import { z as
|
|
25350
|
+
import { z as z75 } from "zod";
|
|
24395
25351
|
|
|
24396
25352
|
// src/agents/verifier.ts
|
|
24397
|
-
import { z as
|
|
24398
|
-
var verdictSchema =
|
|
24399
|
-
reviews:
|
|
24400
|
-
|
|
24401
|
-
path:
|
|
25353
|
+
import { z as z65 } from "zod";
|
|
25354
|
+
var verdictSchema = z65.object({
|
|
25355
|
+
reviews: z65.array(
|
|
25356
|
+
z65.object({
|
|
25357
|
+
path: z65.string(),
|
|
24402
25358
|
/** The verdict itself. The premise findings and the flag must
|
|
24403
25359
|
* agree, and only the flag lets `errors` reject a block: a
|
|
24404
25360
|
* passing review may still carry stray text there: a measured
|
|
24405
25361
|
* model wrote "None found." and "none" into `errors` for blocks
|
|
24406
25362
|
* it had approved, and each cost a copy generation. */
|
|
24407
|
-
passed:
|
|
24408
|
-
allPremisesCovered:
|
|
24409
|
-
actionAppropriate:
|
|
24410
|
-
premises:
|
|
24411
|
-
|
|
24412
|
-
proposition:
|
|
24413
|
-
declaredPremiseIndex:
|
|
24414
|
-
basisFactIds:
|
|
24415
|
-
supported:
|
|
24416
|
-
relevant:
|
|
25363
|
+
passed: z65.boolean(),
|
|
25364
|
+
allPremisesCovered: z65.boolean(),
|
|
25365
|
+
actionAppropriate: z65.boolean(),
|
|
25366
|
+
premises: z65.array(
|
|
25367
|
+
z65.object({
|
|
25368
|
+
proposition: z65.string().min(1),
|
|
25369
|
+
declaredPremiseIndex: z65.number().int().nonnegative().nullable(),
|
|
25370
|
+
basisFactIds: z65.array(z65.string()),
|
|
25371
|
+
supported: z65.boolean(),
|
|
25372
|
+
relevant: z65.boolean()
|
|
24417
25373
|
}).strict()
|
|
24418
25374
|
).max(40),
|
|
24419
|
-
errors:
|
|
25375
|
+
errors: z65.array(z65.string()).max(20)
|
|
24420
25376
|
}).strict()
|
|
24421
25377
|
).max(200)
|
|
24422
25378
|
}).strict();
|
|
@@ -24436,14 +25392,14 @@ ${rateComparison.id}: ${rateComparison.guidance} A narrative that breaks this fa
|
|
|
24436
25392
|
var verdictSchemaFor = (paths, factIds) => {
|
|
24437
25393
|
const enumOf = (values) => {
|
|
24438
25394
|
const [first, ...rest] = values;
|
|
24439
|
-
return first === void 0 ?
|
|
25395
|
+
return first === void 0 ? z65.string().min(1) : z65.enum([first, ...rest]);
|
|
24440
25396
|
};
|
|
24441
25397
|
const review2 = verdictSchema.shape.reviews.element;
|
|
24442
|
-
return
|
|
24443
|
-
reviews:
|
|
25398
|
+
return z65.object({
|
|
25399
|
+
reviews: z65.array(
|
|
24444
25400
|
review2.extend({
|
|
24445
25401
|
path: enumOf(paths),
|
|
24446
|
-
premises: review2.shape.premises.element.extend({ basisFactIds:
|
|
25402
|
+
premises: review2.shape.premises.element.extend({ basisFactIds: z65.array(enumOf(factIds)) }).array().max(40)
|
|
24447
25403
|
})
|
|
24448
25404
|
).min(1).max(Math.max(1, paths.length))
|
|
24449
25405
|
});
|
|
@@ -24721,28 +25677,28 @@ var verifierChunks = (recommendations, profile, context = {}) => {
|
|
|
24721
25677
|
};
|
|
24722
25678
|
|
|
24723
25679
|
// src/codex-workflow/copy-recovery.ts
|
|
24724
|
-
import { z as
|
|
25680
|
+
import { z as z67 } from "zod";
|
|
24725
25681
|
|
|
24726
25682
|
// src/codex-workflow/quality.ts
|
|
24727
|
-
import { readFile as
|
|
25683
|
+
import { readFile as readFile31 } from "node:fs/promises";
|
|
24728
25684
|
import path35 from "node:path";
|
|
24729
|
-
import { z as
|
|
24730
|
-
var storedReviewSchema =
|
|
24731
|
-
criteria:
|
|
24732
|
-
|
|
25685
|
+
import { z as z66 } from "zod";
|
|
25686
|
+
var storedReviewSchema = z66.looseObject({
|
|
25687
|
+
criteria: z66.array(
|
|
25688
|
+
z66.looseObject({ criterionId: z66.string(), outcome: z66.string() })
|
|
24733
25689
|
),
|
|
24734
|
-
unresolved:
|
|
24735
|
-
|
|
24736
|
-
criterionId:
|
|
24737
|
-
stage:
|
|
24738
|
-
file:
|
|
24739
|
-
problem:
|
|
24740
|
-
evidence:
|
|
25690
|
+
unresolved: z66.array(
|
|
25691
|
+
z66.looseObject({
|
|
25692
|
+
criterionId: z66.string(),
|
|
25693
|
+
stage: z66.string(),
|
|
25694
|
+
file: z66.string().nullable(),
|
|
25695
|
+
problem: z66.string(),
|
|
25696
|
+
evidence: z66.string()
|
|
24741
25697
|
})
|
|
24742
25698
|
)
|
|
24743
25699
|
});
|
|
24744
25700
|
var readStoredReview = async (dir) => {
|
|
24745
|
-
const raw = await
|
|
25701
|
+
const raw = await readFile31(path35.join(dir, "OUT", "review.json"), "utf8").catch(
|
|
24746
25702
|
() => "null"
|
|
24747
25703
|
) || "null";
|
|
24748
25704
|
const review2 = storedReviewSchema.nullable().parse(JSON.parse(raw));
|
|
@@ -24790,9 +25746,9 @@ var reportQuality = async (dir, { rounds, degraded, accepted }) => {
|
|
|
24790
25746
|
};
|
|
24791
25747
|
|
|
24792
25748
|
// src/codex-workflow/copy-recovery.ts
|
|
24793
|
-
var legacyRefusal =
|
|
24794
|
-
attempt:
|
|
24795
|
-
errors:
|
|
25749
|
+
var legacyRefusal = z67.object({
|
|
25750
|
+
attempt: z67.number().int(),
|
|
25751
|
+
errors: z67.array(z67.string())
|
|
24796
25752
|
});
|
|
24797
25753
|
var operationalErrors = (errors) => {
|
|
24798
25754
|
return errors.length > 0 && errors.every(
|
|
@@ -24839,19 +25795,19 @@ var CopyVerificationUnavailableError = class extends Error {
|
|
|
24839
25795
|
this.errors = errors;
|
|
24840
25796
|
}
|
|
24841
25797
|
};
|
|
24842
|
-
var windowSchema =
|
|
24843
|
-
passId:
|
|
24844
|
-
startedAt:
|
|
24845
|
-
deadlineAt:
|
|
25798
|
+
var windowSchema = z67.object({
|
|
25799
|
+
passId: z67.string(),
|
|
25800
|
+
startedAt: z67.iso.datetime(),
|
|
25801
|
+
deadlineAt: z67.iso.datetime()
|
|
24846
25802
|
}).strict();
|
|
24847
25803
|
|
|
24848
25804
|
// src/codex-workflow/copy-editor.ts
|
|
24849
|
-
import { readFile as
|
|
25805
|
+
import { readFile as readFile33 } from "node:fs/promises";
|
|
24850
25806
|
import path37 from "node:path";
|
|
24851
|
-
import { z as
|
|
25807
|
+
import { z as z68 } from "zod";
|
|
24852
25808
|
|
|
24853
25809
|
// src/codex-workflow/copy.ts
|
|
24854
|
-
import { mkdir as mkdir15, readFile as
|
|
25810
|
+
import { mkdir as mkdir15, readFile as readFile32, writeFile as writeFile13 } from "node:fs/promises";
|
|
24855
25811
|
import path36 from "node:path";
|
|
24856
25812
|
|
|
24857
25813
|
// src/agents/copywriter-input.ts
|
|
@@ -24924,11 +25880,11 @@ var authorDir = async (env = getEnvironment()) => {
|
|
|
24924
25880
|
var copywriterFiles = async (env = getEnvironment()) => {
|
|
24925
25881
|
const { author: author2, company } = await authorDir(env);
|
|
24926
25882
|
const files = {
|
|
24927
|
-
"RULES.md": await
|
|
24928
|
-
"banlist.json": await
|
|
25883
|
+
"RULES.md": await readFile32(path36.join(author2, "COPY_RULES.md"), "utf8"),
|
|
25884
|
+
"banlist.json": await readFile32(path36.join(author2, "banlist.json"), "utf8")
|
|
24929
25885
|
};
|
|
24930
25886
|
for (const file of ["COMPANY", "positioning", "services"]) {
|
|
24931
|
-
files[`company/${file}.md`] = await
|
|
25887
|
+
files[`company/${file}.md`] = await readFile32(
|
|
24932
25888
|
path36.join(company, `${file}.md`),
|
|
24933
25889
|
"utf8"
|
|
24934
25890
|
);
|
|
@@ -24936,7 +25892,7 @@ var copywriterFiles = async (env = getEnvironment()) => {
|
|
|
24936
25892
|
return files;
|
|
24937
25893
|
};
|
|
24938
25894
|
var readSnapshot = async (dir) => {
|
|
24939
|
-
const raw = await
|
|
25895
|
+
const raw = await readFile32(
|
|
24940
25896
|
path36.join(dir, "OUT", "snapshot.json"),
|
|
24941
25897
|
"utf8"
|
|
24942
25898
|
).catch(() => null);
|
|
@@ -24989,7 +25945,7 @@ var readCopyDocuments = async (dir, files) => {
|
|
|
24989
25945
|
const entries = await Promise.all(
|
|
24990
25946
|
files.map(async (file) => {
|
|
24991
25947
|
const name = path36.posix.relative(copyDir, file);
|
|
24992
|
-
return [name, await
|
|
25948
|
+
return [name, await readFile32(path36.join(dir, file), "utf8")];
|
|
24993
25949
|
})
|
|
24994
25950
|
);
|
|
24995
25951
|
return Object.fromEntries(entries);
|
|
@@ -25215,21 +26171,21 @@ This is your editing turn: return only the complete edited draft required by the
|
|
|
25215
26171
|
}
|
|
25216
26172
|
return { ...call(), trimmed };
|
|
25217
26173
|
};
|
|
25218
|
-
var savedCopyEditsSchema =
|
|
25219
|
-
scope:
|
|
25220
|
-
edits:
|
|
25221
|
-
|
|
25222
|
-
inputDigest:
|
|
25223
|
-
draft:
|
|
25224
|
-
round:
|
|
25225
|
-
errors:
|
|
26174
|
+
var savedCopyEditsSchema = z68.object({
|
|
26175
|
+
scope: z68.string(),
|
|
26176
|
+
edits: z68.array(
|
|
26177
|
+
z68.object({
|
|
26178
|
+
inputDigest: z68.string(),
|
|
26179
|
+
draft: z68.unknown().optional(),
|
|
26180
|
+
round: z68.number(),
|
|
26181
|
+
errors: z68.array(z68.string()),
|
|
25226
26182
|
editedDraft: writeOutputSchema,
|
|
25227
|
-
trimmed:
|
|
26183
|
+
trimmed: z68.array(z68.string()).optional()
|
|
25228
26184
|
})
|
|
25229
26185
|
)
|
|
25230
26186
|
}).nullable();
|
|
25231
26187
|
var readCopyEdits = async (dir, scope) => {
|
|
25232
|
-
const raw = await
|
|
26188
|
+
const raw = await readFile33(
|
|
25233
26189
|
path37.join(dir, "PENDING/copy-edits.json"),
|
|
25234
26190
|
"utf8"
|
|
25235
26191
|
).catch(() => "null");
|
|
@@ -25305,9 +26261,9 @@ var editCopyDraft = async (args) => {
|
|
|
25305
26261
|
|
|
25306
26262
|
// src/codex-workflow/finish.ts
|
|
25307
26263
|
import { createHash as createHash9 } from "node:crypto";
|
|
25308
|
-
import { readFile as
|
|
26264
|
+
import { readFile as readFile34, writeFile as writeFile14 } from "node:fs/promises";
|
|
25309
26265
|
import path38 from "node:path";
|
|
25310
|
-
import { z as
|
|
26266
|
+
import { z as z69 } from "zod";
|
|
25311
26267
|
|
|
25312
26268
|
// src/agents/methodology.ts
|
|
25313
26269
|
var maxNamedModels = 3;
|
|
@@ -25415,7 +26371,7 @@ var codexAnalyzer = (model) => {
|
|
|
25415
26371
|
var finishRun = async (args) => {
|
|
25416
26372
|
const { source, dir, signal } = args;
|
|
25417
26373
|
const { config, request: request2, plan } = source;
|
|
25418
|
-
const aggregateText = await
|
|
26374
|
+
const aggregateText = await readFile34(
|
|
25419
26375
|
path38.join(dir, "OUT", "aggregate.json"),
|
|
25420
26376
|
"utf8"
|
|
25421
26377
|
);
|
|
@@ -25637,7 +26593,7 @@ var isGroundingBundle = (value) => {
|
|
|
25637
26593
|
};
|
|
25638
26594
|
var reuseFinish = async (dir, digest5, aggregate2) => {
|
|
25639
26595
|
const out = (name) => {
|
|
25640
|
-
return
|
|
26596
|
+
return readFile34(path38.join(dir, "OUT", name), "utf8");
|
|
25641
26597
|
};
|
|
25642
26598
|
const recorded2 = await out("finish.inputs.sha").catch(() => null);
|
|
25643
26599
|
if (recorded2?.trim() !== digest5) {
|
|
@@ -25653,9 +26609,9 @@ var reuseFinish = async (dir, digest5, aggregate2) => {
|
|
|
25653
26609
|
const captureManifest = captureManifestSchema.parse(
|
|
25654
26610
|
JSON.parse(await out("capture-manifest.json"))
|
|
25655
26611
|
);
|
|
25656
|
-
const partialFailures =
|
|
26612
|
+
const partialFailures = z69.array(partialFailureSchema).parse(JSON.parse(await out("partial-failures.json")));
|
|
25657
26613
|
const grounding = JSON.parse(await out("grounding.json"));
|
|
25658
|
-
const labelStats =
|
|
26614
|
+
const labelStats = z69.record(z69.string(), z69.number()).parse(JSON.parse(await out("label-stats.json")));
|
|
25659
26615
|
if (grounding !== null && !isGroundingBundle(grounding)) {
|
|
25660
26616
|
throw new Error("OUT/grounding.json is not a grounding bundle.");
|
|
25661
26617
|
}
|
|
@@ -25710,14 +26666,14 @@ import {
|
|
|
25710
26666
|
appendFile as appendFile2,
|
|
25711
26667
|
mkdir as mkdir18,
|
|
25712
26668
|
readdir as readdir7,
|
|
25713
|
-
readFile as
|
|
26669
|
+
readFile as readFile39,
|
|
25714
26670
|
rename as rename10,
|
|
25715
26671
|
rm as rm9,
|
|
25716
26672
|
writeFile as writeFile18
|
|
25717
26673
|
} from "node:fs/promises";
|
|
25718
26674
|
import path43 from "node:path";
|
|
25719
26675
|
import { setTimeout as delay3 } from "node:timers/promises";
|
|
25720
|
-
import { z as
|
|
26676
|
+
import { z as z73 } from "zod";
|
|
25721
26677
|
|
|
25722
26678
|
// src/models/pricing.ts
|
|
25723
26679
|
var tokenCostUsd = (pricing, usage) => {
|
|
@@ -25732,7 +26688,7 @@ import {
|
|
|
25732
26688
|
access as access3,
|
|
25733
26689
|
mkdir as mkdir17,
|
|
25734
26690
|
readdir as readdir6,
|
|
25735
|
-
readFile as
|
|
26691
|
+
readFile as readFile36,
|
|
25736
26692
|
rm as rm7,
|
|
25737
26693
|
writeFile as writeFile16
|
|
25738
26694
|
} from "node:fs/promises";
|
|
@@ -26228,9 +27184,9 @@ var authorExamples = (names = authorExampleNames) => {
|
|
|
26228
27184
|
};
|
|
26229
27185
|
|
|
26230
27186
|
// src/codex-workflow/author-tools.ts
|
|
26231
|
-
import { appendFile, mkdir as mkdir16, readFile as
|
|
27187
|
+
import { appendFile, mkdir as mkdir16, readFile as readFile35, writeFile as writeFile15 } from "node:fs/promises";
|
|
26232
27188
|
import path39 from "node:path";
|
|
26233
|
-
import { z as
|
|
27189
|
+
import { z as z70 } from "zod";
|
|
26234
27190
|
var researchDir = "RESEARCH";
|
|
26235
27191
|
var authorToolCaps = {
|
|
26236
27192
|
search: 20,
|
|
@@ -26243,59 +27199,59 @@ var authorToolCaps = {
|
|
|
26243
27199
|
pageTextBytes: 32 * 1024,
|
|
26244
27200
|
links: 100
|
|
26245
27201
|
};
|
|
26246
|
-
var researchIndexSchema =
|
|
26247
|
-
next:
|
|
26248
|
-
byUrl:
|
|
26249
|
-
|
|
26250
|
-
|
|
27202
|
+
var researchIndexSchema = z70.object({
|
|
27203
|
+
next: z70.number(),
|
|
27204
|
+
byUrl: z70.record(
|
|
27205
|
+
z70.string(),
|
|
27206
|
+
z70.object({ n: z70.number(), kind: z70.enum(["fetch", "render"]) })
|
|
26251
27207
|
)
|
|
26252
27208
|
});
|
|
26253
|
-
var researchJournalEntrySchema =
|
|
26254
|
-
at:
|
|
26255
|
-
tool:
|
|
26256
|
-
args:
|
|
26257
|
-
outcome:
|
|
26258
|
-
reason:
|
|
26259
|
-
elapsedMs:
|
|
26260
|
-
bytes:
|
|
26261
|
-
costUsd:
|
|
26262
|
-
provider:
|
|
26263
|
-
path:
|
|
26264
|
-
urls:
|
|
26265
|
-
cached:
|
|
27209
|
+
var researchJournalEntrySchema = z70.object({
|
|
27210
|
+
at: z70.string(),
|
|
27211
|
+
tool: z70.string(),
|
|
27212
|
+
args: z70.record(z70.string(), z70.unknown()),
|
|
27213
|
+
outcome: z70.enum(["ok", "refused", "error"]),
|
|
27214
|
+
reason: z70.string().optional(),
|
|
27215
|
+
elapsedMs: z70.number(),
|
|
27216
|
+
bytes: z70.number().optional(),
|
|
27217
|
+
costUsd: z70.number().nullable().optional(),
|
|
27218
|
+
provider: z70.string().optional(),
|
|
27219
|
+
path: z70.string().optional(),
|
|
27220
|
+
urls: z70.array(z70.string()).optional(),
|
|
27221
|
+
cached: z70.boolean().optional()
|
|
26266
27222
|
});
|
|
26267
27223
|
var isGroundingSource = (value) => {
|
|
26268
27224
|
return groundingSourceSchema.safeParse(value).success;
|
|
26269
27225
|
};
|
|
26270
|
-
var searchArgs =
|
|
26271
|
-
query:
|
|
26272
|
-
purpose:
|
|
27226
|
+
var searchArgs = z70.object({
|
|
27227
|
+
query: z70.string().trim().min(1).max(300),
|
|
27228
|
+
purpose: z70.string().trim().min(1).max(300)
|
|
26273
27229
|
}).strict();
|
|
26274
|
-
var urlArgs =
|
|
26275
|
-
var submitArgs =
|
|
27230
|
+
var urlArgs = z70.object({ url: z70.string().trim().min(1).max(4096) }).strict();
|
|
27231
|
+
var submitArgs = z70.object({ config: z70.unknown(), notes: z70.unknown() }).strict();
|
|
26276
27232
|
var researchToolDefinitions = [
|
|
26277
27233
|
{
|
|
26278
27234
|
name: "search",
|
|
26279
27235
|
description: "Web search. Returns up to 10 results with url, title and a short snippet; fetch a result to read it. Say what you are trying to find in purpose; it is journaled for the reviewer. Capped per session.",
|
|
26280
|
-
inputSchema:
|
|
27236
|
+
inputSchema: z70.toJSONSchema(searchArgs),
|
|
26281
27237
|
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
26282
27238
|
},
|
|
26283
27239
|
{
|
|
26284
27240
|
name: "fetch",
|
|
26285
27241
|
description: "Fetch a public HTTPS page without JavaScript. Returns the extracted text (up to 32 KB), the links on the page, and the RESEARCH/ path the page was saved under: cite that path in notes.reasons and the url in proposedFacts.sourceUrls. A page already fetched is returned from the saved copy. Capped per session and per host.",
|
|
26286
|
-
inputSchema:
|
|
27242
|
+
inputSchema: z70.toJSONSchema(urlArgs),
|
|
26287
27243
|
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
26288
27244
|
},
|
|
26289
27245
|
{
|
|
26290
27246
|
name: "render",
|
|
26291
27247
|
description: "Fetch a page with a headless browser, for pages that return little text without JavaScript. Same result shape as fetch. Small cap per session: use it only when fetch returned too little.",
|
|
26292
|
-
inputSchema:
|
|
27248
|
+
inputSchema: z70.toJSONSchema(urlArgs),
|
|
26293
27249
|
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
26294
27250
|
},
|
|
26295
27251
|
{
|
|
26296
27252
|
name: "submit",
|
|
26297
27253
|
description: 'Submit the config and the notes. Both are checked against the schema; on success the output file is written and the result is {"ok":true}. On errors, nothing is written and the errors are returned: fix them and submit again. Every call replaces the previous submission. Pass config and notes as JSON objects; a JSON string holding the object is decoded too, so do not retry a call because of how it was serialized.',
|
|
26298
|
-
inputSchema:
|
|
27254
|
+
inputSchema: z70.toJSONSchema(submitArgs)
|
|
26299
27255
|
}
|
|
26300
27256
|
];
|
|
26301
27257
|
var researchDocumentPath = (n) => {
|
|
@@ -26324,7 +27280,7 @@ var parseResearchDocument = (content) => {
|
|
|
26324
27280
|
};
|
|
26325
27281
|
};
|
|
26326
27282
|
var readIndex = async (dir) => {
|
|
26327
|
-
const raw = await
|
|
27283
|
+
const raw = await readFile35(
|
|
26328
27284
|
path39.join(dir, researchDir, "INDEX.json"),
|
|
26329
27285
|
"utf8"
|
|
26330
27286
|
).catch(() => null);
|
|
@@ -26334,7 +27290,7 @@ var readIndex = async (dir) => {
|
|
|
26334
27290
|
return researchIndexSchema.parse(JSON.parse(raw));
|
|
26335
27291
|
};
|
|
26336
27292
|
var readResearchJournal = async (dir, label) => {
|
|
26337
|
-
const raw = await
|
|
27293
|
+
const raw = await readFile35(
|
|
26338
27294
|
path39.join(dir, "JOURNAL", `${label}.research.jsonl`),
|
|
26339
27295
|
"utf8"
|
|
26340
27296
|
).catch(() => "");
|
|
@@ -26349,7 +27305,7 @@ var readResearchDocuments = async (dir) => {
|
|
|
26349
27305
|
continue;
|
|
26350
27306
|
}
|
|
26351
27307
|
seen.add(n);
|
|
26352
|
-
const content = await
|
|
27308
|
+
const content = await readFile35(
|
|
26353
27309
|
path39.join(dir, researchDocumentPath(n)),
|
|
26354
27310
|
"utf8"
|
|
26355
27311
|
).catch(() => null);
|
|
@@ -26358,7 +27314,7 @@ var readResearchDocuments = async (dir) => {
|
|
|
26358
27314
|
continue;
|
|
26359
27315
|
}
|
|
26360
27316
|
const savedSource = JSON.parse(
|
|
26361
|
-
await
|
|
27317
|
+
await readFile35(path39.join(dir, researchSourcePath(n)), "utf8").catch(
|
|
26362
27318
|
() => "null"
|
|
26363
27319
|
)
|
|
26364
27320
|
);
|
|
@@ -26463,11 +27419,11 @@ var materializeAuthorWorkdir = async (args) => {
|
|
|
26463
27419
|
await writeFile16(path40.join(base, "BRIEF.md"), briefDocument(args.brief));
|
|
26464
27420
|
await writeFile16(
|
|
26465
27421
|
path40.join(base, "RULES.md"),
|
|
26466
|
-
await
|
|
27422
|
+
await readFile36(path40.join(author2, "RULES.md"), "utf8")
|
|
26467
27423
|
);
|
|
26468
27424
|
await writeFile16(
|
|
26469
27425
|
path40.join(base, "banlist.json"),
|
|
26470
|
-
await
|
|
27426
|
+
await readFile36(path40.join(author2, "banlist.json"), "utf8")
|
|
26471
27427
|
);
|
|
26472
27428
|
await writeFile16(
|
|
26473
27429
|
path40.join(base, "SCHEMA.json"),
|
|
@@ -26520,7 +27476,7 @@ var authorPacket = async (args) => {
|
|
|
26520
27476
|
if (args.continuation && !file.startsWith(`${authorWorkDir}/PREVIOUS/`)) {
|
|
26521
27477
|
continue;
|
|
26522
27478
|
}
|
|
26523
|
-
const content = await
|
|
27479
|
+
const content = await readFile36(path40.join(args.dir, file), "utf8");
|
|
26524
27480
|
files[file] = file.endsWith(".json") ? JSON.parse(content) : content;
|
|
26525
27481
|
}
|
|
26526
27482
|
return JSON.stringify({
|
|
@@ -26580,7 +27536,7 @@ var researchServerConfig = async (dir, env = getEnvironment()) => {
|
|
|
26580
27536
|
};
|
|
26581
27537
|
};
|
|
26582
27538
|
var readAuthorOutput = async (dir) => {
|
|
26583
|
-
const raw = await
|
|
27539
|
+
const raw = await readFile36(path40.join(dir, authorOutputFile), "utf8").catch(
|
|
26584
27540
|
() => null
|
|
26585
27541
|
);
|
|
26586
27542
|
if (raw === null) {
|
|
@@ -26632,15 +27588,15 @@ var validateAuthorStage = async (args) => {
|
|
|
26632
27588
|
};
|
|
26633
27589
|
|
|
26634
27590
|
// src/codex-workflow/session.ts
|
|
26635
|
-
import { readFile as
|
|
27591
|
+
import { readFile as readFile37, rm as rm8, writeFile as writeFile17 } from "node:fs/promises";
|
|
26636
27592
|
import path41 from "node:path";
|
|
26637
|
-
import { z as
|
|
26638
|
-
var savedSessionSchema =
|
|
26639
|
-
contract:
|
|
26640
|
-
threadId:
|
|
27593
|
+
import { z as z71 } from "zod";
|
|
27594
|
+
var savedSessionSchema = z71.looseObject({
|
|
27595
|
+
contract: z71.string(),
|
|
27596
|
+
threadId: z71.string()
|
|
26641
27597
|
});
|
|
26642
27598
|
var readSession = async (dir, { label, contract }) => {
|
|
26643
|
-
const raw = await
|
|
27599
|
+
const raw = await readFile37(
|
|
26644
27600
|
path41.join(dir, "JOURNAL", `${label}.session.json`),
|
|
26645
27601
|
"utf8"
|
|
26646
27602
|
).catch(() => null);
|
|
@@ -26730,23 +27686,23 @@ var reserveWhenAffordable = async (ledger, reserve, signal) => {
|
|
|
26730
27686
|
};
|
|
26731
27687
|
|
|
26732
27688
|
// src/codex-workflow/batch-input.ts
|
|
26733
|
-
import { readFile as
|
|
27689
|
+
import { readFile as readFile38 } from "node:fs/promises";
|
|
26734
27690
|
import path42 from "node:path";
|
|
26735
|
-
import { z as
|
|
26736
|
-
var trailEntrySchema =
|
|
26737
|
-
by:
|
|
26738
|
-
at:
|
|
26739
|
-
outcome:
|
|
26740
|
-
stage:
|
|
26741
|
-
file:
|
|
26742
|
-
field:
|
|
26743
|
-
to:
|
|
27691
|
+
import { z as z72 } from "zod";
|
|
27692
|
+
var trailEntrySchema = z72.looseObject({
|
|
27693
|
+
by: z72.string(),
|
|
27694
|
+
at: z72.string(),
|
|
27695
|
+
outcome: z72.string(),
|
|
27696
|
+
stage: z72.string(),
|
|
27697
|
+
file: z72.string(),
|
|
27698
|
+
field: z72.string(),
|
|
27699
|
+
to: z72.string()
|
|
26744
27700
|
});
|
|
26745
27701
|
var isTrailEntry = (entry) => {
|
|
26746
27702
|
return trailEntrySchema.safeParse(entry).success;
|
|
26747
27703
|
};
|
|
26748
|
-
var previousPassSchema =
|
|
26749
|
-
var previousCorrectionsSchema =
|
|
27704
|
+
var previousPassSchema = z72.record(z72.string(), z72.unknown()).nullable();
|
|
27705
|
+
var previousCorrectionsSchema = z72.array(z72.record(z72.string(), z72.unknown()));
|
|
26750
27706
|
var readUnlessMissing = async (read, { file, fallback }) => {
|
|
26751
27707
|
try {
|
|
26752
27708
|
return await read(file);
|
|
@@ -26760,7 +27716,7 @@ var readUnlessMissing = async (read, { file, fallback }) => {
|
|
|
26760
27716
|
var batchInput = async (args) => {
|
|
26761
27717
|
const { dir, stage, index } = args;
|
|
26762
27718
|
const read = (file) => {
|
|
26763
|
-
return
|
|
27719
|
+
return readFile38(path42.join(dir, file), "utf8");
|
|
26764
27720
|
};
|
|
26765
27721
|
const inputFile = `OUT/${stage}/${index}.${stage === "analyze" ? "index" : "rows"}.json`;
|
|
26766
27722
|
const current = JSON.parse(await read(inputFile));
|
|
@@ -26774,7 +27730,7 @@ var batchInput = async (args) => {
|
|
|
26774
27730
|
) : void 0;
|
|
26775
27731
|
let hostFeedback;
|
|
26776
27732
|
if (previous) {
|
|
26777
|
-
const trail =
|
|
27733
|
+
const trail = z72.array(z72.unknown()).parse(
|
|
26778
27734
|
JSON.parse(
|
|
26779
27735
|
await readUnlessMissing(read, {
|
|
26780
27736
|
file: "OUT/corrections.json",
|
|
@@ -26828,11 +27784,11 @@ var batchInput = async (args) => {
|
|
|
26828
27784
|
var defaultBatchSize = 10;
|
|
26829
27785
|
var defaultConcurrency = 25;
|
|
26830
27786
|
var maxAttempts = 3;
|
|
26831
|
-
var rowsOutSchema =
|
|
26832
|
-
rows:
|
|
27787
|
+
var rowsOutSchema = z73.looseObject({
|
|
27788
|
+
rows: z73.array(z73.record(z73.string(), z73.unknown())).optional()
|
|
26833
27789
|
});
|
|
26834
27790
|
var readOut = async (dir, { stage, required }) => {
|
|
26835
|
-
const raw = await
|
|
27791
|
+
const raw = await readFile39(
|
|
26836
27792
|
path43.join(dir, "OUT", `${stage}.json`),
|
|
26837
27793
|
"utf8"
|
|
26838
27794
|
).catch(() => null);
|
|
@@ -27061,7 +28017,7 @@ var batchInputsDigest = async (ctx, stage, batch) => {
|
|
|
27061
28017
|
)
|
|
27062
28018
|
};
|
|
27063
28019
|
for (const file of await spec.sharedInputs(ctx.dir)) {
|
|
27064
|
-
parts[file] = await
|
|
28020
|
+
parts[file] = await readFile39(path43.join(ctx.dir, file), "utf8").catch(
|
|
27065
28021
|
() => ""
|
|
27066
28022
|
);
|
|
27067
28023
|
}
|
|
@@ -27078,14 +28034,14 @@ var stageInputsDigest = async (ctx, stage) => {
|
|
|
27078
28034
|
return sha(digests);
|
|
27079
28035
|
};
|
|
27080
28036
|
var isStageFresh = async (ctx, stage) => {
|
|
27081
|
-
const recorded2 = await
|
|
28037
|
+
const recorded2 = await readFile39(
|
|
27082
28038
|
path43.join(ctx.dir, "OUT", `${stage}.inputs.sha`),
|
|
27083
28039
|
"utf8"
|
|
27084
28040
|
).catch(() => null);
|
|
27085
28041
|
if (!recorded2) {
|
|
27086
28042
|
return false;
|
|
27087
28043
|
}
|
|
27088
|
-
const out = await
|
|
28044
|
+
const out = await readFile39(
|
|
27089
28045
|
path43.join(ctx.dir, "OUT", `${stage}.json`),
|
|
27090
28046
|
"utf8"
|
|
27091
28047
|
).catch(() => null);
|
|
@@ -27098,26 +28054,26 @@ var sessionSandbox = (spec) => {
|
|
|
27098
28054
|
const AEO_CODEX_STAGE_SANDBOX = readEnv("AEO_CODEX_STAGE_SANDBOX");
|
|
27099
28055
|
return AEO_CODEX_STAGE_SANDBOX === "danger-full-access" ? "danger-full-access" : "workspace-write";
|
|
27100
28056
|
};
|
|
27101
|
-
var eventText =
|
|
27102
|
-
var eventTokens =
|
|
27103
|
-
var eventUsage =
|
|
28057
|
+
var eventText = z73.string().optional().catch(void 0);
|
|
28058
|
+
var eventTokens = z73.number().optional().catch(void 0);
|
|
28059
|
+
var eventUsage = z73.looseObject({
|
|
27104
28060
|
input_tokens: eventTokens,
|
|
27105
28061
|
cached_input_tokens: eventTokens,
|
|
27106
28062
|
output_tokens: eventTokens
|
|
27107
28063
|
}).optional().catch(void 0);
|
|
27108
|
-
var codexEventSchema =
|
|
28064
|
+
var codexEventSchema = z73.looseObject({
|
|
27109
28065
|
type: eventText,
|
|
27110
28066
|
thread_id: eventText,
|
|
27111
28067
|
message: eventText,
|
|
27112
|
-
error:
|
|
27113
|
-
item:
|
|
28068
|
+
error: z73.looseObject({ message: eventText }).optional().catch(void 0),
|
|
28069
|
+
item: z73.looseObject({
|
|
27114
28070
|
type: eventText,
|
|
27115
28071
|
command: eventText,
|
|
27116
28072
|
text: eventText,
|
|
27117
28073
|
status: eventText
|
|
27118
28074
|
}).optional().catch(void 0),
|
|
27119
28075
|
usage: eventUsage,
|
|
27120
|
-
info:
|
|
28076
|
+
info: z73.looseObject({ total_token_usage: eventUsage }).optional().catch(void 0)
|
|
27121
28077
|
});
|
|
27122
28078
|
var parseCodexEvent = (line) => {
|
|
27123
28079
|
let json;
|
|
@@ -27218,7 +28174,7 @@ var execReservedCodex = async (ctx, { stage, batch, feedback, attempt }, reserve
|
|
|
27218
28174
|
inputs: await Promise.all(
|
|
27219
28175
|
boundFiles.map(async (file) => [
|
|
27220
28176
|
file,
|
|
27221
|
-
await
|
|
28177
|
+
await readFile39(path43.join(ctx.dir, file), "utf8").catch(() => "")
|
|
27222
28178
|
])
|
|
27223
28179
|
)
|
|
27224
28180
|
});
|
|
@@ -27402,7 +28358,7 @@ var correctionValue = (text) => {
|
|
|
27402
28358
|
}
|
|
27403
28359
|
};
|
|
27404
28360
|
var readCorrectable = async (file) => {
|
|
27405
|
-
const raw = await
|
|
28361
|
+
const raw = await readFile39(file, "utf8");
|
|
27406
28362
|
return rowsOutSchema.parse(JSON.parse(raw));
|
|
27407
28363
|
};
|
|
27408
28364
|
var isQualifyRow = (row) => {
|
|
@@ -27489,7 +28445,7 @@ var applyCorrections = async (ctx, from, corrections) => {
|
|
|
27489
28445
|
const scope = { brand: ctx.brand, answers, coverage: false };
|
|
27490
28446
|
for (const [stage, list] of byStage) {
|
|
27491
28447
|
const file = path43.join(ctx.dir, "OUT", `${stage}.json`);
|
|
27492
|
-
const raw = await
|
|
28448
|
+
const raw = await readFile39(file, "utf8").catch(() => null);
|
|
27493
28449
|
if (!raw || !isStageName(stage)) {
|
|
27494
28450
|
for (const correction of list) {
|
|
27495
28451
|
outcomes.push({ correction, outcome: "refused: no such stage output" });
|
|
@@ -27516,8 +28472,8 @@ var applyCorrections = async (ctx, from, corrections) => {
|
|
|
27516
28472
|
await alignBatchRows(path43.join(ctx.dir, "OUT", stage), output);
|
|
27517
28473
|
}
|
|
27518
28474
|
const trailFile = path43.join(ctx.dir, "OUT", "corrections.json");
|
|
27519
|
-
const trail =
|
|
27520
|
-
JSON.parse(await
|
|
28475
|
+
const trail = z73.array(z73.unknown()).parse(
|
|
28476
|
+
JSON.parse(await readFile39(trailFile, "utf8").catch(() => "[]") || "[]")
|
|
27521
28477
|
);
|
|
27522
28478
|
const at = (/* @__PURE__ */ new Date()).toISOString();
|
|
27523
28479
|
trail.push(
|
|
@@ -27603,7 +28559,7 @@ var dropSession = async (ctx, label) => {
|
|
|
27603
28559
|
var incompleteError = (result) => {
|
|
27604
28560
|
return `codex exited ${result.exitCode} without an output file: ${(result.failure ?? result.stderr).slice(-600)}`;
|
|
27605
28561
|
};
|
|
27606
|
-
var storedBatchSchema =
|
|
28562
|
+
var storedBatchSchema = z73.record(z73.string(), z73.unknown());
|
|
27607
28563
|
var runCodexBatch = async (ctx, { stage, batch, files, scope }) => {
|
|
27608
28564
|
const { label, outFile, refusedFile } = files;
|
|
27609
28565
|
const usages = [];
|
|
@@ -27623,7 +28579,7 @@ var runCodexBatch = async (ctx, { stage, batch, files, scope }) => {
|
|
|
27623
28579
|
operationId: result.operationId ?? null
|
|
27624
28580
|
};
|
|
27625
28581
|
usages.push(result.usage);
|
|
27626
|
-
const raw = await
|
|
28582
|
+
const raw = await readFile39(outFile, "utf8").catch(() => null);
|
|
27627
28583
|
if (raw === null) {
|
|
27628
28584
|
const error = incompleteError(result);
|
|
27629
28585
|
if (isAuthError(result.failure ?? result.stderr)) {
|
|
@@ -27707,20 +28663,20 @@ var runCodexBatch = async (ctx, { stage, batch, files, scope }) => {
|
|
|
27707
28663
|
...fatal !== void 0 && { fatal }
|
|
27708
28664
|
};
|
|
27709
28665
|
};
|
|
27710
|
-
var pendingSchema =
|
|
27711
|
-
version:
|
|
27712
|
-
digest:
|
|
28666
|
+
var pendingSchema = z73.object({
|
|
28667
|
+
version: z73.literal(2).optional(),
|
|
28668
|
+
digest: z73.string(),
|
|
27713
28669
|
// A draft the writer never produced is absent from the written file.
|
|
27714
|
-
draft:
|
|
27715
|
-
rounds:
|
|
27716
|
-
errors:
|
|
28670
|
+
draft: z73.unknown().optional(),
|
|
28671
|
+
rounds: z73.number(),
|
|
28672
|
+
errors: z73.array(z73.string())
|
|
27717
28673
|
});
|
|
27718
28674
|
var savePending = async (ctx, { pendingFile, pending }) => {
|
|
27719
28675
|
await writePendingJson(path43.join(ctx.dir, pendingFile), pending);
|
|
27720
28676
|
await ctx.checkpoint?.([pendingFile]);
|
|
27721
28677
|
};
|
|
27722
28678
|
var readPending = async (ctx, { label, pendingFile, digest: digest5 }) => {
|
|
27723
|
-
const raw = await
|
|
28679
|
+
const raw = await readFile39(path43.join(ctx.dir, pendingFile), "utf8").catch(
|
|
27724
28680
|
() => "null"
|
|
27725
28681
|
);
|
|
27726
28682
|
const parsed = pendingSchema.safeParse(JSON.parse(raw));
|
|
@@ -27731,7 +28687,7 @@ var readPending = async (ctx, { label, pendingFile, digest: digest5 }) => {
|
|
|
27731
28687
|
if (saved.version === 2) {
|
|
27732
28688
|
return saved;
|
|
27733
28689
|
}
|
|
27734
|
-
const journalText = await
|
|
28690
|
+
const journalText = await readFile39(
|
|
27735
28691
|
path43.join(ctx.dir, "JOURNAL", `${label}.refusals.jsonl`),
|
|
27736
28692
|
"utf8"
|
|
27737
28693
|
).catch(() => "");
|
|
@@ -27899,7 +28855,7 @@ var reusedBatch = async (ctx, {
|
|
|
27899
28855
|
if (validated.value === void 0 || validated.errors.length) {
|
|
27900
28856
|
return void 0;
|
|
27901
28857
|
}
|
|
27902
|
-
const appliedSha = await
|
|
28858
|
+
const appliedSha = await readFile39(appliedFile, "utf8").catch(() => "");
|
|
27903
28859
|
await ctx.recorder?.record(
|
|
27904
28860
|
"artifact_reused",
|
|
27905
28861
|
{ stage, batch: batch.index },
|
|
@@ -27944,8 +28900,8 @@ var runBatch = async (ctx, {
|
|
|
27944
28900
|
const refusedFile = path43.join(outDir, `${batch.index}.refused.json`);
|
|
27945
28901
|
const scope = scopeFor(ctx, stage, batch);
|
|
27946
28902
|
const digest5 = await batchInputsDigest(ctx, stage, batch);
|
|
27947
|
-
const previous = await
|
|
27948
|
-
const recorded2 = (await
|
|
28903
|
+
const previous = await readFile39(outFile, "utf8").catch(() => null);
|
|
28904
|
+
const recorded2 = (await readFile39(shaFile, "utf8").catch(() => "")).trim();
|
|
27949
28905
|
if (previous !== null && recorded2 === digest5 && (!force || previousAccepted)) {
|
|
27950
28906
|
const reused = await reusedBatch(ctx, {
|
|
27951
28907
|
stage,
|
|
@@ -28043,15 +28999,15 @@ var pool = async (items, {
|
|
|
28043
28999
|
);
|
|
28044
29000
|
await Promise.all(workers);
|
|
28045
29001
|
};
|
|
28046
|
-
var acceptedReviewSchema =
|
|
28047
|
-
verdict:
|
|
28048
|
-
corrections:
|
|
29002
|
+
var acceptedReviewSchema = z73.looseObject({
|
|
29003
|
+
verdict: z73.unknown().optional(),
|
|
29004
|
+
corrections: z73.array(z73.unknown()).optional()
|
|
28049
29005
|
});
|
|
28050
29006
|
var previouslyAccepted = async (ctx, stage, batch) => {
|
|
28051
29007
|
if (!stageSpecs[stage].passes) {
|
|
28052
29008
|
return false;
|
|
28053
29009
|
}
|
|
28054
|
-
const own = await
|
|
29010
|
+
const own = await readFile39(
|
|
28055
29011
|
path43.join(ctx.dir, "OUT", stage, `${batch.index}.json`),
|
|
28056
29012
|
"utf8"
|
|
28057
29013
|
).catch(() => null);
|
|
@@ -28285,19 +29241,19 @@ var runStage = async (initial, stage, options = {}) => {
|
|
|
28285
29241
|
};
|
|
28286
29242
|
|
|
28287
29243
|
// src/codex-workflow/batch-layout.ts
|
|
28288
|
-
import { mkdir as mkdir19, readFile as
|
|
29244
|
+
import { mkdir as mkdir19, readFile as readFile40, writeFile as writeFile19 } from "node:fs/promises";
|
|
28289
29245
|
import path44 from "node:path";
|
|
28290
|
-
import { z as
|
|
28291
|
-
var layoutSchema =
|
|
28292
|
-
scope:
|
|
28293
|
-
size:
|
|
28294
|
-
batches:
|
|
29246
|
+
import { z as z74 } from "zod";
|
|
29247
|
+
var layoutSchema = z74.object({
|
|
29248
|
+
scope: z74.string(),
|
|
29249
|
+
size: z74.number().int().positive(),
|
|
29250
|
+
batches: z74.array(z74.array(z74.string()))
|
|
28295
29251
|
});
|
|
28296
29252
|
var stableBatchLayout = async (dir, { config, files, size }) => {
|
|
28297
29253
|
const file = path44.join(dir, "OUT", "batches.json");
|
|
28298
29254
|
const scope = contentHash(config);
|
|
28299
29255
|
const old = layoutSchema.safeParse(
|
|
28300
|
-
JSON.parse(await
|
|
29256
|
+
JSON.parse(await readFile40(file, "utf8").catch(() => "null"))
|
|
28301
29257
|
);
|
|
28302
29258
|
const layout = old.success && old.data.scope === scope && old.data.size === size ? old.data : { scope, size, batches: [] };
|
|
28303
29259
|
const assigned = new Set(layout.batches.flat());
|
|
@@ -28332,13 +29288,13 @@ var copyInputsOf = (source, extra = {}) => {
|
|
|
28332
29288
|
...extra
|
|
28333
29289
|
};
|
|
28334
29290
|
};
|
|
28335
|
-
var copyPayloadSchema =
|
|
29291
|
+
var copyPayloadSchema = z75.looseObject({
|
|
28336
29292
|
copy: aeoReportCopySchema,
|
|
28337
|
-
provenance:
|
|
28338
|
-
receipt:
|
|
28339
|
-
confidence:
|
|
28340
|
-
outcome:
|
|
28341
|
-
draft:
|
|
29293
|
+
provenance: z75.unknown().optional(),
|
|
29294
|
+
receipt: z75.unknown().optional(),
|
|
29295
|
+
confidence: z75.number(),
|
|
29296
|
+
outcome: z75.string(),
|
|
29297
|
+
draft: z75.unknown().optional(),
|
|
28342
29298
|
quality: aeoSnapshotSchema.shape.meta.shape.quality
|
|
28343
29299
|
});
|
|
28344
29300
|
var prepareWorkdir = async (source, dir, options = {}) => {
|
|
@@ -28435,13 +29391,13 @@ var prepareLockedWorkdir = async (source, dir, options) => {
|
|
|
28435
29391
|
}
|
|
28436
29392
|
};
|
|
28437
29393
|
};
|
|
28438
|
-
var savedVerifierMemorySchema =
|
|
28439
|
-
scope:
|
|
28440
|
-
history:
|
|
28441
|
-
|
|
28442
|
-
|
|
28443
|
-
|
|
28444
|
-
text:
|
|
29394
|
+
var savedVerifierMemorySchema = z75.object({
|
|
29395
|
+
scope: z75.string(),
|
|
29396
|
+
history: z75.record(
|
|
29397
|
+
z75.string(),
|
|
29398
|
+
z75.array(
|
|
29399
|
+
z75.object({
|
|
29400
|
+
text: z75.string(),
|
|
28445
29401
|
review: verdictSchemaFor([], []).shape.reviews.element
|
|
28446
29402
|
})
|
|
28447
29403
|
)
|
|
@@ -28469,7 +29425,7 @@ var withCopy = async (ctx, inputs) => {
|
|
|
28469
29425
|
});
|
|
28470
29426
|
const verifierMemory = {
|
|
28471
29427
|
read: async () => {
|
|
28472
|
-
const raw = await
|
|
29428
|
+
const raw = await readFile41(memoryFile, "utf8").catch(() => "null");
|
|
28473
29429
|
const saved = savedVerifierMemorySchema.parse(JSON.parse(raw));
|
|
28474
29430
|
return saved?.scope === memoryScope ? saved.history : {};
|
|
28475
29431
|
},
|
|
@@ -28643,12 +29599,12 @@ var report = (ctx, run, { reused = false } = {}) => {
|
|
|
28643
29599
|
ctx.log(` ${error.slice(0, 300)}`);
|
|
28644
29600
|
}
|
|
28645
29601
|
};
|
|
28646
|
-
var workflowStateSchema =
|
|
28647
|
-
stages:
|
|
29602
|
+
var workflowStateSchema = z75.looseObject({
|
|
29603
|
+
stages: z75.array(z75.record(z75.string(), z75.unknown())).optional()
|
|
28648
29604
|
});
|
|
28649
29605
|
var writeState = async (dir, run) => {
|
|
28650
29606
|
const file = path45.join(dir, "STATE.json");
|
|
28651
|
-
const raw = await
|
|
29607
|
+
const raw = await readFile41(file, "utf8").catch(() => "{}") || "{}";
|
|
28652
29608
|
const state = workflowStateSchema.parse(JSON.parse(raw));
|
|
28653
29609
|
state.stages = [
|
|
28654
29610
|
...state.stages ?? [],
|
|
@@ -28656,13 +29612,13 @@ var writeState = async (dir, run) => {
|
|
|
28656
29612
|
];
|
|
28657
29613
|
await writeFile20(file, JSON.stringify(state, null, 2));
|
|
28658
29614
|
};
|
|
28659
|
-
var recordedRunSchema =
|
|
28660
|
-
degraded:
|
|
28661
|
-
summary:
|
|
29615
|
+
var recordedRunSchema = z75.looseObject({
|
|
29616
|
+
degraded: z75.array(z75.string()).optional(),
|
|
29617
|
+
summary: z75.record(z75.string(), z75.unknown()).optional()
|
|
28662
29618
|
}).nullable();
|
|
28663
29619
|
var runOne = async (ctx, stage, { force, pass }) => {
|
|
28664
29620
|
if (!force && await isStageFresh(ctx, stage)) {
|
|
28665
|
-
const raw = await
|
|
29621
|
+
const raw = await readFile41(
|
|
28666
29622
|
path45.join(ctx.dir, "OUT", `${stage}.result.json`),
|
|
28667
29623
|
"utf8"
|
|
28668
29624
|
).catch(() => "null");
|
|
@@ -28687,7 +29643,7 @@ var runOne = async (ctx, stage, { force, pass }) => {
|
|
|
28687
29643
|
};
|
|
28688
29644
|
var deliverableCopy = async (ctx, inputs, written) => {
|
|
28689
29645
|
if (written.ok) {
|
|
28690
|
-
const raw = await
|
|
29646
|
+
const raw = await readFile41(path45.join(ctx.dir, "OUT", "write.json"), "utf8");
|
|
28691
29647
|
return copyPayloadSchema.parse(JSON.parse(raw));
|
|
28692
29648
|
}
|
|
28693
29649
|
const draft = {
|
|
@@ -28789,8 +29745,8 @@ var withoutAnswers = (ctx, files) => {
|
|
|
28789
29745
|
answers: ctx.answers.filter((answer) => !gone.has(answer.file))
|
|
28790
29746
|
};
|
|
28791
29747
|
};
|
|
28792
|
-
var correctionTrailSchema =
|
|
28793
|
-
|
|
29748
|
+
var correctionTrailSchema = z75.array(
|
|
29749
|
+
z75.looseObject({ outcome: z75.string().optional() })
|
|
28794
29750
|
);
|
|
28795
29751
|
var Scorecard = class {
|
|
28796
29752
|
#ctx;
|
|
@@ -28829,7 +29785,7 @@ var Scorecard = class {
|
|
|
28829
29785
|
async write(verdict) {
|
|
28830
29786
|
const { dir } = this.#ctx;
|
|
28831
29787
|
const review2 = await readStoredReview(dir);
|
|
28832
|
-
const trailText = await
|
|
29788
|
+
const trailText = await readFile41(path45.join(dir, "OUT", "corrections.json"), "utf8").catch(
|
|
28833
29789
|
() => "[]"
|
|
28834
29790
|
) || "[]";
|
|
28835
29791
|
const trail = correctionTrailSchema.parse(JSON.parse(trailText));
|
|
@@ -28871,7 +29827,7 @@ var Scorecard = class {
|
|
|
28871
29827
|
return card;
|
|
28872
29828
|
}
|
|
28873
29829
|
};
|
|
28874
|
-
var reviewProgressSchema =
|
|
29830
|
+
var reviewProgressSchema = z75.object({ rounds: z75.number(), digest: z75.string(), accepted: z75.boolean() }).nullable();
|
|
28875
29831
|
var runWorkflow = async (prepared, options = {}) => {
|
|
28876
29832
|
try {
|
|
28877
29833
|
return await runWorkflowSteps(prepared, options);
|
|
@@ -28913,7 +29869,7 @@ var runWorkflowSteps = async (prepared, options) => {
|
|
|
28913
29869
|
await ctx.checkpoint?.();
|
|
28914
29870
|
const progressFile = path45.join(ctx.dir, "REVIEW", "progress.json");
|
|
28915
29871
|
const savedProgress = reviewProgressSchema.parse(
|
|
28916
|
-
JSON.parse(await
|
|
29872
|
+
JSON.parse(await readFile41(progressFile, "utf8").catch(() => "null"))
|
|
28917
29873
|
);
|
|
28918
29874
|
const progress = !force && savedProgress?.digest === await stageInputsDigest(ctx, "review") ? savedProgress : null;
|
|
28919
29875
|
let rounds = progress?.rounds ?? 0;
|
|
@@ -29217,16 +30173,16 @@ var prepareRejudgment = async ({
|
|
|
29217
30173
|
};
|
|
29218
30174
|
|
|
29219
30175
|
// src/engine/author.ts
|
|
29220
|
-
import { readFile as
|
|
30176
|
+
import { readFile as readFile42, writeFile as writeFile22 } from "node:fs/promises";
|
|
29221
30177
|
import path47 from "node:path";
|
|
29222
|
-
import { z as
|
|
29223
|
-
var authorRecordSchema =
|
|
29224
|
-
version:
|
|
29225
|
-
runId:
|
|
29226
|
-
brief:
|
|
29227
|
-
proposed:
|
|
29228
|
-
notes:
|
|
29229
|
-
research:
|
|
30178
|
+
import { z as z76 } from "zod";
|
|
30179
|
+
var authorRecordSchema = z76.looseObject({
|
|
30180
|
+
version: z76.literal(1),
|
|
30181
|
+
runId: z76.string(),
|
|
30182
|
+
brief: z76.unknown(),
|
|
30183
|
+
proposed: z76.unknown(),
|
|
30184
|
+
notes: z76.unknown(),
|
|
30185
|
+
research: z76.unknown()
|
|
29230
30186
|
});
|
|
29231
30187
|
var proposalOf = (file) => {
|
|
29232
30188
|
const {
|
|
@@ -29238,7 +30194,7 @@ var proposalOf = (file) => {
|
|
|
29238
30194
|
return measured;
|
|
29239
30195
|
};
|
|
29240
30196
|
var readBrief = async (file) => {
|
|
29241
|
-
const text = await
|
|
30197
|
+
const text = await readFile42(file, "utf8").catch((err) => {
|
|
29242
30198
|
throw new Error(`Please check --brief: ${file} cannot be read.`, {
|
|
29243
30199
|
cause: err
|
|
29244
30200
|
});
|
|
@@ -29388,7 +30344,7 @@ var readAuthorEvidence = async (configFile, file) => {
|
|
|
29388
30344
|
return { kind: "manual" };
|
|
29389
30345
|
}
|
|
29390
30346
|
const reference2 = file.author;
|
|
29391
|
-
const text = await
|
|
30347
|
+
const text = await readFile42(
|
|
29392
30348
|
path47.join(path47.dirname(configFile), reference2.record),
|
|
29393
30349
|
"utf8"
|
|
29394
30350
|
).catch((err) => {
|
|
@@ -30155,9 +31111,9 @@ var executeRun = async ({
|
|
|
30155
31111
|
import path50 from "node:path";
|
|
30156
31112
|
|
|
30157
31113
|
// src/engine/run-status.ts
|
|
30158
|
-
import { readFile as
|
|
31114
|
+
import { readFile as readFile43, stat as stat3 } from "node:fs/promises";
|
|
30159
31115
|
import path49 from "node:path";
|
|
30160
|
-
import { z as
|
|
31116
|
+
import { z as z77 } from "zod";
|
|
30161
31117
|
var SpendCategory = {
|
|
30162
31118
|
PROBES: "probes",
|
|
30163
31119
|
STAGES: "stages",
|
|
@@ -30176,31 +31132,31 @@ var spendCategoryOf = (role) => {
|
|
|
30176
31132
|
}
|
|
30177
31133
|
return SpendCategory.HOST_CALLS;
|
|
30178
31134
|
};
|
|
30179
|
-
var ledgerCallSchema =
|
|
30180
|
-
callId:
|
|
30181
|
-
role:
|
|
30182
|
-
reservedUsd:
|
|
30183
|
-
inputTokens:
|
|
30184
|
-
maxOutputTokens:
|
|
30185
|
-
usage:
|
|
30186
|
-
costUsd:
|
|
30187
|
-
inputTokens:
|
|
30188
|
-
outputTokens:
|
|
31135
|
+
var ledgerCallSchema = z77.looseObject({
|
|
31136
|
+
callId: z77.string(),
|
|
31137
|
+
role: z77.string(),
|
|
31138
|
+
reservedUsd: z77.number(),
|
|
31139
|
+
inputTokens: z77.number(),
|
|
31140
|
+
maxOutputTokens: z77.number(),
|
|
31141
|
+
usage: z77.looseObject({
|
|
31142
|
+
costUsd: z77.number().optional(),
|
|
31143
|
+
inputTokens: z77.number().optional(),
|
|
31144
|
+
outputTokens: z77.number().optional()
|
|
30189
31145
|
}).optional()
|
|
30190
31146
|
});
|
|
30191
|
-
var ledgerSchema =
|
|
30192
|
-
limits:
|
|
30193
|
-
calls:
|
|
31147
|
+
var ledgerSchema = z77.looseObject({
|
|
31148
|
+
limits: z77.looseObject({ maxUsd: z77.number(), deadlineAt: z77.string() }),
|
|
31149
|
+
calls: z77.record(z77.string(), ledgerCallSchema)
|
|
30194
31150
|
});
|
|
30195
|
-
var budgetStateSchema2 =
|
|
30196
|
-
current:
|
|
30197
|
-
deadlineAt:
|
|
30198
|
-
model:
|
|
31151
|
+
var budgetStateSchema2 = z77.looseObject({
|
|
31152
|
+
current: z77.looseObject({ maxUsd: z77.number() }),
|
|
31153
|
+
deadlineAt: z77.string(),
|
|
31154
|
+
model: z77.string().optional()
|
|
30199
31155
|
});
|
|
30200
31156
|
var workflowStages = ["analyze", "qualify", "review", "write"];
|
|
30201
31157
|
var readText2 = async (file) => {
|
|
30202
31158
|
try {
|
|
30203
|
-
return await
|
|
31159
|
+
return await readFile43(file, "utf8");
|
|
30204
31160
|
} catch (err) {
|
|
30205
31161
|
if (hasErrorCode(err, "ENOENT")) {
|
|
30206
31162
|
return void 0;
|