@snoai/memory 0.0.0-stage → 1.0.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/LICENSE +176 -0
- package/README.md +33 -2
- package/config/b-profile-section-registry.json +118 -0
- package/config/llm/compiled/2026-05-19T230932Z/manifest.json +25 -0
- package/config/llm/compiled/2026-05-19T230932Z/registry-root.json +67 -0
- package/config/llm/compiled/2026-05-19T230932Z/resolved/mem_claw/openai_gpt_5_nano.json +5 -0
- package/config/llm/compiled/2026-05-19T230932Z/resolved/mem_claw/openrouter_auto.json +5 -0
- package/config/llm/compiled/2026-05-19T230932Z/resolved/mem_claw/sno_ai_extract.json +5 -0
- package/config/llm/compiled/2026-05-19T230932Z/source/mem_claw/openai_gpt_5_nano.mda +24 -0
- package/config/llm/compiled/2026-05-19T230932Z/source/mem_claw/openrouter_auto.mda +24 -0
- package/config/llm/compiled/2026-05-19T230932Z/source/mem_claw/sno_ai_extract.mda +24 -0
- package/config/llm/compiled/2026-07-21T001311Z/manifest.json +43 -0
- package/config/llm/compiled/2026-07-21T001311Z/registry-root.json +97 -0
- package/config/llm/compiled/2026-07-21T001311Z/resolved/mem_claw/openai_gpt_5_nano.json +5 -0
- package/config/llm/compiled/2026-07-21T001311Z/resolved/mem_claw/openrouter_auto.json +5 -0
- package/config/llm/compiled/2026-07-21T001311Z/resolved/mem_claw/sno_ai_extract.json +5 -0
- package/config/llm/compiled/2026-07-21T001311Z/resolved/mem_claw/sno_conflict_verdict.json +10 -0
- package/config/llm/compiled/2026-07-21T001311Z/resolved/mem_claw/sno_extract_chat.json +10 -0
- package/config/llm/compiled/2026-07-21T001311Z/resolved/mem_claw/sno_extract_profile.json +10 -0
- package/config/llm/compiled/2026-07-21T001311Z/source/mem_claw/openai_gpt_5_nano.mda +24 -0
- package/config/llm/compiled/2026-07-21T001311Z/source/mem_claw/openrouter_auto.mda +24 -0
- package/config/llm/compiled/2026-07-21T001311Z/source/mem_claw/sno_ai_extract.mda +24 -0
- package/config/llm/compiled/2026-07-21T001311Z/source/mem_claw/sno_conflict_verdict.mda +27 -0
- package/config/llm/compiled/2026-07-21T001311Z/source/mem_claw/sno_extract_chat.mda +27 -0
- package/config/llm/compiled/2026-07-21T001311Z/source/mem_claw/sno_extract_profile.mda +27 -0
- package/config/llm/compiled/2026-08-29T060335Z/manifest.json +43 -0
- package/config/llm/compiled/2026-08-29T060335Z/registry-root.json +97 -0
- package/config/llm/compiled/2026-08-29T060335Z/resolved/mem_claw/openai_gpt_5_nano.json +5 -0
- package/config/llm/compiled/2026-08-29T060335Z/resolved/mem_claw/openrouter_auto.json +5 -0
- package/config/llm/compiled/2026-08-29T060335Z/resolved/mem_claw/sno_ai_extract.json +5 -0
- package/config/llm/compiled/2026-08-29T060335Z/resolved/mem_claw/sno_conflict_verdict.json +10 -0
- package/config/llm/compiled/2026-08-29T060335Z/resolved/mem_claw/sno_extract_chat.json +10 -0
- package/config/llm/compiled/2026-08-29T060335Z/resolved/mem_claw/sno_extract_profile.json +10 -0
- package/config/llm/compiled/2026-08-29T060335Z/source/mem_claw/openai_gpt_5_nano.mda +24 -0
- package/config/llm/compiled/2026-08-29T060335Z/source/mem_claw/openrouter_auto.mda +24 -0
- package/config/llm/compiled/2026-08-29T060335Z/source/mem_claw/sno_ai_extract.mda +24 -0
- package/config/llm/compiled/2026-08-29T060335Z/source/mem_claw/sno_conflict_verdict.mda +27 -0
- package/config/llm/compiled/2026-08-29T060335Z/source/mem_claw/sno_extract_chat.mda +27 -0
- package/config/llm/compiled/2026-08-29T060335Z/source/mem_claw/sno_extract_profile.mda +27 -0
- package/config/llm/compiled/2026-09-04T004828Z/manifest.json +43 -0
- package/config/llm/compiled/2026-09-04T004828Z/registry-root.json +97 -0
- package/config/llm/compiled/2026-09-04T004828Z/resolved/mem_claw/openai_gpt_5_nano.json +5 -0
- package/config/llm/compiled/2026-09-04T004828Z/resolved/mem_claw/openrouter_auto.json +5 -0
- package/config/llm/compiled/2026-09-04T004828Z/resolved/mem_claw/sno_ai_extract.json +5 -0
- package/config/llm/compiled/2026-09-04T004828Z/resolved/mem_claw/sno_conflict_verdict.json +10 -0
- package/config/llm/compiled/2026-09-04T004828Z/resolved/mem_claw/sno_extract_chat.json +10 -0
- package/config/llm/compiled/2026-09-04T004828Z/resolved/mem_claw/sno_extract_profile.json +10 -0
- package/config/llm/compiled/2026-09-04T004828Z/source/mem_claw/openai_gpt_5_nano.mda +24 -0
- package/config/llm/compiled/2026-09-04T004828Z/source/mem_claw/openrouter_auto.mda +24 -0
- package/config/llm/compiled/2026-09-04T004828Z/source/mem_claw/sno_ai_extract.mda +24 -0
- package/config/llm/compiled/2026-09-04T004828Z/source/mem_claw/sno_conflict_verdict.mda +27 -0
- package/config/llm/compiled/2026-09-04T004828Z/source/mem_claw/sno_extract_chat.mda +27 -0
- package/config/llm/compiled/2026-09-04T004828Z/source/mem_claw/sno_extract_profile.mda +27 -0
- package/config/llm/current.json +4 -0
- package/config/llm/source/mem_claw/openai_gpt_5_nano.mda +24 -0
- package/config/llm/source/mem_claw/openrouter_auto.mda +24 -0
- package/config/llm/source/mem_claw/sno_ai_extract.mda +24 -0
- package/config/llm/source/mem_claw/sno_conflict_verdict.mda +27 -0
- package/config/llm/source/mem_claw/sno_extract_chat.mda +27 -0
- package/config/llm/source/mem_claw/sno_extract_profile.mda +27 -0
- package/config/llm.trust.json +37 -0
- package/dist/_types-CUKHSRkS.d.ts +103 -0
- package/dist/access-tracker-BbEvEocb.d.ts +110 -0
- package/dist/adapter-B7Jox9-6.d.ts +69 -0
- package/dist/adapter-XaRHZWZ2.js +333 -0
- package/dist/agent-llm-port-5oXgBpzJ.d.ts +53 -0
- package/dist/all-resources-BQK2ugjB.js +6379 -0
- package/dist/all-resources-Dij6l5h0.d.ts +18 -0
- package/dist/ambient-learning-text-normalizer-CxjATmMp.js +170 -0
- package/dist/ambient-learning-text-normalizer-_fH3LeuK.d.ts +10 -0
- package/dist/atomic-extraction-reply-BJ9XV_9s.js +863 -0
- package/dist/atomic-extraction-skill-CcXmuCqL.js +56 -0
- package/dist/atomic-memory-extraction-C5rmogoY.js +3605 -0
- package/dist/atomic-memory-extraction-d9EG-4ti.d.ts +327 -0
- package/dist/b-profile-section-dictionary-provider-BHkoNqgk.js +1812 -0
- package/dist/b-profile-section-dictionary-provider-BxbksLj3.d.ts +62 -0
- package/dist/best-effort-BPZSzKk0.d.ts +9 -0
- package/dist/calendar-instruction-CzqZbAPG.js +194 -0
- package/dist/capture-policy-detector-CxbHPkMX.d.ts +53 -0
- package/dist/capture-policy-detector-DaMfy9CZ.js +357 -0
- package/dist/classifier-DnbbtwTS.d.ts +272 -0
- package/dist/client.d.ts +34 -0
- package/dist/client.js +306 -0
- package/dist/coding-skin.d.ts +51 -0
- package/dist/coding-skin.js +55 -0
- package/dist/config-CL90qYva.js +2576 -0
- package/dist/connection-3IVXpuPE.d.ts +391 -0
- package/dist/connection-C9YD5sgm.js +297 -0
- package/dist/daily-log-generator-CH_KuWHs.js +469 -0
- package/dist/daily-log-generator-CsQPHl4A.d.ts +73 -0
- package/dist/daily-spend-estimator-DiwzBlo1.d.ts +8 -0
- package/dist/data-bootstrap-Bl3lthzE.d.ts +30 -0
- package/dist/data-bootstrap-P8sie9WA.js +172 -0
- package/dist/data-paths-C7sNdqvP.d.ts +22 -0
- package/dist/derived-suppression-cache-CI0durYx.d.ts +36 -0
- package/dist/diagnostic-encoder.d.ts +6 -0
- package/dist/diagnostic-encoder.js +29 -0
- package/dist/embedding-provider-client-Q_hJonK9.js +294 -0
- package/dist/embedding-provider-client-vynZMuit.d.ts +94 -0
- package/dist/entry-metadata-parser-BIVSMCIk.js +20 -0
- package/dist/error-D-wb-rZw.js +23 -0
- package/dist/error-signals-D8_3vYu4.d.ts +28 -0
- package/dist/error-signals-lMH2uAdV.js +134 -0
- package/dist/errors-CeVRxf9V.d.ts +49 -0
- package/dist/extraction-text-sanitizer-B_AhIecT.d.ts +32 -0
- package/dist/i18n-text-DbD6Qify.d.ts +13 -0
- package/dist/index-0aqS8pVF.d.ts +351 -0
- package/dist/index-BO4RU_mc.d.ts +650 -0
- package/dist/index-DL8AVj0Z.d.ts +571 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.js +1201 -0
- package/dist/intent-analyzer-B5XVrWwe.d.ts +28 -0
- package/dist/internal/config/index.d.ts +2 -0
- package/dist/internal/config/index.js +581 -0
- package/dist/internal/config/plugin-config-schema.d.ts +2 -0
- package/dist/internal/config/plugin-config-schema.js +2 -0
- package/dist/internal/config/product-mode.d.ts +2 -0
- package/dist/internal/config/product-mode.js +36 -0
- package/dist/internal/config/settings.d.ts +2 -0
- package/dist/internal/config/settings.js +265 -0
- package/dist/internal/config/skill-categories.d.ts +4 -0
- package/dist/internal/config/skill-categories.js +68 -0
- package/dist/internal/config/skin-defaults.d.ts +6 -0
- package/dist/internal/config/skin-defaults.js +6 -0
- package/dist/internal/contract/discovery.d.ts +10 -0
- package/dist/internal/contract/discovery.js +53 -0
- package/dist/internal/contract/profile.d.ts +2 -0
- package/dist/internal/contract/profile.js +44 -0
- package/dist/internal/contract/routes.d.ts +2 -0
- package/dist/internal/contract/routes.js +62 -0
- package/dist/internal/engine/bindings/memory-cli-shared.d.ts +47 -0
- package/dist/internal/engine/bindings/memory-cli-shared.js +84 -0
- package/dist/internal/engine/bindings/memory-forget-tool.d.ts +5 -0
- package/dist/internal/engine/bindings/memory-forget-tool.js +66 -0
- package/dist/internal/engine/bindings/memory-list-tool.d.ts +5 -0
- package/dist/internal/engine/bindings/memory-list-tool.js +57 -0
- package/dist/internal/engine/bindings/memory-recall-tool.d.ts +10 -0
- package/dist/internal/engine/bindings/memory-recall-tool.js +283 -0
- package/dist/internal/engine/bindings/memory-reflection-resolve-tool.d.ts +5 -0
- package/dist/internal/engine/bindings/memory-reflection-resolve-tool.js +150 -0
- package/dist/internal/engine/bindings/memory-stats-tool.d.ts +5 -0
- package/dist/internal/engine/bindings/memory-stats-tool.js +43 -0
- package/dist/internal/engine/bindings/memory-store-tool.d.ts +5 -0
- package/dist/internal/engine/bindings/memory-store-tool.js +165 -0
- package/dist/internal/engine/bindings/memory-tool-access.d.ts +16 -0
- package/dist/internal/engine/bindings/memory-tool-access.js +46 -0
- package/dist/internal/engine/bindings/memory-tool-formatting.d.ts +62 -0
- package/dist/internal/engine/bindings/memory-tool-formatting.js +106 -0
- package/dist/internal/engine/bindings/memory-tool-results.d.ts +8 -0
- package/dist/internal/engine/bindings/memory-tool-results.js +41 -0
- package/dist/internal/engine/bindings/memory-tool-schemas.d.ts +109 -0
- package/dist/internal/engine/bindings/memory-tool-schemas.js +75 -0
- package/dist/internal/engine/bindings/memory-update-tool.d.ts +5 -0
- package/dist/internal/engine/bindings/memory-update-tool.js +127 -0
- package/dist/internal/engine/bindings/sno-station-mem-ambient-learning-hook.d.ts +14 -0
- package/dist/internal/engine/bindings/sno-station-mem-ambient-learning-hook.js +248 -0
- package/dist/internal/engine/bindings/sno-station-mem-auto-recall-hook.d.ts +12 -0
- package/dist/internal/engine/bindings/sno-station-mem-auto-recall-hook.js +324 -0
- package/dist/internal/engine/bindings/sno-station-mem-hook-types.d.ts +56 -0
- package/dist/internal/engine/bindings/sno-station-mem-hook-types.js +1 -0
- package/dist/internal/engine/bindings/sno-station-mem-insight-distill-factory.d.ts +14 -0
- package/dist/internal/engine/bindings/sno-station-mem-insight-distill-factory.js +119 -0
- package/dist/internal/engine/bindings/sno-station-mem-message-transcript.d.ts +52 -0
- package/dist/internal/engine/bindings/sno-station-mem-message-transcript.js +145 -0
- package/dist/internal/engine/bindings/sno-station-mem-reset-hook.d.ts +10 -0
- package/dist/internal/engine/bindings/sno-station-mem-reset-hook.js +9 -0
- package/dist/internal/engine/bindings/sno-station-mem-runtime-mode.d.ts +36 -0
- package/dist/internal/engine/bindings/sno-station-mem-runtime-mode.js +104 -0
- package/dist/internal/engine/bindings/sno-station-mem-session-state.d.ts +10 -0
- package/dist/internal/engine/bindings/sno-station-mem-session-state.js +27 -0
- package/dist/internal/engine/eval/trace.d.ts +2 -0
- package/dist/internal/engine/eval/trace.js +151 -0
- package/dist/internal/engine/extraction/ambient-learning-text-normalizer.d.ts +2 -0
- package/dist/internal/engine/extraction/ambient-learning-text-normalizer.js +2 -0
- package/dist/internal/engine/extraction/atomic-memory-extraction.d.ts +2 -0
- package/dist/internal/engine/extraction/atomic-memory-extraction.js +2 -0
- package/dist/internal/engine/extraction/b-profile-section-dictionary-provider.d.ts +2 -0
- package/dist/internal/engine/extraction/b-profile-section-dictionary-provider.js +2 -0
- package/dist/internal/engine/extraction/b-profile-section-rekey.d.ts +49 -0
- package/dist/internal/engine/extraction/b-profile-section-rekey.js +730 -0
- package/dist/internal/engine/extraction/capture-policy-detector.d.ts +2 -0
- package/dist/internal/engine/extraction/capture-policy-detector.js +2 -0
- package/dist/internal/engine/extraction/embedding-provider-client.d.ts +2 -0
- package/dist/internal/engine/extraction/embedding-provider-client.js +2 -0
- package/dist/internal/engine/extraction/extraction-text-sanitizer.d.ts +2 -0
- package/dist/internal/engine/extraction/extraction-text-sanitizer.js +114 -0
- package/dist/internal/engine/extraction/memory-metadata-codec.d.ts +3 -0
- package/dist/internal/engine/extraction/memory-metadata-codec.js +2 -0
- package/dist/internal/engine/extraction/memory-temporality-classifier.d.ts +2 -0
- package/dist/internal/engine/extraction/memory-temporality-classifier.js +2 -0
- package/dist/internal/engine/i18n/all-resources.d.ts +2 -0
- package/dist/internal/engine/i18n/all-resources.js +2 -0
- package/dist/internal/engine/i18n/locales.d.ts +2 -0
- package/dist/internal/engine/i18n/locales.js +19 -0
- package/dist/internal/engine/i18n/res/_types.d.ts +2 -0
- package/dist/internal/engine/i18n/res/_types.js +11 -0
- package/dist/internal/engine/observability/adapter.d.ts +2 -0
- package/dist/internal/engine/observability/adapter.js +2 -0
- package/dist/internal/engine/observability/best-effort.d.ts +2 -0
- package/dist/internal/engine/observability/best-effort.js +41 -0
- package/dist/internal/engine/observability/early-diagnostics.js +2 -0
- package/dist/internal/engine/observability/memory-snapshot.d.ts +2 -0
- package/dist/internal/engine/observability/memory-snapshot.js +44 -0
- package/dist/internal/engine/observability/observable-embedder.d.ts +2 -0
- package/dist/internal/engine/observability/observable-embedder.js +43 -0
- package/dist/internal/engine/observability/observable-llm-client.d.ts +2 -0
- package/dist/internal/engine/observability/observable-llm-client.js +98 -0
- package/dist/internal/engine/observability/observable-memory-store.d.ts +2 -0
- package/dist/internal/engine/observability/observable-memory-store.js +701 -0
- package/dist/internal/engine/observability/observable-retriever.d.ts +2 -0
- package/dist/internal/engine/observability/observable-retriever.js +95 -0
- package/dist/internal/engine/observability/runtime-diagnostics.d.ts +13 -0
- package/dist/internal/engine/observability/runtime-diagnostics.js +96 -0
- package/dist/internal/engine/observability/session-registry.d.ts +2 -0
- package/dist/internal/engine/observability/session-registry.js +58 -0
- package/dist/internal/engine/observability/version-metadata.d.ts +7 -0
- package/dist/internal/engine/observability/version-metadata.js +59 -0
- package/dist/internal/engine/operations/daily-spend-estimator.d.ts +2 -0
- package/dist/internal/engine/operations/daily-spend-estimator.js +97 -0
- package/dist/internal/engine/operations/learning-file-maintenance.d.ts +2 -0
- package/dist/internal/engine/operations/learning-file-maintenance.js +255 -0
- package/dist/internal/engine/operations/memory-tier-promoter.d.ts +2 -0
- package/dist/internal/engine/operations/memory-tier-promoter.js +95 -0
- package/dist/internal/engine/operations/runtime-audit-log.d.ts +3 -0
- package/dist/internal/engine/operations/runtime-audit-log.js +3 -0
- package/dist/internal/engine/provider/canonical-memory-corpus.d.ts +38 -0
- package/dist/internal/engine/provider/canonical-memory-corpus.js +253 -0
- package/dist/internal/engine/provider/provider-registration.d.ts +39 -0
- package/dist/internal/engine/provider/provider-registration.js +2 -0
- package/dist/internal/engine/provider/provider-row-renderer.d.ts +7 -0
- package/dist/internal/engine/provider/provider-row-renderer.js +53 -0
- package/dist/internal/engine/provider/provider-types.d.ts +2 -0
- package/dist/internal/engine/provider/provider-types.js +1 -0
- package/dist/internal/engine/reflection/daily-log-generator.d.ts +2 -0
- package/dist/internal/engine/reflection/daily-log-generator.js +2 -0
- package/dist/internal/engine/reflection/reflection-command-hooks.d.ts +2 -0
- package/dist/internal/engine/reflection/reflection-command-hooks.js +2 -0
- package/dist/internal/engine/reflection/reflection-deps.d.ts +2 -0
- package/dist/internal/engine/reflection/reflection-deps.js +1 -0
- package/dist/internal/engine/reflection/reflection-embedded-generator.d.ts +2 -0
- package/dist/internal/engine/reflection/reflection-embedded-generator.js +2 -0
- package/dist/internal/engine/reflection/reflection-injection-hooks.d.ts +2 -0
- package/dist/internal/engine/reflection/reflection-injection-hooks.js +219 -0
- package/dist/internal/engine/reflection/reflection-lifecycle-hooks.d.ts +2 -0
- package/dist/internal/engine/reflection/reflection-lifecycle-hooks.js +63 -0
- package/dist/internal/engine/reflection/strategy-hook-runner.d.ts +4 -0
- package/dist/internal/engine/reflection/strategy-hook-runner.js +3 -0
- package/dist/internal/engine/rem/classifier.d.ts +2 -0
- package/dist/internal/engine/rem/classifier.js +180 -0
- package/dist/internal/engine/rem/index.d.ts +4 -0
- package/dist/internal/engine/rem/index.js +2551 -0
- package/dist/internal/engine/rem/types.d.ts +2 -0
- package/dist/internal/engine/rem/types.js +40 -0
- package/dist/internal/engine/retrieval/access-tracker.d.ts +2 -0
- package/dist/internal/engine/retrieval/access-tracker.js +314 -0
- package/dist/internal/engine/retrieval/intent-analyzer.d.ts +2 -0
- package/dist/internal/engine/retrieval/intent-analyzer.js +27 -0
- package/dist/internal/engine/retrieval/retrieval-gate.d.ts +2 -0
- package/dist/internal/engine/retrieval/retrieval-gate.js +47 -0
- package/dist/internal/engine/retrieval/retriever.d.ts +2 -0
- package/dist/internal/engine/retrieval/retriever.js +2 -0
- package/dist/internal/engine/security/memory-scope-policy.d.ts +2 -0
- package/dist/internal/engine/security/memory-scope-policy.js +2 -0
- package/dist/internal/engine/security/redact.d.ts +2 -0
- package/dist/internal/engine/security/redact.js +34 -0
- package/dist/internal/engine/security/scopes.d.ts +3 -0
- package/dist/internal/engine/security/scopes.js +3 -0
- package/dist/internal/engine/shared/errors.d.ts +2 -0
- package/dist/internal/engine/shared/errors.js +66 -0
- package/dist/internal/engine/shared/i18n-text.d.ts +2 -0
- package/dist/internal/engine/shared/i18n-text.js +58 -0
- package/dist/internal/engine/shared/iso-date-time.d.ts +16 -0
- package/dist/internal/engine/shared/iso-date-time.js +40 -0
- package/dist/internal/engine/shared/lru.d.ts +2 -0
- package/dist/internal/engine/shared/lru.js +30 -0
- package/dist/internal/engine/shared/memory-kind-policy.d.ts +2 -0
- package/dist/internal/engine/shared/memory-kind-policy.js +64 -0
- package/dist/internal/engine/shared/paths.d.ts +3 -0
- package/dist/internal/engine/shared/paths.js +2 -0
- package/dist/internal/engine/shared/types.d.ts +3 -0
- package/dist/internal/engine/shared/types.js +25 -0
- package/dist/internal/engine/shared/utils.d.ts +2 -0
- package/dist/internal/engine/shared/utils.js +175 -0
- package/dist/internal/engine/telemetry/memory-telemetry-api.d.ts +134 -0
- package/dist/internal/engine/telemetry/memory-telemetry-api.js +730 -0
- package/dist/internal/engine/telemetry/memory-telemetry-observability.d.ts +24 -0
- package/dist/internal/engine/telemetry/memory-telemetry-observability.js +133 -0
- package/dist/internal/engine/telemetry/memory-telemetry-outbox.d.ts +2 -0
- package/dist/internal/engine/telemetry/memory-telemetry-outbox.js +443 -0
- package/dist/internal/engine/telemetry/memory-telemetry-types.d.ts +2 -0
- package/dist/internal/engine/telemetry/memory-telemetry-types.js +21 -0
- package/dist/internal/engine/telemetry/observe-ledger.d.ts +30 -0
- package/dist/internal/engine/telemetry/observe-ledger.js +111 -0
- package/dist/internal/model/agent-llm-port.d.ts +2 -0
- package/dist/internal/model/agent-llm-port.js +1 -0
- package/dist/internal/model/llm-client.d.ts +3 -0
- package/dist/internal/model/llm-client.js +3 -0
- package/dist/internal/model/llm-failure.d.ts +26 -0
- package/dist/internal/model/llm-failure.js +63 -0
- package/dist/internal/model/llm-mode-routing.d.ts +22 -0
- package/dist/internal/model/llm-mode-routing.js +37 -0
- package/dist/internal/store/atomic-memory-cutover-sql.d.ts +13 -0
- package/dist/internal/store/atomic-memory-cutover-sql.js +237 -0
- package/dist/internal/store/connection.d.ts +2 -0
- package/dist/internal/store/connection.js +2 -0
- package/dist/internal/store/data-bootstrap.d.ts +2 -0
- package/dist/internal/store/data-bootstrap.js +2 -0
- package/dist/internal/store/data-paths.d.ts +2 -0
- package/dist/internal/store/data-paths.js +65 -0
- package/dist/internal/store/maintenance.d.ts +75 -0
- package/dist/internal/store/maintenance.js +1401 -0
- package/dist/internal/store/memory-kinds-cutover-migrator.d.ts +28 -0
- package/dist/internal/store/memory-kinds-cutover-migrator.js +415 -0
- package/dist/internal/store/migrations.d.ts +27 -0
- package/dist/internal/store/migrations.js +201 -0
- package/dist/internal/store/sqlite-runtime.d.ts +2 -0
- package/dist/internal/store/sqlite-runtime.js +109 -0
- package/dist/internal/store/store.d.ts +3 -0
- package/dist/internal/store/store.js +2 -0
- package/dist/learning-file-maintenance-9b-Ut6Kv.d.ts +30 -0
- package/dist/llm-client-BSYUAcUb.js +1374 -0
- package/dist/llm-client-DOTSGzhe.d.ts +51 -0
- package/dist/locales-JxGmkG6t.d.ts +7 -0
- package/dist/log-site-catalog.generated-BMKWj-Nx.js +2321 -0
- package/dist/log-site-catalog.json +1 -0
- package/dist/lru-DyoaTyIs.d.ts +14 -0
- package/dist/memdump.d.ts +52 -0
- package/dist/memdump.js +163 -0
- package/dist/memory-entry-projector-DHo8jH10.js +1015 -0
- package/dist/memory-kind-policy-BiuRjSJc.d.ts +23 -0
- package/dist/memory-metadata-codec-DL1sbJiN.js +577 -0
- package/dist/memory-metadata-codec-DUvsYe_X.d.ts +68 -0
- package/dist/memory-runtime-DqUS4cWi.js +19459 -0
- package/dist/memory-scope-policy-1gg5QlWZ.d.ts +67 -0
- package/dist/memory-scope-policy-DICSCURA.js +283 -0
- package/dist/memory-snapshot-CqY1BUUA.d.ts +16 -0
- package/dist/memory-source-order-YMRoeDLd.js +134 -0
- package/dist/memory-store-base-CQ_bHlYA.d.ts +1094 -0
- package/dist/memory-store-shared-DqpWJXZZ.js +158 -0
- package/dist/memory-store-write-validation-B_hDG2zf.js +243 -0
- package/dist/memory-telemetry-incidents-BWA9kcZx.js +8 -0
- package/dist/memory-telemetry-metadata-CA7W8tK6.js +77 -0
- package/dist/memory-telemetry-outbox-ddTdImt7.d.ts +74 -0
- package/dist/memory-telemetry-receipts-MAJecvXQ.d.ts +34 -0
- package/dist/memory-telemetry-receipts-YsxbwOAf.js +91 -0
- package/dist/memory-telemetry-types-CufVmrCs.d.ts +14 -0
- package/dist/memory-temporality-classifier-BUjXG5o7.js +184 -0
- package/dist/memory-temporality-classifier-Brht5jyK.d.ts +43 -0
- package/dist/memory-tier-promoter-CqGxCkue.d.ts +43 -0
- package/dist/memory-tool-dependencies-CatGzI9R.d.ts +14 -0
- package/dist/memory-tool-dependencies-DjUoelnm.js +19 -0
- package/dist/model-call-table-CspopkBg.js +563 -0
- package/dist/model-reply-text-CKopStP2.js +334 -0
- package/dist/observable-embedder-CNNe9gkg.d.ts +17 -0
- package/dist/observable-llm-client-CRuKlefQ.d.ts +21 -0
- package/dist/observable-memory-store-CnGDpOY5.d.ts +73 -0
- package/dist/observable-retriever-Cooc62Qw.d.ts +23 -0
- package/dist/operation-cancellation-CTKWwNHk.js +81 -0
- package/dist/paths-qVF-5uBq.d.ts +1 -0
- package/dist/plugin-config-schema-C0UUbOmG.d.ts +413 -0
- package/dist/plugin-config-schema-YJLyIIcJ.js +361 -0
- package/dist/profile-TWPJ_myr.d.ts +13 -0
- package/dist/profile-section-writer-BhGKPBjw.js +2149 -0
- package/dist/provider-registration-CF1tg8Xy.js +721 -0
- package/dist/provider-runtime-types-DFhtdA6d.d.ts +134 -0
- package/dist/provider-types-CZGm6v88.d.ts +23 -0
- package/dist/redact-BTIZcHQL.d.ts +5 -0
- package/dist/reflection-command-hooks-ClUl-iv6.js +644 -0
- package/dist/reflection-command-hooks-G1-dI2Av.d.ts +32 -0
- package/dist/reflection-deps-Ccm2Jf5W.d.ts +19 -0
- package/dist/reflection-embedded-generator-BRvqV5N-.js +130 -0
- package/dist/reflection-embedded-generator-kfQfKEYV.d.ts +14 -0
- package/dist/reflection-injection-hooks-CS_uhjoD.d.ts +43 -0
- package/dist/reflection-lifecycle-hooks-CRSpUdLi.d.ts +27 -0
- package/dist/relation-dictionary-Cev1kyLe.js +4248 -0
- package/dist/release-download.d.ts +8 -0
- package/dist/release-download.js +32 -0
- package/dist/relevant-memories-context-m8nuFZcM.js +23 -0
- package/dist/rem-batch-executor-Dg2HgROM.js +2 -0
- package/dist/rem-batch-executor-DuC4nYyf.js +31640 -0
- package/dist/rem-consumer-retrieval-CR0dtcHR.js +246 -0
- package/dist/rem-trigger-Hn6od8IV.js +730 -0
- package/dist/resolver-Dy-hnjCR.js +103 -0
- package/dist/results-C3ZLroMb.js +140 -0
- package/dist/retrieval-gate-Bx2Zg7jD.d.ts +31 -0
- package/dist/retriever-Dxss5fRv.d.ts +469 -0
- package/dist/retriever-ZoLvPRHq.js +1757 -0
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/routes-DLHT__Ay.js +60 -0
- package/dist/runtime-audit-log-BCeujlEp.js +430 -0
- package/dist/runtime-audit-log-zpQiR9HT.d.ts +149 -0
- package/dist/scopes-CSOn6zdd.js +71 -0
- package/dist/scopes-CtrY-YQ3.d.ts +23 -0
- package/dist/server-CSvxchqg.js +1412 -0
- package/dist/session-registry-DBoE7AvZ.d.ts +14 -0
- package/dist/sidecar/main.d.ts +1 -0
- package/dist/sidecar/main.js +56 -0
- package/dist/signed-registry-constants-Bv0fgZ8Q.d.ts +12 -0
- package/dist/signed-registry-constants-yq3DlG3B.js +82 -0
- package/dist/sno-station-mem-runtime-dependencies-CoWqUMbK.js +30 -0
- package/dist/sno-station-mem-runtime-dependencies-DHESIuPn.d.ts +31 -0
- package/dist/sqlite-runtime-L_ywirTm.d.ts +58 -0
- package/dist/store-C8sUTssE.d.ts +27 -0
- package/dist/store-nPql26YM.js +5830 -0
- package/dist/strategy-hook-runner-Bxy851Xx.d.ts +16 -0
- package/dist/strategy-hook-runner-Djify5Rw.js +110 -0
- package/dist/token-counter-BD1f48Km.js +73 -0
- package/dist/trace-C1JxMfs-.d.ts +86 -0
- package/dist/types-CWdhXLxr.d.ts +477 -0
- package/dist/types-pVomjzqR.d.ts +132 -0
- package/dist/unplaced-candidate-migration-CbQHzcEM.js +940 -0
- package/dist/utils-Ctb9aevJ.d.ts +34 -0
- package/drizzle/0000_initial.sql +10 -0
- package/drizzle/0001_virtual_tables.sql +34 -0
- package/drizzle/0002_add_indexes.sql +11 -0
- package/drizzle/0003_content_hash_lookup_index.sql +2 -0
- package/drizzle/0004_chunk_swap.sql +60 -0
- package/drizzle/0005_drop_legacy_vec_fts.sql +10 -0
- package/drizzle/0006_fts_simple.sql +45 -0
- package/drizzle/0007_restore_simple_fts.sql +40 -0
- package/drizzle/0008_widen_memory_hash_unique_index.sql +4 -0
- package/drizzle/0009_memory_telemetry.sql +109 -0
- package/drizzle/0010_provider_mappings.sql +27 -0
- package/drizzle/0011_db_optimization.sql +82 -0
- package/drizzle/0012_b_profile_lanes.sql +9 -0
- package/drizzle/0013_extraction_timestamps.sql +6 -0
- package/drizzle/0014_extraction_timestamp_source.sql +3 -0
- package/drizzle/0015_task_lifecycle_state.sql +101 -0
- package/drizzle/0016_task_lifecycle_legacy_migration.sql +144 -0
- package/drizzle/0017_unplaced_candidates.sql +15 -0
- package/drizzle/0018_rem_batch_chassis.sql +71 -0
- package/drizzle/0019_profile_recovery_entries.sql +17 -0
- package/drizzle/0020_rem_scan_retry_progress.down.sql +14 -0
- package/drizzle/0020_rem_scan_retry_progress.sql +24 -0
- package/drizzle/0021_rem_two_facet_storage.down.sql +14 -0
- package/drizzle/0021_rem_two_facet_storage.sql +42 -0
- package/drizzle/0022_rem_facet_chunk_versions.down.sql +4 -0
- package/drizzle/0022_rem_facet_chunk_versions.sql +4 -0
- package/drizzle/0023_rem_defect_ledger.sql +40 -0
- package/drizzle/0024_rem_unbuilt_foundations.down.sql +13 -0
- package/drizzle/0024_rem_unbuilt_foundations.sql +65 -0
- package/drizzle/0025_rem_journal_operation_constraint.sql +28 -0
- package/drizzle/0026_rem_journal_detail.sql +1 -0
- package/drizzle/0027_legacy_nodix_namespace.sql +3 -0
- package/drizzle/0028_memory_timezone.sql +23 -0
- package/drizzle/0029_rem_write_hash_symmetry.sql +17 -0
- package/drizzle/0030_atomic_memory_additive.sql +105 -0
- package/drizzle/0031_atomic_extraction_ledger.sql +23 -0
- package/drizzle/0032_atomic_memory_entities.sql +12 -0
- package/drizzle/0033_todo_own_store.sql +99 -0
- package/drizzle/meta/0000_snapshot.json +87 -0
- package/drizzle/meta/_journal.json +244 -0
- package/generated/rem-operations.json +1 -0
- package/package.json +126 -4
- package/scripts/download-simple-tokenizer.mjs +254 -0
- package/settings.default.json +243 -0
- package/skills/extract-atomic-memory/SKILL.md +298 -0
- package/skills/extract-atomic-memory/references/account-for-turns.md +9 -0
- package/skills/extract-atomic-memory/references/calendar-meaning.md +64 -0
- package/skills/extract-atomic-memory/references/capture.md +120 -0
- package/skills/extract-atomic-memory/references/enrichment.md +92 -0
- package/skills/extract-atomic-memory/references/missing-durable-half.md +6 -0
- package/skills/extract-atomic-memory/references/progress-classification.md +21 -0
- package/skills/extract-atomic-memory/references/resolve-subject.md +19 -0
- package/skills/extract-atomic-memory/references/surrounding-context.md +10 -0
- package/skills/extract-atomic-memory/references/user-subject-guard.md +29 -0
- package/skills/judge-group-closure/SKILL.md +25 -0
- package/skills/judge-rem-memory-updates/SKILL.md +56 -0
- package/skills/judge-rem-memory-updates/agents/openai.yaml +4 -0
- package/skills/judge-retired-position/SKILL.md +25 -0
- package/skills/judge-task-lifecycle/SKILL.md +45 -0
- package/skills/key-state-attribute/SKILL.md +16 -0
- package/skills/resolve-entity-identity/SKILL.md +24 -0
- package/skills/resolve-relative-time/SKILL.md +22 -0
- package/sqlite-extensions/LICENSE-simple-tokenizer +28 -0
- package/sqlite-extensions/LICENSE-sqlite-vec +21 -0
- package/sqlite-extensions/linux-arm64/vec0.so +0 -0
- package/sqlite-extensions/linux-x64/vec0.so +0 -0
|
@@ -0,0 +1,863 @@
|
|
|
1
|
+
import { n as readModelReplyJson, t as modelReplyJsonCandidates } from "./model-reply-text-CKopStP2.js";
|
|
2
|
+
import { n as calendarInstructionSchema, t as calculateCalendarTime } from "./calendar-instruction-CzqZbAPG.js";
|
|
3
|
+
import { n as state_vocabulary_default, r as attribute_dictionary_default, t as relations } from "./relation-dictionary-Cev1kyLe.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { createLogger } from "@snoai/utils/logger";
|
|
6
|
+
//#region src/engine/extraction/atomic-progress-boundary.ts
|
|
7
|
+
const log$1 = createLogger("sno-station-mem:atomic-progress-boundary");
|
|
8
|
+
const classificationSchema = z.object({ decisions: z.array(z.object({
|
|
9
|
+
turn_index: z.number().int().nonnegative(),
|
|
10
|
+
progress_only: z.boolean()
|
|
11
|
+
})) });
|
|
12
|
+
function parseProgressTurns(value, turns, { salvage = false } = {}) {
|
|
13
|
+
const expected = new Set(turns.flatMap((turn, index) => turn.role === "user" ? [index] : []));
|
|
14
|
+
const parsed = classificationSchema.safeParse(value);
|
|
15
|
+
if (!parsed.success) return null;
|
|
16
|
+
const indexes = new Set(parsed.data.decisions.map((decision) => decision.turn_index));
|
|
17
|
+
const invalid = indexes.size !== expected.size || parsed.data.decisions.length !== expected.size || [...indexes].some((index) => !expected.has(index));
|
|
18
|
+
if (invalid && !salvage) return null;
|
|
19
|
+
if (invalid) log$1.warn("atomic capture salvaged progress decisions", {
|
|
20
|
+
gate: 3,
|
|
21
|
+
ignored_decisions: parsed.data.decisions.filter((decision) => !expected.has(decision.turn_index)).length,
|
|
22
|
+
missing_turns: [...expected].filter((index) => !indexes.has(index)).length,
|
|
23
|
+
duplicate_decisions: parsed.data.decisions.length - indexes.size
|
|
24
|
+
}, {
|
|
25
|
+
event_name: "memory.atomic_progress_boundary.diagnostic",
|
|
26
|
+
file: "packages/memory/src/engine/extraction/atomic-progress-boundary.ts",
|
|
27
|
+
function: "parseProgressTurns",
|
|
28
|
+
site_id: "extraction.atomic-progress-boundary.salvage_decisions"
|
|
29
|
+
});
|
|
30
|
+
const notProgress = new Set(parsed.data.decisions.filter((decision) => !decision.progress_only).map((decision) => decision.turn_index));
|
|
31
|
+
return new Set(parsed.data.decisions.filter((decision) => decision.progress_only && expected.has(decision.turn_index) && !notProgress.has(decision.turn_index)).map((decision) => decision.turn_index));
|
|
32
|
+
}
|
|
33
|
+
function excludeProgressRecords(records, excluded) {
|
|
34
|
+
return records.filter((record) => {
|
|
35
|
+
const index = (record.sourceSpan ?? record.unresolvedSourceSpan)?.turnIndex;
|
|
36
|
+
return index === void 0 || !excluded.has(index);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region config/atomic-extraction-response.schema.json
|
|
41
|
+
var atomic_extraction_response_schema_default = {
|
|
42
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
43
|
+
$id: "https://www.sno.ai/schemas/mem-claw/atomic-extraction-response-v1.json",
|
|
44
|
+
title: "Atomic extraction response v1",
|
|
45
|
+
type: "object",
|
|
46
|
+
additionalProperties: false,
|
|
47
|
+
required: ["claims_found", "records"],
|
|
48
|
+
properties: {
|
|
49
|
+
"claims_found": {
|
|
50
|
+
"type": "array",
|
|
51
|
+
"items": { "type": "string" },
|
|
52
|
+
"description": "One short string for each claim the turns this call owns state, in the order they appear; empty when they state none. Written before records so the list is read before the array is opened."
|
|
53
|
+
},
|
|
54
|
+
"records": {
|
|
55
|
+
"type": "array",
|
|
56
|
+
"items": {
|
|
57
|
+
"type": "object",
|
|
58
|
+
"additionalProperties": false,
|
|
59
|
+
"required": [
|
|
60
|
+
"kind",
|
|
61
|
+
"claim_text",
|
|
62
|
+
"subject",
|
|
63
|
+
"subject_kind",
|
|
64
|
+
"attribute",
|
|
65
|
+
"value",
|
|
66
|
+
"temporal_phrase",
|
|
67
|
+
"ends_current",
|
|
68
|
+
"ended_at_phrase",
|
|
69
|
+
"importance",
|
|
70
|
+
"changes_current_state",
|
|
71
|
+
"todo",
|
|
72
|
+
"close_reason",
|
|
73
|
+
"source_span",
|
|
74
|
+
"relations",
|
|
75
|
+
"single_claim",
|
|
76
|
+
"time",
|
|
77
|
+
"ended_time"
|
|
78
|
+
],
|
|
79
|
+
"properties": {
|
|
80
|
+
"kind": { "enum": ["occurrence", "standing"] },
|
|
81
|
+
"claim_text": {
|
|
82
|
+
"type": "string",
|
|
83
|
+
"minLength": 1
|
|
84
|
+
},
|
|
85
|
+
"subject": {
|
|
86
|
+
"type": "string",
|
|
87
|
+
"minLength": 1
|
|
88
|
+
},
|
|
89
|
+
"subject_kind": { "enum": [
|
|
90
|
+
"user",
|
|
91
|
+
"agent",
|
|
92
|
+
"named_entity",
|
|
93
|
+
"unresolved"
|
|
94
|
+
] },
|
|
95
|
+
"attribute": { "anyOf": [{ "enum": [
|
|
96
|
+
"ability.awards",
|
|
97
|
+
"ability.certifications",
|
|
98
|
+
"ability.creative",
|
|
99
|
+
"ability.practical",
|
|
100
|
+
"ability.professional",
|
|
101
|
+
"ability.technical",
|
|
102
|
+
"contact.address",
|
|
103
|
+
"contact.email",
|
|
104
|
+
"contact.messaging",
|
|
105
|
+
"contact.phone",
|
|
106
|
+
"contact.social",
|
|
107
|
+
"contact.websites",
|
|
108
|
+
"entity.organization",
|
|
109
|
+
"entity.person",
|
|
110
|
+
"entity.place",
|
|
111
|
+
"finance.budget_style",
|
|
112
|
+
"finance.investing",
|
|
113
|
+
"finance.obligations",
|
|
114
|
+
"goal.career",
|
|
115
|
+
"goal.family",
|
|
116
|
+
"goal.financial",
|
|
117
|
+
"goal.health",
|
|
118
|
+
"goal.learning",
|
|
119
|
+
"goal.personal",
|
|
120
|
+
"goal.project",
|
|
121
|
+
"goal.travel",
|
|
122
|
+
"health.accessibility",
|
|
123
|
+
"health.allergies",
|
|
124
|
+
"health.conditions",
|
|
125
|
+
"health.fitness",
|
|
126
|
+
"health.medications",
|
|
127
|
+
"health.mental",
|
|
128
|
+
"health.sleep",
|
|
129
|
+
"identity.aka",
|
|
130
|
+
"identity.birth_date",
|
|
131
|
+
"identity.birth_place",
|
|
132
|
+
"identity.career_history",
|
|
133
|
+
"identity.education",
|
|
134
|
+
"identity.employer",
|
|
135
|
+
"identity.employment_status",
|
|
136
|
+
"identity.gender",
|
|
137
|
+
"identity.hometown",
|
|
138
|
+
"identity.industry",
|
|
139
|
+
"identity.institutional_affiliation",
|
|
140
|
+
"identity.languages",
|
|
141
|
+
"identity.location",
|
|
142
|
+
"identity.marital_status",
|
|
143
|
+
"identity.name",
|
|
144
|
+
"identity.nationality",
|
|
145
|
+
"identity.occupation",
|
|
146
|
+
"identity.project_role",
|
|
147
|
+
"identity.pronouns",
|
|
148
|
+
"identity.team_membership",
|
|
149
|
+
"identity.timezone",
|
|
150
|
+
"identity.work_location",
|
|
151
|
+
"interest.arts_culture",
|
|
152
|
+
"interest.business",
|
|
153
|
+
"interest.education",
|
|
154
|
+
"interest.health_wellness",
|
|
155
|
+
"interest.history",
|
|
156
|
+
"interest.hobbies",
|
|
157
|
+
"interest.local",
|
|
158
|
+
"interest.nature",
|
|
159
|
+
"interest.philosophy",
|
|
160
|
+
"interest.politics",
|
|
161
|
+
"interest.science",
|
|
162
|
+
"interest.sports",
|
|
163
|
+
"interest.technology",
|
|
164
|
+
"personality.self_view",
|
|
165
|
+
"personality.social_energy",
|
|
166
|
+
"personality.temperament",
|
|
167
|
+
"personality.type",
|
|
168
|
+
"possession.collections",
|
|
169
|
+
"possession.devices",
|
|
170
|
+
"possession.home",
|
|
171
|
+
"possession.subscriptions",
|
|
172
|
+
"possession.vehicle",
|
|
173
|
+
"preference.accommodation",
|
|
174
|
+
"preference.art",
|
|
175
|
+
"preference.audio",
|
|
176
|
+
"preference.cooking",
|
|
177
|
+
"preference.devices",
|
|
178
|
+
"preference.diet",
|
|
179
|
+
"preference.dining",
|
|
180
|
+
"preference.drinks",
|
|
181
|
+
"preference.entertainment_going_out",
|
|
182
|
+
"preference.exercise",
|
|
183
|
+
"preference.fashion",
|
|
184
|
+
"preference.food",
|
|
185
|
+
"preference.games",
|
|
186
|
+
"preference.home",
|
|
187
|
+
"preference.media_sources",
|
|
188
|
+
"preference.music",
|
|
189
|
+
"preference.programming",
|
|
190
|
+
"preference.reading",
|
|
191
|
+
"preference.screen",
|
|
192
|
+
"preference.shopping",
|
|
193
|
+
"preference.social_media",
|
|
194
|
+
"preference.tools",
|
|
195
|
+
"preference.transport",
|
|
196
|
+
"preference.travel_destinations",
|
|
197
|
+
"preference.travel_style",
|
|
198
|
+
"preference.travel",
|
|
199
|
+
"preference.weather",
|
|
200
|
+
"relationship.children",
|
|
201
|
+
"relationship.colleagues",
|
|
202
|
+
"relationship.friends",
|
|
203
|
+
"relationship.parents",
|
|
204
|
+
"relationship.partner",
|
|
205
|
+
"relationship.pets",
|
|
206
|
+
"relationship.relatives",
|
|
207
|
+
"relationship.siblings",
|
|
208
|
+
"routine.commute",
|
|
209
|
+
"routine.daily",
|
|
210
|
+
"routine.habits",
|
|
211
|
+
"routine.weekly",
|
|
212
|
+
"trait.collaboration",
|
|
213
|
+
"trait.communication",
|
|
214
|
+
"trait.constraint",
|
|
215
|
+
"trait.environment",
|
|
216
|
+
"trait.planning",
|
|
217
|
+
"trait.practice",
|
|
218
|
+
"trait.privacy",
|
|
219
|
+
"trait.risk",
|
|
220
|
+
"trait.schedule",
|
|
221
|
+
"trait.tooling_habits",
|
|
222
|
+
"value.causes",
|
|
223
|
+
"value.ethics",
|
|
224
|
+
"value.political",
|
|
225
|
+
"value.priorities",
|
|
226
|
+
"value.spiritual",
|
|
227
|
+
"project.budget",
|
|
228
|
+
"project.timeline",
|
|
229
|
+
"project.objective",
|
|
230
|
+
"project.deliverable",
|
|
231
|
+
"project.lead",
|
|
232
|
+
"project.stakeholder",
|
|
233
|
+
"email.purpose",
|
|
234
|
+
"email.recipient",
|
|
235
|
+
"email.key_point",
|
|
236
|
+
"email.action_item",
|
|
237
|
+
"meeting.attendee",
|
|
238
|
+
"meeting.agenda_item",
|
|
239
|
+
"meeting.key_decision",
|
|
240
|
+
"meeting.next_step"
|
|
241
|
+
] }, { "type": "null" }] },
|
|
242
|
+
"value": {
|
|
243
|
+
"type": "string",
|
|
244
|
+
"minLength": 1
|
|
245
|
+
},
|
|
246
|
+
"temporal_phrase": { "anyOf": [{
|
|
247
|
+
"type": "string",
|
|
248
|
+
"minLength": 1
|
|
249
|
+
}, { "type": "null" }] },
|
|
250
|
+
"ends_current": { "type": "boolean" },
|
|
251
|
+
"ended_at_phrase": { "anyOf": [{
|
|
252
|
+
"type": "string",
|
|
253
|
+
"minLength": 1
|
|
254
|
+
}, { "type": "null" }] },
|
|
255
|
+
"importance": { "enum": [
|
|
256
|
+
"high",
|
|
257
|
+
"medium",
|
|
258
|
+
"low"
|
|
259
|
+
] },
|
|
260
|
+
"changes_current_state": { "type": "boolean" },
|
|
261
|
+
"todo": { "enum": [
|
|
262
|
+
"open",
|
|
263
|
+
"done",
|
|
264
|
+
"removed",
|
|
265
|
+
"none"
|
|
266
|
+
] },
|
|
267
|
+
"close_reason": { "anyOf": [{
|
|
268
|
+
"type": "string",
|
|
269
|
+
"minLength": 1
|
|
270
|
+
}, { "type": "null" }] },
|
|
271
|
+
"source_span": {
|
|
272
|
+
"type": "object",
|
|
273
|
+
"additionalProperties": false,
|
|
274
|
+
"required": ["turn_index", "quote"],
|
|
275
|
+
"properties": {
|
|
276
|
+
"turn_index": {
|
|
277
|
+
"type": "integer",
|
|
278
|
+
"minimum": 0
|
|
279
|
+
},
|
|
280
|
+
"quote": {
|
|
281
|
+
"type": "string",
|
|
282
|
+
"minLength": 1
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
"relations": {
|
|
287
|
+
"type": "array",
|
|
288
|
+
"maxItems": 3,
|
|
289
|
+
"items": {
|
|
290
|
+
"type": "object",
|
|
291
|
+
"additionalProperties": false,
|
|
292
|
+
"required": [
|
|
293
|
+
"subject",
|
|
294
|
+
"predicate",
|
|
295
|
+
"object"
|
|
296
|
+
],
|
|
297
|
+
"properties": {
|
|
298
|
+
"subject": {
|
|
299
|
+
"type": "string",
|
|
300
|
+
"minLength": 1
|
|
301
|
+
},
|
|
302
|
+
"predicate": { "enum": [
|
|
303
|
+
"IS_A",
|
|
304
|
+
"WORKS_ON",
|
|
305
|
+
"NEEDS",
|
|
306
|
+
"PREFERS",
|
|
307
|
+
"FORBIDS",
|
|
308
|
+
"USES",
|
|
309
|
+
"DEPENDS_ON",
|
|
310
|
+
"CAUSED",
|
|
311
|
+
"FIXED_BY",
|
|
312
|
+
"DECIDED",
|
|
313
|
+
"SUPERSEDES",
|
|
314
|
+
"GOVERNED_BY",
|
|
315
|
+
"OWNED_BY",
|
|
316
|
+
"MEMBER_OF",
|
|
317
|
+
"LOCATED_AT",
|
|
318
|
+
"HAS_SKILL",
|
|
319
|
+
"INTERESTED_IN",
|
|
320
|
+
"HAS_ACCOUNT",
|
|
321
|
+
"HAS_OCCUPATION",
|
|
322
|
+
"HAS_METRIC",
|
|
323
|
+
"WORKS_AT",
|
|
324
|
+
"ATTENDED",
|
|
325
|
+
"REPORTS_TO",
|
|
326
|
+
"COLLABORATES_WITH",
|
|
327
|
+
"LEARNED_FROM",
|
|
328
|
+
"ABANDONED",
|
|
329
|
+
"BLOCKED_BY",
|
|
330
|
+
"IMPLEMENTED_IN",
|
|
331
|
+
"OCCURS_UNDER",
|
|
332
|
+
"CITES",
|
|
333
|
+
"CREATED",
|
|
334
|
+
"MENTIONS"
|
|
335
|
+
] },
|
|
336
|
+
"object": {
|
|
337
|
+
"type": "string",
|
|
338
|
+
"minLength": 1
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
"single_claim": { "type": "boolean" },
|
|
344
|
+
"time": { "$ref": "#/$defs/calendarInstruction" },
|
|
345
|
+
"ended_time": { "$ref": "#/$defs/calendarInstruction" }
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
$defs: { "calendarInstruction": { "oneOf": [
|
|
351
|
+
{
|
|
352
|
+
"type": "object",
|
|
353
|
+
"properties": { "kind": {
|
|
354
|
+
"type": "string",
|
|
355
|
+
"const": "none"
|
|
356
|
+
} },
|
|
357
|
+
"required": ["kind"],
|
|
358
|
+
"additionalProperties": false
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"type": "object",
|
|
362
|
+
"properties": { "kind": {
|
|
363
|
+
"type": "string",
|
|
364
|
+
"const": "unresolved"
|
|
365
|
+
} },
|
|
366
|
+
"required": ["kind"],
|
|
367
|
+
"additionalProperties": false
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
"type": "object",
|
|
371
|
+
"properties": {
|
|
372
|
+
"kind": {
|
|
373
|
+
"type": "string",
|
|
374
|
+
"const": "absolute"
|
|
375
|
+
},
|
|
376
|
+
"year": {
|
|
377
|
+
"type": "integer",
|
|
378
|
+
"minimum": -9007199254740991,
|
|
379
|
+
"maximum": 9007199254740991
|
|
380
|
+
},
|
|
381
|
+
"month": {
|
|
382
|
+
"type": "integer",
|
|
383
|
+
"minimum": 1,
|
|
384
|
+
"maximum": 12
|
|
385
|
+
},
|
|
386
|
+
"day": {
|
|
387
|
+
"type": "integer",
|
|
388
|
+
"minimum": 1,
|
|
389
|
+
"maximum": 31
|
|
390
|
+
},
|
|
391
|
+
"precision": {
|
|
392
|
+
"type": "string",
|
|
393
|
+
"enum": [
|
|
394
|
+
"year",
|
|
395
|
+
"month",
|
|
396
|
+
"week",
|
|
397
|
+
"day",
|
|
398
|
+
"minute"
|
|
399
|
+
]
|
|
400
|
+
},
|
|
401
|
+
"hour": {
|
|
402
|
+
"type": "integer",
|
|
403
|
+
"minimum": 0,
|
|
404
|
+
"maximum": 23
|
|
405
|
+
},
|
|
406
|
+
"minute": {
|
|
407
|
+
"type": "integer",
|
|
408
|
+
"minimum": 0,
|
|
409
|
+
"maximum": 59
|
|
410
|
+
},
|
|
411
|
+
"timezone": {
|
|
412
|
+
"type": "string",
|
|
413
|
+
"minLength": 1,
|
|
414
|
+
"description": "A valid IANA time zone identifier or fixed UTC offset in +HH:MM or -HH:MM form; never a natural-language abbreviation. Keep hour and minute in that source zone."
|
|
415
|
+
}
|
|
416
|
+
},
|
|
417
|
+
"required": [
|
|
418
|
+
"kind",
|
|
419
|
+
"year",
|
|
420
|
+
"precision"
|
|
421
|
+
],
|
|
422
|
+
"additionalProperties": false
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
"type": "object",
|
|
426
|
+
"properties": {
|
|
427
|
+
"kind": {
|
|
428
|
+
"type": "string",
|
|
429
|
+
"const": "relative"
|
|
430
|
+
},
|
|
431
|
+
"amount": {
|
|
432
|
+
"type": "integer",
|
|
433
|
+
"minimum": -9007199254740991,
|
|
434
|
+
"maximum": 9007199254740991
|
|
435
|
+
},
|
|
436
|
+
"unit": {
|
|
437
|
+
"type": "string",
|
|
438
|
+
"enum": [
|
|
439
|
+
"year",
|
|
440
|
+
"month",
|
|
441
|
+
"week",
|
|
442
|
+
"day",
|
|
443
|
+
"hour",
|
|
444
|
+
"minute"
|
|
445
|
+
]
|
|
446
|
+
},
|
|
447
|
+
"precision": {
|
|
448
|
+
"type": "string",
|
|
449
|
+
"enum": [
|
|
450
|
+
"year",
|
|
451
|
+
"month",
|
|
452
|
+
"week",
|
|
453
|
+
"day",
|
|
454
|
+
"minute"
|
|
455
|
+
]
|
|
456
|
+
},
|
|
457
|
+
"hour": {
|
|
458
|
+
"type": "integer",
|
|
459
|
+
"minimum": 0,
|
|
460
|
+
"maximum": 23
|
|
461
|
+
},
|
|
462
|
+
"minute": {
|
|
463
|
+
"type": "integer",
|
|
464
|
+
"minimum": 0,
|
|
465
|
+
"maximum": 59
|
|
466
|
+
},
|
|
467
|
+
"timezone": {
|
|
468
|
+
"type": "string",
|
|
469
|
+
"minLength": 1,
|
|
470
|
+
"description": "A valid IANA time zone identifier or fixed UTC offset in +HH:MM or -HH:MM form; never a natural-language abbreviation. Keep hour and minute in that source zone."
|
|
471
|
+
}
|
|
472
|
+
},
|
|
473
|
+
"required": [
|
|
474
|
+
"kind",
|
|
475
|
+
"amount",
|
|
476
|
+
"unit",
|
|
477
|
+
"precision"
|
|
478
|
+
],
|
|
479
|
+
"additionalProperties": false
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
"type": "object",
|
|
483
|
+
"properties": {
|
|
484
|
+
"kind": {
|
|
485
|
+
"type": "string",
|
|
486
|
+
"const": "weekday"
|
|
487
|
+
},
|
|
488
|
+
"day_name": {
|
|
489
|
+
"type": "string",
|
|
490
|
+
"enum": [
|
|
491
|
+
"monday",
|
|
492
|
+
"tuesday",
|
|
493
|
+
"wednesday",
|
|
494
|
+
"thursday",
|
|
495
|
+
"friday",
|
|
496
|
+
"saturday",
|
|
497
|
+
"sunday"
|
|
498
|
+
],
|
|
499
|
+
"description": "The named day as an English lowercase day name, never a number."
|
|
500
|
+
},
|
|
501
|
+
"direction": {
|
|
502
|
+
"type": "string",
|
|
503
|
+
"enum": ["previous", "next"]
|
|
504
|
+
},
|
|
505
|
+
"precision": {
|
|
506
|
+
"type": "string",
|
|
507
|
+
"enum": ["day", "minute"]
|
|
508
|
+
},
|
|
509
|
+
"hour": {
|
|
510
|
+
"type": "integer",
|
|
511
|
+
"minimum": 0,
|
|
512
|
+
"maximum": 23
|
|
513
|
+
},
|
|
514
|
+
"minute": {
|
|
515
|
+
"type": "integer",
|
|
516
|
+
"minimum": 0,
|
|
517
|
+
"maximum": 59
|
|
518
|
+
},
|
|
519
|
+
"timezone": {
|
|
520
|
+
"type": "string",
|
|
521
|
+
"minLength": 1,
|
|
522
|
+
"description": "A valid IANA time zone identifier or fixed UTC offset in +HH:MM or -HH:MM form; never a natural-language abbreviation. Keep hour and minute in that source zone."
|
|
523
|
+
}
|
|
524
|
+
},
|
|
525
|
+
"required": [
|
|
526
|
+
"kind",
|
|
527
|
+
"day_name",
|
|
528
|
+
"direction",
|
|
529
|
+
"precision"
|
|
530
|
+
],
|
|
531
|
+
"additionalProperties": false
|
|
532
|
+
}
|
|
533
|
+
] } }
|
|
534
|
+
};
|
|
535
|
+
//#endregion
|
|
536
|
+
//#region src/engine/extraction/atomic-extraction-reply.ts
|
|
537
|
+
/** @file atomic-extraction-reply.ts
|
|
538
|
+
* @purpose Defines and recovers the one atomic extraction reply shape.
|
|
539
|
+
* @boundary Reply validation only; no model calls, persistence, or post-processing judgment.
|
|
540
|
+
*/
|
|
541
|
+
const log = createLogger("sno-station-mem:atomic-extraction-reply");
|
|
542
|
+
const personAttributeSlugs = new Set(attribute_dictionary_default.slugs.map(({ slug }) => slug));
|
|
543
|
+
const thingAttributeSlugs = new Set(state_vocabulary_default.slugs.map(({ slug }) => slug));
|
|
544
|
+
const relationPredicates = /* @__PURE__ */ new Set([...relations.map(({ type }) => type), "MENTIONS"]);
|
|
545
|
+
const relationSchema = z.object({
|
|
546
|
+
subject: z.string().min(1),
|
|
547
|
+
predicate: z.string().refine((value) => relationPredicates.has(value)),
|
|
548
|
+
object: z.string().min(1)
|
|
549
|
+
}).strip();
|
|
550
|
+
const wireTimeSchema = calendarInstructionSchema.catch(() => {
|
|
551
|
+
log.warn("atomic extraction kept a record with an invalid time judgment", {}, {
|
|
552
|
+
event_name: "memory.atomic_extraction_reply.diagnostic",
|
|
553
|
+
file: "packages/memory/src/engine/extraction/atomic-extraction-reply.ts",
|
|
554
|
+
function: "wireTimeSchema",
|
|
555
|
+
site_id: "extraction.atomic-extraction-reply.invalid_time"
|
|
556
|
+
});
|
|
557
|
+
return { kind: "unresolved" };
|
|
558
|
+
});
|
|
559
|
+
const wireRecordSchema = z.object({
|
|
560
|
+
kind: z.enum(["occurrence", "standing"]),
|
|
561
|
+
claim_text: z.string().min(1),
|
|
562
|
+
subject: z.string().min(1),
|
|
563
|
+
subject_kind: z.enum([
|
|
564
|
+
"user",
|
|
565
|
+
"agent",
|
|
566
|
+
"named_entity",
|
|
567
|
+
"unresolved"
|
|
568
|
+
]),
|
|
569
|
+
attribute: z.string().nullable(),
|
|
570
|
+
value: z.string().min(1),
|
|
571
|
+
temporal_phrase: z.string().min(1).nullable(),
|
|
572
|
+
time: wireTimeSchema.optional(),
|
|
573
|
+
ended_time: wireTimeSchema.optional(),
|
|
574
|
+
ends_current: z.boolean(),
|
|
575
|
+
ended_at_phrase: z.string().min(1).nullable().optional(),
|
|
576
|
+
importance: z.enum([
|
|
577
|
+
"high",
|
|
578
|
+
"medium",
|
|
579
|
+
"low"
|
|
580
|
+
]),
|
|
581
|
+
changes_current_state: z.boolean(),
|
|
582
|
+
todo: z.enum([
|
|
583
|
+
"open",
|
|
584
|
+
"done",
|
|
585
|
+
"removed",
|
|
586
|
+
"none"
|
|
587
|
+
]),
|
|
588
|
+
close_reason: z.string().min(1).nullable(),
|
|
589
|
+
source_span: z.object({
|
|
590
|
+
turn_index: z.number().int().nonnegative(),
|
|
591
|
+
quote: z.string().min(1)
|
|
592
|
+
}).strip(),
|
|
593
|
+
relations: z.array(relationSchema),
|
|
594
|
+
single_claim: z.boolean()
|
|
595
|
+
}).strip();
|
|
596
|
+
const envelopeSchema = z.object({ records: z.array(wireRecordSchema) }).strip();
|
|
597
|
+
const arraySchema = z.array(wireRecordSchema);
|
|
598
|
+
const MAX_RELATIONS = 3;
|
|
599
|
+
function projectRecord(record) {
|
|
600
|
+
const allowedAttributes = record.subject_kind === "user" ? personAttributeSlugs : record.subject_kind === "named_entity" || record.subject_kind === "unresolved" ? thingAttributeSlugs : void 0;
|
|
601
|
+
const offeredAttribute = record.attribute === null ? null : record.attribute.trim().toLowerCase();
|
|
602
|
+
const attribute = offeredAttribute !== null && allowedAttributes?.has(offeredAttribute) ? offeredAttribute : null;
|
|
603
|
+
if (offeredAttribute !== null && attribute === null) log.warn("atomic extraction attribute stored unkeyed", {
|
|
604
|
+
attribute_length: offeredAttribute.length,
|
|
605
|
+
subjectKind: record.subject_kind
|
|
606
|
+
}, {
|
|
607
|
+
event_name: "memory.atomic_extraction_reply.diagnostic",
|
|
608
|
+
file: "packages/memory/src/engine/extraction/atomic-extraction-reply.ts",
|
|
609
|
+
function: "projectRecord",
|
|
610
|
+
site_id: "extraction.atomic-extraction-reply.projectRecord.327508ac5f"
|
|
611
|
+
});
|
|
612
|
+
const endedAtPhrase = record.ends_current ? record.ended_at_phrase ?? null : null;
|
|
613
|
+
if (record.time === void 0 || record.ends_current && record.ended_time === void 0) log.warn("atomic extraction kept a record with an omitted time judgment", {
|
|
614
|
+
time_missing: record.time === void 0,
|
|
615
|
+
ending_time_missing: record.ends_current && record.ended_time === void 0
|
|
616
|
+
}, {
|
|
617
|
+
event_name: "memory.atomic_extraction_reply.diagnostic",
|
|
618
|
+
file: "packages/memory/src/engine/extraction/atomic-extraction-reply.ts",
|
|
619
|
+
function: "projectRecord",
|
|
620
|
+
site_id: "extraction.atomic-extraction-reply.omitted_time"
|
|
621
|
+
});
|
|
622
|
+
if (!record.ends_current && (record.ended_at_phrase ?? null) !== null) log.warn("atomic extraction dropped an ending time on a claim that does not end", { claim_length: record.claim_text.length }, {
|
|
623
|
+
event_name: "memory.atomic_extraction_reply.diagnostic",
|
|
624
|
+
file: "packages/memory/src/engine/extraction/atomic-extraction-reply.ts",
|
|
625
|
+
function: "projectRecord",
|
|
626
|
+
site_id: "extraction.atomic-extraction-reply.projectRecord.aac5440fc2"
|
|
627
|
+
});
|
|
628
|
+
const closeReason = record.todo === "done" || record.todo === "removed" ? record.close_reason : null;
|
|
629
|
+
if (record.relations.length > MAX_RELATIONS) log.warn("atomic extraction kept the first relations only", {
|
|
630
|
+
offered: record.relations.length,
|
|
631
|
+
kept: MAX_RELATIONS
|
|
632
|
+
}, {
|
|
633
|
+
event_name: "memory.atomic_extraction_reply.diagnostic",
|
|
634
|
+
file: "packages/memory/src/engine/extraction/atomic-extraction-reply.ts",
|
|
635
|
+
function: "projectRecord",
|
|
636
|
+
site_id: "extraction.atomic-extraction-reply.projectRecord.b92c90f285"
|
|
637
|
+
});
|
|
638
|
+
return {
|
|
639
|
+
kind: record.kind,
|
|
640
|
+
claimText: record.claim_text,
|
|
641
|
+
subject: record.subject,
|
|
642
|
+
subjectKind: record.subject_kind,
|
|
643
|
+
attribute,
|
|
644
|
+
...offeredAttribute !== null && attribute === null ? { refusedAttribute: offeredAttribute } : {},
|
|
645
|
+
value: record.value,
|
|
646
|
+
temporalPhrase: record.temporal_phrase,
|
|
647
|
+
time: record.time ?? { kind: "unresolved" },
|
|
648
|
+
endedTime: record.ends_current ? record.ended_time ?? { kind: "unresolved" } : { kind: "none" },
|
|
649
|
+
resolvedTime: null,
|
|
650
|
+
endsCurrent: record.ends_current,
|
|
651
|
+
endedAtPhrase,
|
|
652
|
+
endedAt: null,
|
|
653
|
+
importance: record.importance,
|
|
654
|
+
changesCurrentState: record.changes_current_state,
|
|
655
|
+
todo: record.todo,
|
|
656
|
+
closeReason,
|
|
657
|
+
sourceSpan: {
|
|
658
|
+
turnIndex: record.source_span.turn_index,
|
|
659
|
+
quote: record.source_span.quote
|
|
660
|
+
},
|
|
661
|
+
relations: record.relations.slice(0, MAX_RELATIONS),
|
|
662
|
+
singleClaim: record.single_claim
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
function validatePayload(value, turnCount) {
|
|
666
|
+
let records;
|
|
667
|
+
if (Array.isArray(value)) {
|
|
668
|
+
const parsed = arraySchema.safeParse(value);
|
|
669
|
+
if (!parsed.success) return void 0;
|
|
670
|
+
records = parsed.data;
|
|
671
|
+
} else {
|
|
672
|
+
const parsed = envelopeSchema.safeParse(value);
|
|
673
|
+
if (!parsed.success) return void 0;
|
|
674
|
+
records = parsed.data.records;
|
|
675
|
+
}
|
|
676
|
+
if (records.some((record) => record.source_span.turn_index >= turnCount)) return void 0;
|
|
677
|
+
return records.map(projectRecord);
|
|
678
|
+
}
|
|
679
|
+
function parsePayload(text, turnCount) {
|
|
680
|
+
try {
|
|
681
|
+
return validatePayload(JSON.parse(text), turnCount);
|
|
682
|
+
} catch {
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Reads the one reply shape out of whatever the model wrapped it in.
|
|
688
|
+
*
|
|
689
|
+
* Candidate order and think-stripping belong to `modelReplyJsonCandidates`; the schema decision
|
|
690
|
+
* stays here. The first candidate this file admits wins — the previous rule discarded a reply
|
|
691
|
+
* whenever two candidates validated, which cost real memories every time the model wrote its
|
|
692
|
+
* reasoning as prose before the payload (measured 2026-09-04 on the live Memora run).
|
|
693
|
+
*/
|
|
694
|
+
function parseAtomicExtractionReply(raw, turnCount) {
|
|
695
|
+
let malformedCandidateCount = 0;
|
|
696
|
+
for (const candidate of modelReplyJsonCandidates(raw)) {
|
|
697
|
+
const records = parsePayload(candidate, turnCount);
|
|
698
|
+
if (records) return {
|
|
699
|
+
ok: true,
|
|
700
|
+
records,
|
|
701
|
+
malformedCandidateCount
|
|
702
|
+
};
|
|
703
|
+
malformedCandidateCount += 1;
|
|
704
|
+
}
|
|
705
|
+
return {
|
|
706
|
+
ok: false,
|
|
707
|
+
reason: "no-schema-payload",
|
|
708
|
+
malformedCandidateCount
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
const ATOMIC_EXTRACTION_RESPONSE_JSON_SCHEMA = atomic_extraction_response_schema_default;
|
|
712
|
+
const captureFactSchema = wireRecordSchema.pick({
|
|
713
|
+
subject: true,
|
|
714
|
+
subject_kind: true,
|
|
715
|
+
temporal_phrase: true,
|
|
716
|
+
source_span: true
|
|
717
|
+
}).extend({
|
|
718
|
+
id: z.number().int().nonnegative(),
|
|
719
|
+
fact: z.string().min(1),
|
|
720
|
+
ended_at_phrase: wireRecordSchema.shape.ended_at_phrase.unwrap()
|
|
721
|
+
});
|
|
722
|
+
const captureReplySchema = z.object({
|
|
723
|
+
claims_found: z.array(z.string().min(1)),
|
|
724
|
+
decisions: z.array(z.object({
|
|
725
|
+
turn_index: z.number().int().nonnegative(),
|
|
726
|
+
progress_only: z.boolean()
|
|
727
|
+
})),
|
|
728
|
+
facts: z.array(captureFactSchema)
|
|
729
|
+
});
|
|
730
|
+
const enrichmentSchema = wireRecordSchema.omit({
|
|
731
|
+
claim_text: true,
|
|
732
|
+
subject: true,
|
|
733
|
+
subject_kind: true,
|
|
734
|
+
temporal_phrase: true,
|
|
735
|
+
ended_at_phrase: true,
|
|
736
|
+
source_span: true
|
|
737
|
+
}).extend({
|
|
738
|
+
id: z.number().int().nonnegative(),
|
|
739
|
+
time: calendarInstructionSchema,
|
|
740
|
+
ended_time: calendarInstructionSchema,
|
|
741
|
+
relations: z.array(relationSchema.extend({ predicate: z.enum(relations.map(({ type }) => type)) })).max(MAX_RELATIONS)
|
|
742
|
+
});
|
|
743
|
+
const enrichmentReplySchema = z.object({ enrichments: z.array(enrichmentSchema) });
|
|
744
|
+
const ATOMIC_CAPTURE_RESPONSE_JSON_SCHEMA = z.toJSONSchema(captureReplySchema);
|
|
745
|
+
const ATOMIC_ENRICHMENT_RESPONSE_JSON_SCHEMA = z.toJSONSchema(enrichmentReplySchema);
|
|
746
|
+
function parseAtomicCaptureReply(raw, turns, { salvage = false, onReject } = {}) {
|
|
747
|
+
let gate = "unreadable-json";
|
|
748
|
+
const result = readModelReplyJson(raw, (value) => {
|
|
749
|
+
const parsed = captureReplySchema.safeParse(value);
|
|
750
|
+
if (!parsed.success) {
|
|
751
|
+
if (gate === "unreadable-json") gate = "capture-schema";
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
const { facts, claims_found } = parsed.data;
|
|
755
|
+
const kept = facts.map((fact, index) => ({
|
|
756
|
+
...fact,
|
|
757
|
+
id: index
|
|
758
|
+
})).filter((fact) => fact.source_span.turn_index < turns.length);
|
|
759
|
+
if (claims_found.length > 0 && kept.length === 0) {
|
|
760
|
+
gate = "claims-without-facts";
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
const progressTurns = parseProgressTurns(parsed.data, turns, { salvage });
|
|
764
|
+
if (progressTurns === null) {
|
|
765
|
+
gate = "progress-decisions";
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
const wrongIds = facts.filter((fact, index) => fact.id !== index).length;
|
|
769
|
+
const invalidSpans = facts.filter((fact) => fact.source_span.turn_index >= turns.length).length;
|
|
770
|
+
if (!salvage && (wrongIds > 0 || invalidSpans > 0)) {
|
|
771
|
+
gate = wrongIds > 0 ? "fact-ids" : "source-turn-index";
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
774
|
+
if (wrongIds > 0) log.warn("atomic capture salvaged fact ids", {
|
|
775
|
+
gate: 5,
|
|
776
|
+
affected_facts: wrongIds
|
|
777
|
+
}, {
|
|
778
|
+
event_name: "memory.atomic_extraction_reply.diagnostic",
|
|
779
|
+
file: "packages/memory/src/engine/extraction/atomic-extraction-reply.ts",
|
|
780
|
+
function: "parseAtomicCaptureReply",
|
|
781
|
+
site_id: "extraction.atomic-extraction-reply.salvage_ids"
|
|
782
|
+
});
|
|
783
|
+
if (invalidSpans > 0) log.warn("atomic capture dropped facts with invalid source turns", {
|
|
784
|
+
gate: 6,
|
|
785
|
+
affected_facts: invalidSpans
|
|
786
|
+
}, {
|
|
787
|
+
event_name: "memory.atomic_extraction_reply.diagnostic",
|
|
788
|
+
file: "packages/memory/src/engine/extraction/atomic-extraction-reply.ts",
|
|
789
|
+
function: "parseAtomicCaptureReply",
|
|
790
|
+
site_id: "extraction.atomic-extraction-reply.salvage_spans"
|
|
791
|
+
});
|
|
792
|
+
return {
|
|
793
|
+
facts: kept,
|
|
794
|
+
progressTurns
|
|
795
|
+
};
|
|
796
|
+
});
|
|
797
|
+
if (result === void 0) onReject?.(gate);
|
|
798
|
+
return result;
|
|
799
|
+
}
|
|
800
|
+
function warnUnresolvedEnrichmentTime(enrichment, sessionDateTime) {
|
|
801
|
+
for (const field of ["time", "ended_time"]) {
|
|
802
|
+
const instruction = enrichment[field];
|
|
803
|
+
if (instruction.kind === "none" || instruction.kind === "unresolved" || calculateCalendarTime(instruction, sessionDateTime) !== null) continue;
|
|
804
|
+
const missingComponents = [];
|
|
805
|
+
if (instruction.kind === "absolute") {
|
|
806
|
+
if (instruction.precision !== "year" && instruction.month === void 0) missingComponents.push("month");
|
|
807
|
+
if (instruction.precision !== "year" && instruction.precision !== "month" && instruction.day === void 0) missingComponents.push("day");
|
|
808
|
+
} else if (sessionDateTime === void 0) missingComponents.push("session_date_time");
|
|
809
|
+
if (instruction.hour === void 0 && (instruction.minute !== void 0 || instruction.precision === "minute" && instruction.kind !== "relative")) missingComponents.push("hour");
|
|
810
|
+
log.warn("atomic enrichment time could not be calculated", {
|
|
811
|
+
fact_id: enrichment.id,
|
|
812
|
+
field: { name: field },
|
|
813
|
+
kind: instruction.kind,
|
|
814
|
+
precision: { unit: instruction.precision },
|
|
815
|
+
missing_components: missingComponents.map((name) => ({ name }))
|
|
816
|
+
}, {
|
|
817
|
+
event_name: "memory.atomic_extraction_reply.diagnostic",
|
|
818
|
+
file: "packages/memory/src/engine/extraction/atomic-extraction-reply.ts",
|
|
819
|
+
function: "warnUnresolvedEnrichmentTime",
|
|
820
|
+
site_id: "extraction.atomic-extraction-reply.unresolved_enrichment_time"
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
function parseAtomicEnrichmentReply(raw, facts, sessionDateTime) {
|
|
825
|
+
return readModelReplyJson(raw, (value) => {
|
|
826
|
+
const parsed = enrichmentReplySchema.safeParse(value);
|
|
827
|
+
if (!parsed.success) return void 0;
|
|
828
|
+
const byId = new Map(parsed.data.enrichments.map((entry) => [entry.id, entry]));
|
|
829
|
+
if (parsed.data.enrichments.length !== facts.length || byId.size !== facts.length || facts.some((fact) => !byId.has(fact.id))) return void 0;
|
|
830
|
+
const records = [];
|
|
831
|
+
for (const fact of facts) {
|
|
832
|
+
const enrichment = byId.get(fact.id);
|
|
833
|
+
if (enrichment === void 0) return void 0;
|
|
834
|
+
warnUnresolvedEnrichmentTime(enrichment, sessionDateTime);
|
|
835
|
+
records.push(projectRecord({
|
|
836
|
+
...enrichment,
|
|
837
|
+
...fact,
|
|
838
|
+
claim_text: fact.fact
|
|
839
|
+
}));
|
|
840
|
+
}
|
|
841
|
+
return records;
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
function fallbackAtomicCapturedFact(fact) {
|
|
845
|
+
return projectRecord({
|
|
846
|
+
...fact,
|
|
847
|
+
claim_text: fact.fact,
|
|
848
|
+
kind: "occurrence",
|
|
849
|
+
attribute: null,
|
|
850
|
+
value: fact.fact,
|
|
851
|
+
ends_current: false,
|
|
852
|
+
todo: "none",
|
|
853
|
+
close_reason: null,
|
|
854
|
+
changes_current_state: false,
|
|
855
|
+
importance: "low",
|
|
856
|
+
single_claim: true,
|
|
857
|
+
relations: [],
|
|
858
|
+
time: { kind: "unresolved" },
|
|
859
|
+
ended_time: { kind: "none" }
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
//#endregion
|
|
863
|
+
export { parseAtomicCaptureReply as a, atomic_extraction_response_schema_default as c, fallbackAtomicCapturedFact as i, excludeProgressRecords as l, ATOMIC_ENRICHMENT_RESPONSE_JSON_SCHEMA as n, parseAtomicEnrichmentReply as o, ATOMIC_EXTRACTION_RESPONSE_JSON_SCHEMA as r, parseAtomicExtractionReply as s, ATOMIC_CAPTURE_RESPONSE_JSON_SCHEMA as t };
|