@remnic/core 9.28.0 → 9.29.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/dist/access-admin-ops-surface.d.ts +10 -10
- package/dist/access-admin-ops-surface.js +32 -32
- package/dist/access-authorization-probe.d.ts +10 -10
- package/dist/access-authorization-probe.js +33 -33
- package/dist/access-boundary.d.ts +10 -10
- package/dist/access-boundary.js +32 -32
- package/dist/access-cli.js +101 -98
- package/dist/access-cli.js.map +1 -1
- package/dist/access-health-types.d.ts +1 -1
- package/dist/access-http-lcm-compaction.d.ts +10 -10
- package/dist/access-http.d.ts +10 -10
- package/dist/access-http.js +43 -43
- package/dist/access-identity-continuity-surface.d.ts +8 -8
- package/dist/access-identity-continuity-surface.js +32 -32
- package/dist/access-lcm-surface.d.ts +10 -10
- package/dist/access-lcm-surface.js +32 -32
- package/dist/access-mcp.d.ts +10 -10
- package/dist/access-mcp.js +38 -38
- package/dist/access-memory-search-fanout.d.ts +2 -2
- package/dist/access-memory-search-fanout.js +3 -3
- package/dist/{access-namespace-preflight-BiQ_-iUJ.d.ts → access-namespace-preflight-DCXBkDp0.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -3
- package/dist/access-namespace-preflight.js +32 -32
- package/dist/access-observe-write-surface.d.ts +10 -10
- package/dist/access-observe-write-surface.js +32 -32
- package/dist/access-operations-batch.js +35 -35
- package/dist/access-operations.d.ts +10 -10
- package/dist/access-operations.js +37 -37
- package/dist/access-recall-concurrency.d.ts +10 -10
- package/dist/access-recall-concurrency.js +32 -32
- package/dist/access-recall-response.d.ts +10 -10
- package/dist/access-recall-response.js +32 -32
- package/dist/access-recall-surface.d.ts +10 -10
- package/dist/access-recall-surface.js +32 -32
- package/dist/access-schema.d.ts +7 -7
- package/dist/access-schema.js +4 -4
- package/dist/{access-service-CXkIgcGh.d.ts → access-service-DvPW_M5j.d.ts} +7 -7
- package/dist/access-service.d.ts +10 -10
- package/dist/access-service.js +32 -32
- package/dist/access-surface-catalog.d.ts +10 -10
- package/dist/access-wearables-meetings-surface.d.ts +3 -3
- package/dist/action-confidence.d.ts +1 -1
- package/dist/active-memory-bridge.d.ts +1 -1
- package/dist/active-memory-bridge.js +3 -3
- package/dist/active-recall.d.ts +1 -1
- package/dist/active-recall.js +1 -1
- package/dist/adapters/index.js +4 -4
- package/dist/adapters/registry.js +2 -2
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +8 -8
- package/dist/briefing.d.ts +2 -2
- package/dist/briefing.js +8 -8
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer.d.ts +2 -2
- package/dist/buffer.js +2 -2
- package/dist/bulk-import/index.d.ts +3 -3
- package/dist/calibration.d.ts +1 -1
- package/dist/capabilities.d.ts +3 -2
- package/dist/capabilities.js +1 -1
- package/dist/{capsule-crypto-7FJQINUR.js → capsule-crypto-GWVG7LGC.js} +2 -2
- package/dist/{catalog-Bouj8Gfg.d.ts → catalog-BIVgftWu.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-consolidation.js +9 -9
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/{chunk-GQSMYXKL.js → chunk-2AXMQWCN.js} +2 -2
- package/dist/{chunk-VYYNBJXH.js → chunk-2D7FEUCK.js} +6 -6
- package/dist/{chunk-PXQM2HOG.js → chunk-2GXM5N5A.js} +2 -2
- package/dist/{chunk-RDQGLJRR.js → chunk-2XRE6FLM.js} +2 -1
- package/dist/{chunk-RDQGLJRR.js.map → chunk-2XRE6FLM.js.map} +1 -1
- package/dist/{chunk-JIF3VRKQ.js → chunk-35DL7IOI.js} +10 -10
- package/dist/{chunk-2H7OEVPO.js → chunk-3GD2HFR6.js} +2 -2
- package/dist/{chunk-KKBTBUVT.js → chunk-3JNDOAQ2.js} +5 -5
- package/dist/{chunk-4TFIRMTE.js → chunk-4A6YGWQN.js} +2 -2
- package/dist/{chunk-IKMAO55B.js → chunk-55MDBZLC.js} +2 -2
- package/dist/{chunk-RKXZ7P4V.js → chunk-5QDRGWT2.js} +3 -3
- package/dist/{chunk-IPLYGWQF.js → chunk-5W7CTZ2E.js} +6 -6
- package/dist/{chunk-ALTP3MFS.js → chunk-5ZCUDWD4.js} +2 -2
- package/dist/{chunk-B7GROTXD.js → chunk-6LKEUCEM.js} +2 -2
- package/dist/{chunk-2AJ72VVS.js → chunk-7BZOBA5J.js} +3 -3
- package/dist/{chunk-44DUJETW.js → chunk-7HXCF4RE.js} +2 -2
- package/dist/{chunk-WVVK2RFM.js → chunk-7L45JFPW.js} +14 -14
- package/dist/{chunk-R372P2EH.js → chunk-ACXPX4AG.js} +2 -2
- package/dist/{chunk-7CPOZH6Y.js → chunk-ALSGMEJR.js} +5 -5
- package/dist/{chunk-JGUXPJUQ.js → chunk-AS7YMSL6.js} +2 -2
- package/dist/{chunk-DKQM5Q6Q.js → chunk-CW4AGY3G.js} +4 -4
- package/dist/{chunk-ZN4UZWMT.js → chunk-D2ANTDGO.js} +3 -3
- package/dist/{chunk-3UOSVTFR.js → chunk-D3LMYTBV.js} +9 -9
- package/dist/{chunk-FOCEI3TN.js → chunk-DRBXHRXE.js} +2 -1
- package/dist/chunk-DRBXHRXE.js.map +1 -0
- package/dist/{chunk-LIHC3T43.js → chunk-E5OBR6CJ.js} +4 -4
- package/dist/{chunk-XY7QPJDA.js → chunk-E6EE5B67.js} +2 -2
- package/dist/{chunk-TBMRQZDY.js → chunk-EP5BVCRI.js} +2 -2
- package/dist/{chunk-MJPV4LBH.js → chunk-FUYEVEX7.js} +83 -83
- package/dist/{chunk-2BEJ4XCF.js → chunk-FZRQZW4H.js} +2 -2
- package/dist/{chunk-X6ROIHFE.js → chunk-G5R3D5UP.js} +2 -2
- package/dist/{chunk-2FYNLDKJ.js → chunk-GAWOEQEQ.js} +2 -2
- package/dist/{chunk-TKBDJTXG.js → chunk-GBJ4RDFR.js} +94 -20
- package/dist/chunk-GBJ4RDFR.js.map +1 -0
- package/dist/{chunk-QH6CS6XJ.js → chunk-H24WNPA2.js} +2 -2
- package/dist/{chunk-VFNI3RPT.js → chunk-HKJCMOT6.js} +2 -2
- package/dist/{chunk-JQ7T5VDC.js → chunk-HUHX2OCX.js} +1 -1
- package/dist/chunk-HUHX2OCX.js.map +1 -0
- package/dist/{chunk-EZWWCN7I.js → chunk-IAEAFLF2.js} +2 -2
- package/dist/{chunk-NBNDVNJ2.js → chunk-IGPEJVBY.js} +3 -3
- package/dist/{chunk-MQVINOJQ.js → chunk-IYZ5K7MU.js} +3 -3
- package/dist/{chunk-Q5VJUNXA.js → chunk-JMQUBRV6.js} +105 -42
- package/dist/chunk-JMQUBRV6.js.map +1 -0
- package/dist/{chunk-2TQ2UFKH.js → chunk-JP3YPDAW.js} +57 -57
- package/dist/{chunk-P2CLYN6H.js → chunk-K5GB36ME.js} +2 -2
- package/dist/{chunk-227UFSEQ.js → chunk-LEPOP46W.js} +4 -4
- package/dist/{chunk-FBZTWUK5.js → chunk-OFHFH655.js} +8 -8
- package/dist/{chunk-GJPCP5CA.js → chunk-OP6F6L3S.js} +2 -2
- package/dist/{chunk-FGBJBYWP.js → chunk-OVRQLAYR.js} +3 -3
- package/dist/{chunk-2NLLXCJG.js → chunk-OWHERGF2.js} +2 -2
- package/dist/{chunk-3BSJBIZ3.js → chunk-OYJKSZIQ.js} +2 -2
- package/dist/chunk-P2BM76KT.js +528 -0
- package/dist/chunk-P2BM76KT.js.map +1 -0
- package/dist/{chunk-UR5SIN7H.js → chunk-PBUZNGMX.js} +30 -30
- package/dist/{chunk-P2OZKKYP.js → chunk-PHWUFPCO.js} +2 -2
- package/dist/{chunk-Q6YJW6KE.js → chunk-PKRIQL3V.js} +2 -2
- package/dist/{chunk-BR4UFMLO.js → chunk-PTSNLEXK.js} +3 -3
- package/dist/{chunk-AHFZXUZM.js → chunk-QDKK63Y7.js} +3 -3
- package/dist/{chunk-JBPKEARU.js → chunk-RKNJBZ55.js} +4 -4
- package/dist/{chunk-FCCMFVS6.js → chunk-RPSYDM6C.js} +2 -2
- package/dist/chunk-RPW2NOU6.js +33 -0
- package/dist/chunk-RPW2NOU6.js.map +1 -0
- package/dist/{chunk-MWTMTW2T.js → chunk-SH6YO3LT.js} +3 -3
- package/dist/{chunk-IYT632D5.js → chunk-UBKEQOTD.js} +3 -3
- package/dist/{chunk-BJJAX3IZ.js → chunk-UTRO5UJU.js} +2 -2
- package/dist/{chunk-X7Y7WX73.js → chunk-UVYI6VIX.js} +1 -1
- package/dist/{chunk-S24E4MBQ.js → chunk-VSURVXKY.js} +9 -9
- package/dist/chunk-WOCNN776.js +742 -0
- package/dist/chunk-WOCNN776.js.map +1 -0
- package/dist/{chunk-YOBNCD3Z.js → chunk-WRFBW2TT.js} +10 -10
- package/dist/{chunk-MXJ3VP6S.js → chunk-WU7TTVOD.js} +7 -7
- package/dist/{chunk-EG64LXKL.js → chunk-XOZ4ALGB.js} +3 -3
- package/dist/{chunk-2PHX3I5C.js → chunk-Z54EM5YZ.js} +10 -10
- package/dist/{cli-DJbkaZBU.d.ts → cli-CxoSOiG0.d.ts} +5 -5
- package/dist/cli.d.ts +12 -12
- package/dist/cli.js +65 -65
- package/dist/compounding/engine.d.ts +2 -2
- package/dist/compounding/engine.js +9 -9
- package/dist/compounding/preference-consolidator.d.ts +1 -1
- package/dist/compression-optimizer.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +8 -8
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +9 -9
- package/dist/consolidation-provenance-check.d.ts +2 -2
- package/dist/consolidation-undo.d.ts +2 -2
- package/dist/contradiction/index.d.ts +2 -2
- package/dist/contradiction/index.js +6 -6
- package/dist/{contradiction-scan-HMF7CNKD.js → contradiction-scan-HYLIRMJ2.js} +3 -3
- package/dist/conversation-index/backend.d.ts +1 -1
- package/dist/conversation-index/backend.js +2 -2
- package/dist/conversation-index/chunker.d.ts +1 -1
- package/dist/conversation-index/faiss-adapter.d.ts +1 -1
- package/dist/conversation-index/indexer.d.ts +1 -1
- package/dist/conversation-index/search.d.ts +1 -1
- package/dist/corpus-watermark.d.ts +1 -1
- package/dist/corpus-watermark.js +16 -16
- package/dist/day-summary.d.ts +1 -1
- package/dist/day-summary.js +2 -2
- package/dist/delinearize.d.ts +1 -1
- package/dist/direct-answer-wiring.d.ts +1 -1
- package/dist/direct-answer.d.ts +1 -1
- package/dist/embedding-fallback.d.ts +1 -1
- package/dist/embedding-fallback.js +2 -2
- package/dist/enrichment/index.d.ts +1 -1
- package/dist/entity-retrieval.d.ts +2 -2
- package/dist/entity-retrieval.js +8 -8
- package/dist/entity-schema.d.ts +1 -1
- package/dist/explicit-capture.d.ts +8 -8
- package/dist/explicit-capture.js +2 -2
- package/dist/extraction-error-classification.d.ts +1 -1
- package/dist/extraction-faithfulness.d.ts +1 -1
- package/dist/extraction-judge-telemetry.d.ts +1 -1
- package/dist/extraction-judge-training.d.ts +1 -1
- package/dist/extraction-judge.d.ts +1 -1
- package/dist/extraction-liveness.d.ts +1 -1
- package/dist/extraction-source-grounding-helpers.d.ts +34 -0
- package/dist/extraction-source-grounding-helpers.js +62 -0
- package/dist/extraction-source-grounding-helpers.js.map +1 -0
- package/dist/extraction-source-grounding-rules.d.ts +18 -0
- package/dist/extraction-source-grounding-rules.js +12 -0
- package/dist/extraction-source-grounding-rules.js.map +1 -0
- package/dist/extraction-source-grounding.d.ts +11 -0
- package/dist/extraction-source-grounding.js +13 -0
- package/dist/extraction-source-grounding.js.map +1 -0
- package/dist/extraction.d.ts +3 -1
- package/dist/extraction.js +7 -4
- package/dist/fallback-llm.d.ts +1 -1
- package/dist/{first-start-migration-BKNGOFED.js → first-start-migration-F2QJD66E.js} +5 -5
- package/dist/graph-dashboard-diff.d.ts +1 -1
- package/dist/graph-dashboard-key.d.ts +1 -1
- package/dist/graph-dashboard-parser.d.ts +1 -1
- package/dist/graph-edge-reinforcement.d.ts +1 -1
- package/dist/graph-snapshot.d.ts +1 -1
- package/dist/graph.d.ts +1 -1
- package/dist/importance.d.ts +1 -1
- package/dist/importers/index.d.ts +1 -1
- package/dist/in-flight-reads.d.ts +1 -1
- package/dist/index.d.ts +19 -19
- package/dist/index.js +156 -153
- package/dist/intent.d.ts +1 -1
- package/dist/lcm/engine.d.ts +1 -1
- package/dist/lcm/engine.js +4 -4
- package/dist/lcm/index.d.ts +1 -1
- package/dist/lcm/index.js +10 -10
- package/dist/lcm/tools.d.ts +1 -1
- package/dist/lifecycle.d.ts +1 -1
- package/dist/live-connectors-runner.d.ts +1 -1
- package/dist/local-llm.d.ts +1 -1
- package/dist/local-llm.js +2 -2
- package/dist/local-model-endpoint.d.ts +1 -1
- package/dist/maintenance/memory-governance.d.ts +1 -1
- package/dist/maintenance/memory-governance.js +8 -8
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +8 -8
- package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-projection.js +9 -9
- package/dist/{maintenance-DveW6azo.d.ts → maintenance-Cb-PjxQd.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +10 -10
- package/dist/memory-action-policy.d.ts +1 -1
- package/dist/memory-cache.d.ts +1 -1
- package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
- package/dist/memory-projection-store.d.ts +1 -1
- package/dist/memory-provenance.d.ts +1 -1
- package/dist/memory-worth-outcomes.d.ts +2 -2
- package/dist/models-json.d.ts +1 -1
- package/dist/namespaces/migrate.d.ts +3 -3
- package/dist/namespaces/migrate.js +15 -15
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/principal.js +2 -2
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/search.js +7 -7
- package/dist/namespaces/storage.d.ts +3 -3
- package/dist/namespaces/storage.js +8 -8
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/offline-sync-impression-drain.d.ts +1 -1
- package/dist/offline-sync-impression-drain.js +6 -6
- package/dist/operator-doctor-corpus.d.ts +1 -1
- package/dist/operator-doctor-corpus.js +17 -17
- package/dist/operator-doctor-replica.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +3 -3
- package/dist/operator-toolkit.js +23 -23
- package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
- package/dist/orchestration/compression-guideline-coordinator.js +2 -2
- package/dist/orchestration/maintenance.d.ts +4 -4
- package/dist/orchestration/maintenance.js +15 -15
- package/dist/{orchestrator-Cvlgpe6I.d.ts → orchestrator-5GKqb_HL.d.ts} +7 -7
- package/dist/orchestrator.d.ts +8 -8
- package/dist/orchestrator.js +103 -100
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/{pipeline-BveYVaz7.d.ts → pipeline-3Qi1TpRo.d.ts} +1 -1
- package/dist/policy-runtime.d.ts +1 -1
- package/dist/proactive-contention.d.ts +1 -1
- package/dist/provenance.d.ts +1 -1
- package/dist/{qmd-CLWDsbYR.d.ts → qmd-D9JqzzRX.d.ts} +1 -1
- package/dist/qmd-preflight.d.ts +2 -2
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.d.ts +2 -2
- package/dist/recall-concurrency-config.d.ts +1 -1
- package/dist/recall-disclosure-escalation.d.ts +1 -1
- package/dist/recall-explain-renderer.d.ts +1 -1
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-memory-map.d.ts +1 -1
- package/dist/recall-planner-llm.d.ts +1 -1
- package/dist/recall-state.d.ts +1 -1
- package/dist/recall-tag-filter.d.ts +1 -1
- package/dist/recall-timings.d.ts +1 -1
- package/dist/recall-xray-cli.d.ts +1 -1
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.d.ts +1 -1
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.d.ts +1 -1
- package/dist/recall-xray.js +2 -2
- package/dist/replay/normalizers/chatgpt.d.ts +1 -1
- package/dist/replay/normalizers/claude.d.ts +1 -1
- package/dist/replay/normalizers/openclaw.d.ts +1 -1
- package/dist/replay/normalizers/shared.d.ts +1 -1
- package/dist/replay/runner.d.ts +1 -1
- package/dist/replay/types.d.ts +1 -1
- package/dist/replica-divergence.d.ts +1 -1
- package/dist/replica-peers-config.d.ts +1 -1
- package/dist/resolve-auth-token.d.ts +1 -1
- package/dist/resume-bundles.js +2 -2
- package/dist/retrieval-agents.d.ts +2 -2
- package/dist/retrieval-tiers.d.ts +1 -1
- package/dist/routing/engine.d.ts +1 -1
- package/dist/routing/store.d.ts +1 -1
- package/dist/salvage-envelope.d.ts +1 -1
- package/dist/{scope-profiles-BVf3DZ7z.d.ts → scope-profiles-C4g6_UdP.d.ts} +1 -1
- package/dist/search/embed-helper.d.ts +1 -1
- package/dist/search/embed-helper.js +2 -2
- package/dist/search/factory.d.ts +1 -1
- package/dist/search/factory.js +6 -6
- package/dist/search/index.d.ts +1 -1
- package/dist/search/index.js +10 -10
- package/dist/search/lancedb-backend.d.ts +1 -1
- package/dist/search/meilisearch-backend.d.ts +1 -1
- package/dist/search/noop-backend.d.ts +1 -1
- package/dist/search/orama-backend.d.ts +1 -1
- package/dist/search/port.d.ts +1 -1
- package/dist/search/remote-backend.d.ts +1 -1
- package/dist/{semantic-consolidation-DXLV47y2.d.ts → semantic-consolidation-BrxqnzTW.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +9 -9
- package/dist/semantic-rule-promotion.js +8 -8
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +8 -8
- package/dist/{service-DbgPTeMJ.d.ts → service-Bi1JgxdP.d.ts} +2 -2
- package/dist/session-observer-bands.d.ts +1 -1
- package/dist/session-observer-state.d.ts +1 -1
- package/dist/shared-context/manager.d.ts +1 -1
- package/dist/shared-context/manager.js +2 -2
- package/dist/signal.d.ts +1 -1
- package/dist/{storage-DOzTm8wG.d.ts → storage-CcH6yPk2.d.ts} +1 -1
- package/dist/storage.d.ts +2 -2
- package/dist/storage.js +7 -7
- package/dist/summarizer.d.ts +1 -1
- package/dist/summarizer.js +3 -3
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/temporal-supersession.d.ts +2 -2
- package/dist/temporal-timeline-recall.d.ts +1 -1
- package/dist/temporal-validity.d.ts +1 -1
- package/dist/threading.d.ts +1 -1
- package/dist/tier-migration.d.ts +2 -2
- package/dist/tier-routing.d.ts +1 -1
- package/dist/{tier-stats-XKD7SXYY.js → tier-stats-OPTSBNRH.js} +2 -2
- package/dist/topics.d.ts +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/transfer/autodetect.js +1 -1
- package/dist/transfer/backup.js +2 -2
- package/dist/transfer/capsule-export.js +3 -3
- package/dist/transfer/capsule-import.js +2 -2
- package/dist/trust-score-stage.d.ts +1 -1
- package/dist/trust-score.d.ts +1 -1
- package/dist/{types-BA7W-_xy.d.ts → types-Dg0w9ADr.d.ts} +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/utility-runtime.d.ts +1 -1
- package/dist/verified-recall.js +8 -8
- package/dist/write-envelope.d.ts +1 -1
- package/package.json +2 -2
- package/src/capabilities.test.ts +1 -0
- package/src/capabilities.ts +7 -7
- package/src/config.test.ts +5 -0
- package/src/config.ts +1 -1
- package/src/extraction-source-grounding-helpers.ts +603 -0
- package/src/extraction-source-grounding-rules.ts +1031 -0
- package/src/extraction-source-grounding.test.ts +2337 -0
- package/src/extraction-source-grounding.ts +50 -0
- package/src/extraction.ts +120 -15
- package/src/storage/entity-canonical-id-migration.ts +151 -23
- package/src/types.ts +2 -2
- package/dist/chunk-FOCEI3TN.js.map +0 -1
- package/dist/chunk-JQ7T5VDC.js.map +0 -1
- package/dist/chunk-Q5VJUNXA.js.map +0 -1
- package/dist/chunk-TKBDJTXG.js.map +0 -1
- /package/dist/{capsule-crypto-7FJQINUR.js.map → capsule-crypto-GWVG7LGC.js.map} +0 -0
- /package/dist/{chunk-GQSMYXKL.js.map → chunk-2AXMQWCN.js.map} +0 -0
- /package/dist/{chunk-VYYNBJXH.js.map → chunk-2D7FEUCK.js.map} +0 -0
- /package/dist/{chunk-PXQM2HOG.js.map → chunk-2GXM5N5A.js.map} +0 -0
- /package/dist/{chunk-JIF3VRKQ.js.map → chunk-35DL7IOI.js.map} +0 -0
- /package/dist/{chunk-2H7OEVPO.js.map → chunk-3GD2HFR6.js.map} +0 -0
- /package/dist/{chunk-KKBTBUVT.js.map → chunk-3JNDOAQ2.js.map} +0 -0
- /package/dist/{chunk-4TFIRMTE.js.map → chunk-4A6YGWQN.js.map} +0 -0
- /package/dist/{chunk-IKMAO55B.js.map → chunk-55MDBZLC.js.map} +0 -0
- /package/dist/{chunk-RKXZ7P4V.js.map → chunk-5QDRGWT2.js.map} +0 -0
- /package/dist/{chunk-IPLYGWQF.js.map → chunk-5W7CTZ2E.js.map} +0 -0
- /package/dist/{chunk-ALTP3MFS.js.map → chunk-5ZCUDWD4.js.map} +0 -0
- /package/dist/{chunk-B7GROTXD.js.map → chunk-6LKEUCEM.js.map} +0 -0
- /package/dist/{chunk-2AJ72VVS.js.map → chunk-7BZOBA5J.js.map} +0 -0
- /package/dist/{chunk-44DUJETW.js.map → chunk-7HXCF4RE.js.map} +0 -0
- /package/dist/{chunk-WVVK2RFM.js.map → chunk-7L45JFPW.js.map} +0 -0
- /package/dist/{chunk-R372P2EH.js.map → chunk-ACXPX4AG.js.map} +0 -0
- /package/dist/{chunk-7CPOZH6Y.js.map → chunk-ALSGMEJR.js.map} +0 -0
- /package/dist/{chunk-JGUXPJUQ.js.map → chunk-AS7YMSL6.js.map} +0 -0
- /package/dist/{chunk-DKQM5Q6Q.js.map → chunk-CW4AGY3G.js.map} +0 -0
- /package/dist/{chunk-ZN4UZWMT.js.map → chunk-D2ANTDGO.js.map} +0 -0
- /package/dist/{chunk-3UOSVTFR.js.map → chunk-D3LMYTBV.js.map} +0 -0
- /package/dist/{chunk-LIHC3T43.js.map → chunk-E5OBR6CJ.js.map} +0 -0
- /package/dist/{chunk-XY7QPJDA.js.map → chunk-E6EE5B67.js.map} +0 -0
- /package/dist/{chunk-TBMRQZDY.js.map → chunk-EP5BVCRI.js.map} +0 -0
- /package/dist/{chunk-MJPV4LBH.js.map → chunk-FUYEVEX7.js.map} +0 -0
- /package/dist/{chunk-2BEJ4XCF.js.map → chunk-FZRQZW4H.js.map} +0 -0
- /package/dist/{chunk-X6ROIHFE.js.map → chunk-G5R3D5UP.js.map} +0 -0
- /package/dist/{chunk-2FYNLDKJ.js.map → chunk-GAWOEQEQ.js.map} +0 -0
- /package/dist/{chunk-QH6CS6XJ.js.map → chunk-H24WNPA2.js.map} +0 -0
- /package/dist/{chunk-VFNI3RPT.js.map → chunk-HKJCMOT6.js.map} +0 -0
- /package/dist/{chunk-EZWWCN7I.js.map → chunk-IAEAFLF2.js.map} +0 -0
- /package/dist/{chunk-NBNDVNJ2.js.map → chunk-IGPEJVBY.js.map} +0 -0
- /package/dist/{chunk-MQVINOJQ.js.map → chunk-IYZ5K7MU.js.map} +0 -0
- /package/dist/{chunk-2TQ2UFKH.js.map → chunk-JP3YPDAW.js.map} +0 -0
- /package/dist/{chunk-P2CLYN6H.js.map → chunk-K5GB36ME.js.map} +0 -0
- /package/dist/{chunk-227UFSEQ.js.map → chunk-LEPOP46W.js.map} +0 -0
- /package/dist/{chunk-FBZTWUK5.js.map → chunk-OFHFH655.js.map} +0 -0
- /package/dist/{chunk-GJPCP5CA.js.map → chunk-OP6F6L3S.js.map} +0 -0
- /package/dist/{chunk-FGBJBYWP.js.map → chunk-OVRQLAYR.js.map} +0 -0
- /package/dist/{chunk-2NLLXCJG.js.map → chunk-OWHERGF2.js.map} +0 -0
- /package/dist/{chunk-3BSJBIZ3.js.map → chunk-OYJKSZIQ.js.map} +0 -0
- /package/dist/{chunk-UR5SIN7H.js.map → chunk-PBUZNGMX.js.map} +0 -0
- /package/dist/{chunk-P2OZKKYP.js.map → chunk-PHWUFPCO.js.map} +0 -0
- /package/dist/{chunk-Q6YJW6KE.js.map → chunk-PKRIQL3V.js.map} +0 -0
- /package/dist/{chunk-BR4UFMLO.js.map → chunk-PTSNLEXK.js.map} +0 -0
- /package/dist/{chunk-AHFZXUZM.js.map → chunk-QDKK63Y7.js.map} +0 -0
- /package/dist/{chunk-JBPKEARU.js.map → chunk-RKNJBZ55.js.map} +0 -0
- /package/dist/{chunk-FCCMFVS6.js.map → chunk-RPSYDM6C.js.map} +0 -0
- /package/dist/{chunk-MWTMTW2T.js.map → chunk-SH6YO3LT.js.map} +0 -0
- /package/dist/{chunk-IYT632D5.js.map → chunk-UBKEQOTD.js.map} +0 -0
- /package/dist/{chunk-BJJAX3IZ.js.map → chunk-UTRO5UJU.js.map} +0 -0
- /package/dist/{chunk-X7Y7WX73.js.map → chunk-UVYI6VIX.js.map} +0 -0
- /package/dist/{chunk-S24E4MBQ.js.map → chunk-VSURVXKY.js.map} +0 -0
- /package/dist/{chunk-YOBNCD3Z.js.map → chunk-WRFBW2TT.js.map} +0 -0
- /package/dist/{chunk-MXJ3VP6S.js.map → chunk-WU7TTVOD.js.map} +0 -0
- /package/dist/{chunk-EG64LXKL.js.map → chunk-XOZ4ALGB.js.map} +0 -0
- /package/dist/{chunk-2PHX3I5C.js.map → chunk-Z54EM5YZ.js.map} +0 -0
- /package/dist/{contradiction-scan-HMF7CNKD.js.map → contradiction-scan-HYLIRMJ2.js.map} +0 -0
- /package/dist/{first-start-migration-BKNGOFED.js.map → first-start-migration-F2QJD66E.js.map} +0 -0
- /package/dist/{tier-stats-XKD7SXYY.js.map → tier-stats-OPTSBNRH.js.map} +0 -0
|
@@ -0,0 +1,603 @@
|
|
|
1
|
+
export function isInterrogativeSourceSentence(sentence: string): boolean {
|
|
2
|
+
const normalized = sentence.trim();
|
|
3
|
+
const embeddedQuestionVerbIndex = normalized.search(
|
|
4
|
+
/\b(?:determine|know|wonder|ask(?:ed)?|question|decide|check|confirm|find|figure|understand|unclear)\b/iu,
|
|
5
|
+
);
|
|
6
|
+
const embeddedQuestionMarkerIndex = normalized.search(/\b(?:whether|if)\b/iu);
|
|
7
|
+
const hasEmbeddedQuestion = embeddedQuestionVerbIndex >= 0
|
|
8
|
+
&& embeddedQuestionMarkerIndex > embeddedQuestionVerbIndex;
|
|
9
|
+
return normalized.endsWith("?")
|
|
10
|
+
|| hasEmbeddedQuestion
|
|
11
|
+
|| (
|
|
12
|
+
!normalized.includes(":")
|
|
13
|
+
&& /^(?:suppose|assuming|assume|maybe|perhaps|hypothetically|if|whether|imagine|imagining|presume|presuming|supposing|is|are|am|was|were|do|does|did|can|could|will|would|should|has|have|had|what|which|when|where|why|how|who)\b/iu.test(
|
|
14
|
+
normalized,
|
|
15
|
+
)
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function containsContiguousGroundingTokens(
|
|
20
|
+
candidateTokens: ReadonlyArray<string>,
|
|
21
|
+
sourceTokens: ReadonlyArray<string>,
|
|
22
|
+
): boolean {
|
|
23
|
+
if (candidateTokens.length === 0 || candidateTokens.length > sourceTokens.length) return false;
|
|
24
|
+
return sourceTokens.some((_, start) =>
|
|
25
|
+
candidateTokens.every((token, offset) => sourceTokens[start + offset] === token),
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function hasExplicitRoleSubjectToken(
|
|
30
|
+
candidateRole: string | undefined,
|
|
31
|
+
sourceTokensBySentence: ReadonlyArray<ReadonlyArray<string>>,
|
|
32
|
+
): boolean {
|
|
33
|
+
return candidateRole !== undefined
|
|
34
|
+
&& sourceTokensBySentence.some((tokens) => tokens.includes(candidateRole));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function splitGroundingClauses(sentences: ReadonlyArray<string>): string[] {
|
|
38
|
+
return sentences.flatMap((sentence) =>
|
|
39
|
+
sentence
|
|
40
|
+
.split(/,\s+(?=[\p{L}][\p{L}\p{N}'’-]*\s+\S)/gu)
|
|
41
|
+
.flatMap((commaClause) =>
|
|
42
|
+
commaClause
|
|
43
|
+
.split(/\s*(?::|[—–])\s+|\s+\/\s+/u)
|
|
44
|
+
.flatMap((delimiterClause) =>
|
|
45
|
+
delimiterClause
|
|
46
|
+
.split(/\s+(?:and|but|or|while|although|because)\s+/gu)
|
|
47
|
+
.map((clause) => clause.trim())
|
|
48
|
+
.filter((clause) => clause.length > 0),
|
|
49
|
+
),
|
|
50
|
+
),
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const GROUNDING_STOPWORDS: Record<string, true> = {
|
|
55
|
+
a: true,
|
|
56
|
+
an: true,
|
|
57
|
+
and: true,
|
|
58
|
+
are: true,
|
|
59
|
+
as: true,
|
|
60
|
+
at: true,
|
|
61
|
+
be: true,
|
|
62
|
+
been: true,
|
|
63
|
+
being: true,
|
|
64
|
+
but: true,
|
|
65
|
+
by: true,
|
|
66
|
+
can: true,
|
|
67
|
+
could: true,
|
|
68
|
+
did: true,
|
|
69
|
+
do: true,
|
|
70
|
+
does: true,
|
|
71
|
+
for: true,
|
|
72
|
+
from: true,
|
|
73
|
+
had: true,
|
|
74
|
+
has: true,
|
|
75
|
+
have: true,
|
|
76
|
+
he: true,
|
|
77
|
+
her: true,
|
|
78
|
+
here: true,
|
|
79
|
+
hers: true,
|
|
80
|
+
him: true,
|
|
81
|
+
his: true,
|
|
82
|
+
how: true,
|
|
83
|
+
i: true,
|
|
84
|
+
if: true,
|
|
85
|
+
in: true,
|
|
86
|
+
into: true,
|
|
87
|
+
is: true,
|
|
88
|
+
it: true,
|
|
89
|
+
its: true,
|
|
90
|
+
just: true,
|
|
91
|
+
me: true,
|
|
92
|
+
my: true,
|
|
93
|
+
no: true,
|
|
94
|
+
not: true,
|
|
95
|
+
of: true,
|
|
96
|
+
on: true,
|
|
97
|
+
only: true,
|
|
98
|
+
or: true,
|
|
99
|
+
our: true,
|
|
100
|
+
ours: true,
|
|
101
|
+
she: true,
|
|
102
|
+
so: true,
|
|
103
|
+
than: true,
|
|
104
|
+
that: true,
|
|
105
|
+
the: true,
|
|
106
|
+
their: true,
|
|
107
|
+
them: true,
|
|
108
|
+
then: true,
|
|
109
|
+
there: true,
|
|
110
|
+
these: true,
|
|
111
|
+
they: true,
|
|
112
|
+
this: true,
|
|
113
|
+
those: true,
|
|
114
|
+
to: true,
|
|
115
|
+
too: true,
|
|
116
|
+
under: true,
|
|
117
|
+
up: true,
|
|
118
|
+
us: true,
|
|
119
|
+
very: true,
|
|
120
|
+
was: true,
|
|
121
|
+
we: true,
|
|
122
|
+
were: true,
|
|
123
|
+
what: true,
|
|
124
|
+
when: true,
|
|
125
|
+
why: true,
|
|
126
|
+
where: true,
|
|
127
|
+
which: true,
|
|
128
|
+
who: true,
|
|
129
|
+
will: true,
|
|
130
|
+
with: true,
|
|
131
|
+
would: true,
|
|
132
|
+
you: true,
|
|
133
|
+
your: true,
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export const GROUNDING_NEGATION_TOKENS = new Set([
|
|
137
|
+
"no",
|
|
138
|
+
"not",
|
|
139
|
+
"false",
|
|
140
|
+
"untrue",
|
|
141
|
+
"incorrect",
|
|
142
|
+
"wrong",
|
|
143
|
+
"never",
|
|
144
|
+
"without",
|
|
145
|
+
"neither",
|
|
146
|
+
"nor",
|
|
147
|
+
"none",
|
|
148
|
+
"cannot",
|
|
149
|
+
"cant",
|
|
150
|
+
"can't",
|
|
151
|
+
"don't",
|
|
152
|
+
"doesn't",
|
|
153
|
+
"didn't",
|
|
154
|
+
"isn't",
|
|
155
|
+
"aren't",
|
|
156
|
+
"wasn't",
|
|
157
|
+
"weren't",
|
|
158
|
+
"won't",
|
|
159
|
+
"wouldn't",
|
|
160
|
+
"couldn't",
|
|
161
|
+
"shouldn't",
|
|
162
|
+
"haven't",
|
|
163
|
+
"hasn't",
|
|
164
|
+
"hadn't",
|
|
165
|
+
]);
|
|
166
|
+
|
|
167
|
+
export const GROUNDING_AUXILIARY_TOKENS = new Set([
|
|
168
|
+
"am",
|
|
169
|
+
"are",
|
|
170
|
+
"be",
|
|
171
|
+
"been",
|
|
172
|
+
"being",
|
|
173
|
+
"can",
|
|
174
|
+
"could",
|
|
175
|
+
"did",
|
|
176
|
+
"do",
|
|
177
|
+
"does",
|
|
178
|
+
"had",
|
|
179
|
+
"has",
|
|
180
|
+
"have",
|
|
181
|
+
"is",
|
|
182
|
+
"was",
|
|
183
|
+
"were",
|
|
184
|
+
"will",
|
|
185
|
+
"would",
|
|
186
|
+
"should",
|
|
187
|
+
]);
|
|
188
|
+
|
|
189
|
+
export const GROUNDING_COPULAR_FORMS = new Set([
|
|
190
|
+
"am",
|
|
191
|
+
"are",
|
|
192
|
+
"be",
|
|
193
|
+
"been",
|
|
194
|
+
"being",
|
|
195
|
+
"is",
|
|
196
|
+
"was",
|
|
197
|
+
"were",
|
|
198
|
+
]);
|
|
199
|
+
|
|
200
|
+
export const GROUNDING_SUBJECT_PRONOUNS = new Set([
|
|
201
|
+
"he",
|
|
202
|
+
"she",
|
|
203
|
+
"they",
|
|
204
|
+
"it",
|
|
205
|
+
"i",
|
|
206
|
+
"we",
|
|
207
|
+
"you",
|
|
208
|
+
]);
|
|
209
|
+
export const GROUNDING_ENTITY_TYPE_PREFIXES = new Set([
|
|
210
|
+
"person",
|
|
211
|
+
"project",
|
|
212
|
+
"tool",
|
|
213
|
+
"company",
|
|
214
|
+
"place",
|
|
215
|
+
"other",
|
|
216
|
+
]);
|
|
217
|
+
|
|
218
|
+
export const GROUNDING_COMMON_VERB_FORMS = new Set([
|
|
219
|
+
"contains",
|
|
220
|
+
"employs",
|
|
221
|
+
"gives",
|
|
222
|
+
"has",
|
|
223
|
+
"hosts",
|
|
224
|
+
"likes",
|
|
225
|
+
"makes",
|
|
226
|
+
"needs",
|
|
227
|
+
"owns",
|
|
228
|
+
"prefers",
|
|
229
|
+
"requires",
|
|
230
|
+
"runs",
|
|
231
|
+
"shares",
|
|
232
|
+
"supports",
|
|
233
|
+
"takes",
|
|
234
|
+
"uses",
|
|
235
|
+
"wants",
|
|
236
|
+
"works",
|
|
237
|
+
]);
|
|
238
|
+
|
|
239
|
+
export interface GroundingLexeme {
|
|
240
|
+
token: string;
|
|
241
|
+
preserveTerminalS: boolean;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export function groundingLexemes(text: string): GroundingLexeme[] {
|
|
245
|
+
return text.normalize("NFKC").match(
|
|
246
|
+
/[\p{L}\p{N}]+(?:['’][\p{L}\p{N}]+)?(?:\+\+[\p{L}\p{N}]*|#[\p{L}\p{N}]*)?/gu,
|
|
247
|
+
)
|
|
248
|
+
?.map((rawToken) => {
|
|
249
|
+
const token = rawToken.replaceAll("’", "'").toLocaleLowerCase();
|
|
250
|
+
return {
|
|
251
|
+
token,
|
|
252
|
+
preserveTerminalS: /^\p{Lu}/u.test(rawToken) && !GROUNDING_COMMON_VERB_FORMS.has(token),
|
|
253
|
+
};
|
|
254
|
+
})
|
|
255
|
+
?? [];
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export function tokenSequence(text: string): string[] {
|
|
259
|
+
return groundingLexemes(text).map(({ token }) => token);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export function containsExactTokenSequence(candidate: string, source: string): boolean {
|
|
263
|
+
const candidateTokens = tokenSequence(candidate);
|
|
264
|
+
const sourceTokens = tokenSequence(source);
|
|
265
|
+
if (candidateTokens.length === 0 || candidateTokens.length > sourceTokens.length) return false;
|
|
266
|
+
return sourceTokens.some((_, index) =>
|
|
267
|
+
candidateTokens.every((token, offset) => sourceTokens[index + offset] === token),
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export function isNegationCue(token: string): boolean {
|
|
273
|
+
return GROUNDING_NEGATION_TOKENS.has(token) || token.endsWith("n't");
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export function isAttachedNegatedAuxiliary(token: string): boolean {
|
|
277
|
+
return token.endsWith("n't")
|
|
278
|
+
|| token === "cannot"
|
|
279
|
+
|| token === "cant"
|
|
280
|
+
|| token === "can't";
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export function isNegatedAt(tokens: ReadonlyArray<string>, index: number): boolean {
|
|
284
|
+
if (tokens[index - 1] === "only" && tokens[index - 2] === "not") return false;
|
|
285
|
+
const previousStart = Math.max(0, index - 2);
|
|
286
|
+
for (let i = previousStart; i < index; i += 1) {
|
|
287
|
+
if (isNegationCue(tokens[i])) return true;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (tokens[index - 1] === "than" && tokens[index - 2] === "rather") return true;
|
|
291
|
+
if (tokens[index - 1] === "of" && tokens[index - 2] === "instead") return true;
|
|
292
|
+
|
|
293
|
+
const next = tokens[index + 1];
|
|
294
|
+
if (next !== undefined && isAttachedNegatedAuxiliary(next)) return true;
|
|
295
|
+
const nextNext = tokens[index + 2];
|
|
296
|
+
return next !== undefined
|
|
297
|
+
&& nextNext !== undefined
|
|
298
|
+
&& GROUNDING_AUXILIARY_TOKENS.has(next)
|
|
299
|
+
&& isNegationCue(nextNext);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export const GROUNDING_MIN_SHARED_TOKENS = 2;
|
|
303
|
+
export const GROUNDING_MIN_COVERAGE = 0.5;
|
|
304
|
+
|
|
305
|
+
export function stemToken(token: string, preserveTerminalS = false): string {
|
|
306
|
+
if (token.endsWith("'s")) return token.slice(0, -2);
|
|
307
|
+
if (preserveTerminalS) return token;
|
|
308
|
+
if (token.length > 5 && token.endsWith("ing")) {
|
|
309
|
+
const stem = token.slice(0, -3);
|
|
310
|
+
return /(.)\1$/u.test(stem) ? stem.slice(0, -1) : stem;
|
|
311
|
+
}
|
|
312
|
+
if (token.length > 4 && token.endsWith("ed")) return token.slice(0, -2);
|
|
313
|
+
if (
|
|
314
|
+
!preserveTerminalS
|
|
315
|
+
&& token.length > 3
|
|
316
|
+
&& token.endsWith("s")
|
|
317
|
+
&& !token.endsWith("ss")
|
|
318
|
+
&& GROUNDING_COMMON_VERB_FORMS.has(token)
|
|
319
|
+
) {
|
|
320
|
+
return token.slice(0, -1);
|
|
321
|
+
}
|
|
322
|
+
return token;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
export function tokenize(text: string): Set<string> {
|
|
327
|
+
const tokens = new Set<string>();
|
|
328
|
+
for (const { token, preserveTerminalS } of groundingLexemes(text)) {
|
|
329
|
+
if (GROUNDING_STOPWORDS[token] !== true) tokens.add(stemToken(token, preserveTerminalS));
|
|
330
|
+
}
|
|
331
|
+
return tokens;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export function normalizeForExactMatch(text: string): string {
|
|
335
|
+
return text.normalize("NFKC").toLocaleLowerCase().replace(/\s+/gu, " ").trim();
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export function sourceSentences(source: string): string[] {
|
|
339
|
+
const sentences: string[] = [];
|
|
340
|
+
let sentenceStart = 0;
|
|
341
|
+
for (let index = 0; index < source.length; index += 1) {
|
|
342
|
+
const character = source[index];
|
|
343
|
+
const nextCharacter = source[index + 1];
|
|
344
|
+
const boundary = character === "!"
|
|
345
|
+
|| character === "?"
|
|
346
|
+
|| character === ";"
|
|
347
|
+
|| character === "\n"
|
|
348
|
+
|| (character === "." && (
|
|
349
|
+
nextCharacter === undefined
|
|
350
|
+
|| /\s/u.test(nextCharacter)
|
|
351
|
+
|| /["')\]}]/u.test(nextCharacter)
|
|
352
|
+
));
|
|
353
|
+
if (!boundary) continue;
|
|
354
|
+
let sentenceEnd = character === "\n" ? index : index + 1;
|
|
355
|
+
while (/[.!?;\n]/u.test(source[sentenceEnd] ?? "")) sentenceEnd += 1;
|
|
356
|
+
const sentence = source.slice(sentenceStart, sentenceEnd).trim();
|
|
357
|
+
if (sentence.length > 0) sentences.push(sentence);
|
|
358
|
+
sentenceStart = sentenceEnd;
|
|
359
|
+
index = sentenceEnd - 1;
|
|
360
|
+
}
|
|
361
|
+
const trailingSentence = source.slice(sentenceStart).trim();
|
|
362
|
+
if (trailingSentence.length > 0) sentences.push(trailingSentence);
|
|
363
|
+
return sentences.length > 0 ? sentences : [source];
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
export function groundingTokenSequence(text: string): string[] {
|
|
368
|
+
let lexemes = groundingLexemes(text);
|
|
369
|
+
while (lexemes.length > 0 && GROUNDING_AUXILIARY_TOKENS.has(lexemes[0]!.token)) {
|
|
370
|
+
lexemes = lexemes.slice(1);
|
|
371
|
+
}
|
|
372
|
+
return lexemes
|
|
373
|
+
.filter(({ token }) => GROUNDING_STOPWORDS[token] !== true)
|
|
374
|
+
.map(({ token, preserveTerminalS }) => stemToken(token, preserveTerminalS));
|
|
375
|
+
}
|
|
376
|
+
export function normalizedGroundingAlignmentTokenSequence(text: string): string[] {
|
|
377
|
+
const normalized = normalizedGroundingTokenSequence(text);
|
|
378
|
+
const firstLexeme = groundingLexemes(text)[0];
|
|
379
|
+
if (firstLexeme === undefined || !GROUNDING_SUBJECT_PRONOUNS.has(firstLexeme.token)) {
|
|
380
|
+
return normalized;
|
|
381
|
+
}
|
|
382
|
+
return [stemToken(firstLexeme.token, firstLexeme.preserveTerminalS), ...normalized];
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
export function normalizedGroundingTokenSequence(text: string): string[] {
|
|
387
|
+
return groundingTokenSequence(text).map((token) => token.replace(/'$/u, ""));
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
export function areGroundingTokensCompatible(left: string, right: string): boolean {
|
|
391
|
+
return left === right || `${left}e` === right || left === `${right}e`;
|
|
392
|
+
}
|
|
393
|
+
const GROUNDING_DENIAL_REPORTING_VERBS = new Set([
|
|
394
|
+
"deny",
|
|
395
|
+
"denied",
|
|
396
|
+
"denies",
|
|
397
|
+
"denying",
|
|
398
|
+
"dispute",
|
|
399
|
+
"disputed",
|
|
400
|
+
"disputes",
|
|
401
|
+
"disputing",
|
|
402
|
+
"reject",
|
|
403
|
+
"rejected",
|
|
404
|
+
"rejects",
|
|
405
|
+
"rejecting",
|
|
406
|
+
"refute",
|
|
407
|
+
"refuted",
|
|
408
|
+
"refutes",
|
|
409
|
+
"refuting",
|
|
410
|
+
"contradict",
|
|
411
|
+
"contradicted",
|
|
412
|
+
"contradicts",
|
|
413
|
+
"contradicting",
|
|
414
|
+
"disprove",
|
|
415
|
+
"disproved",
|
|
416
|
+
"disproves",
|
|
417
|
+
"disproving",
|
|
418
|
+
]);
|
|
419
|
+
|
|
420
|
+
function isDenialReportingVerb(token: string): boolean {
|
|
421
|
+
return GROUNDING_DENIAL_REPORTING_VERBS.has(token);
|
|
422
|
+
}
|
|
423
|
+
const GROUNDING_NON_ASSERTIVE_REPORTING_VERBS = new Set([
|
|
424
|
+
"allege",
|
|
425
|
+
"alleged",
|
|
426
|
+
"alleges",
|
|
427
|
+
"alleging",
|
|
428
|
+
"allegedly",
|
|
429
|
+
"assert",
|
|
430
|
+
"asserted",
|
|
431
|
+
"asserts",
|
|
432
|
+
"asserting",
|
|
433
|
+
"believe",
|
|
434
|
+
"believed",
|
|
435
|
+
"believes",
|
|
436
|
+
"believing",
|
|
437
|
+
"claim",
|
|
438
|
+
"claimed",
|
|
439
|
+
"claims",
|
|
440
|
+
"claiming",
|
|
441
|
+
"doubt",
|
|
442
|
+
"doubted",
|
|
443
|
+
"doubts",
|
|
444
|
+
"doubting",
|
|
445
|
+
"uncertain",
|
|
446
|
+
"unsure",
|
|
447
|
+
"unclear",
|
|
448
|
+
"unknown",
|
|
449
|
+
"possibly",
|
|
450
|
+
"probably",
|
|
451
|
+
"imagine",
|
|
452
|
+
"imagined",
|
|
453
|
+
"imagines",
|
|
454
|
+
"imagining",
|
|
455
|
+
"report",
|
|
456
|
+
"reported",
|
|
457
|
+
"reports",
|
|
458
|
+
"reporting",
|
|
459
|
+
"reportedly",
|
|
460
|
+
"say",
|
|
461
|
+
"said",
|
|
462
|
+
"says",
|
|
463
|
+
"saying",
|
|
464
|
+
"speculate",
|
|
465
|
+
"speculated",
|
|
466
|
+
"speculates",
|
|
467
|
+
"speculating",
|
|
468
|
+
"suspect",
|
|
469
|
+
"suspected",
|
|
470
|
+
"suspects",
|
|
471
|
+
"suspecting",
|
|
472
|
+
"suppose",
|
|
473
|
+
"supposed",
|
|
474
|
+
"supposes",
|
|
475
|
+
"supposing",
|
|
476
|
+
"supposedly",
|
|
477
|
+
"think",
|
|
478
|
+
"thought",
|
|
479
|
+
"thinks",
|
|
480
|
+
"thinking",
|
|
481
|
+
]);
|
|
482
|
+
|
|
483
|
+
function isNonAssertiveReportingVerb(token: string): boolean {
|
|
484
|
+
return GROUNDING_NON_ASSERTIVE_REPORTING_VERBS.has(token);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
function isGroundingClauseBoundary(token: string): boolean {
|
|
488
|
+
return token === "and"
|
|
489
|
+
|| token === "but"
|
|
490
|
+
|| token === "or"
|
|
491
|
+
|| token === "while"
|
|
492
|
+
|| token === "although"
|
|
493
|
+
|| token === "because";
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function isNonAssertiveReportingAt(tokens: ReadonlyArray<string>, index: number): boolean {
|
|
497
|
+
let boundary = 0;
|
|
498
|
+
for (let cursor = 0; cursor < index; cursor += 1) {
|
|
499
|
+
if (isGroundingClauseBoundary(tokens[cursor]!)) boundary = cursor + 1;
|
|
500
|
+
}
|
|
501
|
+
for (let cursor = index - 1; cursor >= boundary; cursor -= 1) {
|
|
502
|
+
if (
|
|
503
|
+
tokens[cursor] === "that"
|
|
504
|
+
&& cursor > boundary
|
|
505
|
+
&& isNonAssertiveReportingVerb(tokens[cursor - 1]!)
|
|
506
|
+
) {
|
|
507
|
+
return true;
|
|
508
|
+
}
|
|
509
|
+
if (isNonAssertiveReportingVerb(tokens[cursor]!) && index - cursor <= 5) return true;
|
|
510
|
+
}
|
|
511
|
+
return false;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function isDeniedAt(tokens: ReadonlyArray<string>, index: number): boolean {
|
|
515
|
+
let boundary = 0;
|
|
516
|
+
for (let cursor = 0; cursor < index; cursor += 1) {
|
|
517
|
+
if (isGroundingClauseBoundary(tokens[cursor]!)) boundary = cursor + 1;
|
|
518
|
+
}
|
|
519
|
+
for (let cursor = index - 1; cursor >= boundary; cursor -= 1) {
|
|
520
|
+
const token = tokens[cursor];
|
|
521
|
+
if (token === "that" && cursor > boundary && isDenialReportingVerb(tokens[cursor - 1]!)) {
|
|
522
|
+
return true;
|
|
523
|
+
}
|
|
524
|
+
if (isDenialReportingVerb(token) && index - cursor <= 5) return true;
|
|
525
|
+
}
|
|
526
|
+
return false;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
export function hasContradictoryPolarity(candidate: string, source: string): boolean {
|
|
530
|
+
const candidateLexemes = groundingLexemes(candidate);
|
|
531
|
+
const candidateTokens = candidateLexemes.map(({ token }) => token);
|
|
532
|
+
let coherentContradiction = false;
|
|
533
|
+
for (const clause of sourceSentences(source).flatMap((sentence) =>
|
|
534
|
+
sentence.split(/\s+(?:and|but|or|while|although|because)\s+/gu))) {
|
|
535
|
+
const sourceLexemes = groundingLexemes(clause);
|
|
536
|
+
const sourceTokens = sourceLexemes.map(({ token }) => token);
|
|
537
|
+
let sourceCursor = 0;
|
|
538
|
+
let allTokensFound = true;
|
|
539
|
+
let contradiction = false;
|
|
540
|
+
for (const [candidateIndex, candidateToken] of candidateTokens.entries()) {
|
|
541
|
+
if (GROUNDING_STOPWORDS[candidateToken] === true) continue;
|
|
542
|
+
const sourceIndex = sourceTokens.findIndex(
|
|
543
|
+
(sourceToken, index) =>
|
|
544
|
+
index >= sourceCursor
|
|
545
|
+
&& stemToken(sourceToken, sourceLexemes[index]?.preserveTerminalS === true)
|
|
546
|
+
=== stemToken(candidateToken, candidateLexemes[candidateIndex]?.preserveTerminalS === true),
|
|
547
|
+
);
|
|
548
|
+
if (sourceIndex === -1) {
|
|
549
|
+
allTokensFound = false;
|
|
550
|
+
break;
|
|
551
|
+
}
|
|
552
|
+
const candidateNegated = isNegatedAt(candidateTokens, candidateIndex)
|
|
553
|
+
|| isDeniedAt(candidateTokens, candidateIndex);
|
|
554
|
+
const sourceNegated = isNegatedAt(sourceTokens, sourceIndex)
|
|
555
|
+
|| isDeniedAt(sourceTokens, sourceIndex);
|
|
556
|
+
const candidateNonAssertive = isNonAssertiveReportingAt(candidateTokens, candidateIndex);
|
|
557
|
+
const sourceNonAssertive = isNonAssertiveReportingAt(sourceTokens, sourceIndex);
|
|
558
|
+
if (
|
|
559
|
+
candidateNegated !== sourceNegated
|
|
560
|
+
|| candidateNonAssertive !== sourceNonAssertive
|
|
561
|
+
) {
|
|
562
|
+
contradiction = true;
|
|
563
|
+
}
|
|
564
|
+
sourceCursor = sourceIndex + 1;
|
|
565
|
+
}
|
|
566
|
+
if (allTokensFound) {
|
|
567
|
+
if (!contradiction) return false;
|
|
568
|
+
coherentContradiction = true;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
if (coherentContradiction) return true;
|
|
572
|
+
|
|
573
|
+
const sourceLexemes = groundingLexemes(source);
|
|
574
|
+
const sourceTokens = sourceLexemes.map(({ token }) => token);
|
|
575
|
+
const sourcePositions = new Map<string, number[]>();
|
|
576
|
+
sourceLexemes.forEach(({ token, preserveTerminalS }, index) => {
|
|
577
|
+
const key = stemToken(token, preserveTerminalS);
|
|
578
|
+
const positions = sourcePositions.get(key);
|
|
579
|
+
if (positions) positions.push(index);
|
|
580
|
+
else sourcePositions.set(key, [index]);
|
|
581
|
+
});
|
|
582
|
+
for (const [candidateIndex, token] of candidateTokens.entries()) {
|
|
583
|
+
if (GROUNDING_STOPWORDS[token] === true) continue;
|
|
584
|
+
const positions = sourcePositions.get(
|
|
585
|
+
stemToken(token, candidateLexemes[candidateIndex]?.preserveTerminalS === true),
|
|
586
|
+
);
|
|
587
|
+
if (!positions || positions.length === 0) continue;
|
|
588
|
+
const sourceIndex = positions[positions.length - 1];
|
|
589
|
+
const candidateNegated = isNegatedAt(candidateTokens, candidateIndex)
|
|
590
|
+
|| isDeniedAt(candidateTokens, candidateIndex);
|
|
591
|
+
const sourceNegated = isNegatedAt(sourceTokens, sourceIndex)
|
|
592
|
+
|| isDeniedAt(sourceTokens, sourceIndex);
|
|
593
|
+
const candidateNonAssertive = isNonAssertiveReportingAt(candidateTokens, candidateIndex);
|
|
594
|
+
const sourceNonAssertive = isNonAssertiveReportingAt(sourceTokens, sourceIndex);
|
|
595
|
+
if (
|
|
596
|
+
candidateNegated !== sourceNegated
|
|
597
|
+
|| candidateNonAssertive !== sourceNonAssertive
|
|
598
|
+
) {
|
|
599
|
+
return true;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
return false;
|
|
603
|
+
}
|