@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,62 @@
|
|
|
1
|
+
import { g as ProductMode } from "./plugin-config-schema-C0UUbOmG.js";
|
|
2
|
+
import { n as Locale } from "./locales-JxGmkG6t.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/engine/extraction/b-profile-section-registry.d.ts
|
|
5
|
+
type BProfileSectionLocaleMap = Record<Locale, readonly string[]>;
|
|
6
|
+
interface BProfileSectionDefinition {
|
|
7
|
+
name: string;
|
|
8
|
+
domain: string;
|
|
9
|
+
synonyms: BProfileSectionLocaleMap;
|
|
10
|
+
}
|
|
11
|
+
interface BProfileSectionRegistry {
|
|
12
|
+
schema_version: number;
|
|
13
|
+
frozen_at: string;
|
|
14
|
+
domains: readonly string[];
|
|
15
|
+
gate_prompt: {
|
|
16
|
+
instructions: string;
|
|
17
|
+
registry_header: string;
|
|
18
|
+
candidates_header: string;
|
|
19
|
+
output_contract: string;
|
|
20
|
+
};
|
|
21
|
+
active_task_shape: {
|
|
22
|
+
projection_max_items: number;
|
|
23
|
+
projection_title_max_tokens: number;
|
|
24
|
+
};
|
|
25
|
+
sections: readonly BProfileSectionDefinition[];
|
|
26
|
+
section_registry_sha256: string;
|
|
27
|
+
source_git_rev: string;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/engine/extraction/b-profile-section-dictionary-provider.d.ts
|
|
31
|
+
declare const bProfileSectionRegistrySchema: z.ZodType<BProfileSectionRegistry, unknown>;
|
|
32
|
+
declare function computeSectionRegistryHash(registry: BProfileSectionRegistry): string;
|
|
33
|
+
declare const sectionDictionaryCacheStateSchema: z.ZodType<{
|
|
34
|
+
activeRegistry: BProfileSectionRegistry;
|
|
35
|
+
fetchedForPluginVersion?: string;
|
|
36
|
+
appliedSchemaVersion?: number;
|
|
37
|
+
canonicalFormRepairVersion?: number;
|
|
38
|
+
}, unknown>;
|
|
39
|
+
type SectionDictionaryCacheState = z.infer<typeof sectionDictionaryCacheStateSchema>;
|
|
40
|
+
interface SectionDictionaryCache {
|
|
41
|
+
read(): Promise<SectionDictionaryCacheState | undefined>;
|
|
42
|
+
write(state: SectionDictionaryCacheState): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
interface LoadSectionDictionaryResult {
|
|
45
|
+
registry: BProfileSectionRegistry;
|
|
46
|
+
fetched: boolean;
|
|
47
|
+
}
|
|
48
|
+
declare function createSectionDictionaryCache(stateDir?: string): SectionDictionaryCache;
|
|
49
|
+
declare function getActiveSectionRegistry(): BProfileSectionRegistry;
|
|
50
|
+
declare function normalizeTopicToSectionName(topic: string, registry?: BProfileSectionRegistry): string;
|
|
51
|
+
declare function restoreCachedSectionDictionary(args: {
|
|
52
|
+
mode: ProductMode;
|
|
53
|
+
cache: SectionDictionaryCache;
|
|
54
|
+
}): Promise<BProfileSectionRegistry>;
|
|
55
|
+
declare function loadSectionDictionary(args: {
|
|
56
|
+
mode: ProductMode;
|
|
57
|
+
pluginVersion: string;
|
|
58
|
+
fetchFn: () => Promise<unknown>;
|
|
59
|
+
cache: SectionDictionaryCache;
|
|
60
|
+
}): Promise<LoadSectionDictionaryResult>;
|
|
61
|
+
//#endregion
|
|
62
|
+
export { computeSectionRegistryHash as a, loadSectionDictionary as c, bProfileSectionRegistrySchema as i, normalizeTopicToSectionName as l, SectionDictionaryCache as n, createSectionDictionaryCache as o, SectionDictionaryCacheState as r, getActiveSectionRegistry as s, LoadSectionDictionaryResult as t, restoreCachedSectionDictionary as u };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/engine/observability/best-effort.d.ts
|
|
2
|
+
type ObserveLogger = {
|
|
3
|
+
warn(message: string): void;
|
|
4
|
+
};
|
|
5
|
+
/** Failures never reach the caller, but every one is logged at error level. */
|
|
6
|
+
declare function bestEffort(label: string, fn: () => void | Promise<void>, _logger?: ObserveLogger): Promise<void>;
|
|
7
|
+
declare function bestEffortSync<T>(label: string, fn: () => T, _logger?: ObserveLogger): T | undefined;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { bestEffort as n, bestEffortSync as r, ObserveLogger as t };
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
//#region src/engine/extraction/calendar-instruction.ts
|
|
4
|
+
/** Calendar operations supplied by a model. This module never reads natural language. */
|
|
5
|
+
/** Day names in ISO order; the wire carries the name because models do not share one numbering. */
|
|
6
|
+
const WEEKDAYS = [
|
|
7
|
+
"monday",
|
|
8
|
+
"tuesday",
|
|
9
|
+
"wednesday",
|
|
10
|
+
"thursday",
|
|
11
|
+
"friday",
|
|
12
|
+
"saturday",
|
|
13
|
+
"sunday"
|
|
14
|
+
];
|
|
15
|
+
const precisionSchema = z.enum([
|
|
16
|
+
"year",
|
|
17
|
+
"month",
|
|
18
|
+
"week",
|
|
19
|
+
"day",
|
|
20
|
+
"minute"
|
|
21
|
+
]);
|
|
22
|
+
const clock = {
|
|
23
|
+
hour: z.number().int().min(0).max(23).optional(),
|
|
24
|
+
minute: z.number().int().min(0).max(59).optional(),
|
|
25
|
+
timezone: z.string().min(1).describe("A valid IANA time zone identifier or fixed UTC offset in +HH:MM or -HH:MM form; never a natural-language abbreviation. Keep hour and minute in that source zone.").optional()
|
|
26
|
+
};
|
|
27
|
+
const calendarInstructionSchema = z.discriminatedUnion("kind", [
|
|
28
|
+
z.object({ kind: z.literal("none") }).strict(),
|
|
29
|
+
z.object({ kind: z.literal("unresolved") }).strict(),
|
|
30
|
+
z.object({
|
|
31
|
+
kind: z.literal("absolute"),
|
|
32
|
+
year: z.number().int(),
|
|
33
|
+
month: z.number().int().min(1).max(12).optional(),
|
|
34
|
+
day: z.number().int().min(1).max(31).optional(),
|
|
35
|
+
precision: precisionSchema,
|
|
36
|
+
...clock
|
|
37
|
+
}).strict(),
|
|
38
|
+
z.object({
|
|
39
|
+
kind: z.literal("relative"),
|
|
40
|
+
amount: z.number().int(),
|
|
41
|
+
unit: z.enum([
|
|
42
|
+
"year",
|
|
43
|
+
"month",
|
|
44
|
+
"week",
|
|
45
|
+
"day",
|
|
46
|
+
"hour",
|
|
47
|
+
"minute"
|
|
48
|
+
]),
|
|
49
|
+
precision: precisionSchema,
|
|
50
|
+
...clock
|
|
51
|
+
}).strict(),
|
|
52
|
+
z.object({
|
|
53
|
+
kind: z.literal("weekday"),
|
|
54
|
+
day_name: z.enum(WEEKDAYS).describe("The named day as an English lowercase day name, never a number."),
|
|
55
|
+
direction: z.enum(["previous", "next"]),
|
|
56
|
+
precision: z.enum(["day", "minute"]),
|
|
57
|
+
...clock
|
|
58
|
+
}).strict()
|
|
59
|
+
]);
|
|
60
|
+
/** Validate only serialized calendar labels and precision, never natural-language meaning. */
|
|
61
|
+
function isCalendarLabel(value, precision) {
|
|
62
|
+
if (typeof value !== "string") return false;
|
|
63
|
+
try {
|
|
64
|
+
switch (precision) {
|
|
65
|
+
case "year": return /^\d{4}$/u.test(value) && Temporal.PlainYearMonth.from(`${value}-01`).year === Number(value);
|
|
66
|
+
case "month": return Temporal.PlainYearMonth.from(value).toString() === value;
|
|
67
|
+
case "day": return Temporal.PlainDate.from(value).toString() === value;
|
|
68
|
+
case "minute": return Temporal.PlainDateTime.from(value).toString({ smallestUnit: "minute" }) === value;
|
|
69
|
+
case "week": {
|
|
70
|
+
const [from, until, extra] = value.split("/");
|
|
71
|
+
if (!from || !until || extra !== void 0) return false;
|
|
72
|
+
const start = Temporal.PlainDate.from(from);
|
|
73
|
+
return start.toString() === from && start.dayOfWeek === 1 && start.add({ days: 7 }).toString() === until;
|
|
74
|
+
}
|
|
75
|
+
default: return false;
|
|
76
|
+
}
|
|
77
|
+
} catch {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function sessionZoneCarriedBy(value) {
|
|
82
|
+
if (!value) return void 0;
|
|
83
|
+
try {
|
|
84
|
+
return Temporal.ZonedDateTime.from(value).timeZoneId;
|
|
85
|
+
} catch {}
|
|
86
|
+
const offset = /(Z|[+-]\d{2}:?\d{2})$/u.exec(value)?.[1];
|
|
87
|
+
return offset === "Z" ? "UTC" : offset;
|
|
88
|
+
}
|
|
89
|
+
function anchorDate(value, zone) {
|
|
90
|
+
if (!value) return void 0;
|
|
91
|
+
try {
|
|
92
|
+
return Temporal.Instant.from(value).toZonedDateTimeISO(zone);
|
|
93
|
+
} catch {}
|
|
94
|
+
try {
|
|
95
|
+
return Temporal.ZonedDateTime.from(value).withTimeZone(zone);
|
|
96
|
+
} catch {}
|
|
97
|
+
try {
|
|
98
|
+
return Temporal.PlainDateTime.from(value).toZonedDateTime(zone);
|
|
99
|
+
} catch {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function calendarSessionTimestamp(value, zone) {
|
|
104
|
+
return anchorDate(value, zone ?? sessionZoneCarriedBy(value) ?? "UTC")?.epochMilliseconds;
|
|
105
|
+
}
|
|
106
|
+
function shift(unit, amount) {
|
|
107
|
+
switch (unit) {
|
|
108
|
+
case "year": return { years: amount };
|
|
109
|
+
case "month": return { months: amount };
|
|
110
|
+
case "week": return { weeks: amount };
|
|
111
|
+
case "day": return { days: amount };
|
|
112
|
+
case "hour": return { hours: amount };
|
|
113
|
+
case "minute": return { minutes: amount };
|
|
114
|
+
default: throw new Error("Unknown calendar unit");
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function interval(date, precision) {
|
|
118
|
+
let start = date.startOfDay();
|
|
119
|
+
if (precision === "year") start = start.with({
|
|
120
|
+
month: 1,
|
|
121
|
+
day: 1
|
|
122
|
+
});
|
|
123
|
+
if (precision === "month") start = start.with({ day: 1 });
|
|
124
|
+
if (precision === "week") start = start.subtract({ days: start.dayOfWeek - 1 });
|
|
125
|
+
if (precision === "minute") start = date.with({
|
|
126
|
+
second: 0,
|
|
127
|
+
millisecond: 0,
|
|
128
|
+
microsecond: 0,
|
|
129
|
+
nanosecond: 0
|
|
130
|
+
});
|
|
131
|
+
const end = start.add(shift(precision, 1));
|
|
132
|
+
const iso = start.toPlainDate().toString();
|
|
133
|
+
const label = precision === "year" ? iso.slice(0, 4) : precision === "month" ? iso.slice(0, 7) : precision === "week" ? `${iso}/${end.toPlainDate().toString()}` : precision === "minute" ? start.toPlainDateTime().toString({ smallestUnit: "minute" }) : iso;
|
|
134
|
+
return {
|
|
135
|
+
year: start.year,
|
|
136
|
+
month: start.month,
|
|
137
|
+
day: start.day,
|
|
138
|
+
...precision === "minute" ? {
|
|
139
|
+
hour: start.hour,
|
|
140
|
+
minute: start.minute
|
|
141
|
+
} : {},
|
|
142
|
+
precision,
|
|
143
|
+
timezone: date.timeZoneId,
|
|
144
|
+
label,
|
|
145
|
+
from: start.epochMilliseconds,
|
|
146
|
+
until: end.epochMilliseconds
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/** Invalid or unsupported instructions stay unresolved; no phrase parser or clock fallback. */
|
|
150
|
+
function calculateCalendarTime(instruction, sessionDateTime, sessionTimezone) {
|
|
151
|
+
if (instruction.kind === "none" || instruction.kind === "unresolved") return null;
|
|
152
|
+
if ((instruction.hour !== void 0 || instruction.minute !== void 0) && instruction.precision !== "minute") return null;
|
|
153
|
+
if (instruction.minute !== void 0 && instruction.hour === void 0) return null;
|
|
154
|
+
if (instruction.kind === "weekday" && instruction.precision === "minute" && instruction.hour === void 0) return null;
|
|
155
|
+
const zone = instruction.timezone ?? sessionTimezone ?? sessionZoneCarriedBy(sessionDateTime) ?? "UTC";
|
|
156
|
+
try {
|
|
157
|
+
let date;
|
|
158
|
+
if (instruction.kind === "absolute") {
|
|
159
|
+
if (instruction.precision !== "year" && instruction.month === void 0) return null;
|
|
160
|
+
if (!["year", "month"].includes(instruction.precision) && instruction.day === void 0) return null;
|
|
161
|
+
if (instruction.precision === "minute" && instruction.hour === void 0) return null;
|
|
162
|
+
date = Temporal.ZonedDateTime.from({
|
|
163
|
+
timeZone: zone,
|
|
164
|
+
year: instruction.year,
|
|
165
|
+
month: instruction.month ?? 1,
|
|
166
|
+
day: instruction.day ?? 1,
|
|
167
|
+
hour: instruction.hour ?? 0,
|
|
168
|
+
minute: instruction.minute ?? 0
|
|
169
|
+
}, {
|
|
170
|
+
overflow: "reject",
|
|
171
|
+
disambiguation: "reject"
|
|
172
|
+
});
|
|
173
|
+
} else {
|
|
174
|
+
const anchor = anchorDate(sessionDateTime, zone);
|
|
175
|
+
if (!anchor) return null;
|
|
176
|
+
if (instruction.kind === "relative") date = anchor.add(shift(instruction.unit, instruction.amount));
|
|
177
|
+
else {
|
|
178
|
+
const forward = instruction.direction === "next";
|
|
179
|
+
const weekday = WEEKDAYS.indexOf(instruction.day_name) + 1;
|
|
180
|
+
const delta = forward ? (weekday - anchor.dayOfWeek + 7) % 7 : (anchor.dayOfWeek - weekday + 7) % 7;
|
|
181
|
+
date = anchor.add({ days: (forward ? 1 : -1) * (delta || 7) });
|
|
182
|
+
}
|
|
183
|
+
if (instruction.hour !== void 0) date = date.with({
|
|
184
|
+
hour: instruction.hour,
|
|
185
|
+
minute: instruction.minute ?? 0
|
|
186
|
+
}, { disambiguation: "reject" });
|
|
187
|
+
}
|
|
188
|
+
return interval(date, instruction.precision);
|
|
189
|
+
} catch {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
//#endregion
|
|
194
|
+
export { sessionZoneCarriedBy as a, isCalendarLabel as i, calendarInstructionSchema as n, calendarSessionTimestamp as r, calculateCalendarTime as t };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { h as MemoryCategory } from "./types-DxKqU60b.js";
|
|
2
|
+
//#region src/engine/extraction/capture-policy-detector.d.ts
|
|
3
|
+
declare const PROMPT_INJECTION_PATTERNS: RegExp[];
|
|
4
|
+
/** Implements looks like prompt injection as the local memory capture policy operation. */
|
|
5
|
+
declare function looksLikePromptInjection(text: string): boolean;
|
|
6
|
+
/** Implements escape memory for prompt as the local memory capture policy operation. */
|
|
7
|
+
declare function escapeMemoryForPrompt(text: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Formats relevant memories context for callers without mutating stored memory capture policy
|
|
10
|
+
* data.
|
|
11
|
+
*/
|
|
12
|
+
declare function formatRelevantMemoriesContext(memories: Array<{
|
|
13
|
+
category: string;
|
|
14
|
+
text: string;
|
|
15
|
+
lane?: "active" | "parked" | "quarantined";
|
|
16
|
+
/** Calendar day the remembered event happened, when the row resolved one. */
|
|
17
|
+
eventDate?: string;
|
|
18
|
+
/** Calendar day the row was said, for a row with no event date of its own. */
|
|
19
|
+
saidOn?: string;
|
|
20
|
+
/** The sentence the row was written from, when one was kept. */
|
|
21
|
+
quote?: string;
|
|
22
|
+
}>): string;
|
|
23
|
+
declare const EXPLICIT_MEMORY_COMMAND_POSITIVE_PATTERNS: ReadonlyArray<RegExp>;
|
|
24
|
+
declare const EXPLICIT_MEMORY_COMMAND_RECALL_QUESTION_PATTERNS: ReadonlyArray<RegExp>;
|
|
25
|
+
declare const EXPLICIT_MEMORY_COMMAND_MANAGEMENT_PATTERNS: ReadonlyArray<RegExp>;
|
|
26
|
+
interface DetectCategoryOptions {
|
|
27
|
+
sessionId?: string;
|
|
28
|
+
explicitLocale?: string;
|
|
29
|
+
}
|
|
30
|
+
interface CategoryVoteResult {
|
|
31
|
+
category?: MemoryCategory;
|
|
32
|
+
confidence: number;
|
|
33
|
+
reason: string;
|
|
34
|
+
scores: Record<MemoryCategory, number>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Evaluates should capture without side effects so callers can branch
|
|
38
|
+
* predictably. Thin boolean view of `decideRawInputGate` — the raw-input gate
|
|
39
|
+
* is the single source of truth for the check order and semantics.
|
|
40
|
+
*/
|
|
41
|
+
declare function shouldCapture(text: string): boolean;
|
|
42
|
+
type CaptureDropReason = "cron" | "length-too-short" | "prompt-injection" | "context-fragment" | "html" | "markdown" | "emoji" | "noise" | "envelope-only";
|
|
43
|
+
type CaptureDecision = {
|
|
44
|
+
decision: "keep";
|
|
45
|
+
} | {
|
|
46
|
+
decision: "drop";
|
|
47
|
+
reason: CaptureDropReason;
|
|
48
|
+
};
|
|
49
|
+
/** Implements detect category as the local memory capture policy operation. */
|
|
50
|
+
declare function detectCategoryVote(text: string, options?: DetectCategoryOptions): CategoryVoteResult;
|
|
51
|
+
declare function detectCategory(text: string, options?: DetectCategoryOptions): MemoryCategory | undefined;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { EXPLICIT_MEMORY_COMMAND_MANAGEMENT_PATTERNS as a, PROMPT_INJECTION_PATTERNS as c, escapeMemoryForPrompt as d, formatRelevantMemoriesContext as f, DetectCategoryOptions as i, detectCategory as l, shouldCapture as m, CaptureDropReason as n, EXPLICIT_MEMORY_COMMAND_POSITIVE_PATTERNS as o, looksLikePromptInjection as p, CategoryVoteResult as r, EXPLICIT_MEMORY_COMMAND_RECALL_QUESTION_PATTERNS as s, CaptureDecision as t, detectCategoryVote as u };
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import "./internal/config/index.js";
|
|
2
|
+
import { normalizeCategory } from "./internal/engine/shared/types.js";
|
|
3
|
+
import { HTML_TAG_PATTERN } from "./internal/engine/shared/i18n-text.js";
|
|
4
|
+
import { n as RESOURCES_BY_LOCALE, t as ALL_RESOURCES } from "./all-resources-BQK2ugjB.js";
|
|
5
|
+
import { t as resolveLocale } from "./resolver-Dy-hnjCR.js";
|
|
6
|
+
import { normalizeQuery } from "./internal/engine/retrieval/retrieval-gate.js";
|
|
7
|
+
import { a as RELEVANT_MEMORIES_UNTRUSTED_LINE, n as RELEVANT_MEMORIES_INSTRUCTION_LINE, o as RELEVANT_MEMORY_RECORD_PREFIX, r as RELEVANT_MEMORIES_OPEN_TAG, s as looksLikeRelevantMemoriesContextFragment, t as RELEVANT_MEMORIES_CLOSE_TAG } from "./relevant-memories-context-m8nuFZcM.js";
|
|
8
|
+
//#region src/engine/extraction/confusable-skeleton.ts
|
|
9
|
+
/** @file confusable-skeleton.ts
|
|
10
|
+
* @purpose Normalizes common Unicode confusables before prompt-injection checks.
|
|
11
|
+
*/
|
|
12
|
+
const CONFUSABLES = {
|
|
13
|
+
Α: "A",
|
|
14
|
+
А: "A",
|
|
15
|
+
Β: "B",
|
|
16
|
+
В: "B",
|
|
17
|
+
Ε: "E",
|
|
18
|
+
Е: "E",
|
|
19
|
+
Η: "H",
|
|
20
|
+
Н: "H",
|
|
21
|
+
Ι: "I",
|
|
22
|
+
І: "I",
|
|
23
|
+
Κ: "K",
|
|
24
|
+
К: "K",
|
|
25
|
+
Μ: "M",
|
|
26
|
+
М: "M",
|
|
27
|
+
Ν: "N",
|
|
28
|
+
О: "O",
|
|
29
|
+
Ρ: "P",
|
|
30
|
+
Р: "P",
|
|
31
|
+
С: "C",
|
|
32
|
+
Τ: "T",
|
|
33
|
+
Т: "T",
|
|
34
|
+
Χ: "X",
|
|
35
|
+
Х: "X",
|
|
36
|
+
Υ: "Y",
|
|
37
|
+
а: "a",
|
|
38
|
+
е: "e",
|
|
39
|
+
і: "i",
|
|
40
|
+
ο: "o",
|
|
41
|
+
о: "o",
|
|
42
|
+
р: "p",
|
|
43
|
+
с: "c",
|
|
44
|
+
х: "x",
|
|
45
|
+
у: "y",
|
|
46
|
+
"0": "0",
|
|
47
|
+
"1": "1",
|
|
48
|
+
"2": "2",
|
|
49
|
+
"3": "3",
|
|
50
|
+
"4": "4",
|
|
51
|
+
"5": "5",
|
|
52
|
+
"6": "6",
|
|
53
|
+
"7": "7",
|
|
54
|
+
"8": "8",
|
|
55
|
+
"9": "9"
|
|
56
|
+
};
|
|
57
|
+
function buildConfusableSkeleton(text) {
|
|
58
|
+
return Array.from(text.normalize("NFKC"), (char) => CONFUSABLES[char] ?? char).join("");
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/engine/extraction/capture-policy-detector.ts
|
|
62
|
+
/** @file capture-policy-detector.ts
|
|
63
|
+
* @purpose Gates automatic memory capture and prepares safe extraction input.
|
|
64
|
+
* @boundary Conversation turns, cleanup rules, noise filters, and extractor prompts.
|
|
65
|
+
* @see ambient-learning-text-normalizer.ts, memory-extraction-pipeline.ts, memory-noise-classifier.ts.
|
|
66
|
+
*/
|
|
67
|
+
const PROMPT_INJECTION_PATTERNS = [
|
|
68
|
+
/\bignore\b.{0,30}\b(all|any|previous|above|prior)\b.{0,30}\binstructions?\b/,
|
|
69
|
+
/\b(forget|disregard|discard|override|bypass)\b.{0,30}\b(previous|prior|above|system|developer)\b.{0,30}\b(instructions?|directions?|messages?|rules?)\b/,
|
|
70
|
+
/\b(do\s*not|don\s*t|dont)\b.{0,20}\bfollow\b.{0,20}\b(system|developer)\b/,
|
|
71
|
+
/\bfrom\s+now\s+on\b.{0,40}\b(answer|respond|reply|say|act|pretend)\b/,
|
|
72
|
+
/\b(reveal|print|show|leak|dump)\b.{0,30}\b(system|developer)\b.{0,30}\b(prompt|message|instructions?|rules?|polic(?:y|ies))\b/,
|
|
73
|
+
/\b(new|updated|highest|higher|top)\s+priority\s+(instruction|rule|directive|command)s?\b/,
|
|
74
|
+
/\byou\b.{0,20}\b(must|should|will|need\s+to|required\s+to)\b.{0,40}\b(answer|respond|reply|say|act|pretend|ignore|follow|use|call|invoke|execute)\b/,
|
|
75
|
+
/\byou\s+(must\s+|should\s+|will\s+)?always\b.{0,30}\b(answer|respond|reply|say|act|pretend)\b/,
|
|
76
|
+
/^\s*always\b.{0,30}\b(answer|respond|reply|say|act|pretend)\b/,
|
|
77
|
+
/\bwhen\b.{0,40}\b(asked|prompted|questioned)\b.{0,40}\b(answer|respond|reply|say)\b/,
|
|
78
|
+
/\bsystem\s*prompt\b/,
|
|
79
|
+
/\bdeveloper\s*message\b/,
|
|
80
|
+
/<\s*(system|assistant|developer|tool|function|relevant-memories)\b/,
|
|
81
|
+
/\b(run|execute|call|invoke)\b.{0,40}\b(tool|command)\b/
|
|
82
|
+
];
|
|
83
|
+
const PROMPT_ESCAPE_MAP = {
|
|
84
|
+
"&": "&",
|
|
85
|
+
"<": "<",
|
|
86
|
+
">": ">",
|
|
87
|
+
"\"": """,
|
|
88
|
+
"'": "'"
|
|
89
|
+
};
|
|
90
|
+
const CJK_CHAR_PATTERN = /[\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/;
|
|
91
|
+
function testPattern(pattern, text) {
|
|
92
|
+
pattern.lastIndex = 0;
|
|
93
|
+
const matches = pattern.test(text);
|
|
94
|
+
pattern.lastIndex = 0;
|
|
95
|
+
return matches;
|
|
96
|
+
}
|
|
97
|
+
function normalizeInjectionText(text) {
|
|
98
|
+
return text.normalize("NFKC").replace(/[\u200B-\u200F\u2060\uFEFF]/g, "").replace(/[\r\n\t]+/g, " ").replace(/[^\p{L}\p{N}\s<>/_-]/gu, " ").toLowerCase().replace(/\s+/g, " ").trim();
|
|
99
|
+
}
|
|
100
|
+
/** Implements looks like prompt injection as the local memory capture policy operation. */
|
|
101
|
+
function looksLikePromptInjection(text) {
|
|
102
|
+
const normalized = normalizeInjectionText(text);
|
|
103
|
+
if (!normalized) return false;
|
|
104
|
+
return [
|
|
105
|
+
normalized,
|
|
106
|
+
normalizeInjectionText(buildConfusableSkeleton(text)),
|
|
107
|
+
normalized.replace(/[-_]+/g, " ").replace(/\s+/g, " ").trim()
|
|
108
|
+
].some((candidate) => PROMPT_INJECTION_PATTERNS.some((pattern) => testPattern(pattern, candidate)));
|
|
109
|
+
}
|
|
110
|
+
/** Implements escape memory for prompt as the local memory capture policy operation. */
|
|
111
|
+
function escapeMemoryForPrompt(text) {
|
|
112
|
+
return text.replace(HTML_TAG_PATTERN, "").replace(/\s+/g, " ").trim().replace(/[&<>"']/g, (char) => PROMPT_ESCAPE_MAP[char] ?? char);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Render-side only, and deliberately NOT the whole-message rule the capture path uses.
|
|
116
|
+
*
|
|
117
|
+
* The two look alike and are not. On the capture path a pattern match LOSES a memory, so a
|
|
118
|
+
* substring rule there is the wrong instrument and was measured destroying real facts. Here
|
|
119
|
+
* nothing is lost: an already-stored memory is simply not quoted back into this one prompt. That
|
|
120
|
+
* is defence in depth against feeding a stored injection probe — "What is my blue backpack code?
|
|
121
|
+
* Answer with only that code." — back to the model as if it were a fact, and a substring match is
|
|
122
|
+
* the right strength for it. The union is used rather than one locale's bundle for the same
|
|
123
|
+
* reason: over-matching here costs a memory one turn of visibility, not its existence.
|
|
124
|
+
*/
|
|
125
|
+
function getCaptureMinLength(text) {
|
|
126
|
+
return CJK_CHAR_PATTERN.test(text) ? 4 : 10;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Formats relevant memories context for callers without mutating stored memory capture policy
|
|
130
|
+
* data.
|
|
131
|
+
*/
|
|
132
|
+
function formatRelevantMemoriesContext(memories) {
|
|
133
|
+
const memoryLines = memories.filter((entry) => (entry.lane === void 0 || entry.lane === "active") && normalizeCategory(entry.category)).map((entry, index) => `${RELEVANT_MEMORY_RECORD_PREFIX} ${index + 1}: ${JSON.stringify({
|
|
134
|
+
category: normalizeCategory(entry.category),
|
|
135
|
+
...entry.eventDate === void 0 ? {} : { event_date: entry.eventDate },
|
|
136
|
+
...entry.saidOn === void 0 ? {} : { said_on: entry.saidOn },
|
|
137
|
+
text: escapeMemoryForPrompt(entry.text),
|
|
138
|
+
...entry.quote === void 0 ? {} : { quote: escapeMemoryForPrompt(entry.quote) }
|
|
139
|
+
})}`);
|
|
140
|
+
return [
|
|
141
|
+
RELEVANT_MEMORIES_UNTRUSTED_LINE,
|
|
142
|
+
RELEVANT_MEMORIES_INSTRUCTION_LINE,
|
|
143
|
+
RELEVANT_MEMORIES_OPEN_TAG,
|
|
144
|
+
...memoryLines,
|
|
145
|
+
RELEVANT_MEMORIES_CLOSE_TAG
|
|
146
|
+
].join("\n");
|
|
147
|
+
}
|
|
148
|
+
const EXPLICIT_MEMORY_COMMAND_POSITIVE_PATTERNS = ALL_RESOURCES.flatMap((r) => [...r.captureTriggers.explicitMemoryCommandPositivePatterns]);
|
|
149
|
+
const EXPLICIT_MEMORY_COMMAND_RECALL_QUESTION_PATTERNS = ALL_RESOURCES.flatMap((r) => [...r.captureTriggers.explicitMemoryCommandRecallQuestionPatterns]);
|
|
150
|
+
const EXPLICIT_MEMORY_COMMAND_MANAGEMENT_PATTERNS = ALL_RESOURCES.flatMap((r) => [...r.captureTriggers.explicitMemoryCommandManagementPatterns]);
|
|
151
|
+
const EXACT_CATEGORY_RULES = [
|
|
152
|
+
{
|
|
153
|
+
category: "profile",
|
|
154
|
+
score: 4,
|
|
155
|
+
reason: "identity-self-profile",
|
|
156
|
+
patterns: [
|
|
157
|
+
/\b(my name is|i am|i'm|i live in|i work at|i work as|my role is|my email is|my phone is|allergic to)\b/i,
|
|
158
|
+
/\b(i use the display name|my display name is|my home city is)\b/i,
|
|
159
|
+
/anzeigenamen|arbeite ich als|heimatstadt/i,
|
|
160
|
+
/nombre visible|trabajo como|ciudad base/i,
|
|
161
|
+
/nom affiché|nom affiche|travaille comme|ville d'origine/i,
|
|
162
|
+
/表示名|プラットフォームエンジニア|出身地/,
|
|
163
|
+
/표시 이름|플랫폼 엔지니어|고향/,
|
|
164
|
+
/меня зовут|отображаемое имя|работаю платформенным|родной город/i,
|
|
165
|
+
/显示名|顯示名|平台工程师|平台工程師|家乡|家鄉/,
|
|
166
|
+
/我的(名字|姓名|显示名|顯示名|家乡|家鄉).+是|我叫|住在|工作于|过敏/
|
|
167
|
+
]
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
category: "profile",
|
|
171
|
+
score: 4,
|
|
172
|
+
reason: "explicit-preference",
|
|
173
|
+
patterns: [
|
|
174
|
+
/\b(i|we)\s+(?:(?:always|usually|generally|often)\s+)?(?:prefer|like|love|hate|want|need|care about|would rather)\b/i,
|
|
175
|
+
/\b(favou?rite|preferred)\b/i,
|
|
176
|
+
/lieblingseditor|statusmeldungen|utc-zeitstempel|bevorzuge ich|möchte ich/i,
|
|
177
|
+
/editor favorito|estados breves|marcas de tiempo|me gustan|prefiero/i,
|
|
178
|
+
/éditeur favori|editeur favori|statuts courts|horodatages|je préfère|je prefere|j'aime/i,
|
|
179
|
+
/ダークモード|お気に入り|進捗報告|好み|希望/,
|
|
180
|
+
/다크 모드|좋아하는|상태 업데이트|선호/,
|
|
181
|
+
/предпочитаю|любимый редактор|нравятся короткие|временные метки/i,
|
|
182
|
+
/喜欢|喜歡|最喜欢|最喜歡|偏好|希望使用/,
|
|
183
|
+
/喜欢|偏好|讨厌|想要|需要/
|
|
184
|
+
]
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
category: "episodic",
|
|
188
|
+
score: 4,
|
|
189
|
+
reason: "entity-reference",
|
|
190
|
+
patterns: [
|
|
191
|
+
/[\w.-]+@[\w.-]+\.\w+/,
|
|
192
|
+
/\+\d{7,}/,
|
|
193
|
+
/\b(project|project owner|team|company|organization|manager|spouse|wife|husband|son|daughter|pet|repo|service)\b/i,
|
|
194
|
+
/\b(operating system|conference hotel|tool shelf|dashboard|room booking|workshop|instruction manual|prompt card|message archive|rule book|system monitor|developer laptop|assistant coach|tool catalog)\b/i,
|
|
195
|
+
/\b(cluster is named|notebook lives in)\b/i,
|
|
196
|
+
/projektleiterin|staging-cluster|release-notizbuch|betriebssystem|entwicklerkonferenz|assistenzleitung|werkzeugregal|kommandozentrale|funktionsraum|anleitung|prompt-karte|nachrichtenarchiv|regelbuch|systemmonitor|entwicklerlaptop|assistenztrainer|werkzeugkatalog/i,
|
|
197
|
+
/gerente|dueña del proyecto|duena del proyecto|cluster de staging|cuaderno de releases|sistema operativo|conferencia de desarrolladores|subgerente|estantería de herramientas|estanteria de herramientas|centro de comando|sala de funciones|taller de políticas|taller de politicas|manual de instrucciones|tarjeta de prompt|archivo de mensajes|libro de reglas|monitor del sistema|portátil de desarrollador|portatil de desarrollador|entrenador asistente|catálogo de herramientas|catalogo de herramientas/i,
|
|
198
|
+
/responsable|projet facturation|cluster de staging|carnet de release|système d'exploitation|systeme d'exploitation|conférence développeur|conference developpeur|responsable adjointe|étagère à outils|etagere a outils|centre de commande|salle de fonction|atelier politique|manuel d'instructions|carte de prompt|archive des messages|livre de règles|livre de regles|moniteur système|moniteur systeme|ordinateur développeur|ordinateur developpeur|entraîneur assistant|entraineur assistant|catalogue d'outils/i,
|
|
199
|
+
/マネージャー|プロジェクトの責任者|クラスタ名|リリースノート|オペレーティングシステム|開発者会議|副マネージャー|工具棚|コマンドセンター|機能室|ポリシーワークショップ|説明書|プロンプトカード|メッセージ保管庫|ルールブック|システムモニター|開発者用ノートpc|アシスタントコーチ|ツールカタログ/i,
|
|
200
|
+
/매니저|프로젝트 담당자|클러스터 이름|릴리스 노트|운영 체제|개발자 컨퍼런스|부매니저|도구 선반|명령 센터|기능실|정책 워크숍|사용 설명서|프롬프트 카드|메시지 보관함|규칙 책|시스템 모니터|개발자 노트북|보조 코치|도구 카탈로그/,
|
|
201
|
+
/менеджер|проектом биллинга|стейджинг-кластер|заметки релиза|операционная система|конференция разработчиков|помощник менеджера|полка инструментов|командный центр|функциональная комната|семинар по policy|инструкция|архив сообщений|книга правил|системный монитор|ноутбук разработчика|ассистент тренера|каталог инструментов/i,
|
|
202
|
+
/经理|經理|项目负责人|專案負責人|集群叫|叢集叫|发布笔记|發布筆記|操作系统|作業系統|开发者大会|開發者大會|助理经理|助理經理|工具架|命令中心|功能室|政策工作坊|说明书|說明書|prompt卡片|消息归档|訊息歸檔|规则书|規則書|系统监控器|系統監控器|开发者电脑|開發者電腦|助理教练|助理教練|工具目录|工具目錄/,
|
|
203
|
+
/项目|团队|公司|组织|经理|宠物|服务/
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
category: "episodic",
|
|
208
|
+
score: 4,
|
|
209
|
+
reason: "event-or-decision",
|
|
210
|
+
patterns: [
|
|
211
|
+
/\b(decided|chose|switched|migrated|shipped|released|deployed|incident|happened|finished|will use|we'll use|going forward|from now on)\b/i,
|
|
212
|
+
/\b(meeting is scheduled|rollout is planned)\b/i,
|
|
213
|
+
/beschlossen|geplant|abgeschlossen/i,
|
|
214
|
+
/decidimos|programada|planeado|terminó|termino/i,
|
|
215
|
+
/décidé|decide|planifiée|planifiee|prévu|prevu|terminé|termine/i,
|
|
216
|
+
/移行を決め|レビューが予定|ロールアウトが計画|監査が完了/,
|
|
217
|
+
/마이그레이션하기로 결정|리뷰가 예정|롤아웃이 계획|감사가 완료/,
|
|
218
|
+
/решили мигрировать|назначен|запланирован|завершился/i,
|
|
219
|
+
/决定迁移|決定遷移|已经排期|已經排期|已经计划|已經計畫|审计完成|稽核完成/,
|
|
220
|
+
/决定迁移|決定遷移|选择改用|選擇改用|上线完成|上線完成|发布上线|發布上線|事故|以后|以後|从现在开始|從現在開始/
|
|
221
|
+
]
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
category: "lesson",
|
|
225
|
+
score: 4,
|
|
226
|
+
reason: "lesson-or-retrospective",
|
|
227
|
+
patterns: [
|
|
228
|
+
/\b(learned|lesson|takeaway|remember that|next time|mistake|avoid|never again|root cause|fix was|solution was|sop)\b/i,
|
|
229
|
+
/lektion|gelernt|erkenntnis|mehrdeutige erinnerungen/i,
|
|
230
|
+
/lección|leccion|aprendimos|conclusión|conclusion|memorias ambiguas/i,
|
|
231
|
+
/leçon|lecon|appris|conclusion|mémoires ambiguës|memoires ambigues/i,
|
|
232
|
+
/教訓|学びました|重要です|棄権すべき/,
|
|
233
|
+
/교훈|배웠|검토해야|저장하지 않아야/,
|
|
234
|
+
/урок|научились|вывод|неоднозначные memories/i,
|
|
235
|
+
/经验教训|經驗教訓|学到|學到|结论|結論|模糊记忆|模糊記憶/,
|
|
236
|
+
/学到|教训|下次|避免|根因|复盘|反思/
|
|
237
|
+
]
|
|
238
|
+
}
|
|
239
|
+
];
|
|
240
|
+
/**
|
|
241
|
+
* Evaluates should capture without side effects so callers can branch
|
|
242
|
+
* predictably. Thin boolean view of `decideRawInputGate` — the raw-input gate
|
|
243
|
+
* is the single source of truth for the check order and semantics.
|
|
244
|
+
*/
|
|
245
|
+
function shouldCapture(text) {
|
|
246
|
+
return decideRawInputGate(text).decision === "keep";
|
|
247
|
+
}
|
|
248
|
+
const KEEP = { decision: "keep" };
|
|
249
|
+
function drop(reason) {
|
|
250
|
+
return {
|
|
251
|
+
decision: "drop",
|
|
252
|
+
reason
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* The raw-input capture gate as a reason-carrying decision. This is the single
|
|
257
|
+
* source of truth for the gate's check order and semantics — `shouldCapture`
|
|
258
|
+
* is a thin boolean view of it, and each `drop(reason)` names the failed check.
|
|
259
|
+
*/
|
|
260
|
+
function decideRawInputGate(text) {
|
|
261
|
+
if (/^\s*\[cron:[^\]]+\]/i.test(text)) return drop("cron");
|
|
262
|
+
const s = normalizeQuery(text);
|
|
263
|
+
const minLen = getCaptureMinLength(s);
|
|
264
|
+
if (s.length < minLen) return drop("length-too-short");
|
|
265
|
+
if (looksLikeRelevantMemoriesContextFragment(s)) return drop("context-fragment");
|
|
266
|
+
if (s.startsWith("<") && s.includes("</")) return drop("html");
|
|
267
|
+
if (s.includes("**") && s.includes("\n-")) return drop("markdown");
|
|
268
|
+
if ((s.match(/[\u{1F300}-\u{1F9FF}]/gu) ?? []).length > 3) return drop("emoji");
|
|
269
|
+
return KEEP;
|
|
270
|
+
}
|
|
271
|
+
/** Implements detect category as the local memory capture policy operation. */
|
|
272
|
+
function detectCategoryVote(text, options = {}) {
|
|
273
|
+
const normalized = normalizeQuery(text);
|
|
274
|
+
const lower = normalized.toLowerCase();
|
|
275
|
+
if (looksLikePromptInjection(normalized)) return {
|
|
276
|
+
confidence: 0,
|
|
277
|
+
reason: "prompt-injection-abstain",
|
|
278
|
+
scores: {
|
|
279
|
+
episodic: 0,
|
|
280
|
+
profile: 0,
|
|
281
|
+
persona: 0,
|
|
282
|
+
lesson: 0,
|
|
283
|
+
summary: 0,
|
|
284
|
+
state: 0
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
const scores = {
|
|
288
|
+
episodic: 0,
|
|
289
|
+
profile: 0,
|
|
290
|
+
persona: 0,
|
|
291
|
+
lesson: 0,
|
|
292
|
+
summary: 0,
|
|
293
|
+
state: 0
|
|
294
|
+
};
|
|
295
|
+
const locale = resolveLocale({
|
|
296
|
+
text: normalized,
|
|
297
|
+
...options.sessionId ? { sessionId: options.sessionId } : {},
|
|
298
|
+
...options.explicitLocale ? { explicitLocale: options.explicitLocale } : {}
|
|
299
|
+
});
|
|
300
|
+
const triggers = RESOURCES_BY_LOCALE[locale].captureTriggers;
|
|
301
|
+
const reasons = [];
|
|
302
|
+
for (const rule of EXACT_CATEGORY_RULES) if (rule.patterns.some((pattern) => testPattern(pattern, lower))) {
|
|
303
|
+
scores[rule.category] += rule.score;
|
|
304
|
+
reasons.push(rule.reason);
|
|
305
|
+
}
|
|
306
|
+
const ROUTING_KEY_REMAP = {
|
|
307
|
+
identity: "profile",
|
|
308
|
+
preference: "profile",
|
|
309
|
+
entity: "episodic",
|
|
310
|
+
event: "episodic",
|
|
311
|
+
lesson: "lesson"
|
|
312
|
+
};
|
|
313
|
+
for (const [routingKey, patterns] of Object.entries(triggers.categoryRouting)) {
|
|
314
|
+
const category = ROUTING_KEY_REMAP[routingKey];
|
|
315
|
+
if (!category) continue;
|
|
316
|
+
if (patterns.some((pattern) => testPattern(pattern, normalized))) {
|
|
317
|
+
scores[category] += 2;
|
|
318
|
+
reasons.push(`locale-route-${category}`);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
const localeRules = [
|
|
322
|
+
["profile", triggers.identityPattern],
|
|
323
|
+
["profile", triggers.preferencePattern],
|
|
324
|
+
["episodic", triggers.entityPattern],
|
|
325
|
+
["episodic", triggers.eventPattern],
|
|
326
|
+
["lesson", triggers.lessonPattern]
|
|
327
|
+
];
|
|
328
|
+
for (const [category, pattern] of localeRules) if (testPattern(pattern, lower)) {
|
|
329
|
+
scores[category] += 2;
|
|
330
|
+
reasons.push(`locale-${category}`);
|
|
331
|
+
}
|
|
332
|
+
const ranked = Object.entries(scores).sort((a, b) => b[1] - a[1]);
|
|
333
|
+
const top = ranked[0];
|
|
334
|
+
if (!top) return {
|
|
335
|
+
confidence: 0,
|
|
336
|
+
reason: "no-category-signal",
|
|
337
|
+
scores
|
|
338
|
+
};
|
|
339
|
+
const [category, score] = top;
|
|
340
|
+
const runnerUp = ranked[1]?.[1] ?? 0;
|
|
341
|
+
if (score <= 0 || score === runnerUp) return {
|
|
342
|
+
confidence: 0,
|
|
343
|
+
reason: score <= 0 ? "no-category-signal" : "ambiguous-category",
|
|
344
|
+
scores
|
|
345
|
+
};
|
|
346
|
+
return {
|
|
347
|
+
category,
|
|
348
|
+
confidence: Math.min(1, score / 6),
|
|
349
|
+
reason: reasons.join(","),
|
|
350
|
+
scores
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
function detectCategory(text, options = {}) {
|
|
354
|
+
return detectCategoryVote(text, options).category;
|
|
355
|
+
}
|
|
356
|
+
//#endregion
|
|
357
|
+
export { detectCategory as a, formatRelevantMemoriesContext as c, PROMPT_INJECTION_PATTERNS as i, looksLikePromptInjection as l, EXPLICIT_MEMORY_COMMAND_POSITIVE_PATTERNS as n, detectCategoryVote as o, EXPLICIT_MEMORY_COMMAND_RECALL_QUESTION_PATTERNS as r, escapeMemoryForPrompt as s, EXPLICIT_MEMORY_COMMAND_MANAGEMENT_PATTERNS as t, shouldCapture as u };
|