@snoai/memory 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +176 -0
- package/README.md +33 -2
- package/config/b-profile-section-registry.json +118 -0
- package/config/llm/compiled/2026-05-19T230932Z/manifest.json +25 -0
- package/config/llm/compiled/2026-05-19T230932Z/registry-root.json +67 -0
- package/config/llm/compiled/2026-05-19T230932Z/resolved/mem_claw/openai_gpt_5_nano.json +5 -0
- package/config/llm/compiled/2026-05-19T230932Z/resolved/mem_claw/openrouter_auto.json +5 -0
- package/config/llm/compiled/2026-05-19T230932Z/resolved/mem_claw/sno_ai_extract.json +5 -0
- package/config/llm/compiled/2026-05-19T230932Z/source/mem_claw/openai_gpt_5_nano.mda +24 -0
- package/config/llm/compiled/2026-05-19T230932Z/source/mem_claw/openrouter_auto.mda +24 -0
- package/config/llm/compiled/2026-05-19T230932Z/source/mem_claw/sno_ai_extract.mda +24 -0
- package/config/llm/compiled/2026-07-21T001311Z/manifest.json +43 -0
- package/config/llm/compiled/2026-07-21T001311Z/registry-root.json +97 -0
- package/config/llm/compiled/2026-07-21T001311Z/resolved/mem_claw/openai_gpt_5_nano.json +5 -0
- package/config/llm/compiled/2026-07-21T001311Z/resolved/mem_claw/openrouter_auto.json +5 -0
- package/config/llm/compiled/2026-07-21T001311Z/resolved/mem_claw/sno_ai_extract.json +5 -0
- package/config/llm/compiled/2026-07-21T001311Z/resolved/mem_claw/sno_conflict_verdict.json +10 -0
- package/config/llm/compiled/2026-07-21T001311Z/resolved/mem_claw/sno_extract_chat.json +10 -0
- package/config/llm/compiled/2026-07-21T001311Z/resolved/mem_claw/sno_extract_profile.json +10 -0
- package/config/llm/compiled/2026-07-21T001311Z/source/mem_claw/openai_gpt_5_nano.mda +24 -0
- package/config/llm/compiled/2026-07-21T001311Z/source/mem_claw/openrouter_auto.mda +24 -0
- package/config/llm/compiled/2026-07-21T001311Z/source/mem_claw/sno_ai_extract.mda +24 -0
- package/config/llm/compiled/2026-07-21T001311Z/source/mem_claw/sno_conflict_verdict.mda +27 -0
- package/config/llm/compiled/2026-07-21T001311Z/source/mem_claw/sno_extract_chat.mda +27 -0
- package/config/llm/compiled/2026-07-21T001311Z/source/mem_claw/sno_extract_profile.mda +27 -0
- package/config/llm/compiled/2026-08-29T060335Z/manifest.json +43 -0
- package/config/llm/compiled/2026-08-29T060335Z/registry-root.json +97 -0
- package/config/llm/compiled/2026-08-29T060335Z/resolved/mem_claw/openai_gpt_5_nano.json +5 -0
- package/config/llm/compiled/2026-08-29T060335Z/resolved/mem_claw/openrouter_auto.json +5 -0
- package/config/llm/compiled/2026-08-29T060335Z/resolved/mem_claw/sno_ai_extract.json +5 -0
- package/config/llm/compiled/2026-08-29T060335Z/resolved/mem_claw/sno_conflict_verdict.json +10 -0
- package/config/llm/compiled/2026-08-29T060335Z/resolved/mem_claw/sno_extract_chat.json +10 -0
- package/config/llm/compiled/2026-08-29T060335Z/resolved/mem_claw/sno_extract_profile.json +10 -0
- package/config/llm/compiled/2026-08-29T060335Z/source/mem_claw/openai_gpt_5_nano.mda +24 -0
- package/config/llm/compiled/2026-08-29T060335Z/source/mem_claw/openrouter_auto.mda +24 -0
- package/config/llm/compiled/2026-08-29T060335Z/source/mem_claw/sno_ai_extract.mda +24 -0
- package/config/llm/compiled/2026-08-29T060335Z/source/mem_claw/sno_conflict_verdict.mda +27 -0
- package/config/llm/compiled/2026-08-29T060335Z/source/mem_claw/sno_extract_chat.mda +27 -0
- package/config/llm/compiled/2026-08-29T060335Z/source/mem_claw/sno_extract_profile.mda +27 -0
- package/config/llm/compiled/2026-09-04T004828Z/manifest.json +43 -0
- package/config/llm/compiled/2026-09-04T004828Z/registry-root.json +97 -0
- package/config/llm/compiled/2026-09-04T004828Z/resolved/mem_claw/openai_gpt_5_nano.json +5 -0
- package/config/llm/compiled/2026-09-04T004828Z/resolved/mem_claw/openrouter_auto.json +5 -0
- package/config/llm/compiled/2026-09-04T004828Z/resolved/mem_claw/sno_ai_extract.json +5 -0
- package/config/llm/compiled/2026-09-04T004828Z/resolved/mem_claw/sno_conflict_verdict.json +10 -0
- package/config/llm/compiled/2026-09-04T004828Z/resolved/mem_claw/sno_extract_chat.json +10 -0
- package/config/llm/compiled/2026-09-04T004828Z/resolved/mem_claw/sno_extract_profile.json +10 -0
- package/config/llm/compiled/2026-09-04T004828Z/source/mem_claw/openai_gpt_5_nano.mda +24 -0
- package/config/llm/compiled/2026-09-04T004828Z/source/mem_claw/openrouter_auto.mda +24 -0
- package/config/llm/compiled/2026-09-04T004828Z/source/mem_claw/sno_ai_extract.mda +24 -0
- package/config/llm/compiled/2026-09-04T004828Z/source/mem_claw/sno_conflict_verdict.mda +27 -0
- package/config/llm/compiled/2026-09-04T004828Z/source/mem_claw/sno_extract_chat.mda +27 -0
- package/config/llm/compiled/2026-09-04T004828Z/source/mem_claw/sno_extract_profile.mda +27 -0
- package/config/llm/current.json +4 -0
- package/config/llm/source/mem_claw/openai_gpt_5_nano.mda +24 -0
- package/config/llm/source/mem_claw/openrouter_auto.mda +24 -0
- package/config/llm/source/mem_claw/sno_ai_extract.mda +24 -0
- package/config/llm/source/mem_claw/sno_conflict_verdict.mda +27 -0
- package/config/llm/source/mem_claw/sno_extract_chat.mda +27 -0
- package/config/llm/source/mem_claw/sno_extract_profile.mda +27 -0
- package/config/llm.trust.json +37 -0
- package/dist/_types-CUKHSRkS.d.ts +103 -0
- package/dist/access-tracker-BbEvEocb.d.ts +110 -0
- package/dist/adapter-B7Jox9-6.d.ts +69 -0
- package/dist/adapter-XaRHZWZ2.js +333 -0
- package/dist/agent-llm-port-5oXgBpzJ.d.ts +53 -0
- package/dist/all-resources-BQK2ugjB.js +6379 -0
- package/dist/all-resources-Dij6l5h0.d.ts +18 -0
- package/dist/ambient-learning-text-normalizer-CxjATmMp.js +170 -0
- package/dist/ambient-learning-text-normalizer-_fH3LeuK.d.ts +10 -0
- package/dist/atomic-extraction-reply-BJ9XV_9s.js +863 -0
- package/dist/atomic-extraction-skill-CcXmuCqL.js +56 -0
- package/dist/atomic-memory-extraction-C5rmogoY.js +3605 -0
- package/dist/atomic-memory-extraction-d9EG-4ti.d.ts +327 -0
- package/dist/b-profile-section-dictionary-provider-BHkoNqgk.js +1812 -0
- package/dist/b-profile-section-dictionary-provider-BxbksLj3.d.ts +62 -0
- package/dist/best-effort-BPZSzKk0.d.ts +9 -0
- package/dist/calendar-instruction-CzqZbAPG.js +194 -0
- package/dist/capture-policy-detector-CxbHPkMX.d.ts +53 -0
- package/dist/capture-policy-detector-DaMfy9CZ.js +357 -0
- package/dist/classifier-DnbbtwTS.d.ts +272 -0
- package/dist/client.d.ts +34 -0
- package/dist/client.js +306 -0
- package/dist/coding-skin.d.ts +51 -0
- package/dist/coding-skin.js +55 -0
- package/dist/config-CL90qYva.js +2576 -0
- package/dist/connection-3IVXpuPE.d.ts +391 -0
- package/dist/connection-C9YD5sgm.js +297 -0
- package/dist/daily-log-generator-CH_KuWHs.js +469 -0
- package/dist/daily-log-generator-CsQPHl4A.d.ts +73 -0
- package/dist/daily-spend-estimator-DiwzBlo1.d.ts +8 -0
- package/dist/data-bootstrap-Bl3lthzE.d.ts +30 -0
- package/dist/data-bootstrap-P8sie9WA.js +172 -0
- package/dist/data-paths-C7sNdqvP.d.ts +22 -0
- package/dist/derived-suppression-cache-CI0durYx.d.ts +36 -0
- package/dist/diagnostic-encoder.d.ts +6 -0
- package/dist/diagnostic-encoder.js +29 -0
- package/dist/embedding-provider-client-Q_hJonK9.js +294 -0
- package/dist/embedding-provider-client-vynZMuit.d.ts +94 -0
- package/dist/entry-metadata-parser-BIVSMCIk.js +20 -0
- package/dist/error-D-wb-rZw.js +23 -0
- package/dist/error-signals-D8_3vYu4.d.ts +28 -0
- package/dist/error-signals-lMH2uAdV.js +134 -0
- package/dist/errors-CeVRxf9V.d.ts +49 -0
- package/dist/extraction-text-sanitizer-B_AhIecT.d.ts +32 -0
- package/dist/i18n-text-DbD6Qify.d.ts +13 -0
- package/dist/index-0aqS8pVF.d.ts +351 -0
- package/dist/index-BO4RU_mc.d.ts +650 -0
- package/dist/index-DL8AVj0Z.d.ts +571 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.js +1201 -0
- package/dist/intent-analyzer-B5XVrWwe.d.ts +28 -0
- package/dist/internal/config/index.d.ts +2 -0
- package/dist/internal/config/index.js +581 -0
- package/dist/internal/config/plugin-config-schema.d.ts +2 -0
- package/dist/internal/config/plugin-config-schema.js +2 -0
- package/dist/internal/config/product-mode.d.ts +2 -0
- package/dist/internal/config/product-mode.js +36 -0
- package/dist/internal/config/settings.d.ts +2 -0
- package/dist/internal/config/settings.js +265 -0
- package/dist/internal/config/skill-categories.d.ts +4 -0
- package/dist/internal/config/skill-categories.js +68 -0
- package/dist/internal/config/skin-defaults.d.ts +6 -0
- package/dist/internal/config/skin-defaults.js +6 -0
- package/dist/internal/contract/discovery.d.ts +10 -0
- package/dist/internal/contract/discovery.js +53 -0
- package/dist/internal/contract/profile.d.ts +2 -0
- package/dist/internal/contract/profile.js +44 -0
- package/dist/internal/contract/routes.d.ts +2 -0
- package/dist/internal/contract/routes.js +62 -0
- package/dist/internal/engine/bindings/memory-cli-shared.d.ts +47 -0
- package/dist/internal/engine/bindings/memory-cli-shared.js +84 -0
- package/dist/internal/engine/bindings/memory-forget-tool.d.ts +5 -0
- package/dist/internal/engine/bindings/memory-forget-tool.js +66 -0
- package/dist/internal/engine/bindings/memory-list-tool.d.ts +5 -0
- package/dist/internal/engine/bindings/memory-list-tool.js +57 -0
- package/dist/internal/engine/bindings/memory-recall-tool.d.ts +10 -0
- package/dist/internal/engine/bindings/memory-recall-tool.js +283 -0
- package/dist/internal/engine/bindings/memory-reflection-resolve-tool.d.ts +5 -0
- package/dist/internal/engine/bindings/memory-reflection-resolve-tool.js +150 -0
- package/dist/internal/engine/bindings/memory-stats-tool.d.ts +5 -0
- package/dist/internal/engine/bindings/memory-stats-tool.js +43 -0
- package/dist/internal/engine/bindings/memory-store-tool.d.ts +5 -0
- package/dist/internal/engine/bindings/memory-store-tool.js +165 -0
- package/dist/internal/engine/bindings/memory-tool-access.d.ts +16 -0
- package/dist/internal/engine/bindings/memory-tool-access.js +46 -0
- package/dist/internal/engine/bindings/memory-tool-formatting.d.ts +62 -0
- package/dist/internal/engine/bindings/memory-tool-formatting.js +106 -0
- package/dist/internal/engine/bindings/memory-tool-results.d.ts +8 -0
- package/dist/internal/engine/bindings/memory-tool-results.js +41 -0
- package/dist/internal/engine/bindings/memory-tool-schemas.d.ts +109 -0
- package/dist/internal/engine/bindings/memory-tool-schemas.js +75 -0
- package/dist/internal/engine/bindings/memory-update-tool.d.ts +5 -0
- package/dist/internal/engine/bindings/memory-update-tool.js +127 -0
- package/dist/internal/engine/bindings/sno-station-mem-ambient-learning-hook.d.ts +14 -0
- package/dist/internal/engine/bindings/sno-station-mem-ambient-learning-hook.js +248 -0
- package/dist/internal/engine/bindings/sno-station-mem-auto-recall-hook.d.ts +12 -0
- package/dist/internal/engine/bindings/sno-station-mem-auto-recall-hook.js +324 -0
- package/dist/internal/engine/bindings/sno-station-mem-hook-types.d.ts +56 -0
- package/dist/internal/engine/bindings/sno-station-mem-hook-types.js +1 -0
- package/dist/internal/engine/bindings/sno-station-mem-insight-distill-factory.d.ts +14 -0
- package/dist/internal/engine/bindings/sno-station-mem-insight-distill-factory.js +119 -0
- package/dist/internal/engine/bindings/sno-station-mem-message-transcript.d.ts +52 -0
- package/dist/internal/engine/bindings/sno-station-mem-message-transcript.js +145 -0
- package/dist/internal/engine/bindings/sno-station-mem-reset-hook.d.ts +10 -0
- package/dist/internal/engine/bindings/sno-station-mem-reset-hook.js +9 -0
- package/dist/internal/engine/bindings/sno-station-mem-runtime-mode.d.ts +36 -0
- package/dist/internal/engine/bindings/sno-station-mem-runtime-mode.js +104 -0
- package/dist/internal/engine/bindings/sno-station-mem-session-state.d.ts +10 -0
- package/dist/internal/engine/bindings/sno-station-mem-session-state.js +27 -0
- package/dist/internal/engine/eval/trace.d.ts +2 -0
- package/dist/internal/engine/eval/trace.js +151 -0
- package/dist/internal/engine/extraction/ambient-learning-text-normalizer.d.ts +2 -0
- package/dist/internal/engine/extraction/ambient-learning-text-normalizer.js +2 -0
- package/dist/internal/engine/extraction/atomic-memory-extraction.d.ts +2 -0
- package/dist/internal/engine/extraction/atomic-memory-extraction.js +2 -0
- package/dist/internal/engine/extraction/b-profile-section-dictionary-provider.d.ts +2 -0
- package/dist/internal/engine/extraction/b-profile-section-dictionary-provider.js +2 -0
- package/dist/internal/engine/extraction/b-profile-section-rekey.d.ts +49 -0
- package/dist/internal/engine/extraction/b-profile-section-rekey.js +730 -0
- package/dist/internal/engine/extraction/capture-policy-detector.d.ts +2 -0
- package/dist/internal/engine/extraction/capture-policy-detector.js +2 -0
- package/dist/internal/engine/extraction/embedding-provider-client.d.ts +2 -0
- package/dist/internal/engine/extraction/embedding-provider-client.js +2 -0
- package/dist/internal/engine/extraction/extraction-text-sanitizer.d.ts +2 -0
- package/dist/internal/engine/extraction/extraction-text-sanitizer.js +114 -0
- package/dist/internal/engine/extraction/memory-metadata-codec.d.ts +3 -0
- package/dist/internal/engine/extraction/memory-metadata-codec.js +2 -0
- package/dist/internal/engine/extraction/memory-temporality-classifier.d.ts +2 -0
- package/dist/internal/engine/extraction/memory-temporality-classifier.js +2 -0
- package/dist/internal/engine/i18n/all-resources.d.ts +2 -0
- package/dist/internal/engine/i18n/all-resources.js +2 -0
- package/dist/internal/engine/i18n/locales.d.ts +2 -0
- package/dist/internal/engine/i18n/locales.js +19 -0
- package/dist/internal/engine/i18n/res/_types.d.ts +2 -0
- package/dist/internal/engine/i18n/res/_types.js +11 -0
- package/dist/internal/engine/observability/adapter.d.ts +2 -0
- package/dist/internal/engine/observability/adapter.js +2 -0
- package/dist/internal/engine/observability/best-effort.d.ts +2 -0
- package/dist/internal/engine/observability/best-effort.js +41 -0
- package/dist/internal/engine/observability/early-diagnostics.js +2 -0
- package/dist/internal/engine/observability/memory-snapshot.d.ts +2 -0
- package/dist/internal/engine/observability/memory-snapshot.js +44 -0
- package/dist/internal/engine/observability/observable-embedder.d.ts +2 -0
- package/dist/internal/engine/observability/observable-embedder.js +43 -0
- package/dist/internal/engine/observability/observable-llm-client.d.ts +2 -0
- package/dist/internal/engine/observability/observable-llm-client.js +98 -0
- package/dist/internal/engine/observability/observable-memory-store.d.ts +2 -0
- package/dist/internal/engine/observability/observable-memory-store.js +701 -0
- package/dist/internal/engine/observability/observable-retriever.d.ts +2 -0
- package/dist/internal/engine/observability/observable-retriever.js +95 -0
- package/dist/internal/engine/observability/runtime-diagnostics.d.ts +13 -0
- package/dist/internal/engine/observability/runtime-diagnostics.js +96 -0
- package/dist/internal/engine/observability/session-registry.d.ts +2 -0
- package/dist/internal/engine/observability/session-registry.js +58 -0
- package/dist/internal/engine/observability/version-metadata.d.ts +7 -0
- package/dist/internal/engine/observability/version-metadata.js +59 -0
- package/dist/internal/engine/operations/daily-spend-estimator.d.ts +2 -0
- package/dist/internal/engine/operations/daily-spend-estimator.js +97 -0
- package/dist/internal/engine/operations/learning-file-maintenance.d.ts +2 -0
- package/dist/internal/engine/operations/learning-file-maintenance.js +255 -0
- package/dist/internal/engine/operations/memory-tier-promoter.d.ts +2 -0
- package/dist/internal/engine/operations/memory-tier-promoter.js +95 -0
- package/dist/internal/engine/operations/runtime-audit-log.d.ts +3 -0
- package/dist/internal/engine/operations/runtime-audit-log.js +3 -0
- package/dist/internal/engine/provider/canonical-memory-corpus.d.ts +38 -0
- package/dist/internal/engine/provider/canonical-memory-corpus.js +253 -0
- package/dist/internal/engine/provider/provider-registration.d.ts +39 -0
- package/dist/internal/engine/provider/provider-registration.js +2 -0
- package/dist/internal/engine/provider/provider-row-renderer.d.ts +7 -0
- package/dist/internal/engine/provider/provider-row-renderer.js +53 -0
- package/dist/internal/engine/provider/provider-types.d.ts +2 -0
- package/dist/internal/engine/provider/provider-types.js +1 -0
- package/dist/internal/engine/reflection/daily-log-generator.d.ts +2 -0
- package/dist/internal/engine/reflection/daily-log-generator.js +2 -0
- package/dist/internal/engine/reflection/reflection-command-hooks.d.ts +2 -0
- package/dist/internal/engine/reflection/reflection-command-hooks.js +2 -0
- package/dist/internal/engine/reflection/reflection-deps.d.ts +2 -0
- package/dist/internal/engine/reflection/reflection-deps.js +1 -0
- package/dist/internal/engine/reflection/reflection-embedded-generator.d.ts +2 -0
- package/dist/internal/engine/reflection/reflection-embedded-generator.js +2 -0
- package/dist/internal/engine/reflection/reflection-injection-hooks.d.ts +2 -0
- package/dist/internal/engine/reflection/reflection-injection-hooks.js +219 -0
- package/dist/internal/engine/reflection/reflection-lifecycle-hooks.d.ts +2 -0
- package/dist/internal/engine/reflection/reflection-lifecycle-hooks.js +63 -0
- package/dist/internal/engine/reflection/strategy-hook-runner.d.ts +4 -0
- package/dist/internal/engine/reflection/strategy-hook-runner.js +3 -0
- package/dist/internal/engine/rem/classifier.d.ts +2 -0
- package/dist/internal/engine/rem/classifier.js +180 -0
- package/dist/internal/engine/rem/index.d.ts +4 -0
- package/dist/internal/engine/rem/index.js +2551 -0
- package/dist/internal/engine/rem/types.d.ts +2 -0
- package/dist/internal/engine/rem/types.js +40 -0
- package/dist/internal/engine/retrieval/access-tracker.d.ts +2 -0
- package/dist/internal/engine/retrieval/access-tracker.js +314 -0
- package/dist/internal/engine/retrieval/intent-analyzer.d.ts +2 -0
- package/dist/internal/engine/retrieval/intent-analyzer.js +27 -0
- package/dist/internal/engine/retrieval/retrieval-gate.d.ts +2 -0
- package/dist/internal/engine/retrieval/retrieval-gate.js +47 -0
- package/dist/internal/engine/retrieval/retriever.d.ts +2 -0
- package/dist/internal/engine/retrieval/retriever.js +2 -0
- package/dist/internal/engine/security/memory-scope-policy.d.ts +2 -0
- package/dist/internal/engine/security/memory-scope-policy.js +2 -0
- package/dist/internal/engine/security/redact.d.ts +2 -0
- package/dist/internal/engine/security/redact.js +34 -0
- package/dist/internal/engine/security/scopes.d.ts +3 -0
- package/dist/internal/engine/security/scopes.js +3 -0
- package/dist/internal/engine/shared/errors.d.ts +2 -0
- package/dist/internal/engine/shared/errors.js +66 -0
- package/dist/internal/engine/shared/i18n-text.d.ts +2 -0
- package/dist/internal/engine/shared/i18n-text.js +58 -0
- package/dist/internal/engine/shared/iso-date-time.d.ts +16 -0
- package/dist/internal/engine/shared/iso-date-time.js +40 -0
- package/dist/internal/engine/shared/lru.d.ts +2 -0
- package/dist/internal/engine/shared/lru.js +30 -0
- package/dist/internal/engine/shared/memory-kind-policy.d.ts +2 -0
- package/dist/internal/engine/shared/memory-kind-policy.js +64 -0
- package/dist/internal/engine/shared/paths.d.ts +3 -0
- package/dist/internal/engine/shared/paths.js +2 -0
- package/dist/internal/engine/shared/types.d.ts +3 -0
- package/dist/internal/engine/shared/types.js +25 -0
- package/dist/internal/engine/shared/utils.d.ts +2 -0
- package/dist/internal/engine/shared/utils.js +175 -0
- package/dist/internal/engine/telemetry/memory-telemetry-api.d.ts +134 -0
- package/dist/internal/engine/telemetry/memory-telemetry-api.js +730 -0
- package/dist/internal/engine/telemetry/memory-telemetry-observability.d.ts +24 -0
- package/dist/internal/engine/telemetry/memory-telemetry-observability.js +133 -0
- package/dist/internal/engine/telemetry/memory-telemetry-outbox.d.ts +2 -0
- package/dist/internal/engine/telemetry/memory-telemetry-outbox.js +443 -0
- package/dist/internal/engine/telemetry/memory-telemetry-types.d.ts +2 -0
- package/dist/internal/engine/telemetry/memory-telemetry-types.js +21 -0
- package/dist/internal/engine/telemetry/observe-ledger.d.ts +30 -0
- package/dist/internal/engine/telemetry/observe-ledger.js +111 -0
- package/dist/internal/model/agent-llm-port.d.ts +2 -0
- package/dist/internal/model/agent-llm-port.js +1 -0
- package/dist/internal/model/llm-client.d.ts +3 -0
- package/dist/internal/model/llm-client.js +3 -0
- package/dist/internal/model/llm-failure.d.ts +26 -0
- package/dist/internal/model/llm-failure.js +63 -0
- package/dist/internal/model/llm-mode-routing.d.ts +22 -0
- package/dist/internal/model/llm-mode-routing.js +37 -0
- package/dist/internal/store/atomic-memory-cutover-sql.d.ts +13 -0
- package/dist/internal/store/atomic-memory-cutover-sql.js +237 -0
- package/dist/internal/store/connection.d.ts +2 -0
- package/dist/internal/store/connection.js +2 -0
- package/dist/internal/store/data-bootstrap.d.ts +2 -0
- package/dist/internal/store/data-bootstrap.js +2 -0
- package/dist/internal/store/data-paths.d.ts +2 -0
- package/dist/internal/store/data-paths.js +65 -0
- package/dist/internal/store/maintenance.d.ts +75 -0
- package/dist/internal/store/maintenance.js +1401 -0
- package/dist/internal/store/memory-kinds-cutover-migrator.d.ts +28 -0
- package/dist/internal/store/memory-kinds-cutover-migrator.js +415 -0
- package/dist/internal/store/migrations.d.ts +27 -0
- package/dist/internal/store/migrations.js +201 -0
- package/dist/internal/store/sqlite-runtime.d.ts +2 -0
- package/dist/internal/store/sqlite-runtime.js +109 -0
- package/dist/internal/store/store.d.ts +3 -0
- package/dist/internal/store/store.js +2 -0
- package/dist/learning-file-maintenance-9b-Ut6Kv.d.ts +30 -0
- package/dist/llm-client-BSYUAcUb.js +1374 -0
- package/dist/llm-client-DOTSGzhe.d.ts +51 -0
- package/dist/locales-JxGmkG6t.d.ts +7 -0
- package/dist/log-site-catalog.generated-BMKWj-Nx.js +2321 -0
- package/dist/log-site-catalog.json +1 -0
- package/dist/lru-DyoaTyIs.d.ts +14 -0
- package/dist/memdump.d.ts +52 -0
- package/dist/memdump.js +163 -0
- package/dist/memory-entry-projector-DHo8jH10.js +1015 -0
- package/dist/memory-kind-policy-BiuRjSJc.d.ts +23 -0
- package/dist/memory-metadata-codec-DL1sbJiN.js +577 -0
- package/dist/memory-metadata-codec-DUvsYe_X.d.ts +68 -0
- package/dist/memory-runtime-DqUS4cWi.js +19459 -0
- package/dist/memory-scope-policy-1gg5QlWZ.d.ts +67 -0
- package/dist/memory-scope-policy-DICSCURA.js +283 -0
- package/dist/memory-snapshot-CqY1BUUA.d.ts +16 -0
- package/dist/memory-source-order-YMRoeDLd.js +134 -0
- package/dist/memory-store-base-CQ_bHlYA.d.ts +1094 -0
- package/dist/memory-store-shared-DqpWJXZZ.js +158 -0
- package/dist/memory-store-write-validation-B_hDG2zf.js +243 -0
- package/dist/memory-telemetry-incidents-BWA9kcZx.js +8 -0
- package/dist/memory-telemetry-metadata-CA7W8tK6.js +77 -0
- package/dist/memory-telemetry-outbox-ddTdImt7.d.ts +74 -0
- package/dist/memory-telemetry-receipts-MAJecvXQ.d.ts +34 -0
- package/dist/memory-telemetry-receipts-YsxbwOAf.js +91 -0
- package/dist/memory-telemetry-types-CufVmrCs.d.ts +14 -0
- package/dist/memory-temporality-classifier-BUjXG5o7.js +184 -0
- package/dist/memory-temporality-classifier-Brht5jyK.d.ts +43 -0
- package/dist/memory-tier-promoter-CqGxCkue.d.ts +43 -0
- package/dist/memory-tool-dependencies-CatGzI9R.d.ts +14 -0
- package/dist/memory-tool-dependencies-DjUoelnm.js +19 -0
- package/dist/model-call-table-CspopkBg.js +563 -0
- package/dist/model-reply-text-CKopStP2.js +334 -0
- package/dist/observable-embedder-CNNe9gkg.d.ts +17 -0
- package/dist/observable-llm-client-CRuKlefQ.d.ts +21 -0
- package/dist/observable-memory-store-CnGDpOY5.d.ts +73 -0
- package/dist/observable-retriever-Cooc62Qw.d.ts +23 -0
- package/dist/operation-cancellation-CTKWwNHk.js +81 -0
- package/dist/paths-qVF-5uBq.d.ts +1 -0
- package/dist/plugin-config-schema-C0UUbOmG.d.ts +413 -0
- package/dist/plugin-config-schema-YJLyIIcJ.js +361 -0
- package/dist/profile-TWPJ_myr.d.ts +13 -0
- package/dist/profile-section-writer-BhGKPBjw.js +2149 -0
- package/dist/provider-registration-CF1tg8Xy.js +721 -0
- package/dist/provider-runtime-types-DFhtdA6d.d.ts +134 -0
- package/dist/provider-types-CZGm6v88.d.ts +23 -0
- package/dist/redact-BTIZcHQL.d.ts +5 -0
- package/dist/reflection-command-hooks-ClUl-iv6.js +644 -0
- package/dist/reflection-command-hooks-G1-dI2Av.d.ts +32 -0
- package/dist/reflection-deps-Ccm2Jf5W.d.ts +19 -0
- package/dist/reflection-embedded-generator-BRvqV5N-.js +130 -0
- package/dist/reflection-embedded-generator-kfQfKEYV.d.ts +14 -0
- package/dist/reflection-injection-hooks-CS_uhjoD.d.ts +43 -0
- package/dist/reflection-lifecycle-hooks-CRSpUdLi.d.ts +27 -0
- package/dist/relation-dictionary-Cev1kyLe.js +4248 -0
- package/dist/release-download.d.ts +8 -0
- package/dist/release-download.js +32 -0
- package/dist/relevant-memories-context-m8nuFZcM.js +23 -0
- package/dist/rem-batch-executor-Dg2HgROM.js +2 -0
- package/dist/rem-batch-executor-DuC4nYyf.js +31640 -0
- package/dist/rem-consumer-retrieval-CR0dtcHR.js +246 -0
- package/dist/rem-trigger-Hn6od8IV.js +730 -0
- package/dist/resolver-Dy-hnjCR.js +103 -0
- package/dist/results-C3ZLroMb.js +140 -0
- package/dist/retrieval-gate-Bx2Zg7jD.d.ts +31 -0
- package/dist/retriever-Dxss5fRv.d.ts +469 -0
- package/dist/retriever-ZoLvPRHq.js +1757 -0
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/routes-DLHT__Ay.js +60 -0
- package/dist/runtime-audit-log-BCeujlEp.js +430 -0
- package/dist/runtime-audit-log-zpQiR9HT.d.ts +149 -0
- package/dist/scopes-CSOn6zdd.js +71 -0
- package/dist/scopes-CtrY-YQ3.d.ts +23 -0
- package/dist/server-CSvxchqg.js +1412 -0
- package/dist/session-registry-DBoE7AvZ.d.ts +14 -0
- package/dist/sidecar/main.d.ts +1 -0
- package/dist/sidecar/main.js +56 -0
- package/dist/signed-registry-constants-Bv0fgZ8Q.d.ts +12 -0
- package/dist/signed-registry-constants-yq3DlG3B.js +82 -0
- package/dist/sno-station-mem-runtime-dependencies-CoWqUMbK.js +30 -0
- package/dist/sno-station-mem-runtime-dependencies-DHESIuPn.d.ts +31 -0
- package/dist/sqlite-runtime-L_ywirTm.d.ts +58 -0
- package/dist/store-C8sUTssE.d.ts +27 -0
- package/dist/store-nPql26YM.js +5830 -0
- package/dist/strategy-hook-runner-Bxy851Xx.d.ts +16 -0
- package/dist/strategy-hook-runner-Djify5Rw.js +110 -0
- package/dist/token-counter-BD1f48Km.js +73 -0
- package/dist/trace-C1JxMfs-.d.ts +86 -0
- package/dist/types-CWdhXLxr.d.ts +477 -0
- package/dist/types-pVomjzqR.d.ts +132 -0
- package/dist/unplaced-candidate-migration-CbQHzcEM.js +940 -0
- package/dist/utils-Ctb9aevJ.d.ts +34 -0
- package/drizzle/0000_initial.sql +10 -0
- package/drizzle/0001_virtual_tables.sql +34 -0
- package/drizzle/0002_add_indexes.sql +11 -0
- package/drizzle/0003_content_hash_lookup_index.sql +2 -0
- package/drizzle/0004_chunk_swap.sql +60 -0
- package/drizzle/0005_drop_legacy_vec_fts.sql +10 -0
- package/drizzle/0006_fts_simple.sql +45 -0
- package/drizzle/0007_restore_simple_fts.sql +40 -0
- package/drizzle/0008_widen_memory_hash_unique_index.sql +4 -0
- package/drizzle/0009_memory_telemetry.sql +109 -0
- package/drizzle/0010_provider_mappings.sql +27 -0
- package/drizzle/0011_db_optimization.sql +82 -0
- package/drizzle/0012_b_profile_lanes.sql +9 -0
- package/drizzle/0013_extraction_timestamps.sql +6 -0
- package/drizzle/0014_extraction_timestamp_source.sql +3 -0
- package/drizzle/0015_task_lifecycle_state.sql +101 -0
- package/drizzle/0016_task_lifecycle_legacy_migration.sql +144 -0
- package/drizzle/0017_unplaced_candidates.sql +15 -0
- package/drizzle/0018_rem_batch_chassis.sql +71 -0
- package/drizzle/0019_profile_recovery_entries.sql +17 -0
- package/drizzle/0020_rem_scan_retry_progress.down.sql +14 -0
- package/drizzle/0020_rem_scan_retry_progress.sql +24 -0
- package/drizzle/0021_rem_two_facet_storage.down.sql +14 -0
- package/drizzle/0021_rem_two_facet_storage.sql +42 -0
- package/drizzle/0022_rem_facet_chunk_versions.down.sql +4 -0
- package/drizzle/0022_rem_facet_chunk_versions.sql +4 -0
- package/drizzle/0023_rem_defect_ledger.sql +40 -0
- package/drizzle/0024_rem_unbuilt_foundations.down.sql +13 -0
- package/drizzle/0024_rem_unbuilt_foundations.sql +65 -0
- package/drizzle/0025_rem_journal_operation_constraint.sql +28 -0
- package/drizzle/0026_rem_journal_detail.sql +1 -0
- package/drizzle/0027_legacy_nodix_namespace.sql +3 -0
- package/drizzle/0028_memory_timezone.sql +23 -0
- package/drizzle/0029_rem_write_hash_symmetry.sql +17 -0
- package/drizzle/0030_atomic_memory_additive.sql +105 -0
- package/drizzle/0031_atomic_extraction_ledger.sql +23 -0
- package/drizzle/0032_atomic_memory_entities.sql +12 -0
- package/drizzle/0033_todo_own_store.sql +99 -0
- package/drizzle/meta/0000_snapshot.json +87 -0
- package/drizzle/meta/_journal.json +244 -0
- package/generated/rem-operations.json +1 -0
- package/package.json +126 -4
- package/scripts/download-simple-tokenizer.mjs +254 -0
- package/settings.default.json +243 -0
- package/skills/extract-atomic-memory/SKILL.md +298 -0
- package/skills/extract-atomic-memory/references/account-for-turns.md +9 -0
- package/skills/extract-atomic-memory/references/calendar-meaning.md +64 -0
- package/skills/extract-atomic-memory/references/capture.md +120 -0
- package/skills/extract-atomic-memory/references/enrichment.md +92 -0
- package/skills/extract-atomic-memory/references/missing-durable-half.md +6 -0
- package/skills/extract-atomic-memory/references/progress-classification.md +21 -0
- package/skills/extract-atomic-memory/references/resolve-subject.md +19 -0
- package/skills/extract-atomic-memory/references/surrounding-context.md +10 -0
- package/skills/extract-atomic-memory/references/user-subject-guard.md +29 -0
- package/skills/judge-group-closure/SKILL.md +25 -0
- package/skills/judge-rem-memory-updates/SKILL.md +56 -0
- package/skills/judge-rem-memory-updates/agents/openai.yaml +4 -0
- package/skills/judge-retired-position/SKILL.md +25 -0
- package/skills/judge-task-lifecycle/SKILL.md +45 -0
- package/skills/key-state-attribute/SKILL.md +16 -0
- package/skills/resolve-entity-identity/SKILL.md +24 -0
- package/skills/resolve-relative-time/SKILL.md +22 -0
- package/sqlite-extensions/LICENSE-simple-tokenizer +28 -0
- package/sqlite-extensions/LICENSE-sqlite-vec +21 -0
- package/sqlite-extensions/linux-arm64/vec0.so +0 -0
- package/sqlite-extensions/linux-x64/vec0.so +0 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { assertLocalFilesystem, getInstallManifestPath, getSnoStationMemDataDir } from "./internal/store/data-paths.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { createLogger } from "@snoai/utils/logger";
|
|
4
|
+
import { basename, dirname } from "node:path";
|
|
5
|
+
import { createUUIDv7, isLowercaseCanonicalUUIDv7 } from "@snoai/common-core";
|
|
6
|
+
import { chmodSync, closeSync, existsSync, fsyncSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, writeFileSync } from "node:fs";
|
|
7
|
+
const INSTALL_MANIFEST_TEMP_SUFFIX = ".tmp-";
|
|
8
|
+
/** Schema. No `lastSeenVersion` / `lastSeenAt`. */
|
|
9
|
+
const InstallManifestSchema = z.object({
|
|
10
|
+
schemaVersion: z.literal(1),
|
|
11
|
+
dataFormatVersion: z.literal(1),
|
|
12
|
+
installationId: z.string().refine(isLowercaseCanonicalUUIDv7, { message: "installationId must be a lowercase canonical UUID-v7" }),
|
|
13
|
+
createdAt: z.string().datetime(),
|
|
14
|
+
dbPath: z.string().min(1)
|
|
15
|
+
});
|
|
16
|
+
/** Thrown when the on-disk manifest fails Zod validation or JSON parsing. */
|
|
17
|
+
var ManifestSchemaError = class extends Error {
|
|
18
|
+
path;
|
|
19
|
+
kind = "ManifestSchemaError";
|
|
20
|
+
constructor(path, cause) {
|
|
21
|
+
super(`install manifest at ${path} is corrupt or has unexpected schema: ${cause instanceof Error ? cause.message : String(cause)}`, { cause: cause instanceof Error ? cause : void 0 });
|
|
22
|
+
this.path = path;
|
|
23
|
+
this.name = "ManifestSchemaError";
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Thrown when the data dir contains user data (DB / audit log / cost log) but
|
|
28
|
+
* `install.json` is missing, so nothing destructive happens
|
|
29
|
+
* here; the user must restore `install.json` from backup or move the data aside.
|
|
30
|
+
*/
|
|
31
|
+
var ManifestMissingButDataPresentError = class extends Error {
|
|
32
|
+
dataDir;
|
|
33
|
+
kind = "ManifestMissingButDataPresentError";
|
|
34
|
+
constructor(dataDir) {
|
|
35
|
+
super(`install.json is missing but the data dir at ${dataDir} contains user data; refusing to overwrite. Restore install.json from backup or move the data aside.`);
|
|
36
|
+
this.dataDir = dataDir;
|
|
37
|
+
this.name = "ManifestMissingButDataPresentError";
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
/** Read + Zod-validate `install.json`. Throws `ManifestSchemaError` on any failure. */
|
|
41
|
+
function readInstallManifest(path) {
|
|
42
|
+
let raw;
|
|
43
|
+
try {
|
|
44
|
+
raw = readFileSync(path, "utf8");
|
|
45
|
+
} catch (err) {
|
|
46
|
+
throw new ManifestSchemaError(path, err);
|
|
47
|
+
}
|
|
48
|
+
let parsed;
|
|
49
|
+
try {
|
|
50
|
+
parsed = JSON.parse(raw);
|
|
51
|
+
} catch (err) {
|
|
52
|
+
throw new ManifestSchemaError(path, err);
|
|
53
|
+
}
|
|
54
|
+
const result = InstallManifestSchema.safeParse(parsed);
|
|
55
|
+
if (!result.success) throw new ManifestSchemaError(path, result.error);
|
|
56
|
+
return result.data;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Atomic write: tmp → fsync(tmp) → rename(tmp, target) → fsync(parent dir).
|
|
60
|
+
* POSIX rename is atomic on local FS; the parent fsync makes the rename
|
|
61
|
+
* durable across a power loss. Mode 0644 (no secrets in the manifest).
|
|
62
|
+
*/
|
|
63
|
+
function writeInstallManifestAtomic(path, manifest) {
|
|
64
|
+
const validated = InstallManifestSchema.parse(manifest);
|
|
65
|
+
const dir = dirname(path);
|
|
66
|
+
mkdirSync(dir, {
|
|
67
|
+
recursive: true,
|
|
68
|
+
mode: 448
|
|
69
|
+
});
|
|
70
|
+
const tmp = `${path}${INSTALL_MANIFEST_TEMP_SUFFIX}${process.pid}-${Date.now().toString(36)}`;
|
|
71
|
+
writeFileSync(tmp, JSON.stringify(validated), { mode: 420 });
|
|
72
|
+
chmodSync(tmp, 420);
|
|
73
|
+
const fd = openSync(tmp, "r");
|
|
74
|
+
try {
|
|
75
|
+
fsyncSync(fd);
|
|
76
|
+
} finally {
|
|
77
|
+
closeSync(fd);
|
|
78
|
+
}
|
|
79
|
+
renameSync(tmp, path);
|
|
80
|
+
const dirFd = openSync(dir, 0);
|
|
81
|
+
try {
|
|
82
|
+
fsyncSync(dirFd);
|
|
83
|
+
} finally {
|
|
84
|
+
closeSync(dirFd);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** Build a fresh manifest at first-install time. UUIDv7 for time-ordering. */
|
|
88
|
+
function freshInstallManifest(args) {
|
|
89
|
+
return InstallManifestSchema.parse({
|
|
90
|
+
schemaVersion: 1,
|
|
91
|
+
dataFormatVersion: 1,
|
|
92
|
+
installationId: createUUIDv7(),
|
|
93
|
+
createdAt: args.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
94
|
+
dbPath: args.dbPath
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/store/data-bootstrap.ts
|
|
99
|
+
/** @file data-bootstrap.ts
|
|
100
|
+
* @purpose Drive the boot flow: ensure data dir exists, probe
|
|
101
|
+
* filesystem, then resolve or create the install manifest
|
|
102
|
+
* and return the settings-selected DB path the rest of the runtime should open.
|
|
103
|
+
* @boundary Called once at plugin register-time, AFTER `initSqliteRuntime()`
|
|
104
|
+
* resolves the DEK. Returns `{ dbPath, manifest, manifestPath }`.
|
|
105
|
+
*/
|
|
106
|
+
const log = createLogger("sno-station-mem:data-bootstrap");
|
|
107
|
+
/** Detect "data exists but manifest missing". */
|
|
108
|
+
function newDirHasUserData(dataDir, manifestPath) {
|
|
109
|
+
const manifestTempPrefix = `${basename(manifestPath)}${INSTALL_MANIFEST_TEMP_SUFFIX}`;
|
|
110
|
+
try {
|
|
111
|
+
return readdirSync(dataDir, { withFileTypes: true }).some((entry) => !(entry.isFile() && entry.name.startsWith(manifestTempPrefix)));
|
|
112
|
+
} catch {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Branches:
|
|
118
|
+
* 1. manifest exists → read + validate.
|
|
119
|
+
* 2. manifest missing AND data dir contains user data → refuse.
|
|
120
|
+
* 3. manifest missing, dir empty → fresh install.
|
|
121
|
+
*/
|
|
122
|
+
function bootstrapDataLayout(storePath) {
|
|
123
|
+
const dataDir = getSnoStationMemDataDir();
|
|
124
|
+
mkdirSync(dataDir, {
|
|
125
|
+
recursive: true,
|
|
126
|
+
mode: 448
|
|
127
|
+
});
|
|
128
|
+
assertLocalFilesystem(dataDir);
|
|
129
|
+
const manifestPath = getInstallManifestPath();
|
|
130
|
+
if (existsSync(manifestPath)) {
|
|
131
|
+
const manifest = readInstallManifest(manifestPath);
|
|
132
|
+
const dbPath = storePath;
|
|
133
|
+
log.info("manifest loaded", {
|
|
134
|
+
installationId: manifest.installationId,
|
|
135
|
+
dataFormatVersion: manifest.dataFormatVersion,
|
|
136
|
+
dbPath
|
|
137
|
+
}, {
|
|
138
|
+
event_name: "sno_station_mem.data-bootstrap.manifest.loaded",
|
|
139
|
+
file: "packages/memory/src/store/data-bootstrap.ts",
|
|
140
|
+
function: "bootstrapDataLayout",
|
|
141
|
+
site_id: "data-bootstrap.bootstrapDataLayout.4fc42585ae"
|
|
142
|
+
});
|
|
143
|
+
return {
|
|
144
|
+
dbPath,
|
|
145
|
+
manifest,
|
|
146
|
+
manifestPath,
|
|
147
|
+
dataDir
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
if (newDirHasUserData(dataDir, manifestPath)) throw new ManifestMissingButDataPresentError(dataDir);
|
|
151
|
+
const manifest = freshInstallManifest({ dbPath: storePath });
|
|
152
|
+
writeInstallManifestAtomic(manifestPath, manifest);
|
|
153
|
+
const resolved = storePath;
|
|
154
|
+
log.info("fresh install bootstrapped", {
|
|
155
|
+
installationId: manifest.installationId,
|
|
156
|
+
dataFormatVersion: manifest.dataFormatVersion,
|
|
157
|
+
dbPath: resolved
|
|
158
|
+
}, {
|
|
159
|
+
event_name: "sno_station_mem.data-bootstrap.fresh.install.bootstrapped",
|
|
160
|
+
file: "packages/memory/src/store/data-bootstrap.ts",
|
|
161
|
+
function: "bootstrapDataLayout",
|
|
162
|
+
site_id: "data-bootstrap.bootstrapDataLayout.4af3189946"
|
|
163
|
+
});
|
|
164
|
+
return {
|
|
165
|
+
dbPath: resolved,
|
|
166
|
+
manifest,
|
|
167
|
+
manifestPath,
|
|
168
|
+
dataDir
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
export { bootstrapDataLayout as t };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/store/data-paths.d.ts
|
|
2
|
+
/** Typed boundary error for refuse-to-operate when data dir is on NFS/SMB/FUSE. */
|
|
3
|
+
declare class NonLocalFilesystemError extends Error {
|
|
4
|
+
readonly dir: string;
|
|
5
|
+
readonly fsType: number;
|
|
6
|
+
readonly kind: "NonLocalFilesystemError";
|
|
7
|
+
constructor(dir: string, fsType: number);
|
|
8
|
+
}
|
|
9
|
+
declare function getSnoStationMemDataDir(): string;
|
|
10
|
+
declare function getInstallManifestPath(): string;
|
|
11
|
+
declare function getAuditLogPath(): string;
|
|
12
|
+
declare function getCostLogPath(): string;
|
|
13
|
+
declare function getKillswitchPath(): string;
|
|
14
|
+
declare function getBackupsDir(): string;
|
|
15
|
+
/**
|
|
16
|
+
* `statfs(2)`-based check: throws `NonLocalFilesystemError` when `dir` sits on
|
|
17
|
+
* NFS / SMB / FUSE (which includes iCloud-Drive-watched directories). POSIX
|
|
18
|
+
* only — Windows is out of v1 projectId.
|
|
19
|
+
*/
|
|
20
|
+
declare function assertLocalFilesystem(dir: string): void;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { getCostLogPath as a, getSnoStationMemDataDir as c, getBackupsDir as i, assertLocalFilesystem as n, getInstallManifestPath as o, getAuditLogPath as r, getKillswitchPath as s, NonLocalFilesystemError as t };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import "./types-CWdhXLxr.js";
|
|
2
|
+
//#region src/engine/reflection/reflection-line-loader.d.ts
|
|
3
|
+
interface ReflectionLineSource {
|
|
4
|
+
line: string;
|
|
5
|
+
rowId: string;
|
|
6
|
+
factId: string;
|
|
7
|
+
sourceAgentId: string;
|
|
8
|
+
memoryKind: string;
|
|
9
|
+
projectId: string;
|
|
10
|
+
rank: number;
|
|
11
|
+
score: number;
|
|
12
|
+
}
|
|
13
|
+
interface LoadedReflectionSlices {
|
|
14
|
+
invariants: string[];
|
|
15
|
+
derived: string[];
|
|
16
|
+
invariantSources: ReflectionLineSource[];
|
|
17
|
+
derivedSources: ReflectionLineSource[];
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/engine/reflection/derived-line-cache.d.ts
|
|
21
|
+
type ReflectionDerivedCacheEntry = {
|
|
22
|
+
updatedAt: number;
|
|
23
|
+
derived: string[];
|
|
24
|
+
derivedSources?: ReflectionLineSource[];
|
|
25
|
+
};
|
|
26
|
+
type ReflectionDerivedCache = Map<string, ReflectionDerivedCacheEntry>;
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/engine/reflection/derived-suppression-cache.d.ts
|
|
29
|
+
type ReflectionDerivedSuppressionEntry = {
|
|
30
|
+
updatedAt: number;
|
|
31
|
+
until: number;
|
|
32
|
+
reason: string;
|
|
33
|
+
};
|
|
34
|
+
type ReflectionDerivedSuppressionCache = Map<string, ReflectionDerivedSuppressionEntry>;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { ReflectionDerivedCache as n, LoadedReflectionSlices as r, ReflectionDerivedSuppressionCache as t };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DiagnosticInput, DiagnosticInput as DiagnosticInput$1, LogLevel, LogSource } from "@snoai/utils/log-encoder";
|
|
2
|
+
//#region src/engine/observability/early-diagnostics.d.ts
|
|
3
|
+
export declare function encodeDiagnostic(input: DiagnosticInput$1): string;
|
|
4
|
+
export declare function writeEmergencyDiagnostic(input: DiagnosticInput$1): void;
|
|
5
|
+
//#endregion
|
|
6
|
+
export type { DiagnosticInput, LogLevel, LogSource };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { n as version, t as logSiteCatalog } from "./log-site-catalog.generated-BMKWj-Nx.js";
|
|
2
|
+
import { diagnosticProcessInstanceId, encodeDiagnostic as encodeDiagnostic$1, writeEmergencyDiagnostic as writeEmergencyDiagnostic$1 } from "@snoai/utils/log-encoder";
|
|
3
|
+
//#region src/engine/observability/early-diagnostics.ts
|
|
4
|
+
function bindApplication(input) {
|
|
5
|
+
const site = logSiteCatalog.sites[input.source.site_id];
|
|
6
|
+
const matched = site?.file === input.source.file && site?.function === input.source.function;
|
|
7
|
+
return {
|
|
8
|
+
...input,
|
|
9
|
+
resource: {
|
|
10
|
+
service_name: "sno-station-mem",
|
|
11
|
+
service_version: version,
|
|
12
|
+
build_id: logSiteCatalog.build_id,
|
|
13
|
+
process_id: process.pid,
|
|
14
|
+
process_instance_id: diagnosticProcessInstanceId
|
|
15
|
+
},
|
|
16
|
+
resolvedSource: {
|
|
17
|
+
catalog_status: matched ? "available" : "unavailable",
|
|
18
|
+
...!matched ? { catalog_reason: "site_not_in_catalog" } : {}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function encodeDiagnostic(input) {
|
|
23
|
+
return encodeDiagnostic$1(bindApplication(input));
|
|
24
|
+
}
|
|
25
|
+
function writeEmergencyDiagnostic(input) {
|
|
26
|
+
writeEmergencyDiagnostic$1(bindApplication(input));
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { encodeDiagnostic, writeEmergencyDiagnostic };
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { CACHE_TTL_MS, RETRIEVAL_STORAGE_CHUNK_PROFILE } from "./internal/config/index.js";
|
|
2
|
+
import { EmbeddingError } from "./internal/engine/shared/errors.js";
|
|
3
|
+
import { chunk } from "@snoai/chunking";
|
|
4
|
+
import { CachedEmbeddingProvider, LOCAL_EMBEDDING_CACHE_DIR_DEFAULT, LOCAL_EMBEDDING_MODEL, LOCAL_EMBEDDING_MODEL_REVISION, LocalEmbedProvider, ensureModelDownloaded } from "@snoai/embedder";
|
|
5
|
+
import { createLogger } from "@snoai/utils/logger";
|
|
6
|
+
//#region src/engine/extraction/embedding-provider-factory.ts
|
|
7
|
+
function resolveEmbeddingCacheDir(config) {
|
|
8
|
+
return config.cacheDir || LOCAL_EMBEDDING_CACHE_DIR_DEFAULT;
|
|
9
|
+
}
|
|
10
|
+
/** Assembles provider from validated inputs for deterministic embedding generation. */
|
|
11
|
+
function buildProvider(config) {
|
|
12
|
+
return new LocalEmbedProvider({
|
|
13
|
+
...config.cacheDir ? { cacheDir: config.cacheDir } : {},
|
|
14
|
+
offline: config.offline,
|
|
15
|
+
mirror: config.mirror,
|
|
16
|
+
dtype: config.dtype,
|
|
17
|
+
sessionOptions: config.sessionOptions,
|
|
18
|
+
...config.model !== void 0 ? { model: config.model } : {},
|
|
19
|
+
...config.revision !== void 0 ? { revision: config.revision } : {},
|
|
20
|
+
...config.nativeDim !== void 0 ? { nativeDim: config.nativeDim } : {},
|
|
21
|
+
...config.dimensions !== void 0 ? { outputDim: config.dimensions } : {},
|
|
22
|
+
...config.pooling !== void 0 ? { pooling: config.pooling } : {}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/engine/extraction/embedding-vector-aggregation.ts
|
|
27
|
+
/**
|
|
28
|
+
* Compute L2-normalized weighted average of Float32Array vectors.
|
|
29
|
+
* Weights are typically chunk char lengths so longer chunks contribute more.
|
|
30
|
+
*/
|
|
31
|
+
function weightedAverageFloat32(vectors, weights, dim) {
|
|
32
|
+
const acc = new Array(dim).fill(0);
|
|
33
|
+
let totalWeight = 0;
|
|
34
|
+
for (let i = 0; i < vectors.length; i++) {
|
|
35
|
+
const w = weights[i] ?? 1;
|
|
36
|
+
const vec = vectors[i];
|
|
37
|
+
if (!vec) continue;
|
|
38
|
+
totalWeight += w;
|
|
39
|
+
for (let j = 0; j < dim; j++) acc[j] = (acc[j] ?? 0) + (vec[j] ?? 0) * w;
|
|
40
|
+
}
|
|
41
|
+
if (totalWeight > 0) for (let j = 0; j < dim; j++) acc[j] = (acc[j] ?? 0) / totalWeight;
|
|
42
|
+
let norm = 0;
|
|
43
|
+
for (let j = 0; j < dim; j++) {
|
|
44
|
+
const v = acc[j] ?? 0;
|
|
45
|
+
norm += v * v;
|
|
46
|
+
}
|
|
47
|
+
norm = Math.sqrt(norm);
|
|
48
|
+
if (norm > 0) for (let j = 0; j < dim; j++) acc[j] = (acc[j] ?? 0) / norm;
|
|
49
|
+
return Float32Array.from(acc);
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/engine/shared/token-bound.ts
|
|
53
|
+
/** @file token-bound.ts
|
|
54
|
+
* @purpose Cuts text to a token budget under any monotonic token counter.
|
|
55
|
+
* @boundary Pure text function; the caller supplies the counter.
|
|
56
|
+
*/
|
|
57
|
+
/**
|
|
58
|
+
* Longest prefix of `text` costing at most `maxTokens` under `countTokens`. Bounding by
|
|
59
|
+
* token cost rather than character count keeps the budget honest across scripts: a
|
|
60
|
+
* character bound buys several times more prompt for Latin text than for CJK.
|
|
61
|
+
*
|
|
62
|
+
* Binary search is safe because every counter used here never decreases as the
|
|
63
|
+
* substring is extended, and searching over code points rather than UTF-16 units means
|
|
64
|
+
* a cut can never split a surrogate pair. The result is right-trimmed, which can only
|
|
65
|
+
* lower the token count, so the budget still holds.
|
|
66
|
+
*/
|
|
67
|
+
function truncateToTokens(text, maxTokens, countTokens) {
|
|
68
|
+
if (countTokens(text) <= maxTokens) return text;
|
|
69
|
+
const codePoints = Array.from(text);
|
|
70
|
+
let low = 0;
|
|
71
|
+
let high = codePoints.length;
|
|
72
|
+
while (low < high) {
|
|
73
|
+
const mid = Math.ceil((low + high) / 2);
|
|
74
|
+
if (countTokens(codePoints.slice(0, mid).join("")) <= maxTokens) low = mid;
|
|
75
|
+
else high = mid - 1;
|
|
76
|
+
}
|
|
77
|
+
return codePoints.slice(0, low).join("").trimEnd();
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/engine/extraction/embedding-provider-client.ts
|
|
81
|
+
/** @file embedding-provider-client.ts
|
|
82
|
+
* @purpose Adapts embedding providers to the plugin retrieval and storage contract.
|
|
83
|
+
* @boundary Local ONNX embeddings, chunk sizing, and vector dimensions.
|
|
84
|
+
* @see store.ts, retriever.ts.
|
|
85
|
+
*/
|
|
86
|
+
/** Local ONNX embedding with an LRU cache and oversized-text chunking. */
|
|
87
|
+
const log = createLogger("sno-station-mem:embed");
|
|
88
|
+
var Embedder = class {
|
|
89
|
+
provider;
|
|
90
|
+
chunkingEnabled;
|
|
91
|
+
dimensions;
|
|
92
|
+
providerKind;
|
|
93
|
+
model;
|
|
94
|
+
warmupPromise = null;
|
|
95
|
+
modelDownload;
|
|
96
|
+
/**
|
|
97
|
+
* Initializes embedding generation collaborators while keeping runtime work in explicit
|
|
98
|
+
* methods.
|
|
99
|
+
*/
|
|
100
|
+
constructor(config, _stateDir) {
|
|
101
|
+
this.chunkingEnabled = config.chunking !== false;
|
|
102
|
+
const providerKind = config.provider ?? "local-onnx";
|
|
103
|
+
const inner = buildProvider(config);
|
|
104
|
+
this.modelDownload = config.model && config.model !== LOCAL_EMBEDDING_MODEL || config.revision && config.revision !== LOCAL_EMBEDDING_MODEL_REVISION ? void 0 : {
|
|
105
|
+
cacheDir: resolveEmbeddingCacheDir(config),
|
|
106
|
+
offline: config.offline,
|
|
107
|
+
mirror: config.mirror,
|
|
108
|
+
...config.dtype ? { dtype: config.dtype } : {}
|
|
109
|
+
};
|
|
110
|
+
this.dimensions = inner.dimension;
|
|
111
|
+
this.providerKind = providerKind;
|
|
112
|
+
this.model = config.model && config.model.trim().length > 0 ? config.model : LOCAL_EMBEDDING_MODEL;
|
|
113
|
+
this.provider = new CachedEmbeddingProvider(inner, {
|
|
114
|
+
maxSize: 256,
|
|
115
|
+
ttlMs: CACHE_TTL_MS
|
|
116
|
+
});
|
|
117
|
+
log.info("embedder initialized", {
|
|
118
|
+
provider: providerKind,
|
|
119
|
+
model: this.model,
|
|
120
|
+
dimensions: this.dimensions,
|
|
121
|
+
chunking: this.chunkingEnabled,
|
|
122
|
+
maxContextTokens: 512
|
|
123
|
+
}, {
|
|
124
|
+
event_name: "sno_station_mem.embedding-provider-client.embedder.initialized",
|
|
125
|
+
file: "packages/memory/src/engine/extraction/embedding-provider-client.ts",
|
|
126
|
+
function: "<anonymous callback>",
|
|
127
|
+
site_id: "embedding-provider-client.<anonymous callback>.3c8d5ee192"
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/** Converts float32 into the transport shape expected by embedding generation. */
|
|
131
|
+
toFloat32(vector) {
|
|
132
|
+
if (vector.length !== this.dimensions) throw new EmbeddingError(`Embedding dimension mismatch: expected ${this.dimensions}, got ${vector.length}`);
|
|
133
|
+
return Float32Array.from(vector);
|
|
134
|
+
}
|
|
135
|
+
buildEmbedderChunkConfig() {
|
|
136
|
+
return {
|
|
137
|
+
contentType: "prose",
|
|
138
|
+
minTokens: RETRIEVAL_STORAGE_CHUNK_PROFILE.minTokens,
|
|
139
|
+
targetTokens: 512,
|
|
140
|
+
maxTokens: 512,
|
|
141
|
+
overlapTokens: RETRIEVAL_STORAGE_CHUNK_PROFILE.overlapTokens
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Exact token count under the embedding model's own tokenizer — the count the model
|
|
146
|
+
* sees, so `DEFAULT_MAX_CONTEXT_TOKENS` checked against it is a hard limit. Synchronous;
|
|
147
|
+
* throws until the model has loaded, which `warmup()` does at plugin register time.
|
|
148
|
+
*/
|
|
149
|
+
countTokens(text) {
|
|
150
|
+
return this.provider.countTokens(text);
|
|
151
|
+
}
|
|
152
|
+
/** Longest prefix of `text` within `maxTokens` under {@link countTokens}. */
|
|
153
|
+
truncateToTokens(text, maxTokens) {
|
|
154
|
+
return truncateToTokens(text, maxTokens, (t) => this.countTokens(t));
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Wait for warmup before issuing real embedding work. Calls `warmup()`
|
|
158
|
+
* itself so callers that bypass register-time warmup (tests, ad-hoc
|
|
159
|
+
* scripts) still get the same fail-loud probe — `warmup()` is memoized,
|
|
160
|
+
* so repeated calls reuse the in-flight or completed promise.
|
|
161
|
+
*/
|
|
162
|
+
async awaitWarmup() {
|
|
163
|
+
await this.warmup();
|
|
164
|
+
}
|
|
165
|
+
/** Implements embed as the local embedding generation operation. */
|
|
166
|
+
async embed(text) {
|
|
167
|
+
await this.awaitWarmup();
|
|
168
|
+
if (!this.chunkingEnabled) return this.embedDirect(text);
|
|
169
|
+
const tokens = this.countTokens(text);
|
|
170
|
+
if (tokens <= 512) return this.embedDirect(text);
|
|
171
|
+
const chunks = chunk(text, this.buildEmbedderChunkConfig()).map((draft) => draft.chunkText);
|
|
172
|
+
for (const piece of chunks) {
|
|
173
|
+
const pieceTokens = this.countTokens(piece);
|
|
174
|
+
if (pieceTokens > 512) throw new EmbeddingError(`Embedder chunk of ${pieceTokens} tokens exceeds DEFAULT_MAX_CONTEXT_TOKENS (512)`);
|
|
175
|
+
}
|
|
176
|
+
if (chunks.length <= 1) return this.embedDirect(chunks[0] ?? text);
|
|
177
|
+
log.warn("legacy chunker invoked (embedding-API safety net)", {
|
|
178
|
+
chunks: chunks.length,
|
|
179
|
+
totalTokens: tokens,
|
|
180
|
+
maxTokens: 512
|
|
181
|
+
}, {
|
|
182
|
+
event_name: "sno_station_mem.embedding-provider-client.legacy.chunker.invoked.embedding.api.safety.net",
|
|
183
|
+
file: "packages/memory/src/engine/extraction/embedding-provider-client.ts",
|
|
184
|
+
function: "embed",
|
|
185
|
+
site_id: "embedding-provider-client.embed.ab60111378"
|
|
186
|
+
});
|
|
187
|
+
return weightedAverageFloat32(await this.embedMany(chunks), chunks.map((c) => c.length), this.dimensions);
|
|
188
|
+
}
|
|
189
|
+
/** Implements embed direct as the local embedding generation operation. */
|
|
190
|
+
async embedDirect(text) {
|
|
191
|
+
try {
|
|
192
|
+
const vector = await this.provider.embed(text);
|
|
193
|
+
return this.toFloat32(vector);
|
|
194
|
+
} catch (error) {
|
|
195
|
+
log.error("passage embedding failed", {
|
|
196
|
+
textLength: text.length,
|
|
197
|
+
error
|
|
198
|
+
}, {
|
|
199
|
+
event_name: "sno_station_mem.embedding-provider-client.passage.embedding.failed",
|
|
200
|
+
file: "packages/memory/src/engine/extraction/embedding-provider-client.ts",
|
|
201
|
+
function: "embedDirect",
|
|
202
|
+
site_id: "embedding-provider-client.embedDirect.c6998ac2fb"
|
|
203
|
+
});
|
|
204
|
+
throw new EmbeddingError("Failed to generate passage embedding", error);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/** Implements embed many as the local embedding generation operation. */
|
|
208
|
+
async embedMany(values) {
|
|
209
|
+
await this.awaitWarmup();
|
|
210
|
+
log.debug("batch embedding", { count: values.length }, {
|
|
211
|
+
event_name: "sno_station_mem.embedding-provider-client.batch.embedding",
|
|
212
|
+
file: "packages/memory/src/engine/extraction/embedding-provider-client.ts",
|
|
213
|
+
function: "embedMany",
|
|
214
|
+
site_id: "embedding-provider-client.embedMany.8ffe2fb365"
|
|
215
|
+
});
|
|
216
|
+
try {
|
|
217
|
+
const vectors = await this.provider.embedDocuments(values);
|
|
218
|
+
if (vectors.length !== values.length) throw new EmbeddingError(`Embedding provider returned ${vectors.length} vectors for ${values.length} inputs`);
|
|
219
|
+
return vectors.map((v) => this.toFloat32(v));
|
|
220
|
+
} catch (error) {
|
|
221
|
+
log.error("batch embedding failed", {
|
|
222
|
+
count: values.length,
|
|
223
|
+
error
|
|
224
|
+
}, {
|
|
225
|
+
event_name: "sno_station_mem.embedding-provider-client.batch.embedding.failed",
|
|
226
|
+
file: "packages/memory/src/engine/extraction/embedding-provider-client.ts",
|
|
227
|
+
function: "embedMany",
|
|
228
|
+
site_id: "embedding-provider-client.embedMany.71b35eadaf"
|
|
229
|
+
});
|
|
230
|
+
if (error instanceof EmbeddingError) throw error;
|
|
231
|
+
throw new EmbeddingError("Failed to generate batch embeddings", error);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Embed each input text individually as a passage. Used by chunk-level
|
|
236
|
+
* ingestion in `MemoryStore` — one vector per chunk, no averaging. Reuses
|
|
237
|
+
* the batch primitive and its cache.
|
|
238
|
+
*/
|
|
239
|
+
async embedChunks(texts) {
|
|
240
|
+
if (texts.length === 0) return [];
|
|
241
|
+
return this.embedMany(texts);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Force the underlying ONNX model to load and run one real inference.
|
|
245
|
+
*
|
|
246
|
+
* LocalEmbedProvider lazy-loads the model on first `embed()` call. That
|
|
247
|
+
* means `new Embedder(...)` succeeds even if the model file is missing —
|
|
248
|
+
* the failure only surfaces later, per-turn, during ambient-learning, where
|
|
249
|
+
* the error is swallowed by `Promise.allSettled`. Calling `warmup()` at
|
|
250
|
+
* plugin-register time turns a latent misconfiguration into a hard,
|
|
251
|
+
* loud registration failure. Caller should let the error propagate.
|
|
252
|
+
*/
|
|
253
|
+
async warmup() {
|
|
254
|
+
if (this.warmupPromise) return this.warmupPromise;
|
|
255
|
+
const probe = (async () => {
|
|
256
|
+
try {
|
|
257
|
+
if (this.modelDownload) await ensureModelDownloaded(this.modelDownload);
|
|
258
|
+
const vector = await this.provider.embed("warmup");
|
|
259
|
+
if (vector.length !== this.dimensions) throw new EmbeddingError(`Embedder warmup dimension mismatch: expected ${this.dimensions}, got ${vector.length}`);
|
|
260
|
+
log.info("embedder warmup ok", { dimensions: this.dimensions }, {
|
|
261
|
+
event_name: "sno_station_mem.embedding-provider-client.embedder.warmup.ok",
|
|
262
|
+
file: "packages/memory/src/engine/extraction/embedding-provider-client.ts",
|
|
263
|
+
function: "<anonymous callback>",
|
|
264
|
+
site_id: "embedding-provider-client.<anonymous callback>.32cc9ec43e"
|
|
265
|
+
});
|
|
266
|
+
} catch (error) {
|
|
267
|
+
log.error("embedder warmup failed", { error }, {
|
|
268
|
+
event_name: "sno_station_mem.embedding-provider-client.embedder.warmup.failed",
|
|
269
|
+
file: "packages/memory/src/engine/extraction/embedding-provider-client.ts",
|
|
270
|
+
function: "<anonymous callback>",
|
|
271
|
+
site_id: "embedding-provider-client.<anonymous callback>.d7a3f8337c"
|
|
272
|
+
});
|
|
273
|
+
throw new EmbeddingError("Embedder warmup failed — the plugin cannot capture or recall memories. Check that the local ONNX model exists at the configured cacheDir.", error);
|
|
274
|
+
}
|
|
275
|
+
})();
|
|
276
|
+
this.warmupPromise = probe.catch((err) => {
|
|
277
|
+
this.warmupPromise = null;
|
|
278
|
+
throw err;
|
|
279
|
+
});
|
|
280
|
+
return this.warmupPromise;
|
|
281
|
+
}
|
|
282
|
+
/** Implements dispose as the local embedding generation operation. */
|
|
283
|
+
async dispose() {
|
|
284
|
+
const warmup = this.warmupPromise;
|
|
285
|
+
if (warmup) await warmup.catch(() => void 0);
|
|
286
|
+
await this.provider.dispose();
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
/** Creates the embedder facade around the local ONNX provider. */
|
|
290
|
+
function createEmbedder(config, stateDir) {
|
|
291
|
+
return new Embedder(config, stateDir);
|
|
292
|
+
}
|
|
293
|
+
//#endregion
|
|
294
|
+
export { createEmbedder as n, Embedder as t };
|
|
@@ -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 };
|