literally-aeo 0.2.0 → 0.2.1
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 +777 -382
- package/dist/lib/access/schema.js +6 -6
- package/dist/lib/agents/author-schema.js +10 -10
- package/dist/lib/agents/author-validation.js +18 -18
- package/dist/lib/agents/copy-validation.js +22 -21
- package/dist/lib/agents/copywriter-input.js +22 -7
- package/dist/lib/agents/facts.js +21 -6
- 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/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-HFRAHG5C.js → chunk-3GPUCXVA.js} +14 -14
- package/dist/lib/chunks/{chunk-TJQ5OPLQ.js → chunk-3OE4UQIB.js} +7 -7
- package/dist/lib/chunks/{chunk-FOCJ7HPC.js → chunk-3OWJBGQE.js} +11 -11
- package/dist/lib/chunks/{chunk-Y4OGZ3Q5.js → chunk-46PVVQYR.js} +1 -1
- 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-OQU5IXAJ.js → chunk-66DVMLGR.js} +10 -10
- 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-7Z27HQWL.js → chunk-6JICXLDA.js} +3 -3
- 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-622NMXN6.js → chunk-7HM6IZ3L.js} +2 -2
- package/dist/lib/chunks/{chunk-XR44YSHT.js → chunk-7LBSNDRR.js} +10 -8
- 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-NGHAP2P5.js → chunk-AAFHXNLU.js} +4 -4
- package/dist/lib/chunks/{chunk-OBXAHX3L.js → chunk-AASWJR7Q.js} +1 -5
- package/dist/lib/chunks/{chunk-VPZQGND4.js → chunk-AJKV46SM.js} +3 -3
- package/dist/lib/chunks/{chunk-NCXSNHXX.js → chunk-AJO7XVXK.js} +12 -12
- package/dist/lib/chunks/{chunk-5JPYM4MD.js → chunk-AK6YNTCV.js} +1 -1
- 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-NCLFZOZU.js → chunk-CH7OCYDL.js} +1 -1
- package/dist/lib/chunks/{chunk-FUAUPNRO.js → chunk-DDS4G4DO.js} +7 -7
- 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-UEMZYHYJ.js → chunk-E3OGPTUY.js} +1 -1
- package/dist/lib/chunks/{chunk-SDWYZM64.js → chunk-EDQTINTL.js} +5 -1
- 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-GESHTTSA.js → chunk-FIC7JSR4.js} +2 -2
- package/dist/lib/chunks/{chunk-RJ5R6YYA.js → chunk-FJL2V6P5.js} +6 -6
- package/dist/lib/chunks/{chunk-QSJ4IKUF.js → chunk-FL6LN2K6.js} +5 -5
- package/dist/lib/chunks/{chunk-663HABKP.js → chunk-HI3PD3KR.js} +8 -8
- 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-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-YRBIC5QH.js → chunk-JXBLGCXZ.js} +1 -1
- package/dist/lib/chunks/{chunk-D2INDP5W.js → chunk-JYFEXVWC.js} +7 -6
- 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-ZYSPTOKK.js → chunk-KQCRJIEG.js} +1 -1
- package/dist/lib/chunks/{chunk-RR46EDDR.js → chunk-KSOHZKV5.js} +22 -22
- package/dist/lib/chunks/{chunk-R6XDZWUL.js → chunk-LR27H2HZ.js} +11 -11
- 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-QHUDJVPJ.js → chunk-MTDYBJXH.js} +7 -7
- package/dist/lib/chunks/{chunk-BE4ENGUY.js → chunk-OQFAMKLN.js} +6 -6
- package/dist/lib/chunks/{chunk-SHUMCKCS.js → chunk-PWOYEIPF.js} +4 -4
- package/dist/lib/chunks/{chunk-4PD65FRJ.js → chunk-PXB4PWJI.js} +3 -3
- package/dist/lib/chunks/{chunk-7ZOJE6BH.js → chunk-QGZ4QSUE.js} +8 -7
- package/dist/lib/chunks/{chunk-GNMFJ2OK.js → chunk-QJZTDZMB.js} +8 -8
- package/dist/lib/chunks/{chunk-HQG63ZKO.js → chunk-R2AJYV6A.js} +17 -17
- package/dist/lib/chunks/{chunk-5B3RNVZ6.js → chunk-RK57YZKM.js} +1 -1
- package/dist/lib/chunks/{chunk-EBUQPCKB.js → chunk-RPTADJXD.js} +1 -1
- package/dist/lib/chunks/{chunk-GDKGZQ3T.js → chunk-RXSHKWZJ.js} +3 -3
- package/dist/lib/chunks/{chunk-CUYVHXHI.js → chunk-SD7LR26G.js} +3 -3
- package/dist/lib/chunks/{chunk-6GHHNPFJ.js → chunk-SIJOQRRK.js} +1 -1
- package/dist/lib/chunks/{chunk-2GU6CNQI.js → chunk-SLAPBFRH.js} +5 -5
- package/dist/lib/chunks/{chunk-2ROXN2EC.js → chunk-SMPP7B7F.js} +10 -10
- package/dist/lib/chunks/{chunk-L7MEIRJB.js → chunk-SQQ56UP2.js} +15 -6
- package/dist/lib/chunks/{chunk-WVACVWBL.js → chunk-T5XQ6NXD.js} +6 -4
- 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-3JO5TXBA.js → chunk-UYDQXXDQ.js} +4 -4
- package/dist/lib/chunks/{chunk-LOBXOZ2R.js → chunk-V5JJEEBT.js} +1 -1
- package/dist/lib/chunks/{chunk-OU73OUX4.js → chunk-VPXYGN4I.js} +71 -6
- package/dist/lib/chunks/{chunk-Z7V63UZA.js → chunk-VXDMOB7O.js} +4 -4
- 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-D3GE3OCB.js → chunk-XAKME6NM.js} +1 -1
- 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-G62E525I.js → chunk-XNTFOVCE.js} +2 -2
- package/dist/lib/chunks/{chunk-D7GEQVLL.js → chunk-YKJHFD64.js} +1 -1
- package/dist/lib/chunks/{chunk-VKM6MMA4.js → chunk-YZEZRQIG.js} +33 -2
- package/dist/lib/chunks/{chunk-5ZITQDVE.js → chunk-ZQ3ER7JD.js} +12 -13
- package/dist/lib/cli/bundle-commands.js +87 -85
- package/dist/lib/cli/run-commands.js +104 -100
- package/dist/lib/cli/status-command.js +73 -71
- 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 +36 -33
- package/dist/lib/codex-workflow/capture.js +24 -24
- 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 +30 -29
- package/dist/lib/codex-workflow/copy-recovery.js +11 -11
- package/dist/lib/codex-workflow/copy.js +27 -26
- package/dist/lib/codex-workflow/finish.js +34 -34
- package/dist/lib/codex-workflow/loop.js +62 -60
- 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 +43 -40
- package/dist/lib/codex-workflow/workdir.js +13 -13
- package/dist/lib/engine/audit-file.js +14 -10
- package/dist/lib/engine/author.js +50 -47
- package/dist/lib/engine/cost-estimate.js +18 -16
- package/dist/lib/engine/local-run.js +72 -70
- package/dist/lib/engine/preflight.js +11 -11
- package/dist/lib/engine/rejudge.js +78 -76
- package/dist/lib/engine/run-status.js +73 -71
- package/dist/lib/engine/templates.js +15 -11
- 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/pipeline.js +19 -20
- package/dist/lib/probes/agent-clis.js +10 -10
- package/dist/lib/probes/probes.js +11 -11
- 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/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 +2 -5
- 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/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 +89 -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/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
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
import type { LookupAddress } from 'node:dns';
|
|
2
|
+
import { lookup } from 'node:dns/promises';
|
|
3
|
+
import { request } from 'node:https';
|
|
4
|
+
import { isIP } from 'node:net';
|
|
5
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
6
|
+
import { isPublicAddress } from '../workflow/callbacks';
|
|
7
|
+
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// The one guard every request to a site passes through
|
|
10
|
+
// (specs/aeo-checks-and-reach-spec.md §3.1): https on port 443 with no
|
|
11
|
+
// credentials, every DNS answer public and the socket pinned to the checked
|
|
12
|
+
// address, each redirect hop validated again, an identity-encoded body bounded
|
|
13
|
+
// in bytes. The research fetch, the site checks and the Chromium proxy all
|
|
14
|
+
// decide destinations here.
|
|
15
|
+
// ============================================================================
|
|
16
|
+
|
|
17
|
+
export type SourceRetrievalReason =
|
|
18
|
+
| 'unsafe_destination'
|
|
19
|
+
| 'timeout'
|
|
20
|
+
| 'too_large'
|
|
21
|
+
| 'unsupported_content'
|
|
22
|
+
| 'http_error'
|
|
23
|
+
| 'empty_content'
|
|
24
|
+
| 'network_error';
|
|
25
|
+
|
|
26
|
+
export class SourceRetrievalError extends Error {
|
|
27
|
+
readonly reason: SourceRetrievalReason;
|
|
28
|
+
readonly status: number | undefined;
|
|
29
|
+
|
|
30
|
+
constructor(
|
|
31
|
+
reason: SourceRetrievalReason,
|
|
32
|
+
message: string,
|
|
33
|
+
{ status, cause }: { status?: number; cause?: unknown } = {},
|
|
34
|
+
) {
|
|
35
|
+
super(message, cause === undefined ? undefined : { cause });
|
|
36
|
+
this.name = 'SourceRetrievalError';
|
|
37
|
+
this.reason = reason;
|
|
38
|
+
this.status = status;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const validateResearchUrl = (value: string): URL => {
|
|
43
|
+
let url: URL;
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
url = new URL(value);
|
|
47
|
+
} catch {
|
|
48
|
+
throw new SourceRetrievalError(
|
|
49
|
+
'unsafe_destination',
|
|
50
|
+
`Invalid source URL: ${value}.`,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (
|
|
55
|
+
url.protocol !== 'https:' ||
|
|
56
|
+
url.username ||
|
|
57
|
+
url.password ||
|
|
58
|
+
url.port ||
|
|
59
|
+
url.hostname === 'localhost' ||
|
|
60
|
+
url.hostname.endsWith('.localhost') ||
|
|
61
|
+
url.hostname.endsWith('.local') ||
|
|
62
|
+
url.hostname.endsWith('.internal') ||
|
|
63
|
+
url.hostname === 'metadata.google.internal'
|
|
64
|
+
) {
|
|
65
|
+
throw new SourceRetrievalError(
|
|
66
|
+
'unsafe_destination',
|
|
67
|
+
`Source must use public HTTPS with no credentials: ${url.hostname}.`,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const host = url.hostname.replace(/^\[|\]$/g, '');
|
|
72
|
+
|
|
73
|
+
if (isIP(host) && !isPublicAddress(host)) {
|
|
74
|
+
throw new SourceRetrievalError(
|
|
75
|
+
'unsafe_destination',
|
|
76
|
+
`Private source destination: ${host}.`,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
url.hash = '';
|
|
81
|
+
|
|
82
|
+
return url;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const withAbort = <T>(promise: Promise<T>, signal: AbortSignal): Promise<T> => {
|
|
86
|
+
signal.throwIfAborted();
|
|
87
|
+
|
|
88
|
+
return new Promise((resolve, reject) => {
|
|
89
|
+
const aborted = () => {
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors -- AbortSignal.reason is typed any; rejecting with it keeps the caller's abort error.
|
|
91
|
+
reject(signal.reason);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
signal.addEventListener('abort', aborted, { once: true });
|
|
95
|
+
|
|
96
|
+
promise.then(resolve, reject).finally(() => {
|
|
97
|
+
signal.removeEventListener('abort', aborted);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export type LookupAll = (host: string) => Promise<LookupAddress[]>;
|
|
103
|
+
|
|
104
|
+
const lookupAll: LookupAll = (host) => {
|
|
105
|
+
return lookup(host, { all: true });
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* resolvePublicAddress returns the address a connection to the host is
|
|
110
|
+
* pinned to. Every DNS answer must be public, not only the first: a host
|
|
111
|
+
* that also answers with a private address could hand it to the next
|
|
112
|
+
* lookup, so the socket never looks the name up again.
|
|
113
|
+
*/
|
|
114
|
+
export const resolvePublicAddress = async (
|
|
115
|
+
hostname: string,
|
|
116
|
+
signal: AbortSignal,
|
|
117
|
+
lookupHost: LookupAll = lookupAll,
|
|
118
|
+
): Promise<LookupAddress> => {
|
|
119
|
+
const host = hostname.replace(/^\[|\]$/g, '');
|
|
120
|
+
const addresses = await withAbort(lookupHost(host), signal);
|
|
121
|
+
|
|
122
|
+
if (
|
|
123
|
+
addresses.length === 0 ||
|
|
124
|
+
addresses.some(({ address }) => !isPublicAddress(address))
|
|
125
|
+
) {
|
|
126
|
+
throw new SourceRetrievalError(
|
|
127
|
+
'unsafe_destination',
|
|
128
|
+
`Source DNS must resolve exclusively to public addresses: ${host}.`,
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const [firstAddress] = addresses;
|
|
133
|
+
|
|
134
|
+
if (!firstAddress) {
|
|
135
|
+
throw new SourceRetrievalError(
|
|
136
|
+
'unsafe_destination',
|
|
137
|
+
`Source DNS returned no address: ${host}.`,
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return firstAddress;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* HostPacer runs one request at a time per host, each starting a fixed
|
|
146
|
+
* interval after the previous one ended. One pacer serves every request of
|
|
147
|
+
* a phase, so checks that run side by side still reach a site one by one.
|
|
148
|
+
*/
|
|
149
|
+
export type HostPacer = <T>(url: URL, send: () => Promise<T>) => Promise<T>;
|
|
150
|
+
|
|
151
|
+
export const createHostPacer = (
|
|
152
|
+
intervalInMs: number,
|
|
153
|
+
wait: (ms: number) => Promise<unknown> = delay,
|
|
154
|
+
): HostPacer => {
|
|
155
|
+
const lastRequestByHost = new Map<string, Promise<unknown>>();
|
|
156
|
+
|
|
157
|
+
return (url, send) => {
|
|
158
|
+
const previous = lastRequestByHost.get(url.hostname);
|
|
159
|
+
const current = (async () => {
|
|
160
|
+
if (previous) {
|
|
161
|
+
await previous;
|
|
162
|
+
await wait(intervalInMs);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return send();
|
|
166
|
+
})();
|
|
167
|
+
|
|
168
|
+
lastRequestByHost.set(
|
|
169
|
+
url.hostname,
|
|
170
|
+
current.catch(() => undefined),
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
return current;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
/** How a successful response's body is read. */
|
|
178
|
+
export type BodyPolicy = {
|
|
179
|
+
/** Content types the body may have; any other is refused unread. */
|
|
180
|
+
contentTypes: RegExp | 'any';
|
|
181
|
+
maxBytes: number;
|
|
182
|
+
/** Past maxBytes: keep the prefix and say so, or refuse the response. */
|
|
183
|
+
oversize: 'truncate' | 'refuse';
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export type GuardedRequestOptions = {
|
|
187
|
+
url: string;
|
|
188
|
+
/** Bounds each hop from when it is sent; a wait for the host's turn in
|
|
189
|
+
* the pacer is not counted, or a request queued behind a slow render
|
|
190
|
+
* would time out without ever being sent. */
|
|
191
|
+
timeoutInMs: number;
|
|
192
|
+
signal?: AbortSignal;
|
|
193
|
+
userAgent: string;
|
|
194
|
+
accept: string;
|
|
195
|
+
/** Redirects followed before the request is refused. */
|
|
196
|
+
redirects: number;
|
|
197
|
+
/** Absent: only the status and headers are read, never the body. */
|
|
198
|
+
body?: BodyPolicy;
|
|
199
|
+
/** Wraps every hop's request: the caller's spacing per host. */
|
|
200
|
+
pace?: HostPacer;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export type GuardedHop = { url: string; status: number };
|
|
204
|
+
|
|
205
|
+
export type GuardedResponse = {
|
|
206
|
+
/** The URL of the final hop. */
|
|
207
|
+
url: string;
|
|
208
|
+
status: number;
|
|
209
|
+
contentType: string;
|
|
210
|
+
/** Read only for a 2xx under a body policy. */
|
|
211
|
+
body: Buffer | undefined;
|
|
212
|
+
isTruncated: boolean;
|
|
213
|
+
/** Every response received, the final one last. */
|
|
214
|
+
hops: GuardedHop[];
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/** A failure as a site check records it: a refused destination or redirect
|
|
218
|
+
* names its reason (`unsafe_destination: …`). */
|
|
219
|
+
export const describeSiteError = (error: unknown): string => {
|
|
220
|
+
if (error instanceof SourceRetrievalError) {
|
|
221
|
+
return `${error.reason}: ${error.message}`;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return error instanceof Error ? error.message : String(error);
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
/** A request bound to a phase's pacer: what the site checks receive. */
|
|
228
|
+
export type SiteRequest = (
|
|
229
|
+
options: Omit<GuardedRequestOptions, 'pace'>,
|
|
230
|
+
) => Promise<GuardedResponse>;
|
|
231
|
+
|
|
232
|
+
type HopResponse = Omit<GuardedResponse, 'url' | 'hops'> & {
|
|
233
|
+
location: string | undefined;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
const isRedirect = (status: number): boolean => {
|
|
237
|
+
return status >= 300 && status < 400;
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
const isSuccess = (status: number): boolean => {
|
|
241
|
+
return status >= 200 && status < 300;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const requestHop = async (
|
|
245
|
+
url: URL,
|
|
246
|
+
options: GuardedRequestOptions,
|
|
247
|
+
signal: AbortSignal,
|
|
248
|
+
): Promise<HopResponse> => {
|
|
249
|
+
const address = await resolvePublicAddress(url.hostname, signal);
|
|
250
|
+
|
|
251
|
+
signal.throwIfAborted();
|
|
252
|
+
|
|
253
|
+
return new Promise((resolve, reject) => {
|
|
254
|
+
const req = request(
|
|
255
|
+
url,
|
|
256
|
+
{
|
|
257
|
+
method: 'GET',
|
|
258
|
+
signal,
|
|
259
|
+
headers: {
|
|
260
|
+
'accept': options.accept,
|
|
261
|
+
// Never a compressed body: nothing to decompress, so no bomb to
|
|
262
|
+
// bound. An encoded body despite this is refused below.
|
|
263
|
+
'accept-encoding': 'identity',
|
|
264
|
+
'user-agent': options.userAgent,
|
|
265
|
+
},
|
|
266
|
+
lookup: (_host, lookupOptions, callback) => {
|
|
267
|
+
if (lookupOptions.all) {
|
|
268
|
+
callback(null, [address]);
|
|
269
|
+
} else {
|
|
270
|
+
callback(null, address.address, address.family);
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
(response) => {
|
|
275
|
+
const status = response.statusCode ?? 0;
|
|
276
|
+
const contentType = response.headers['content-type'] ?? '';
|
|
277
|
+
const encoding = response.headers['content-encoding'];
|
|
278
|
+
const policy = options.body;
|
|
279
|
+
const settle = (body: Buffer | undefined, isTruncated: boolean) => {
|
|
280
|
+
resolve({
|
|
281
|
+
status,
|
|
282
|
+
location: response.headers.location,
|
|
283
|
+
contentType,
|
|
284
|
+
body,
|
|
285
|
+
isTruncated,
|
|
286
|
+
});
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
if (!policy || !isSuccess(status)) {
|
|
290
|
+
response.destroy();
|
|
291
|
+
settle(undefined, false);
|
|
292
|
+
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (
|
|
297
|
+
(policy.contentTypes !== 'any' &&
|
|
298
|
+
!policy.contentTypes.test(contentType)) ||
|
|
299
|
+
(encoding && encoding !== 'identity')
|
|
300
|
+
) {
|
|
301
|
+
response.destroy();
|
|
302
|
+
reject(
|
|
303
|
+
new SourceRetrievalError(
|
|
304
|
+
'unsupported_content',
|
|
305
|
+
`Unsupported source content: ${contentType}.`,
|
|
306
|
+
),
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const chunks: Buffer[] = [];
|
|
313
|
+
let bytes = 0;
|
|
314
|
+
|
|
315
|
+
response.on('data', (chunk: Buffer) => {
|
|
316
|
+
bytes += chunk.length;
|
|
317
|
+
|
|
318
|
+
if (bytes <= policy.maxBytes) {
|
|
319
|
+
chunks.push(chunk);
|
|
320
|
+
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
response.destroy();
|
|
325
|
+
|
|
326
|
+
if (policy.oversize === 'refuse') {
|
|
327
|
+
reject(
|
|
328
|
+
new SourceRetrievalError(
|
|
329
|
+
'too_large',
|
|
330
|
+
`Source response exceeds byte limit: ${bytes} bytes.`,
|
|
331
|
+
),
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const kept = Buffer.concat(chunks);
|
|
338
|
+
|
|
339
|
+
settle(
|
|
340
|
+
Buffer.concat([
|
|
341
|
+
kept,
|
|
342
|
+
chunk.subarray(0, policy.maxBytes - kept.length),
|
|
343
|
+
]),
|
|
344
|
+
true,
|
|
345
|
+
);
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
response.once('error', reject);
|
|
349
|
+
response.once('end', () => {
|
|
350
|
+
settle(Buffer.concat(chunks), false);
|
|
351
|
+
});
|
|
352
|
+
},
|
|
353
|
+
);
|
|
354
|
+
|
|
355
|
+
req.once('error', reject);
|
|
356
|
+
req.end();
|
|
357
|
+
});
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* guardedRequest sends a GET under the guard and returns any status: the
|
|
362
|
+
* caller decides what a 403 or a 5xx means. A redirect it cannot follow
|
|
363
|
+
* (no Location, or past the limit) and an unsafe hop are refused.
|
|
364
|
+
*/
|
|
365
|
+
export const guardedRequest = async (
|
|
366
|
+
options: GuardedRequestOptions,
|
|
367
|
+
): Promise<GuardedResponse> => {
|
|
368
|
+
const pace: HostPacer = options.pace ?? ((_url, send) => send());
|
|
369
|
+
const hops: GuardedHop[] = [];
|
|
370
|
+
let url = validateResearchUrl(options.url);
|
|
371
|
+
let hopSignal: AbortSignal | undefined;
|
|
372
|
+
|
|
373
|
+
try {
|
|
374
|
+
for (let redirects = 0; ; redirects += 1) {
|
|
375
|
+
const target = url;
|
|
376
|
+
const response = await pace(target, () => {
|
|
377
|
+
options.signal?.throwIfAborted();
|
|
378
|
+
|
|
379
|
+
const signal = AbortSignal.any([
|
|
380
|
+
AbortSignal.timeout(options.timeoutInMs),
|
|
381
|
+
...(options.signal ? [options.signal] : []),
|
|
382
|
+
]);
|
|
383
|
+
|
|
384
|
+
hopSignal = signal;
|
|
385
|
+
|
|
386
|
+
return requestHop(target, options, signal);
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
hops.push({ url: target.href, status: response.status });
|
|
390
|
+
|
|
391
|
+
if (!isRedirect(response.status)) {
|
|
392
|
+
const { location: _location, ...final } = response;
|
|
393
|
+
|
|
394
|
+
return { ...final, url: target.href, hops };
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
if (!response.location) {
|
|
398
|
+
throw new SourceRetrievalError(
|
|
399
|
+
'http_error',
|
|
400
|
+
`Source redirect without a location: ${target.href}.`,
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
if (redirects === options.redirects) {
|
|
405
|
+
throw new SourceRetrievalError(
|
|
406
|
+
'http_error',
|
|
407
|
+
`Source redirect limit exceeded: ${target.href}.`,
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
url = validateResearchUrl(new URL(response.location, target).href);
|
|
412
|
+
}
|
|
413
|
+
} catch (error) {
|
|
414
|
+
if (options.signal?.aborted) {
|
|
415
|
+
throw options.signal.reason;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
if (error instanceof SourceRetrievalError) {
|
|
419
|
+
throw error;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
throw new SourceRetrievalError(
|
|
423
|
+
hopSignal?.aborted ? 'timeout' : 'network_error',
|
|
424
|
+
`Source retrieval failed: ${url.href}.`,
|
|
425
|
+
{ cause: error },
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
};
|
package/src/grounding/tools.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { contentHash } from '../stores/content-hash';
|
|
3
|
-
import { fetchGroundingSource
|
|
3
|
+
import { fetchGroundingSource } from './fetch';
|
|
4
|
+
import { validateResearchUrl } from './guarded-request';
|
|
4
5
|
import { GroundingIntegrityError } from './validation';
|
|
5
6
|
import {
|
|
6
7
|
groundingSourceSchema,
|
package/src/lib/checkpoint.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import type { AeoPrompt, AeoSurface,
|
|
3
|
-
import {
|
|
2
|
+
import type { AeoPrompt, AeoSurface, ProbeDepth } from '../schema';
|
|
3
|
+
import { agentProbedPrompts, isAgentSurface, runsPerPromptOn } from '../schema';
|
|
4
4
|
import type { CheckpointMatch, ProbeUnit } from '../stores/ports';
|
|
5
5
|
|
|
6
6
|
export type {
|
|
@@ -51,27 +51,26 @@ export const unitRecordKey = (unit: ProbeUnit): string => {
|
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* The probe units a run plans for one section: chat surfaces cover every
|
|
54
|
-
* prompt
|
|
55
|
-
*
|
|
56
|
-
* set is both the resume scope and the scoring denominator.
|
|
54
|
+
* prompt, agent surfaces the config's agentProbes subset, each at the depth
|
|
55
|
+
* runsPerPromptOn gives it. Mirrors the pipeline's fan-out exactly — the
|
|
56
|
+
* planned set is both the resume scope and the scoring denominator.
|
|
57
57
|
*/
|
|
58
|
-
export const plannedProbeUnitsForSection = (
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
58
|
+
export const plannedProbeUnitsForSection = (
|
|
59
|
+
args: ProbeDepth & {
|
|
60
|
+
sectionKey: string;
|
|
61
|
+
prompts: AeoPrompt[];
|
|
62
|
+
surfaces: readonly AeoSurface[];
|
|
63
|
+
},
|
|
64
|
+
): ProbeUnit[] => {
|
|
64
65
|
const chatSurfaces = args.surfaces.filter((s) => !isAgentSurface(s));
|
|
65
66
|
const agentSurfaces = args.surfaces.filter(isAgentSurface);
|
|
66
|
-
const agentPrompts = args.agentProbes
|
|
67
|
-
? args.prompts.slice(0, args.agentProbes.maxPromptsPerSection)
|
|
68
|
-
: args.prompts;
|
|
67
|
+
const agentPrompts = agentProbedPrompts(args.prompts, args.agentProbes);
|
|
69
68
|
|
|
70
69
|
const units: ProbeUnit[] = [];
|
|
71
70
|
|
|
72
71
|
for (const prompt of args.prompts) {
|
|
73
72
|
for (const surface of chatSurfaces) {
|
|
74
|
-
for (let run = 1; run <=
|
|
73
|
+
for (let run = 1; run <= runsPerPromptOn(surface, args); run += 1) {
|
|
75
74
|
units.push(
|
|
76
75
|
createUnit({
|
|
77
76
|
sectionKey: args.sectionKey,
|
|
@@ -86,7 +85,7 @@ export const plannedProbeUnitsForSection = (args: {
|
|
|
86
85
|
|
|
87
86
|
for (const prompt of agentPrompts) {
|
|
88
87
|
for (const surface of agentSurfaces) {
|
|
89
|
-
for (let run = 1; run <= args
|
|
88
|
+
for (let run = 1; run <= runsPerPromptOn(surface, args); run += 1) {
|
|
90
89
|
units.push(
|
|
91
90
|
createUnit({
|
|
92
91
|
sectionKey: args.sectionKey,
|
package/src/pipeline.ts
CHANGED
|
@@ -7,9 +7,10 @@ import type {
|
|
|
7
7
|
AeoSurface,
|
|
8
8
|
AeoVisibility,
|
|
9
9
|
AgentProbeConfig,
|
|
10
|
+
ChatProbeConfig,
|
|
10
11
|
RetrievalLog,
|
|
11
12
|
} from './schema';
|
|
12
|
-
import { isAgentSurface } from './schema';
|
|
13
|
+
import { agentProbedPrompts, isAgentSurface } from './schema';
|
|
13
14
|
import { createLog } from './lib/log';
|
|
14
15
|
import {
|
|
15
16
|
aiSearchProbeModels,
|
|
@@ -129,6 +130,8 @@ export type SectionRunArgs = {
|
|
|
129
130
|
// and how many of the section's prompts get agent probes. Always present —
|
|
130
131
|
// the config schema fills the canonical default.
|
|
131
132
|
agentProbes: AgentProbeConfig;
|
|
133
|
+
// Chat probe volume; undefined = the canonical surfaceRunCounts.
|
|
134
|
+
chatProbes: ChatProbeConfig | undefined;
|
|
132
135
|
agentCliVersions: AgentCliVersions;
|
|
133
136
|
// The run every fresh capture and analysis is stamped with (§4.2).
|
|
134
137
|
runId: string;
|
|
@@ -243,13 +246,9 @@ export const captureSectionProbes = async (
|
|
|
243
246
|
|
|
244
247
|
// Agent probes may cover a configured subset of prompts (the first N in
|
|
245
248
|
// config order) at a configured run count; the chat batch always covers
|
|
246
|
-
// every prompt at the
|
|
249
|
+
// every prompt, at the configured chat depth.
|
|
247
250
|
const agentRunsPerPrompt = args.agentProbes.runsPerPrompt;
|
|
248
|
-
const
|
|
249
|
-
? args.prompts.slice(0, args.agentProbes.maxPromptsPerSection)
|
|
250
|
-
: args.prompts;
|
|
251
|
-
|
|
252
|
-
const agentPromptInputs = promptInputs.slice(0, agentPrompts.length);
|
|
251
|
+
const agentPromptInputs = agentProbedPrompts(promptInputs, args.agentProbes);
|
|
253
252
|
|
|
254
253
|
// Store resume: split the section's planned units into cached hits
|
|
255
254
|
// (reused as-is) and missing keys (the only units the probe batches run).
|
|
@@ -258,6 +257,7 @@ export const captureSectionProbes = async (
|
|
|
258
257
|
prompts: args.prompts,
|
|
259
258
|
surfaces: args.surfaces,
|
|
260
259
|
agentProbes: args.agentProbes,
|
|
260
|
+
chatProbes: args.chatProbes,
|
|
261
261
|
});
|
|
262
262
|
|
|
263
263
|
const unitByKey = new Map<string, ProbeUnit>();
|
|
@@ -332,6 +332,11 @@ export const captureSectionProbes = async (
|
|
|
332
332
|
captureMetadata: {
|
|
333
333
|
requestedModel: requestedModelOf(probe),
|
|
334
334
|
reportedModel: probe.reportedModel ?? null,
|
|
335
|
+
// Progress comparisons hash these into each answer's collection
|
|
336
|
+
// method, so they stay as earlier releases recorded them. Chat
|
|
337
|
+
// depth is left out: it does not change how one answer is
|
|
338
|
+
// collected, and a depth difference already shows as a scope
|
|
339
|
+
// change.
|
|
335
340
|
parameters: {
|
|
336
341
|
geography: args.geography,
|
|
337
342
|
language: args.language,
|
|
@@ -367,6 +372,7 @@ export const captureSectionProbes = async (
|
|
|
367
372
|
language: args.language,
|
|
368
373
|
prompts: promptInputs,
|
|
369
374
|
surfaces: selectedChatSurfaces,
|
|
375
|
+
chatProbes: args.chatProbes,
|
|
370
376
|
filter: shouldRun,
|
|
371
377
|
onResult: bank,
|
|
372
378
|
trace,
|
package/src/probes/agent-clis.ts
CHANGED
|
@@ -523,9 +523,8 @@ export const runAgentProbesForPrompts = async (args: {
|
|
|
523
523
|
prompts: ProbePromptInput[];
|
|
524
524
|
surfaces?: readonly AeoAgentSurface[];
|
|
525
525
|
versions: AgentCliVersions;
|
|
526
|
-
// Runs per prompt per surface
|
|
527
|
-
//
|
|
528
|
-
// revised 2026-08-21).
|
|
526
|
+
// Runs per prompt per surface: the config's agentProbes depth (spec §5,
|
|
527
|
+
// revised 2026-08-21). Omitted = the canonical surfaceRunCounts value.
|
|
529
528
|
runsPerPrompt?: number;
|
|
530
529
|
// Unit-level gate for store resume: return false to skip a planned
|
|
531
530
|
// (prompt × surface × run) execution. Omitted = run everything.
|
package/src/probes/probes.ts
CHANGED
|
@@ -3,8 +3,13 @@ import { gateway } from '@ai-sdk/gateway';
|
|
|
3
3
|
import { openai } from '@ai-sdk/openai';
|
|
4
4
|
import { google } from '@ai-sdk/google';
|
|
5
5
|
import { anthropic } from '@ai-sdk/anthropic';
|
|
6
|
-
import type {
|
|
7
|
-
|
|
6
|
+
import type {
|
|
7
|
+
AeoChatSurface,
|
|
8
|
+
AeoSurface,
|
|
9
|
+
ChatProbeConfig,
|
|
10
|
+
RetrievalLog,
|
|
11
|
+
} from '../schema';
|
|
12
|
+
import { chatRunsPerPrompt, chatSurfaces } from '../schema';
|
|
8
13
|
import { surfaceRetrievalExposure } from '../retrieval';
|
|
9
14
|
import { createLog } from '../lib/log';
|
|
10
15
|
import { servedModelOf } from '../models/served-model';
|
|
@@ -115,6 +120,9 @@ export type ProbeJob = {
|
|
|
115
120
|
// Which chat surfaces to run — defaults to all five. Lets `--surfaces`
|
|
116
121
|
// iterate cheaply without touching the canonical run counts.
|
|
117
122
|
surfaces?: readonly AeoChatSurface[];
|
|
123
|
+
// Runs per prompt; undefined = the canonical surfaceRunCounts. Must be
|
|
124
|
+
// the depth the plan was built with, or resume and scoring disagree.
|
|
125
|
+
chatProbes: ChatProbeConfig | undefined;
|
|
118
126
|
// Unit-level gate for store resume: return false to skip a planned
|
|
119
127
|
// (prompt × surface × run) execution. Omitted = run everything.
|
|
120
128
|
filter?: (unit: {
|
|
@@ -401,18 +409,23 @@ const unexposedRetrieval = (surface: AeoChatSurface): RetrievalLog => {
|
|
|
401
409
|
return { exposure: surfaceRetrievalExposure[surface], calls: [] };
|
|
402
410
|
};
|
|
403
411
|
|
|
404
|
-
// Builds the 5-surface probe configuration.
|
|
405
|
-
//
|
|
406
|
-
//
|
|
412
|
+
// Builds the 5-surface probe configuration. Run counts come from
|
|
413
|
+
// chatRunsPerPrompt (schema.ts), the rule the plan and the scoring
|
|
414
|
+
// denominators read too.
|
|
407
415
|
const buildProbeModels = (args: {
|
|
408
416
|
geography: string;
|
|
409
417
|
language: string;
|
|
410
418
|
surfaces: readonly AeoChatSurface[];
|
|
419
|
+
chatProbes: ChatProbeConfig | undefined;
|
|
411
420
|
}): ProbeModelConfig[] => {
|
|
421
|
+
const runsOn = (surface: AeoChatSurface) => {
|
|
422
|
+
return chatRunsPerPrompt(surface, args.chatProbes);
|
|
423
|
+
};
|
|
424
|
+
|
|
412
425
|
const all: ProbeModelConfig[] = [
|
|
413
426
|
{
|
|
414
427
|
name: 'chatgpt',
|
|
415
|
-
runs:
|
|
428
|
+
runs: runsOn('chatgpt'),
|
|
416
429
|
provider: 'gateway',
|
|
417
430
|
probe: async (promptText) => {
|
|
418
431
|
return runSearchRequiredProbe({
|
|
@@ -426,7 +439,7 @@ const buildProbeModels = (args: {
|
|
|
426
439
|
},
|
|
427
440
|
{
|
|
428
441
|
name: 'gemini',
|
|
429
|
-
runs:
|
|
442
|
+
runs: runsOn('gemini'),
|
|
430
443
|
provider: 'gateway',
|
|
431
444
|
probe: async (promptText) => {
|
|
432
445
|
return runSearchRequiredProbe({
|
|
@@ -441,7 +454,7 @@ const buildProbeModels = (args: {
|
|
|
441
454
|
},
|
|
442
455
|
{
|
|
443
456
|
name: 'claude',
|
|
444
|
-
runs:
|
|
457
|
+
runs: runsOn('claude'),
|
|
445
458
|
provider: 'gateway',
|
|
446
459
|
probe: async (promptText) => {
|
|
447
460
|
return runSearchRequiredProbe({
|
|
@@ -457,7 +470,7 @@ const buildProbeModels = (args: {
|
|
|
457
470
|
},
|
|
458
471
|
{
|
|
459
472
|
name: 'perplexity',
|
|
460
|
-
runs:
|
|
473
|
+
runs: runsOn('perplexity'),
|
|
461
474
|
provider: 'gateway',
|
|
462
475
|
probe: async (promptText) => {
|
|
463
476
|
// Perplexity cites with bare numeric markers ([1], [2]) and returns
|
|
@@ -513,7 +526,7 @@ const buildProbeModels = (args: {
|
|
|
513
526
|
},
|
|
514
527
|
{
|
|
515
528
|
name: 'google_ai_overview',
|
|
516
|
-
runs:
|
|
529
|
+
runs: runsOn('google_ai_overview'),
|
|
517
530
|
provider: 'dataforseo',
|
|
518
531
|
probe: async (promptText) => {
|
|
519
532
|
const retrieval = unexposedRetrieval('google_ai_overview');
|
|
@@ -606,6 +619,7 @@ export const runProbesForPrompts = async (
|
|
|
606
619
|
geography: job.geography,
|
|
607
620
|
language: job.language,
|
|
608
621
|
surfaces: job.surfaces ?? chatSurfaces,
|
|
622
|
+
chatProbes: job.chatProbes,
|
|
609
623
|
});
|
|
610
624
|
|
|
611
625
|
const limiter = job.limiter ?? unlimited();
|
|
@@ -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(),
|