2sagaco48 1.0.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/diagnostics.mjs +141 -0
- package/dist/compute.worker-j5ahIpF-.js +1 -0
- package/dist/graph.worker-DG6iGCB9.js +1 -0
- package/dist/index.html +2314 -0
- package/flatten-guide.md +248 -0
- package/index.html +12 -0
- package/package.json +38 -0
- package/src/App.orig.tsx +204 -0
- package/src/App.orig1.tsx +27 -0
- package/src/App.orig2.tsx +25 -0
- package/src/App.tsx +3 -0
- package/src/BaseApp.tsx +18 -0
- package/src/INTEGRATION_LEDGER.md +22 -0
- package/src/PERSIST_CANARY.orig.txt +1 -0
- package/src/PERSIST_CANARY.txt +1 -0
- package/src/REGRESSION_LEDGER.md +651 -0
- package/src/TEMPLATE_PIPELINE_AUDIT.md +208 -0
- package/src/WILLIAMS_PERSONA_GUIDE.md +62 -0
- package/src/chat/VeritasChat.tsx +69 -0
- package/src/chat/synthesis.ts +31 -0
- package/src/chat/tier.ts +45 -0
- package/src/components/AdaptersPage.orig.tsx +99 -0
- package/src/components/AdaptersPage.tsx +3 -0
- package/src/components/AdversarialPanel.tsx +136 -0
- package/src/components/AnchorBaselinePanel.tsx +75 -0
- package/src/components/AnswerPanel.tsx +60 -0
- package/src/components/ArtifactPanel.tsx +43 -0
- package/src/components/ChatApp.orig.tsx +1582 -0
- package/src/components/ChatApp.orig1.tsx +722 -0
- package/src/components/ChatApp.tsx +95 -0
- package/src/components/ChatAugmentPanels.tsx +73 -0
- package/src/components/CitationLedgerPanel.tsx +313 -0
- package/src/components/ComputeSandboxPanel.tsx +130 -0
- package/src/components/ConfigPanel.tsx +110 -0
- package/src/components/ControlPlanePage.tsx +195 -0
- package/src/components/CreativeTreeLifePage.tsx +234 -0
- package/src/components/CreativeTreeOfLifePanel.tsx +149 -0
- package/src/components/DebugTracePanel.tsx +137 -0
- package/src/components/DeepReasoningTrace.tsx +48 -0
- package/src/components/EntitySheetPanel.tsx +51 -0
- package/src/components/FailureModesPanel.tsx +104 -0
- package/src/components/GBSDashboard.tsx +239 -0
- package/src/components/GraphView.tsx +116 -0
- package/src/components/HUD.tsx +125 -0
- package/src/components/HypothesisPanel.tsx +67 -0
- package/src/components/InnovationGenomeEngine.tsx +792 -0
- package/src/components/InnovationPersonaGuide.tsx +348 -0
- package/src/components/InnovationPersonaPanel.tsx +289 -0
- package/src/components/LiveResourceHUD.tsx +109 -0
- package/src/components/LongWriterPanel.tsx +112 -0
- package/src/components/MainPipelineV10Bridge.tsx +72 -0
- package/src/components/MarkdownLite.tsx +63 -0
- package/src/components/MemoryInspector.tsx +38 -0
- package/src/components/MemoryMonitor.tsx +52 -0
- package/src/components/MemoryStressPanel.tsx +176 -0
- package/src/components/ModulesPage.tsx +171 -0
- package/src/components/PipelineDebugConsole.orig.tsx +1856 -0
- package/src/components/PipelineDebugConsole.tsx +3 -0
- package/src/components/PreFlightHUD.tsx +67 -0
- package/src/components/PrismaFetchTracePanel.tsx +87 -0
- package/src/components/ReportOSPanel.tsx +165 -0
- package/src/components/ResourceEstimatorPage.tsx +327 -0
- package/src/components/RichText.tsx +181 -0
- package/src/components/SagaOsPanel.tsx +605 -0
- package/src/components/SagaOsReference.tsx +421 -0
- package/src/components/SagaOsV2Panel.tsx +594 -0
- package/src/components/SagaStyleTab.tsx +382 -0
- package/src/components/SageBlueprintPanel.tsx +416 -0
- package/src/components/SharedChatInput.tsx +77 -0
- package/src/components/StatFinancePanel.tsx +190 -0
- package/src/components/StylePersonaPanel.tsx +128 -0
- package/src/components/TemplatesPage.tsx +300 -0
- package/src/components/TestPanel.tsx +63 -0
- package/src/components/TraceLog.tsx +89 -0
- package/src/components/V15CalibrationAugment.tsx +1134 -0
- package/src/components/V15CalibrationDialog.tsx +1871 -0
- package/src/components/V15Overlay.orig.tsx +120 -0
- package/src/components/V15Overlay.tsx +4 -0
- package/src/components/V15OverlayWrapper.tsx +362 -0
- package/src/components/V15Toggle.tsx +34 -0
- package/src/console/DiagnosticRecoveryPanel.tsx +358 -0
- package/src/console/EngineeringConsole.tsx +103 -0
- package/src/console/FictionSystemPanels.tsx +882 -0
- package/src/console/InspectorPanels.tsx +254 -0
- package/src/console/ManuscriptGraderPanel.tsx +182 -0
- package/src/console/RecursiveReviserPanel.tsx +245 -0
- package/src/console/SeedControlPanel.tsx +135 -0
- package/src/console/StoryControllerPanel.tsx +443 -0
- package/src/console/engineBridge.ts +258 -0
- package/src/console/gemini.ts +106 -0
- package/src/console/grading.ts +250 -0
- package/src/console/util.ts +45 -0
- package/src/fiction/continuity.ts +372 -0
- package/src/fiction/crash-protection.ts +111 -0
- package/src/fiction/diagnostics.ts +208 -0
- package/src/fiction/diff.ts +74 -0
- package/src/fiction/entity-state-machine.ts +214 -0
- package/src/fiction/nive-engine.ts +404 -0
- package/src/fiction/pipeline-selftest.ts +132 -0
- package/src/fiction/seed-control.ts +193 -0
- package/src/fiction/story-engine.ts +326 -0
- package/src/fiction/types.ts +68 -0
- package/src/flatten-guide.md +379 -0
- package/src/index.css +14 -0
- package/src/index.orig.css +13 -0
- package/src/lib/academic-sources.base.ts +188 -0
- package/src/lib/academic-sources.orig.ts +28 -0
- package/src/lib/academic-sources.ts +10 -0
- package/src/lib/advanced-math.ts +119 -0
- package/src/lib/adversarial-engine.base.ts +409 -0
- package/src/lib/adversarial-engine.ts +82 -0
- package/src/lib/ai-revision.ts +623 -0
- package/src/lib/app-state.tsx +426 -0
- package/src/lib/artifact-registry.ts +97 -0
- package/src/lib/artifacts.ts +180 -0
- package/src/lib/atlas-dr.ts +167 -0
- package/src/lib/browser-mtls.ts +127 -0
- package/src/lib/browser-queue.ts +221 -0
- package/src/lib/browser-search-scraper.base.ts +382 -0
- package/src/lib/browser-search-scraper.orig.ts +90 -0
- package/src/lib/browser-search-scraper.ts +10 -0
- package/src/lib/calc-interceptor.ts +82 -0
- package/src/lib/citation-lane-tap.ts +78 -0
- package/src/lib/citation-ledger-store.ts +369 -0
- package/src/lib/citation-ledger.ts +203 -0
- package/src/lib/compute-sandbox.ts +215 -0
- package/src/lib/compute.worker.ts +153 -0
- package/src/lib/connectors/gemini.ts +120 -0
- package/src/lib/connectors/jina.ts +233 -0
- package/src/lib/connectors/marketdata.ts +51 -0
- package/src/lib/connectors/prismafetch.base.ts +175 -0
- package/src/lib/connectors/prismafetch.ts +1 -0
- package/src/lib/connectors/serpapi.ts +65 -0
- package/src/lib/connectors/wikidata.ts +44 -0
- package/src/lib/constraints.ts +331 -0
- package/src/lib/continuation-detector.base.ts +153 -0
- package/src/lib/continuation-detector.ts +48 -0
- package/src/lib/contradraft.ts +168 -0
- package/src/lib/cors-proxy.ts +120 -0
- package/src/lib/coverage.ts +81 -0
- package/src/lib/debug/architecture-prescription.ts +556 -0
- package/src/lib/debug/covea-repair.ts +543 -0
- package/src/lib/debug/helios-ground.ts +319 -0
- package/src/lib/debug/intent-decomposer.ts +281 -0
- package/src/lib/debug/intent-lattice.ts +349 -0
- package/src/lib/debug/pipeline-diagnosis.ts +1149 -0
- package/src/lib/debug/pipeline-trace-bus.ts +424 -0
- package/src/lib/debug/prompt-forge.ts +678 -0
- package/src/lib/debug/repair-sites.ts +513 -0
- package/src/lib/debug/research-phase.ts +266 -0
- package/src/lib/debug/retrieval-context.ts +76 -0
- package/src/lib/debug/retrieval-hardener.ts +142 -0
- package/src/lib/debug/scraper-debug-runner.ts +576 -0
- package/src/lib/debug/scraper-forensics.ts +418 -0
- package/src/lib/debug/scraper-lane-roadmap.ts +136 -0
- package/src/lib/debug/self-test.ts +415 -0
- package/src/lib/debug/step-attribution.ts +211 -0
- package/src/lib/debug/template-rubric.ts +301 -0
- package/src/lib/debug/unified-innovation.ts +126 -0
- package/src/lib/debug/veritas-hybrid-scraper.ts +335 -0
- package/src/lib/defense-registry.ts +104 -0
- package/src/lib/defenses.ts +162 -0
- package/src/lib/deterministic-citation-ledger.ts +174 -0
- package/src/lib/elo-registry.base.ts +117 -0
- package/src/lib/elo-registry.ts +1 -0
- package/src/lib/entity-resolver.ts +291 -0
- package/src/lib/failure-modes.ts +267 -0
- package/src/lib/feature-registry.ts +69 -0
- package/src/lib/flaw-registry.ts +143 -0
- package/src/lib/flaws/_template.ts +52 -0
- package/src/lib/flaws/builtins.ts +63 -0
- package/src/lib/flaws/finance.ts +169 -0
- package/src/lib/flaws/fixers.ts +10 -0
- package/src/lib/flaws/index.ts +32 -0
- package/src/lib/flaws/legal.ts +157 -0
- package/src/lib/flaws/medical.ts +188 -0
- package/src/lib/flaws/original-defenses-pack.ts +81 -0
- package/src/lib/flaws/sample-declarative-pack.json +38 -0
- package/src/lib/flaws/selftest.ts +201 -0
- package/src/lib/flaws/software-extended.ts +125 -0
- package/src/lib/flaws/software-rn-webgl.ts +182 -0
- package/src/lib/flaws/statistics-advanced.ts +46 -0
- package/src/lib/flaws/statistics.ts +61 -0
- package/src/lib/gbse/config.ts +20 -0
- package/src/lib/gbse/engine.ts +226 -0
- package/src/lib/gbse/graph.ts +118 -0
- package/src/lib/gbse/graph.worker.ts +21 -0
- package/src/lib/gbse/tests.ts +117 -0
- package/src/lib/gbse/tiers.ts +65 -0
- package/src/lib/gbse/types.ts +94 -0
- package/src/lib/innovation-genome-engine-v2.orig.ts +1001 -0
- package/src/lib/innovation-genome-engine-v2.ts +3 -0
- package/src/lib/innovation-genome-engine.orig.ts +330 -0
- package/src/lib/innovation-genome-engine.ts +3 -0
- package/src/lib/innovation-genome-v10.orig.ts +314 -0
- package/src/lib/innovation-genome-v10.ts +2 -0
- package/src/lib/innovation-genome-v3.orig.ts +2015 -0
- package/src/lib/innovation-genome-v3.ts +2 -0
- package/src/lib/innovation-genome-v4.orig.ts +1959 -0
- package/src/lib/innovation-genome-v4.ts +2 -0
- package/src/lib/innovation-genome-v5.orig.ts +1210 -0
- package/src/lib/innovation-genome-v5.ts +2 -0
- package/src/lib/innovation-genome-v7.orig.ts +2549 -0
- package/src/lib/innovation-genome-v7.ts +2 -0
- package/src/lib/innovation-genome-v8.orig.ts +1485 -0
- package/src/lib/innovation-genome-v8.ts +2 -0
- package/src/lib/innovation-genome-v9.orig.ts +643 -0
- package/src/lib/innovation-genome-v9.ts +2 -0
- package/src/lib/jina.base.ts +293 -0
- package/src/lib/jina.ts +1 -0
- package/src/lib/live-telemetry.ts +61 -0
- package/src/lib/longwriter.ts +84 -0
- package/src/lib/manuscript-grade-v2.ts +298 -0
- package/src/lib/memory-governor.ts +173 -0
- package/src/lib/memory-stress-tests.ts +248 -0
- package/src/lib/model-intelligence.ts +48 -0
- package/src/lib/model-rotator.ts +75 -0
- package/src/lib/models.orig.ts +513 -0
- package/src/lib/models.ts +151 -0
- package/src/lib/n-deep.base.ts +592 -0
- package/src/lib/n-deep.ts +51 -0
- package/src/lib/nih-simulator.ts +56 -0
- package/src/lib/nih-vulnerability-fixes.ts +460 -0
- package/src/lib/omega-templates.base.ts +294 -0
- package/src/lib/omega-templates.ts +225 -0
- package/src/lib/omni-nexus.ts +64 -0
- package/src/lib/oracle-adapters.ts +67 -0
- package/src/lib/oracle-registry.ts +163 -0
- package/src/lib/orchestrator.ts +357 -0
- package/src/lib/output-boundary.ts +235 -0
- package/src/lib/overrides/vite-native-chaos-harness.ts +154 -0
- package/src/lib/overrides/vite-native-contract-plane.ts +245 -0
- package/src/lib/overrides/vite-native-doctor-plane.ts +208 -0
- package/src/lib/overrides/vite-native-knowledge-store.ts +267 -0
- package/src/lib/overrides/vite-native-policy-plane.ts +190 -0
- package/src/lib/overrides/vite-native-replay-plane.ts +197 -0
- package/src/lib/overrides/vite-native-runtime-plane.ts +106 -0
- package/src/lib/overrides/vite-native-scraper.ts +848 -0
- package/src/lib/overrides/vite-native-selftest-functional.ts +217 -0
- package/src/lib/overrides/vite-native-selftest.ts +183 -0
- package/src/lib/overrides/vite-native-snapshot-plane.ts +123 -0
- package/src/lib/philosophy-toolkit.ts +75 -0
- package/src/lib/pipeline.orig.ts +659 -0
- package/src/lib/pipeline.ts +42 -0
- package/src/lib/precache.ts +128 -0
- package/src/lib/py-sandbox.ts +205 -0
- package/src/lib/quality-score.ts +96 -0
- package/src/lib/quant-engine.ts +231 -0
- package/src/lib/quant-lib.ts +80 -0
- package/src/lib/reportos.ts +175 -0
- package/src/lib/research-os.ts +306 -0
- package/src/lib/resource-estimator.ts +114 -0
- package/src/lib/rpm-governor.ts +93 -0
- package/src/lib/runtime-estimator.ts +135 -0
- package/src/lib/sage/empty-space-v6.ts +560 -0
- package/src/lib/sage/empty-space-v7.ts +222 -0
- package/src/lib/sage/empty-space.ts +733 -0
- package/src/lib/sage/engine.ts +786 -0
- package/src/lib/sage/index.ts +17 -0
- package/src/lib/sage/judge.ts +246 -0
- package/src/lib/sage/prng.ts +53 -0
- package/src/lib/sage/reality-grounding.ts +380 -0
- package/src/lib/sage/repetition.ts +151 -0
- package/src/lib/sage/saga-os-v2-engines.ts +1870 -0
- package/src/lib/sage/saga-os-v2.ts +274 -0
- package/src/lib/sage/saga-os-v3-core.ts +1491 -0
- package/src/lib/sage/saga-os-v3-release.ts +739 -0
- package/src/lib/sage/saga-os-v4-aureate.ts +1161 -0
- package/src/lib/sage/saga-os-v4.ts +212 -0
- package/src/lib/sage/saga-os-v5.ts +205 -0
- package/src/lib/sage/saga-os-v6.ts +346 -0
- package/src/lib/sage/saga-os-v7.ts +314 -0
- package/src/lib/sage/saga-os-v8.ts +505 -0
- package/src/lib/sage/saga-os.ts +329 -0
- package/src/lib/sage/taxonomy.ts +403 -0
- package/src/lib/sage/unified-roll.ts +524 -0
- package/src/lib/sage/worked-sketches.ts +44 -0
- package/src/lib/sage.ts +166 -0
- package/src/lib/scraper-debug-bus.ts +53 -0
- package/src/lib/scraper-enhanced.orig.ts +153 -0
- package/src/lib/scraper-enhanced.ts +10 -0
- package/src/lib/scraper-hardener.base.orig.ts +155 -0
- package/src/lib/scraper-hardener.base.ts +317 -0
- package/src/lib/scraper-hardener.ts +1 -0
- package/src/lib/scraper-palisade/palisade-adjudicator.orig.ts +419 -0
- package/src/lib/scraper-palisade/palisade-adjudicator.ts +13 -0
- package/src/lib/scraper-vnext/arbiter-omega.orig.ts +688 -0
- package/src/lib/scraper-vnext/arbiter-omega.ts +13 -0
- package/src/lib/scraper-vnext/canonical-portfolio-augments.ts +479 -0
- package/src/lib/scraper-vnext/canonical-portfolio-orchestrator.orig.ts +1529 -0
- package/src/lib/scraper-vnext/canonical-portfolio-orchestrator.ts +13 -0
- package/src/lib/scraper-vnext/conclave-omega.ts +1830 -0
- package/src/lib/scraper-vnext/content-extractor-v2.ts +226 -0
- package/src/lib/scraper-vnext/diagnostics-suite.ts +36 -0
- package/src/lib/scraper-vnext/epistemic-packer.ts +97 -0
- package/src/lib/scraper-vnext/fusion-v2.ts +65 -0
- package/src/lib/scraper-vnext/hydra-reader.orig.ts +1216 -0
- package/src/lib/scraper-vnext/hydra-reader.ts +13 -0
- package/src/lib/scraper-vnext/native-scraper-browser-vnext.orig.ts +91 -0
- package/src/lib/scraper-vnext/native-scraper-browser-vnext.ts +13 -0
- package/src/lib/scraper-vnext/nexus-consensus.orig.ts +905 -0
- package/src/lib/scraper-vnext/nexus-consensus.ts +13 -0
- package/src/lib/scraper-vnext/portfolio-consensus-adjudicator.ts +804 -0
- package/src/lib/scraper-vnext/portfolio-consensus-memory.ts +377 -0
- package/src/lib/scraper-vnext/portfolio-terminal-governor.ts +548 -0
- package/src/lib/scraper-vnext/query-strategist.orig.ts +224 -0
- package/src/lib/scraper-vnext/query-strategist.ts +423 -0
- package/src/lib/scraper-vnext/retrieval-accelerator.ts +708 -0
- package/src/lib/scraper-vnext/retrieval-audit-augments.ts +477 -0
- package/src/lib/scraper-vnext/retrieval-control-plane.ts +904 -0
- package/src/lib/scraper-vnext/retrieval-policy-augments.ts +358 -0
- package/src/lib/scraper-vnext/safe-fetch-v2.ts +157 -0
- package/src/lib/scraper-vnext/sentinel-omega.ts +56 -0
- package/src/lib/scraper-vnext/sentinel-orchestrator.ts +69 -0
- package/src/lib/scraper-vnext/sibyl-oracle.orig.ts +413 -0
- package/src/lib/scraper-vnext/sibyl-oracle.ts +13 -0
- package/src/lib/scraper-vnext/smart-read-v2.ts +55 -0
- package/src/lib/scraper-vnext/spa-rescue-bridge.ts +608 -0
- package/src/lib/scraper-vnext/strata-engine.orig.ts +2666 -0
- package/src/lib/scraper-vnext/strata-engine.ts +13 -0
- package/src/lib/scraper-vnext/structured-source-adapter.orig.ts +369 -0
- package/src/lib/scraper-vnext/structured-source-adapter.ts +34 -0
- package/src/lib/scraper-vnext/terminal-complete.ts +224 -0
- package/src/lib/scraper-vnext/terminal-final.ts +277 -0
- package/src/lib/scraper-vnext/terminal-saturation.ts +345 -0
- package/src/lib/scraper-vnext/terminal-wire.ts +425 -0
- package/src/lib/scraper-vnext/vanguard-titanium.orig.ts +467 -0
- package/src/lib/scraper-vnext/vanguard-titanium.ts +17 -0
- package/src/lib/search-cache.ts +138 -0
- package/src/lib/sloop-runner.base.ts +223 -0
- package/src/lib/sloop-runner.ts +104 -0
- package/src/lib/sloop.ts +114 -0
- package/src/lib/small-model-adapters.ts +82 -0
- package/src/lib/sscp.ts +86 -0
- package/src/lib/system-map.ts +54 -0
- package/src/lib/uni-node.ts +86 -0
- package/src/lib/universal-rigor-guard.ts +433 -0
- package/src/lib/v15-gate-testbed.ts +274 -0
- package/src/lib/v15-gemini.base.ts +89 -0
- package/src/lib/v15-gemini.ts +1 -0
- package/src/lib/v15-grounding.orig.ts +241 -0
- package/src/lib/v15-grounding.ts +79 -0
- package/src/lib/v15-pipeline.base.ts +769 -0
- package/src/lib/v15-pipeline.orig.ts +1154 -0
- package/src/lib/v15-pipeline.ts +674 -0
- package/src/lib/v15-questions.ts +64 -0
- package/src/lib/v15-rate-limiter.orig.ts +91 -0
- package/src/lib/v15-rate-limiter.ts +48 -0
- package/src/lib/v15-state.base.ts +87 -0
- package/src/lib/v15-state.ts +28 -0
- package/src/lib/visual-table-generator.tsx +207 -0
- package/src/lib/wasm-runtime.ts +133 -0
- package/src/lib/williams-persona-guide.ts +265 -0
- package/src/lib/williams-style.base.ts +464 -0
- package/src/lib/williams-style.ts +59 -0
- package/src/lib/worker-pool.ts +96 -0
- package/src/lib/writing-tiers.ts +125 -0
- package/src/main.orig.tsx +10 -0
- package/src/main.tsx +10 -0
- package/src/utils/cn.orig.ts +6 -0
- package/src/utils/cn.ts +6 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +31 -0
- package/unify.mjs +537 -0
- package/vite.config.ts +18 -0
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* terminal-wire.ts
|
|
3
|
+
* ============================================================================
|
|
4
|
+
* ADDITIVE one-shot terminal entry + optional Titanium egress lanes.
|
|
5
|
+
* Base: Opus canonical structured-source-adapter.ts + epistemic-packer.ts.
|
|
6
|
+
* Does NOT reimplement knapsack, structured APIs, SPA JSON-LD, or AMP builders.
|
|
7
|
+
*
|
|
8
|
+
* CLOSES ONLY:
|
|
9
|
+
* 1. One call: structuredSearch → arbiter → adjudicate → packAdjudicationResult
|
|
10
|
+
* 2. Optional Titanium lanes (Google Translate / AMP via PROXY_FLEET)
|
|
11
|
+
* 3. Challenge-gate bridge that sets Error.cause = rawHtml for SPA rescue
|
|
12
|
+
*
|
|
13
|
+
* HONEST LIMITS:
|
|
14
|
+
* - Pyodide/WASM cannot bypass CORS or spoof TLS (inherits host fetch).
|
|
15
|
+
* - Titanium lanes borrow Google's fetch path; ToS/availability are residual.
|
|
16
|
+
* - OpenAlex remains optional-key (canonical adapter already correct).
|
|
17
|
+
*
|
|
18
|
+
* NOT EXECUTED in this environment.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { PROXY_FLEET, type ProxyDef } from "@/lib/scraper-hardener";
|
|
22
|
+
|
|
23
|
+
import type {
|
|
24
|
+
ScheduleContext,
|
|
25
|
+
RetrievalPolicy,
|
|
26
|
+
CrawlPayload,
|
|
27
|
+
LaneCandidate,
|
|
28
|
+
} from "./retrieval-control-plane";
|
|
29
|
+
|
|
30
|
+
import { getRetrievalControlPlane } from "./retrieval-control-plane";
|
|
31
|
+
|
|
32
|
+
import {
|
|
33
|
+
withChallengeGate,
|
|
34
|
+
prioritizeSeeds,
|
|
35
|
+
detectPageBlock,
|
|
36
|
+
} from "./retrieval-policy-augments";
|
|
37
|
+
|
|
38
|
+
import {
|
|
39
|
+
structuredSearch,
|
|
40
|
+
wrappedStructuredChallengeReader,
|
|
41
|
+
buildAmpCacheUrl,
|
|
42
|
+
fetchViaAmpCache,
|
|
43
|
+
type StructuredItem,
|
|
44
|
+
type StructuredAdapterOptions,
|
|
45
|
+
} from "./structured-source-adapter";
|
|
46
|
+
|
|
47
|
+
import {
|
|
48
|
+
packAdjudicationResult,
|
|
49
|
+
type EvidencePackOptions,
|
|
50
|
+
} from "./epistemic-packer";
|
|
51
|
+
|
|
52
|
+
import { arbiterResearch } from "./arbiter-omega";
|
|
53
|
+
import { adjudicateResearch } from "../scraper-palisade/palisade-adjudicator";
|
|
54
|
+
import { conclaveOmegaRead } from "./conclave-omega";
|
|
55
|
+
|
|
56
|
+
// ── Types ───────────────────────────────────────────────────────────────────
|
|
57
|
+
|
|
58
|
+
export interface TerminalWireOptions {
|
|
59
|
+
signal?: AbortSignal;
|
|
60
|
+
depth?: number;
|
|
61
|
+
enrichTop?: number;
|
|
62
|
+
maxContextTokens?: number;
|
|
63
|
+
charsPerToken?: number;
|
|
64
|
+
openAlexApiKey?: string;
|
|
65
|
+
allowTitanium?: boolean;
|
|
66
|
+
allowAmp?: boolean;
|
|
67
|
+
allowJina?: boolean;
|
|
68
|
+
allowPublicProxies?: boolean;
|
|
69
|
+
allowWayback?: boolean;
|
|
70
|
+
crawlExtra?: boolean;
|
|
71
|
+
maxCrawlPages?: number;
|
|
72
|
+
onDebug?: (m: string) => void;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface TerminalWireResult {
|
|
76
|
+
ok: boolean;
|
|
77
|
+
provider: string;
|
|
78
|
+
evidenceBlock: string;
|
|
79
|
+
pack: {
|
|
80
|
+
totalTokens: number;
|
|
81
|
+
droppedCount: number;
|
|
82
|
+
method: string;
|
|
83
|
+
utilization: number;
|
|
84
|
+
};
|
|
85
|
+
structuredItems: StructuredItem[];
|
|
86
|
+
dispositionCounts: Record<string, number>;
|
|
87
|
+
provenanceProof?: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// ── Challenge gate that populates Error.cause for SPA rescue ────────────────
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Same as withChallengeGate, but attaches raw HTML as Error.cause so
|
|
94
|
+
* wrappedStructuredChallengeReader can call rescueSpaPayload.
|
|
95
|
+
* Does not weaken hard-challenge rejection.
|
|
96
|
+
*/
|
|
97
|
+
export function withChallengeGateCause<T>(
|
|
98
|
+
reader: (
|
|
99
|
+
url: string,
|
|
100
|
+
ctx: ScheduleContext,
|
|
101
|
+
policy: RetrievalPolicy,
|
|
102
|
+
) => Promise<CrawlPayload<T> & { text?: string }>,
|
|
103
|
+
): (
|
|
104
|
+
url: string,
|
|
105
|
+
ctx: ScheduleContext,
|
|
106
|
+
policy: RetrievalPolicy,
|
|
107
|
+
) => Promise<CrawlPayload<T>> {
|
|
108
|
+
const gated = withChallengeGate(async (url, ctx, policy) => {
|
|
109
|
+
const payload = await reader(url, ctx, policy);
|
|
110
|
+
const text = payload.text ?? "";
|
|
111
|
+
const det = detectPageBlock(text);
|
|
112
|
+
if (det.blocked) {
|
|
113
|
+
const err = new Error(`challenge_detected:${det.kind}`);
|
|
114
|
+
// Bridge for wrappedStructuredChallengeReader SPA rescue path
|
|
115
|
+
(err as Error & { cause?: string }).cause = text;
|
|
116
|
+
throw err;
|
|
117
|
+
}
|
|
118
|
+
// Soft SPA shell: still return payload; structured interceptor may salvage
|
|
119
|
+
return payload;
|
|
120
|
+
});
|
|
121
|
+
return gated as any;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// ── Titanium lane builders (optional; compose into hedgedQuorum) ────────────
|
|
125
|
+
|
|
126
|
+
function proxyHost(proxy: ProxyDef, target: string): string {
|
|
127
|
+
try {
|
|
128
|
+
return new URL(proxy.build(target)).hostname;
|
|
129
|
+
} catch {
|
|
130
|
+
return `proxy-${proxy.name}`;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function buildGoogleTranslateUrl(targetUrl: string): string {
|
|
135
|
+
return `https://translate.google.com/translate?sl=auto&tl=en&u=${encodeURIComponent(targetUrl)}`;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Optional LaneCandidates: CORS proxy → Google Translate → target.
|
|
140
|
+
* Target WAF may see Google egress; residual ToS/rate/layout risk.
|
|
141
|
+
* admissionUrl = proxy host (scheduler accounting is honest).
|
|
142
|
+
*/
|
|
143
|
+
export function buildTitaniumTranslateLanes(
|
|
144
|
+
targetUrl: string,
|
|
145
|
+
maxBytes = 2_000_000,
|
|
146
|
+
): LaneCandidate<{ text: string; source: string; bytesRead: number }>[] {
|
|
147
|
+
const gUrl = buildGoogleTranslateUrl(targetUrl);
|
|
148
|
+
return PROXY_FLEET.map((proxy) => ({
|
|
149
|
+
id: `titanium:translate:${proxy.name}`,
|
|
150
|
+
laneClass: "hosted-renderer",
|
|
151
|
+
admissionUrl: `https://${proxyHost(proxy, gUrl)}/`,
|
|
152
|
+
priority: 55,
|
|
153
|
+
run: async (signal) => {
|
|
154
|
+
const res = await fetch(proxy.build(gUrl), {
|
|
155
|
+
method: "GET",
|
|
156
|
+
signal,
|
|
157
|
+
credentials: "omit",
|
|
158
|
+
referrerPolicy: "no-referrer",
|
|
159
|
+
});
|
|
160
|
+
if (!res.ok) throw new Error(`titanium_translate_${res.status}`);
|
|
161
|
+
const raw = proxy.unwrap ? proxy.unwrap(await res.text()) : await res.text();
|
|
162
|
+
const text = raw.slice(0, maxBytes);
|
|
163
|
+
const det = detectPageBlock(text);
|
|
164
|
+
if (det.blocked) throw new Error(`challenge_detected:${det.kind}`);
|
|
165
|
+
if (text.trim().length < 80) throw new Error("thin");
|
|
166
|
+
return {
|
|
167
|
+
text,
|
|
168
|
+
source: `titanium:translate:${proxy.name}`,
|
|
169
|
+
bytesRead: text.length,
|
|
170
|
+
};
|
|
171
|
+
},
|
|
172
|
+
}));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Optional AMP cache lanes (uses canonical buildAmpCacheUrl + fetchViaAmpCache
|
|
177
|
+
* when direct; proxy-chained when needed).
|
|
178
|
+
*/
|
|
179
|
+
export function buildTitaniumAmpLanes(
|
|
180
|
+
targetUrl: string,
|
|
181
|
+
maxBytes = 2_000_000,
|
|
182
|
+
): LaneCandidate<{ text: string; source: string; bytesRead: number }>[] {
|
|
183
|
+
const amp = buildAmpCacheUrl(targetUrl);
|
|
184
|
+
if (!amp) return [];
|
|
185
|
+
|
|
186
|
+
const lanes: LaneCandidate<{ text: string; source: string; bytesRead: number }>[] = [
|
|
187
|
+
{
|
|
188
|
+
id: "titanium:amp:direct",
|
|
189
|
+
laneClass: "hosted-renderer",
|
|
190
|
+
admissionUrl: "https://cdn.ampproject.org/",
|
|
191
|
+
priority: 70,
|
|
192
|
+
run: async (signal) => {
|
|
193
|
+
const r = await fetchViaAmpCache(targetUrl, { signal, maxBytes });
|
|
194
|
+
if (!r.ok) throw new Error("amp_miss");
|
|
195
|
+
const det = detectPageBlock(r.text);
|
|
196
|
+
if (det.blocked) throw new Error(`challenge_detected:${det.kind}`);
|
|
197
|
+
return { text: r.text, source: "titanium:amp:direct", bytesRead: r.text.length };
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
];
|
|
201
|
+
|
|
202
|
+
for (const proxy of PROXY_FLEET.slice(0, 2)) {
|
|
203
|
+
lanes.push({
|
|
204
|
+
id: `titanium:amp:${proxy.name}`,
|
|
205
|
+
laneClass: "hosted-renderer",
|
|
206
|
+
admissionUrl: `https://${proxyHost(proxy, amp)}/`,
|
|
207
|
+
priority: 60,
|
|
208
|
+
run: async (signal) => {
|
|
209
|
+
const res = await fetch(proxy.build(amp), {
|
|
210
|
+
method: "GET",
|
|
211
|
+
signal,
|
|
212
|
+
credentials: "omit",
|
|
213
|
+
referrerPolicy: "no-referrer",
|
|
214
|
+
});
|
|
215
|
+
if (!res.ok) throw new Error(`amp_proxy_${res.status}`);
|
|
216
|
+
const text = (proxy.unwrap ? proxy.unwrap(await res.text()) : await res.text()).slice(0, maxBytes);
|
|
217
|
+
if (detectPageBlock(text).blocked) throw new Error("challenge_detected");
|
|
218
|
+
if (text.trim().length < 80) throw new Error("thin");
|
|
219
|
+
return { text, source: `titanium:amp:${proxy.name}`, bytesRead: text.length };
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
return lanes;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// ── One-shot terminal ground ────────────────────────────────────────────────
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* terminalWireGround — full pipeline, one call, no double-fetch of research.
|
|
230
|
+
*
|
|
231
|
+
* Order:
|
|
232
|
+
* 1) structuredSearch (academic/RSS APIs, keyless except optional OpenAlex)
|
|
233
|
+
* 2) arbiterResearch (Conclave-Ω + FACR) once
|
|
234
|
+
* 3) adjudicateResearch (PALISADE) once
|
|
235
|
+
* 4) optional bounded crawl with robots + challenge-cause + structured intercept
|
|
236
|
+
* 5) packAdjudicationResult (canonical Opus knapsack) — boundaries never truncated
|
|
237
|
+
*/
|
|
238
|
+
export async function terminalWireGround(
|
|
239
|
+
query: string,
|
|
240
|
+
opts?: TerminalWireOptions,
|
|
241
|
+
): Promise<TerminalWireResult> {
|
|
242
|
+
const dbg = opts?.onDebug ?? (() => {});
|
|
243
|
+
const depth = Math.max(2, Math.min(20, Math.floor(opts?.depth ?? 8)));
|
|
244
|
+
const maxTokens = Math.max(500, Math.floor(opts?.maxContextTokens ?? 8_000));
|
|
245
|
+
|
|
246
|
+
// 1. Structured APIs first (no challenge pages)
|
|
247
|
+
dbg("terminal-wire: structuredSearch");
|
|
248
|
+
const structured = await structuredSearch(query, {
|
|
249
|
+
signal: opts?.signal,
|
|
250
|
+
limitPerSource: 6,
|
|
251
|
+
openAlexApiKey: opts?.openAlexApiKey,
|
|
252
|
+
} satisfies StructuredAdapterOptions);
|
|
253
|
+
|
|
254
|
+
// 2–3. Trust pipeline once
|
|
255
|
+
dbg("terminal-wire: arbiterResearch");
|
|
256
|
+
const research = await arbiterResearch(query, {
|
|
257
|
+
signal: opts?.signal,
|
|
258
|
+
depth,
|
|
259
|
+
enrichTop: opts?.enrichTop ?? Math.min(depth, 6),
|
|
260
|
+
allowJina: opts?.allowJina,
|
|
261
|
+
allowPublicProxies: opts?.allowPublicProxies,
|
|
262
|
+
allowWayback: opts?.allowWayback,
|
|
263
|
+
onDebug: dbg,
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
dbg("terminal-wire: adjudicateResearch");
|
|
267
|
+
const adjudication = await adjudicateResearch(research);
|
|
268
|
+
|
|
269
|
+
// 4. Optional extra crawl coverage (additive; does not re-run arbiter)
|
|
270
|
+
if (opts?.crawlExtra !== false) {
|
|
271
|
+
try {
|
|
272
|
+
const plane = getRetrievalControlPlane({
|
|
273
|
+
scheduler: {
|
|
274
|
+
globalConcurrency: 12,
|
|
275
|
+
hostConcurrencyStart: 2,
|
|
276
|
+
hostConcurrencyMax: 6,
|
|
277
|
+
},
|
|
278
|
+
});
|
|
279
|
+
const seeds = prioritizeSeeds(
|
|
280
|
+
research.sources
|
|
281
|
+
.map((s) => s.canonicalUrl || s.url)
|
|
282
|
+
.filter(Boolean)
|
|
283
|
+
.slice(0, 24),
|
|
284
|
+
);
|
|
285
|
+
if (seeds.length > 0) {
|
|
286
|
+
dbg(`terminal-wire: crawl ${seeds.length} seeds`);
|
|
287
|
+
const baseReader = async (
|
|
288
|
+
url: string,
|
|
289
|
+
ctx: ScheduleContext,
|
|
290
|
+
policy: RetrievalPolicy,
|
|
291
|
+
) => {
|
|
292
|
+
const read = await conclaveOmegaRead(url, {
|
|
293
|
+
signal: ctx.signal ?? opts?.signal,
|
|
294
|
+
maxBytes: policy.maxBytes,
|
|
295
|
+
});
|
|
296
|
+
return {
|
|
297
|
+
value: read,
|
|
298
|
+
text: read.markdown || read.content,
|
|
299
|
+
contentType: "text/markdown",
|
|
300
|
+
canonicalUrl: read.canonicalUrl,
|
|
301
|
+
bytesRead: read.bytesRead,
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
await plane.crawl(
|
|
305
|
+
seeds,
|
|
306
|
+
wrappedStructuredChallengeReader(
|
|
307
|
+
withChallengeGateCause(baseReader),
|
|
308
|
+
{
|
|
309
|
+
signal: opts?.signal,
|
|
310
|
+
openAlexApiKey: opts?.openAlexApiKey,
|
|
311
|
+
onSpaRescue: (u) => dbg(`spa-rescue: ${u}`),
|
|
312
|
+
},
|
|
313
|
+
),
|
|
314
|
+
{
|
|
315
|
+
signal: opts?.signal,
|
|
316
|
+
maxPages: opts?.maxCrawlPages ?? 12,
|
|
317
|
+
maxDepth: 1,
|
|
318
|
+
sameOriginOnly: true,
|
|
319
|
+
policy: {
|
|
320
|
+
extractionVersion: "conclave-omega-v1",
|
|
321
|
+
cacheMode: "performance",
|
|
322
|
+
freshnessMs: 3_600_000,
|
|
323
|
+
requiredLaneClasses: 2,
|
|
324
|
+
robotsMode: "advisory",
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
} catch (e) {
|
|
330
|
+
dbg(`terminal-wire: crawl skipped: ${e instanceof Error ? e.message : "err"}`);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Merge structured API hits into adjudication-like bag for packing value
|
|
335
|
+
// (claims already adjudicated; structured items appended as high-trust sources)
|
|
336
|
+
const enrichedForPack = {
|
|
337
|
+
...adjudication,
|
|
338
|
+
sources: [
|
|
339
|
+
...(adjudication as any).sources ?? research.sources ?? [],
|
|
340
|
+
...structured.items.map((it, i) => ({
|
|
341
|
+
index: 10_000 + i,
|
|
342
|
+
title: it.title,
|
|
343
|
+
canonicalUrl: it.externalUrl ?? it.doi ?? `structured:${it.kind}:${i}`,
|
|
344
|
+
url: it.externalUrl,
|
|
345
|
+
content: it.pageContent,
|
|
346
|
+
effectiveTrust: it.confidence,
|
|
347
|
+
quarantined: false,
|
|
348
|
+
})),
|
|
349
|
+
],
|
|
350
|
+
manifestRoot: (adjudication as any).provenance?.manifestRoot
|
|
351
|
+
?? (research as any).manifestRoot
|
|
352
|
+
?? "unavailable",
|
|
353
|
+
provider: `terminal-wire(${adjudication.provider}+structured:${structured.queriedSources?.join(",") ?? structured.items.length})`,
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
// 5. Canonical knapsack — never truncates header/footer/manifest
|
|
357
|
+
const { evidenceBlock, packResult } = packAdjudicationResult(enrichedForPack as any, {
|
|
358
|
+
maxContextTokens: maxTokens,
|
|
359
|
+
charsPerToken: opts?.charsPerToken ?? 4,
|
|
360
|
+
} satisfies EvidencePackOptions);
|
|
361
|
+
|
|
362
|
+
const counts = (adjudication as any).counts ?? {};
|
|
363
|
+
const ok =
|
|
364
|
+
(counts.attested ?? 0) + (counts.supported ?? 0) > 0
|
|
365
|
+
|| structured.items.length >= 2
|
|
366
|
+
|| research.ok;
|
|
367
|
+
|
|
368
|
+
return {
|
|
369
|
+
ok,
|
|
370
|
+
provider: enrichedForPack.provider,
|
|
371
|
+
evidenceBlock,
|
|
372
|
+
pack: {
|
|
373
|
+
totalTokens: packResult.totalTokens,
|
|
374
|
+
droppedCount: packResult.droppedCount,
|
|
375
|
+
method: packResult.method,
|
|
376
|
+
utilization: packResult.utilization,
|
|
377
|
+
},
|
|
378
|
+
structuredItems: structured.items,
|
|
379
|
+
dispositionCounts: counts,
|
|
380
|
+
provenanceProof: (adjudication as any).provenance?.proof,
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// ── Diagnostics ─────────────────────────────────────────────────────────────
|
|
385
|
+
|
|
386
|
+
export function runTerminalWireDiagnostics(): {
|
|
387
|
+
ok: boolean;
|
|
388
|
+
checks: Array<{ id: string; passed: boolean; detail: string }>;
|
|
389
|
+
} {
|
|
390
|
+
const checks: Array<{ id: string; passed: boolean; detail: string }> = [];
|
|
391
|
+
const add = (id: string, p: boolean, d: string) =>
|
|
392
|
+
checks.push({ id, passed: p, detail: d });
|
|
393
|
+
|
|
394
|
+
const tUrl = buildGoogleTranslateUrl("https://example.com/a");
|
|
395
|
+
add(
|
|
396
|
+
"translate-url",
|
|
397
|
+
tUrl.includes("translate.google.com") && tUrl.includes(encodeURIComponent("https://example.com/a")),
|
|
398
|
+
tUrl.slice(0, 80),
|
|
399
|
+
);
|
|
400
|
+
|
|
401
|
+
const ampLanes = buildTitaniumAmpLanes("https://www.example.com/x");
|
|
402
|
+
add("amp-lanes-nonempty-or-null-ok", Array.isArray(ampLanes), `n=${ampLanes.length}`);
|
|
403
|
+
|
|
404
|
+
const trLanes = buildTitaniumTranslateLanes("https://example.com/x");
|
|
405
|
+
add("translate-lanes-use-proxy-admission", trLanes.every((l) => l.laneClass === "hosted-renderer"), `n=${trLanes.length}`);
|
|
406
|
+
|
|
407
|
+
// cause bridge: hard challenge throws with cause string
|
|
408
|
+
let causeOk = false;
|
|
409
|
+
try {
|
|
410
|
+
const text = "Please stand by, while we are checking your browser before accessing";
|
|
411
|
+
const det = detectPageBlock(text);
|
|
412
|
+
if (det.blocked) {
|
|
413
|
+
const err = new Error(`challenge_detected:${det.kind}`);
|
|
414
|
+
(err as any).cause = text;
|
|
415
|
+
throw err;
|
|
416
|
+
}
|
|
417
|
+
} catch (e) {
|
|
418
|
+
causeOk = typeof (e as any)?.cause === "string" && (e as any).cause.length > 20;
|
|
419
|
+
}
|
|
420
|
+
add("challenge-cause-populated", causeOk, "Error.cause set for SPA rescue path");
|
|
421
|
+
|
|
422
|
+
add("no-wasm-socket-claim", true, "documented: Pyodide cannot bypass CORS");
|
|
423
|
+
|
|
424
|
+
return { ok: checks.every((c) => c.passed), checks };
|
|
425
|
+
}
|