literally-aeo 0.2.0 → 0.2.2
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 +29 -1
- package/dist/author-tools.js +479 -397
- package/dist/cli.mjs +808 -386
- package/dist/lib/access/schema.js +6 -6
- package/dist/lib/agents/author-schema.js +10 -10
- package/dist/lib/agents/author-validation.js +20 -18
- package/dist/lib/agents/copy-validation.js +22 -21
- package/dist/lib/agents/copywriter-input.js +23 -8
- package/dist/lib/agents/facts.js +22 -7
- package/dist/lib/agents/narrative-facts.js +20 -2
- package/dist/lib/agents/verifier.js +25 -24
- package/dist/lib/analysis/domain-classifier.js +19 -20
- package/dist/lib/analysis/domain-labels.js +10 -10
- package/dist/lib/analysis/progress-schema.js +2 -2
- package/dist/lib/analysis/progress.js +18 -19
- package/dist/lib/analysis/retrieval.js +20 -3
- package/dist/lib/analysis/scoring.js +20 -3
- package/dist/lib/analysis/search-analyzer.js +19 -5
- package/dist/lib/analysis/sentiment.js +16 -17
- package/dist/lib/author/examples.js +11 -11
- package/dist/lib/bundle/contracts.js +14 -12
- package/dist/lib/bundle/export.js +27 -27
- package/dist/lib/bundle/isolation.js +2 -2
- package/dist/lib/bundle/journal.js +13 -13
- package/dist/lib/bundle/project-journal.js +17 -17
- package/dist/lib/bundle/project.js +25 -25
- package/dist/lib/bundle/read.js +28 -28
- package/dist/lib/bundle/recorder.js +15 -15
- package/dist/lib/bundle/redact.js +13 -13
- package/dist/lib/bundle/trace-coverage.js +13 -13
- package/dist/lib/bundle/verify-integrity.js +15 -15
- package/dist/lib/bundle/verify-measurement.js +21 -21
- package/dist/lib/bundle/verify-report.js +29 -29
- package/dist/lib/bundle/verify.js +37 -37
- package/dist/lib/capture-manifest.js +12 -12
- package/dist/lib/checks/crawler-access.js +4 -1
- package/dist/lib/checks/money-pages.js +13 -0
- package/dist/lib/checks/renderability.js +5 -1
- package/dist/lib/checks/run-checks.js +21 -18
- package/dist/lib/chunks/{chunk-BSRKN6FU.js → chunk-2FOKEIIN.js} +1 -1
- package/dist/lib/chunks/{chunk-JXMDOAKA.js → chunk-2KH7LNK7.js} +11 -11
- package/dist/lib/chunks/{chunk-D3GE3OCB.js → chunk-3CMPR6ZZ.js} +1 -1
- package/dist/lib/chunks/{chunk-TJQ5OPLQ.js → chunk-3OE4UQIB.js} +7 -7
- package/dist/lib/chunks/{chunk-Y4OGZ3Q5.js → chunk-46PVVQYR.js} +1 -1
- package/dist/lib/chunks/{chunk-OU73OUX4.js → chunk-4GLW3ZRO.js} +67 -7
- package/dist/lib/chunks/{chunk-EV4DRS5M.js → chunk-4XIAXX7K.js} +1 -1
- package/dist/lib/chunks/{chunk-IBOWGKN7.js → chunk-52F5XYOW.js} +1 -1
- package/dist/lib/chunks/{chunk-FFOVLI3U.js → chunk-66T7JC57.js} +12 -10
- package/dist/lib/chunks/{chunk-IE7NAL6B.js → chunk-6HMHXSCS.js} +2 -2
- package/dist/lib/chunks/chunk-75DMLOQ7.js +127 -0
- package/dist/lib/chunks/{chunk-6G25V4CF.js → chunk-7CW6U5WJ.js} +1 -1
- package/dist/lib/chunks/{chunk-CUYVHXHI.js → chunk-7DNLRXEY.js} +3 -3
- package/dist/lib/chunks/{chunk-622NMXN6.js → chunk-7HM6IZ3L.js} +2 -2
- package/dist/lib/chunks/{chunk-F4W5YHDZ.js → chunk-7WO3FFPS.js} +2 -2
- package/dist/lib/chunks/{chunk-ULRXHSJL.js → chunk-7YDXD4MD.js} +9 -6
- package/dist/lib/chunks/{chunk-UEMZYHYJ.js → chunk-7YZPEX3T.js} +2 -2
- package/dist/lib/chunks/{chunk-OBXAHX3L.js → chunk-AASWJR7Q.js} +1 -5
- package/dist/lib/chunks/{chunk-NCXSNHXX.js → chunk-AJO7XVXK.js} +12 -12
- package/dist/lib/chunks/{chunk-2GU6CNQI.js → chunk-AT3XMGES.js} +5 -5
- package/dist/lib/chunks/{chunk-MNWO7EHC.js → chunk-BFWK3TBN.js} +2 -2
- package/dist/lib/chunks/{chunk-BGOIPHJZ.js → chunk-BGAHZIL3.js} +18 -12
- package/dist/lib/chunks/{chunk-ZCOI3HE2.js → chunk-BRENK356.js} +1 -1
- package/dist/lib/chunks/{chunk-KJMU5KH4.js → chunk-BXF4OC74.js} +18 -9
- package/dist/lib/chunks/{chunk-5JPYM4MD.js → chunk-BYHXNFWN.js} +1 -1
- package/dist/lib/chunks/{chunk-NCLFZOZU.js → chunk-CH7OCYDL.js} +1 -1
- package/dist/lib/chunks/{chunk-OKL7GN2F.js → chunk-DL6YQDTE.js} +31 -5
- package/dist/lib/chunks/{chunk-PDS5KWO3.js → chunk-E2YTTB6Q.js} +56 -42
- package/dist/lib/chunks/{chunk-SDWYZM64.js → chunk-EDQTINTL.js} +5 -1
- package/dist/lib/chunks/{chunk-4PD65FRJ.js → chunk-EOO5RBUW.js} +3 -3
- package/dist/lib/chunks/chunk-ESEMYWUH.js +257 -0
- package/dist/lib/chunks/{chunk-YHS5IEVZ.js → chunk-F2NSJ6PG.js} +12 -8
- package/dist/lib/chunks/{chunk-BLKLPUYR.js → chunk-F7DBTXKG.js} +6 -6
- package/dist/lib/chunks/{chunk-EE26FNSY.js → chunk-FDM2YNQL.js} +1 -1
- package/dist/lib/chunks/{chunk-RJ5R6YYA.js → chunk-FJL2V6P5.js} +6 -6
- package/dist/lib/chunks/chunk-FK2JQHAX.js +30 -0
- package/dist/lib/chunks/{chunk-QHUDJVPJ.js → chunk-GLUGYZQO.js} +7 -7
- package/dist/lib/chunks/{chunk-GNMFJ2OK.js → chunk-HCUJ2J7P.js} +8 -8
- package/dist/lib/chunks/{chunk-2ROXN2EC.js → chunk-HGGOGCPX.js} +10 -10
- package/dist/lib/chunks/{chunk-VPZQGND4.js → chunk-HGGRPOSA.js} +3 -3
- package/dist/lib/chunks/{chunk-EJ655TVU.js → chunk-I3UE52ZV.js} +2 -2
- package/dist/lib/chunks/{chunk-ML4W6KC6.js → chunk-J5NPHPXY.js} +5 -4
- package/dist/lib/chunks/{chunk-HFRAHG5C.js → chunk-J7QKT5E7.js} +17 -17
- package/dist/lib/chunks/{chunk-V7OAPKNF.js → chunk-JBOOD6MU.js} +10 -9
- package/dist/lib/chunks/{chunk-YAAUWCJ4.js → chunk-JKPBXPCW.js} +3 -3
- package/dist/lib/chunks/{chunk-5HT55QYX.js → chunk-JQDQVG3D.js} +1 -1
- package/dist/lib/chunks/{chunk-GESHTTSA.js → chunk-JYCVBFH5.js} +2 -2
- package/dist/lib/chunks/{chunk-W2VGLWTS.js → chunk-K2FZFESR.js} +10 -10
- package/dist/lib/chunks/{chunk-DC6PN7QJ.js → chunk-K4Y5NT4M.js} +11 -7
- package/dist/lib/chunks/chunk-K7YFL5KB.js +182 -0
- package/dist/lib/chunks/{chunk-EBUQPCKB.js → chunk-KFAT65P7.js} +1 -1
- package/dist/lib/chunks/{chunk-ZYSPTOKK.js → chunk-KQCRJIEG.js} +1 -1
- package/dist/lib/chunks/{chunk-R6XDZWUL.js → chunk-LR27H2HZ.js} +11 -11
- package/dist/lib/chunks/{chunk-FUAUPNRO.js → chunk-LTCDLURT.js} +7 -7
- package/dist/lib/chunks/{chunk-KZR25REO.js → chunk-LTI2YYU3.js} +1 -1
- package/dist/lib/chunks/{chunk-EPQHVILQ.js → chunk-MA27TFEY.js} +5 -3
- package/dist/lib/chunks/{chunk-UZJSTJFP.js → chunk-MENTBQGB.js} +6 -5
- package/dist/lib/chunks/chunk-MPJCZN4G.js +155 -0
- package/dist/lib/chunks/{chunk-BE4ENGUY.js → chunk-OOLWU667.js} +6 -6
- package/dist/lib/chunks/{chunk-QSJ4IKUF.js → chunk-PIF3GL62.js} +5 -5
- package/dist/lib/chunks/{chunk-W5X7WJYL.js → chunk-PIFTG6YW.js} +3 -3
- package/dist/lib/chunks/{chunk-YRBIC5QH.js → chunk-PKNODC6Y.js} +1 -1
- package/dist/lib/chunks/{chunk-SHUMCKCS.js → chunk-PWOYEIPF.js} +4 -4
- package/dist/lib/chunks/{chunk-RR46EDDR.js → chunk-QD3JXA3Y.js} +25 -25
- package/dist/lib/chunks/{chunk-7ZOJE6BH.js → chunk-QGZ4QSUE.js} +8 -7
- package/dist/lib/chunks/{chunk-D2INDP5W.js → chunk-R5UPOEWE.js} +9 -8
- package/dist/lib/chunks/{chunk-VKM6MMA4.js → chunk-RIJERFGU.js} +34 -3
- package/dist/lib/chunks/{chunk-5B3RNVZ6.js → chunk-RK57YZKM.js} +1 -1
- package/dist/lib/chunks/{chunk-GDKGZQ3T.js → chunk-RXSHKWZJ.js} +3 -3
- package/dist/lib/chunks/{chunk-NGHAP2P5.js → chunk-S6QOXJAL.js} +4 -4
- package/dist/lib/chunks/{chunk-6GHHNPFJ.js → chunk-SIJOQRRK.js} +1 -1
- package/dist/lib/chunks/{chunk-663HABKP.js → chunk-T6XZQOXS.js} +8 -8
- package/dist/lib/chunks/{chunk-EYKINDNK.js → chunk-TAPVCSCR.js} +1 -1
- package/dist/lib/chunks/{chunk-ISN6MBNB.js → chunk-U5USH2HB.js} +7 -7
- package/dist/lib/chunks/{chunk-MRL5RUP7.js → chunk-U6BW6LGX.js} +10 -3
- package/dist/lib/chunks/{chunk-L7MEIRJB.js → chunk-UNCUG2YS.js} +15 -6
- package/dist/lib/chunks/{chunk-3JO5TXBA.js → chunk-UYDQXXDQ.js} +4 -4
- package/dist/lib/chunks/{chunk-LOBXOZ2R.js → chunk-V5JJEEBT.js} +1 -1
- package/dist/lib/chunks/{chunk-XR44YSHT.js → chunk-VHKHYAC5.js} +30 -9
- package/dist/lib/chunks/{chunk-Z7V63UZA.js → chunk-VXDMOB7O.js} +4 -4
- package/dist/lib/chunks/{chunk-G62E525I.js → chunk-VXYQWE45.js} +2 -2
- package/dist/lib/chunks/{chunk-W5DC23OP.js → chunk-WCLKIPJV.js} +1 -1
- package/dist/lib/chunks/{chunk-7XO3SQAX.js → chunk-WDT2Y7D7.js} +1 -1
- package/dist/lib/chunks/{chunk-OVUCZLH2.js → chunk-WIBMVNIH.js} +2 -2
- package/dist/lib/chunks/{chunk-5T3V6XJS.js → chunk-WNIXDMJL.js} +1 -1
- package/dist/lib/chunks/{chunk-HTOD4W4E.js → chunk-WZGI7UVM.js} +2 -2
- package/dist/lib/chunks/{chunk-HQG63ZKO.js → chunk-XA27KAUV.js} +17 -17
- package/dist/lib/chunks/{chunk-I3XGRGXE.js → chunk-XAN4CRFP.js} +33 -41
- package/dist/lib/chunks/{chunk-AYY4MYTW.js → chunk-XFUYEFQP.js} +1 -1
- package/dist/lib/chunks/{chunk-FOCJ7HPC.js → chunk-XSER7WEB.js} +11 -11
- package/dist/lib/chunks/{chunk-WVACVWBL.js → chunk-YEUCAPKP.js} +6 -4
- package/dist/lib/chunks/{chunk-7Z27HQWL.js → chunk-YGLWQFKL.js} +3 -3
- package/dist/lib/chunks/{chunk-D7GEQVLL.js → chunk-YKJHFD64.js} +1 -1
- package/dist/lib/chunks/{chunk-OQU5IXAJ.js → chunk-ZOGIJGU3.js} +10 -10
- package/dist/lib/chunks/{chunk-5ZITQDVE.js → chunk-ZQ3ER7JD.js} +12 -13
- package/dist/lib/cli/bundle-commands.js +91 -88
- package/dist/lib/cli/run-commands.js +110 -105
- package/dist/lib/cli/status-command.js +77 -74
- package/dist/lib/codex-workflow/aggregate.js +21 -22
- package/dist/lib/codex-workflow/author-search.js +4 -3
- package/dist/lib/codex-workflow/author-tools.js +17 -15
- package/dist/lib/codex-workflow/author.js +38 -34
- package/dist/lib/codex-workflow/capture.js +25 -25
- package/dist/lib/codex-workflow/checkpoint.js +13 -13
- package/dist/lib/codex-workflow/checks.js +15 -16
- package/dist/lib/codex-workflow/copy-editor.js +31 -30
- package/dist/lib/codex-workflow/copy-recovery.js +11 -11
- package/dist/lib/codex-workflow/copy.js +28 -27
- package/dist/lib/codex-workflow/finish.js +34 -34
- package/dist/lib/codex-workflow/loop.js +65 -62
- package/dist/lib/codex-workflow/quality.js +11 -11
- package/dist/lib/codex-workflow/run-inputs.js +12 -12
- package/dist/lib/codex-workflow/run-source.js +26 -23
- package/dist/lib/codex-workflow/schemas.js +11 -11
- package/dist/lib/codex-workflow/session.js +14 -14
- package/dist/lib/codex-workflow/stage.js +45 -41
- package/dist/lib/codex-workflow/workdir.js +13 -13
- package/dist/lib/engine/audit-file.js +16 -11
- package/dist/lib/engine/author.js +53 -49
- package/dist/lib/engine/cost-estimate.js +18 -16
- package/dist/lib/engine/local-run.js +76 -73
- package/dist/lib/engine/preflight.js +12 -12
- package/dist/lib/engine/rejudge.js +82 -79
- package/dist/lib/engine/run-status.js +77 -74
- package/dist/lib/engine/templates.js +17 -12
- package/dist/lib/grounding/chromium-guard.js +13 -0
- package/dist/lib/grounding/controller.js +11 -10
- package/dist/lib/grounding/extract.js +10 -9
- package/dist/lib/grounding/fetch.js +4 -7
- package/dist/lib/grounding/file-store.js +5 -5
- package/dist/lib/grounding/grounding-runtime.js +32 -31
- package/dist/lib/grounding/guarded-request.js +18 -0
- package/dist/lib/grounding/model.js +9 -8
- package/dist/lib/grounding/profile.js +4 -4
- package/dist/lib/grounding/recorded-tools.js +16 -16
- package/dist/lib/grounding/session.js +3 -3
- package/dist/lib/grounding/tools.js +4 -3
- package/dist/lib/grounding/validation.js +2 -2
- package/dist/lib/harness/report/artifacts.js +11 -11
- package/dist/lib/harness/report/capture-coverage.js +4 -4
- package/dist/lib/lib/checkpoint.js +10 -10
- package/dist/lib/lib/progress-comparison.js +2 -2
- package/dist/lib/models/batching.js +3 -3
- package/dist/lib/models/structured.js +2 -2
- package/dist/lib/models/supported-models.js +1 -1
- package/dist/lib/pipeline.js +20 -21
- package/dist/lib/probes/agent-clis.js +10 -10
- package/dist/lib/probes/probes.js +12 -12
- package/dist/lib/probes/web-tool-guard.js +3 -3
- package/dist/lib/report/contracts.js +4 -4
- package/dist/lib/report/core/progress-comparison.js +2 -2
- package/dist/lib/report/core/progress-schema.js +2 -2
- package/dist/lib/report/core/schema.js +2 -4
- package/dist/lib/report/core/surfaces.js +1 -3
- package/dist/lib/runner.js +23 -24
- package/dist/lib/schema.js +19 -13
- package/dist/lib/section-result.js +14 -15
- package/dist/lib/stores/artifacts.js +17 -17
- package/dist/lib/stores/files.js +31 -31
- package/dist/lib/stores/local-versions.js +10 -10
- package/dist/lib/stores/memory.js +33 -33
- package/dist/lib/stores/publication.js +23 -22
- package/dist/lib/surfaces.js +1 -3
- package/dist/lib/viewer/server.js +38 -38
- package/dist/lib/workflow/schema.js +8 -8
- package/dist/types/agents/author-schema.d.ts +3 -3
- package/dist/types/analysis/scoring.d.ts +2 -2
- package/dist/types/bundle/contracts.d.ts +3 -2
- package/dist/types/checks/crawler-access.d.ts +3 -2
- package/dist/types/checks/money-pages.d.ts +19 -0
- package/dist/types/checks/renderability.d.ts +8 -1
- package/dist/types/codex-workflow/author-tools.d.ts +3 -3
- package/dist/types/codex-workflow/run-inputs.d.ts +3 -0
- package/dist/types/codex-workflow/schemas.d.ts +6 -6
- package/dist/types/engine/audit-file.d.ts +6 -1
- package/dist/types/engine/preflight.d.ts +2 -0
- package/dist/types/grounding/chromium-guard.d.ts +41 -0
- package/dist/types/grounding/fetch.d.ts +0 -10
- package/dist/types/grounding/guarded-request.d.ts +76 -0
- package/dist/types/harness/report/artifacts.d.ts +1 -0
- package/dist/types/lib/checkpoint.d.ts +5 -6
- package/dist/types/pipeline.d.ts +2 -1
- package/dist/types/probes/probes.d.ts +2 -1
- package/dist/types/report/contracts.d.ts +2 -0
- package/dist/types/report/core/schema.d.ts +3 -1
- package/dist/types/report/core/surfaces.d.ts +0 -1
- package/dist/types/schema.d.ts +22 -0
- package/dist/types/section-result.d.ts +1 -1
- package/package.json +1 -1
- package/resources/guide/OPERATOR.md +12 -3
- package/src/agents/author-schema.ts +13 -1
- package/src/agents/author-validation.ts +24 -6
- package/src/agents/facts.ts +8 -8
- package/src/agents/narrative-facts.ts +9 -20
- package/src/agents/verifier.ts +2 -2
- package/src/analysis/progress.ts +1 -0
- package/src/analysis/scoring.ts +9 -13
- package/src/bundle/contracts.ts +7 -2
- package/src/bundle/verify.ts +3 -3
- package/src/capture-manifest.ts +4 -0
- package/src/checks/crawler-access.ts +70 -50
- package/src/checks/money-pages.ts +48 -0
- package/src/checks/renderability.ts +113 -87
- package/src/checks/run-checks.ts +16 -3
- package/src/cli/run-commands.ts +2 -0
- package/src/codex-workflow/aggregate.ts +1 -0
- package/src/codex-workflow/author-tools.ts +39 -60
- package/src/codex-workflow/capture.ts +1 -0
- package/src/codex-workflow/copy-editor.ts +3 -3
- package/src/codex-workflow/loop.ts +2 -2
- package/src/engine/audit-file.ts +79 -2
- package/src/engine/guide/OPERATOR.md +12 -3
- package/src/engine/preflight.ts +50 -0
- package/src/grounding/chromium-guard.ts +273 -0
- package/src/grounding/controller.ts +1 -1
- package/src/grounding/fetch.ts +39 -276
- package/src/grounding/guarded-request.ts +428 -0
- package/src/grounding/tools.ts +2 -1
- package/src/grounding/validation.ts +1 -1
- package/src/lib/checkpoint.ts +15 -16
- package/src/models/supported-models.ts +3 -3
- package/src/pipeline.ts +13 -7
- package/src/probes/agent-clis.ts +2 -3
- package/src/probes/probes.ts +24 -10
- package/src/report/core/schema.ts +4 -1
- package/src/report/core/surfaces.ts +4 -8
- package/src/runner.ts +1 -0
- package/src/schema.ts +68 -4
- package/src/section-result.ts +6 -5
- package/dist/lib/chunks/chunk-6EH4N3EU.js +0 -113
- package/dist/lib/chunks/chunk-SWJ7KQSL.js +0 -318
- package/dist/lib/chunks/{chunk-CO5T6WU5.js → chunk-OD36HUXA.js} +3 -3
- package/dist/lib/chunks/{chunk-XI5H46DF.js → chunk-SASE7U6E.js} +3 -3
|
@@ -21,7 +21,6 @@ export {
|
|
|
21
21
|
chatSurfaces,
|
|
22
22
|
surfaceRunCounts,
|
|
23
23
|
isAgentSurface,
|
|
24
|
-
plannedRunsPerPrompt,
|
|
25
24
|
} from './surfaces';
|
|
26
25
|
export type { AeoAgentSurface, AeoChatSurface, AeoSurface } from './surfaces';
|
|
27
26
|
|
|
@@ -298,6 +297,10 @@ export const aeoTechnicalChecksSchema = z.object({
|
|
|
298
297
|
robotsUrl: z.string(),
|
|
299
298
|
fetchedAt: z.string(),
|
|
300
299
|
robotsFetchError: z.string().nullable(),
|
|
300
|
+
// True when robots.txt ran past the 500 KiB RFC 9309 asks a reader to
|
|
301
|
+
// parse: the verdicts rest on that prefix. Absent on snapshots written
|
|
302
|
+
// before the bound existed.
|
|
303
|
+
robotsTruncated: z.boolean().optional(),
|
|
301
304
|
bots: z.array(
|
|
302
305
|
z.object({
|
|
303
306
|
bot: z.string(),
|
|
@@ -44,8 +44,10 @@ export const isAgentSurface = (surface: string): surface is AeoAgentSurface => {
|
|
|
44
44
|
|
|
45
45
|
// Runs per prompt per surface — canonical (2/2/2/2/1 for the chat surfaces,
|
|
46
46
|
// matching the console exactly; 2 each for the agent CLIs per spec §5).
|
|
47
|
-
//
|
|
48
|
-
//
|
|
47
|
+
// The default depth: a config's chatProbes and agentProbes override it, and
|
|
48
|
+
// runsPerPromptOn (schema.ts) is the rule every planned-run denominator
|
|
49
|
+
// reads, so a captured-answer shortfall lowers share of voice instead of
|
|
50
|
+
// hiding.
|
|
49
51
|
export const surfaceRunCounts: Readonly<Record<AeoSurface, number>> = {
|
|
50
52
|
chatgpt: 2,
|
|
51
53
|
gemini: 2,
|
|
@@ -56,9 +58,3 @@ export const surfaceRunCounts: Readonly<Record<AeoSurface, number>> = {
|
|
|
56
58
|
codex: 2,
|
|
57
59
|
cursor: 2,
|
|
58
60
|
};
|
|
59
|
-
|
|
60
|
-
export const plannedRunsPerPrompt = (
|
|
61
|
-
surfaces: readonly AeoSurface[],
|
|
62
|
-
): number => {
|
|
63
|
-
return surfaces.reduce((sum, surface) => sum + surfaceRunCounts[surface], 0);
|
|
64
|
-
};
|
package/src/runner.ts
CHANGED
package/src/schema.ts
CHANGED
|
@@ -4,7 +4,11 @@ import {
|
|
|
4
4
|
brandSchema,
|
|
5
5
|
aeoPromptSchema,
|
|
6
6
|
aeoSurfaceSchema,
|
|
7
|
+
isAgentSurface,
|
|
7
8
|
sourceCategorySchema,
|
|
9
|
+
surfaceRunCounts,
|
|
10
|
+
type AeoChatSurface,
|
|
11
|
+
type AeoSurface,
|
|
8
12
|
} from './report/core/schema';
|
|
9
13
|
import { coverageThresholdsSchema } from './coverage-schema';
|
|
10
14
|
import { groundingBundleSchema } from './grounding/schema';
|
|
@@ -23,13 +27,21 @@ export const aeoSectionConfigSchema = z.object({
|
|
|
23
27
|
competitors: z.array(brandSchema).optional(),
|
|
24
28
|
});
|
|
25
29
|
|
|
30
|
+
// Measurement depth: how many times each prompt is asked on a surface. A
|
|
31
|
+
// report may measure fewer prompts more deeply. The ceiling keeps one
|
|
32
|
+
// typo from planning thousands of paid answers; maxPlannedUnits and the
|
|
33
|
+
// budget still bound the run as a whole.
|
|
34
|
+
const maxRunsPerPrompt = 25;
|
|
35
|
+
|
|
36
|
+
const runsPerPromptSchema = z.number().int().min(1).max(maxRunsPerPrompt);
|
|
37
|
+
|
|
26
38
|
// Agent probe volume (spec §5, revised 2026-08-21): defaults are the
|
|
27
|
-
// canonical 2 runs per prompt over every prompt
|
|
28
|
-
//
|
|
29
|
-
//
|
|
39
|
+
// canonical 2 runs per prompt over every prompt. Changing either value after
|
|
40
|
+
// the first committed run is an agent-baseline reset — call it out in the
|
|
41
|
+
// methodology note.
|
|
30
42
|
export const agentProbeConfigSchema = z.object({
|
|
31
43
|
// Runs per prompt per agent surface.
|
|
32
|
-
runsPerPrompt:
|
|
44
|
+
runsPerPrompt: runsPerPromptSchema.default(2),
|
|
33
45
|
// Cap on how many of each section's prompts get agent probes — the FIRST N
|
|
34
46
|
// prompts in config order, so the subset is stable across runs. Omitted =
|
|
35
47
|
// all prompts.
|
|
@@ -38,6 +50,55 @@ export const agentProbeConfigSchema = z.object({
|
|
|
38
50
|
|
|
39
51
|
export type AgentProbeConfig = z.infer<typeof agentProbeConfigSchema>;
|
|
40
52
|
|
|
53
|
+
/** agentProbedPrompts is the prompts the coding agents are asked: the first
|
|
54
|
+
* maxPromptsPerSection in config order, or every prompt. */
|
|
55
|
+
export const agentProbedPrompts = <Prompt>(
|
|
56
|
+
prompts: readonly Prompt[],
|
|
57
|
+
agentProbes: AgentProbeConfig,
|
|
58
|
+
): Prompt[] => {
|
|
59
|
+
return prompts.slice(0, agentProbes.maxPromptsPerSection ?? prompts.length);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// Chat probe volume. Optional with no default, so a config without it parses,
|
|
63
|
+
// and digests, exactly as configs did before chat depth was configurable:
|
|
64
|
+
// bundles exported earlier still verify. Omitted = the canonical
|
|
65
|
+
// surfaceRunCounts (2 per surface, 1 for AI Overview); set = that many runs
|
|
66
|
+
// on every chat surface. AI Overview included: each of its runs is a live
|
|
67
|
+
// search, sampling whether an overview appears and what it says.
|
|
68
|
+
export const chatProbeConfigSchema = z
|
|
69
|
+
.object({ runsPerPrompt: runsPerPromptSchema })
|
|
70
|
+
.strict();
|
|
71
|
+
|
|
72
|
+
export type ChatProbeConfig = z.infer<typeof chatProbeConfigSchema>;
|
|
73
|
+
|
|
74
|
+
/** chatRunsPerPrompt is how many times each prompt is asked on a chat
|
|
75
|
+
* surface. */
|
|
76
|
+
export const chatRunsPerPrompt = (
|
|
77
|
+
surface: AeoChatSurface,
|
|
78
|
+
chatProbes: ChatProbeConfig | undefined,
|
|
79
|
+
): number => {
|
|
80
|
+
return chatProbes?.runsPerPrompt ?? surfaceRunCounts[surface];
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type ProbeDepth = {
|
|
84
|
+
agentProbes: AgentProbeConfig;
|
|
85
|
+
chatProbes: ChatProbeConfig | undefined;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/** runsPerPromptOn is how many times each prompt is asked on a surface: the
|
|
89
|
+
* depth the plan is built at, which the probe batches and every
|
|
90
|
+
* planned-answer denominator must match. */
|
|
91
|
+
export const runsPerPromptOn = (
|
|
92
|
+
surface: AeoSurface,
|
|
93
|
+
depth: ProbeDepth,
|
|
94
|
+
): number => {
|
|
95
|
+
if (isAgentSurface(surface)) {
|
|
96
|
+
return depth.agentProbes.runsPerPrompt;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return chatRunsPerPrompt(surface, depth.chatProbes);
|
|
100
|
+
};
|
|
101
|
+
|
|
41
102
|
const ownedCompetitorDomainSchema = z
|
|
42
103
|
.string()
|
|
43
104
|
.trim()
|
|
@@ -67,6 +128,9 @@ export const aeoAuditConfigSchema = z.object({
|
|
|
67
128
|
// the schema — consumers read config.agentProbes directly, no fallbacks.
|
|
68
129
|
// prefault({}) runs {} through the inner schema so its own defaults fill.
|
|
69
130
|
agentProbes: agentProbeConfigSchema.prefault({}),
|
|
131
|
+
// Read through runsPerPromptOn or chatRunsPerPrompt, which own the
|
|
132
|
+
// fallback to the canonical counts.
|
|
133
|
+
chatProbes: chatProbeConfigSchema.optional(),
|
|
70
134
|
// Renderability targets — docs, pricing, comparison pages (§7.4).
|
|
71
135
|
moneyPages: z.array(z.string().url()),
|
|
72
136
|
// Grounds accuracy flagging (§7.2): claims contradicting this brief are
|
package/src/section-result.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
AeoVisibility,
|
|
7
7
|
} from './schema';
|
|
8
8
|
import {
|
|
9
|
+
agentProbedPrompts,
|
|
9
10
|
agentSurfaces,
|
|
10
11
|
allSurfaces,
|
|
11
12
|
chatSurfaces,
|
|
@@ -48,6 +49,7 @@ export const assembleSectionResult = (
|
|
|
48
49
|
| 'prompts'
|
|
49
50
|
| 'surfaces'
|
|
50
51
|
| 'agentProbes'
|
|
52
|
+
| 'chatProbes'
|
|
51
53
|
>,
|
|
52
54
|
capture: SectionCaptureSummary,
|
|
53
55
|
analyses: readonly PromptAnalysisResult[],
|
|
@@ -60,10 +62,8 @@ export const assembleSectionResult = (
|
|
|
60
62
|
(s): s is AeoAgentSurface => isAgentSurface(s),
|
|
61
63
|
);
|
|
62
64
|
|
|
63
|
-
const
|
|
64
|
-
const agentPrompts = args.agentProbes
|
|
65
|
-
? args.prompts.slice(0, args.agentProbes.maxPromptsPerSection)
|
|
66
|
-
: args.prompts;
|
|
65
|
+
const depth = { agentProbes: args.agentProbes, chatProbes: args.chatProbes };
|
|
66
|
+
const agentPrompts = agentProbedPrompts(args.prompts, args.agentProbes);
|
|
67
67
|
|
|
68
68
|
const probeCount = capture.probeCount;
|
|
69
69
|
const analysisFailures: SectionRunResult['analysisFailures'] =
|
|
@@ -120,6 +120,7 @@ export const assembleSectionResult = (
|
|
|
120
120
|
.filter((r) => !isAgentSurface(r.surface))
|
|
121
121
|
.map(toScoringInput),
|
|
122
122
|
surfaces: selectedChatSurfaces,
|
|
123
|
+
depth,
|
|
123
124
|
})
|
|
124
125
|
: null;
|
|
125
126
|
|
|
@@ -134,7 +135,7 @@ export const assembleSectionResult = (
|
|
|
134
135
|
prompts: agentPromptsForScoring,
|
|
135
136
|
results: agentResults.map(toScoringInput),
|
|
136
137
|
surfaces: selectedAgentSurfaces,
|
|
137
|
-
|
|
138
|
+
depth,
|
|
138
139
|
})
|
|
139
140
|
: null;
|
|
140
141
|
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createLog
|
|
3
|
-
} from "./chunk-ZSEY7AHQ.js";
|
|
4
|
-
|
|
5
|
-
// src/checks/renderability.ts
|
|
6
|
-
import { load } from "cheerio";
|
|
7
|
-
var log = createLog("Renderability");
|
|
8
|
-
var fetchTimeoutMs = 2e4;
|
|
9
|
-
var renderTimeoutMs = 45e3;
|
|
10
|
-
var settleTimeoutMs = 8e3;
|
|
11
|
-
var missingRatioThreshold = 0.4;
|
|
12
|
-
var missingCharsThreshold = 500;
|
|
13
|
-
var runRenderabilityCheck = async (moneyPages) => {
|
|
14
|
-
if (moneyPages.length === 0) {
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
const { chromium } = await import("playwright");
|
|
18
|
-
const browser = await chromium.launch();
|
|
19
|
-
try {
|
|
20
|
-
const results = [];
|
|
21
|
-
for (const url of moneyPages) {
|
|
22
|
-
const pageStartedAt = Date.now();
|
|
23
|
-
const result = await checkPage(url, browser);
|
|
24
|
-
results.push(result);
|
|
25
|
-
log.debug("Renderability page checked", {
|
|
26
|
-
url,
|
|
27
|
-
durationMs: Date.now() - pageStartedAt,
|
|
28
|
-
staticTextChars: result.staticTextChars,
|
|
29
|
-
renderedTextChars: result.renderedTextChars,
|
|
30
|
-
flagged: result.flagged,
|
|
31
|
-
error: result.error
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
log.info("Renderability check completed", {
|
|
35
|
-
pages: results.length,
|
|
36
|
-
flagged: results.filter((r) => r.flagged).length,
|
|
37
|
-
errors: results.filter((r) => r.error).length
|
|
38
|
-
});
|
|
39
|
-
return results;
|
|
40
|
-
} finally {
|
|
41
|
-
await browser.close();
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var checkPage = async (url, browser) => {
|
|
45
|
-
try {
|
|
46
|
-
const response = await fetch(url, {
|
|
47
|
-
signal: AbortSignal.timeout(fetchTimeoutMs),
|
|
48
|
-
headers: { "user-agent": "literally-aeo-audit/1.0" }
|
|
49
|
-
});
|
|
50
|
-
if (!response.ok) {
|
|
51
|
-
return {
|
|
52
|
-
url,
|
|
53
|
-
staticTextChars: 0,
|
|
54
|
-
renderedTextChars: 0,
|
|
55
|
-
missingRatio: 0,
|
|
56
|
-
flagged: false,
|
|
57
|
-
error: `Static fetch failed: HTTP ${response.status}`
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
const staticText = extractText(await response.text());
|
|
61
|
-
const page = await browser.newPage();
|
|
62
|
-
let renderedText;
|
|
63
|
-
try {
|
|
64
|
-
await page.goto(url, { waitUntil: "load", timeout: renderTimeoutMs });
|
|
65
|
-
await page.waitForLoadState("networkidle", { timeout: settleTimeoutMs }).catch(() => void 0);
|
|
66
|
-
renderedText = normalizeWhitespace(
|
|
67
|
-
await page.evaluate(
|
|
68
|
-
() => document.querySelector("body")?.innerText ?? ""
|
|
69
|
-
)
|
|
70
|
-
);
|
|
71
|
-
} finally {
|
|
72
|
-
await page.close();
|
|
73
|
-
}
|
|
74
|
-
const staticChars = staticText.length;
|
|
75
|
-
const renderedChars = renderedText.length;
|
|
76
|
-
const missingChars = Math.max(0, renderedChars - staticChars);
|
|
77
|
-
const missingRatio = renderedChars > 0 ? missingChars / renderedChars : 0;
|
|
78
|
-
const flagged = missingRatio > missingRatioThreshold && missingChars > missingCharsThreshold;
|
|
79
|
-
return {
|
|
80
|
-
url,
|
|
81
|
-
staticTextChars: staticChars,
|
|
82
|
-
renderedTextChars: renderedChars,
|
|
83
|
-
missingRatio: Math.round(missingRatio * 1e3) / 1e3,
|
|
84
|
-
flagged,
|
|
85
|
-
error: null
|
|
86
|
-
};
|
|
87
|
-
} catch (error) {
|
|
88
|
-
log.warn("Renderability check failed for page", {
|
|
89
|
-
url,
|
|
90
|
-
error: String(error)
|
|
91
|
-
});
|
|
92
|
-
return {
|
|
93
|
-
url,
|
|
94
|
-
staticTextChars: 0,
|
|
95
|
-
renderedTextChars: 0,
|
|
96
|
-
missingRatio: 0,
|
|
97
|
-
flagged: false,
|
|
98
|
-
error: error instanceof Error ? error.message : String(error)
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
var extractText = (html) => {
|
|
103
|
-
const $ = load(html);
|
|
104
|
-
$("script, style, noscript, template").remove();
|
|
105
|
-
return normalizeWhitespace($("body").text());
|
|
106
|
-
};
|
|
107
|
-
var normalizeWhitespace = (text) => {
|
|
108
|
-
return text.replace(/\s+/g, " ").trim();
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export {
|
|
112
|
-
runRenderabilityCheck
|
|
113
|
-
};
|
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isPublicAddress
|
|
3
|
-
} from "./chunk-NL2LDKXX.js";
|
|
4
|
-
import {
|
|
5
|
-
contentHash
|
|
6
|
-
} from "./chunk-H2KDLDK6.js";
|
|
7
|
-
import {
|
|
8
|
-
sourceExtractionVersion
|
|
9
|
-
} from "./chunk-6RAKXYSR.js";
|
|
10
|
-
|
|
11
|
-
// src/grounding/fetch.ts
|
|
12
|
-
import { lookup } from "node:dns/promises";
|
|
13
|
-
import { isIP } from "node:net";
|
|
14
|
-
import { request } from "node:https";
|
|
15
|
-
import { load } from "cheerio";
|
|
16
|
-
var sourceLimits = {
|
|
17
|
-
timeoutMs: 15e3,
|
|
18
|
-
receivedBytes: 2097152,
|
|
19
|
-
retainedBytes: 16384,
|
|
20
|
-
redirects: 3
|
|
21
|
-
};
|
|
22
|
-
var SourceRetrievalError = class extends Error {
|
|
23
|
-
reason;
|
|
24
|
-
status;
|
|
25
|
-
constructor(reason, message, { status, cause } = {}) {
|
|
26
|
-
super(message, cause === void 0 ? void 0 : { cause });
|
|
27
|
-
this.name = "SourceRetrievalError";
|
|
28
|
-
this.reason = reason;
|
|
29
|
-
this.status = status;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
var validateResearchUrl = (value) => {
|
|
33
|
-
let url;
|
|
34
|
-
try {
|
|
35
|
-
url = new URL(value);
|
|
36
|
-
} catch {
|
|
37
|
-
throw new SourceRetrievalError(
|
|
38
|
-
"unsafe_destination",
|
|
39
|
-
`Invalid source URL: ${value}.`
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
if (url.protocol !== "https:" || url.username || url.password || url.port || url.hostname === "localhost" || url.hostname.endsWith(".localhost") || url.hostname.endsWith(".local") || url.hostname.endsWith(".internal") || url.hostname === "metadata.google.internal") {
|
|
43
|
-
throw new SourceRetrievalError(
|
|
44
|
-
"unsafe_destination",
|
|
45
|
-
`Source must use public HTTPS with no credentials: ${url.hostname}.`
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
const host = url.hostname.replace(/^\[|\]$/g, "");
|
|
49
|
-
if (isIP(host) && !isPublicAddress(host)) {
|
|
50
|
-
throw new SourceRetrievalError(
|
|
51
|
-
"unsafe_destination",
|
|
52
|
-
`Private source destination: ${host}.`
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
url.hash = "";
|
|
56
|
-
return url;
|
|
57
|
-
};
|
|
58
|
-
var canonicalResearchUrl = (value) => {
|
|
59
|
-
const url = new URL(value);
|
|
60
|
-
url.hash = "";
|
|
61
|
-
url.hostname = url.hostname.toLowerCase();
|
|
62
|
-
if (url.pathname.length > 1 && url.pathname.endsWith("/")) {
|
|
63
|
-
url.pathname = url.pathname.slice(0, -1);
|
|
64
|
-
}
|
|
65
|
-
return url.href;
|
|
66
|
-
};
|
|
67
|
-
var withAbort = (promise, signal) => {
|
|
68
|
-
signal.throwIfAborted();
|
|
69
|
-
return new Promise((resolve, reject) => {
|
|
70
|
-
const aborted = () => {
|
|
71
|
-
reject(signal.reason);
|
|
72
|
-
};
|
|
73
|
-
signal.addEventListener("abort", aborted, { once: true });
|
|
74
|
-
promise.then(resolve, reject).finally(() => {
|
|
75
|
-
signal.removeEventListener("abort", aborted);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
var requestDocument = async (url, signal) => {
|
|
80
|
-
const host = url.hostname.replace(/^\[|\]$/g, "");
|
|
81
|
-
const addresses = await withAbort(lookup(host, { all: true }), signal);
|
|
82
|
-
if (addresses.length === 0 || addresses.some(({ address }) => !isPublicAddress(address))) {
|
|
83
|
-
throw new SourceRetrievalError(
|
|
84
|
-
"unsafe_destination",
|
|
85
|
-
`Source DNS must resolve exclusively to public addresses: ${host}.`
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
const [firstAddress] = addresses;
|
|
89
|
-
if (!firstAddress) {
|
|
90
|
-
throw new SourceRetrievalError(
|
|
91
|
-
"unsafe_destination",
|
|
92
|
-
`Source DNS returned no address: ${host}.`
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
signal.throwIfAborted();
|
|
96
|
-
return new Promise((resolve, reject) => {
|
|
97
|
-
const req = request(
|
|
98
|
-
url,
|
|
99
|
-
{
|
|
100
|
-
method: "GET",
|
|
101
|
-
signal,
|
|
102
|
-
headers: {
|
|
103
|
-
"accept": "text/html,text/plain",
|
|
104
|
-
"accept-encoding": "identity",
|
|
105
|
-
"user-agent": "Literally-AEO-Research/1"
|
|
106
|
-
},
|
|
107
|
-
lookup: (_host, options, callback) => {
|
|
108
|
-
if (options.all) {
|
|
109
|
-
callback(null, [firstAddress]);
|
|
110
|
-
} else {
|
|
111
|
-
callback(null, firstAddress.address, firstAddress.family);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
(response) => {
|
|
116
|
-
const status = response.statusCode ?? 0;
|
|
117
|
-
const contentType = response.headers["content-type"] ?? "";
|
|
118
|
-
if (status >= 300 && status < 400) {
|
|
119
|
-
response.destroy();
|
|
120
|
-
resolve({
|
|
121
|
-
status,
|
|
122
|
-
location: response.headers.location,
|
|
123
|
-
contentType,
|
|
124
|
-
body: ""
|
|
125
|
-
});
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
if (status < 200 || status >= 300) {
|
|
129
|
-
response.destroy();
|
|
130
|
-
reject(
|
|
131
|
-
new SourceRetrievalError("http_error", `Source HTTP ${status}.`, {
|
|
132
|
-
status
|
|
133
|
-
})
|
|
134
|
-
);
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
if (!/^(text\/html|text\/plain|application\/xhtml\+xml)(;|$)/i.test(
|
|
138
|
-
contentType
|
|
139
|
-
) || response.headers["content-encoding"] && response.headers["content-encoding"] !== "identity") {
|
|
140
|
-
response.destroy();
|
|
141
|
-
reject(
|
|
142
|
-
new SourceRetrievalError(
|
|
143
|
-
"unsupported_content",
|
|
144
|
-
`Unsupported source content: ${contentType}.`
|
|
145
|
-
)
|
|
146
|
-
);
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
const chunks = [];
|
|
150
|
-
let bytes = 0;
|
|
151
|
-
response.on("data", (chunk) => {
|
|
152
|
-
bytes += chunk.length;
|
|
153
|
-
if (bytes > sourceLimits.receivedBytes) {
|
|
154
|
-
response.destroy();
|
|
155
|
-
reject(
|
|
156
|
-
new SourceRetrievalError(
|
|
157
|
-
"too_large",
|
|
158
|
-
`Source response exceeds byte limit: ${bytes} bytes.`
|
|
159
|
-
)
|
|
160
|
-
);
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
chunks.push(chunk);
|
|
164
|
-
});
|
|
165
|
-
response.once("error", reject);
|
|
166
|
-
response.once("end", () => {
|
|
167
|
-
resolve({
|
|
168
|
-
status,
|
|
169
|
-
contentType,
|
|
170
|
-
body: Buffer.concat(chunks).toString("utf8")
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
);
|
|
175
|
-
req.once("error", reject);
|
|
176
|
-
req.end();
|
|
177
|
-
});
|
|
178
|
-
};
|
|
179
|
-
var boundedUtf8 = (text, bytes) => {
|
|
180
|
-
return Buffer.from(text).subarray(0, bytes).toString("utf8").replace(/\uFFFD$/, "");
|
|
181
|
-
};
|
|
182
|
-
var extractSourceDocument = (args) => {
|
|
183
|
-
const final = validateResearchUrl(args.finalUrl);
|
|
184
|
-
validateResearchUrl(args.requestedUrl);
|
|
185
|
-
if (Buffer.byteLength(args.body) > sourceLimits.receivedBytes) {
|
|
186
|
-
throw new SourceRetrievalError(
|
|
187
|
-
"too_large",
|
|
188
|
-
`Source response exceeds byte limit: ${Buffer.byteLength(args.body)} bytes.`
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
let text;
|
|
192
|
-
let title = "";
|
|
193
|
-
let sourceDate = null;
|
|
194
|
-
const links = [];
|
|
195
|
-
if (/html/i.test(args.contentType)) {
|
|
196
|
-
const $ = load(args.body);
|
|
197
|
-
title = $("title").first().text().trim().slice(0, 500);
|
|
198
|
-
const declaredDate = $('meta[property="article:published_time"]').attr("content") ?? $('meta[name="date"]').attr("content");
|
|
199
|
-
if (declaredDate && /^\d{4}-\d{2}-\d{2}(?:T|$)/.test(declaredDate) && Number.isFinite(Date.parse(declaredDate))) {
|
|
200
|
-
sourceDate = new Date(declaredDate).toISOString();
|
|
201
|
-
}
|
|
202
|
-
$(
|
|
203
|
-
"script,style,noscript,iframe,object,embed,svg,form,input,button,nav,footer,header"
|
|
204
|
-
).remove();
|
|
205
|
-
$("a[href]").each((_index, element) => {
|
|
206
|
-
const href = $(element).attr("href");
|
|
207
|
-
if (links.length >= 100 || href === void 0) {
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
try {
|
|
211
|
-
const url = validateResearchUrl(new URL(href, final).href).href;
|
|
212
|
-
if (!links.includes(url)) {
|
|
213
|
-
links.push(url);
|
|
214
|
-
}
|
|
215
|
-
} catch {
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
$("p,div,li,h1,h2,h3,h4,section,article,br,tr").append("\n");
|
|
219
|
-
text = ($("main").length ? $("main").text() : $("body").text()).replace(/[\t\r ]+/g, " ").replace(/\n\s*\n+/g, "\n\n").trim();
|
|
220
|
-
} else {
|
|
221
|
-
text = args.body.replace(/\r\n/g, "\n").trim();
|
|
222
|
-
}
|
|
223
|
-
if (!text) {
|
|
224
|
-
throw new SourceRetrievalError(
|
|
225
|
-
"empty_content",
|
|
226
|
-
`No readable source text: ${final.href}.`
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
const documentDigest = contentHash(text);
|
|
230
|
-
const retained = boundedUtf8(text, sourceLimits.retainedBytes);
|
|
231
|
-
const id = `src_${contentHash({ url: final.href, documentDigest }).slice(0, 32)}`;
|
|
232
|
-
const passages = [
|
|
233
|
-
{ id: `${id}_p0`, text: retained, digest: contentHash(retained) }
|
|
234
|
-
];
|
|
235
|
-
return {
|
|
236
|
-
source: {
|
|
237
|
-
id,
|
|
238
|
-
requestedUrl: args.requestedUrl,
|
|
239
|
-
finalUrl: final.href,
|
|
240
|
-
title,
|
|
241
|
-
publisher: final.hostname,
|
|
242
|
-
provenance: args.firstPartyHosts?.includes(final.hostname) ? "first_party" : "unknown",
|
|
243
|
-
fetchedAt: args.fetchedAt,
|
|
244
|
-
sourceDate,
|
|
245
|
-
documentDigest,
|
|
246
|
-
retainedDigest: contentHash(passages.map((passage) => passage.text)),
|
|
247
|
-
passages,
|
|
248
|
-
extractionVersion: sourceExtractionVersion,
|
|
249
|
-
truncated: retained !== text
|
|
250
|
-
},
|
|
251
|
-
links,
|
|
252
|
-
// The whole extracted text, for a reader that keeps more than the
|
|
253
|
-
// grounding passage (the author's research tools keep 32 KB).
|
|
254
|
-
text
|
|
255
|
-
};
|
|
256
|
-
};
|
|
257
|
-
var fetchGroundingSource = async (args) => {
|
|
258
|
-
const signal = AbortSignal.any([
|
|
259
|
-
AbortSignal.timeout(sourceLimits.timeoutMs),
|
|
260
|
-
...args.signal ? [args.signal] : []
|
|
261
|
-
]);
|
|
262
|
-
let url = validateResearchUrl(args.url);
|
|
263
|
-
try {
|
|
264
|
-
for (let redirects = 0; redirects <= sourceLimits.redirects; redirects += 1) {
|
|
265
|
-
await args.beforeRequest?.();
|
|
266
|
-
signal.throwIfAborted();
|
|
267
|
-
const response = await requestDocument(url, signal);
|
|
268
|
-
if (response.status >= 300 && response.status < 400) {
|
|
269
|
-
if (!response.location || redirects === sourceLimits.redirects) {
|
|
270
|
-
throw new SourceRetrievalError(
|
|
271
|
-
"http_error",
|
|
272
|
-
`Source redirect limit exceeded: ${url.href}.`
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
url = validateResearchUrl(new URL(response.location, url).href);
|
|
276
|
-
continue;
|
|
277
|
-
}
|
|
278
|
-
return {
|
|
279
|
-
...extractSourceDocument({
|
|
280
|
-
requestedUrl: args.url,
|
|
281
|
-
finalUrl: url.href,
|
|
282
|
-
body: response.body,
|
|
283
|
-
contentType: response.contentType,
|
|
284
|
-
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
285
|
-
firstPartyHosts: args.firstPartyHosts
|
|
286
|
-
}),
|
|
287
|
-
requestCount: redirects + 1,
|
|
288
|
-
bytes: Buffer.byteLength(response.body)
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
throw new SourceRetrievalError(
|
|
292
|
-
"http_error",
|
|
293
|
-
`Source redirect limit exceeded: ${url.href}.`
|
|
294
|
-
);
|
|
295
|
-
} catch (error) {
|
|
296
|
-
if (args.signal?.aborted) {
|
|
297
|
-
throw args.signal.reason;
|
|
298
|
-
}
|
|
299
|
-
if (error instanceof SourceRetrievalError) {
|
|
300
|
-
throw error;
|
|
301
|
-
}
|
|
302
|
-
throw new SourceRetrievalError(
|
|
303
|
-
signal.aborted ? "timeout" : "network_error",
|
|
304
|
-
`Source retrieval failed: ${url.href}.`,
|
|
305
|
-
{ cause: error }
|
|
306
|
-
);
|
|
307
|
-
}
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
export {
|
|
311
|
-
sourceLimits,
|
|
312
|
-
SourceRetrievalError,
|
|
313
|
-
validateResearchUrl,
|
|
314
|
-
canonicalResearchUrl,
|
|
315
|
-
boundedUtf8,
|
|
316
|
-
extractSourceDocument,
|
|
317
|
-
fetchGroundingSource
|
|
318
|
-
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
structuredWireSchema
|
|
3
|
-
} from "./chunk-Y6D6IVOM.js";
|
|
4
1
|
import {
|
|
5
2
|
structuredImageMessages,
|
|
6
3
|
structuredImageTokens
|
|
7
4
|
} from "./chunk-WDOA5JEH.js";
|
|
5
|
+
import {
|
|
6
|
+
structuredWireSchema
|
|
7
|
+
} from "./chunk-Y6D6IVOM.js";
|
|
8
8
|
import {
|
|
9
9
|
servedModelOf
|
|
10
10
|
} from "./chunk-ZVAKKRRD.js";
|
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
ModelCallAbortError
|
|
6
6
|
} from "./chunk-55U7PRRM.js";
|
|
7
|
-
import {
|
|
8
|
-
ModelBudgetError
|
|
9
|
-
} from "./chunk-TNL2GWYR.js";
|
|
10
7
|
import {
|
|
11
8
|
normalizeDomain
|
|
12
9
|
} from "./chunk-QTXOW5XC.js";
|
|
10
|
+
import {
|
|
11
|
+
ModelBudgetError
|
|
12
|
+
} from "./chunk-TNL2GWYR.js";
|
|
13
13
|
|
|
14
14
|
// src/analysis/search-analyzer.ts
|
|
15
15
|
import { APICallError } from "ai";
|