@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,2 @@
|
|
|
1
|
+
import { C as RemVerdictCheckpoint, D as parseRemOperationType, E as assertJobIdentity, S as RemUpdateRewriteConfig, T as WriteTextVersionInput, _ as RemOwner, a as REM_ROW_STATES, b as RemStatementLike, c as RemConfig, d as RemEnableGateArtifact, f as RemForgetPort, g as RemOperationType, h as RemMutationResult, i as REM_OPERATION_TYPES, l as RemConflictPort, m as RemMutationRefusalReason, n as REM_BUILT_OPERATION_TYPES, o as RemBuiltOperationType, p as RemJobState, r as REM_JOB_STATES, s as RemClockPort, t as MoveLaneInput, u as RemDatabaseLike, v as RemPorts, w as SoftCloseInput, x as RemTransactionLike, y as RemRowState } from "../../../types-pVomjzqR.js";
|
|
2
|
+
export { MoveLaneInput, REM_BUILT_OPERATION_TYPES, REM_JOB_STATES, REM_OPERATION_TYPES, REM_ROW_STATES, RemBuiltOperationType, RemClockPort, RemConfig, RemConflictPort, RemDatabaseLike, RemEnableGateArtifact, RemForgetPort, RemJobState, RemMutationRefusalReason, RemMutationResult, RemOperationType, RemOwner, RemPorts, RemRowState, RemStatementLike, RemTransactionLike, RemUpdateRewriteConfig, RemVerdictCheckpoint, SoftCloseInput, WriteTextVersionInput, assertJobIdentity, parseRemOperationType };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//#region src/engine/rem/types.ts
|
|
2
|
+
const REM_OPERATION_TYPES = [
|
|
3
|
+
"rem-update",
|
|
4
|
+
"rem-replace",
|
|
5
|
+
"rem-distill",
|
|
6
|
+
"rem-retire"
|
|
7
|
+
];
|
|
8
|
+
const REM_BUILT_OPERATION_TYPES = ["rem-update", "rem-replace"];
|
|
9
|
+
function parseRemOperationType(value) {
|
|
10
|
+
for (const operation of REM_OPERATION_TYPES) if (value === operation) return operation;
|
|
11
|
+
}
|
|
12
|
+
const REM_JOB_STATES = [
|
|
13
|
+
"queued",
|
|
14
|
+
"running",
|
|
15
|
+
"done",
|
|
16
|
+
"failed"
|
|
17
|
+
];
|
|
18
|
+
const REM_ROW_STATES = [
|
|
19
|
+
"transition",
|
|
20
|
+
"stale-current",
|
|
21
|
+
"pure-negation",
|
|
22
|
+
"ambiguous"
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Refuses a write whose audit identity is not real. A required `string` is not proof of one:
|
|
26
|
+
* TypeScript accepts `""`, the journal's `job_id`/`job_type` columns are `NOT NULL` but not
|
|
27
|
+
* non-blank, and a JavaScript caller can omit the field entirely.
|
|
28
|
+
*
|
|
29
|
+
* No valid identity, no write — the whole operation is refused before any transaction opens. This
|
|
30
|
+
* does not rescue the write; it refuses it, which is the intended trade: an unattributable row in
|
|
31
|
+
* the audit ledger is worse than a refused operation the caller can see and retry.
|
|
32
|
+
*
|
|
33
|
+
* The accepted set is `REM_OPERATION_TYPES` itself, so the runtime check and the type cannot drift.
|
|
34
|
+
*/
|
|
35
|
+
function assertJobIdentity(jobId, jobType) {
|
|
36
|
+
if (typeof jobId !== "string" || jobId.trim().length === 0) throw new Error(`REM write requires a non-blank job id, got: ${String(jobId)}`);
|
|
37
|
+
if (typeof jobType !== "string" || parseRemOperationType(jobType) === void 0) throw new Error(`REM write requires a known job type, got: ${String(jobType)}`);
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { REM_BUILT_OPERATION_TYPES, REM_JOB_STATES, REM_OPERATION_TYPES, REM_ROW_STATES, assertJobIdentity, parseRemOperationType };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as computeEffectiveHalfLife, i as buildUpdatedMetadata, n as AccessTracker, o as parseAccessMetadata, r as AccessTrackerOptions, t as AccessMetadata } from "../../../access-tracker-BbEvEocb.js";
|
|
2
|
+
export { AccessMetadata, AccessTracker, AccessTrackerOptions, buildUpdatedMetadata, computeEffectiveHalfLife, parseAccessMetadata };
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { DEFAULT_RECALL_LIFECYCLE } from "../../config/index.js";
|
|
2
|
+
import { createLogger } from "@snoai/utils/logger";
|
|
3
|
+
//#region src/engine/retrieval/access-tracker.ts
|
|
4
|
+
/** @file access-tracker.ts
|
|
5
|
+
* @purpose Tracks memory access signals that feed recency, ranking, and decay decisions.
|
|
6
|
+
* @boundary Memory store metadata and retrieval result identifiers.
|
|
7
|
+
* @see store.ts, retriever.ts, selective-forgetting-scorer.ts, retrieval-stats.ts.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Access Tracker
|
|
11
|
+
*
|
|
12
|
+
* Tracks memory access patterns to support reinforcement-based decay.
|
|
13
|
+
* Frequently accessed memories decay more slowly (longer effective half-life).
|
|
14
|
+
*/
|
|
15
|
+
const log = createLogger("sno-station-mem:access-tracker");
|
|
16
|
+
const MIN_ACCESS_COUNT = 0;
|
|
17
|
+
const LEGACY_MAX_ACCESS_COUNT = 1e4;
|
|
18
|
+
/** Default debounce interval before flushing pending writes (5 seconds) */
|
|
19
|
+
const DEFAULT_DEBOUNCE_MS = 5e3;
|
|
20
|
+
const MAX_RETRY_DELAY_MS = 6e4;
|
|
21
|
+
const MAX_WRITE_FAILURES_PER_ID = 5;
|
|
22
|
+
/** Access count itself decays with a 30-day half-life */
|
|
23
|
+
const ACCESS_DECAY_HALF_LIFE_DAYS = 30;
|
|
24
|
+
/** Implements clamp access count as the local access reinforcement metadata operation. */
|
|
25
|
+
function clampAccessCount(value, ceiling = LEGACY_MAX_ACCESS_COUNT) {
|
|
26
|
+
if (!Number.isFinite(value)) return MIN_ACCESS_COUNT;
|
|
27
|
+
return Math.min(ceiling, Math.max(MIN_ACCESS_COUNT, Math.floor(value)));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Parse access-related fields from a metadata JSON string.
|
|
31
|
+
*
|
|
32
|
+
* Handles: undefined, empty string, malformed JSON, negative numbers,
|
|
33
|
+
* numbers exceeding 10000. Always returns a valid AccessMetadata.
|
|
34
|
+
*/
|
|
35
|
+
function parseAccessMetadata(metadata) {
|
|
36
|
+
if (metadata === void 0 || metadata === "") return {
|
|
37
|
+
accessCount: 0,
|
|
38
|
+
lastAccessedAt: 0
|
|
39
|
+
};
|
|
40
|
+
let parsed;
|
|
41
|
+
try {
|
|
42
|
+
parsed = JSON.parse(metadata);
|
|
43
|
+
} catch {
|
|
44
|
+
return {
|
|
45
|
+
accessCount: 0,
|
|
46
|
+
lastAccessedAt: 0
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (typeof parsed !== "object" || parsed === null) return {
|
|
50
|
+
accessCount: 0,
|
|
51
|
+
lastAccessedAt: 0
|
|
52
|
+
};
|
|
53
|
+
const obj = parsed;
|
|
54
|
+
const rawCountAny = obj.accessCount ?? obj.access_count;
|
|
55
|
+
const rawCount = typeof rawCountAny === "number" ? rawCountAny : Number(rawCountAny ?? 0);
|
|
56
|
+
const rawLastAny = obj.lastAccessedAt ?? obj.last_accessed_at;
|
|
57
|
+
const rawLastAccessed = typeof rawLastAny === "number" ? rawLastAny : Number(rawLastAny ?? 0);
|
|
58
|
+
return {
|
|
59
|
+
accessCount: clampAccessCount(rawCount),
|
|
60
|
+
lastAccessedAt: Number.isFinite(rawLastAccessed) && rawLastAccessed >= 0 ? rawLastAccessed : 0
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Merge an access-count increment into existing metadata JSON.
|
|
65
|
+
*
|
|
66
|
+
* Preserves ALL existing fields in the metadata object — only overwrites
|
|
67
|
+
* `accessCount` and `lastAccessedAt`. Returns a new JSON string.
|
|
68
|
+
*/
|
|
69
|
+
function buildUpdatedMetadata(existingMetadata, accessDelta, ceiling = LEGACY_MAX_ACCESS_COUNT) {
|
|
70
|
+
let existing = {};
|
|
71
|
+
if (existingMetadata !== void 0 && existingMetadata !== "") try {
|
|
72
|
+
const parsed = JSON.parse(existingMetadata);
|
|
73
|
+
if (typeof parsed === "object" && parsed !== null) existing = { ...parsed };
|
|
74
|
+
} catch {}
|
|
75
|
+
const newCount = clampAccessCount(parseAccessMetadata(existingMetadata).accessCount + accessDelta, ceiling);
|
|
76
|
+
const now = Date.now();
|
|
77
|
+
return JSON.stringify({
|
|
78
|
+
...existing,
|
|
79
|
+
accessCount: newCount,
|
|
80
|
+
lastAccessedAt: now,
|
|
81
|
+
access_count: newCount,
|
|
82
|
+
last_accessed_at: now
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Compute the effective half-life for a memory based on its access history.
|
|
87
|
+
*
|
|
88
|
+
* The access count itself decays over time (30-day half-life for access
|
|
89
|
+
* freshness), so stale accesses contribute less reinforcement. The extension
|
|
90
|
+
* uses a logarithmic curve (`Math.log1p`) to provide diminishing returns.
|
|
91
|
+
*
|
|
92
|
+
* @param baseHalfLife - Base half-life in days (e.g. 30)
|
|
93
|
+
* @param accessCount - Raw number of times the memory was accessed
|
|
94
|
+
* @param lastAccessedAt - Timestamp (ms) of last access
|
|
95
|
+
* @param reinforcementFactor - Scaling factor for reinforcement (0 = disabled)
|
|
96
|
+
* @param maxMultiplier - Hard cap: result <= baseHalfLife * maxMultiplier
|
|
97
|
+
* @returns Effective half-life in days
|
|
98
|
+
*/
|
|
99
|
+
function computeEffectiveHalfLife(baseHalfLife, accessCount, lastAccessedAt, reinforcementFactor, maxMultiplier, now = Date.now()) {
|
|
100
|
+
if (reinforcementFactor === 0 || accessCount <= 0) return baseHalfLife;
|
|
101
|
+
const daysSinceLastAccess = Math.max(0, (now - lastAccessedAt) / 864e5);
|
|
102
|
+
const effectiveAccessCount = accessCount * Math.exp(-daysSinceLastAccess * (Math.LN2 / ACCESS_DECAY_HALF_LIFE_DAYS));
|
|
103
|
+
const result = baseHalfLife + baseHalfLife * reinforcementFactor * Math.log1p(effectiveAccessCount);
|
|
104
|
+
const cap = baseHalfLife * maxMultiplier;
|
|
105
|
+
return Math.min(result, cap);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Debounced write-back tracker for memory access events.
|
|
109
|
+
*
|
|
110
|
+
* `recordAccess()` is synchronous (Map update only, no I/O). Pending deltas
|
|
111
|
+
* accumulate until `flush()` is called (or after debounceMs timeout).
|
|
112
|
+
* On flush, each pending entry is read via `store.getById()`, its metadata
|
|
113
|
+
* is merged with the accumulated access delta, and written back via
|
|
114
|
+
* `store.update()`.
|
|
115
|
+
*/
|
|
116
|
+
var AccessTracker = class {
|
|
117
|
+
pending = /* @__PURE__ */ new Map();
|
|
118
|
+
debounceTimer;
|
|
119
|
+
flushPromise;
|
|
120
|
+
debounceMs;
|
|
121
|
+
store;
|
|
122
|
+
retryDelayMs;
|
|
123
|
+
writeFailures = /* @__PURE__ */ new Map();
|
|
124
|
+
destroying = false;
|
|
125
|
+
recallLifecycle;
|
|
126
|
+
clampedOnce = /* @__PURE__ */ new Set();
|
|
127
|
+
/**
|
|
128
|
+
* Initializes access reinforcement metadata collaborators while keeping runtime work in
|
|
129
|
+
* explicit methods.
|
|
130
|
+
*/
|
|
131
|
+
constructor(options) {
|
|
132
|
+
this.store = options.store;
|
|
133
|
+
this.debounceMs = options.debounceMs ?? DEFAULT_DEBOUNCE_MS;
|
|
134
|
+
this.retryDelayMs = this.debounceMs;
|
|
135
|
+
this.recallLifecycle = options.recallLifecycle ?? DEFAULT_RECALL_LIFECYCLE;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Record one access for each of the given memory IDs.
|
|
139
|
+
* Synchronous — only updates the in-memory pending map.
|
|
140
|
+
*/
|
|
141
|
+
recordAccess(ids) {
|
|
142
|
+
if (this.destroying) return;
|
|
143
|
+
for (const id of ids) {
|
|
144
|
+
const current = this.pending.get(id) ?? 0;
|
|
145
|
+
this.pending.set(id, current + 1);
|
|
146
|
+
}
|
|
147
|
+
this.resetTimer();
|
|
148
|
+
}
|
|
149
|
+
/** Return a snapshot of all pending (id -> delta) entries. */
|
|
150
|
+
getPendingUpdates() {
|
|
151
|
+
return new Map(this.pending);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Flush pending access deltas to the store.
|
|
155
|
+
*
|
|
156
|
+
* If a flush is already in progress, awaits the current flush to complete.
|
|
157
|
+
* If new pending data accumulated during the in-flight flush, a follow-up
|
|
158
|
+
* flush is automatically triggered.
|
|
159
|
+
*/
|
|
160
|
+
async flush() {
|
|
161
|
+
this.clearTimer();
|
|
162
|
+
if (this.flushPromise) {
|
|
163
|
+
await this.flushPromise;
|
|
164
|
+
if (this.pending.size > 0 && !this.destroying) this.scheduleRetry();
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (this.pending.size === 0) return;
|
|
168
|
+
this.flushPromise = this.doFlush();
|
|
169
|
+
try {
|
|
170
|
+
await this.flushPromise;
|
|
171
|
+
} finally {
|
|
172
|
+
this.flushPromise = void 0;
|
|
173
|
+
}
|
|
174
|
+
if (this.pending.size > 0) {
|
|
175
|
+
if (!this.destroying) this.scheduleRetry();
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
this.retryDelayMs = this.debounceMs;
|
|
179
|
+
}
|
|
180
|
+
/** Tear down the tracker with one final best-effort flush. */
|
|
181
|
+
async destroy() {
|
|
182
|
+
this.destroying = true;
|
|
183
|
+
this.clearTimer();
|
|
184
|
+
if (this.flushPromise) await this.flushPromise;
|
|
185
|
+
if (this.pending.size > 0) await this.doFlush();
|
|
186
|
+
if (this.pending.size > 0) log.warn("destroying with pending writes", { pendingCount: this.pending.size }, {
|
|
187
|
+
event_name: "sno_station_mem.access-tracker.destroying.with.pending.writes",
|
|
188
|
+
file: "packages/memory/src/engine/retrieval/access-tracker.ts",
|
|
189
|
+
function: "destroy",
|
|
190
|
+
site_id: "access-tracker.destroy.5991e0f580"
|
|
191
|
+
});
|
|
192
|
+
this.pending.clear();
|
|
193
|
+
this.writeFailures.clear();
|
|
194
|
+
this.retryDelayMs = this.debounceMs;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Flushes all pending deltas in ONE store call (one mutex acquisition + one
|
|
198
|
+
* transaction), instead of the historical per-id mutex+transaction+full
|
|
199
|
+
* update() round trip. Policy (rate-limit window, ceiling clamp) stays here,
|
|
200
|
+
* delivered through per-id delta callbacks; the store only merges and writes.
|
|
201
|
+
*/
|
|
202
|
+
async doFlush() {
|
|
203
|
+
const batch = new Map(this.pending);
|
|
204
|
+
this.pending.clear();
|
|
205
|
+
if (batch.size === 0) return;
|
|
206
|
+
try {
|
|
207
|
+
const entries = Array.from(batch).flatMap(([id, delta]) => {
|
|
208
|
+
if (this.store.getById(id)?.category !== "episodic") return [];
|
|
209
|
+
return [{
|
|
210
|
+
memoryId: id,
|
|
211
|
+
deltaFn: (current) => this.buildAccessDelta(id, delta, current)
|
|
212
|
+
}];
|
|
213
|
+
});
|
|
214
|
+
await this.store.applyMetadataDeltas(entries);
|
|
215
|
+
for (const id of batch.keys()) this.writeFailures.delete(id);
|
|
216
|
+
} catch (err) {
|
|
217
|
+
for (const [id, delta] of batch) {
|
|
218
|
+
const failures = (this.writeFailures.get(id) ?? 0) + 1;
|
|
219
|
+
if (failures >= MAX_WRITE_FAILURES_PER_ID) {
|
|
220
|
+
this.writeFailures.delete(id);
|
|
221
|
+
log.warn("dropping access delta after repeated write failures", {
|
|
222
|
+
memory_id: id,
|
|
223
|
+
failures,
|
|
224
|
+
error: err
|
|
225
|
+
}, {
|
|
226
|
+
event_name: "sno_station_mem.access-tracker.dropping.access.delta.after.repeated.write.failures",
|
|
227
|
+
file: "packages/memory/src/engine/retrieval/access-tracker.ts",
|
|
228
|
+
function: "doFlush",
|
|
229
|
+
site_id: "access-tracker.doFlush.b3bb3939f2"
|
|
230
|
+
});
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
this.writeFailures.set(id, failures);
|
|
234
|
+
this.pending.set(id, (this.pending.get(id) ?? 0) + delta);
|
|
235
|
+
}
|
|
236
|
+
log.warn("access flush batch failed", {
|
|
237
|
+
batchSize: batch.size,
|
|
238
|
+
error: err,
|
|
239
|
+
committed_count: 0
|
|
240
|
+
}, {
|
|
241
|
+
event_name: "sno_station_mem.access-tracker.access.flush.batch.failed",
|
|
242
|
+
file: "packages/memory/src/engine/retrieval/access-tracker.ts",
|
|
243
|
+
function: "doFlush",
|
|
244
|
+
site_id: "access-tracker.doFlush.f82865a307"
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Per-id policy transform executed inside the store's batch transaction.
|
|
250
|
+
* Returns undefined to skip the write (rate-limited). Both metadata key
|
|
251
|
+
* styles are written — see the cross-subsystem naming note on
|
|
252
|
+
* buildUpdatedMetadata.
|
|
253
|
+
*/
|
|
254
|
+
buildAccessDelta(id, delta, current) {
|
|
255
|
+
const record = current;
|
|
256
|
+
const rawCount = record.accessCount ?? record.access_count;
|
|
257
|
+
const prevCount = clampAccessCount(typeof rawCount === "number" ? rawCount : Number(rawCount ?? 0));
|
|
258
|
+
const rawLast = record.lastAccessedAt ?? record.last_accessed_at;
|
|
259
|
+
const prevLastRaw = typeof rawLast === "number" ? rawLast : Number(rawLast ?? 0);
|
|
260
|
+
const prevLast = Number.isFinite(prevLastRaw) && prevLastRaw >= 0 ? prevLastRaw : 0;
|
|
261
|
+
const now = Date.now();
|
|
262
|
+
let ceiling = LEGACY_MAX_ACCESS_COUNT;
|
|
263
|
+
if (this.recallLifecycle.autoRecallAccessTracking) {
|
|
264
|
+
ceiling = this.recallLifecycle.accessCountCeiling;
|
|
265
|
+
if (prevLast > 0 && now - prevLast < this.recallLifecycle.accessRateLimitMs) return void 0;
|
|
266
|
+
if (prevCount > ceiling && !this.clampedOnce.has(id)) {
|
|
267
|
+
this.clampedOnce.add(id);
|
|
268
|
+
log.warn("legacy access count clamped to ceiling", {
|
|
269
|
+
memory_id: id,
|
|
270
|
+
previousCount: prevCount,
|
|
271
|
+
ceiling
|
|
272
|
+
}, {
|
|
273
|
+
event_name: "sno_station_mem.access-tracker.legacy.access.count.clamped.to.ceiling",
|
|
274
|
+
file: "packages/memory/src/engine/retrieval/access-tracker.ts",
|
|
275
|
+
function: "buildAccessDelta",
|
|
276
|
+
site_id: "access-tracker.buildAccessDelta.4ac8f20936"
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
const newCount = clampAccessCount(prevCount + delta, ceiling);
|
|
281
|
+
return {
|
|
282
|
+
accessCount: newCount,
|
|
283
|
+
lastAccessedAt: now,
|
|
284
|
+
access_count: newCount,
|
|
285
|
+
last_accessed_at: now
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
/** Implements reset timer as the local access reinforcement metadata operation. */
|
|
289
|
+
resetTimer() {
|
|
290
|
+
this.resetTimerWithDelay(this.debounceMs);
|
|
291
|
+
}
|
|
292
|
+
/** Implements schedule retry as the local access reinforcement metadata operation. */
|
|
293
|
+
scheduleRetry() {
|
|
294
|
+
this.retryDelayMs = Math.min(this.retryDelayMs * 2, MAX_RETRY_DELAY_MS);
|
|
295
|
+
this.resetTimerWithDelay(this.retryDelayMs);
|
|
296
|
+
}
|
|
297
|
+
/** Implements reset timer with delay as the local access reinforcement metadata operation. */
|
|
298
|
+
resetTimerWithDelay(delayMs) {
|
|
299
|
+
if (this.destroying) return;
|
|
300
|
+
this.clearTimer();
|
|
301
|
+
this.debounceTimer = setTimeout(() => {
|
|
302
|
+
this.flush();
|
|
303
|
+
}, delayMs);
|
|
304
|
+
}
|
|
305
|
+
/** Removes timer while preserving access reinforcement metadata invariants. */
|
|
306
|
+
clearTimer() {
|
|
307
|
+
if (this.debounceTimer !== void 0) {
|
|
308
|
+
clearTimeout(this.debounceTimer);
|
|
309
|
+
this.debounceTimer = void 0;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
//#endregion
|
|
314
|
+
export { AccessTracker, buildUpdatedMetadata, computeEffectiveHalfLife, parseAccessMetadata };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/engine/retrieval/intent-analyzer.ts
|
|
2
|
+
/** @file intent-analyzer.ts
|
|
3
|
+
* @purpose Renders a recalled memory as one line of text for context injection.
|
|
4
|
+
* @boundary Pure formatting; no query parsing, no pattern banks, no locale rules.
|
|
5
|
+
*
|
|
6
|
+
* The name is historical. This file used to read the query's wording through nine locale rule
|
|
7
|
+
* banks and return a category set plus a rendering depth: a match restricted which categories
|
|
8
|
+
* were eligible and how much of each memory was shown, and a miss returned the shortest form.
|
|
9
|
+
* All of it was deleted on 2026-08-21 — a keyword may hint at scoring, never decide the path or
|
|
10
|
+
* shorten the answer. What survived is the renderer below.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Format a memory entry as one line for context injection.
|
|
14
|
+
*
|
|
15
|
+
* One form only: the complete text. The shorter tiers were chosen from the query's wording, so
|
|
16
|
+
* a question phrased outside the pattern banks received the shortest one. Deleted 2026-08-21.
|
|
17
|
+
*/
|
|
18
|
+
function formatAtDepth(entry, score, _index, extra) {
|
|
19
|
+
const scoreStr = `${(score * 100).toFixed(0)}%`;
|
|
20
|
+
const sourceSuffix = [extra?.bm25Hit ? "vector+BM25" : null, extra?.reranked ? "+reranked" : null].filter(Boolean).join("");
|
|
21
|
+
const sourceTag = sourceSuffix ? `, ${sourceSuffix}` : "";
|
|
22
|
+
const safe = extra?.sanitize ? extra.sanitize(entry.text) : entry.text;
|
|
23
|
+
const datePrefix = extra?.eventDate ? `[${extra.eventDate}] ` : "";
|
|
24
|
+
return `- [${entry.category}] ${datePrefix}${safe} (${scoreStr}${sourceTag})`;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { formatAtDepth };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region src/engine/retrieval/retrieval-gate.ts
|
|
2
|
+
/** @file retrieval-gate.ts
|
|
3
|
+
* @purpose Decides whether a query needs memory retrieval at all (skip vs proceed).
|
|
4
|
+
* @boundary Intent analysis, temporal classification, and retrieval configuration.
|
|
5
|
+
* @see intent-analyzer.ts, memory-temporality-classifier.ts, retriever.ts.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Retrieval Gate
|
|
9
|
+
* Determines whether a query needs memory retrieval at all.
|
|
10
|
+
* Skips retrieval for greetings, commands, simple instructions, and system messages.
|
|
11
|
+
* Saves embedding API calls and reduces noise injection.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Strip SnoStationMem metadata headers, cron wrappers, and timestamp prefixes
|
|
15
|
+
* so that the raw user intent is what gets evaluated by skip/force patterns.
|
|
16
|
+
*/
|
|
17
|
+
function normalizeQuery(raw) {
|
|
18
|
+
let q = raw;
|
|
19
|
+
q = q.replace(/^(Conversation info|Sender) \(untrusted metadata\):[\s\S]*?\n\s*\n/gim, "");
|
|
20
|
+
q = q.replace(/\[cron:[^\]]*\]\s*/gi, "");
|
|
21
|
+
q = q.replace(/\[\w{3}\s+\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}(?:\s+[\w/+-]+)?\]\s*/g, "");
|
|
22
|
+
return q.trim();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The floor below which there is nothing to search FOR — not a judgement about whether a query
|
|
26
|
+
* deserves a search. Mirrors the `autoRecallMinLength` default in the plugin config schema; the
|
|
27
|
+
* two must not drift.
|
|
28
|
+
*/
|
|
29
|
+
const RETRIEVAL_MIN_QUERY_CHARS = 2;
|
|
30
|
+
/**
|
|
31
|
+
* Decide whether a query is too short to search on. Length only.
|
|
32
|
+
*
|
|
33
|
+
* There is deliberately NO pattern list here. Until 2026-08-21 this function also read 118 skip
|
|
34
|
+
* and force-retrieve regexes across nine locale bundles, and a match on a negative one meant the
|
|
35
|
+
* turn was never searched at all — a keyword deciding the control flow, which is the shape this
|
|
36
|
+
* repository forbids. Retrieval is a local SQLite plus local-embedding search; the cost argument
|
|
37
|
+
* that justified a gate does not hold, and whether a result is relevant belongs to scoring.
|
|
38
|
+
*
|
|
39
|
+
* @param minLength - Override minimum length threshold (for autoRecallMinLength support).
|
|
40
|
+
*/
|
|
41
|
+
function shouldSkipRetrieval(query, minLength) {
|
|
42
|
+
const trimmed = normalizeQuery(query);
|
|
43
|
+
const effectiveMinLength = minLength ?? RETRIEVAL_MIN_QUERY_CHARS;
|
|
44
|
+
return trimmed.length < effectiveMinLength && !trimmed.includes("?") && !trimmed.includes("?");
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { normalizeQuery, shouldSkipRetrieval };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as RerankFallbackSignal, c as collectParallelStage, d as RetrievalConfig, f as RetrievalContext, i as RerankFallbackReason, l as DEFAULT_RETRIEVAL_CONFIG, n as MemoryRetrieverInternals, o as RerankOutcome, p as withServingValidityDefault, r as RERANK_FALLBACK_REASONS, s as createRetriever, t as MemoryRetriever, u as RerankProvider } from "../../../retriever-Dxss5fRv.js";
|
|
2
|
+
export { DEFAULT_RETRIEVAL_CONFIG, MemoryRetriever, MemoryRetrieverInternals, RERANK_FALLBACK_REASONS, RerankFallbackReason, RerankFallbackSignal, RerankOutcome, RerankProvider, RetrievalConfig, RetrievalContext, collectParallelStage, createRetriever, withServingValidityDefault };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as DEFAULT_RETRIEVAL_CONFIG, i as createRetriever, n as MemoryRetriever, o as withServingValidityDefault, r as RERANK_FALLBACK_REASONS, t as collectParallelStage } from "../../../retriever-ZoLvPRHq.js";
|
|
2
|
+
export { DEFAULT_RETRIEVAL_CONFIG, MemoryRetriever, RERANK_FALLBACK_REASONS, collectParallelStage, createRetriever, withServingValidityDefault };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { redactForStorage } from "@snoai/content-sanitizer";
|
|
2
|
+
//#region src/engine/security/redact.ts
|
|
3
|
+
/** @file redact.ts
|
|
4
|
+
* @purpose Redacts sensitive values before logs, diagnostics, or model-visible text.
|
|
5
|
+
* @boundary Security boundaries, capture payloads, and CLI output hygiene.
|
|
6
|
+
* @see capture-policy-detector.ts, memory-management-cli.ts, memory-tool-registration.ts.
|
|
7
|
+
*/
|
|
8
|
+
const REDACTED_SECRET = "[REDACTED_SECRET]";
|
|
9
|
+
const NAMED_CREDENTIAL_PATTERN = /\b[A-Za-z0-9]+_(?:live|key|secret|token)_[A-Za-z0-9][A-Za-z0-9_-]{11,}\b/gi;
|
|
10
|
+
const LABELED_CREDENTIAL_PATTERN = /\b((?:api[\s_-]*key|access[\s_-]*token|refresh[\s_-]*token|auth[\s_-]*token|password|passphrase|secret|credential|token)\s*(?:is|was|=|:)\s*)([A-Za-z0-9][A-Za-z0-9._/+=$:-]{11,})/gi;
|
|
11
|
+
const LONG_ALPHANUMERIC_PATTERN = /\b[A-Za-z0-9]{32,}\b/g;
|
|
12
|
+
function isHighEntropyCredentialCandidate(value) {
|
|
13
|
+
if (/^[A-Fa-f0-9]+$/.test(value)) return false;
|
|
14
|
+
if (!/[A-Za-z]/.test(value) || !/\d/.test(value)) return false;
|
|
15
|
+
const counts = /* @__PURE__ */ new Map();
|
|
16
|
+
for (const character of value) counts.set(character, (counts.get(character) ?? 0) + 1);
|
|
17
|
+
return [...counts.values()].reduce((total, count) => {
|
|
18
|
+
const probability = count / value.length;
|
|
19
|
+
return total - probability * Math.log2(probability);
|
|
20
|
+
}, 0) >= 3.2;
|
|
21
|
+
}
|
|
22
|
+
function redactGenericCredentials(text) {
|
|
23
|
+
return text.replace(NAMED_CREDENTIAL_PATTERN, REDACTED_SECRET).replace(LABELED_CREDENTIAL_PATTERN, (_match, label) => `${label}${REDACTED_SECRET}`).replace(LONG_ALPHANUMERIC_PATTERN, (value) => isHighEntropyCredentialCandidate(value) ? REDACTED_SECRET : value);
|
|
24
|
+
}
|
|
25
|
+
/** Redacts provider-specific and conservative generic credential forms. */
|
|
26
|
+
function redactSecrets(text) {
|
|
27
|
+
const providerRedacted = redactForStorage(text, {
|
|
28
|
+
source: "generic-text",
|
|
29
|
+
contentType: "plain_text"
|
|
30
|
+
}).text;
|
|
31
|
+
return redactGenericCredentials(providerRedacted);
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { redactSecrets };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as ScopeConfig, i as SCOPE_PATTERNS, n as createScopePolicy, o as ScopeDefinition, r as DEFAULT_SCOPE_CONFIG, s as ScopePolicy, t as MemoryScopePolicy } from "../../../memory-scope-policy-1gg5QlWZ.js";
|
|
2
|
+
import { a as createCustomScope, c as filterScopesForAgent, d as resolveScopeFilter, i as createAgentScope, l as isScopeAccessible, n as isSystemBypassId, o as createProjectScope, r as parseAgentIdFromSessionKey, s as createUserScope, t as _resetLegacyFallbackWarningState, u as parseScopeId } from "../../../scopes-CtrY-YQ3.js";
|
|
3
|
+
export { DEFAULT_SCOPE_CONFIG, MemoryScopePolicy, SCOPE_PATTERNS, type ScopeConfig, type ScopeDefinition, type ScopePolicy, _resetLegacyFallbackWarningState, createAgentScope, createCustomScope, createProjectScope, createScopePolicy, createUserScope, filterScopesForAgent, isScopeAccessible, isSystemBypassId, parseAgentIdFromSessionKey, parseScopeId, resolveScopeFilter };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as parseAgentIdFromSessionKey, c as SCOPE_PATTERNS, i as isSystemBypassId, n as createScopePolicy, r as _resetLegacyFallbackWarningState, s as DEFAULT_SCOPE_CONFIG, t as MemoryScopePolicy } from "../../../memory-scope-policy-DICSCURA.js";
|
|
2
|
+
import { a as filterScopesForAgent, c as resolveScopeFilter, i as createUserScope, n as createCustomScope, o as isScopeAccessible, r as createProjectScope, s as parseScopeId, t as createAgentScope } from "../../../scopes-CSOn6zdd.js";
|
|
3
|
+
export { DEFAULT_SCOPE_CONFIG, MemoryScopePolicy, SCOPE_PATTERNS, _resetLegacyFallbackWarningState, createAgentScope, createCustomScope, createProjectScope, createScopePolicy, createUserScope, filterScopesForAgent, isScopeAccessible, isSystemBypassId, parseAgentIdFromSessionKey, parseScopeId, resolveScopeFilter };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
//#region src/engine/shared/errors.ts
|
|
2
|
+
/** @file errors.ts
|
|
3
|
+
* @purpose Defines typed plugin errors and stable codes for callers and CLI output.
|
|
4
|
+
* @boundary Runtime boundaries, CLI error mapping, and test assertions.
|
|
5
|
+
* @see memory-management-cli.ts, sno-station-mem-plugin-runtime.ts, memory-tool-registration.ts.
|
|
6
|
+
*/
|
|
7
|
+
var SnoStationMemError = class extends Error {
|
|
8
|
+
code;
|
|
9
|
+
/**
|
|
10
|
+
* Initializes typed error reporting collaborators while keeping runtime work in explicit
|
|
11
|
+
* methods.
|
|
12
|
+
*/
|
|
13
|
+
constructor(code, message, cause) {
|
|
14
|
+
super(message, cause ? { cause } : void 0);
|
|
15
|
+
this.name = "SnoStationMemError";
|
|
16
|
+
this.code = code;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var StorageError = class extends SnoStationMemError {
|
|
20
|
+
/**
|
|
21
|
+
* Initializes typed error reporting collaborators while keeping runtime work in explicit
|
|
22
|
+
* methods.
|
|
23
|
+
*/
|
|
24
|
+
constructor(message, cause) {
|
|
25
|
+
super("storage_error", message, cause);
|
|
26
|
+
this.name = "StorageError";
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var EmbeddingError = class extends SnoStationMemError {
|
|
30
|
+
/**
|
|
31
|
+
* Initializes typed error reporting collaborators while keeping runtime work in explicit
|
|
32
|
+
* methods.
|
|
33
|
+
*/
|
|
34
|
+
constructor(message, cause) {
|
|
35
|
+
super("embedding_error", message, cause);
|
|
36
|
+
this.name = "EmbeddingError";
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var RetrievalError = class extends SnoStationMemError {
|
|
40
|
+
/**
|
|
41
|
+
* Carries the cause's own message in `message`, not only in `cause`.
|
|
42
|
+
*
|
|
43
|
+
* Retrieval wraps every failure as "Failed to retrieve memories", and every consumer that
|
|
44
|
+
* reports one — a tool result, an eval harness, an HTTP boundary — reports `message` and drops
|
|
45
|
+
* the Error. Measured 2026-09-04: a whole evaluation round scored nothing and the only trace
|
|
46
|
+
* on disk was fifteen identical copies of that sentence, so the reason had to be re-derived by
|
|
47
|
+
* reproducing the run. The cause stays attached as well; this only makes it survive the trip.
|
|
48
|
+
*/
|
|
49
|
+
constructor(message, cause) {
|
|
50
|
+
const reason = cause instanceof Error ? cause.message : void 0;
|
|
51
|
+
super("retrieval_error", reason ? `${message}: ${reason}` : message, cause);
|
|
52
|
+
this.name = "RetrievalError";
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var ConfigError = class extends SnoStationMemError {
|
|
56
|
+
/**
|
|
57
|
+
* Initializes typed error reporting collaborators while keeping runtime work in explicit
|
|
58
|
+
* methods.
|
|
59
|
+
*/
|
|
60
|
+
constructor(message, cause) {
|
|
61
|
+
super("config_error", message, cause);
|
|
62
|
+
this.name = "ConfigError";
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
//#endregion
|
|
66
|
+
export { ConfigError, EmbeddingError, RetrievalError, SnoStationMemError, StorageError };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as stripRoleLabelPrefix, c as unicodeBoundaryRegex, i as stripHtmlTags, n as boundaryAwareRegex, o as tokenizeForFts, r as normalizeForCompare, s as truncateGraphemes, t as HTML_TAG_PATTERN } from "../../../i18n-text-DbD6Qify.js";
|
|
2
|
+
export { HTML_TAG_PATTERN, boundaryAwareRegex, normalizeForCompare, stripHtmlTags, stripRoleLabelPrefix, tokenizeForFts, truncateGraphemes, unicodeBoundaryRegex };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//#region src/engine/shared/i18n-text.ts
|
|
2
|
+
/** @file i18n-text.ts
|
|
3
|
+
* @purpose Shared Unicode-aware text helpers for multilingual memory paths.
|
|
4
|
+
* @boundary Pure string/RegExp helpers only; no locale detection or persistence.
|
|
5
|
+
*/
|
|
6
|
+
const REGEXP_SPECIAL_CHARS = /[.*+?^${}()|[\]\\]/g;
|
|
7
|
+
const CJK_CHAR_PATTERN = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u;
|
|
8
|
+
const LETTER_OR_NUMBER = String.raw`[\p{L}\p{N}]`;
|
|
9
|
+
const HTML_TAG_PATTERN = /<!--[\s\S]*?(?:-->|$)|<\/?[A-Za-z][^>]*>/g;
|
|
10
|
+
const ROLE_LABEL_PREFIX_PATTERN = /(^|\n)([ \t]*)(system|assistant|user|developer|tool|function)\s*:/giu;
|
|
11
|
+
function withUnicodeFlag(flags) {
|
|
12
|
+
return flags.includes("u") ? flags : `${flags}u`;
|
|
13
|
+
}
|
|
14
|
+
function escapeRegExp(term) {
|
|
15
|
+
return term.replace(REGEXP_SPECIAL_CHARS, "\\$&");
|
|
16
|
+
}
|
|
17
|
+
function splitGraphemes(text) {
|
|
18
|
+
if (typeof Intl.Segmenter !== "function") return [...text];
|
|
19
|
+
return [...new Intl.Segmenter(void 0, { granularity: "grapheme" }).segment(text)].map((segment) => segment.segment);
|
|
20
|
+
}
|
|
21
|
+
/** Builds a Unicode-aware left/right token-boundary regex around a regex body. */
|
|
22
|
+
function unicodeBoundaryRegex(body, flags = "i") {
|
|
23
|
+
return new RegExp(`(?<!${LETTER_OR_NUMBER})(?:${body})(?!${LETTER_OR_NUMBER})`, withUnicodeFlag(flags));
|
|
24
|
+
}
|
|
25
|
+
/** Matches CJK terms by substring and alphabetic terms by Unicode token boundaries. */
|
|
26
|
+
function boundaryAwareRegex(term, flags = "i") {
|
|
27
|
+
const trimmed = term.trim();
|
|
28
|
+
if (!trimmed) return /(?!)/u;
|
|
29
|
+
const escaped = escapeRegExp(trimmed);
|
|
30
|
+
if (CJK_CHAR_PATTERN.test(trimmed)) return new RegExp(escaped, withUnicodeFlag(flags));
|
|
31
|
+
return unicodeBoundaryRegex(escaped, flags);
|
|
32
|
+
}
|
|
33
|
+
function stripHtmlTags(text) {
|
|
34
|
+
return text.replace(HTML_TAG_PATTERN, "");
|
|
35
|
+
}
|
|
36
|
+
function stripRoleLabelPrefix(text) {
|
|
37
|
+
return text.replace(ROLE_LABEL_PREFIX_PATTERN, "$1$2[$3]:");
|
|
38
|
+
}
|
|
39
|
+
function normalizeForCompare(text) {
|
|
40
|
+
return text.normalize("NFKC").toLocaleLowerCase().replace(/\s+/gu, " ").trim();
|
|
41
|
+
}
|
|
42
|
+
function truncateGraphemes(text, maxGraphemes, suffix = "") {
|
|
43
|
+
if (maxGraphemes <= 0) return "";
|
|
44
|
+
const graphemes = splitGraphemes(text);
|
|
45
|
+
if (graphemes.length <= maxGraphemes) return text;
|
|
46
|
+
return `${graphemes.slice(0, maxGraphemes).join("").trimEnd()}${suffix}`;
|
|
47
|
+
}
|
|
48
|
+
function tokenizeForFts(rawQuery) {
|
|
49
|
+
const normalized = normalizeForCompare(rawQuery).replace(/["']/gu, " ").replace(/[^\p{L}\p{N}\s_-]/gu, " ").trim();
|
|
50
|
+
if (!normalized) return [];
|
|
51
|
+
if (typeof Intl.Segmenter === "function") {
|
|
52
|
+
const tokens = [...new Intl.Segmenter(void 0, { granularity: "word" }).segment(normalized)].filter((segment) => segment.isWordLike).map((segment) => segment.segment);
|
|
53
|
+
if (tokens.length > 0) return tokens;
|
|
54
|
+
}
|
|
55
|
+
return normalized.split(/\s+/u).filter(Boolean);
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { HTML_TAG_PATTERN, boundaryAwareRegex, normalizeForCompare, stripHtmlTags, stripRoleLabelPrefix, tokenizeForFts, truncateGraphemes, unicodeBoundaryRegex };
|