literally-aeo 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +6031 -5158
- package/dist/lib/agents/author-schema.js +5 -5
- package/dist/lib/agents/author-validation.js +7 -7
- package/dist/lib/agents/copy-validation.js +9 -9
- package/dist/lib/agents/copywriter-input.js +8 -8
- package/dist/lib/agents/facts.js +7 -7
- package/dist/lib/agents/narrative-facts.js +6 -6
- package/dist/lib/agents/verifier.js +13 -12
- package/dist/lib/analysis/domain-classifier.js +12 -10
- package/dist/lib/analysis/domain-labels.js +4 -4
- package/dist/lib/analysis/outreach.js +2 -2
- package/dist/lib/analysis/progress.js +8 -8
- package/dist/lib/analysis/retrieval.js +5 -5
- package/dist/lib/analysis/scoring.js +5 -5
- package/dist/lib/analysis/search-analyzer.js +6 -6
- package/dist/lib/analysis/sentiment.js +12 -10
- package/dist/lib/analysis/source-mix.js +2 -2
- package/dist/lib/author/examples.js +6 -6
- package/dist/lib/bundle/contracts.js +6 -6
- package/dist/lib/bundle/export.js +18 -18
- package/dist/lib/bundle/journal.js +7 -7
- package/dist/lib/bundle/project-journal.js +10 -10
- package/dist/lib/bundle/project.js +16 -16
- package/dist/lib/bundle/read.js +19 -19
- package/dist/lib/bundle/recorder.js +8 -8
- package/dist/lib/bundle/redact.js +7 -7
- package/dist/lib/bundle/trace-coverage.js +7 -7
- package/dist/lib/bundle/verify-integrity.js +9 -9
- package/dist/lib/bundle/verify-measurement.js +22 -13
- package/dist/lib/bundle/verify-report.js +23 -15
- package/dist/lib/bundle/verify.js +31 -23
- package/dist/lib/capture-manifest.js +6 -6
- package/dist/lib/checks/crawler-access.js +2 -2
- package/dist/lib/checks/renderability.js +2 -2
- package/dist/lib/checks/run-checks.js +12 -12
- package/dist/lib/chunks/{chunk-3CMPR6ZZ.js → chunk-2C723CW7.js} +1 -1
- package/dist/lib/chunks/chunk-2FDSOZ6Q.js +287 -0
- package/dist/lib/chunks/{chunk-PWOYEIPF.js → chunk-2U5QSA6Q.js} +7 -7
- package/dist/lib/chunks/{chunk-6EI4CVRW.js → chunk-3ESH5NDR.js} +5 -1
- package/dist/lib/chunks/{chunk-VHKHYAC5.js → chunk-3S2FAVRE.js} +2 -2
- package/dist/lib/chunks/{chunk-LR27H2HZ.js → chunk-44NSZBCP.js} +6 -6
- package/dist/lib/chunks/{chunk-JBOOD6MU.js → chunk-4AWFF53U.js} +12 -4
- package/dist/lib/chunks/{chunk-MENTBQGB.js → chunk-4HPMLJKC.js} +4 -4
- package/dist/lib/chunks/{chunk-S6QOXJAL.js → chunk-4Q2WFZ5J.js} +11 -4
- package/dist/lib/chunks/{chunk-7DNLRXEY.js → chunk-5JU2Y2I6.js} +2 -2
- package/dist/lib/chunks/{chunk-KFAT65P7.js → chunk-64JFN2Q5.js} +1 -1
- package/dist/lib/chunks/chunk-66UE4TT2.js +245 -0
- package/dist/lib/chunks/chunk-6N3C6E3D.js +105 -0
- package/dist/lib/chunks/{chunk-F2NSJ6PG.js → chunk-6RED3G6K.js} +7 -3
- package/dist/lib/chunks/{chunk-HCUJ2J7P.js → chunk-7KLTOVIY.js} +9 -9
- package/dist/lib/chunks/{chunk-EOO5RBUW.js → chunk-7ZR3WDF2.js} +38 -5
- package/dist/lib/chunks/chunk-A5PF7UE2.js +86 -0
- package/dist/lib/chunks/{chunk-PKNODC6Y.js → chunk-AB7DUTX5.js} +1 -1
- package/dist/lib/chunks/{chunk-WDT2Y7D7.js → chunk-AQCWKHTE.js} +11 -7
- package/dist/lib/chunks/{chunk-UNCUG2YS.js → chunk-ASHFEFCU.js} +3 -3
- package/dist/lib/chunks/{chunk-BYHXNFWN.js → chunk-ASIFUJG2.js} +1 -1
- package/dist/lib/chunks/{chunk-ZSEY7AHQ.js → chunk-BBK54RVK.js} +14 -11
- package/dist/lib/chunks/chunk-BQMUZLHO.js +17 -0
- package/dist/lib/chunks/{chunk-QD3JXA3Y.js → chunk-CQNIPZH3.js} +18 -18
- package/dist/lib/chunks/{chunk-7HM6IZ3L.js → chunk-CVEXMYPW.js} +2 -2
- package/dist/lib/chunks/chunk-CXZIHHLJ.js +95 -0
- package/dist/lib/chunks/{chunk-75DMLOQ7.js → chunk-CYJNBVQB.js} +1 -1
- package/dist/lib/chunks/{chunk-FAUFE7MI.js → chunk-D7N5OLYL.js} +1 -1
- package/dist/lib/chunks/{chunk-E2YTTB6Q.js → chunk-DSK3PM4Z.js} +1 -1
- package/dist/lib/chunks/{chunk-TNL2GWYR.js → chunk-EUXNCXCR.js} +22 -0
- package/dist/lib/chunks/{chunk-FJL2V6P5.js → chunk-F4EQULFR.js} +6 -6
- package/dist/lib/chunks/{chunk-QGZ4QSUE.js → chunk-FHV4PBYG.js} +1 -1
- package/dist/lib/chunks/{chunk-K2FZFESR.js → chunk-FONFW67K.js} +4 -4
- package/dist/lib/chunks/{chunk-PIFTG6YW.js → chunk-FPPHYGIO.js} +2 -2
- package/dist/lib/chunks/{chunk-VXYQWE45.js → chunk-FYE4R5TY.js} +2 -2
- package/dist/lib/chunks/{chunk-JYCVBFH5.js → chunk-H2DOBJZC.js} +2 -2
- package/dist/lib/chunks/{chunk-XA27KAUV.js → chunk-HEWHNSDP.js} +68 -36
- package/dist/lib/chunks/{chunk-RXSHKWZJ.js → chunk-HLC6OHGO.js} +2 -2
- package/dist/lib/chunks/{chunk-6HMHXSCS.js → chunk-HXXFRZTJ.js} +2 -2
- package/dist/lib/chunks/{chunk-R5UPOEWE.js → chunk-HYMWNGOK.js} +10 -3
- package/dist/lib/chunks/chunk-IH67TEGY.js +73 -0
- package/dist/lib/chunks/{chunk-JKPBXPCW.js → chunk-IMADI2YP.js} +1 -1
- package/dist/lib/chunks/{chunk-AT3XMGES.js → chunk-JBGQFPTY.js} +4 -4
- package/dist/lib/chunks/{chunk-JQDQVG3D.js → chunk-JDU3ZCKO.js} +1 -1
- package/dist/lib/chunks/{chunk-2KH7LNK7.js → chunk-JGIX427K.js} +7 -7
- package/dist/lib/chunks/{chunk-7CW6U5WJ.js → chunk-JIE2ANVD.js} +1 -1
- package/dist/lib/chunks/{chunk-YEUCAPKP.js → chunk-JJFOILZK.js} +2 -2
- package/dist/lib/chunks/{chunk-F7DBTXKG.js → chunk-JMIK2QN3.js} +4 -3
- package/dist/lib/chunks/chunk-JW7DTYSI.js +116 -0
- package/dist/lib/chunks/{chunk-BFWK3TBN.js → chunk-JXLCKACO.js} +2 -2
- package/dist/lib/chunks/{chunk-7WO3FFPS.js → chunk-K5NQDJLE.js} +1 -1
- package/dist/lib/chunks/{chunk-BXF4OC74.js → chunk-KI2FB4Y3.js} +30 -16
- package/dist/lib/chunks/{chunk-Y2CZ6FZY.js → chunk-KRWDELRS.js} +30 -7
- package/dist/lib/chunks/{chunk-SIJOQRRK.js → chunk-KRXOJJR7.js} +1 -1
- package/dist/lib/chunks/chunk-KSUI4DAY.js +15 -0
- package/dist/lib/chunks/chunk-KXFZ3CH3.js +98 -0
- package/dist/lib/chunks/{chunk-XSER7WEB.js → chunk-LJCWZ5SZ.js} +14 -14
- package/dist/lib/chunks/{chunk-HGGRPOSA.js → chunk-LNYQMWJO.js} +3 -3
- package/dist/lib/chunks/{chunk-DL6YQDTE.js → chunk-LOIAGEKN.js} +2 -2
- package/dist/lib/chunks/{chunk-I3UE52ZV.js → chunk-LPOIMPJK.js} +2 -2
- package/dist/lib/chunks/{chunk-66T7JC57.js → chunk-LUKP64NX.js} +2 -2
- package/dist/lib/chunks/chunk-MNG5TZRW.js +208 -0
- package/dist/lib/chunks/{chunk-HGGOGCPX.js → chunk-MPQXB7HN.js} +7 -7
- package/dist/lib/chunks/{chunk-YGLWQFKL.js → chunk-MZ2KN3IH.js} +3 -3
- package/dist/lib/chunks/chunk-N62G4EWT.js +91 -0
- package/dist/lib/chunks/{chunk-7YDXD4MD.js → chunk-ODIXZHHX.js} +1 -1
- package/dist/lib/chunks/{chunk-GLUGYZQO.js → chunk-OTVHGRCO.js} +8 -8
- package/dist/lib/chunks/{chunk-RIJERFGU.js → chunk-OVF27NAO.js} +69 -17
- package/dist/lib/chunks/chunk-P6LHGBYU.js +90 -0
- package/dist/lib/chunks/{chunk-U5USH2HB.js → chunk-PAL5SXIP.js} +1 -1
- package/dist/lib/chunks/{chunk-W5XYW6ZM.js → chunk-PT6PK2MJ.js} +26 -19
- package/dist/lib/chunks/{chunk-OD36HUXA.js → chunk-Q22FCF4A.js} +6 -7
- package/dist/lib/chunks/chunk-QKTKQSPS.js +292 -0
- package/dist/lib/chunks/{chunk-K4Y5NT4M.js → chunk-QO5TPMWS.js} +2 -2
- package/dist/lib/chunks/{chunk-4GLW3ZRO.js → chunk-QUZYFAGP.js} +4 -4
- package/dist/lib/chunks/{chunk-T6XZQOXS.js → chunk-QVMPTT7R.js} +5 -5
- package/dist/lib/chunks/{chunk-OOLWU667.js → chunk-RGZY6YUQ.js} +5 -5
- package/dist/lib/chunks/{chunk-U6BW6LGX.js → chunk-RM2VVR7Y.js} +1 -1
- package/dist/lib/chunks/{chunk-AJO7XVXK.js → chunk-RMSH7RUG.js} +6 -6
- package/dist/lib/chunks/{chunk-V5B6UZ3E.js → chunk-RQGEPR6V.js} +1 -0
- package/dist/lib/chunks/{chunk-V5JJEEBT.js → chunk-RYB77E7O.js} +6 -5
- package/dist/lib/chunks/chunk-S24JGY7B.js +97 -0
- package/dist/lib/chunks/{chunk-6GKKALCI.js → chunk-SF4UJ2AY.js} +1 -1
- package/dist/lib/chunks/chunk-SJCUR4QX.js +94 -0
- package/dist/lib/chunks/{chunk-XAN4CRFP.js → chunk-SQ55KGHO.js} +1 -1
- package/dist/lib/chunks/{chunk-ZOGIJGU3.js → chunk-TKOQMB6A.js} +7 -7
- package/dist/lib/chunks/{chunk-UYDQXXDQ.js → chunk-TWK6IA4P.js} +1 -1
- package/dist/lib/chunks/{chunk-DVFFYY5G.js → chunk-U42I3SBR.js} +13 -9
- package/dist/lib/chunks/{chunk-PIF3GL62.js → chunk-UECQONVZ.js} +5 -5
- package/dist/lib/chunks/{chunk-FDM2YNQL.js → chunk-VTY53IFN.js} +1 -1
- package/dist/lib/chunks/chunk-VYUC772A.js +338 -0
- package/dist/lib/chunks/{chunk-WCLKIPJV.js → chunk-WPCBE2NZ.js} +1 -1
- package/dist/lib/chunks/{chunk-3OE4UQIB.js → chunk-WRHGLRUK.js} +5 -5
- package/dist/lib/chunks/{chunk-J7QKT5E7.js → chunk-WUIY7BXR.js} +34 -17
- package/dist/lib/chunks/{chunk-7YYDUHJG.js → chunk-WZA4H4TG.js} +39 -13
- package/dist/lib/chunks/{chunk-NH4QGBJV.js → chunk-XBSA7MNJ.js} +7 -2
- package/dist/lib/chunks/chunk-XTBCXEH7.js +243 -0
- package/dist/lib/chunks/{chunk-ZQ3ER7JD.js → chunk-YPVJAXPP.js} +1 -1
- package/dist/lib/chunks/{chunk-SASE7U6E.js → chunk-YQD5ITKI.js} +1 -1
- package/dist/lib/chunks/{chunk-LTCDLURT.js → chunk-YY4BH5XM.js} +6 -6
- package/dist/lib/chunks/{chunk-J5NPHPXY.js → chunk-Z3BZRBQF.js} +36 -2
- package/dist/lib/chunks/{chunk-XFUYEFQP.js → chunk-ZBQU2VU3.js} +1 -1
- package/dist/lib/chunks/{chunk-7YZPEX3T.js → chunk-ZHGABG7L.js} +2 -2
- package/dist/lib/chunks/chunk-ZZCRYG36.js +31 -0
- package/dist/lib/cli/bundle-commands.js +89 -73
- package/dist/lib/cli/run-commands.js +136 -92
- package/dist/lib/cli/status-command.js +75 -59
- package/dist/lib/codex-workflow/aggregate.js +20 -12
- package/dist/lib/codex-workflow/author-tools.js +7 -7
- package/dist/lib/codex-workflow/author.js +23 -22
- package/dist/lib/codex-workflow/capture.js +38 -17
- package/dist/lib/codex-workflow/checkpoint.js +7 -7
- package/dist/lib/codex-workflow/checks.js +9 -9
- package/dist/lib/codex-workflow/copy-editor.js +19 -18
- package/dist/lib/codex-workflow/copy-recovery.js +4 -4
- package/dist/lib/codex-workflow/copy.js +16 -15
- package/dist/lib/codex-workflow/finish.js +28 -24
- package/dist/lib/codex-workflow/host-models.js +2 -2
- package/dist/lib/codex-workflow/loop.js +51 -46
- package/dist/lib/codex-workflow/quality.js +4 -4
- package/dist/lib/codex-workflow/run-inputs.js +6 -6
- package/dist/lib/codex-workflow/run-source.js +16 -16
- package/dist/lib/codex-workflow/schemas.js +6 -6
- package/dist/lib/codex-workflow/session.js +8 -8
- package/dist/lib/codex-workflow/stage.js +30 -28
- package/dist/lib/codex-workflow/workdir.js +18 -11
- package/dist/lib/engine/audit-file.js +7 -7
- package/dist/lib/engine/author.js +38 -36
- package/dist/lib/engine/cost-estimate.js +37 -9
- package/dist/lib/engine/local-run.js +74 -58
- package/dist/lib/engine/preflight.js +37 -9
- package/dist/lib/engine/rejudge.js +80 -64
- package/dist/lib/engine/run-bindings.js +62 -0
- package/dist/lib/engine/run-status.js +75 -59
- package/dist/lib/engine/templates.js +8 -8
- package/dist/lib/grounding/controller.js +8 -7
- package/dist/lib/grounding/extract.js +8 -6
- package/dist/lib/grounding/grounding-runtime.js +22 -21
- package/dist/lib/grounding/model-usage.js +2 -2
- package/dist/lib/grounding/model.js +7 -5
- package/dist/lib/grounding/recorded-tools.js +9 -9
- package/dist/lib/harness/report/artifacts.js +5 -5
- package/dist/lib/lib/checkpoint.js +5 -5
- package/dist/lib/lib/log.js +1 -1
- package/dist/lib/models/accounting.js +1 -1
- package/dist/lib/models/batching.js +6 -4
- package/dist/lib/models/budget-protection.js +1 -1
- package/dist/lib/models/cost-coefficients.js +2 -1
- package/dist/lib/models/gateway-cost.js +7 -0
- package/dist/lib/models/structured.js +5 -3
- package/dist/lib/models/supported-models.js +1 -1
- package/dist/lib/pipeline.js +36 -17
- package/dist/lib/probes/adapter.js +6 -0
- package/dist/lib/probes/adapters/cli-agents.js +44 -0
- package/dist/lib/probes/adapters/cli-claude-code.js +21 -0
- package/dist/lib/probes/adapters/cli-codex.js +23 -0
- package/dist/lib/probes/adapters/cli-cursor.js +21 -0
- package/dist/lib/probes/adapters/cli-process.js +34 -0
- package/dist/lib/probes/adapters/dataforseo-ai-overview.js +20 -0
- package/dist/lib/probes/adapters/gateway-chat.js +30 -0
- package/dist/lib/probes/adapters/gateway-perplexity.js +19 -0
- package/dist/lib/probes/agent-cli-parsers.js +2 -2
- package/dist/lib/probes/agent-clis.js +26 -11
- package/dist/lib/probes/answer-text.js +21 -0
- package/dist/lib/probes/attempt.js +28 -0
- package/dist/lib/probes/bindings.js +69 -0
- package/dist/lib/probes/charged-trace.js +47 -3
- package/dist/lib/probes/dataforseo-locale.js +1 -1
- package/dist/lib/probes/dataforseo.js +8 -5
- package/dist/lib/probes/grounding-urls.js +6 -4
- package/dist/lib/probes/legacy-bindings.js +7 -0
- package/dist/lib/probes/limits.js +1 -1
- package/dist/lib/probes/probes.js +33 -12
- package/dist/lib/runner.js +17 -14
- package/dist/lib/schema.js +4 -4
- package/dist/lib/section-result.js +6 -6
- package/dist/lib/stores/artifacts.js +7 -7
- package/dist/lib/stores/files.js +19 -17
- package/dist/lib/stores/local-versions.js +5 -5
- package/dist/lib/stores/memory.js +19 -14
- package/dist/lib/stores/publication.js +10 -10
- package/dist/lib/stores/unit-record.js +28 -0
- package/dist/lib/viewer/server.js +32 -24
- package/dist/lib/workflow/schema.js +3 -3
- package/dist/types/bundle/contracts.d.ts +1 -1
- package/dist/types/capture-manifest.d.ts +1 -0
- package/dist/types/codex-workflow/capture.d.ts +13 -0
- package/dist/types/codex-workflow/workdir.d.ts +0 -1
- package/dist/types/engine/cost-estimate.d.ts +5 -1
- package/dist/types/engine/preflight.d.ts +6 -1
- package/dist/types/engine/run-bindings.d.ts +25 -0
- package/dist/types/models/accounting.d.ts +7 -0
- package/dist/types/models/cost-coefficients.d.ts +5 -5
- package/dist/types/models/gateway-cost.d.ts +3 -0
- package/dist/types/pipeline.d.ts +2 -0
- package/dist/types/probes/adapter.d.ts +112 -0
- package/dist/types/probes/adapters/cli-agents.d.ts +19 -0
- package/dist/types/probes/adapters/cli-claude-code.d.ts +4 -0
- package/dist/types/probes/adapters/cli-codex.d.ts +10 -0
- package/dist/types/probes/adapters/cli-cursor.d.ts +4 -0
- package/dist/types/probes/adapters/cli-process.d.ts +86 -0
- package/dist/types/probes/adapters/dataforseo-ai-overview.d.ts +12 -0
- package/dist/types/probes/adapters/gateway-chat.d.ts +32 -0
- package/dist/types/probes/adapters/gateway-perplexity.d.ts +10 -0
- package/dist/types/probes/agent-clis.d.ts +7 -49
- package/dist/types/probes/answer-text.d.ts +20 -0
- package/dist/types/probes/attempt.d.ts +113 -0
- package/dist/types/probes/bindings.d.ts +79 -0
- package/dist/types/probes/charged-trace.d.ts +2 -1
- package/dist/types/probes/dataforseo.d.ts +24 -1
- package/dist/types/probes/grounding-urls.d.ts +18 -5
- package/dist/types/probes/legacy-bindings.d.ts +36 -0
- package/dist/types/probes/limits.d.ts +12 -6
- package/dist/types/probes/probe-trace.d.ts +10 -0
- package/dist/types/probes/probes.d.ts +5 -3
- package/dist/types/stores/ports.d.ts +1 -0
- package/dist/types/stores/unit-record.d.ts +11 -0
- package/package.json +6 -6
- package/src/analysis/progress.ts +10 -1
- package/src/bundle/contracts.ts +1 -1
- package/src/bundle/recorder.ts +47 -1
- package/src/capture-manifest.ts +6 -0
- package/src/cli/run-commands.ts +37 -1
- package/src/codex-workflow/capture.ts +60 -0
- package/src/codex-workflow/workdir.ts +3 -4
- package/src/engine/cost-estimate.ts +10 -4
- package/src/engine/local-run.ts +21 -2
- package/src/engine/preflight.ts +113 -17
- package/src/engine/rejudge.ts +5 -0
- package/src/engine/run-bindings.ts +142 -0
- package/src/grounding/extract.ts +1 -0
- package/src/grounding/model-usage.ts +4 -0
- package/src/lib/log.ts +17 -15
- package/src/models/accounting.ts +34 -0
- package/src/models/budget-protection.ts +1 -0
- package/src/models/cost-coefficients.ts +17 -13
- package/src/models/gateway-cost.ts +32 -0
- package/src/models/structured.ts +2 -10
- package/src/models/supported-models.ts +2 -2
- package/src/pipeline.ts +36 -17
- package/src/probes/adapter.ts +122 -0
- package/src/probes/adapters/cli-agents.ts +123 -0
- package/src/probes/adapters/cli-claude-code.ts +119 -0
- package/src/probes/adapters/cli-codex.ts +145 -0
- package/src/probes/adapters/cli-cursor.ts +95 -0
- package/src/probes/adapters/cli-process.ts +522 -0
- package/src/probes/adapters/dataforseo-ai-overview.ts +106 -0
- package/src/probes/adapters/gateway-chat.ts +339 -0
- package/src/probes/adapters/gateway-perplexity.ts +104 -0
- package/src/probes/agent-clis.ts +151 -1088
- package/src/probes/answer-text.ts +153 -0
- package/src/probes/attempt.ts +462 -0
- package/src/probes/bindings.ts +344 -0
- package/src/probes/charged-trace.ts +54 -13
- package/src/probes/dataforseo-locale.ts +13 -2
- package/src/probes/dataforseo.ts +265 -188
- package/src/probes/grounding-urls.ts +68 -19
- package/src/probes/legacy-bindings.ts +40 -0
- package/src/probes/limits.ts +31 -18
- package/src/probes/probe-trace.ts +10 -0
- package/src/probes/probes.ts +64 -736
- package/src/runner.ts +13 -0
- package/src/stores/files.ts +78 -54
- package/src/stores/memory.ts +4 -1
- package/src/stores/ports.ts +3 -0
- package/src/stores/unit-record.ts +151 -0
- package/dist/lib/chunks/chunk-BGAHZIL3.js +0 -563
- package/dist/lib/chunks/chunk-IB6RROHE.js +0 -204
- package/dist/lib/chunks/chunk-WZGI7UVM.js +0 -937
package/src/probes/dataforseo.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { createLog } from '../lib/log';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
dataForSeoLanguageCodes,
|
|
6
|
-
dataForSeoLocationCodes,
|
|
7
|
-
} from './dataforseo-locale';
|
|
3
|
+
import type { resolveDataForSeoLocale } from './dataforseo-locale';
|
|
8
4
|
import { ProbeFailure } from './failure';
|
|
9
5
|
|
|
10
6
|
const log = createLog('DataForSEO');
|
|
@@ -14,6 +10,12 @@ const log = createLog('DataForSEO');
|
|
|
14
10
|
// console's intelligence/clients/dataforseo.ts; the SERP/keyword endpoints
|
|
15
11
|
// this audit doesn't use were left behind).
|
|
16
12
|
//
|
|
13
|
+
// One client per run (probe adapters spec §7, phase 3 item 5): its
|
|
14
|
+
// credentials are passed in, its throttle is its own, its response body is
|
|
15
|
+
// bounded while it is read, and every field it reads is checked. The market
|
|
16
|
+
// is a resolved DataForSEO locale; a market the table cannot place is refused
|
|
17
|
+
// when the run is planned, never sent as the United States.
|
|
18
|
+
//
|
|
17
19
|
// Failure taxonomy (hardening spec §2.2, §3.6): a SERP that came back with
|
|
18
20
|
// no `ai_overview` item is an honest measurement (`no_overview`); a failed
|
|
19
21
|
// task, a bad location code, a 5xx or a timeout is a typed ProbeFailure
|
|
@@ -21,39 +23,44 @@ const log = createLog('DataForSEO');
|
|
|
21
23
|
// Retries belong to the caller: each attempt here is one paid SERP task.
|
|
22
24
|
// ============================================================================
|
|
23
25
|
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
+
// Provider fields the client does not read pass through unchecked, so a
|
|
27
|
+
// field DataForSEO adds never fails a probe; every field it reads is typed
|
|
28
|
+
// and bounded.
|
|
26
29
|
const dataForSeoResponseSchema = z.object({
|
|
27
30
|
status_code: z.number(),
|
|
28
|
-
status_message: z.string().optional(),
|
|
31
|
+
status_message: z.string().max(2_000).optional(),
|
|
29
32
|
tasks: z
|
|
30
33
|
.array(
|
|
31
34
|
z.object({
|
|
32
|
-
id: z.string().optional(),
|
|
35
|
+
id: z.string().max(200).optional(),
|
|
33
36
|
status_code: z.number(),
|
|
34
|
-
status_message: z.string().optional(),
|
|
35
|
-
result: z.array(z.unknown()).nullish(),
|
|
37
|
+
status_message: z.string().max(2_000).optional(),
|
|
38
|
+
result: z.array(z.unknown()).max(100).nullish(),
|
|
36
39
|
}),
|
|
37
40
|
)
|
|
41
|
+
.max(100)
|
|
38
42
|
.nullish(),
|
|
39
43
|
});
|
|
40
44
|
|
|
41
45
|
const serpResultSchema = z.object({
|
|
42
|
-
items: z.array(z.record(z.string(), z.unknown())).nullish(),
|
|
46
|
+
items: z.array(z.record(z.string(), z.unknown())).max(1_000).nullish(),
|
|
43
47
|
});
|
|
44
48
|
|
|
49
|
+
const referenceField = z.string().max(10_000).nullish();
|
|
50
|
+
|
|
45
51
|
const aiOverviewItemSchema = z.object({
|
|
46
|
-
markdown: z.string().nullish(),
|
|
52
|
+
markdown: z.string().max(200_000).nullish(),
|
|
47
53
|
references: z
|
|
48
54
|
.array(
|
|
49
55
|
z.object({
|
|
50
|
-
source:
|
|
51
|
-
domain:
|
|
52
|
-
url:
|
|
53
|
-
title:
|
|
54
|
-
text:
|
|
56
|
+
source: referenceField,
|
|
57
|
+
domain: referenceField,
|
|
58
|
+
url: referenceField,
|
|
59
|
+
title: referenceField,
|
|
60
|
+
text: referenceField,
|
|
55
61
|
}),
|
|
56
62
|
)
|
|
63
|
+
.max(500)
|
|
57
64
|
.nullish(),
|
|
58
65
|
});
|
|
59
66
|
|
|
@@ -69,218 +76,288 @@ export type AIOverviewOutcome =
|
|
|
69
76
|
| { status: 'overview'; markdown: string; references: AIOverviewReference[] }
|
|
70
77
|
| { status: 'no_overview' };
|
|
71
78
|
|
|
79
|
+
/** Where a SERP is placed: a market resolveDataForSeoLocale mapped. */
|
|
80
|
+
export type DataForSeoLocale = NonNullable<
|
|
81
|
+
ReturnType<typeof resolveDataForSeoLocale>
|
|
82
|
+
>;
|
|
83
|
+
|
|
84
|
+
export type DataForSeoProbeClient = {
|
|
85
|
+
getGoogleAIOverview: (
|
|
86
|
+
query: string,
|
|
87
|
+
locale: DataForSeoLocale,
|
|
88
|
+
) => Promise<AIOverviewOutcome>;
|
|
89
|
+
};
|
|
90
|
+
|
|
72
91
|
const baseUrl = 'https://api.dataforseo.com/v3';
|
|
92
|
+
export const aiOverviewEndpoint = '/serp/google/organic/live/advanced';
|
|
93
|
+
|
|
94
|
+
/** aiOverviewTask is the SERP task an AI Overview probe sends. */
|
|
95
|
+
export const aiOverviewTask = (query: string, locale: DataForSeoLocale) => {
|
|
96
|
+
return {
|
|
97
|
+
keyword: query,
|
|
98
|
+
language_code: locale.languageCode,
|
|
99
|
+
location_code: locale.locationCode,
|
|
100
|
+
load_async_ai_overview: true,
|
|
101
|
+
};
|
|
102
|
+
};
|
|
73
103
|
const requestDelayMs = 50;
|
|
74
104
|
const requestTimeoutMs = 30_000;
|
|
105
|
+
const maxResponseBytes = 8 * 1024 * 1024;
|
|
75
106
|
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
let throttleChain: Promise<void> = Promise.resolve();
|
|
107
|
+
// DataForSEO's own status codes: 40202 is "too many requests".
|
|
108
|
+
const capacityStatusCodes = new Set([40202]);
|
|
79
109
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
);
|
|
110
|
+
/** readBoundedBody reads a response body, refusing one larger than the
|
|
111
|
+
* limit as it arrives instead of after buffering it whole. */
|
|
112
|
+
const readBoundedBody = async (response: Response): Promise<string> => {
|
|
113
|
+
if (!response.body) {
|
|
114
|
+
return '';
|
|
115
|
+
}
|
|
87
116
|
|
|
88
|
-
|
|
117
|
+
const reader = response.body.getReader();
|
|
118
|
+
const chunks: Uint8Array[] = [];
|
|
119
|
+
let size = 0;
|
|
89
120
|
|
|
90
|
-
|
|
121
|
+
try {
|
|
122
|
+
for (
|
|
123
|
+
let chunk = await reader.read();
|
|
124
|
+
!chunk.done;
|
|
125
|
+
chunk = await reader.read()
|
|
126
|
+
) {
|
|
127
|
+
size += chunk.value.length;
|
|
128
|
+
|
|
129
|
+
if (size > maxResponseBytes) {
|
|
130
|
+
throw new ProbeFailure(
|
|
131
|
+
'cli_error',
|
|
132
|
+
`DataForSEO response exceeds ${maxResponseBytes} bytes`,
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
chunks.push(chunk.value);
|
|
137
|
+
}
|
|
138
|
+
} finally {
|
|
139
|
+
// Cancelling a finished or failed reader has nothing left to report.
|
|
140
|
+
await reader.cancel().catch(() => undefined);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return Buffer.concat(chunks).toString('utf8');
|
|
91
144
|
};
|
|
92
145
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
146
|
+
/** parseProviderJson checks a provider document against `schema`, and
|
|
147
|
+
* reports a document that is not the shape the client reads as a parser
|
|
148
|
+
* failure of the probe. */
|
|
149
|
+
const parseProviderJson = <T>(schema: z.ZodType<T>, value: unknown): T => {
|
|
150
|
+
const parsed = schema.safeParse(value);
|
|
96
151
|
|
|
97
|
-
if (!
|
|
98
|
-
|
|
152
|
+
if (!parsed.success) {
|
|
153
|
+
const issue = parsed.error.issues[0];
|
|
154
|
+
|
|
155
|
+
throw new ProbeFailure(
|
|
156
|
+
'parser',
|
|
157
|
+
`DataForSEO response does not match the expected shape (${issue?.path.join('.') ?? ''}: ${issue?.message ?? 'invalid'})`,
|
|
158
|
+
);
|
|
99
159
|
}
|
|
100
160
|
|
|
101
|
-
return
|
|
161
|
+
return parsed.data;
|
|
102
162
|
};
|
|
103
163
|
|
|
104
|
-
|
|
105
|
-
|
|
164
|
+
/**
|
|
165
|
+
* createDataForSeoProbeClient is one run's AI Overview client. Requests are
|
|
166
|
+
* spaced by the client's own throttle: callers queue behind one chain
|
|
167
|
+
* instead of all reading the last request time before any of them awaits
|
|
168
|
+
* (§3.5).
|
|
169
|
+
*/
|
|
170
|
+
export const createDataForSeoProbeClient = ({
|
|
171
|
+
login,
|
|
172
|
+
password,
|
|
173
|
+
}: {
|
|
174
|
+
login: string;
|
|
175
|
+
password: string;
|
|
176
|
+
}): DataForSeoProbeClient => {
|
|
177
|
+
if (!login || !password) {
|
|
178
|
+
throw new Error('Please provide both DataForSEO credentials.');
|
|
179
|
+
}
|
|
106
180
|
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
body: unknown[],
|
|
110
|
-
): Promise<unknown[]> => {
|
|
111
|
-
const authorization = getAuthHeader();
|
|
112
|
-
|
|
113
|
-
return throttled(async () => {
|
|
114
|
-
let response: Response;
|
|
115
|
-
|
|
116
|
-
try {
|
|
117
|
-
response = await fetch(`${baseUrl}${endpoint}`, {
|
|
118
|
-
method: 'POST',
|
|
119
|
-
headers: {
|
|
120
|
-
'Authorization': authorization,
|
|
121
|
-
'Content-Type': 'application/json',
|
|
122
|
-
},
|
|
123
|
-
body: JSON.stringify(body),
|
|
124
|
-
signal: AbortSignal.timeout(requestTimeoutMs),
|
|
125
|
-
});
|
|
126
|
-
} catch (error) {
|
|
127
|
-
const name = error instanceof Error ? error.name : '';
|
|
128
|
-
|
|
129
|
-
if (name === 'TimeoutError' || name === 'AbortError') {
|
|
130
|
-
throw new ProbeFailure(
|
|
131
|
-
'timeout',
|
|
132
|
-
`DataForSEO request exceeded ${requestTimeoutMs}ms`,
|
|
133
|
-
{ cause: error },
|
|
134
|
-
);
|
|
135
|
-
}
|
|
181
|
+
const authorization = `Basic ${Buffer.from(`${login}:${password}`).toString('base64')}`;
|
|
182
|
+
let throttleChain: Promise<void> = Promise.resolve();
|
|
136
183
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
184
|
+
const throttled = <T>(fn: () => Promise<T>): Promise<T> => {
|
|
185
|
+
const slot = throttleChain.then(
|
|
186
|
+
() =>
|
|
187
|
+
new Promise<void>((resolve) => {
|
|
188
|
+
setTimeout(resolve, requestDelayMs);
|
|
189
|
+
}),
|
|
190
|
+
);
|
|
143
191
|
|
|
144
|
-
|
|
145
|
-
|
|
192
|
+
throttleChain = slot.catch(() => undefined);
|
|
193
|
+
|
|
194
|
+
return slot.then(fn);
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const apiRequest = async (
|
|
198
|
+
endpoint: string,
|
|
199
|
+
body: unknown[],
|
|
200
|
+
): Promise<unknown[]> => {
|
|
201
|
+
return throttled(async () => {
|
|
202
|
+
let response: Response;
|
|
203
|
+
|
|
204
|
+
try {
|
|
205
|
+
response = await fetch(`${baseUrl}${endpoint}`, {
|
|
206
|
+
method: 'POST',
|
|
207
|
+
headers: {
|
|
208
|
+
'Authorization': authorization,
|
|
209
|
+
'Content-Type': 'application/json',
|
|
210
|
+
},
|
|
211
|
+
body: JSON.stringify(body),
|
|
212
|
+
signal: AbortSignal.timeout(requestTimeoutMs),
|
|
213
|
+
});
|
|
214
|
+
} catch (error) {
|
|
215
|
+
const name = error instanceof Error ? error.name : '';
|
|
216
|
+
|
|
217
|
+
if (name === 'TimeoutError' || name === 'AbortError') {
|
|
218
|
+
throw new ProbeFailure(
|
|
219
|
+
'timeout',
|
|
220
|
+
`DataForSEO request exceeded ${requestTimeoutMs}ms`,
|
|
221
|
+
{ cause: error },
|
|
222
|
+
);
|
|
223
|
+
}
|
|
146
224
|
|
|
147
|
-
if (response.status === 401 || response.status === 403) {
|
|
148
225
|
throw new ProbeFailure(
|
|
149
|
-
'
|
|
150
|
-
`DataForSEO
|
|
226
|
+
'cli_error',
|
|
227
|
+
`DataForSEO request failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
228
|
+
{ cause: error },
|
|
151
229
|
);
|
|
152
230
|
}
|
|
153
231
|
|
|
154
|
-
if (response.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
)
|
|
232
|
+
if (!response.ok) {
|
|
233
|
+
await response.body?.cancel().catch(() => undefined);
|
|
234
|
+
const detail = `${response.status}: ${response.statusText}`;
|
|
235
|
+
|
|
236
|
+
if (response.status === 401 || response.status === 403) {
|
|
237
|
+
throw new ProbeFailure(
|
|
238
|
+
'auth',
|
|
239
|
+
`DataForSEO rejected the credentials (${detail})`,
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (response.status === 429 || response.status === 503) {
|
|
244
|
+
throw new ProbeFailure(
|
|
245
|
+
'capacity',
|
|
246
|
+
`DataForSEO is throttling (${detail})`,
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
throw new ProbeFailure('cli_error', `DataForSEO HTTP error ${detail}`);
|
|
159
251
|
}
|
|
160
252
|
|
|
161
|
-
|
|
162
|
-
|
|
253
|
+
const text = await readBoundedBody(response);
|
|
254
|
+
let json: unknown;
|
|
163
255
|
|
|
164
|
-
|
|
256
|
+
try {
|
|
257
|
+
json = JSON.parse(text);
|
|
258
|
+
} catch (error) {
|
|
259
|
+
throw new ProbeFailure('parser', 'DataForSEO response is not JSON', {
|
|
260
|
+
cause: error,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const data = parseProviderJson(dataForSeoResponseSchema, json);
|
|
265
|
+
|
|
266
|
+
if (data.status_code !== 20000) {
|
|
267
|
+
if (capacityStatusCodes.has(data.status_code)) {
|
|
268
|
+
throw new ProbeFailure(
|
|
269
|
+
'capacity',
|
|
270
|
+
`DataForSEO API ${data.status_code}: ${data.status_message}`,
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// 40101 is a search-engine server error, not rejected credentials.
|
|
275
|
+
// https://docs.dataforseo.com/v3/appendix/errors/
|
|
276
|
+
if (data.status_code === 40100) {
|
|
277
|
+
throw new ProbeFailure(
|
|
278
|
+
'auth',
|
|
279
|
+
`DataForSEO API ${data.status_code}: ${data.status_message}`,
|
|
280
|
+
);
|
|
281
|
+
}
|
|
165
282
|
|
|
166
|
-
if (data.status_code !== 20000) {
|
|
167
|
-
if (capacityStatusCodes.has(data.status_code)) {
|
|
168
283
|
throw new ProbeFailure(
|
|
169
|
-
'
|
|
284
|
+
'cli_error',
|
|
170
285
|
`DataForSEO API ${data.status_code}: ${data.status_message}`,
|
|
171
286
|
);
|
|
172
287
|
}
|
|
173
288
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
289
|
+
const results: unknown[] = [];
|
|
290
|
+
|
|
291
|
+
for (const task of data.tasks ?? []) {
|
|
292
|
+
if (task.status_code === 20000 && task.result) {
|
|
293
|
+
results.push(...task.result);
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// A task that did not complete is a failed probe, not an absent
|
|
298
|
+
// AI Overview (§2.2).
|
|
299
|
+
log.warn('DataForSEO task failed', {
|
|
300
|
+
endpoint,
|
|
301
|
+
taskId: task.id,
|
|
302
|
+
taskStatusCode: task.status_code,
|
|
303
|
+
taskStatusMessage: task.status_message,
|
|
304
|
+
});
|
|
305
|
+
|
|
177
306
|
throw new ProbeFailure(
|
|
178
|
-
'
|
|
179
|
-
`DataForSEO
|
|
307
|
+
capacityStatusCodes.has(task.status_code) ? 'capacity' : 'cli_error',
|
|
308
|
+
`DataForSEO task ${task.status_code}: ${task.status_message}`,
|
|
180
309
|
);
|
|
181
310
|
}
|
|
182
311
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
);
|
|
187
|
-
}
|
|
312
|
+
return results;
|
|
313
|
+
});
|
|
314
|
+
};
|
|
188
315
|
|
|
189
|
-
|
|
316
|
+
const getGoogleAIOverview: DataForSeoProbeClient['getGoogleAIOverview'] =
|
|
317
|
+
async (query, locale) => {
|
|
318
|
+
const results = await apiRequest(aiOverviewEndpoint, [
|
|
319
|
+
aiOverviewTask(query, locale),
|
|
320
|
+
]);
|
|
190
321
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
322
|
+
if (results.length === 0) {
|
|
323
|
+
throw new ProbeFailure(
|
|
324
|
+
'cli_error',
|
|
325
|
+
'DataForSEO returned a completed task with no SERP result.',
|
|
326
|
+
);
|
|
195
327
|
}
|
|
196
328
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
taskStatusCode: task.status_code,
|
|
203
|
-
taskStatusMessage: task.status_message,
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
throw new ProbeFailure(
|
|
207
|
-
capacityStatusCodes.has(task.status_code) ? 'capacity' : 'cli_error',
|
|
208
|
-
`DataForSEO task ${task.status_code}: ${task.status_message}`,
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return results;
|
|
213
|
-
});
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
export const getGoogleAIOverview = async (
|
|
217
|
-
query: string,
|
|
218
|
-
geography: string,
|
|
219
|
-
language: string,
|
|
220
|
-
): Promise<AIOverviewOutcome> => {
|
|
221
|
-
const tasks = [
|
|
222
|
-
{
|
|
223
|
-
keyword: query,
|
|
224
|
-
...getGeoParams(geography, language),
|
|
225
|
-
load_async_ai_overview: true,
|
|
226
|
-
},
|
|
227
|
-
];
|
|
228
|
-
|
|
229
|
-
const results = await apiRequest('/serp/google/organic/live/advanced', tasks);
|
|
230
|
-
|
|
231
|
-
if (results.length === 0) {
|
|
232
|
-
throw new ProbeFailure(
|
|
233
|
-
'cli_error',
|
|
234
|
-
'DataForSEO returned a completed task with no SERP result.',
|
|
235
|
-
);
|
|
236
|
-
}
|
|
329
|
+
for (const result of results) {
|
|
330
|
+
const items = parseProviderJson(serpResultSchema, result).items ?? [];
|
|
331
|
+
const aiOverviewItem = items.find(
|
|
332
|
+
(item) => item.type === 'ai_overview',
|
|
333
|
+
);
|
|
237
334
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
335
|
+
if (!aiOverviewItem) {
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
241
338
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
339
|
+
const aiOverview = parseProviderJson(
|
|
340
|
+
aiOverviewItemSchema,
|
|
341
|
+
aiOverviewItem,
|
|
342
|
+
);
|
|
343
|
+
const markdown = aiOverview.markdown ?? '';
|
|
344
|
+
const rawRefs = aiOverview.references ?? [];
|
|
345
|
+
|
|
346
|
+
return {
|
|
347
|
+
status: 'overview',
|
|
348
|
+
markdown,
|
|
349
|
+
references: rawRefs.map((ref) => ({
|
|
350
|
+
source: ref.source ?? '',
|
|
351
|
+
domain: ref.domain ?? '',
|
|
352
|
+
url: ref.url ?? '',
|
|
353
|
+
title: ref.title ?? '',
|
|
354
|
+
text: ref.text ?? '',
|
|
355
|
+
})),
|
|
356
|
+
};
|
|
357
|
+
}
|
|
245
358
|
|
|
246
|
-
|
|
247
|
-
const markdown = aiOverview.markdown ?? '';
|
|
248
|
-
const rawRefs = aiOverview.references ?? [];
|
|
249
|
-
|
|
250
|
-
return {
|
|
251
|
-
status: 'overview',
|
|
252
|
-
markdown,
|
|
253
|
-
references: rawRefs.map((ref) => ({
|
|
254
|
-
source: ref.source ?? '',
|
|
255
|
-
domain: ref.domain ?? '',
|
|
256
|
-
url: ref.url ?? '',
|
|
257
|
-
title: ref.title ?? '',
|
|
258
|
-
text: ref.text ?? '',
|
|
259
|
-
})),
|
|
359
|
+
return { status: 'no_overview' };
|
|
260
360
|
};
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
return { status: 'no_overview' };
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
// ---------------------------------------------------------------------------
|
|
267
|
-
// Geo helpers (ported subset — SERP live endpoints require a location code)
|
|
268
|
-
// ---------------------------------------------------------------------------
|
|
269
|
-
|
|
270
|
-
const getLocationCode = (geography: string): number => {
|
|
271
|
-
return dataForSeoLocationCodes[geography.toLowerCase()] ?? 2840;
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
const getGeoParams = (
|
|
275
|
-
geography: string,
|
|
276
|
-
language: string,
|
|
277
|
-
): Record<string, number | string> => {
|
|
278
|
-
return {
|
|
279
|
-
language_code: getLanguageCode(language),
|
|
280
|
-
location_code: getLocationCode(geography),
|
|
281
|
-
};
|
|
282
|
-
};
|
|
283
361
|
|
|
284
|
-
|
|
285
|
-
return dataForSeoLanguageCodes[language.toLowerCase()] ?? 'en';
|
|
362
|
+
return { getGoogleAIOverview };
|
|
286
363
|
};
|