literally-aeo 0.4.2 → 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 +1503 -548
- package/dist/lib/agents/methodology.js +3 -3
- package/dist/lib/bundle/contracts.js +1 -1
- package/dist/lib/bundle/export.js +12 -12
- package/dist/lib/bundle/journal.js +2 -2
- package/dist/lib/bundle/project-journal.js +5 -5
- package/dist/lib/bundle/project.js +10 -10
- package/dist/lib/bundle/read.js +13 -13
- 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-22SP35NA.js → chunk-2ANSPIUT.js} +1 -1
- package/dist/lib/chunks/{chunk-ITLJZUKL.js → chunk-54GMIPWV.js} +1 -1
- package/dist/lib/chunks/{chunk-QJX6YXXQ.js → chunk-65OIYOUH.js} +2 -2
- package/dist/lib/chunks/{chunk-ENPRRXH5.js → chunk-6MGXILUJ.js} +1 -1
- package/dist/lib/chunks/chunk-6OURIXQZ.js +472 -0
- package/dist/lib/chunks/{chunk-AMK6IHJD.js → chunk-746643QV.js} +1 -1
- package/dist/lib/chunks/{chunk-AMF3T5A3.js → chunk-74K4E3ZS.js} +1 -1
- package/dist/lib/chunks/{chunk-5EM6J7TG.js → chunk-7HCVSLVG.js} +1 -1
- package/dist/lib/chunks/{chunk-RWVXK7XE.js → chunk-7K2XT3WI.js} +5 -5
- package/dist/lib/chunks/{chunk-VOK4TUXV.js → chunk-7L4Y6N3V.js} +1 -1
- package/dist/lib/chunks/{chunk-TD47AB37.js → chunk-7QWT7LFM.js} +2 -2
- package/dist/lib/chunks/{chunk-ATKP5ZW6.js → chunk-7SA2CRSS.js} +1 -1
- package/dist/lib/chunks/{chunk-Q6TZB2OQ.js → chunk-ARKZ5PJN.js} +1 -1
- package/dist/lib/chunks/{chunk-FBMO6UV4.js → chunk-B6XGNJUU.js} +1 -1
- package/dist/lib/chunks/{chunk-RR63UE5H.js → chunk-BNX7S4GK.js} +4 -4
- package/dist/lib/chunks/chunk-BWBPEXEU.js +83 -0
- package/dist/lib/chunks/{chunk-DKR7LSP2.js → chunk-BZAPAGXM.js} +1 -1
- package/dist/lib/chunks/{chunk-FFDMGNRO.js → chunk-C2Q7YE7Y.js} +6 -6
- package/dist/lib/chunks/{chunk-NWABYXDQ.js → chunk-D2LJMNH3.js} +2 -2
- package/dist/lib/chunks/{chunk-XT5M3PPQ.js → chunk-EVEJ3MFU.js} +3 -3
- package/dist/lib/chunks/{chunk-U4AROC2Z.js → chunk-GC7DISQO.js} +1 -1
- package/dist/lib/chunks/{chunk-YRXYTCMY.js → chunk-JHUI2K5X.js} +1 -1
- package/dist/lib/chunks/chunk-JQFLWUCA.js +123 -0
- package/dist/lib/chunks/{chunk-HJEIEMPE.js → chunk-JREYIUNG.js} +4 -4
- package/dist/lib/chunks/{chunk-FXCUGNFL.js → chunk-JXQOWHWB.js} +1 -1
- package/dist/lib/chunks/{chunk-BKAERR7J.js → chunk-KFJ5O5CL.js} +2 -2
- package/dist/lib/chunks/{chunk-6P7EZJI7.js → chunk-KSJ3NZIJ.js} +4 -2
- package/dist/lib/chunks/{chunk-EZ23TKTX.js → chunk-L5HFTFFG.js} +2 -2
- package/dist/lib/chunks/{chunk-DI4LZR37.js → chunk-LJD37WAV.js} +2 -2
- package/dist/lib/chunks/{chunk-YPGJN232.js → chunk-MKA2EP7M.js} +1 -1
- package/dist/lib/chunks/{chunk-JN4332MJ.js → chunk-MMJ5UR2E.js} +1 -1
- package/dist/lib/chunks/{chunk-A2RW4ZMR.js → chunk-MQFFMD4Q.js} +1 -1
- package/dist/lib/chunks/{chunk-CRXJFOCK.js → chunk-NM2LUMQT.js} +4 -4
- package/dist/lib/chunks/{chunk-RYV25YGT.js → chunk-P5VVHTZU.js} +1 -1
- package/dist/lib/chunks/{chunk-JKBXKACC.js → chunk-PFG3ESJE.js} +7 -7
- package/dist/lib/chunks/{chunk-OF3WIGG7.js → chunk-Q7CWM6LZ.js} +6 -6
- package/dist/lib/chunks/{chunk-DU3MAXVC.js → chunk-R5NLULQW.js} +1 -1
- package/dist/lib/chunks/{chunk-T5Q5CBTA.js → chunk-RM7U5M5L.js} +1 -1
- package/dist/lib/chunks/{chunk-JGBJQ3TO.js → chunk-RQ6GUJI5.js} +1 -1
- package/dist/lib/chunks/{chunk-CMB2KSW2.js → chunk-RUSMX6JH.js} +16 -7
- package/dist/lib/chunks/{chunk-KFYTORIT.js → chunk-UNNRLD2U.js} +4 -4
- package/dist/lib/chunks/chunk-VFN2J4Z3.js +626 -0
- package/dist/lib/chunks/{chunk-3DVFQMJT.js → chunk-VPJN2GNC.js} +1 -1
- package/dist/lib/chunks/{chunk-NZOKSFIA.js → chunk-XSOTCSD3.js} +3 -3
- package/dist/lib/chunks/{chunk-M4XGUJMO.js → chunk-YX4EH6FR.js} +1 -1
- package/dist/lib/chunks/{chunk-WIRVKAYB.js → chunk-ZC4MKS3J.js} +11 -11
- package/dist/lib/chunks/{chunk-KC35BXW7.js → chunk-ZM4RHMBI.js} +1 -1
- package/dist/lib/cli/bundle-commands.js +57 -32
- package/dist/lib/cli/guide-command.js +1 -1
- package/dist/lib/cli/run-commands.js +36 -36
- package/dist/lib/cli/status-command.js +18 -18
- package/dist/lib/codex-workflow/aggregate.js +2 -2
- package/dist/lib/codex-workflow/author.js +3 -3
- package/dist/lib/codex-workflow/capture.js +5 -5
- package/dist/lib/codex-workflow/copy-editor.js +3 -3
- package/dist/lib/codex-workflow/copy.js +2 -2
- package/dist/lib/codex-workflow/finish.js +5 -5
- package/dist/lib/codex-workflow/loop.js +13 -13
- package/dist/lib/codex-workflow/run-source.js +5 -5
- package/dist/lib/codex-workflow/stage.js +4 -4
- package/dist/lib/engine/audit-file.js +3 -3
- package/dist/lib/engine/author.js +10 -10
- package/dist/lib/engine/cost-estimate.js +3 -3
- package/dist/lib/engine/local-run.js +17 -17
- package/dist/lib/engine/preflight.js +3 -3
- package/dist/lib/engine/rejudge.js +24 -24
- package/dist/lib/engine/resources.js +1 -1
- package/dist/lib/engine/run-bindings.js +3 -3
- package/dist/lib/engine/run-method.js +2 -2
- package/dist/lib/engine/run-models.js +4 -4
- package/dist/lib/engine/run-status.js +18 -18
- 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/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/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/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(
|
|
@@ -23631,68 +23644,282 @@ var runPreflight = async (args) => {
|
|
|
23631
23644
|
return checks;
|
|
23632
23645
|
};
|
|
23633
23646
|
|
|
23634
|
-
// src/
|
|
23635
|
-
import {
|
|
23636
|
-
import
|
|
23637
|
-
|
|
23638
|
-
|
|
23639
|
-
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
|
+
};
|
|
23640
23708
|
|
|
23641
23709
|
// src/viewer/page.ts
|
|
23642
23710
|
var styles = `
|
|
23643
23711
|
:root {
|
|
23644
|
-
--
|
|
23645
|
-
--
|
|
23646
|
-
--
|
|
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. */
|
|
23647
23720
|
color-scheme: light;
|
|
23648
23721
|
}
|
|
23649
|
-
@media (prefers-color-scheme: dark) {
|
|
23650
|
-
:root {
|
|
23651
|
-
--bg: #111317; --fg: #e8eaee; --muted: #9aa1ad; --line: #2a2e36;
|
|
23652
|
-
--panel: #181b21; --accent: #8fa2ff; --pass: #5fd08f; --fail: #ff8a80;
|
|
23653
|
-
--warn: #e5b45a;
|
|
23654
|
-
color-scheme: dark;
|
|
23655
|
-
}
|
|
23656
|
-
}
|
|
23657
23722
|
* { box-sizing: border-box; }
|
|
23658
|
-
|
|
23659
|
-
|
|
23660
|
-
|
|
23661
|
-
h1
|
|
23662
|
-
|
|
23663
|
-
|
|
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); }
|
|
23664
23732
|
.muted { color: var(--muted); }
|
|
23665
|
-
.
|
|
23666
|
-
|
|
23667
|
-
.
|
|
23668
|
-
.
|
|
23669
|
-
|
|
23670
|
-
|
|
23671
|
-
.
|
|
23672
|
-
|
|
23673
|
-
|
|
23674
|
-
|
|
23675
|
-
|
|
23676
|
-
.
|
|
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); }
|
|
23677
23773
|
.tip[hidden] { display: none; }
|
|
23678
|
-
|
|
23679
|
-
|
|
23680
|
-
|
|
23681
|
-
|
|
23682
|
-
|
|
23683
|
-
|
|
23684
|
-
|
|
23685
|
-
|
|
23686
|
-
|
|
23687
|
-
|
|
23688
|
-
|
|
23689
|
-
|
|
23690
|
-
|
|
23691
|
-
|
|
23692
|
-
.
|
|
23693
|
-
|
|
23694
|
-
|
|
23695
|
-
|
|
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
|
+
}
|
|
23696
23923
|
`;
|
|
23697
23924
|
var script = `
|
|
23698
23925
|
const token = new URLSearchParams(location.search).get('t');
|
|
@@ -23708,46 +23935,31 @@ const el = (tag, attrs = {}, ...children) => {
|
|
|
23708
23935
|
else if (key.startsWith('on')) node.addEventListener(key.slice(2), value);
|
|
23709
23936
|
else node.setAttribute(key, value);
|
|
23710
23937
|
}
|
|
23711
|
-
for (const child of children) {
|
|
23712
|
-
if (child === null || child === undefined) continue;
|
|
23938
|
+
for (const child of children.flat()) {
|
|
23939
|
+
if (child === null || child === undefined || child === false) continue;
|
|
23713
23940
|
node.append(typeof child === 'string' ? document.createTextNode(child) : child);
|
|
23714
23941
|
}
|
|
23715
23942
|
return node;
|
|
23716
23943
|
};
|
|
23717
|
-
const
|
|
23718
|
-
|
|
23719
|
-
|
|
23720
|
-
const
|
|
23721
|
-
|
|
23722
|
-
|
|
23723
|
-
|
|
23724
|
-
|
|
23725
|
-
evidence && isShare(evidence.low) && isShare(evidence.high) && evidence.low <= evidence.high
|
|
23726
|
-
&& isCount(evidence.count) && isCount(evidence.captured) && isCount(evidence.planned)
|
|
23727
|
-
? evidence : null;
|
|
23728
|
-
// Outward to whole percents, so the range shown always contains the computed
|
|
23729
|
-
// interval. The bounds are stored to 6 decimals; scaling them to an integer
|
|
23730
|
-
// first keeps a bound of 0.07 (7.000000000000001 once multiplied) at 7%.
|
|
23731
|
-
// The rule of report/core/rate-interval.ts, repeated here because this page
|
|
23732
|
-
// is one self-contained script; page.spec.ts holds the two to the same
|
|
23733
|
-
// answers.
|
|
23734
|
-
const intervalText = (evidence) =>
|
|
23735
|
-
Math.floor(Math.round(evidence.low * 1e6) / 1e4) + '\u2013'
|
|
23736
|
-
+ 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
|
+
|
|
23737
23952
|
// The counts behind an interval, in a tooltip (WCAG 1.4.13). It opens on
|
|
23738
23953
|
// hover, on keyboard focus and on a tap; it stays open while the pointer is
|
|
23739
23954
|
// over it; Escape closes it; and a screen reader reads it as the interval's
|
|
23740
23955
|
// description. It sits in the flow under the interval, so a scrolling table
|
|
23741
23956
|
// cannot clip it and it hides nothing.
|
|
23742
|
-
const tipDismissals = [];
|
|
23743
|
-
document.addEventListener('keydown', (event) => {
|
|
23744
|
-
if (event.key === 'Escape') for (const dismiss of tipDismissals) dismiss();
|
|
23745
|
-
});
|
|
23746
23957
|
let tipCount = 0;
|
|
23747
|
-
const
|
|
23958
|
+
const intervalOf = (interval) => {
|
|
23959
|
+
if (!interval) return null;
|
|
23748
23960
|
tipCount += 1;
|
|
23749
23961
|
const id = 'tip-' + tipCount;
|
|
23750
|
-
const tip = el('span', { class: 'tip', role: 'tooltip', id, hidden: '' },
|
|
23962
|
+
const tip = el('span', { class: 'tip', role: 'tooltip', id, hidden: '' }, interval.counts);
|
|
23751
23963
|
let hovered = false;
|
|
23752
23964
|
let focused = false;
|
|
23753
23965
|
const sync = () => {
|
|
@@ -23755,193 +23967,351 @@ const withTip = (label, name, text) => {
|
|
|
23755
23967
|
else tip.setAttribute('hidden', '');
|
|
23756
23968
|
};
|
|
23757
23969
|
const trigger = el('button', { type: 'button', class: 'tip-trigger',
|
|
23758
|
-
'aria-label':
|
|
23970
|
+
'aria-label': interval.label, 'aria-describedby': id,
|
|
23759
23971
|
// Safari focuses no button on a click or a tap, and a button that kept
|
|
23760
23972
|
// focus through Escape gets no new focus event: a click (or Enter or
|
|
23761
23973
|
// Space) opens the tip itself, until focus moves on.
|
|
23762
23974
|
onclick: () => { trigger.focus(); focused = true; sync(); },
|
|
23763
23975
|
onfocus: () => { focused = true; sync(); },
|
|
23764
23976
|
onblur: () => { focused = false; sync(); },
|
|
23765
|
-
},
|
|
23766
|
-
|
|
23977
|
+
}, interval.text);
|
|
23978
|
+
dismissals.push(() => { hovered = false; focused = false; sync(); });
|
|
23767
23979
|
return el('span', { class: 'interval',
|
|
23768
23980
|
onmouseenter: () => { hovered = true; sync(); },
|
|
23769
23981
|
onmouseleave: () => { hovered = false; sync(); },
|
|
23770
23982
|
}, trigger, tip);
|
|
23771
23983
|
};
|
|
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
|
-
|
|
23814
|
-
|
|
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)))));
|
|
23815
24241
|
|
|
23816
24242
|
const render = async () => {
|
|
23817
24243
|
const root = document.getElementById('app');
|
|
23818
|
-
const [info,
|
|
23819
|
-
get('__viewer'), get('__verification'), get('report/snapshot.json'),
|
|
23820
|
-
get('captures/units.json'), get('inputs/config.json'),
|
|
23821
|
-
]);
|
|
24244
|
+
const [info, result, report] = await Promise.all([get('__viewer'), get('__verification'), get('__report')]);
|
|
23822
24245
|
root.replaceChildren();
|
|
23823
|
-
if (!info) {
|
|
23824
|
-
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.'));
|
|
23825
24248
|
return;
|
|
23826
24249
|
}
|
|
23827
|
-
const
|
|
23828
|
-
|
|
23829
|
-
root.append(
|
|
23830
|
-
el('h1', {}, brand + ': AI visibility audit'),
|
|
23831
|
-
el('p', { class: 'muted' }, info.originLabel + ' \xB7 ' + info.source),
|
|
23832
|
-
);
|
|
24250
|
+
const sheet = createSheet();
|
|
24251
|
+
const shown = report.outcome === 'shown';
|
|
23833
24252
|
if (info.workingState) {
|
|
23834
|
-
root.append(el('div', { class: 'banner
|
|
24253
|
+
root.append(el('div', { class: 'banner' },
|
|
23835
24254
|
'Working state, not a finalized revision: this is not an integrity receipt. Export the run to finalize it.'));
|
|
23836
24255
|
}
|
|
23837
|
-
|
|
23838
|
-
|
|
23839
|
-
|
|
23840
|
-
|
|
23841
|
-
|
|
23842
|
-
|
|
23843
|
-
|
|
23844
|
-
|
|
23845
|
-
|
|
23846
|
-
|
|
23847
|
-
|
|
23848
|
-
|
|
23849
|
-
|
|
23850
|
-
|
|
23851
|
-
}
|
|
23852
|
-
const
|
|
23853
|
-
|
|
23854
|
-
|
|
23855
|
-
|
|
23856
|
-
|
|
23857
|
-
|
|
23858
|
-
|
|
23859
|
-
|
|
23860
|
-
|
|
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
|
+
]);
|
|
23861
24282
|
}
|
|
23862
|
-
|
|
23863
|
-
|
|
23864
|
-
|
|
23865
|
-
|
|
23866
|
-
|
|
23867
|
-
|
|
23868
|
-
|
|
23869
|
-
|
|
23870
|
-
|
|
23871
|
-
|
|
23872
|
-
|
|
23873
|
-
root.append(el('div', { class: 'grid' },
|
|
23874
|
-
rateStat('Assistant share of voice', summary.prospectShareOfVoice,
|
|
23875
|
-
summary.prospectShareOfVoiceEvidence, 'Mentioned'),
|
|
23876
|
-
rateStat('Assistant citation rate', summary.prospectCitationRate,
|
|
23877
|
-
summary.prospectCitationRateEvidence, 'Cited'),
|
|
23878
|
-
rateStat('Coding-agent share of voice', summary.agentShareOfVoice,
|
|
23879
|
-
summary.agentShareOfVoiceEvidence, 'Mentioned'),
|
|
23880
|
-
rateStat('Coding-agent citation rate', summary.agentCitationRate,
|
|
23881
|
-
summary.agentCitationRateEvidence, 'Cited'),
|
|
23882
|
-
// The scraped consumer apps, only for a run that planned one.
|
|
23883
|
-
...(summary.consumerShareOfVoice === undefined ? [] : [
|
|
23884
|
-
rateStat('Consumer-app share of voice', summary.consumerShareOfVoice,
|
|
23885
|
-
summary.consumerShareOfVoiceEvidence, 'Mentioned'),
|
|
23886
|
-
rateStat('Consumer-app citation rate', summary.consumerCitationRate,
|
|
23887
|
-
summary.consumerCitationRateEvidence, 'Cited'),
|
|
23888
|
-
]),
|
|
23889
|
-
el('div', { class: 'stat' }, el('b', {}, summary.topCompetitorDomain || 'none'), 'Most mentioned competitor'),
|
|
23890
|
-
));
|
|
23891
|
-
root.append(el('p', { class: 'muted' },
|
|
23892
|
-
'Share of voice is how often the measured answers name the product, not market share.'));
|
|
23893
|
-
root.append(...modelTable(summary.byModel, labelOf));
|
|
23894
|
-
const drawer = el('div', { class: 'drawer', hidden: '' });
|
|
23895
|
-
const body = el('tbody');
|
|
23896
|
-
for (const row of matrix) {
|
|
23897
|
-
const prompt = prompts[row.promptIdx] || { text: '' };
|
|
23898
|
-
const promptId = (promptIds.get(section.key) || [])[row.promptIdx];
|
|
23899
|
-
const record = answers.get(answerKey(section.key, promptId, row.surface, row.runIndex || 0));
|
|
23900
|
-
const open = () => {
|
|
23901
|
-
drawer.removeAttribute('hidden');
|
|
23902
|
-
drawer.replaceChildren(
|
|
23903
|
-
el('h3', {}, labelOf(row.surface) + ', run ' + (row.runIndex || 0)),
|
|
23904
|
-
el('p', {}, prompt.text),
|
|
23905
|
-
record ? el('pre', {}, record.probe.text)
|
|
23906
|
-
: el('p', { class: 'limited' }, 'The answer is not in this bundle.'),
|
|
23907
|
-
...(row.citedUrls && row.citedUrls.length
|
|
23908
|
-
? [el('h3', {}, 'Cited sources'), ...row.citedUrls.map((url) => el('div', {}, sourceLink(url)))]
|
|
23909
|
-
: []),
|
|
23910
|
-
);
|
|
23911
|
-
drawer.scrollIntoView({ block: 'nearest' });
|
|
23912
|
-
};
|
|
23913
|
-
body.append(el('tr', { class: 'row', tabindex: '0', onclick: open,
|
|
23914
|
-
onkeydown: (event) => { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); open(); } } },
|
|
23915
|
-
el('td', {}, prompt.text),
|
|
23916
|
-
el('td', {}, labelOf(row.surface)),
|
|
23917
|
-
el('td', {}, String(row.runIndex || 0)),
|
|
23918
|
-
el('td', {}, row.prospectMentioned ? 'mentioned' + (row.prospectPosition ? ' (' + row.prospectPosition + ')' : '') : 'not mentioned'),
|
|
23919
|
-
el('td', {}, (row.qualifiedCompetitors || []).map((entry) => entry.name).join(', ')),
|
|
23920
|
-
));
|
|
23921
|
-
}
|
|
23922
|
-
root.append(el('div', { class: 'table-wrap' }, el('table', {},
|
|
23923
|
-
el('thead', {}, el('tr', {}, el('th', {}, 'Question'), el('th', {}, 'Surface'),
|
|
23924
|
-
el('th', {}, 'Run'), el('th', {}, 'Product'), el('th', {}, 'Alternatives named'))),
|
|
23925
|
-
body)), drawer);
|
|
23926
|
-
}
|
|
23927
|
-
const methodology = snapshot.meta && Array.isArray(snapshot.meta.methodology)
|
|
23928
|
-
? snapshot.meta.methodology.filter((sentence) => typeof sentence === 'string')
|
|
23929
|
-
: [];
|
|
23930
|
-
if (methodology.length) {
|
|
23931
|
-
root.append(el('h2', {}, 'Methodology'),
|
|
23932
|
-
el('ul', { class: 'methodology' },
|
|
23933
|
-
...methodology.map((sentence) => el('li', {}, sentence))));
|
|
23934
|
-
}
|
|
23935
|
-
root.append(el('footer', {},
|
|
23936
|
-
'Generated with Literally.dev AEO, an open-source AI visibility audit tool. ',
|
|
23937
|
-
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);
|
|
23938
24294
|
};
|
|
23939
24295
|
|
|
23940
24296
|
render().catch((error) => {
|
|
23941
24297
|
document.getElementById('app').textContent = 'The viewer could not load this bundle: ' + error.message;
|
|
23942
24298
|
});
|
|
23943
24299
|
`;
|
|
23944
|
-
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);
|
|
23945
24315
|
return `<!doctype html>
|
|
23946
24316
|
<html lang="en">
|
|
23947
24317
|
<head>
|
|
@@ -23949,23 +24319,649 @@ var viewerPage = (nonce) => {
|
|
|
23949
24319
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
23950
24320
|
<meta name="referrer" content="no-referrer">
|
|
23951
24321
|
<title>Literally.dev AEO</title>
|
|
23952
|
-
<style nonce="${nonce}">${styles}</style>
|
|
24322
|
+
<style nonce="${nonce}">${faces}${styles}</style>
|
|
23953
24323
|
</head>
|
|
23954
24324
|
<body>
|
|
23955
|
-
<main id="app"><p class="
|
|
24325
|
+
<main id="app"><p class="container">Loading the audit\u2026</p></main>
|
|
23956
24326
|
<script nonce="${nonce}">${script}</script>
|
|
23957
24327
|
</body>
|
|
23958
24328
|
</html>`;
|
|
23959
24329
|
};
|
|
23960
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
|
+
|
|
23961
24957
|
// src/viewer/server.ts
|
|
23962
24958
|
var originLabels = {
|
|
23963
24959
|
[RunOrigin.LOCAL]: "Run locally by the report owner",
|
|
23964
24960
|
[RunOrigin.HOSTED]: "Run by Literally.dev",
|
|
23965
24961
|
[RunOrigin.LEGACY_IMPORT]: "Imported from a run without an execution trace"
|
|
23966
24962
|
};
|
|
23967
|
-
var manifestOriginSchema =
|
|
23968
|
-
run:
|
|
24963
|
+
var manifestOriginSchema = z64.looseObject({
|
|
24964
|
+
run: z64.looseObject({ origin: z64.string() })
|
|
23969
24965
|
});
|
|
23970
24966
|
var sameToken = (expected, received) => {
|
|
23971
24967
|
if (received === null) {
|
|
@@ -24012,10 +25008,11 @@ var derivedDocuments = (bundle) => {
|
|
|
24012
25008
|
originLabel: origin === void 0 ? "Run locally by the report owner" : originLabels[origin] ?? "Origin unknown"
|
|
24013
25009
|
}
|
|
24014
25010
|
],
|
|
24015
|
-
["__verification", bundle.workingState ? null : verification]
|
|
25011
|
+
["__verification", bundle.workingState ? null : verification],
|
|
25012
|
+
["__report", presentReport(bundle.files)]
|
|
24016
25013
|
]);
|
|
24017
25014
|
};
|
|
24018
|
-
var startViewer = async (bundle, { port = 0 } = {}) => {
|
|
25015
|
+
var startViewer = async (bundle, { port = 0, fonts = /* @__PURE__ */ new Map() } = {}) => {
|
|
24019
25016
|
const token = randomBytes2(32).toString("hex");
|
|
24020
25017
|
const derived = derivedDocuments(bundle);
|
|
24021
25018
|
let host = "";
|
|
@@ -24033,12 +25030,17 @@ var startViewer = async (bundle, { port = 0 } = {}) => {
|
|
|
24033
25030
|
const nonce = randomBytes2(16).toString("base64");
|
|
24034
25031
|
send(response, {
|
|
24035
25032
|
status: 200,
|
|
24036
|
-
body: viewerPage(nonce),
|
|
25033
|
+
body: viewerPage(nonce, fonts.size > 0 ? token : void 0),
|
|
24037
25034
|
contentType: "text/html; charset=utf-8",
|
|
24038
|
-
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'`
|
|
24039
25036
|
});
|
|
24040
25037
|
return;
|
|
24041
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
|
+
}
|
|
24042
25044
|
const file = decodeURIComponent(url.pathname.replace(/^\/data\//, ""));
|
|
24043
25045
|
const derivedDocument = derived.get(file);
|
|
24044
25046
|
if (url.pathname.startsWith("/data/") && derivedDocument !== void 0) {
|
|
@@ -24188,10 +25190,10 @@ var runExport = async (flags, usage) => {
|
|
|
24188
25190
|
if (dir === void 0) {
|
|
24189
25191
|
throw new Error(usage);
|
|
24190
25192
|
}
|
|
24191
|
-
if (await runDirectoryState(
|
|
25193
|
+
if (await runDirectoryState(path34.resolve(dir)) === "new") {
|
|
24192
25194
|
writeErr(
|
|
24193
25195
|
[
|
|
24194
|
-
`${
|
|
25196
|
+
`${path34.resolve(dir)} holds no run to export (it has no INPUTS.json).`,
|
|
24195
25197
|
` A local run: measure first with literally-aeo run --output ${dir}`,
|
|
24196
25198
|
` A hosted work directory from before INPUTS.json: pnpm aeo:codex prepare --report <reportKey> --workdir ${dir}`
|
|
24197
25199
|
].join("\n")
|
|
@@ -24200,7 +25202,7 @@ var runExport = async (flags, usage) => {
|
|
|
24200
25202
|
}
|
|
24201
25203
|
const settings = await readSettings(flags.options.get("--env-file"));
|
|
24202
25204
|
const redactFile = flags.options.get("--redact");
|
|
24203
|
-
const redactions = redactFile ? await readRedactions(
|
|
25205
|
+
const redactions = redactFile ? await readRedactions(path34.resolve(redactFile)) : void 0;
|
|
24204
25206
|
try {
|
|
24205
25207
|
const result = await exportRun(dir, {
|
|
24206
25208
|
output: flags.options.get("--output"),
|
|
@@ -24261,7 +25263,7 @@ var runVerify = async (flags, usage) => {
|
|
|
24261
25263
|
writeErr(err.message);
|
|
24262
25264
|
return 1;
|
|
24263
25265
|
}
|
|
24264
|
-
verification = refusedVerification(
|
|
25266
|
+
verification = refusedVerification(path34.resolve(target), {
|
|
24265
25267
|
id: "bundle.integrity",
|
|
24266
25268
|
title: "Bundle integrity",
|
|
24267
25269
|
outcome: "fail",
|
|
@@ -24275,12 +25277,26 @@ var runVerify = async (flags, usage) => {
|
|
|
24275
25277
|
);
|
|
24276
25278
|
return verification.exitCode;
|
|
24277
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
|
+
};
|
|
24278
25294
|
var runView = async (flags, usage) => {
|
|
24279
25295
|
const target = flags.positional[0];
|
|
24280
25296
|
if (target === void 0) {
|
|
24281
25297
|
throw new Error(usage);
|
|
24282
25298
|
}
|
|
24283
|
-
const resolved =
|
|
25299
|
+
const resolved = path34.resolve(target);
|
|
24284
25300
|
const revisions = await readFinalizedRevisions(resolved).catch(() => []);
|
|
24285
25301
|
const isRunDirectory = await runDirectoryState(resolved).then(
|
|
24286
25302
|
(state) => state !== "new",
|
|
@@ -24294,7 +25310,8 @@ var runView = async (flags, usage) => {
|
|
|
24294
25310
|
} : { ...await readBundleSource(resolved), workingState: false };
|
|
24295
25311
|
const portOption = flags.options.get("--port");
|
|
24296
25312
|
const viewer = await startViewer(bundle, {
|
|
24297
|
-
port: portOption === void 0 ? 0 : Number(portOption)
|
|
25313
|
+
port: portOption === void 0 ? 0 : Number(portOption),
|
|
25314
|
+
fonts: await readViewerFonts()
|
|
24298
25315
|
});
|
|
24299
25316
|
writeOut(
|
|
24300
25317
|
flags.switches.has("--json") ? JSON.stringify({ resultVersion: 1, command: "view", url: viewer.url }) : `Viewing ${bundle.description}
|
|
@@ -24310,72 +25327,10 @@ Press Ctrl-C to stop.`
|
|
|
24310
25327
|
};
|
|
24311
25328
|
|
|
24312
25329
|
// src/cli/guide-command.ts
|
|
24313
|
-
import { readFile as
|
|
24314
|
-
|
|
24315
|
-
// src/engine/resources.ts
|
|
24316
|
-
import { access as access2 } from "node:fs/promises";
|
|
24317
|
-
import path34 from "node:path";
|
|
24318
|
-
|
|
24319
|
-
// src/engine/package-root.ts
|
|
24320
|
-
import { readFileSync as readFileSync2 } from "node:fs";
|
|
24321
|
-
import path33 from "node:path";
|
|
24322
|
-
import { fileURLToPath } from "node:url";
|
|
24323
|
-
var enginePackageName = "literally-aeo";
|
|
24324
|
-
var isEngineManifest = (file) => {
|
|
24325
|
-
try {
|
|
24326
|
-
const manifest = JSON.parse(readFileSync2(file, "utf8"));
|
|
24327
|
-
return typeof manifest === "object" && manifest !== null && "name" in manifest && manifest.name === enginePackageName;
|
|
24328
|
-
} catch {
|
|
24329
|
-
return false;
|
|
24330
|
-
}
|
|
24331
|
-
};
|
|
24332
|
-
var enginePackageRoot = () => {
|
|
24333
|
-
const start = path33.dirname(fileURLToPath(import.meta.url));
|
|
24334
|
-
let dir = start;
|
|
24335
|
-
for (; ; ) {
|
|
24336
|
-
if (isEngineManifest(path33.join(dir, "package.json"))) {
|
|
24337
|
-
return dir;
|
|
24338
|
-
}
|
|
24339
|
-
const parent = path33.dirname(dir);
|
|
24340
|
-
if (parent === dir) {
|
|
24341
|
-
throw new Error(
|
|
24342
|
-
`No ${enginePackageName} package.json above ${start}; the engine runs from its own package.`
|
|
24343
|
-
);
|
|
24344
|
-
}
|
|
24345
|
-
dir = parent;
|
|
24346
|
-
}
|
|
24347
|
-
};
|
|
24348
|
-
|
|
24349
|
-
// src/engine/resources.ts
|
|
24350
|
-
var exists = async (file) => {
|
|
24351
|
-
return access2(file).then(
|
|
24352
|
-
() => true,
|
|
24353
|
-
() => false
|
|
24354
|
-
);
|
|
24355
|
-
};
|
|
24356
|
-
var engineResources = async () => {
|
|
24357
|
-
const root = enginePackageRoot();
|
|
24358
|
-
const packed = path34.join(root, "resources");
|
|
24359
|
-
if (await exists(path34.join(packed, "author", "COPY_RULES.md"))) {
|
|
24360
|
-
return {
|
|
24361
|
-
root,
|
|
24362
|
-
author: path34.join(packed, "author"),
|
|
24363
|
-
editorial: path34.join(packed, "editorial"),
|
|
24364
|
-
guide: path34.join(packed, "guide", "OPERATOR.md")
|
|
24365
|
-
};
|
|
24366
|
-
}
|
|
24367
|
-
return {
|
|
24368
|
-
root,
|
|
24369
|
-
author: path34.join(root, "src", "author"),
|
|
24370
|
-
editorial: path34.join(root, "src", "engine", "editorial"),
|
|
24371
|
-
guide: path34.join(root, "src", "engine", "guide", "OPERATOR.md")
|
|
24372
|
-
};
|
|
24373
|
-
};
|
|
24374
|
-
|
|
24375
|
-
// src/cli/guide-command.ts
|
|
25330
|
+
import { readFile as readFile30 } from "node:fs/promises";
|
|
24376
25331
|
var readOperatorGuide = async () => {
|
|
24377
25332
|
const { guide } = await engineResources();
|
|
24378
|
-
return
|
|
25333
|
+
return readFile30(guide, "utf8");
|
|
24379
25334
|
};
|
|
24380
25335
|
var runGuide = async (flags) => {
|
|
24381
25336
|
const guide = await readOperatorGuide();
|
|
@@ -24390,34 +25345,34 @@ import { writeFile as writeFile23 } from "node:fs/promises";
|
|
|
24390
25345
|
import path48 from "node:path";
|
|
24391
25346
|
|
|
24392
25347
|
// src/codex-workflow/loop.ts
|
|
24393
|
-
import { mkdir as mkdir20, readFile as
|
|
25348
|
+
import { mkdir as mkdir20, readFile as readFile41, writeFile as writeFile20 } from "node:fs/promises";
|
|
24394
25349
|
import path45 from "node:path";
|
|
24395
|
-
import { z as
|
|
25350
|
+
import { z as z75 } from "zod";
|
|
24396
25351
|
|
|
24397
25352
|
// src/agents/verifier.ts
|
|
24398
|
-
import { z as
|
|
24399
|
-
var verdictSchema =
|
|
24400
|
-
reviews:
|
|
24401
|
-
|
|
24402
|
-
path:
|
|
25353
|
+
import { z as z65 } from "zod";
|
|
25354
|
+
var verdictSchema = z65.object({
|
|
25355
|
+
reviews: z65.array(
|
|
25356
|
+
z65.object({
|
|
25357
|
+
path: z65.string(),
|
|
24403
25358
|
/** The verdict itself. The premise findings and the flag must
|
|
24404
25359
|
* agree, and only the flag lets `errors` reject a block: a
|
|
24405
25360
|
* passing review may still carry stray text there: a measured
|
|
24406
25361
|
* model wrote "None found." and "none" into `errors` for blocks
|
|
24407
25362
|
* it had approved, and each cost a copy generation. */
|
|
24408
|
-
passed:
|
|
24409
|
-
allPremisesCovered:
|
|
24410
|
-
actionAppropriate:
|
|
24411
|
-
premises:
|
|
24412
|
-
|
|
24413
|
-
proposition:
|
|
24414
|
-
declaredPremiseIndex:
|
|
24415
|
-
basisFactIds:
|
|
24416
|
-
supported:
|
|
24417
|
-
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()
|
|
24418
25373
|
}).strict()
|
|
24419
25374
|
).max(40),
|
|
24420
|
-
errors:
|
|
25375
|
+
errors: z65.array(z65.string()).max(20)
|
|
24421
25376
|
}).strict()
|
|
24422
25377
|
).max(200)
|
|
24423
25378
|
}).strict();
|
|
@@ -24437,14 +25392,14 @@ ${rateComparison.id}: ${rateComparison.guidance} A narrative that breaks this fa
|
|
|
24437
25392
|
var verdictSchemaFor = (paths, factIds) => {
|
|
24438
25393
|
const enumOf = (values) => {
|
|
24439
25394
|
const [first, ...rest] = values;
|
|
24440
|
-
return first === void 0 ?
|
|
25395
|
+
return first === void 0 ? z65.string().min(1) : z65.enum([first, ...rest]);
|
|
24441
25396
|
};
|
|
24442
25397
|
const review2 = verdictSchema.shape.reviews.element;
|
|
24443
|
-
return
|
|
24444
|
-
reviews:
|
|
25398
|
+
return z65.object({
|
|
25399
|
+
reviews: z65.array(
|
|
24445
25400
|
review2.extend({
|
|
24446
25401
|
path: enumOf(paths),
|
|
24447
|
-
premises: review2.shape.premises.element.extend({ basisFactIds:
|
|
25402
|
+
premises: review2.shape.premises.element.extend({ basisFactIds: z65.array(enumOf(factIds)) }).array().max(40)
|
|
24448
25403
|
})
|
|
24449
25404
|
).min(1).max(Math.max(1, paths.length))
|
|
24450
25405
|
});
|
|
@@ -24722,28 +25677,28 @@ var verifierChunks = (recommendations, profile, context = {}) => {
|
|
|
24722
25677
|
};
|
|
24723
25678
|
|
|
24724
25679
|
// src/codex-workflow/copy-recovery.ts
|
|
24725
|
-
import { z as
|
|
25680
|
+
import { z as z67 } from "zod";
|
|
24726
25681
|
|
|
24727
25682
|
// src/codex-workflow/quality.ts
|
|
24728
|
-
import { readFile as
|
|
25683
|
+
import { readFile as readFile31 } from "node:fs/promises";
|
|
24729
25684
|
import path35 from "node:path";
|
|
24730
|
-
import { z as
|
|
24731
|
-
var storedReviewSchema =
|
|
24732
|
-
criteria:
|
|
24733
|
-
|
|
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() })
|
|
24734
25689
|
),
|
|
24735
|
-
unresolved:
|
|
24736
|
-
|
|
24737
|
-
criterionId:
|
|
24738
|
-
stage:
|
|
24739
|
-
file:
|
|
24740
|
-
problem:
|
|
24741
|
-
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()
|
|
24742
25697
|
})
|
|
24743
25698
|
)
|
|
24744
25699
|
});
|
|
24745
25700
|
var readStoredReview = async (dir) => {
|
|
24746
|
-
const raw = await
|
|
25701
|
+
const raw = await readFile31(path35.join(dir, "OUT", "review.json"), "utf8").catch(
|
|
24747
25702
|
() => "null"
|
|
24748
25703
|
) || "null";
|
|
24749
25704
|
const review2 = storedReviewSchema.nullable().parse(JSON.parse(raw));
|
|
@@ -24791,9 +25746,9 @@ var reportQuality = async (dir, { rounds, degraded, accepted }) => {
|
|
|
24791
25746
|
};
|
|
24792
25747
|
|
|
24793
25748
|
// src/codex-workflow/copy-recovery.ts
|
|
24794
|
-
var legacyRefusal =
|
|
24795
|
-
attempt:
|
|
24796
|
-
errors:
|
|
25749
|
+
var legacyRefusal = z67.object({
|
|
25750
|
+
attempt: z67.number().int(),
|
|
25751
|
+
errors: z67.array(z67.string())
|
|
24797
25752
|
});
|
|
24798
25753
|
var operationalErrors = (errors) => {
|
|
24799
25754
|
return errors.length > 0 && errors.every(
|
|
@@ -24840,19 +25795,19 @@ var CopyVerificationUnavailableError = class extends Error {
|
|
|
24840
25795
|
this.errors = errors;
|
|
24841
25796
|
}
|
|
24842
25797
|
};
|
|
24843
|
-
var windowSchema =
|
|
24844
|
-
passId:
|
|
24845
|
-
startedAt:
|
|
24846
|
-
deadlineAt:
|
|
25798
|
+
var windowSchema = z67.object({
|
|
25799
|
+
passId: z67.string(),
|
|
25800
|
+
startedAt: z67.iso.datetime(),
|
|
25801
|
+
deadlineAt: z67.iso.datetime()
|
|
24847
25802
|
}).strict();
|
|
24848
25803
|
|
|
24849
25804
|
// src/codex-workflow/copy-editor.ts
|
|
24850
|
-
import { readFile as
|
|
25805
|
+
import { readFile as readFile33 } from "node:fs/promises";
|
|
24851
25806
|
import path37 from "node:path";
|
|
24852
|
-
import { z as
|
|
25807
|
+
import { z as z68 } from "zod";
|
|
24853
25808
|
|
|
24854
25809
|
// src/codex-workflow/copy.ts
|
|
24855
|
-
import { mkdir as mkdir15, readFile as
|
|
25810
|
+
import { mkdir as mkdir15, readFile as readFile32, writeFile as writeFile13 } from "node:fs/promises";
|
|
24856
25811
|
import path36 from "node:path";
|
|
24857
25812
|
|
|
24858
25813
|
// src/agents/copywriter-input.ts
|
|
@@ -24925,11 +25880,11 @@ var authorDir = async (env = getEnvironment()) => {
|
|
|
24925
25880
|
var copywriterFiles = async (env = getEnvironment()) => {
|
|
24926
25881
|
const { author: author2, company } = await authorDir(env);
|
|
24927
25882
|
const files = {
|
|
24928
|
-
"RULES.md": await
|
|
24929
|
-
"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")
|
|
24930
25885
|
};
|
|
24931
25886
|
for (const file of ["COMPANY", "positioning", "services"]) {
|
|
24932
|
-
files[`company/${file}.md`] = await
|
|
25887
|
+
files[`company/${file}.md`] = await readFile32(
|
|
24933
25888
|
path36.join(company, `${file}.md`),
|
|
24934
25889
|
"utf8"
|
|
24935
25890
|
);
|
|
@@ -24937,7 +25892,7 @@ var copywriterFiles = async (env = getEnvironment()) => {
|
|
|
24937
25892
|
return files;
|
|
24938
25893
|
};
|
|
24939
25894
|
var readSnapshot = async (dir) => {
|
|
24940
|
-
const raw = await
|
|
25895
|
+
const raw = await readFile32(
|
|
24941
25896
|
path36.join(dir, "OUT", "snapshot.json"),
|
|
24942
25897
|
"utf8"
|
|
24943
25898
|
).catch(() => null);
|
|
@@ -24990,7 +25945,7 @@ var readCopyDocuments = async (dir, files) => {
|
|
|
24990
25945
|
const entries = await Promise.all(
|
|
24991
25946
|
files.map(async (file) => {
|
|
24992
25947
|
const name = path36.posix.relative(copyDir, file);
|
|
24993
|
-
return [name, await
|
|
25948
|
+
return [name, await readFile32(path36.join(dir, file), "utf8")];
|
|
24994
25949
|
})
|
|
24995
25950
|
);
|
|
24996
25951
|
return Object.fromEntries(entries);
|
|
@@ -25216,21 +26171,21 @@ This is your editing turn: return only the complete edited draft required by the
|
|
|
25216
26171
|
}
|
|
25217
26172
|
return { ...call(), trimmed };
|
|
25218
26173
|
};
|
|
25219
|
-
var savedCopyEditsSchema =
|
|
25220
|
-
scope:
|
|
25221
|
-
edits:
|
|
25222
|
-
|
|
25223
|
-
inputDigest:
|
|
25224
|
-
draft:
|
|
25225
|
-
round:
|
|
25226
|
-
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()),
|
|
25227
26182
|
editedDraft: writeOutputSchema,
|
|
25228
|
-
trimmed:
|
|
26183
|
+
trimmed: z68.array(z68.string()).optional()
|
|
25229
26184
|
})
|
|
25230
26185
|
)
|
|
25231
26186
|
}).nullable();
|
|
25232
26187
|
var readCopyEdits = async (dir, scope) => {
|
|
25233
|
-
const raw = await
|
|
26188
|
+
const raw = await readFile33(
|
|
25234
26189
|
path37.join(dir, "PENDING/copy-edits.json"),
|
|
25235
26190
|
"utf8"
|
|
25236
26191
|
).catch(() => "null");
|
|
@@ -25306,9 +26261,9 @@ var editCopyDraft = async (args) => {
|
|
|
25306
26261
|
|
|
25307
26262
|
// src/codex-workflow/finish.ts
|
|
25308
26263
|
import { createHash as createHash9 } from "node:crypto";
|
|
25309
|
-
import { readFile as
|
|
26264
|
+
import { readFile as readFile34, writeFile as writeFile14 } from "node:fs/promises";
|
|
25310
26265
|
import path38 from "node:path";
|
|
25311
|
-
import { z as
|
|
26266
|
+
import { z as z69 } from "zod";
|
|
25312
26267
|
|
|
25313
26268
|
// src/agents/methodology.ts
|
|
25314
26269
|
var maxNamedModels = 3;
|
|
@@ -25416,7 +26371,7 @@ var codexAnalyzer = (model) => {
|
|
|
25416
26371
|
var finishRun = async (args) => {
|
|
25417
26372
|
const { source, dir, signal } = args;
|
|
25418
26373
|
const { config, request: request2, plan } = source;
|
|
25419
|
-
const aggregateText = await
|
|
26374
|
+
const aggregateText = await readFile34(
|
|
25420
26375
|
path38.join(dir, "OUT", "aggregate.json"),
|
|
25421
26376
|
"utf8"
|
|
25422
26377
|
);
|
|
@@ -25638,7 +26593,7 @@ var isGroundingBundle = (value) => {
|
|
|
25638
26593
|
};
|
|
25639
26594
|
var reuseFinish = async (dir, digest5, aggregate2) => {
|
|
25640
26595
|
const out = (name) => {
|
|
25641
|
-
return
|
|
26596
|
+
return readFile34(path38.join(dir, "OUT", name), "utf8");
|
|
25642
26597
|
};
|
|
25643
26598
|
const recorded2 = await out("finish.inputs.sha").catch(() => null);
|
|
25644
26599
|
if (recorded2?.trim() !== digest5) {
|
|
@@ -25654,9 +26609,9 @@ var reuseFinish = async (dir, digest5, aggregate2) => {
|
|
|
25654
26609
|
const captureManifest = captureManifestSchema.parse(
|
|
25655
26610
|
JSON.parse(await out("capture-manifest.json"))
|
|
25656
26611
|
);
|
|
25657
|
-
const partialFailures =
|
|
26612
|
+
const partialFailures = z69.array(partialFailureSchema).parse(JSON.parse(await out("partial-failures.json")));
|
|
25658
26613
|
const grounding = JSON.parse(await out("grounding.json"));
|
|
25659
|
-
const labelStats =
|
|
26614
|
+
const labelStats = z69.record(z69.string(), z69.number()).parse(JSON.parse(await out("label-stats.json")));
|
|
25660
26615
|
if (grounding !== null && !isGroundingBundle(grounding)) {
|
|
25661
26616
|
throw new Error("OUT/grounding.json is not a grounding bundle.");
|
|
25662
26617
|
}
|
|
@@ -25711,14 +26666,14 @@ import {
|
|
|
25711
26666
|
appendFile as appendFile2,
|
|
25712
26667
|
mkdir as mkdir18,
|
|
25713
26668
|
readdir as readdir7,
|
|
25714
|
-
readFile as
|
|
26669
|
+
readFile as readFile39,
|
|
25715
26670
|
rename as rename10,
|
|
25716
26671
|
rm as rm9,
|
|
25717
26672
|
writeFile as writeFile18
|
|
25718
26673
|
} from "node:fs/promises";
|
|
25719
26674
|
import path43 from "node:path";
|
|
25720
26675
|
import { setTimeout as delay3 } from "node:timers/promises";
|
|
25721
|
-
import { z as
|
|
26676
|
+
import { z as z73 } from "zod";
|
|
25722
26677
|
|
|
25723
26678
|
// src/models/pricing.ts
|
|
25724
26679
|
var tokenCostUsd = (pricing, usage) => {
|
|
@@ -25733,7 +26688,7 @@ import {
|
|
|
25733
26688
|
access as access3,
|
|
25734
26689
|
mkdir as mkdir17,
|
|
25735
26690
|
readdir as readdir6,
|
|
25736
|
-
readFile as
|
|
26691
|
+
readFile as readFile36,
|
|
25737
26692
|
rm as rm7,
|
|
25738
26693
|
writeFile as writeFile16
|
|
25739
26694
|
} from "node:fs/promises";
|
|
@@ -26229,9 +27184,9 @@ var authorExamples = (names = authorExampleNames) => {
|
|
|
26229
27184
|
};
|
|
26230
27185
|
|
|
26231
27186
|
// src/codex-workflow/author-tools.ts
|
|
26232
|
-
import { appendFile, mkdir as mkdir16, readFile as
|
|
27187
|
+
import { appendFile, mkdir as mkdir16, readFile as readFile35, writeFile as writeFile15 } from "node:fs/promises";
|
|
26233
27188
|
import path39 from "node:path";
|
|
26234
|
-
import { z as
|
|
27189
|
+
import { z as z70 } from "zod";
|
|
26235
27190
|
var researchDir = "RESEARCH";
|
|
26236
27191
|
var authorToolCaps = {
|
|
26237
27192
|
search: 20,
|
|
@@ -26244,59 +27199,59 @@ var authorToolCaps = {
|
|
|
26244
27199
|
pageTextBytes: 32 * 1024,
|
|
26245
27200
|
links: 100
|
|
26246
27201
|
};
|
|
26247
|
-
var researchIndexSchema =
|
|
26248
|
-
next:
|
|
26249
|
-
byUrl:
|
|
26250
|
-
|
|
26251
|
-
|
|
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"]) })
|
|
26252
27207
|
)
|
|
26253
27208
|
});
|
|
26254
|
-
var researchJournalEntrySchema =
|
|
26255
|
-
at:
|
|
26256
|
-
tool:
|
|
26257
|
-
args:
|
|
26258
|
-
outcome:
|
|
26259
|
-
reason:
|
|
26260
|
-
elapsedMs:
|
|
26261
|
-
bytes:
|
|
26262
|
-
costUsd:
|
|
26263
|
-
provider:
|
|
26264
|
-
path:
|
|
26265
|
-
urls:
|
|
26266
|
-
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()
|
|
26267
27222
|
});
|
|
26268
27223
|
var isGroundingSource = (value) => {
|
|
26269
27224
|
return groundingSourceSchema.safeParse(value).success;
|
|
26270
27225
|
};
|
|
26271
|
-
var searchArgs =
|
|
26272
|
-
query:
|
|
26273
|
-
purpose:
|
|
27226
|
+
var searchArgs = z70.object({
|
|
27227
|
+
query: z70.string().trim().min(1).max(300),
|
|
27228
|
+
purpose: z70.string().trim().min(1).max(300)
|
|
26274
27229
|
}).strict();
|
|
26275
|
-
var urlArgs =
|
|
26276
|
-
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();
|
|
26277
27232
|
var researchToolDefinitions = [
|
|
26278
27233
|
{
|
|
26279
27234
|
name: "search",
|
|
26280
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.",
|
|
26281
|
-
inputSchema:
|
|
27236
|
+
inputSchema: z70.toJSONSchema(searchArgs),
|
|
26282
27237
|
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
26283
27238
|
},
|
|
26284
27239
|
{
|
|
26285
27240
|
name: "fetch",
|
|
26286
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.",
|
|
26287
|
-
inputSchema:
|
|
27242
|
+
inputSchema: z70.toJSONSchema(urlArgs),
|
|
26288
27243
|
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
26289
27244
|
},
|
|
26290
27245
|
{
|
|
26291
27246
|
name: "render",
|
|
26292
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.",
|
|
26293
|
-
inputSchema:
|
|
27248
|
+
inputSchema: z70.toJSONSchema(urlArgs),
|
|
26294
27249
|
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
26295
27250
|
},
|
|
26296
27251
|
{
|
|
26297
27252
|
name: "submit",
|
|
26298
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.',
|
|
26299
|
-
inputSchema:
|
|
27254
|
+
inputSchema: z70.toJSONSchema(submitArgs)
|
|
26300
27255
|
}
|
|
26301
27256
|
];
|
|
26302
27257
|
var researchDocumentPath = (n) => {
|
|
@@ -26325,7 +27280,7 @@ var parseResearchDocument = (content) => {
|
|
|
26325
27280
|
};
|
|
26326
27281
|
};
|
|
26327
27282
|
var readIndex = async (dir) => {
|
|
26328
|
-
const raw = await
|
|
27283
|
+
const raw = await readFile35(
|
|
26329
27284
|
path39.join(dir, researchDir, "INDEX.json"),
|
|
26330
27285
|
"utf8"
|
|
26331
27286
|
).catch(() => null);
|
|
@@ -26335,7 +27290,7 @@ var readIndex = async (dir) => {
|
|
|
26335
27290
|
return researchIndexSchema.parse(JSON.parse(raw));
|
|
26336
27291
|
};
|
|
26337
27292
|
var readResearchJournal = async (dir, label) => {
|
|
26338
|
-
const raw = await
|
|
27293
|
+
const raw = await readFile35(
|
|
26339
27294
|
path39.join(dir, "JOURNAL", `${label}.research.jsonl`),
|
|
26340
27295
|
"utf8"
|
|
26341
27296
|
).catch(() => "");
|
|
@@ -26350,7 +27305,7 @@ var readResearchDocuments = async (dir) => {
|
|
|
26350
27305
|
continue;
|
|
26351
27306
|
}
|
|
26352
27307
|
seen.add(n);
|
|
26353
|
-
const content = await
|
|
27308
|
+
const content = await readFile35(
|
|
26354
27309
|
path39.join(dir, researchDocumentPath(n)),
|
|
26355
27310
|
"utf8"
|
|
26356
27311
|
).catch(() => null);
|
|
@@ -26359,7 +27314,7 @@ var readResearchDocuments = async (dir) => {
|
|
|
26359
27314
|
continue;
|
|
26360
27315
|
}
|
|
26361
27316
|
const savedSource = JSON.parse(
|
|
26362
|
-
await
|
|
27317
|
+
await readFile35(path39.join(dir, researchSourcePath(n)), "utf8").catch(
|
|
26363
27318
|
() => "null"
|
|
26364
27319
|
)
|
|
26365
27320
|
);
|
|
@@ -26464,11 +27419,11 @@ var materializeAuthorWorkdir = async (args) => {
|
|
|
26464
27419
|
await writeFile16(path40.join(base, "BRIEF.md"), briefDocument(args.brief));
|
|
26465
27420
|
await writeFile16(
|
|
26466
27421
|
path40.join(base, "RULES.md"),
|
|
26467
|
-
await
|
|
27422
|
+
await readFile36(path40.join(author2, "RULES.md"), "utf8")
|
|
26468
27423
|
);
|
|
26469
27424
|
await writeFile16(
|
|
26470
27425
|
path40.join(base, "banlist.json"),
|
|
26471
|
-
await
|
|
27426
|
+
await readFile36(path40.join(author2, "banlist.json"), "utf8")
|
|
26472
27427
|
);
|
|
26473
27428
|
await writeFile16(
|
|
26474
27429
|
path40.join(base, "SCHEMA.json"),
|
|
@@ -26521,7 +27476,7 @@ var authorPacket = async (args) => {
|
|
|
26521
27476
|
if (args.continuation && !file.startsWith(`${authorWorkDir}/PREVIOUS/`)) {
|
|
26522
27477
|
continue;
|
|
26523
27478
|
}
|
|
26524
|
-
const content = await
|
|
27479
|
+
const content = await readFile36(path40.join(args.dir, file), "utf8");
|
|
26525
27480
|
files[file] = file.endsWith(".json") ? JSON.parse(content) : content;
|
|
26526
27481
|
}
|
|
26527
27482
|
return JSON.stringify({
|
|
@@ -26581,7 +27536,7 @@ var researchServerConfig = async (dir, env = getEnvironment()) => {
|
|
|
26581
27536
|
};
|
|
26582
27537
|
};
|
|
26583
27538
|
var readAuthorOutput = async (dir) => {
|
|
26584
|
-
const raw = await
|
|
27539
|
+
const raw = await readFile36(path40.join(dir, authorOutputFile), "utf8").catch(
|
|
26585
27540
|
() => null
|
|
26586
27541
|
);
|
|
26587
27542
|
if (raw === null) {
|
|
@@ -26633,15 +27588,15 @@ var validateAuthorStage = async (args) => {
|
|
|
26633
27588
|
};
|
|
26634
27589
|
|
|
26635
27590
|
// src/codex-workflow/session.ts
|
|
26636
|
-
import { readFile as
|
|
27591
|
+
import { readFile as readFile37, rm as rm8, writeFile as writeFile17 } from "node:fs/promises";
|
|
26637
27592
|
import path41 from "node:path";
|
|
26638
|
-
import { z as
|
|
26639
|
-
var savedSessionSchema =
|
|
26640
|
-
contract:
|
|
26641
|
-
threadId:
|
|
27593
|
+
import { z as z71 } from "zod";
|
|
27594
|
+
var savedSessionSchema = z71.looseObject({
|
|
27595
|
+
contract: z71.string(),
|
|
27596
|
+
threadId: z71.string()
|
|
26642
27597
|
});
|
|
26643
27598
|
var readSession = async (dir, { label, contract }) => {
|
|
26644
|
-
const raw = await
|
|
27599
|
+
const raw = await readFile37(
|
|
26645
27600
|
path41.join(dir, "JOURNAL", `${label}.session.json`),
|
|
26646
27601
|
"utf8"
|
|
26647
27602
|
).catch(() => null);
|
|
@@ -26731,23 +27686,23 @@ var reserveWhenAffordable = async (ledger, reserve, signal) => {
|
|
|
26731
27686
|
};
|
|
26732
27687
|
|
|
26733
27688
|
// src/codex-workflow/batch-input.ts
|
|
26734
|
-
import { readFile as
|
|
27689
|
+
import { readFile as readFile38 } from "node:fs/promises";
|
|
26735
27690
|
import path42 from "node:path";
|
|
26736
|
-
import { z as
|
|
26737
|
-
var trailEntrySchema =
|
|
26738
|
-
by:
|
|
26739
|
-
at:
|
|
26740
|
-
outcome:
|
|
26741
|
-
stage:
|
|
26742
|
-
file:
|
|
26743
|
-
field:
|
|
26744
|
-
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()
|
|
26745
27700
|
});
|
|
26746
27701
|
var isTrailEntry = (entry) => {
|
|
26747
27702
|
return trailEntrySchema.safeParse(entry).success;
|
|
26748
27703
|
};
|
|
26749
|
-
var previousPassSchema =
|
|
26750
|
-
var previousCorrectionsSchema =
|
|
27704
|
+
var previousPassSchema = z72.record(z72.string(), z72.unknown()).nullable();
|
|
27705
|
+
var previousCorrectionsSchema = z72.array(z72.record(z72.string(), z72.unknown()));
|
|
26751
27706
|
var readUnlessMissing = async (read, { file, fallback }) => {
|
|
26752
27707
|
try {
|
|
26753
27708
|
return await read(file);
|
|
@@ -26761,7 +27716,7 @@ var readUnlessMissing = async (read, { file, fallback }) => {
|
|
|
26761
27716
|
var batchInput = async (args) => {
|
|
26762
27717
|
const { dir, stage, index } = args;
|
|
26763
27718
|
const read = (file) => {
|
|
26764
|
-
return
|
|
27719
|
+
return readFile38(path42.join(dir, file), "utf8");
|
|
26765
27720
|
};
|
|
26766
27721
|
const inputFile = `OUT/${stage}/${index}.${stage === "analyze" ? "index" : "rows"}.json`;
|
|
26767
27722
|
const current = JSON.parse(await read(inputFile));
|
|
@@ -26775,7 +27730,7 @@ var batchInput = async (args) => {
|
|
|
26775
27730
|
) : void 0;
|
|
26776
27731
|
let hostFeedback;
|
|
26777
27732
|
if (previous) {
|
|
26778
|
-
const trail =
|
|
27733
|
+
const trail = z72.array(z72.unknown()).parse(
|
|
26779
27734
|
JSON.parse(
|
|
26780
27735
|
await readUnlessMissing(read, {
|
|
26781
27736
|
file: "OUT/corrections.json",
|
|
@@ -26829,11 +27784,11 @@ var batchInput = async (args) => {
|
|
|
26829
27784
|
var defaultBatchSize = 10;
|
|
26830
27785
|
var defaultConcurrency = 25;
|
|
26831
27786
|
var maxAttempts = 3;
|
|
26832
|
-
var rowsOutSchema =
|
|
26833
|
-
rows:
|
|
27787
|
+
var rowsOutSchema = z73.looseObject({
|
|
27788
|
+
rows: z73.array(z73.record(z73.string(), z73.unknown())).optional()
|
|
26834
27789
|
});
|
|
26835
27790
|
var readOut = async (dir, { stage, required }) => {
|
|
26836
|
-
const raw = await
|
|
27791
|
+
const raw = await readFile39(
|
|
26837
27792
|
path43.join(dir, "OUT", `${stage}.json`),
|
|
26838
27793
|
"utf8"
|
|
26839
27794
|
).catch(() => null);
|
|
@@ -27062,7 +28017,7 @@ var batchInputsDigest = async (ctx, stage, batch) => {
|
|
|
27062
28017
|
)
|
|
27063
28018
|
};
|
|
27064
28019
|
for (const file of await spec.sharedInputs(ctx.dir)) {
|
|
27065
|
-
parts[file] = await
|
|
28020
|
+
parts[file] = await readFile39(path43.join(ctx.dir, file), "utf8").catch(
|
|
27066
28021
|
() => ""
|
|
27067
28022
|
);
|
|
27068
28023
|
}
|
|
@@ -27079,14 +28034,14 @@ var stageInputsDigest = async (ctx, stage) => {
|
|
|
27079
28034
|
return sha(digests);
|
|
27080
28035
|
};
|
|
27081
28036
|
var isStageFresh = async (ctx, stage) => {
|
|
27082
|
-
const recorded2 = await
|
|
28037
|
+
const recorded2 = await readFile39(
|
|
27083
28038
|
path43.join(ctx.dir, "OUT", `${stage}.inputs.sha`),
|
|
27084
28039
|
"utf8"
|
|
27085
28040
|
).catch(() => null);
|
|
27086
28041
|
if (!recorded2) {
|
|
27087
28042
|
return false;
|
|
27088
28043
|
}
|
|
27089
|
-
const out = await
|
|
28044
|
+
const out = await readFile39(
|
|
27090
28045
|
path43.join(ctx.dir, "OUT", `${stage}.json`),
|
|
27091
28046
|
"utf8"
|
|
27092
28047
|
).catch(() => null);
|
|
@@ -27099,26 +28054,26 @@ var sessionSandbox = (spec) => {
|
|
|
27099
28054
|
const AEO_CODEX_STAGE_SANDBOX = readEnv("AEO_CODEX_STAGE_SANDBOX");
|
|
27100
28055
|
return AEO_CODEX_STAGE_SANDBOX === "danger-full-access" ? "danger-full-access" : "workspace-write";
|
|
27101
28056
|
};
|
|
27102
|
-
var eventText =
|
|
27103
|
-
var eventTokens =
|
|
27104
|
-
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({
|
|
27105
28060
|
input_tokens: eventTokens,
|
|
27106
28061
|
cached_input_tokens: eventTokens,
|
|
27107
28062
|
output_tokens: eventTokens
|
|
27108
28063
|
}).optional().catch(void 0);
|
|
27109
|
-
var codexEventSchema =
|
|
28064
|
+
var codexEventSchema = z73.looseObject({
|
|
27110
28065
|
type: eventText,
|
|
27111
28066
|
thread_id: eventText,
|
|
27112
28067
|
message: eventText,
|
|
27113
|
-
error:
|
|
27114
|
-
item:
|
|
28068
|
+
error: z73.looseObject({ message: eventText }).optional().catch(void 0),
|
|
28069
|
+
item: z73.looseObject({
|
|
27115
28070
|
type: eventText,
|
|
27116
28071
|
command: eventText,
|
|
27117
28072
|
text: eventText,
|
|
27118
28073
|
status: eventText
|
|
27119
28074
|
}).optional().catch(void 0),
|
|
27120
28075
|
usage: eventUsage,
|
|
27121
|
-
info:
|
|
28076
|
+
info: z73.looseObject({ total_token_usage: eventUsage }).optional().catch(void 0)
|
|
27122
28077
|
});
|
|
27123
28078
|
var parseCodexEvent = (line) => {
|
|
27124
28079
|
let json;
|
|
@@ -27219,7 +28174,7 @@ var execReservedCodex = async (ctx, { stage, batch, feedback, attempt }, reserve
|
|
|
27219
28174
|
inputs: await Promise.all(
|
|
27220
28175
|
boundFiles.map(async (file) => [
|
|
27221
28176
|
file,
|
|
27222
|
-
await
|
|
28177
|
+
await readFile39(path43.join(ctx.dir, file), "utf8").catch(() => "")
|
|
27223
28178
|
])
|
|
27224
28179
|
)
|
|
27225
28180
|
});
|
|
@@ -27403,7 +28358,7 @@ var correctionValue = (text) => {
|
|
|
27403
28358
|
}
|
|
27404
28359
|
};
|
|
27405
28360
|
var readCorrectable = async (file) => {
|
|
27406
|
-
const raw = await
|
|
28361
|
+
const raw = await readFile39(file, "utf8");
|
|
27407
28362
|
return rowsOutSchema.parse(JSON.parse(raw));
|
|
27408
28363
|
};
|
|
27409
28364
|
var isQualifyRow = (row) => {
|
|
@@ -27490,7 +28445,7 @@ var applyCorrections = async (ctx, from, corrections) => {
|
|
|
27490
28445
|
const scope = { brand: ctx.brand, answers, coverage: false };
|
|
27491
28446
|
for (const [stage, list] of byStage) {
|
|
27492
28447
|
const file = path43.join(ctx.dir, "OUT", `${stage}.json`);
|
|
27493
|
-
const raw = await
|
|
28448
|
+
const raw = await readFile39(file, "utf8").catch(() => null);
|
|
27494
28449
|
if (!raw || !isStageName(stage)) {
|
|
27495
28450
|
for (const correction of list) {
|
|
27496
28451
|
outcomes.push({ correction, outcome: "refused: no such stage output" });
|
|
@@ -27517,8 +28472,8 @@ var applyCorrections = async (ctx, from, corrections) => {
|
|
|
27517
28472
|
await alignBatchRows(path43.join(ctx.dir, "OUT", stage), output);
|
|
27518
28473
|
}
|
|
27519
28474
|
const trailFile = path43.join(ctx.dir, "OUT", "corrections.json");
|
|
27520
|
-
const trail =
|
|
27521
|
-
JSON.parse(await
|
|
28475
|
+
const trail = z73.array(z73.unknown()).parse(
|
|
28476
|
+
JSON.parse(await readFile39(trailFile, "utf8").catch(() => "[]") || "[]")
|
|
27522
28477
|
);
|
|
27523
28478
|
const at = (/* @__PURE__ */ new Date()).toISOString();
|
|
27524
28479
|
trail.push(
|
|
@@ -27604,7 +28559,7 @@ var dropSession = async (ctx, label) => {
|
|
|
27604
28559
|
var incompleteError = (result) => {
|
|
27605
28560
|
return `codex exited ${result.exitCode} without an output file: ${(result.failure ?? result.stderr).slice(-600)}`;
|
|
27606
28561
|
};
|
|
27607
|
-
var storedBatchSchema =
|
|
28562
|
+
var storedBatchSchema = z73.record(z73.string(), z73.unknown());
|
|
27608
28563
|
var runCodexBatch = async (ctx, { stage, batch, files, scope }) => {
|
|
27609
28564
|
const { label, outFile, refusedFile } = files;
|
|
27610
28565
|
const usages = [];
|
|
@@ -27624,7 +28579,7 @@ var runCodexBatch = async (ctx, { stage, batch, files, scope }) => {
|
|
|
27624
28579
|
operationId: result.operationId ?? null
|
|
27625
28580
|
};
|
|
27626
28581
|
usages.push(result.usage);
|
|
27627
|
-
const raw = await
|
|
28582
|
+
const raw = await readFile39(outFile, "utf8").catch(() => null);
|
|
27628
28583
|
if (raw === null) {
|
|
27629
28584
|
const error = incompleteError(result);
|
|
27630
28585
|
if (isAuthError(result.failure ?? result.stderr)) {
|
|
@@ -27708,20 +28663,20 @@ var runCodexBatch = async (ctx, { stage, batch, files, scope }) => {
|
|
|
27708
28663
|
...fatal !== void 0 && { fatal }
|
|
27709
28664
|
};
|
|
27710
28665
|
};
|
|
27711
|
-
var pendingSchema =
|
|
27712
|
-
version:
|
|
27713
|
-
digest:
|
|
28666
|
+
var pendingSchema = z73.object({
|
|
28667
|
+
version: z73.literal(2).optional(),
|
|
28668
|
+
digest: z73.string(),
|
|
27714
28669
|
// A draft the writer never produced is absent from the written file.
|
|
27715
|
-
draft:
|
|
27716
|
-
rounds:
|
|
27717
|
-
errors:
|
|
28670
|
+
draft: z73.unknown().optional(),
|
|
28671
|
+
rounds: z73.number(),
|
|
28672
|
+
errors: z73.array(z73.string())
|
|
27718
28673
|
});
|
|
27719
28674
|
var savePending = async (ctx, { pendingFile, pending }) => {
|
|
27720
28675
|
await writePendingJson(path43.join(ctx.dir, pendingFile), pending);
|
|
27721
28676
|
await ctx.checkpoint?.([pendingFile]);
|
|
27722
28677
|
};
|
|
27723
28678
|
var readPending = async (ctx, { label, pendingFile, digest: digest5 }) => {
|
|
27724
|
-
const raw = await
|
|
28679
|
+
const raw = await readFile39(path43.join(ctx.dir, pendingFile), "utf8").catch(
|
|
27725
28680
|
() => "null"
|
|
27726
28681
|
);
|
|
27727
28682
|
const parsed = pendingSchema.safeParse(JSON.parse(raw));
|
|
@@ -27732,7 +28687,7 @@ var readPending = async (ctx, { label, pendingFile, digest: digest5 }) => {
|
|
|
27732
28687
|
if (saved.version === 2) {
|
|
27733
28688
|
return saved;
|
|
27734
28689
|
}
|
|
27735
|
-
const journalText = await
|
|
28690
|
+
const journalText = await readFile39(
|
|
27736
28691
|
path43.join(ctx.dir, "JOURNAL", `${label}.refusals.jsonl`),
|
|
27737
28692
|
"utf8"
|
|
27738
28693
|
).catch(() => "");
|
|
@@ -27900,7 +28855,7 @@ var reusedBatch = async (ctx, {
|
|
|
27900
28855
|
if (validated.value === void 0 || validated.errors.length) {
|
|
27901
28856
|
return void 0;
|
|
27902
28857
|
}
|
|
27903
|
-
const appliedSha = await
|
|
28858
|
+
const appliedSha = await readFile39(appliedFile, "utf8").catch(() => "");
|
|
27904
28859
|
await ctx.recorder?.record(
|
|
27905
28860
|
"artifact_reused",
|
|
27906
28861
|
{ stage, batch: batch.index },
|
|
@@ -27945,8 +28900,8 @@ var runBatch = async (ctx, {
|
|
|
27945
28900
|
const refusedFile = path43.join(outDir, `${batch.index}.refused.json`);
|
|
27946
28901
|
const scope = scopeFor(ctx, stage, batch);
|
|
27947
28902
|
const digest5 = await batchInputsDigest(ctx, stage, batch);
|
|
27948
|
-
const previous = await
|
|
27949
|
-
const recorded2 = (await
|
|
28903
|
+
const previous = await readFile39(outFile, "utf8").catch(() => null);
|
|
28904
|
+
const recorded2 = (await readFile39(shaFile, "utf8").catch(() => "")).trim();
|
|
27950
28905
|
if (previous !== null && recorded2 === digest5 && (!force || previousAccepted)) {
|
|
27951
28906
|
const reused = await reusedBatch(ctx, {
|
|
27952
28907
|
stage,
|
|
@@ -28044,15 +28999,15 @@ var pool = async (items, {
|
|
|
28044
28999
|
);
|
|
28045
29000
|
await Promise.all(workers);
|
|
28046
29001
|
};
|
|
28047
|
-
var acceptedReviewSchema =
|
|
28048
|
-
verdict:
|
|
28049
|
-
corrections:
|
|
29002
|
+
var acceptedReviewSchema = z73.looseObject({
|
|
29003
|
+
verdict: z73.unknown().optional(),
|
|
29004
|
+
corrections: z73.array(z73.unknown()).optional()
|
|
28050
29005
|
});
|
|
28051
29006
|
var previouslyAccepted = async (ctx, stage, batch) => {
|
|
28052
29007
|
if (!stageSpecs[stage].passes) {
|
|
28053
29008
|
return false;
|
|
28054
29009
|
}
|
|
28055
|
-
const own = await
|
|
29010
|
+
const own = await readFile39(
|
|
28056
29011
|
path43.join(ctx.dir, "OUT", stage, `${batch.index}.json`),
|
|
28057
29012
|
"utf8"
|
|
28058
29013
|
).catch(() => null);
|
|
@@ -28286,19 +29241,19 @@ var runStage = async (initial, stage, options = {}) => {
|
|
|
28286
29241
|
};
|
|
28287
29242
|
|
|
28288
29243
|
// src/codex-workflow/batch-layout.ts
|
|
28289
|
-
import { mkdir as mkdir19, readFile as
|
|
29244
|
+
import { mkdir as mkdir19, readFile as readFile40, writeFile as writeFile19 } from "node:fs/promises";
|
|
28290
29245
|
import path44 from "node:path";
|
|
28291
|
-
import { z as
|
|
28292
|
-
var layoutSchema =
|
|
28293
|
-
scope:
|
|
28294
|
-
size:
|
|
28295
|
-
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()))
|
|
28296
29251
|
});
|
|
28297
29252
|
var stableBatchLayout = async (dir, { config, files, size }) => {
|
|
28298
29253
|
const file = path44.join(dir, "OUT", "batches.json");
|
|
28299
29254
|
const scope = contentHash(config);
|
|
28300
29255
|
const old = layoutSchema.safeParse(
|
|
28301
|
-
JSON.parse(await
|
|
29256
|
+
JSON.parse(await readFile40(file, "utf8").catch(() => "null"))
|
|
28302
29257
|
);
|
|
28303
29258
|
const layout = old.success && old.data.scope === scope && old.data.size === size ? old.data : { scope, size, batches: [] };
|
|
28304
29259
|
const assigned = new Set(layout.batches.flat());
|
|
@@ -28333,13 +29288,13 @@ var copyInputsOf = (source, extra = {}) => {
|
|
|
28333
29288
|
...extra
|
|
28334
29289
|
};
|
|
28335
29290
|
};
|
|
28336
|
-
var copyPayloadSchema =
|
|
29291
|
+
var copyPayloadSchema = z75.looseObject({
|
|
28337
29292
|
copy: aeoReportCopySchema,
|
|
28338
|
-
provenance:
|
|
28339
|
-
receipt:
|
|
28340
|
-
confidence:
|
|
28341
|
-
outcome:
|
|
28342
|
-
draft:
|
|
29293
|
+
provenance: z75.unknown().optional(),
|
|
29294
|
+
receipt: z75.unknown().optional(),
|
|
29295
|
+
confidence: z75.number(),
|
|
29296
|
+
outcome: z75.string(),
|
|
29297
|
+
draft: z75.unknown().optional(),
|
|
28343
29298
|
quality: aeoSnapshotSchema.shape.meta.shape.quality
|
|
28344
29299
|
});
|
|
28345
29300
|
var prepareWorkdir = async (source, dir, options = {}) => {
|
|
@@ -28436,13 +29391,13 @@ var prepareLockedWorkdir = async (source, dir, options) => {
|
|
|
28436
29391
|
}
|
|
28437
29392
|
};
|
|
28438
29393
|
};
|
|
28439
|
-
var savedVerifierMemorySchema =
|
|
28440
|
-
scope:
|
|
28441
|
-
history:
|
|
28442
|
-
|
|
28443
|
-
|
|
28444
|
-
|
|
28445
|
-
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(),
|
|
28446
29401
|
review: verdictSchemaFor([], []).shape.reviews.element
|
|
28447
29402
|
})
|
|
28448
29403
|
)
|
|
@@ -28470,7 +29425,7 @@ var withCopy = async (ctx, inputs) => {
|
|
|
28470
29425
|
});
|
|
28471
29426
|
const verifierMemory = {
|
|
28472
29427
|
read: async () => {
|
|
28473
|
-
const raw = await
|
|
29428
|
+
const raw = await readFile41(memoryFile, "utf8").catch(() => "null");
|
|
28474
29429
|
const saved = savedVerifierMemorySchema.parse(JSON.parse(raw));
|
|
28475
29430
|
return saved?.scope === memoryScope ? saved.history : {};
|
|
28476
29431
|
},
|
|
@@ -28644,12 +29599,12 @@ var report = (ctx, run, { reused = false } = {}) => {
|
|
|
28644
29599
|
ctx.log(` ${error.slice(0, 300)}`);
|
|
28645
29600
|
}
|
|
28646
29601
|
};
|
|
28647
|
-
var workflowStateSchema =
|
|
28648
|
-
stages:
|
|
29602
|
+
var workflowStateSchema = z75.looseObject({
|
|
29603
|
+
stages: z75.array(z75.record(z75.string(), z75.unknown())).optional()
|
|
28649
29604
|
});
|
|
28650
29605
|
var writeState = async (dir, run) => {
|
|
28651
29606
|
const file = path45.join(dir, "STATE.json");
|
|
28652
|
-
const raw = await
|
|
29607
|
+
const raw = await readFile41(file, "utf8").catch(() => "{}") || "{}";
|
|
28653
29608
|
const state = workflowStateSchema.parse(JSON.parse(raw));
|
|
28654
29609
|
state.stages = [
|
|
28655
29610
|
...state.stages ?? [],
|
|
@@ -28657,13 +29612,13 @@ var writeState = async (dir, run) => {
|
|
|
28657
29612
|
];
|
|
28658
29613
|
await writeFile20(file, JSON.stringify(state, null, 2));
|
|
28659
29614
|
};
|
|
28660
|
-
var recordedRunSchema =
|
|
28661
|
-
degraded:
|
|
28662
|
-
summary:
|
|
29615
|
+
var recordedRunSchema = z75.looseObject({
|
|
29616
|
+
degraded: z75.array(z75.string()).optional(),
|
|
29617
|
+
summary: z75.record(z75.string(), z75.unknown()).optional()
|
|
28663
29618
|
}).nullable();
|
|
28664
29619
|
var runOne = async (ctx, stage, { force, pass }) => {
|
|
28665
29620
|
if (!force && await isStageFresh(ctx, stage)) {
|
|
28666
|
-
const raw = await
|
|
29621
|
+
const raw = await readFile41(
|
|
28667
29622
|
path45.join(ctx.dir, "OUT", `${stage}.result.json`),
|
|
28668
29623
|
"utf8"
|
|
28669
29624
|
).catch(() => "null");
|
|
@@ -28688,7 +29643,7 @@ var runOne = async (ctx, stage, { force, pass }) => {
|
|
|
28688
29643
|
};
|
|
28689
29644
|
var deliverableCopy = async (ctx, inputs, written) => {
|
|
28690
29645
|
if (written.ok) {
|
|
28691
|
-
const raw = await
|
|
29646
|
+
const raw = await readFile41(path45.join(ctx.dir, "OUT", "write.json"), "utf8");
|
|
28692
29647
|
return copyPayloadSchema.parse(JSON.parse(raw));
|
|
28693
29648
|
}
|
|
28694
29649
|
const draft = {
|
|
@@ -28790,8 +29745,8 @@ var withoutAnswers = (ctx, files) => {
|
|
|
28790
29745
|
answers: ctx.answers.filter((answer) => !gone.has(answer.file))
|
|
28791
29746
|
};
|
|
28792
29747
|
};
|
|
28793
|
-
var correctionTrailSchema =
|
|
28794
|
-
|
|
29748
|
+
var correctionTrailSchema = z75.array(
|
|
29749
|
+
z75.looseObject({ outcome: z75.string().optional() })
|
|
28795
29750
|
);
|
|
28796
29751
|
var Scorecard = class {
|
|
28797
29752
|
#ctx;
|
|
@@ -28830,7 +29785,7 @@ var Scorecard = class {
|
|
|
28830
29785
|
async write(verdict) {
|
|
28831
29786
|
const { dir } = this.#ctx;
|
|
28832
29787
|
const review2 = await readStoredReview(dir);
|
|
28833
|
-
const trailText = await
|
|
29788
|
+
const trailText = await readFile41(path45.join(dir, "OUT", "corrections.json"), "utf8").catch(
|
|
28834
29789
|
() => "[]"
|
|
28835
29790
|
) || "[]";
|
|
28836
29791
|
const trail = correctionTrailSchema.parse(JSON.parse(trailText));
|
|
@@ -28872,7 +29827,7 @@ var Scorecard = class {
|
|
|
28872
29827
|
return card;
|
|
28873
29828
|
}
|
|
28874
29829
|
};
|
|
28875
|
-
var reviewProgressSchema =
|
|
29830
|
+
var reviewProgressSchema = z75.object({ rounds: z75.number(), digest: z75.string(), accepted: z75.boolean() }).nullable();
|
|
28876
29831
|
var runWorkflow = async (prepared, options = {}) => {
|
|
28877
29832
|
try {
|
|
28878
29833
|
return await runWorkflowSteps(prepared, options);
|
|
@@ -28914,7 +29869,7 @@ var runWorkflowSteps = async (prepared, options) => {
|
|
|
28914
29869
|
await ctx.checkpoint?.();
|
|
28915
29870
|
const progressFile = path45.join(ctx.dir, "REVIEW", "progress.json");
|
|
28916
29871
|
const savedProgress = reviewProgressSchema.parse(
|
|
28917
|
-
JSON.parse(await
|
|
29872
|
+
JSON.parse(await readFile41(progressFile, "utf8").catch(() => "null"))
|
|
28918
29873
|
);
|
|
28919
29874
|
const progress = !force && savedProgress?.digest === await stageInputsDigest(ctx, "review") ? savedProgress : null;
|
|
28920
29875
|
let rounds = progress?.rounds ?? 0;
|
|
@@ -29218,16 +30173,16 @@ var prepareRejudgment = async ({
|
|
|
29218
30173
|
};
|
|
29219
30174
|
|
|
29220
30175
|
// src/engine/author.ts
|
|
29221
|
-
import { readFile as
|
|
30176
|
+
import { readFile as readFile42, writeFile as writeFile22 } from "node:fs/promises";
|
|
29222
30177
|
import path47 from "node:path";
|
|
29223
|
-
import { z as
|
|
29224
|
-
var authorRecordSchema =
|
|
29225
|
-
version:
|
|
29226
|
-
runId:
|
|
29227
|
-
brief:
|
|
29228
|
-
proposed:
|
|
29229
|
-
notes:
|
|
29230
|
-
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()
|
|
29231
30186
|
});
|
|
29232
30187
|
var proposalOf = (file) => {
|
|
29233
30188
|
const {
|
|
@@ -29239,7 +30194,7 @@ var proposalOf = (file) => {
|
|
|
29239
30194
|
return measured;
|
|
29240
30195
|
};
|
|
29241
30196
|
var readBrief = async (file) => {
|
|
29242
|
-
const text = await
|
|
30197
|
+
const text = await readFile42(file, "utf8").catch((err) => {
|
|
29243
30198
|
throw new Error(`Please check --brief: ${file} cannot be read.`, {
|
|
29244
30199
|
cause: err
|
|
29245
30200
|
});
|
|
@@ -29389,7 +30344,7 @@ var readAuthorEvidence = async (configFile, file) => {
|
|
|
29389
30344
|
return { kind: "manual" };
|
|
29390
30345
|
}
|
|
29391
30346
|
const reference2 = file.author;
|
|
29392
|
-
const text = await
|
|
30347
|
+
const text = await readFile42(
|
|
29393
30348
|
path47.join(path47.dirname(configFile), reference2.record),
|
|
29394
30349
|
"utf8"
|
|
29395
30350
|
).catch((err) => {
|
|
@@ -30156,9 +31111,9 @@ var executeRun = async ({
|
|
|
30156
31111
|
import path50 from "node:path";
|
|
30157
31112
|
|
|
30158
31113
|
// src/engine/run-status.ts
|
|
30159
|
-
import { readFile as
|
|
31114
|
+
import { readFile as readFile43, stat as stat3 } from "node:fs/promises";
|
|
30160
31115
|
import path49 from "node:path";
|
|
30161
|
-
import { z as
|
|
31116
|
+
import { z as z77 } from "zod";
|
|
30162
31117
|
var SpendCategory = {
|
|
30163
31118
|
PROBES: "probes",
|
|
30164
31119
|
STAGES: "stages",
|
|
@@ -30177,31 +31132,31 @@ var spendCategoryOf = (role) => {
|
|
|
30177
31132
|
}
|
|
30178
31133
|
return SpendCategory.HOST_CALLS;
|
|
30179
31134
|
};
|
|
30180
|
-
var ledgerCallSchema =
|
|
30181
|
-
callId:
|
|
30182
|
-
role:
|
|
30183
|
-
reservedUsd:
|
|
30184
|
-
inputTokens:
|
|
30185
|
-
maxOutputTokens:
|
|
30186
|
-
usage:
|
|
30187
|
-
costUsd:
|
|
30188
|
-
inputTokens:
|
|
30189
|
-
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()
|
|
30190
31145
|
}).optional()
|
|
30191
31146
|
});
|
|
30192
|
-
var ledgerSchema =
|
|
30193
|
-
limits:
|
|
30194
|
-
calls:
|
|
31147
|
+
var ledgerSchema = z77.looseObject({
|
|
31148
|
+
limits: z77.looseObject({ maxUsd: z77.number(), deadlineAt: z77.string() }),
|
|
31149
|
+
calls: z77.record(z77.string(), ledgerCallSchema)
|
|
30195
31150
|
});
|
|
30196
|
-
var budgetStateSchema2 =
|
|
30197
|
-
current:
|
|
30198
|
-
deadlineAt:
|
|
30199
|
-
model:
|
|
31151
|
+
var budgetStateSchema2 = z77.looseObject({
|
|
31152
|
+
current: z77.looseObject({ maxUsd: z77.number() }),
|
|
31153
|
+
deadlineAt: z77.string(),
|
|
31154
|
+
model: z77.string().optional()
|
|
30200
31155
|
});
|
|
30201
31156
|
var workflowStages = ["analyze", "qualify", "review", "write"];
|
|
30202
31157
|
var readText2 = async (file) => {
|
|
30203
31158
|
try {
|
|
30204
|
-
return await
|
|
31159
|
+
return await readFile43(file, "utf8");
|
|
30205
31160
|
} catch (err) {
|
|
30206
31161
|
if (hasErrorCode(err, "ENOENT")) {
|
|
30207
31162
|
return void 0;
|