@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,67 @@
|
|
|
1
|
+
//#region src/engine/security/scope-policy-types.d.ts
|
|
2
|
+
/** @file scope-policy-types.ts
|
|
3
|
+
* @purpose Defines scope policy contracts, defaults, and identifier patterns.
|
|
4
|
+
* @boundary Types and static scope constants only.
|
|
5
|
+
*/
|
|
6
|
+
interface ScopeDefinition {
|
|
7
|
+
description?: string;
|
|
8
|
+
metadata?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
interface ScopeConfig {
|
|
11
|
+
default: string;
|
|
12
|
+
definitions: Record<string, ScopeDefinition>;
|
|
13
|
+
agentAccess: Record<string, string[]>;
|
|
14
|
+
extraAccessibleScopes: string[];
|
|
15
|
+
}
|
|
16
|
+
interface ScopePolicy {
|
|
17
|
+
getAccessibleScopes(agentId?: string): string[];
|
|
18
|
+
/** Store-layer filter: undefined = full bypass, [] = deny-all, array = restrict. */
|
|
19
|
+
getScopeFilter?(agentId?: string): string[] | undefined;
|
|
20
|
+
getDefaultScope(agentId?: string): string;
|
|
21
|
+
isAccessible(scope: string, agentId?: string): boolean;
|
|
22
|
+
validateScope(scope: string): boolean;
|
|
23
|
+
getAllScopes(): string[];
|
|
24
|
+
getScopeDefinition(scope: string): ScopeDefinition | undefined;
|
|
25
|
+
}
|
|
26
|
+
declare const DEFAULT_SCOPE_CONFIG: ScopeConfig;
|
|
27
|
+
declare const SCOPE_PATTERNS: {
|
|
28
|
+
readonly GLOBAL: "global";
|
|
29
|
+
readonly AGENT: (agentId: string) => string;
|
|
30
|
+
readonly CUSTOM: (name: string) => string;
|
|
31
|
+
readonly REFLECTION: (agentId: string) => string;
|
|
32
|
+
readonly PROJECT: (projectId: string) => string;
|
|
33
|
+
readonly USER: (userId: string) => string;
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/engine/security/memory-scope-policy.d.ts
|
|
37
|
+
declare class MemoryScopePolicy implements ScopePolicy {
|
|
38
|
+
private config;
|
|
39
|
+
private readonly warn?;
|
|
40
|
+
constructor(config?: Partial<ScopeConfig>, warn?: (message: string, fields?: Record<string, unknown>) => void);
|
|
41
|
+
private validateConfiguration;
|
|
42
|
+
private isBuiltInScope;
|
|
43
|
+
getAccessibleScopes(agentId?: string): string[];
|
|
44
|
+
resolveAgentScopes(agentId?: string): string[];
|
|
45
|
+
getScopeFilter(agentId?: string): string[] | undefined;
|
|
46
|
+
getDefaultScope(agentId?: string): string;
|
|
47
|
+
isAccessible(scope: string, agentId?: string): boolean;
|
|
48
|
+
validateScope(scope: string): boolean;
|
|
49
|
+
getAllScopes(): string[];
|
|
50
|
+
getScopeDefinition(scope: string): ScopeDefinition | undefined;
|
|
51
|
+
addScopeDefinition(scope: string, definition: ScopeDefinition): void;
|
|
52
|
+
removeScopeDefinition(scope: string): boolean;
|
|
53
|
+
setAgentAccess(agentId: string, scopes: string[]): void;
|
|
54
|
+
removeAgentAccess(agentId: string): boolean;
|
|
55
|
+
setExtraAccessibleScopes(scopes: string[]): void;
|
|
56
|
+
private validateScopeFormat;
|
|
57
|
+
exportConfig(): ScopeConfig;
|
|
58
|
+
importConfig(config: Partial<ScopeConfig>): void;
|
|
59
|
+
getStats(): {
|
|
60
|
+
totalScopes: number;
|
|
61
|
+
agentsWithCustomAccess: number;
|
|
62
|
+
scopesByType: Record<string, number>;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
declare function createScopePolicy(config?: Partial<ScopeConfig>, warn?: (message: string, fields?: Record<string, unknown>) => void): MemoryScopePolicy;
|
|
66
|
+
//#endregion
|
|
67
|
+
export { ScopeConfig as a, SCOPE_PATTERNS as i, createScopePolicy as n, ScopeDefinition as o, DEFAULT_SCOPE_CONFIG as r, ScopePolicy as s, MemoryScopePolicy as t };
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { createLogger } from "@snoai/utils/logger";
|
|
2
|
+
//#region src/engine/security/scope-policy-types.ts
|
|
3
|
+
const DEFAULT_SCOPE_CONFIG = {
|
|
4
|
+
default: "global",
|
|
5
|
+
definitions: { global: { description: "Shared knowledge across all agents" } },
|
|
6
|
+
agentAccess: {},
|
|
7
|
+
extraAccessibleScopes: []
|
|
8
|
+
};
|
|
9
|
+
const SCOPE_PATTERNS = {
|
|
10
|
+
GLOBAL: "global",
|
|
11
|
+
AGENT: (agentId) => `agent:${agentId}`,
|
|
12
|
+
CUSTOM: (name) => `custom:${name}`,
|
|
13
|
+
REFLECTION: (agentId) => `reflection:agent:${agentId}`,
|
|
14
|
+
PROJECT: (projectId) => `project:${projectId}`,
|
|
15
|
+
USER: (userId) => `user:${userId}`
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/engine/security/scope-identity.ts
|
|
19
|
+
/** @file scope-identity.ts
|
|
20
|
+
* @purpose Normalizes agent identities and configured access lists for scope policy.
|
|
21
|
+
* @boundary Identity parsing, bypass detection, and config normalization only.
|
|
22
|
+
*/
|
|
23
|
+
const log = createLogger("sno-station-mem:scopes");
|
|
24
|
+
const SYSTEM_BYPASS_IDS = /* @__PURE__ */ new Set(["system", "undefined"]);
|
|
25
|
+
const warnedLegacyFallbackBypassIds = /* @__PURE__ */ new Set();
|
|
26
|
+
const warnedLegacyStringBypassIds = /* @__PURE__ */ new Set();
|
|
27
|
+
function normalizeExtraAccessibleScopes(extraAccessibleScopes) {
|
|
28
|
+
if (!Array.isArray(extraAccessibleScopes)) return [];
|
|
29
|
+
const normalized = [];
|
|
30
|
+
const seen = /* @__PURE__ */ new Set();
|
|
31
|
+
for (const rawScope of extraAccessibleScopes) {
|
|
32
|
+
if (typeof rawScope !== "string") continue;
|
|
33
|
+
const scope = rawScope.trim();
|
|
34
|
+
if (!scope || seen.has(scope)) continue;
|
|
35
|
+
seen.add(scope);
|
|
36
|
+
normalized.push(scope);
|
|
37
|
+
}
|
|
38
|
+
return normalized;
|
|
39
|
+
}
|
|
40
|
+
function isSystemBypassId(agentId) {
|
|
41
|
+
if (typeof agentId !== "string") return false;
|
|
42
|
+
if (agentId === "undefined" && !warnedLegacyStringBypassIds.has(agentId)) {
|
|
43
|
+
warnedLegacyStringBypassIds.add(agentId);
|
|
44
|
+
log.warn("legacy string agentId bypass detected", { reason_code: "legacy_undefined_string" }, {
|
|
45
|
+
event_name: "sno_station_mem.scope-identity.legacy.string.agentid.bypass.detected",
|
|
46
|
+
file: "packages/memory/src/engine/security/scope-identity.ts",
|
|
47
|
+
function: "isSystemBypassId",
|
|
48
|
+
site_id: "scope-identity.isSystemBypassId.1d89371f35"
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return SYSTEM_BYPASS_IDS.has(agentId);
|
|
52
|
+
}
|
|
53
|
+
/** @internal Exported for tests that need to reset legacy warning throttles. */
|
|
54
|
+
function _resetLegacyFallbackWarningState() {
|
|
55
|
+
warnedLegacyFallbackBypassIds.clear();
|
|
56
|
+
warnedLegacyStringBypassIds.clear();
|
|
57
|
+
}
|
|
58
|
+
function shouldWarnLegacyFallbackBypassId(agentId) {
|
|
59
|
+
if (warnedLegacyFallbackBypassIds.has(agentId)) return false;
|
|
60
|
+
warnedLegacyFallbackBypassIds.add(agentId);
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
function parseAgentIdFromSessionKey(sessionKey) {
|
|
64
|
+
if (!sessionKey) return void 0;
|
|
65
|
+
const sk = sessionKey.trim();
|
|
66
|
+
if (!sk.startsWith("agent:")) return void 0;
|
|
67
|
+
const rest = sk.slice(6);
|
|
68
|
+
const colonIdx = rest.indexOf(":");
|
|
69
|
+
const candidate = (colonIdx === -1 ? rest : rest.slice(0, colonIdx)).trim();
|
|
70
|
+
if (!candidate || isSystemBypassId(candidate)) return void 0;
|
|
71
|
+
return candidate;
|
|
72
|
+
}
|
|
73
|
+
function withOwnReflectionScope(scopes, agentId) {
|
|
74
|
+
const reflectionScope = SCOPE_PATTERNS.REFLECTION(agentId);
|
|
75
|
+
return scopes.includes(reflectionScope) ? [...scopes] : [...scopes, reflectionScope];
|
|
76
|
+
}
|
|
77
|
+
function normalizeAgentAccessMap(agentAccess) {
|
|
78
|
+
const normalized = {};
|
|
79
|
+
if (!agentAccess) return normalized;
|
|
80
|
+
for (const [rawAgentId, scopes] of Object.entries(agentAccess)) {
|
|
81
|
+
const agentId = rawAgentId.trim();
|
|
82
|
+
if (!agentId) continue;
|
|
83
|
+
normalized[agentId] = Array.isArray(scopes) ? [...scopes] : [];
|
|
84
|
+
}
|
|
85
|
+
return normalized;
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/engine/security/memory-scope-policy.ts
|
|
89
|
+
/** @file memory-scope-policy.ts
|
|
90
|
+
* @purpose Implements mutable memory scope policy management.
|
|
91
|
+
* @boundary Scope config validation and access decisions only.
|
|
92
|
+
*/
|
|
93
|
+
var MemoryScopePolicy = class {
|
|
94
|
+
config;
|
|
95
|
+
warn;
|
|
96
|
+
constructor(config = {}, warn) {
|
|
97
|
+
this.warn = warn;
|
|
98
|
+
this.config = {
|
|
99
|
+
default: config.default ?? DEFAULT_SCOPE_CONFIG.default,
|
|
100
|
+
definitions: {
|
|
101
|
+
...DEFAULT_SCOPE_CONFIG.definitions,
|
|
102
|
+
...config.definitions ?? {}
|
|
103
|
+
},
|
|
104
|
+
agentAccess: {
|
|
105
|
+
...normalizeAgentAccessMap(DEFAULT_SCOPE_CONFIG.agentAccess),
|
|
106
|
+
...normalizeAgentAccessMap(config.agentAccess)
|
|
107
|
+
},
|
|
108
|
+
extraAccessibleScopes: normalizeExtraAccessibleScopes(config.extraAccessibleScopes ?? DEFAULT_SCOPE_CONFIG.extraAccessibleScopes)
|
|
109
|
+
};
|
|
110
|
+
if (!this.config.definitions.global) this.config.definitions.global = { description: "Shared knowledge across all agents" };
|
|
111
|
+
this.validateConfiguration();
|
|
112
|
+
}
|
|
113
|
+
validateConfiguration() {
|
|
114
|
+
if (!this.config.definitions[this.config.default] && !this.isBuiltInScope(this.config.default)) throw new Error(`Default scope '${this.config.default}' not found in definitions or built-in scopes`);
|
|
115
|
+
for (const [agentId, scopes] of Object.entries(this.config.agentAccess)) {
|
|
116
|
+
const trimmedAgentId = agentId.trim();
|
|
117
|
+
if (isSystemBypassId(trimmedAgentId)) throw new Error(`Reserved bypass agent ID '${trimmedAgentId}' cannot have explicit access configured.`);
|
|
118
|
+
for (const scope of scopes) if (!this.config.definitions[scope] && !this.isBuiltInScope(scope)) this.warn?.("invalid_scope_in_agent_access", {
|
|
119
|
+
agentId,
|
|
120
|
+
scope
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
for (const scope of this.config.extraAccessibleScopes) if (!this.config.definitions[scope] && !this.isBuiltInScope(scope)) this.warn?.("invalid_scope_in_extra_accessible_scopes", { scope });
|
|
124
|
+
}
|
|
125
|
+
isBuiltInScope(scope) {
|
|
126
|
+
if (scope === "global") return true;
|
|
127
|
+
return [
|
|
128
|
+
"agent:",
|
|
129
|
+
"custom:",
|
|
130
|
+
"project:",
|
|
131
|
+
"user:",
|
|
132
|
+
"reflection:"
|
|
133
|
+
].some((p) => scope.startsWith(p) && scope.length > p.length);
|
|
134
|
+
}
|
|
135
|
+
getAccessibleScopes(agentId) {
|
|
136
|
+
const mergeExtraAccessibleScopes = (scopes) => {
|
|
137
|
+
if (this.config.extraAccessibleScopes.length === 0) return scopes;
|
|
138
|
+
const merged = [...scopes];
|
|
139
|
+
for (const scope of this.config.extraAccessibleScopes) if (!merged.includes(scope)) merged.push(scope);
|
|
140
|
+
return merged;
|
|
141
|
+
};
|
|
142
|
+
if (isSystemBypassId(agentId)) return mergeExtraAccessibleScopes(this.getAllScopes());
|
|
143
|
+
if (!agentId?.trim()) return mergeExtraAccessibleScopes([this.config.default]);
|
|
144
|
+
const normalizedAgentId = agentId.trim();
|
|
145
|
+
if (isSystemBypassId(normalizedAgentId)) return mergeExtraAccessibleScopes(this.getAllScopes());
|
|
146
|
+
const explicitAccess = this.config.agentAccess[normalizedAgentId];
|
|
147
|
+
if (explicitAccess) return mergeExtraAccessibleScopes(withOwnReflectionScope(explicitAccess, normalizedAgentId));
|
|
148
|
+
return mergeExtraAccessibleScopes(withOwnReflectionScope(["global", SCOPE_PATTERNS.AGENT(normalizedAgentId)], normalizedAgentId));
|
|
149
|
+
}
|
|
150
|
+
resolveAgentScopes(agentId) {
|
|
151
|
+
return this.getAccessibleScopes(agentId);
|
|
152
|
+
}
|
|
153
|
+
getScopeFilter(agentId) {
|
|
154
|
+
if (isSystemBypassId(agentId)) return void 0;
|
|
155
|
+
if (!agentId?.trim()) return [this.config.default];
|
|
156
|
+
const normalizedAgentId = agentId.trim();
|
|
157
|
+
if (isSystemBypassId(normalizedAgentId)) return void 0;
|
|
158
|
+
return this.getAccessibleScopes(normalizedAgentId);
|
|
159
|
+
}
|
|
160
|
+
getDefaultScope(agentId) {
|
|
161
|
+
if (!agentId?.trim()) return this.config.default;
|
|
162
|
+
const normalizedAgentId = agentId.trim();
|
|
163
|
+
if (isSystemBypassId(normalizedAgentId)) throw new Error(`Reserved bypass agent ID '${normalizedAgentId}' must provide an explicit write scope.`);
|
|
164
|
+
const agentScope = SCOPE_PATTERNS.AGENT(normalizedAgentId);
|
|
165
|
+
return this.getAccessibleScopes(normalizedAgentId).includes(agentScope) ? agentScope : this.config.default;
|
|
166
|
+
}
|
|
167
|
+
isAccessible(scope, agentId) {
|
|
168
|
+
if (isSystemBypassId(agentId)) return this.validateScope(scope);
|
|
169
|
+
return this.getAccessibleScopes(agentId).includes(scope);
|
|
170
|
+
}
|
|
171
|
+
validateScope(scope) {
|
|
172
|
+
if (typeof scope !== "string" || scope.trim().length === 0) return false;
|
|
173
|
+
const trimmed = scope.trim();
|
|
174
|
+
return this.config.definitions[trimmed] !== void 0 || this.isBuiltInScope(trimmed);
|
|
175
|
+
}
|
|
176
|
+
getAllScopes() {
|
|
177
|
+
return Object.keys(this.config.definitions);
|
|
178
|
+
}
|
|
179
|
+
getScopeDefinition(scope) {
|
|
180
|
+
return this.config.definitions[scope];
|
|
181
|
+
}
|
|
182
|
+
addScopeDefinition(scope, definition) {
|
|
183
|
+
if (!this.validateScopeFormat(scope)) throw new Error(`Invalid scope format: ${scope}`);
|
|
184
|
+
this.config.definitions[scope] = definition;
|
|
185
|
+
}
|
|
186
|
+
removeScopeDefinition(scope) {
|
|
187
|
+
if (scope === "global") throw new Error("Cannot remove global scope");
|
|
188
|
+
if (!this.config.definitions[scope]) return false;
|
|
189
|
+
delete this.config.definitions[scope];
|
|
190
|
+
for (const [agentId, scopes] of Object.entries(this.config.agentAccess)) {
|
|
191
|
+
const filtered = scopes.filter((s) => s !== scope);
|
|
192
|
+
if (filtered.length !== scopes.length) this.config.agentAccess[agentId] = filtered;
|
|
193
|
+
}
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
setAgentAccess(agentId, scopes) {
|
|
197
|
+
if (!agentId || typeof agentId !== "string") throw new Error("Invalid agent ID");
|
|
198
|
+
const normalizedAgentId = agentId.trim();
|
|
199
|
+
if (!normalizedAgentId) throw new Error("Invalid agent ID");
|
|
200
|
+
if (isSystemBypassId(normalizedAgentId)) throw new Error(`Reserved bypass agent ID cannot have explicit access configured: ${agentId}`);
|
|
201
|
+
for (const scope of scopes) if (!this.validateScope(scope)) throw new Error(`Invalid scope: ${scope}`);
|
|
202
|
+
this.config.agentAccess[normalizedAgentId] = [...scopes];
|
|
203
|
+
}
|
|
204
|
+
removeAgentAccess(agentId) {
|
|
205
|
+
const normalizedAgentId = agentId.trim();
|
|
206
|
+
if (!this.config.agentAccess[normalizedAgentId]) return false;
|
|
207
|
+
delete this.config.agentAccess[normalizedAgentId];
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
setExtraAccessibleScopes(scopes) {
|
|
211
|
+
const normalizedScopes = normalizeExtraAccessibleScopes(scopes);
|
|
212
|
+
for (const scope of normalizedScopes) if (!this.validateScope(scope)) throw new Error(`Invalid scope: ${scope}`);
|
|
213
|
+
this.config.extraAccessibleScopes = normalizedScopes;
|
|
214
|
+
}
|
|
215
|
+
validateScopeFormat(scope) {
|
|
216
|
+
if (!scope || typeof scope !== "string") return false;
|
|
217
|
+
const trimmed = scope.trim();
|
|
218
|
+
if (trimmed.length === 0 || trimmed.length > 100) return false;
|
|
219
|
+
return /^[a-zA-Z0-9._:-]+$/.test(trimmed);
|
|
220
|
+
}
|
|
221
|
+
exportConfig() {
|
|
222
|
+
return {
|
|
223
|
+
default: this.config.default,
|
|
224
|
+
definitions: JSON.parse(JSON.stringify(this.config.definitions)),
|
|
225
|
+
agentAccess: JSON.parse(JSON.stringify(this.config.agentAccess)),
|
|
226
|
+
extraAccessibleScopes: [...this.config.extraAccessibleScopes]
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
importConfig(config) {
|
|
230
|
+
if (config.definitions) {
|
|
231
|
+
for (const key of Object.keys(config.definitions)) if (!this.validateScopeFormat(key) && !this.isBuiltInScope(key)) throw new Error(`Invalid scope format in imported config: ${key}`);
|
|
232
|
+
}
|
|
233
|
+
const previous = this.config;
|
|
234
|
+
const next = {
|
|
235
|
+
default: config.default ?? previous.default,
|
|
236
|
+
definitions: {
|
|
237
|
+
...previous.definitions,
|
|
238
|
+
...config.definitions ?? {}
|
|
239
|
+
},
|
|
240
|
+
agentAccess: {
|
|
241
|
+
...normalizeAgentAccessMap(previous.agentAccess),
|
|
242
|
+
...normalizeAgentAccessMap(config.agentAccess)
|
|
243
|
+
},
|
|
244
|
+
extraAccessibleScopes: normalizeExtraAccessibleScopes(config.extraAccessibleScopes ?? previous.extraAccessibleScopes)
|
|
245
|
+
};
|
|
246
|
+
this.config = next;
|
|
247
|
+
try {
|
|
248
|
+
this.validateConfiguration();
|
|
249
|
+
} catch (error) {
|
|
250
|
+
this.config = previous;
|
|
251
|
+
throw error;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
getStats() {
|
|
255
|
+
const scopes = this.getAllScopes();
|
|
256
|
+
const scopesByType = {
|
|
257
|
+
global: 0,
|
|
258
|
+
agent: 0,
|
|
259
|
+
custom: 0,
|
|
260
|
+
project: 0,
|
|
261
|
+
user: 0,
|
|
262
|
+
reflection: 0,
|
|
263
|
+
other: 0
|
|
264
|
+
};
|
|
265
|
+
for (const scope of scopes) if (scope === "global") scopesByType.global = (scopesByType.global ?? 0) + 1;
|
|
266
|
+
else if (scope.startsWith("agent:")) scopesByType.agent = (scopesByType.agent ?? 0) + 1;
|
|
267
|
+
else if (scope.startsWith("custom:")) scopesByType.custom = (scopesByType.custom ?? 0) + 1;
|
|
268
|
+
else if (scope.startsWith("project:")) scopesByType.project = (scopesByType.project ?? 0) + 1;
|
|
269
|
+
else if (scope.startsWith("user:")) scopesByType.user = (scopesByType.user ?? 0) + 1;
|
|
270
|
+
else if (scope.startsWith("reflection:")) scopesByType.reflection = (scopesByType.reflection ?? 0) + 1;
|
|
271
|
+
else scopesByType.other = (scopesByType.other ?? 0) + 1;
|
|
272
|
+
return {
|
|
273
|
+
totalScopes: scopes.length,
|
|
274
|
+
agentsWithCustomAccess: Object.keys(this.config.agentAccess).length,
|
|
275
|
+
scopesByType
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
function createScopePolicy(config = {}, warn) {
|
|
280
|
+
return new MemoryScopePolicy(config, warn);
|
|
281
|
+
}
|
|
282
|
+
//#endregion
|
|
283
|
+
export { parseAgentIdFromSessionKey as a, SCOPE_PATTERNS as c, isSystemBypassId as i, createScopePolicy as n, shouldWarnLegacyFallbackBypassId as o, _resetLegacyFallbackWarningState as r, DEFAULT_SCOPE_CONFIG as s, MemoryScopePolicy as t };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { t as PluginConfig } from "./plugin-config-schema-C0UUbOmG.js";
|
|
2
|
+
import "./types-DxKqU60b.js";
|
|
3
|
+
import { r as SqliteDatabaseLike } from "./sqlite-runtime-L_ywirTm.js";
|
|
4
|
+
//#region src/engine/observability/memory-snapshot.d.ts
|
|
5
|
+
type SnapshotReason = "startup" | "session_end";
|
|
6
|
+
type MemorySnapshotPayload = {
|
|
7
|
+
session_uuid: string;
|
|
8
|
+
snapshot_reason: SnapshotReason;
|
|
9
|
+
total_entries: number;
|
|
10
|
+
total_bytes: number;
|
|
11
|
+
oldest_entry_ts_ms?: number;
|
|
12
|
+
newest_entry_ts_ms?: number;
|
|
13
|
+
};
|
|
14
|
+
declare function readMemorySnapshotPayload(dbPath: string, _config: PluginConfig, snapshotUuid: string, reason: SnapshotReason, liveDb?: SqliteDatabaseLike): Promise<MemorySnapshotPayload>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { SnapshotReason as n, readMemorySnapshotPayload as r, MemorySnapshotPayload as t };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
//#region src/store/memory-source-order.ts
|
|
2
|
+
function compareNumber(left, right) {
|
|
3
|
+
if (left === right) return 0;
|
|
4
|
+
return left < right ? -1 : 1;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The one number a row is ordered by. `valid_from` is the event time; when the model resolved
|
|
8
|
+
* none, the row's own session moment stands in for it — exactly as the write sets
|
|
9
|
+
* `timestamp = valid_from ?? sessionTimestampMs`. Folding both into a single monotone number is
|
|
10
|
+
* what makes the comparison transitive: comparing `valid_from` only when both sides carried one
|
|
11
|
+
* left mixed dated/undated rows able to form a cycle. A row with neither (written before this
|
|
12
|
+
* field, or a hand-written key) sorts oldest.
|
|
13
|
+
*/
|
|
14
|
+
function orderTime(order) {
|
|
15
|
+
return order.valid_from ?? order.session_moment ?? Number.NEGATIVE_INFINITY;
|
|
16
|
+
}
|
|
17
|
+
function compareMemorySourceOrder(left, right) {
|
|
18
|
+
return compareNumber(orderTime(left), orderTime(right)) || compareNumber(left.session_ordinal, right.session_ordinal) || compareNumber(left.global_turn_index, right.global_turn_index) || compareNumber(left.rowid, right.rowid);
|
|
19
|
+
}
|
|
20
|
+
/** The latest correction assertion in this row's existing predecessor chain. */
|
|
21
|
+
function readCorrectionMoment(database, rowId) {
|
|
22
|
+
const row = database.prepare(`WITH RECURSIVE predecessors(id, project_id, metadata) AS (
|
|
23
|
+
SELECT id, project_id, metadata FROM nodix_memories WHERE id = ?
|
|
24
|
+
UNION
|
|
25
|
+
SELECT parent.id, parent.project_id, parent.metadata FROM nodix_memories parent
|
|
26
|
+
JOIN predecessors child ON parent.project_id = child.project_id AND json_valid(parent.metadata)
|
|
27
|
+
AND json_extract(parent.metadata, '$.superseded_by') = child.id
|
|
28
|
+
) SELECT MAX(CASE WHEN json_valid(metadata)
|
|
29
|
+
AND json_extract(metadata, '$.source_order.correction') = 1
|
|
30
|
+
THEN json_extract(metadata, '$.source_order.session_moment') END) AS moment FROM predecessors`).get(rowId);
|
|
31
|
+
return typeof row === "object" && row !== null && "moment" in row && typeof row.moment === "number" ? row.moment : void 0;
|
|
32
|
+
}
|
|
33
|
+
/** Apply correction assertion time at retirement, preserving ordinary event ordering. */
|
|
34
|
+
function compareMemoryRetirementOrder(database, leftId, left, rightId, right) {
|
|
35
|
+
const correctedAt = Math.max(readCorrectionMoment(database, leftId) ?? Number.NEGATIVE_INFINITY, readCorrectionMoment(database, rightId) ?? Number.NEGATIVE_INFINITY);
|
|
36
|
+
if (Number.isFinite(correctedAt) && left.session_moment !== void 0 && right.session_moment !== void 0) {
|
|
37
|
+
const leftPredates = left.session_moment < correctedAt;
|
|
38
|
+
if (leftPredates !== right.session_moment < correctedAt) return leftPredates ? -1 : 1;
|
|
39
|
+
if (left.correction || right.correction) {
|
|
40
|
+
const assertionOrder = compareNumber(left.session_moment, right.session_moment);
|
|
41
|
+
if (assertionOrder !== 0) return assertionOrder;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return compareMemorySourceOrder(left, right);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Two rows born from one conversation turn: at arrival neither is older than the other. One
|
|
48
|
+
* statement is extracted as several rows — a timeline and its phases, an ending and its
|
|
49
|
+
* replacement — and the `rowid` tie-break below read them as successive, so a one-cardinality
|
|
50
|
+
* attribute closed every facet but the last and an ending was offered its own replacement to
|
|
51
|
+
* retire (measured 2026-09-07: 23 and 3 rows of one six-persona run). A same-turn revision is
|
|
52
|
+
* the model's `ends_current` job, not an ordering question. The sentinel of a row with no
|
|
53
|
+
* `source_order` never matches another sentinel.
|
|
54
|
+
*/
|
|
55
|
+
function sameSourceTurn(left, right) {
|
|
56
|
+
return left.conversation_id !== void 0 && left.conversation_id === right.conversation_id && Number.isFinite(left.session_ordinal) && left.session_ordinal === right.session_ordinal && left.global_turn_index === right.global_turn_index;
|
|
57
|
+
}
|
|
58
|
+
function isSafeInteger(value) {
|
|
59
|
+
return typeof value === "number" && Number.isSafeInteger(value);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The order key a row carries, or the one a row written before this change is treated as having.
|
|
63
|
+
*
|
|
64
|
+
* A row from before REQ-2 has no `source_order` until the maintenance pass backfills it, and an
|
|
65
|
+
* ordinary wave must keep running over such a store rather than throwing. Those rows are older
|
|
66
|
+
* than everything written since — that is what "written before" means — so they read as the
|
|
67
|
+
* lowest possible key: anything may close them, and they may close nothing.
|
|
68
|
+
*/
|
|
69
|
+
function readMemorySourceOrderOrOldest(metadata) {
|
|
70
|
+
try {
|
|
71
|
+
return readMemorySourceOrder(metadata);
|
|
72
|
+
} catch {
|
|
73
|
+
return {
|
|
74
|
+
valid_from: null,
|
|
75
|
+
session_ordinal: Number.NEGATIVE_INFINITY,
|
|
76
|
+
global_turn_index: Number.NEGATIVE_INFINITY,
|
|
77
|
+
rowid: Number.NEGATIVE_INFINITY
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function readMemorySourceOrder(metadata) {
|
|
82
|
+
const parsed = JSON.parse(metadata);
|
|
83
|
+
if (typeof parsed !== "object" || parsed === null || !("source_order" in parsed)) throw new Error("Memory row has no source_order");
|
|
84
|
+
const sourceOrder = parsed.source_order;
|
|
85
|
+
if (typeof sourceOrder !== "object" || sourceOrder === null) throw new Error("Memory row has invalid source_order");
|
|
86
|
+
const validFrom = "valid_from" in sourceOrder ? sourceOrder.valid_from : void 0;
|
|
87
|
+
const sessionMoment = "session_moment" in sourceOrder ? sourceOrder.session_moment : void 0;
|
|
88
|
+
const sessionOrdinal = "session_ordinal" in sourceOrder ? sourceOrder.session_ordinal : void 0;
|
|
89
|
+
const globalTurnIndex = "global_turn_index" in sourceOrder ? sourceOrder.global_turn_index : void 0;
|
|
90
|
+
const rowid = "rowid" in sourceOrder ? sourceOrder.rowid : void 0;
|
|
91
|
+
const conversationId = "conversation_id" in sourceOrder && typeof sourceOrder.conversation_id === "string" ? sourceOrder.conversation_id : void 0;
|
|
92
|
+
if (validFrom !== null && !isSafeInteger(validFrom) || sessionMoment !== void 0 && !isSafeInteger(sessionMoment) || !isSafeInteger(sessionOrdinal) || !isSafeInteger(globalTurnIndex) || !isSafeInteger(rowid)) throw new Error("Memory row has invalid source_order");
|
|
93
|
+
return {
|
|
94
|
+
valid_from: validFrom,
|
|
95
|
+
...sessionMoment === void 0 ? {} : { session_moment: sessionMoment },
|
|
96
|
+
session_ordinal: sessionOrdinal,
|
|
97
|
+
global_turn_index: globalTurnIndex,
|
|
98
|
+
rowid,
|
|
99
|
+
...conversationId === void 0 ? {} : { conversation_id: conversationId },
|
|
100
|
+
..."correction" in sourceOrder && sourceOrder.correction === true ? { correction: true } : {}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function readMetadata(metadata) {
|
|
104
|
+
const parsed = JSON.parse(metadata);
|
|
105
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error("Memory row has invalid metadata");
|
|
106
|
+
return { ...parsed };
|
|
107
|
+
}
|
|
108
|
+
function activeMergeId(metadata) {
|
|
109
|
+
return typeof metadata.merge_id === "string" ? metadata.merge_id : void 0;
|
|
110
|
+
}
|
|
111
|
+
function readClosableRow(database, rowId) {
|
|
112
|
+
const row = database.prepare("SELECT id, metadata, valid_from AS validFrom, valid_until AS validUntil FROM nodix_memories WHERE id = ?").get(rowId);
|
|
113
|
+
if (!row) throw new Error(`Memory row '${rowId}' does not exist`);
|
|
114
|
+
return row;
|
|
115
|
+
}
|
|
116
|
+
function closeMemoryRow(database, input) {
|
|
117
|
+
const row = readClosableRow(database, input.targetRowId);
|
|
118
|
+
const metadata = readMetadata(row.metadata);
|
|
119
|
+
if (metadata.superseded_by === input.closingRowId) return false;
|
|
120
|
+
if (metadata.superseded_by !== void 0 && metadata.superseded_by !== null) throw new Error(`Memory row '${input.targetRowId}' is already closed`);
|
|
121
|
+
if (input.targetRowId !== input.closingRowId && compareMemoryRetirementOrder(database, input.closingRowId, input.closingOrder, input.targetRowId, readMemorySourceOrderOrOldest(row.metadata)) < 0) throw new Error("Closing row source_order must be strictly greater than target source_order");
|
|
122
|
+
const validUntil = input.validUntilMode === "clear" ? null : row.validFrom !== null && input.closingValidFrom !== null && input.closingValidFrom > row.validFrom ? input.closingValidFrom : row.validUntil;
|
|
123
|
+
const closingMetadata = input.targetRowId === input.closingRowId ? metadata : readMetadata(readClosableRow(database, input.closingRowId).metadata);
|
|
124
|
+
const mergeId = activeMergeId(metadata) ?? activeMergeId(closingMetadata);
|
|
125
|
+
database.prepare("UPDATE nodix_memories SET metadata = ?, valid_until = ? WHERE id = ?").run(JSON.stringify({
|
|
126
|
+
...metadata,
|
|
127
|
+
superseded_by: input.closingRowId,
|
|
128
|
+
superseded_at: input.supersededAt,
|
|
129
|
+
...mergeId === void 0 ? {} : { close_merge_id: mergeId }
|
|
130
|
+
}), validUntil, input.targetRowId);
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
export { readMemorySourceOrder as a, readCorrectionMoment as i, compareMemoryRetirementOrder as n, readMemorySourceOrderOrOldest as o, compareMemorySourceOrder as r, sameSourceTurn as s, closeMemoryRow as t };
|