@snoai/memory 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +176 -0
- package/README.md +7 -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-CSc21GtV.d.ts +110 -0
- package/dist/adapter-DMEmCTKo.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-BpOUWPJM.d.ts +327 -0
- package/dist/atomic-memory-extraction-sdNf1-B1.js +3605 -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-CHz5GOPA.d.ts +53 -0
- package/dist/capture-policy-detector-DaMfy9CZ.js +357 -0
- package/dist/classifier-C96uH9OF.d.ts +272 -0
- package/dist/client.d.ts +34 -0
- package/dist/client.js +305 -0
- package/dist/coding-skin.d.ts +51 -0
- package/dist/coding-skin.js +55 -0
- package/dist/config-tSrvLXgV.js +2577 -0
- package/dist/connection-DAbzki8K.d.ts +391 -0
- package/dist/connection-DliCOBB2.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-CYniFp8b.js +172 -0
- package/dist/data-bootstrap-CcJUwkqf.d.ts +30 -0
- package/dist/data-paths-C7sNdqvP.d.ts +22 -0
- package/dist/derived-suppression-cache-C7bGARc0.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-BsMap4It.d.ts +650 -0
- package/dist/index-DL8AVj0Z.d.ts +571 -0
- package/dist/index-DQ7VL6d3.d.ts +350 -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 +61 -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 +37 -0
- package/dist/internal/engine/bindings/sno-station-mem-runtime-mode.js +105 -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-B7Xoxqou.js +1378 -0
- package/dist/llm-client-DOTSGzhe.d.ts +51 -0
- package/dist/locales-JxGmkG6t.d.ts +7 -0
- package/dist/log-site-catalog.generated-B9WYdnAM.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-LKt0u3gy.d.ts +23 -0
- package/dist/memory-metadata-codec-C3oQd47V.d.ts +68 -0
- package/dist/memory-metadata-codec-DL1sbJiN.js +577 -0
- package/dist/memory-runtime-BZtREuwW.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-3e44ND2i.d.ts +16 -0
- package/dist/memory-source-order-BtrIxaIt.js +134 -0
- package/dist/memory-store-base-XRA4S9Xl.d.ts +1095 -0
- package/dist/memory-store-shared-DeIDkhLj.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-CEdRTN5J.d.ts +43 -0
- package/dist/memory-temporality-classifier-CKiTAHXe.js +184 -0
- package/dist/memory-tier-promoter-DbTpahkP.d.ts +43 -0
- package/dist/memory-tool-dependencies-CLODycUw.js +19 -0
- package/dist/memory-tool-dependencies-N69chrQc.d.ts +14 -0
- package/dist/model-call-table-CspopkBg.js +563 -0
- package/dist/model-reply-text-CKopStP2.js +334 -0
- package/dist/observable-embedder-DQnNgf9O.d.ts +17 -0
- package/dist/observable-llm-client-uwqPADpN.d.ts +21 -0
- package/dist/observable-memory-store-BaZKbhgq.d.ts +73 -0
- package/dist/observable-retriever-Dt_NUxAA.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-hIphqpUY.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-BeQiJI9-.js +644 -0
- package/dist/reflection-command-hooks-C1Vxgb-O.d.ts +32 -0
- package/dist/reflection-deps-RpLPFrSc.d.ts +19 -0
- package/dist/reflection-embedded-generator-CDUhgV96.js +130 -0
- package/dist/reflection-embedded-generator-CxOex5xK.d.ts +14 -0
- package/dist/reflection-injection-hooks-DfUgqu8f.d.ts +43 -0
- package/dist/reflection-lifecycle-hooks-Ct5HBdSG.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-Cbm5gfSe.js +31644 -0
- package/dist/rem-batch-executor-bc0IFlp2.js +2 -0
- package/dist/rem-consumer-retrieval-CRpvG8KS.js +246 -0
- package/dist/rem-trigger-BTxkcjgT.js +729 -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-CygHBazG.js +1757 -0
- package/dist/retriever-Ruk3zp7_.d.ts +469 -0
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/routes-Ce7SQKec.js +59 -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-BPAY4NTG.js +1410 -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-Bu-MiqPX.d.ts +31 -0
- package/dist/sno-station-mem-runtime-dependencies-DjLOhB45.js +30 -0
- package/dist/sqlite-runtime-L_ywirTm.d.ts +58 -0
- package/dist/store-2pM0-dZg.d.ts +27 -0
- package/dist/store-DzpZBMEm.js +5830 -0
- package/dist/strategy-hook-runner-gBtU47tX.d.ts +16 -0
- package/dist/strategy-hook-runner-zmdIYOmQ.js +110 -0
- package/dist/token-counter-BD1f48Km.js +73 -0
- package/dist/trace-1t1n_wUm.d.ts +86 -0
- package/dist/types-DxKqU60b.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,94 @@
|
|
|
1
|
+
import { LocalEmbedDtype, LocalEmbedSessionOptions } from "@snoai/embedder";
|
|
2
|
+
//#region src/engine/extraction/embedding-provider-factory.d.ts
|
|
3
|
+
type EmbeddingProviderKind = "local-onnx";
|
|
4
|
+
interface EmbeddingConfig {
|
|
5
|
+
/** Which provider to instantiate. Defaults to local-onnx. */
|
|
6
|
+
provider?: EmbeddingProviderKind;
|
|
7
|
+
/** Hugging Face model id. Defaults to the bundled PPLX INT8 model. */
|
|
8
|
+
model?: string;
|
|
9
|
+
/** Output dimension. Smaller values truncate and re-normalize the native vector. */
|
|
10
|
+
dimensions?: number;
|
|
11
|
+
/** Native model dimension. Defaults to 1024 for bundled PPLX. */
|
|
12
|
+
nativeDim?: number;
|
|
13
|
+
/** Pinned HuggingFace revision SHA for local-onnx (defaults to bundled 0.6B revision). */
|
|
14
|
+
revision?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Pooling strategy for local-onnx. Defaults to `mean` for bundled PPLX.
|
|
17
|
+
* Read the model's `1_Pooling/config.json`.
|
|
18
|
+
*/
|
|
19
|
+
pooling?: "last_token" | "mean" | "cls";
|
|
20
|
+
normalized?: boolean;
|
|
21
|
+
/** Local ONNX model cache directory (default: ./embedding/models) */
|
|
22
|
+
cacheDir?: string;
|
|
23
|
+
offline?: boolean;
|
|
24
|
+
mirror?: string;
|
|
25
|
+
/** Quantization dtype. Default: q8. */
|
|
26
|
+
dtype?: LocalEmbedDtype;
|
|
27
|
+
/** ONNX Runtime session options for local low-memory operation. */
|
|
28
|
+
sessionOptions?: LocalEmbedSessionOptions;
|
|
29
|
+
/** Enable text chunking for long passages (default: true) */
|
|
30
|
+
chunking?: boolean;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/engine/extraction/embedding-provider-client.d.ts
|
|
34
|
+
declare class Embedder {
|
|
35
|
+
private readonly provider;
|
|
36
|
+
private readonly chunkingEnabled;
|
|
37
|
+
readonly dimensions: number;
|
|
38
|
+
readonly providerKind: EmbeddingProviderKind;
|
|
39
|
+
readonly model: string;
|
|
40
|
+
private warmupPromise;
|
|
41
|
+
private readonly modelDownload;
|
|
42
|
+
/**
|
|
43
|
+
* Initializes embedding generation collaborators while keeping runtime work in explicit
|
|
44
|
+
* methods.
|
|
45
|
+
*/
|
|
46
|
+
constructor(config: EmbeddingConfig, _stateDir: string);
|
|
47
|
+
/** Converts float32 into the transport shape expected by embedding generation. */
|
|
48
|
+
private toFloat32;
|
|
49
|
+
private buildEmbedderChunkConfig;
|
|
50
|
+
/**
|
|
51
|
+
* Exact token count under the embedding model's own tokenizer — the count the model
|
|
52
|
+
* sees, so `DEFAULT_MAX_CONTEXT_TOKENS` checked against it is a hard limit. Synchronous;
|
|
53
|
+
* throws until the model has loaded, which `warmup()` does at plugin register time.
|
|
54
|
+
*/
|
|
55
|
+
countTokens(text: string): number;
|
|
56
|
+
/** Longest prefix of `text` within `maxTokens` under {@link countTokens}. */
|
|
57
|
+
truncateToTokens(text: string, maxTokens: number): string;
|
|
58
|
+
/**
|
|
59
|
+
* Wait for warmup before issuing real embedding work. Calls `warmup()`
|
|
60
|
+
* itself so callers that bypass register-time warmup (tests, ad-hoc
|
|
61
|
+
* scripts) still get the same fail-loud probe — `warmup()` is memoized,
|
|
62
|
+
* so repeated calls reuse the in-flight or completed promise.
|
|
63
|
+
*/
|
|
64
|
+
private awaitWarmup;
|
|
65
|
+
/** Implements embed as the local embedding generation operation. */
|
|
66
|
+
embed(text: string): Promise<Float32Array>;
|
|
67
|
+
/** Implements embed direct as the local embedding generation operation. */
|
|
68
|
+
protected embedDirect(text: string): Promise<Float32Array>;
|
|
69
|
+
/** Implements embed many as the local embedding generation operation. */
|
|
70
|
+
embedMany(values: string[]): Promise<Float32Array[]>;
|
|
71
|
+
/**
|
|
72
|
+
* Embed each input text individually as a passage. Used by chunk-level
|
|
73
|
+
* ingestion in `MemoryStore` — one vector per chunk, no averaging. Reuses
|
|
74
|
+
* the batch primitive and its cache.
|
|
75
|
+
*/
|
|
76
|
+
embedChunks(texts: string[]): Promise<Float32Array[]>;
|
|
77
|
+
/**
|
|
78
|
+
* Force the underlying ONNX model to load and run one real inference.
|
|
79
|
+
*
|
|
80
|
+
* LocalEmbedProvider lazy-loads the model on first `embed()` call. That
|
|
81
|
+
* means `new Embedder(...)` succeeds even if the model file is missing —
|
|
82
|
+
* the failure only surfaces later, per-turn, during ambient-learning, where
|
|
83
|
+
* the error is swallowed by `Promise.allSettled`. Calling `warmup()` at
|
|
84
|
+
* plugin-register time turns a latent misconfiguration into a hard,
|
|
85
|
+
* loud registration failure. Caller should let the error propagate.
|
|
86
|
+
*/
|
|
87
|
+
warmup(): Promise<void>;
|
|
88
|
+
/** Implements dispose as the local embedding generation operation. */
|
|
89
|
+
dispose(): Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
/** Creates the embedder facade around the local ONNX provider. */
|
|
92
|
+
declare function createEmbedder(config: EmbeddingConfig, stateDir: string): Embedder;
|
|
93
|
+
//#endregion
|
|
94
|
+
export { EmbeddingProviderKind as i, createEmbedder as n, EmbeddingConfig as r, Embedder as t };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/engine/reflection/entry-metadata-parser.ts
|
|
2
|
+
/** @file entry-metadata-parser.ts
|
|
3
|
+
* @purpose Defines metadata helpers for reflection provenance, severity, and grouping.
|
|
4
|
+
* @boundary Reflection item storage, retry handling, and reporting surfaces.
|
|
5
|
+
* @see daily-log-generator.ts, slice-item-payload-builder.ts, transient-generation-retry.ts.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Reflection metadata parsing utilities.
|
|
9
|
+
*/
|
|
10
|
+
function parseReflectionMetadata(metadataRaw) {
|
|
11
|
+
if (!metadataRaw) return {};
|
|
12
|
+
try {
|
|
13
|
+
const parsed = JSON.parse(metadataRaw);
|
|
14
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
15
|
+
} catch {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { parseReflectionMetadata as t };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/contract/error.ts
|
|
2
|
+
const DEGRADED_REASONS = [
|
|
3
|
+
"sidecar-unreachable",
|
|
4
|
+
"sidecar-unresponsive",
|
|
5
|
+
"principal-mismatch",
|
|
6
|
+
"store-mismatch",
|
|
7
|
+
"no-agent-endpoint",
|
|
8
|
+
"invalid-input",
|
|
9
|
+
"timeout",
|
|
10
|
+
"storage-unavailable",
|
|
11
|
+
"engine-failed"
|
|
12
|
+
];
|
|
13
|
+
var ContractError = class extends Error {
|
|
14
|
+
reason;
|
|
15
|
+
degraded = true;
|
|
16
|
+
constructor(reason, message = reason) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.reason = reason;
|
|
19
|
+
this.name = "ContractError";
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { DEGRADED_REASONS as n, ContractError as t };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/engine/security/error-signals.d.ts
|
|
2
|
+
type ReflectionErrorSignal = {
|
|
3
|
+
at: number;
|
|
4
|
+
toolName: string;
|
|
5
|
+
summary: string;
|
|
6
|
+
source: "tool_error" | "tool_output";
|
|
7
|
+
signature: string;
|
|
8
|
+
signatureHash: string;
|
|
9
|
+
};
|
|
10
|
+
type ReflectionErrorState = {
|
|
11
|
+
entries: ReflectionErrorSignal[];
|
|
12
|
+
lastInjectedCount: number;
|
|
13
|
+
signatureSet: Set<string>;
|
|
14
|
+
updatedAt: number;
|
|
15
|
+
};
|
|
16
|
+
type CreateErrorSignalTrackerOptions = {
|
|
17
|
+
maxTrackedSessions?: number;
|
|
18
|
+
};
|
|
19
|
+
/** Creates the per-session tracker that batches runtime errors for reflection feedback. */
|
|
20
|
+
declare function createErrorSignalTracker(options?: CreateErrorSignalTrackerOptions): {
|
|
21
|
+
getState: (sessionKey: string) => ReflectionErrorState;
|
|
22
|
+
addSignal: (sessionKey: string, signal: ReflectionErrorSignal, dedupeEnabled: boolean) => void;
|
|
23
|
+
getPendingSignals: (sessionKey: string, maxEntries: number) => ReflectionErrorSignal[];
|
|
24
|
+
clearSession: (sessionKey: string) => void;
|
|
25
|
+
prune: (ttlMs: number, maxSessions: number) => void;
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { createErrorSignalTracker as n, ReflectionErrorSignal as t };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import "./internal/config/index.js";
|
|
2
|
+
import { redactSecrets } from "./internal/engine/security/redact.js";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
//#region src/engine/security/error-signals.ts
|
|
5
|
+
/** @file error-signals.ts
|
|
6
|
+
* @purpose Classifies error-like text patterns used by capture and retrieval heuristics.
|
|
7
|
+
* @boundary Multilingual runtime regexes and operational signal extraction.
|
|
8
|
+
* @see capture-policy-detector.ts, intent-analyzer.ts, memory-noise-classifier.ts.
|
|
9
|
+
*/
|
|
10
|
+
const ERROR_SIGNAL_PATTERNS = [
|
|
11
|
+
/\[error\]|error:|exception:|fatal:|traceback|syntaxerror|typeerror|referenceerror|npm err!/,
|
|
12
|
+
/command not found|no such file|permission denied|non-zero|exit code/,
|
|
13
|
+
/"status"\s*:\s*"error"|"status"\s*:\s*"failed"|\biserror\b/,
|
|
14
|
+
/错误\s*[::]|异常\s*[::]|报错\s*[::]|失败\s*[::]/
|
|
15
|
+
];
|
|
16
|
+
const SUMMARY_MAX_LEN = 220;
|
|
17
|
+
const SIGNATURE_MAX_LEN = 240;
|
|
18
|
+
const MAX_ENTRIES_PER_SESSION = 30;
|
|
19
|
+
/** Implements touch session state as the local runtime error signal extraction operation. */
|
|
20
|
+
function touchSessionState(sessions, key, state) {
|
|
21
|
+
sessions.delete(key);
|
|
22
|
+
sessions.set(key, state);
|
|
23
|
+
return state;
|
|
24
|
+
}
|
|
25
|
+
/** Filters oldest sessions before it affects runtime error signal extraction decisions. */
|
|
26
|
+
function pruneOldestSessions(sessions, maxSessions) {
|
|
27
|
+
const cappedMaxSessions = Math.max(0, maxSessions);
|
|
28
|
+
while (sessions.size > cappedMaxSessions) {
|
|
29
|
+
const oldestKey = sessions.keys().next().value;
|
|
30
|
+
if (oldestKey === void 0) break;
|
|
31
|
+
sessions.delete(oldestKey);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** Implements contains error signal as the local runtime error signal extraction operation. */
|
|
35
|
+
function containsErrorSignal(text) {
|
|
36
|
+
const normalized = text.toLowerCase();
|
|
37
|
+
return ERROR_SIGNAL_PATTERNS.some((p) => p.test(normalized));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Normalizes error signature at the boundary before runtime error signal extraction uses it.
|
|
41
|
+
*/
|
|
42
|
+
function normalizeErrorSignature(text) {
|
|
43
|
+
return redactSecrets(String(text || "")).toLowerCase().replace(/[a-z]:\\[^ \n\r\t]+/gi, "<path>").replace(/\/[^ \n\r\t]+/g, "<path>").replace(/\b0x[0-9a-f]+\b/gi, "<hex>").replace(/\b\d+\b/g, "<n>").replace(/\s+/g, " ").trim().slice(0, SIGNATURE_MAX_LEN);
|
|
44
|
+
}
|
|
45
|
+
/** Implements summarize error text as the local runtime error signal extraction operation. */
|
|
46
|
+
function summarizeErrorText(text, maxLen = SUMMARY_MAX_LEN) {
|
|
47
|
+
const oneLine = redactSecrets(text).replace(/\s+/g, " ").trim();
|
|
48
|
+
if (!oneLine) return "(empty tool error)";
|
|
49
|
+
return oneLine.length <= maxLen ? oneLine : `${oneLine.slice(0, maxLen - 3)}...`;
|
|
50
|
+
}
|
|
51
|
+
/** Implements sha256 hex as the local runtime error signal extraction operation. */
|
|
52
|
+
function sha256Hex(text) {
|
|
53
|
+
return createHash("sha256").update(text, "utf8").digest("hex");
|
|
54
|
+
}
|
|
55
|
+
/** Extracts text from tool result from raw inputs while tolerating partial data. */
|
|
56
|
+
function extractTextFromToolResult(result) {
|
|
57
|
+
if (result == null) return "";
|
|
58
|
+
if (typeof result === "string") return result;
|
|
59
|
+
if (typeof result !== "object") return "";
|
|
60
|
+
const obj = result;
|
|
61
|
+
const content = obj.content;
|
|
62
|
+
if (!Array.isArray(content)) return typeof obj.text === "string" ? obj.text : "";
|
|
63
|
+
const parts = [];
|
|
64
|
+
for (const item of content) {
|
|
65
|
+
if (!item || typeof item !== "object") continue;
|
|
66
|
+
const rec = item;
|
|
67
|
+
if (rec.type === "text" && typeof rec.text === "string") parts.push(rec.text);
|
|
68
|
+
}
|
|
69
|
+
return parts.join("\n");
|
|
70
|
+
}
|
|
71
|
+
/** Creates the per-session tracker that batches runtime errors for reflection feedback. */
|
|
72
|
+
function createErrorSignalTracker(options = {}) {
|
|
73
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
74
|
+
const maxTrackedSessions = Math.max(0, options.maxTrackedSessions ?? 200);
|
|
75
|
+
/** Returns state from runtime error signal extraction state without side effects. */
|
|
76
|
+
const getState = (sessionKey) => {
|
|
77
|
+
const key = sessionKey.trim();
|
|
78
|
+
const current = sessions.get(key);
|
|
79
|
+
if (current) {
|
|
80
|
+
current.updatedAt = Date.now();
|
|
81
|
+
return touchSessionState(sessions, key, current);
|
|
82
|
+
}
|
|
83
|
+
pruneOldestSessions(sessions, Math.max(0, maxTrackedSessions - 1));
|
|
84
|
+
return touchSessionState(sessions, key, {
|
|
85
|
+
entries: [],
|
|
86
|
+
lastInjectedCount: 0,
|
|
87
|
+
signatureSet: /* @__PURE__ */ new Set(),
|
|
88
|
+
updatedAt: Date.now()
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
getState,
|
|
93
|
+
/** Adds signal to the local runtime error signal extraction accumulator. */
|
|
94
|
+
addSignal(sessionKey, signal, dedupeEnabled) {
|
|
95
|
+
if (!sessionKey.trim()) return;
|
|
96
|
+
const state = getState(sessionKey);
|
|
97
|
+
if (dedupeEnabled && state.signatureSet.has(signal.signatureHash)) return;
|
|
98
|
+
state.entries.push(signal);
|
|
99
|
+
state.signatureSet.add(signal.signatureHash);
|
|
100
|
+
state.updatedAt = Date.now();
|
|
101
|
+
if (state.entries.length > MAX_ENTRIES_PER_SESSION) {
|
|
102
|
+
const removed = state.entries.length - MAX_ENTRIES_PER_SESSION;
|
|
103
|
+
state.entries.splice(0, removed);
|
|
104
|
+
state.lastInjectedCount = Math.max(0, state.lastInjectedCount - removed);
|
|
105
|
+
state.signatureSet = new Set(state.entries.map((e) => e.signatureHash));
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
/** Drains the not-yet-injected error signals, advancing the injection marker so callers never re-receive them. */
|
|
109
|
+
getPendingSignals(sessionKey, maxEntries) {
|
|
110
|
+
if (maxEntries <= 0) return [];
|
|
111
|
+
const key = sessionKey.trim();
|
|
112
|
+
const state = sessions.get(key);
|
|
113
|
+
if (!state) return [];
|
|
114
|
+
state.updatedAt = Date.now();
|
|
115
|
+
touchSessionState(sessions, key, state);
|
|
116
|
+
const start = Math.min(Math.max(0, state.lastInjectedCount), state.entries.length);
|
|
117
|
+
const pending = state.entries.slice(start);
|
|
118
|
+
state.lastInjectedCount = state.entries.length;
|
|
119
|
+
return pending.length > maxEntries ? pending.slice(-maxEntries) : pending;
|
|
120
|
+
},
|
|
121
|
+
/** Removes session while preserving runtime error signal extraction invariants. */
|
|
122
|
+
clearSession(sessionKey) {
|
|
123
|
+
sessions.delete(sessionKey.trim());
|
|
124
|
+
},
|
|
125
|
+
/** Implements prune as the local runtime error signal extraction operation. */
|
|
126
|
+
prune(ttlMs, maxSessions) {
|
|
127
|
+
const now = Date.now();
|
|
128
|
+
for (const [key, state] of sessions.entries()) if (now - state.updatedAt > ttlMs) sessions.delete(key);
|
|
129
|
+
pruneOldestSessions(sessions, maxSessions);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
export { sha256Hex as a, normalizeErrorSignature as i, createErrorSignalTracker as n, summarizeErrorText as o, extractTextFromToolResult as r, containsErrorSignal as t };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//#region src/engine/shared/errors.d.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
|
+
declare class SnoStationMemError extends Error {
|
|
8
|
+
readonly code: string;
|
|
9
|
+
/**
|
|
10
|
+
* Initializes typed error reporting collaborators while keeping runtime work in explicit
|
|
11
|
+
* methods.
|
|
12
|
+
*/
|
|
13
|
+
constructor(code: string, message: string, cause?: unknown);
|
|
14
|
+
}
|
|
15
|
+
declare class StorageError extends SnoStationMemError {
|
|
16
|
+
/**
|
|
17
|
+
* Initializes typed error reporting collaborators while keeping runtime work in explicit
|
|
18
|
+
* methods.
|
|
19
|
+
*/
|
|
20
|
+
constructor(message: string, cause?: unknown);
|
|
21
|
+
}
|
|
22
|
+
declare class EmbeddingError extends SnoStationMemError {
|
|
23
|
+
/**
|
|
24
|
+
* Initializes typed error reporting collaborators while keeping runtime work in explicit
|
|
25
|
+
* methods.
|
|
26
|
+
*/
|
|
27
|
+
constructor(message: string, cause?: unknown);
|
|
28
|
+
}
|
|
29
|
+
declare class RetrievalError extends SnoStationMemError {
|
|
30
|
+
/**
|
|
31
|
+
* Carries the cause's own message in `message`, not only in `cause`.
|
|
32
|
+
*
|
|
33
|
+
* Retrieval wraps every failure as "Failed to retrieve memories", and every consumer that
|
|
34
|
+
* reports one — a tool result, an eval harness, an HTTP boundary — reports `message` and drops
|
|
35
|
+
* the Error. Measured 2026-09-04: a whole evaluation round scored nothing and the only trace
|
|
36
|
+
* on disk was fifteen identical copies of that sentence, so the reason had to be re-derived by
|
|
37
|
+
* reproducing the run. The cause stays attached as well; this only makes it survive the trip.
|
|
38
|
+
*/
|
|
39
|
+
constructor(message: string, cause?: unknown);
|
|
40
|
+
}
|
|
41
|
+
declare class ConfigError extends SnoStationMemError {
|
|
42
|
+
/**
|
|
43
|
+
* Initializes typed error reporting collaborators while keeping runtime work in explicit
|
|
44
|
+
* methods.
|
|
45
|
+
*/
|
|
46
|
+
constructor(message: string, cause?: unknown);
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { StorageError as a, SnoStationMemError as i, EmbeddingError as n, RetrievalError as r, ConfigError as t };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/engine/extraction/extraction-text-sanitizer.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Keeps a section's clause list inside `DEFAULT_MAX_CONTEXT_TOKENS`, the repository-wide
|
|
4
|
+
* per-record ceiling the store refuses to write past.
|
|
5
|
+
*
|
|
6
|
+
* A profile section is one row by design (`getByFactKey` is singular), and merging appends, so
|
|
7
|
+
* a long-lived section grows without bound — measured 2026-09-14 on a real persona store, five
|
|
8
|
+
* successive versions of `preferences.general` ran 516 → 533 → 538 → 540 → 576 tokens. Past the
|
|
9
|
+
* ceiling the embedder and the reranker both truncate silently, so the tail of such a section is
|
|
10
|
+
* already invisible to retrieval; dropping it here is the same loss made honest, and it keeps the
|
|
11
|
+
* merge writing instead of throwing.
|
|
12
|
+
*
|
|
13
|
+
* Oldest clauses go first: `mergeProfileSection` seeds the map with the stored clauses and then
|
|
14
|
+
* the incoming ones, so insertion order runs oldest to newest. The abstract is kept whatever
|
|
15
|
+
* happens — it is the section's only summary and it leads the indexed text.
|
|
16
|
+
*/
|
|
17
|
+
declare function boundSectionContent(content: string, abstract: string, countRecordTokens: (text: string) => number): string;
|
|
18
|
+
/**
|
|
19
|
+
* Build the string that goes into the `text` column of `nodix_memories`.
|
|
20
|
+
*
|
|
21
|
+
* The FTS5 BM25 index is derived from this column only (see
|
|
22
|
+
* drizzle/0001_virtual_tables.sql). Concatenating abstract and content gives
|
|
23
|
+
* BM25 the same source surface used for vector embedding.
|
|
24
|
+
*/
|
|
25
|
+
declare function buildIndexedText(abstract: string, content: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Strip platform envelope metadata injected by SnoStationMem channels before the
|
|
28
|
+
* conversation text reaches the extraction LLM.
|
|
29
|
+
*/
|
|
30
|
+
declare function stripEnvelopeMetadata(text: string): string;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { buildIndexedText as n, stripEnvelopeMetadata as r, boundSectionContent as t };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/engine/shared/i18n-text.d.ts
|
|
2
|
+
declare const HTML_TAG_PATTERN: RegExp;
|
|
3
|
+
/** Builds a Unicode-aware left/right token-boundary regex around a regex body. */
|
|
4
|
+
declare function unicodeBoundaryRegex(body: string, flags?: string): RegExp;
|
|
5
|
+
/** Matches CJK terms by substring and alphabetic terms by Unicode token boundaries. */
|
|
6
|
+
declare function boundaryAwareRegex(term: string, flags?: string): RegExp;
|
|
7
|
+
declare function stripHtmlTags(text: string): string;
|
|
8
|
+
declare function stripRoleLabelPrefix(text: string): string;
|
|
9
|
+
declare function normalizeForCompare(text: string): string;
|
|
10
|
+
declare function truncateGraphemes(text: string, maxGraphemes: number, suffix?: string): string;
|
|
11
|
+
declare function tokenizeForFts(rawQuery: string): string[];
|
|
12
|
+
//#endregion
|
|
13
|
+
export { stripRoleLabelPrefix as a, unicodeBoundaryRegex as c, stripHtmlTags as i, boundaryAwareRegex as n, tokenizeForFts as o, normalizeForCompare as r, truncateGraphemes as s, HTML_TAG_PATTERN as t };
|