@graphorin/memory 0.6.1 → 0.7.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/CHANGELOG.md +71 -0
- package/README.md +1 -1
- package/dist/conflict/index.js +0 -1
- package/dist/conflict/pipeline.js +0 -1
- package/dist/conflict/pipeline.js.map +1 -1
- package/dist/conflict/stages/stage3-heuristic-regex.js +0 -1
- package/dist/conflict/stages/stage3-heuristic-regex.js.map +1 -1
- package/dist/conflict/types.d.ts +1 -1
- package/dist/conflict/types.js.map +1 -1
- package/dist/consolidator/index.js +2 -0
- package/dist/consolidator/index.js.map +1 -1
- package/dist/consolidator/lock.js +7 -1
- package/dist/consolidator/lock.js.map +1 -1
- package/dist/consolidator/phases/deep.js +19 -12
- package/dist/consolidator/phases/deep.js.map +1 -1
- package/dist/consolidator/phases/induce.d.ts.map +1 -1
- package/dist/consolidator/phases/induce.js +2 -3
- package/dist/consolidator/phases/induce.js.map +1 -1
- package/dist/consolidator/phases/reflect.js +35 -8
- package/dist/consolidator/phases/reflect.js.map +1 -1
- package/dist/consolidator/phases/standard.js +199 -28
- package/dist/consolidator/phases/standard.js.map +1 -1
- package/dist/consolidator/reconcile.js +16 -15
- package/dist/consolidator/reconcile.js.map +1 -1
- package/dist/consolidator/runtime.d.ts.map +1 -1
- package/dist/consolidator/runtime.js +129 -47
- package/dist/consolidator/runtime.js.map +1 -1
- package/dist/consolidator/scheduler.d.ts +17 -3
- package/dist/consolidator/scheduler.d.ts.map +1 -1
- package/dist/consolidator/scheduler.js.map +1 -1
- package/dist/consolidator/types.d.ts +30 -1
- package/dist/consolidator/types.d.ts.map +1 -1
- package/dist/consolidator/types.js +10 -0
- package/dist/consolidator/types.js.map +1 -1
- package/dist/context-engine/compaction/clear-tool-results.d.ts +1 -1
- package/dist/context-engine/compaction/clear-tool-results.js +1 -1
- package/dist/context-engine/compaction/clear-tool-results.js.map +1 -1
- package/dist/context-engine/compaction/compactor.d.ts +1 -0
- package/dist/context-engine/compaction/compactor.d.ts.map +1 -1
- package/dist/context-engine/compaction/compactor.js +32 -8
- package/dist/context-engine/compaction/compactor.js.map +1 -1
- package/dist/context-engine/compaction/hooks/types.d.ts +1 -1
- package/dist/context-engine/compaction/index.d.ts +1 -0
- package/dist/context-engine/compaction/templates/marker.d.ts +33 -0
- package/dist/context-engine/compaction/templates/marker.d.ts.map +1 -0
- package/dist/context-engine/compaction/templates/marker.js +34 -0
- package/dist/context-engine/compaction/templates/marker.js.map +1 -0
- package/dist/context-engine/compaction/templates/summary-9-section.d.ts +1 -1
- package/dist/context-engine/compaction/templates/summary-9-section.d.ts.map +1 -1
- package/dist/context-engine/compaction/templates/summary-9-section.js +4 -3
- package/dist/context-engine/compaction/templates/summary-9-section.js.map +1 -1
- package/dist/context-engine/engine.d.ts +7 -176
- package/dist/context-engine/engine.d.ts.map +1 -1
- package/dist/context-engine/engine.js +0 -2
- package/dist/context-engine/engine.js.map +1 -1
- package/dist/context-engine/index.d.ts +8 -49
- package/dist/context-engine/io-types.d.ts +144 -0
- package/dist/context-engine/io-types.d.ts.map +1 -0
- package/dist/context-engine/locale-packs/types.d.ts +1 -1
- package/dist/context-engine/locale-packs/types.js.map +1 -1
- package/dist/context-engine/privacy-filter.d.ts +1 -2
- package/dist/context-engine/privacy-filter.d.ts.map +1 -1
- package/dist/context-engine/privacy-filter.js +1 -2
- package/dist/context-engine/privacy-filter.js.map +1 -1
- package/dist/errors/index.d.ts +2 -2
- package/dist/errors/index.js +2 -2
- package/dist/errors/index.js.map +1 -1
- package/dist/facade.d.ts +43 -52
- package/dist/facade.d.ts.map +1 -1
- package/dist/facade.js +5 -3
- package/dist/facade.js.map +1 -1
- package/dist/graph/entity-resolver.js +1 -1
- package/dist/graph/entity-resolver.js.map +1 -1
- package/dist/index.d.ts +16 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -5
- package/dist/index.js.map +1 -1
- package/dist/internal/envelope.js +57 -0
- package/dist/internal/envelope.js.map +1 -0
- package/dist/internal/injection-heuristics.js +0 -0
- package/dist/internal/injection-heuristics.js.map +1 -1
- package/dist/internal/llm-json.js +40 -0
- package/dist/internal/llm-json.js.map +1 -0
- package/dist/internal/storage-adapter.d.ts +23 -10
- package/dist/internal/storage-adapter.d.ts.map +1 -1
- package/dist/memory-interface.d.ts +131 -0
- package/dist/memory-interface.d.ts.map +1 -0
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/dist/search/iterative.d.ts.map +1 -1
- package/dist/search/iterative.js +2 -3
- package/dist/search/iterative.js.map +1 -1
- package/dist/search/query-transform.d.ts.map +1 -1
- package/dist/search/query-transform.js +2 -3
- package/dist/search/query-transform.js.map +1 -1
- package/dist/tiers/episodic-memory.js +3 -3
- package/dist/tiers/episodic-memory.js.map +1 -1
- package/dist/tiers/index.d.ts +2 -2
- package/dist/tiers/insight-memory.js +1 -1
- package/dist/tiers/insight-memory.js.map +1 -1
- package/dist/tiers/procedural-memory.d.ts +1 -1
- package/dist/tiers/procedural-memory.js +2 -2
- package/dist/tiers/procedural-memory.js.map +1 -1
- package/dist/tiers/semantic-memory.d.ts +58 -4
- package/dist/tiers/semantic-memory.d.ts.map +1 -1
- package/dist/tiers/semantic-memory.js +103 -20
- package/dist/tiers/semantic-memory.js.map +1 -1
- package/dist/tools/block-tools.d.ts +19 -57
- package/dist/tools/block-tools.d.ts.map +1 -1
- package/dist/tools/block-tools.js.map +1 -1
- package/dist/tools/fact-tools.d.ts +53 -214
- package/dist/tools/fact-tools.d.ts.map +1 -1
- package/dist/tools/fact-tools.js +3 -2
- package/dist/tools/fact-tools.js.map +1 -1
- package/dist/tools/recall-tools.d.ts +34 -175
- package/dist/tools/recall-tools.d.ts.map +1 -1
- package/dist/tools/recall-tools.js +5 -4
- package/dist/tools/recall-tools.js.map +1 -1
- package/dist/tools/runbook-tools.d.ts +15 -58
- package/dist/tools/runbook-tools.d.ts.map +1 -1
- package/dist/tools/runbook-tools.js.map +1 -1
- package/dist/tools/types.d.ts +1 -1
- package/package.json +18 -17
- package/src/conflict/index.ts +29 -0
- package/src/conflict/locale-packs/en.ts +142 -0
- package/src/conflict/locale-packs/index.ts +17 -0
- package/src/conflict/locale-packs/types.ts +138 -0
- package/src/conflict/pipeline.ts +371 -0
- package/src/conflict/stages/helpers.ts +65 -0
- package/src/conflict/stages/stage1-exact-dedup.ts +40 -0
- package/src/conflict/stages/stage2-embedding-three-zone.ts +54 -0
- package/src/conflict/stages/stage3-heuristic-regex.ts +51 -0
- package/src/conflict/stages/stage4-subject-predicate.ts +46 -0
- package/src/conflict/stages/stage5-defer-to-deep.ts +34 -0
- package/src/conflict/types.ts +263 -0
- package/src/consolidator/budget.ts +312 -0
- package/src/consolidator/decay.ts +246 -0
- package/src/consolidator/dlq.ts +61 -0
- package/src/consolidator/errors.ts +87 -0
- package/src/consolidator/idempotency.ts +27 -0
- package/src/consolidator/index.ts +269 -0
- package/src/consolidator/lock.ts +141 -0
- package/src/consolidator/noise-filter.ts +235 -0
- package/src/consolidator/phases/deep.ts +308 -0
- package/src/consolidator/phases/induce.ts +423 -0
- package/src/consolidator/phases/learned-context.ts +233 -0
- package/src/consolidator/phases/light.ts +166 -0
- package/src/consolidator/phases/reflect.ts +504 -0
- package/src/consolidator/phases/standard.ts +1002 -0
- package/src/consolidator/reconcile.ts +273 -0
- package/src/consolidator/runtime.ts +1049 -0
- package/src/consolidator/scheduler.ts +182 -0
- package/src/consolidator/triggers.ts +134 -0
- package/src/consolidator/types.ts +622 -0
- package/src/context-engine/annotations.ts +161 -0
- package/src/context-engine/auto-recall.ts +92 -0
- package/src/context-engine/compaction/clear-tool-results.ts +232 -0
- package/src/context-engine/compaction/compactor.ts +403 -0
- package/src/context-engine/compaction/hooks/reanchor-persona-block.ts +55 -0
- package/src/context-engine/compaction/hooks/reanchor-pinned-facts.ts +66 -0
- package/src/context-engine/compaction/hooks/reanchor-project-rules.ts +57 -0
- package/src/context-engine/compaction/hooks/reanchor-recent-results.ts +116 -0
- package/src/context-engine/compaction/hooks/types.ts +68 -0
- package/src/context-engine/compaction/index.ts +60 -0
- package/src/context-engine/compaction/templates/marker.ts +33 -0
- package/src/context-engine/compaction/templates/summary-9-section.ts +223 -0
- package/src/context-engine/compaction/thresholds.ts +107 -0
- package/src/context-engine/compaction/types.ts +255 -0
- package/src/context-engine/engine.ts +970 -0
- package/src/context-engine/index.ts +118 -0
- package/src/context-engine/io-types.ts +162 -0
- package/src/context-engine/locale-packs/en.ts +107 -0
- package/src/context-engine/locale-packs/index.ts +19 -0
- package/src/context-engine/locale-packs/resolver.ts +197 -0
- package/src/context-engine/locale-packs/types.ts +177 -0
- package/src/context-engine/metadata.ts +114 -0
- package/src/context-engine/preambles/inbound-en.ts +19 -0
- package/src/context-engine/privacy-filter.ts +190 -0
- package/src/context-engine/templates/base-en.ts +19 -0
- package/src/context-engine/templates/composer.ts +91 -0
- package/src/context-engine/token-budget.ts +319 -0
- package/src/context-engine/token-counter.ts +157 -0
- package/src/errors/index.ts +273 -0
- package/src/facade.ts +750 -0
- package/src/graph/entity-resolver.ts +364 -0
- package/src/graph/index.ts +24 -0
- package/src/index.ts +259 -0
- package/src/internal/contextualize.ts +173 -0
- package/src/internal/embedder-binding.ts +53 -0
- package/src/internal/envelope.ts +70 -0
- package/src/internal/id.ts +23 -0
- package/src/internal/injection-heuristics.ts +0 -0
- package/src/internal/llm-json.ts +38 -0
- package/src/internal/spans.ts +35 -0
- package/src/internal/storage-adapter.ts +963 -0
- package/src/memory-interface.ts +158 -0
- package/src/migration/embedder-migration.ts +237 -0
- package/src/migration/index.ts +13 -0
- package/src/search/explain.ts +123 -0
- package/src/search/fit-weights.ts +109 -0
- package/src/search/graph-ppr.ts +38 -0
- package/src/search/index.ts +55 -0
- package/src/search/iterative.ts +658 -0
- package/src/search/query-transform.ts +285 -0
- package/src/search/rrf.ts +225 -0
- package/src/search/trust.ts +55 -0
- package/src/search/types.ts +50 -0
- package/src/tiers/episodic-memory.ts +463 -0
- package/src/tiers/index.ts +50 -0
- package/src/tiers/insight-memory.ts +208 -0
- package/src/tiers/procedural-memory.ts +482 -0
- package/src/tiers/semantic-memory.ts +1729 -0
- package/src/tiers/session-memory.ts +271 -0
- package/src/tiers/shared-memory.ts +62 -0
- package/src/tiers/working-memory.ts +368 -0
- package/src/tools/block-tools.ts +172 -0
- package/src/tools/fact-tools.ts +473 -0
- package/src/tools/index.ts +109 -0
- package/src/tools/recall-tools.ts +303 -0
- package/src/tools/runbook-tools.ts +107 -0
- package/src/tools/taint.ts +39 -0
- package/src/tools/types.ts +37 -0
- package/dist/conflict/locale-packs/index.js +0 -4
- package/dist/context-engine/compaction/index.js +0 -10
- package/dist/context-engine/index.d.ts.map +0 -1
- package/dist/context-engine/index.js +0 -25
- package/dist/context-engine/locale-packs/index.js +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"privacy-filter.js","names":["kept: TRecord[]","dropped: Array<{ readonly record: TRecord; readonly reason: PrivacyDecisionReason }>","counters: Record<PrivacyDecisionReason, number>"],"sources":["../../src/context-engine/privacy-filter.ts"],"sourcesContent":["/**\n * D2 sensitivity-tier filter. Tags every memory record with a\n * decision (`'pass'` / `'drop'`) before the assembled prompt is\n * compiled. The filter is *tier-based* - it trusts the\n * `record.sensitivity` tag the consolidator / writer set; the\n * outbound prompt-redaction middleware (D3, ADR-045) is the\n * universal backstop for content the filter cannot see (raw user\n * input, tool results, MCP responses, skill bodies, agent\n * instructions, tool-call args).\n *\n * @packageDocumentation\n */\n\nimport type { LocalProviderTrust, Sensitivity } from '@graphorin/core';\n\n/**\n * Filter input: the record-level sensitivity tag + the per-tier\n * trust class of the active provider.\n *\n * @stable\n */\nexport interface PrivacyFilterContext {\n /**\n * Sensitivity tiers the active provider is allowed to receive.\n * When omitted, the per-tier defaults below apply.\n */\n readonly providerAcceptsSensitivity?: ReadonlyArray<Sensitivity>;\n /**\n * Trust class of the active provider as classified by\n * `@graphorin/provider/trust/classify-local-provider.ts`. Defaults\n * to `'public-tls'` (the conservative cloud default).\n */\n readonly providerTrust?: LocalProviderTrust;\n /**\n * Per-user opt-in for cloud upload of `'internal'`-tier content.\n * Default `false` - `'internal'` content does not leave the\n * loopback boundary unless the user explicitly opts in.\n */\n readonly cloudUploadConsent?: boolean;\n /**\n * Override the default sensitivity applied to records that are\n * missing a tag. Default `'internal'` per DEC-126.\n */\n readonly defaultSensitivity?: Sensitivity;\n}\n\n/**\n * Output of {@link decide} for a single record.\n *\n * @stable\n */\nexport type PrivacyDecision = 'pass' | 'drop';\n\n/**\n * Reason the decision was made. Surfaced to the metadata block so\n * operators can audit per-tier drops.\n *\n * @stable\n */\nexport type PrivacyDecisionReason =\n | 'provider-rejects-secret'\n | 'provider-rejects-internal'\n | 'no-cloud-upload-consent'\n | 'allowed';\n\n/**\n * Resolve the effective `acceptsSensitivity` set for a provider.\n * The function is pure: callers can supply a custom matrix to\n * override the defaults (used by tests + custom adapters).\n *\n * Defaults (DEC-149, ADR-013 ext):\n *\n * - `'loopback'` → `['public', 'internal', 'secret']`.\n * - `'private'` → `['public', 'internal']`.\n * - `'public-tls'` / `'public-
|
|
1
|
+
{"version":3,"file":"privacy-filter.js","names":["kept: TRecord[]","dropped: Array<{ readonly record: TRecord; readonly reason: PrivacyDecisionReason }>","counters: Record<PrivacyDecisionReason, number>"],"sources":["../../src/context-engine/privacy-filter.ts"],"sourcesContent":["/**\n * D2 sensitivity-tier filter. Tags every memory record with a\n * decision (`'pass'` / `'drop'`) before the assembled prompt is\n * compiled. The filter is *tier-based* - it trusts the\n * `record.sensitivity` tag the consolidator / writer set; the\n * outbound prompt-redaction middleware (D3, ADR-045) is the\n * universal backstop for content the filter cannot see (raw user\n * input, tool results, MCP responses, skill bodies, agent\n * instructions, tool-call args).\n *\n * @packageDocumentation\n */\n\nimport type { LocalProviderTrust, Sensitivity } from '@graphorin/core';\n\n/**\n * Filter input: the record-level sensitivity tag + the per-tier\n * trust class of the active provider.\n *\n * @stable\n */\nexport interface PrivacyFilterContext {\n /**\n * Sensitivity tiers the active provider is allowed to receive.\n * When omitted, the per-tier defaults below apply.\n */\n readonly providerAcceptsSensitivity?: ReadonlyArray<Sensitivity>;\n /**\n * Trust class of the active provider as classified by\n * `@graphorin/provider/trust/classify-local-provider.ts`. Defaults\n * to `'public-tls'` (the conservative cloud default).\n */\n readonly providerTrust?: LocalProviderTrust;\n /**\n * Per-user opt-in for cloud upload of `'internal'`-tier content.\n * Default `false` - `'internal'` content does not leave the\n * loopback boundary unless the user explicitly opts in.\n */\n readonly cloudUploadConsent?: boolean;\n /**\n * Override the default sensitivity applied to records that are\n * missing a tag. Default `'internal'` per DEC-126.\n */\n readonly defaultSensitivity?: Sensitivity;\n}\n\n/**\n * Output of {@link decide} for a single record.\n *\n * @stable\n */\nexport type PrivacyDecision = 'pass' | 'drop';\n\n/**\n * Reason the decision was made. Surfaced to the metadata block so\n * operators can audit per-tier drops.\n *\n * @stable\n */\nexport type PrivacyDecisionReason =\n | 'provider-rejects-secret'\n | 'provider-rejects-internal'\n | 'no-cloud-upload-consent'\n | 'allowed';\n\n/**\n * Resolve the effective `acceptsSensitivity` set for a provider.\n * The function is pure: callers can supply a custom matrix to\n * override the defaults (used by tests + custom adapters).\n *\n * Defaults (DEC-149, ADR-013 ext):\n *\n * - `'loopback'` → `['public', 'internal', 'secret']`.\n * - `'private'` → `['public', 'internal']`.\n * - `'public-tls'` / `'public-cleartext'` → `['public']`.\n *\n * Per-provider overrides always win over the defaults - pass\n * `providerAcceptsSensitivity` explicitly to override.\n *\n * @stable\n */\nexport function effectiveAcceptsSensitivity(\n context: PrivacyFilterContext,\n): ReadonlyArray<Sensitivity> {\n if (context.providerAcceptsSensitivity !== undefined) {\n return context.providerAcceptsSensitivity;\n }\n switch (context.providerTrust ?? 'public-tls') {\n case 'loopback':\n return ['public', 'internal', 'secret'];\n case 'private':\n return ['public', 'internal'];\n case 'public-tls':\n case 'public-cleartext':\n return ['public'];\n default:\n return ['public'];\n }\n}\n\n/**\n * Decide whether a single record is safe to send to the active\n * provider. The decision logic mirrors the DoD spec:\n *\n * - `'public'` always passes.\n * - `'secret'` passes only when the provider explicitly accepts\n * `'secret'` AND the trust class is `'loopback'`.\n * - `'internal'` passes when the provider accepts `'internal'`\n * AND `cloudUploadConsent === true` (or the trust class is\n * `'loopback'` / `'private'`).\n *\n * @stable\n */\nexport function decide(\n recordSensitivity: Sensitivity | undefined,\n context: PrivacyFilterContext,\n): { readonly decision: PrivacyDecision; readonly reason: PrivacyDecisionReason } {\n const sensitivity = recordSensitivity ?? context.defaultSensitivity ?? 'internal';\n const accepts = effectiveAcceptsSensitivity(context);\n const trust = context.providerTrust ?? 'public-tls';\n if (sensitivity === 'public') {\n return { decision: 'pass', reason: 'allowed' };\n }\n if (sensitivity === 'secret') {\n if (accepts.includes('secret') && trust === 'loopback') {\n return { decision: 'pass', reason: 'allowed' };\n }\n return { decision: 'drop', reason: 'provider-rejects-secret' };\n }\n // 'internal'\n if (!accepts.includes('internal')) {\n return { decision: 'drop', reason: 'provider-rejects-internal' };\n }\n if (trust === 'loopback' || trust === 'private') {\n return { decision: 'pass', reason: 'allowed' };\n }\n if (context.cloudUploadConsent === true) {\n return { decision: 'pass', reason: 'allowed' };\n }\n return { decision: 'drop', reason: 'no-cloud-upload-consent' };\n}\n\n/**\n * Bookkeeping returned by {@link partition}. Carries both the\n * surviving + dropped records and a per-reason counter for the\n * audit trail.\n *\n * @stable\n */\nexport interface PartitionResult<TRecord> {\n readonly kept: ReadonlyArray<TRecord>;\n readonly dropped: ReadonlyArray<{\n readonly record: TRecord;\n readonly reason: PrivacyDecisionReason;\n }>;\n readonly counters: Readonly<Record<PrivacyDecisionReason, number>>;\n}\n\n/**\n * Partition a record list against the supplied filter context.\n *\n * @stable\n */\nexport function partition<TRecord extends { readonly sensitivity?: Sensitivity }>(\n records: ReadonlyArray<TRecord>,\n context: PrivacyFilterContext,\n): PartitionResult<TRecord> {\n const kept: TRecord[] = [];\n const dropped: Array<{ readonly record: TRecord; readonly reason: PrivacyDecisionReason }> = [];\n const counters: Record<PrivacyDecisionReason, number> = {\n allowed: 0,\n 'no-cloud-upload-consent': 0,\n 'provider-rejects-internal': 0,\n 'provider-rejects-secret': 0,\n };\n for (const record of records) {\n const outcome = decide(record.sensitivity, context);\n counters[outcome.reason] += 1;\n if (outcome.decision === 'pass') {\n kept.push(record);\n } else {\n dropped.push({ record, reason: outcome.reason });\n }\n }\n return Object.freeze({\n kept: Object.freeze(kept),\n dropped: Object.freeze(dropped),\n counters: Object.freeze(counters),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiFA,SAAgB,4BACd,SAC4B;AAC5B,KAAI,QAAQ,+BAA+B,OACzC,QAAO,QAAQ;AAEjB,SAAQ,QAAQ,iBAAiB,cAAjC;EACE,KAAK,WACH,QAAO;GAAC;GAAU;GAAY;GAAS;EACzC,KAAK,UACH,QAAO,CAAC,UAAU,WAAW;EAC/B,KAAK;EACL,KAAK,mBACH,QAAO,CAAC,SAAS;EACnB,QACE,QAAO,CAAC,SAAS;;;;;;;;;;;;;;;;AAiBvB,SAAgB,OACd,mBACA,SACgF;CAChF,MAAM,cAAc,qBAAqB,QAAQ,sBAAsB;CACvE,MAAM,UAAU,4BAA4B,QAAQ;CACpD,MAAM,QAAQ,QAAQ,iBAAiB;AACvC,KAAI,gBAAgB,SAClB,QAAO;EAAE,UAAU;EAAQ,QAAQ;EAAW;AAEhD,KAAI,gBAAgB,UAAU;AAC5B,MAAI,QAAQ,SAAS,SAAS,IAAI,UAAU,WAC1C,QAAO;GAAE,UAAU;GAAQ,QAAQ;GAAW;AAEhD,SAAO;GAAE,UAAU;GAAQ,QAAQ;GAA2B;;AAGhE,KAAI,CAAC,QAAQ,SAAS,WAAW,CAC/B,QAAO;EAAE,UAAU;EAAQ,QAAQ;EAA6B;AAElE,KAAI,UAAU,cAAc,UAAU,UACpC,QAAO;EAAE,UAAU;EAAQ,QAAQ;EAAW;AAEhD,KAAI,QAAQ,uBAAuB,KACjC,QAAO;EAAE,UAAU;EAAQ,QAAQ;EAAW;AAEhD,QAAO;EAAE,UAAU;EAAQ,QAAQ;EAA2B;;;;;;;AAwBhE,SAAgB,UACd,SACA,SAC0B;CAC1B,MAAMA,OAAkB,EAAE;CAC1B,MAAMC,UAAuF,EAAE;CAC/F,MAAMC,WAAkD;EACtD,SAAS;EACT,2BAA2B;EAC3B,6BAA6B;EAC7B,2BAA2B;EAC5B;AACD,MAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,UAAU,OAAO,OAAO,aAAa,QAAQ;AACnD,WAAS,QAAQ,WAAW;AAC5B,MAAI,QAAQ,aAAa,OACvB,MAAK,KAAK,OAAO;MAEjB,SAAQ,KAAK;GAAE;GAAQ,QAAQ,QAAQ;GAAQ,CAAC;;AAGpD,QAAO,OAAO,OAAO;EACnB,MAAM,OAAO,OAAO,KAAK;EACzB,SAAS,OAAO,OAAO,QAAQ;EAC/B,UAAU,OAAO,OAAO,SAAS;EAClC,CAAC"}
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -133,7 +133,7 @@ declare class EmbedderMigrationStateError extends GraphorinMemoryError {
|
|
|
133
133
|
constructor(message: string);
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
|
-
* Raised by
|
|
136
|
+
* Raised by `SemanticMemory.validate` (P1-4 / MRET-3) when a caller
|
|
137
137
|
* tries to promote a fact whose quarantine was triggered by the offline
|
|
138
138
|
* injection heuristics. Such a fact is a memory-poisoning candidate: the
|
|
139
139
|
* agent's own `fact_validate` tool must never be able to admit it into
|
|
@@ -151,7 +151,7 @@ declare class QuarantinePromotionRefusedError extends GraphorinMemoryError {
|
|
|
151
151
|
constructor(factId: string, markers: ReadonlyArray<string>);
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
154
|
-
* Raised when
|
|
154
|
+
* Raised when `ProceduralMemory.induce` (P2-2) is called but no
|
|
155
155
|
* workflow inducer was configured. Induction abstracts concrete values into
|
|
156
156
|
* variables, which needs a provider - so the capability is opt-in and the
|
|
157
157
|
* default (offline) procedural tier never silently no-ops a requested
|
package/dist/errors/index.js
CHANGED
|
@@ -160,7 +160,7 @@ var EmbedderMigrationStateError = class extends GraphorinMemoryError {
|
|
|
160
160
|
}
|
|
161
161
|
};
|
|
162
162
|
/**
|
|
163
|
-
* Raised by
|
|
163
|
+
* Raised by `SemanticMemory.validate` (P1-4 / MRET-3) when a caller
|
|
164
164
|
* tries to promote a fact whose quarantine was triggered by the offline
|
|
165
165
|
* injection heuristics. Such a fact is a memory-poisoning candidate: the
|
|
166
166
|
* agent's own `fact_validate` tool must never be able to admit it into
|
|
@@ -182,7 +182,7 @@ var QuarantinePromotionRefusedError = class extends GraphorinMemoryError {
|
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
184
|
/**
|
|
185
|
-
* Raised when
|
|
185
|
+
* Raised when `ProceduralMemory.induce` (P2-2) is called but no
|
|
186
186
|
* workflow inducer was configured. Induction abstracts concrete values into
|
|
187
187
|
* variables, which needs a provider - so the capability is opt-in and the
|
|
188
188
|
* default (offline) procedural tier never silently no-ops a requested
|
package/dist/errors/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/errors/index.ts"],"sourcesContent":["/**\n * Typed error classes raised by `@graphorin/memory`. Every memory\n * subsystem throws one of these instead of plain `Error` so consumers\n * can pattern-match on `kind` and `name` without parsing the message.\n *\n * @packageDocumentation\n */\n\n/**\n * Base class for every error raised by `@graphorin/memory`. Carries a\n * stable lowercase `kind` discriminator and an optional `hint`\n * surfaced to operators (CLI command / docs link to fix the issue).\n *\n * @stable\n */\nexport abstract class GraphorinMemoryError extends Error {\n /** Stable lowercase discriminator. */\n abstract readonly kind: string;\n /** Optional actionable hint surfaced to operators. */\n readonly hint?: string;\n\n constructor(message: string, options?: { cause?: unknown; hint?: string }) {\n super(message, options !== undefined && 'cause' in options ? { cause: options.cause } : {});\n if (options?.hint !== undefined) {\n this.hint = options.hint;\n }\n }\n}\n\n/**\n * Raised when a memory write would reference an embedder that is not\n * registered in the storage layer's `embedding_meta` registry.\n *\n * @stable\n */\nexport class EmbedderRegistrationError extends GraphorinMemoryError {\n override readonly name = 'EmbedderRegistrationError';\n readonly kind = 'embedder-registration' as const;\n readonly embedderId: string;\n\n constructor(embedderId: string, options?: { cause?: unknown }) {\n super(\n `[graphorin/memory] embedder '${embedderId}' is not registered. ` +\n 'createMemory({ embedder, ... }) registers the configured embedder; ' +\n 'manual writes must reference an already-registered embedder_id.',\n {\n ...(options?.cause !== undefined ? { cause: options.cause } : {}),\n hint: 'Pass `embedder` to createMemory(...) so the registration runs at startup.',\n },\n );\n this.embedderId = embedderId;\n }\n}\n\n/**\n * Raised when a memory tool is invoked outside the per-tool ACL or the\n * memory-modification guard tier rejects the call.\n *\n * @stable\n */\nexport class MemoryToolDeniedError extends GraphorinMemoryError {\n override readonly name = 'MemoryToolDeniedError';\n readonly kind = 'memory-tool-denied' as const;\n readonly toolName: string;\n readonly reason: string;\n\n constructor(toolName: string, reason: string) {\n super(`[graphorin/memory] memory tool '${toolName}' was denied: ${reason}`, {\n hint: 'Check the tool authorisation matrix and the memory-modification guard tier policy.',\n });\n this.toolName = toolName;\n this.reason = reason;\n }\n}\n\n/**\n * Raised by `WorkingMemory` when a write would exceed the declared\n * `charLimit` and the overflow policy is `'reject'`.\n *\n * @stable\n */\nexport class WorkingBlockOverflowError extends GraphorinMemoryError {\n override readonly name = 'WorkingBlockOverflowError';\n readonly kind = 'working-block-overflow' as const;\n readonly label: string;\n readonly attempted: number;\n readonly charLimit: number;\n\n constructor(label: string, attempted: number, charLimit: number) {\n super(\n `[graphorin/memory] working block '${label}' overflow: attempted ${attempted} chars, limit is ${charLimit}.`,\n {\n hint: \"Switch the block's overflow policy to 'truncate' or shorten the input.\",\n },\n );\n this.label = label;\n this.attempted = attempted;\n this.charLimit = charLimit;\n }\n}\n\n/**\n * Raised by `WorkingMemory.replace(...)` when the supplied unique\n * substring is not present (or appears more than once) in the block\n * value.\n *\n * @stable\n */\nexport class WorkingBlockReplaceMismatchError extends GraphorinMemoryError {\n override readonly name = 'WorkingBlockReplaceMismatchError';\n readonly kind = 'working-block-replace-mismatch' as const;\n readonly label: string;\n readonly occurrences: number;\n\n constructor(label: string, occurrences: number) {\n super(\n `[graphorin/memory] block_replace on '${label}' expected exactly one occurrence of the unique substring, found ${occurrences}.`,\n {\n hint: 'Pass a longer unique substring or use block_rethink to replace the entire value.',\n },\n );\n this.label = label;\n this.occurrences = occurrences;\n }\n}\n\n/**\n * Thrown when any mutation targets a block defined with\n * `readOnly: true` (MRET-14). Previously this guard threw\n * `WorkingBlockReplaceMismatchError(label, 0)` - semantically \"your\n * unique substring matched 0 times\", which misled callers that retry\n * replace operations on mismatch.\n *\n * @stable\n */\nexport class WorkingBlockReadOnlyError extends GraphorinMemoryError {\n override readonly name = 'WorkingBlockReadOnlyError';\n readonly kind = 'working-block-read-only' as const;\n readonly label: string;\n\n constructor(label: string) {\n super(`[graphorin/memory] block '${label}' is read-only - mutations are not allowed.`, {\n hint: 'Define the block without readOnly, or write through an operator path that redefines it.',\n });\n this.label = label;\n }\n}\n\n/**\n * Raised by the embedder migration runner when the operator attempts a\n * silent embedder swap under the `lock-on-first` policy.\n *\n * @stable\n */\nexport class EmbedderMigrationLockedError extends GraphorinMemoryError {\n override readonly name = 'EmbedderMigrationLockedError';\n readonly kind = 'embedder-migration-locked' as const;\n readonly source: string;\n readonly target: string;\n\n constructor(source: string, target: string) {\n super(\n `[graphorin/memory] cannot swap embedder from '${source}' to '${target}' under the 'lock-on-first' policy. ` +\n 'Run `graphorin memory migrate` (Phase 15) or pass `policy: \"auto-migrate\"` / \"multi-active\".',\n {\n hint: 'Plan an explicit migration before swapping the active embedder.',\n },\n );\n this.source = source;\n this.target = target;\n }\n}\n\n/**\n * Raised by `migrateEmbedder(...)` when the runner is interrupted via\n * `AbortSignal`. The surrounding `for-await` loop receives this error so\n * the operator can re-run the migration. MST-12: there is no persisted\n * cursor today, so a re-run restarts from the beginning.\n *\n * @stable\n */\nexport class EmbedderMigrationAbortedError extends GraphorinMemoryError {\n override readonly name = 'EmbedderMigrationAbortedError';\n readonly kind = 'embedder-migration-aborted' as const;\n readonly migrationId: string;\n\n constructor(migrationId: string) {\n super(\n `[graphorin/memory] embedder migration '${migrationId}' aborted before completion. ` +\n 'Re-run `migrateEmbedder(...)` to restart (there is no persisted cursor yet, so it begins again).',\n {\n hint: 'Re-invoke migrateEmbedder(...) to restart the migration.',\n },\n );\n this.migrationId = migrationId;\n }\n}\n\n/**\n * Raised by the migration runner when the migration references embedders\n * that are no longer registered (e.g. the operator removed the underlying\n * tables manually).\n *\n * @stable\n */\nexport class EmbedderMigrationStateError extends GraphorinMemoryError {\n override readonly name = 'EmbedderMigrationStateError';\n readonly kind = 'embedder-migration-state' as const;\n\n constructor(message: string) {\n super(`[graphorin/memory] ${message}`, {\n hint: 'Re-register the source/target embedders (or re-run with the current ones) before retrying.',\n });\n }\n}\n\n/**\n * Raised by {@link SemanticMemory.validate} (P1-4 / MRET-3) when a caller\n * tries to promote a fact whose quarantine was triggered by the offline\n * injection heuristics. Such a fact is a memory-poisoning candidate: the\n * agent's own `fact_validate` tool must never be able to admit it into\n * action-driving recall, so promotion is refused unless an operator\n * passes the explicit `force` flag through the programmatic API.\n *\n * @stable\n */\nexport class QuarantinePromotionRefusedError extends GraphorinMemoryError {\n override readonly name = 'QuarantinePromotionRefusedError';\n readonly kind = 'quarantine-promotion-refused' as const;\n readonly factId: string;\n /** Injection-rule labels that tripped on the fact's text. */\n readonly markers: ReadonlyArray<string>;\n\n constructor(factId: string, markers: ReadonlyArray<string>) {\n super(\n `[graphorin/memory] refusing to promote fact '${factId}' out of quarantine: ` +\n `its text trips the injection heuristics (${markers.join(', ')}). ` +\n 'Promotion of an injection-flagged memory is an operator action - ' +\n 'pass `{ force: true }` to validate(...) from a trusted (non-agent) caller after review.',\n {\n hint: 'Review the quarantined fact, then promote it with validate(scope, id, reason, { force: true }) from an operator context.',\n },\n );\n this.factId = factId;\n this.markers = Object.freeze([...markers]);\n }\n}\n\n/**\n * Raised when {@link ProceduralMemory.induce} (P2-2) is called but no\n * workflow inducer was configured. Induction abstracts concrete values into\n * variables, which needs a provider - so the capability is opt-in and the\n * default (offline) procedural tier never silently no-ops a requested\n * induction.\n *\n * @stable\n */\nexport class ProcedureInductionNotConfiguredError extends GraphorinMemoryError {\n override readonly name = 'ProcedureInductionNotConfiguredError';\n readonly kind = 'procedure-induction-not-configured' as const;\n\n constructor(options?: { cause?: unknown }) {\n super(\n '[graphorin/memory] procedure induction requires a provider. ' +\n 'ProceduralMemory.induce(...) needs an inducer to abstract values into ' +\n 'variables; enable it with createMemory({ procedureInduction: { provider } }).',\n {\n ...(options?.cause !== undefined ? { cause: options.cause } : {}),\n hint: 'Pass `procedureInduction: { provider }` to createMemory(...).',\n },\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,IAAsB,uBAAtB,cAAmD,MAAM;;CAIvD,AAAS;CAET,YAAY,SAAiB,SAA8C;AACzE,QAAM,SAAS,YAAY,UAAa,WAAW,UAAU,EAAE,OAAO,QAAQ,OAAO,GAAG,EAAE,CAAC;AAC3F,MAAI,SAAS,SAAS,OACpB,MAAK,OAAO,QAAQ;;;;;;;;;AAW1B,IAAa,4BAAb,cAA+C,qBAAqB;CAClE,AAAkB,OAAO;CACzB,AAAS,OAAO;CAChB,AAAS;CAET,YAAY,YAAoB,SAA+B;AAC7D,QACE,gCAAgC,WAAW,0JAG3C;GACE,GAAI,SAAS,UAAU,SAAY,EAAE,OAAO,QAAQ,OAAO,GAAG,EAAE;GAChE,MAAM;GACP,CACF;AACD,OAAK,aAAa;;;;;;;;;AAUtB,IAAa,wBAAb,cAA2C,qBAAqB;CAC9D,AAAkB,OAAO;CACzB,AAAS,OAAO;CAChB,AAAS;CACT,AAAS;CAET,YAAY,UAAkB,QAAgB;AAC5C,QAAM,mCAAmC,SAAS,gBAAgB,UAAU,EAC1E,MAAM,sFACP,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AkB,OAAO;CACzB,AAAS,OAAO;CAEhB,YAAY,SAAiB;AAC3B,QAAM,sBAAsB,WAAW,EACrC,MAAM,8FACP,CAAC;;;;;;;;;;;;;AAcN,IAAa,kCAAb,cAAqD,qBAAqB;CACxE,AAAkB,OAAO;CACzB,AAAS,OAAO;CAChB,AAAS;;CAET,AAAS;CAET,YAAY,QAAgB,SAAgC;AAC1D,QACE,gDAAgD,OAAO,gEACT,QAAQ,KAAK,KAAK,CAAC,gKAGjE,EACE,MAAM,4HACP,CACF;AACD,OAAK,SAAS;AACd,OAAK,UAAU,OAAO,OAAO,CAAC,GAAG,QAAQ,CAAC;;;;;;;;;;;;AAa9C,IAAa,uCAAb,cAA0D,qBAAqB;CAC7E,AAAkB,OAAO;CACzB,AAAS,OAAO;CAEhB,YAAY,SAA+B;AACzC,QACE,mNAGA;GACE,GAAI,SAAS,UAAU,SAAY,EAAE,OAAO,QAAQ,OAAO,GAAG,EAAE;GAChE,MAAM;GACP,CACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/errors/index.ts"],"sourcesContent":["/**\n * Typed error classes raised by `@graphorin/memory`. Every memory\n * subsystem throws one of these instead of plain `Error` so consumers\n * can pattern-match on `kind` and `name` without parsing the message.\n *\n * @packageDocumentation\n */\n\n/**\n * Base class for every error raised by `@graphorin/memory`. Carries a\n * stable lowercase `kind` discriminator and an optional `hint`\n * surfaced to operators (CLI command / docs link to fix the issue).\n *\n * @stable\n */\nexport abstract class GraphorinMemoryError extends Error {\n /** Stable lowercase discriminator. */\n abstract readonly kind: string;\n /** Optional actionable hint surfaced to operators. */\n readonly hint?: string;\n\n constructor(message: string, options?: { cause?: unknown; hint?: string }) {\n super(message, options !== undefined && 'cause' in options ? { cause: options.cause } : {});\n if (options?.hint !== undefined) {\n this.hint = options.hint;\n }\n }\n}\n\n/**\n * Raised when a memory write would reference an embedder that is not\n * registered in the storage layer's `embedding_meta` registry.\n *\n * @stable\n */\nexport class EmbedderRegistrationError extends GraphorinMemoryError {\n override readonly name = 'EmbedderRegistrationError';\n readonly kind = 'embedder-registration' as const;\n readonly embedderId: string;\n\n constructor(embedderId: string, options?: { cause?: unknown }) {\n super(\n `[graphorin/memory] embedder '${embedderId}' is not registered. ` +\n 'createMemory({ embedder, ... }) registers the configured embedder; ' +\n 'manual writes must reference an already-registered embedder_id.',\n {\n ...(options?.cause !== undefined ? { cause: options.cause } : {}),\n hint: 'Pass `embedder` to createMemory(...) so the registration runs at startup.',\n },\n );\n this.embedderId = embedderId;\n }\n}\n\n/**\n * Raised when a memory tool is invoked outside the per-tool ACL or the\n * memory-modification guard tier rejects the call.\n *\n * @stable\n */\nexport class MemoryToolDeniedError extends GraphorinMemoryError {\n override readonly name = 'MemoryToolDeniedError';\n readonly kind = 'memory-tool-denied' as const;\n readonly toolName: string;\n readonly reason: string;\n\n constructor(toolName: string, reason: string) {\n super(`[graphorin/memory] memory tool '${toolName}' was denied: ${reason}`, {\n hint: 'Check the tool authorisation matrix and the memory-modification guard tier policy.',\n });\n this.toolName = toolName;\n this.reason = reason;\n }\n}\n\n/**\n * Raised by `WorkingMemory` when a write would exceed the declared\n * `charLimit` and the overflow policy is `'reject'`.\n *\n * @stable\n */\nexport class WorkingBlockOverflowError extends GraphorinMemoryError {\n override readonly name = 'WorkingBlockOverflowError';\n readonly kind = 'working-block-overflow' as const;\n readonly label: string;\n readonly attempted: number;\n readonly charLimit: number;\n\n constructor(label: string, attempted: number, charLimit: number) {\n super(\n `[graphorin/memory] working block '${label}' overflow: attempted ${attempted} chars, limit is ${charLimit}.`,\n {\n hint: \"Switch the block's overflow policy to 'truncate' or shorten the input.\",\n },\n );\n this.label = label;\n this.attempted = attempted;\n this.charLimit = charLimit;\n }\n}\n\n/**\n * Raised by `WorkingMemory.replace(...)` when the supplied unique\n * substring is not present (or appears more than once) in the block\n * value.\n *\n * @stable\n */\nexport class WorkingBlockReplaceMismatchError extends GraphorinMemoryError {\n override readonly name = 'WorkingBlockReplaceMismatchError';\n readonly kind = 'working-block-replace-mismatch' as const;\n readonly label: string;\n readonly occurrences: number;\n\n constructor(label: string, occurrences: number) {\n super(\n `[graphorin/memory] block_replace on '${label}' expected exactly one occurrence of the unique substring, found ${occurrences}.`,\n {\n hint: 'Pass a longer unique substring or use block_rethink to replace the entire value.',\n },\n );\n this.label = label;\n this.occurrences = occurrences;\n }\n}\n\n/**\n * Thrown when any mutation targets a block defined with\n * `readOnly: true` (MRET-14). Previously this guard threw\n * `WorkingBlockReplaceMismatchError(label, 0)` - semantically \"your\n * unique substring matched 0 times\", which misled callers that retry\n * replace operations on mismatch.\n *\n * @stable\n */\nexport class WorkingBlockReadOnlyError extends GraphorinMemoryError {\n override readonly name = 'WorkingBlockReadOnlyError';\n readonly kind = 'working-block-read-only' as const;\n readonly label: string;\n\n constructor(label: string) {\n super(`[graphorin/memory] block '${label}' is read-only - mutations are not allowed.`, {\n hint: 'Define the block without readOnly, or write through an operator path that redefines it.',\n });\n this.label = label;\n }\n}\n\n/**\n * Raised by the embedder migration runner when the operator attempts a\n * silent embedder swap under the `lock-on-first` policy.\n *\n * @stable\n */\nexport class EmbedderMigrationLockedError extends GraphorinMemoryError {\n override readonly name = 'EmbedderMigrationLockedError';\n readonly kind = 'embedder-migration-locked' as const;\n readonly source: string;\n readonly target: string;\n\n constructor(source: string, target: string) {\n super(\n `[graphorin/memory] cannot swap embedder from '${source}' to '${target}' under the 'lock-on-first' policy. ` +\n 'Run `graphorin memory migrate` (Phase 15) or pass `policy: \"auto-migrate\"` / \"multi-active\".',\n {\n hint: 'Plan an explicit migration before swapping the active embedder.',\n },\n );\n this.source = source;\n this.target = target;\n }\n}\n\n/**\n * Raised by `migrateEmbedder(...)` when the runner is interrupted via\n * `AbortSignal`. The surrounding `for-await` loop receives this error so\n * the operator can re-run the migration. MST-12: there is no persisted\n * cursor today, so a re-run restarts from the beginning.\n *\n * @stable\n */\nexport class EmbedderMigrationAbortedError extends GraphorinMemoryError {\n override readonly name = 'EmbedderMigrationAbortedError';\n readonly kind = 'embedder-migration-aborted' as const;\n readonly migrationId: string;\n\n constructor(migrationId: string) {\n super(\n `[graphorin/memory] embedder migration '${migrationId}' aborted before completion. ` +\n 'Re-run `migrateEmbedder(...)` to restart (there is no persisted cursor yet, so it begins again).',\n {\n hint: 'Re-invoke migrateEmbedder(...) to restart the migration.',\n },\n );\n this.migrationId = migrationId;\n }\n}\n\n/**\n * Raised by the migration runner when the migration references embedders\n * that are no longer registered (e.g. the operator removed the underlying\n * tables manually).\n *\n * @stable\n */\nexport class EmbedderMigrationStateError extends GraphorinMemoryError {\n override readonly name = 'EmbedderMigrationStateError';\n readonly kind = 'embedder-migration-state' as const;\n\n constructor(message: string) {\n super(`[graphorin/memory] ${message}`, {\n hint: 'Re-register the source/target embedders (or re-run with the current ones) before retrying.',\n });\n }\n}\n\n/**\n * Raised by `SemanticMemory.validate` (P1-4 / MRET-3) when a caller\n * tries to promote a fact whose quarantine was triggered by the offline\n * injection heuristics. Such a fact is a memory-poisoning candidate: the\n * agent's own `fact_validate` tool must never be able to admit it into\n * action-driving recall, so promotion is refused unless an operator\n * passes the explicit `force` flag through the programmatic API.\n *\n * @stable\n */\nexport class QuarantinePromotionRefusedError extends GraphorinMemoryError {\n override readonly name = 'QuarantinePromotionRefusedError';\n readonly kind = 'quarantine-promotion-refused' as const;\n readonly factId: string;\n /** Injection-rule labels that tripped on the fact's text. */\n readonly markers: ReadonlyArray<string>;\n\n constructor(factId: string, markers: ReadonlyArray<string>) {\n super(\n `[graphorin/memory] refusing to promote fact '${factId}' out of quarantine: ` +\n `its text trips the injection heuristics (${markers.join(', ')}). ` +\n 'Promotion of an injection-flagged memory is an operator action - ' +\n 'pass `{ force: true }` to validate(...) from a trusted (non-agent) caller after review.',\n {\n hint: 'Review the quarantined fact, then promote it with validate(scope, id, reason, { force: true }) from an operator context.',\n },\n );\n this.factId = factId;\n this.markers = Object.freeze([...markers]);\n }\n}\n\n/**\n * Raised when `ProceduralMemory.induce` (P2-2) is called but no\n * workflow inducer was configured. Induction abstracts concrete values into\n * variables, which needs a provider - so the capability is opt-in and the\n * default (offline) procedural tier never silently no-ops a requested\n * induction.\n *\n * @stable\n */\nexport class ProcedureInductionNotConfiguredError extends GraphorinMemoryError {\n override readonly name = 'ProcedureInductionNotConfiguredError';\n readonly kind = 'procedure-induction-not-configured' as const;\n\n constructor(options?: { cause?: unknown }) {\n super(\n '[graphorin/memory] procedure induction requires a provider. ' +\n 'ProceduralMemory.induce(...) needs an inducer to abstract values into ' +\n 'variables; enable it with createMemory({ procedureInduction: { provider } }).',\n {\n ...(options?.cause !== undefined ? { cause: options.cause } : {}),\n hint: 'Pass `procedureInduction: { provider }` to createMemory(...).',\n },\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,IAAsB,uBAAtB,cAAmD,MAAM;;CAIvD,AAAS;CAET,YAAY,SAAiB,SAA8C;AACzE,QAAM,SAAS,YAAY,UAAa,WAAW,UAAU,EAAE,OAAO,QAAQ,OAAO,GAAG,EAAE,CAAC;AAC3F,MAAI,SAAS,SAAS,OACpB,MAAK,OAAO,QAAQ;;;;;;;;;AAW1B,IAAa,4BAAb,cAA+C,qBAAqB;CAClE,AAAkB,OAAO;CACzB,AAAS,OAAO;CAChB,AAAS;CAET,YAAY,YAAoB,SAA+B;AAC7D,QACE,gCAAgC,WAAW,0JAG3C;GACE,GAAI,SAAS,UAAU,SAAY,EAAE,OAAO,QAAQ,OAAO,GAAG,EAAE;GAChE,MAAM;GACP,CACF;AACD,OAAK,aAAa;;;;;;;;;AAUtB,IAAa,wBAAb,cAA2C,qBAAqB;CAC9D,AAAkB,OAAO;CACzB,AAAS,OAAO;CAChB,AAAS;CACT,AAAS;CAET,YAAY,UAAkB,QAAgB;AAC5C,QAAM,mCAAmC,SAAS,gBAAgB,UAAU,EAC1E,MAAM,sFACP,CAAC;AACF,OAAK,WAAW;AAChB,OAAK,SAAS;;;;;;;;;AAUlB,IAAa,4BAAb,cAA+C,qBAAqB;CAClE,AAA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AAC;;;;;;;;;;;;;AAcN,IAAa,kCAAb,cAAqD,qBAAqB;CACxE,AAAkB,OAAO;CACzB,AAAS,OAAO;CAChB,AAAS;;CAET,AAAS;CAET,YAAY,QAAgB,SAAgC;AAC1D,QACE,gDAAgD,OAAO,gEACT,QAAQ,KAAK,KAAK,CAAC,gKAGjE,EACE,MAAM,4HACP,CACF;AACD,OAAK,SAAS;AACd,OAAK,UAAU,OAAO,OAAO,CAAC,GAAG,QAAQ,CAAC;;;;;;;;;;;;AAa9C,IAAa,uCAAb,cAA0D,qBAAqB;CAC7E,AAAkB,OAAO;CACzB,AAAS,OAAO;CAEhB,YAAY,SAA+B;AACzC,QACE,mNAGA;GACE,GAAI,SAAS,UAAU,SAAY,EAAE,OAAO,QAAQ,OAAO,GAAG,EAAE;GAChE,MAAM;GACP,CACF"}
|
package/dist/facade.d.ts
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
import { EmbeddingMetaRegistryLike, MemoryStoreAdapter } from "./internal/storage-adapter.js";
|
|
2
|
-
import {
|
|
2
|
+
import { ConflictPipelineOptions } from "./conflict/types.js";
|
|
3
3
|
import "./conflict/index.js";
|
|
4
4
|
import { ContextualRetrievalMode } from "./internal/contextualize.js";
|
|
5
|
-
import { EpisodicMemory } from "./tiers/episodic-memory.js";
|
|
6
5
|
import { SalienceWeights } from "./consolidator/decay.js";
|
|
7
6
|
import { EntityResolutionConfig } from "./graph/entity-resolver.js";
|
|
8
7
|
import { ReRanker } from "./search/types.js";
|
|
9
|
-
import {
|
|
10
|
-
import { BlockDefinition
|
|
8
|
+
import { SemanticSearchDefaults } from "./tiers/semantic-memory.js";
|
|
9
|
+
import { BlockDefinition } from "./tiers/working-memory.js";
|
|
11
10
|
import { ConsolidatorCeilings, ConsolidatorPhase, ConsolidatorTier, ConsolidatorTriggerSpec, OnBudgetExceed, PhaseListener } from "./consolidator/types.js";
|
|
12
|
-
import { Consolidator } from "./consolidator/runtime.js";
|
|
13
11
|
import "./consolidator/index.js";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
17
|
-
import { ProceduralMemory } from "./tiers/procedural-memory.js";
|
|
18
|
-
import { SessionMemory } from "./tiers/session-memory.js";
|
|
19
|
-
import { SharedMemory } from "./tiers/shared-memory.js";
|
|
12
|
+
import { Memory } from "./memory-interface.js";
|
|
13
|
+
import { ContextEngineConfig } from "./context-engine/engine.js";
|
|
14
|
+
import "./context-engine/index.js";
|
|
20
15
|
import { ScopeResolver } from "./tools/types.js";
|
|
21
16
|
import "./tools/index.js";
|
|
22
|
-
import { EmbedderProvider,
|
|
17
|
+
import { EmbedderProvider, Provider, SessionScope, Tracer } from "@graphorin/core";
|
|
23
18
|
|
|
24
19
|
//#region src/facade.d.ts
|
|
25
20
|
|
|
@@ -45,6 +40,23 @@ interface CreateMemoryOptions {
|
|
|
45
40
|
readonly tracer?: Tracer;
|
|
46
41
|
/** Override the reranker used by `SemanticMemory.search`. */
|
|
47
42
|
readonly reranker?: ReRanker;
|
|
43
|
+
/**
|
|
44
|
+
* Construction-time retrieval defaults (W-086) merged under every
|
|
45
|
+
* `SemanticMemory.search(...)` call, per-call options winning
|
|
46
|
+
* key-by-key. This is how the advanced retrieval stack (multi-query
|
|
47
|
+
* fan-out, HyDE, graph expansion, entity matching, weighted fusion,
|
|
48
|
+
* decay ranking) reaches the model-facing surfaces - `fact_search`,
|
|
49
|
+
* auto-recall and `deep_recall` all funnel through `search()` and
|
|
50
|
+
* inherit these without custom tools. Deliberately excludes the
|
|
51
|
+
* trust-sensitive predicates (`includeQuarantined`,
|
|
52
|
+
* `includeSuperseded`, `trustWeighting`, `owner`) so configuration
|
|
53
|
+
* cannot silently weaken trust gates. The fan-out switches only take
|
|
54
|
+
* effect when their backing dependency is configured (`queryTransform`
|
|
55
|
+
* for `multiQuery`/`hyde`, `graph` for `expandHops`/`entityMatch`) -
|
|
56
|
+
* and they add provider latency and cost to EVERY recall, including
|
|
57
|
+
* auto-recall, so opt in deliberately.
|
|
58
|
+
*/
|
|
59
|
+
readonly searchDefaults?: SemanticSearchDefaults;
|
|
48
60
|
/**
|
|
49
61
|
* Contextual-retrieval mode for the write path (P1-3). `'late-chunk'`
|
|
50
62
|
* (default) prepends a deterministic, offline situating context
|
|
@@ -111,13 +123,21 @@ interface CreateMemoryOptions {
|
|
|
111
123
|
readonly maxIterations?: number;
|
|
112
124
|
/** Output-token ceiling per grade call. Default 256. */
|
|
113
125
|
readonly maxTokens?: number;
|
|
126
|
+
/**
|
|
127
|
+
* Default difficulty-gate threshold in `[0, 1]` (W-088). The gate's
|
|
128
|
+
* signal lexicon is **English-only**: on non-English deployments the
|
|
129
|
+
* auto-gate never fires, so either lower this threshold or rely on
|
|
130
|
+
* `forceHard` (`deep_recall` already forces the loop). Omitted ⇒ the
|
|
131
|
+
* built-in `0.5`; per-call `difficultyThreshold` overrides it.
|
|
132
|
+
*/
|
|
133
|
+
readonly difficultyThreshold?: number;
|
|
114
134
|
};
|
|
115
135
|
/**
|
|
116
136
|
* Opt-in workflow induction (P2-2). When set, `ProceduralMemory.induce(...)`
|
|
117
137
|
* distils a reusable, value-abstracted procedure from a successful agent
|
|
118
138
|
* trajectory and stores it **quarantined** + `provenance: 'induction'`.
|
|
119
139
|
* Omitted (the default) ⇒ `induce(...)` throws
|
|
120
|
-
*
|
|
140
|
+
* `ProcedureInductionNotConfiguredError` and the procedural tier
|
|
121
141
|
* stays pure offline CRUD - no provider call.
|
|
122
142
|
*/
|
|
123
143
|
readonly procedureInduction?: {
|
|
@@ -195,6 +215,13 @@ interface CreateMemoryOptions {
|
|
|
195
215
|
/** Weights for the multi-signal salience score (X-1). */
|
|
196
216
|
readonly salienceWeights?: SalienceWeights;
|
|
197
217
|
readonly maxStandardBatchSize?: number;
|
|
218
|
+
/**
|
|
219
|
+
* Input transcript budget for one standard-phase slice, in
|
|
220
|
+
* characters (W-081). Over-budget batches are half-split before the
|
|
221
|
+
* provider call; a lone over-budget message is tail-truncated.
|
|
222
|
+
* Per-tier default (60k chars ~ 15k tokens; 120k on `full`).
|
|
223
|
+
*/
|
|
224
|
+
readonly maxTranscriptChars?: number;
|
|
198
225
|
readonly maxDeepConflictsPerRun?: number;
|
|
199
226
|
readonly dlqMaxRetries?: number;
|
|
200
227
|
readonly dlqBaseBackoffMs?: number;
|
|
@@ -211,6 +238,8 @@ interface CreateMemoryOptions {
|
|
|
211
238
|
readonly importanceThreshold?: number;
|
|
212
239
|
/** Upper bound on salient questions reflection asks per pass (P1-1). */
|
|
213
240
|
readonly reflectionMaxQuestions?: number;
|
|
241
|
+
/** Override the quarantined-insight queue cap (W-082). Default 100. */
|
|
242
|
+
readonly reflectionMaxQuarantinedInsights?: number;
|
|
214
243
|
/**
|
|
215
244
|
* Contextual retrieval for standard-phase fact writes (P1-3).
|
|
216
245
|
* `'llm'` opts into one budgeted cheap-model call per write to author
|
|
@@ -255,44 +284,6 @@ interface CreateMemoryOptions {
|
|
|
255
284
|
*/
|
|
256
285
|
readonly contextEngine?: ContextEngineConfig;
|
|
257
286
|
}
|
|
258
|
-
/**
|
|
259
|
-
* The facade returned by {@link createMemory}.
|
|
260
|
-
*
|
|
261
|
-
* @stable
|
|
262
|
-
*/
|
|
263
|
-
interface Memory {
|
|
264
|
-
readonly working: WorkingMemory;
|
|
265
|
-
readonly session: SessionMemory;
|
|
266
|
-
readonly episodic: EpisodicMemory;
|
|
267
|
-
readonly semantic: SemanticMemory;
|
|
268
|
-
readonly procedural: ProceduralMemory;
|
|
269
|
-
readonly shared: SharedMemory;
|
|
270
|
-
/**
|
|
271
|
-
* Read surface over reflection insights (P1-1). A no-op (returns
|
|
272
|
-
* empty) when the storage adapter does not expose the optional
|
|
273
|
-
* insight surface.
|
|
274
|
-
*/
|
|
275
|
-
readonly insights: InsightMemory;
|
|
276
|
-
readonly tools: ReadonlyArray<Tool>;
|
|
277
|
-
readonly consolidator: Consolidator;
|
|
278
|
-
/** The configured conflict pipeline. Surfaced for tests + CLI tooling. */
|
|
279
|
-
readonly conflictPipeline: ConflictPipeline;
|
|
280
|
-
/** The configured context engine (Phase 10d). */
|
|
281
|
-
readonly contextEngine: ContextEngine;
|
|
282
|
-
/** The active embedder, when configured. `null` otherwise. */
|
|
283
|
-
readonly embedder: EmbedderProvider | null;
|
|
284
|
-
/** The canonical id of the active embedder, when configured. */
|
|
285
|
-
embedderId(): string | null;
|
|
286
|
-
/**
|
|
287
|
-
* Compile a system-prompt block bundle. The bundle carries the
|
|
288
|
-
* static fragments per memory tier; the agent runtime consumes
|
|
289
|
-
* the {@link ContextEngine} surface (`memory.contextEngine`)
|
|
290
|
-
* directly for the full six-layer assembly.
|
|
291
|
-
*/
|
|
292
|
-
compile(scope: CompileScope, options?: CompileOptions): Promise<MemoryContextBlocks>;
|
|
293
|
-
/** Counter snapshot consumed by Phase 10d's metadata layer. */
|
|
294
|
-
metadata(scope: SessionScope): Promise<MemoryMetadata>;
|
|
295
|
-
}
|
|
296
287
|
/**
|
|
297
288
|
* Wire every memory subsystem in one call. Returns the typed
|
|
298
289
|
* `Memory` facade ready to be passed into `createAgent({...})`.
|
|
@@ -303,5 +294,5 @@ declare function createMemory(options: CreateMemoryOptions): Memory;
|
|
|
303
294
|
/** @internal - test seam for the one-time disabled-config warning. */
|
|
304
295
|
declare function _resetConsolidatorConfigWarningForTesting(): void;
|
|
305
296
|
//#endregion
|
|
306
|
-
export { CreateMemoryOptions, Memory, _resetConsolidatorConfigWarningForTesting, createMemory };
|
|
297
|
+
export { CreateMemoryOptions, type Memory, _resetConsolidatorConfigWarningForTesting, createMemory };
|
|
307
298
|
//# sourceMappingURL=facade.d.ts.map
|
package/dist/facade.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facade.d.ts","names":[],"sources":["../src/facade.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"facade.d.ts","names":[],"sources":["../src/facade.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiFoB,UAdH,mBAAA,CAcG;EAEE;EAiBM,SAAA,KAAA,EA/BV,kBA+BU;EAyBL;EAiBJ,SAAA,UAAA,EAvEI,yBAuEJ;EAIK;EAgBD,SAAA,QAAA,CAAA,EAzFD,gBAyFC;EAwBA;EAiCG,SAAA,aAAA,CAAA,EAhJC,aAgJD,CAhJe,eAgJf,CAAA;EAYY;;;;;EAGN,SAAA,MAAA,CAAA,EAzJZ,MAyJY;EAAR;EACA,SAAA,QAAA,CAAA,EAxJF,QAwJE;EAOK;;;;;;;;;;;AAiG7B;AAmYA;;;;4BAlnB4B;;;;;;;;;;;;;;;;;;;;;;;;;uBAyBL;;;;;;;;;;;;;;;;;mBAiBJ;;;;wBAIK;;;;;;;;;;;;;;;;uBAgBD;;;;;;;;;;;;;;;;;;;;;;;;uBAwBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAiCG;;;;;;;;;;;;wBAYF,cAAc;oBAClB;sBACE,cAAc;wBACZ,QAAQ;wBACR;;;;;;;;;;6BAOK;;4BAED;;;4BAGA;;;;;;;+BAOG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCAiCI;;;;;;;;;;;;4BAYP;wBACJ;;;;;;+BAMO;;;;;;;;8BAQD;;;;;;;;;2BASH;;;;;;;;iBAgBX,YAAA,UAAsB,sBAAsB;;iBAmY5C,yCAAA,CAAA"}
|
package/dist/facade.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { createConflictPipeline } from "./conflict/pipeline.js";
|
|
2
|
-
import "./conflict/index.js";
|
|
3
2
|
import { createProviderWorkflowInducer } from "./consolidator/phases/induce.js";
|
|
4
3
|
import { WorkingMemory } from "./tiers/working-memory.js";
|
|
5
4
|
import { createConsolidator } from "./consolidator/runtime.js";
|
|
6
5
|
import { createConsolidatorPlaceholder } from "./consolidator/index.js";
|
|
7
6
|
import { enLocalePack } from "./context-engine/locale-packs/en.js";
|
|
8
|
-
import "./context-engine/locale-packs/index.js";
|
|
9
7
|
import { resolveLocalePack } from "./context-engine/locale-packs/resolver.js";
|
|
10
8
|
import { gatherMemoryMetadata, renderMetadataBlock } from "./context-engine/metadata.js";
|
|
11
9
|
import { partition } from "./context-engine/privacy-filter.js";
|
|
@@ -87,7 +85,9 @@ function createMemory(options) {
|
|
|
87
85
|
...entityResolver !== null ? { entityResolver } : {},
|
|
88
86
|
...grader !== null ? { grader } : {},
|
|
89
87
|
...options.iterativeRetrieval?.maxIterations !== void 0 ? { iterativeMaxIterations: options.iterativeRetrieval.maxIterations } : {},
|
|
90
|
-
...options.
|
|
88
|
+
...options.iterativeRetrieval?.difficultyThreshold !== void 0 ? { iterativeDifficultyThreshold: options.iterativeRetrieval.difficultyThreshold } : {},
|
|
89
|
+
...options.consolidator?.salienceWeights !== void 0 ? { trustWeights: options.consolidator.salienceWeights } : {},
|
|
90
|
+
...options.searchDefaults !== void 0 ? { searchDefaults: options.searchDefaults } : {}
|
|
91
91
|
});
|
|
92
92
|
let consolidatorForSpend = null;
|
|
93
93
|
const inducer = options.procedureInduction !== void 0 ? createProviderWorkflowInducer(options.procedureInduction.provider, {
|
|
@@ -232,6 +232,7 @@ function buildConsolidator(opts, store, semantic, episodic, working, tracer) {
|
|
|
232
232
|
...opts.decayCapacity !== void 0 ? { decayCapacity: opts.decayCapacity } : {},
|
|
233
233
|
...opts.salienceWeights !== void 0 ? { salienceWeights: opts.salienceWeights } : {},
|
|
234
234
|
...opts.maxStandardBatchSize !== void 0 ? { maxStandardBatchSize: opts.maxStandardBatchSize } : {},
|
|
235
|
+
...opts.maxTranscriptChars !== void 0 ? { maxTranscriptChars: opts.maxTranscriptChars } : {},
|
|
235
236
|
...opts.maxDeepConflictsPerRun !== void 0 ? { maxDeepConflictsPerRun: opts.maxDeepConflictsPerRun } : {},
|
|
236
237
|
...opts.dlqMaxRetries !== void 0 ? { dlqMaxRetries: opts.dlqMaxRetries } : {},
|
|
237
238
|
...opts.dlqBaseBackoffMs !== void 0 ? { dlqBaseBackoffMs: opts.dlqBaseBackoffMs } : {},
|
|
@@ -242,6 +243,7 @@ function buildConsolidator(opts, store, semantic, episodic, working, tracer) {
|
|
|
242
243
|
...opts.reflection !== void 0 ? { reflection: opts.reflection } : {},
|
|
243
244
|
...opts.importanceThreshold !== void 0 ? { importanceThreshold: opts.importanceThreshold } : {},
|
|
244
245
|
...opts.reflectionMaxQuestions !== void 0 ? { reflectionMaxQuestions: opts.reflectionMaxQuestions } : {},
|
|
246
|
+
...opts.reflectionMaxQuarantinedInsights !== void 0 ? { reflectionMaxQuarantinedInsights: opts.reflectionMaxQuarantinedInsights } : {},
|
|
245
247
|
...opts.contextualRetrieval !== void 0 ? { contextualRetrieval: opts.contextualRetrieval } : {},
|
|
246
248
|
...opts.learnedContext !== void 0 ? { learnedContext: opts.learnedContext } : {},
|
|
247
249
|
...opts.learnedContextMaxChars !== void 0 ? { learnedContextMaxChars: opts.learnedContextMaxChars } : {},
|
package/dist/facade.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facade.js","names":["reranker: ReRanker","resolveScope: ScopeResolver","activeEmbedderId: string | null","consolidatorForSpend: Consolidator | null","consolidator: Consolidator","contextEngine: ContextEngine","out: { -readonly [K in keyof MemoryContextBlocks]: MemoryContextBlocks[K] }","blocksKept: ReadonlyArray<(typeof blocks)[number]>","rulesKept: ReadonlyArray<(typeof rules)[number]>","filterContext: Parameters<typeof partitionBySensitivity>[1]","partitionBySensitivity"],"sources":["../src/facade.ts"],"sourcesContent":["/**\n * `createMemory()` - the facade that wires every tier sub-module (the\n * seven-tier system) + the eleven (+1 gated) memory tools + the search\n * reranker + the context engine\n * stubs + the consolidator placeholder.\n *\n * @packageDocumentation\n */\n\nimport type {\n EmbedderProvider,\n MemoryMetadata,\n Provider,\n SessionScope,\n Tool,\n Tracer,\n} from '@graphorin/core';\nimport { NOOP_TRACER } from '@graphorin/core';\nimport {\n type ConflictPipeline,\n type ConflictPipelineOptions,\n createConflictPipeline,\n} from './conflict/index.js';\nimport {\n type Consolidator,\n type ConsolidatorCeilings,\n type ConsolidatorPhase,\n type ConsolidatorTier,\n type ConsolidatorTriggerSpec,\n createConsolidator,\n createConsolidatorPlaceholder,\n createProviderWorkflowInducer,\n type OnBudgetExceed,\n type PhaseListener,\n type SalienceWeights,\n} from './consolidator/index.js';\nimport { createContextEngine } from './context-engine/engine.js';\nimport type {\n CompileOptions,\n CompileScope,\n ContextEngine,\n ContextEngineConfig,\n MemoryContextBlocks,\n} from './context-engine/index.js';\nimport { enLocalePack } from './context-engine/locale-packs/index.js';\nimport { resolveLocalePack } from './context-engine/locale-packs/resolver.js';\nimport { gatherMemoryMetadata, renderMetadataBlock } from './context-engine/metadata.js';\nimport { partition as partitionBySensitivity } from './context-engine/privacy-filter.js';\nimport { composeLayer1 } from './context-engine/templates/composer.js';\nimport { type EntityResolutionConfig, EntityResolver } from './graph/entity-resolver.js';\nimport type { ContextualRetrievalMode } from './internal/contextualize.js';\nimport { bindEmbedder } from './internal/embedder-binding.js';\nimport type { EmbeddingMetaRegistryLike, MemoryStoreAdapter } from './internal/storage-adapter.js';\nimport { createProviderRetrievalGrader } from './search/iterative.js';\nimport { createProviderQueryTransformer } from './search/query-transform.js';\nimport { RRFReranker } from './search/rrf.js';\nimport type { ReRanker } from './search/types.js';\nimport { EpisodicMemory } from './tiers/episodic-memory.js';\nimport { InsightMemory } from './tiers/insight-memory.js';\nimport { ProceduralMemory } from './tiers/procedural-memory.js';\nimport { SemanticMemory } from './tiers/semantic-memory.js';\nimport { SessionMemory } from './tiers/session-memory.js';\nimport { SharedMemory } from './tiers/shared-memory.js';\nimport { type BlockDefinition, WorkingMemory } from './tiers/working-memory.js';\nimport { buildMemoryTools, type ScopeResolver } from './tools/index.js';\n\n/**\n * Options accepted by {@link createMemory}.\n *\n * @stable\n */\nexport interface CreateMemoryOptions {\n /** Storage adapter (default: `@graphorin/store-sqlite`'s `MemoryStore`). */\n readonly store: MemoryStoreAdapter;\n /** Embedder registry. The default sqlite store exposes one as `sqlite.embeddings`. */\n readonly embeddings: EmbeddingMetaRegistryLike;\n /** Embedder provider (default: none - vector search is disabled). */\n readonly embedder?: EmbedderProvider;\n /** Pre-declared working blocks (idempotent - re-defining is a no-op). */\n readonly workingBlocks?: ReadonlyArray<BlockDefinition>;\n /**\n * Tracer used for every `memory.*` span. Defaults to the no-op\n * tracer from `@graphorin/core` so unit tests do not need to wire\n * the observability stack.\n */\n readonly tracer?: Tracer;\n /** Override the reranker used by `SemanticMemory.search`. */\n readonly reranker?: ReRanker;\n /**\n * Contextual-retrieval mode for the write path (P1-3). `'late-chunk'`\n * (default) prepends a deterministic, offline situating context\n * (entities / timeframe / topics, derived from the fact's own\n * structured fields) to the text that is embedded + FTS-indexed, so a\n * terse fact stays findable; the canonical `text` is preserved. `'off'`\n * indexes the bare text. The `'llm'` enrichment is **not** available on\n * the hot path - it is a consolidator-only opt-in configured via\n * `consolidator: { contextualRetrieval: 'llm' }`.\n */\n readonly contextualRetrieval?: 'off' | 'late-chunk';\n /**\n * Query transformation for retrieval (P2-3, opt-in). When supplied,\n * `SemanticMemory.search(..., { multiQuery })` fans the query into\n * reworded variants (multi-query / RAG-Fusion) and `{ hyde }` adds a\n * hypothetical-answer embedding - both via one cheap LLM call on the\n * given provider, fused through the existing RRF reranker. Omitted (the\n * default) ⇒ search stays **offline + single-shot** and the\n * `multiQuery` / `hyde` search options become silent no-ops. Reserve it\n * for retrieval-heavy recall, not every search (it adds provider\n * latency).\n */\n readonly queryTransform?: {\n /** Cheap provider used to rewrite the query / write the HyDE passage. */\n readonly provider: Provider;\n /** Hard ceiling on reworded variants requested per call. Default 5. */\n readonly maxVariants?: number;\n /** Output-token ceiling per transform call. Default 256. */\n readonly maxTokens?: number;\n };\n /**\n * Relation-graph entity resolution (P2-1). When `entityResolution` is\n * `true` **and** the storage adapter exposes a `graph` surface (the\n * default `@graphorin/store-sqlite` does), `remember(...)` resolves a\n * fact's subject / object to canonical entities and links them, so\n * `search(..., { expandHops: 1 })` can traverse relationships. Omitted\n * (the default) ⇒ facts still carry s/p/o but form no entity links and\n * the write path stays offline + unchanged. Dedup is lexical +\n * embedding (offline, via the configured embedder); LLM adjudication of\n * ambiguous merges is a further opt-in that needs `provider`.\n */\n readonly graph?: EntityResolutionConfig & {\n /** Enable entity resolution + linking on write. Default `false`. */\n readonly entityResolution?: boolean;\n /** Provider for opt-in LLM adjudication of ambiguous merges. */\n readonly provider?: Provider;\n };\n /**\n * Agentic / iterative retrieval (P2-4, opt-in). When supplied,\n * `SemanticMemory.searchIterative(...)` and the gated `deep_recall`\n * tool can grade a retrieved set on the given provider and, for queries\n * judged hard, reformulate + retrieve again (widening to one-hop graph\n * expansion) up to `maxIterations`, abstaining instead of confabulating\n * when memory is insufficient. Omitted (the default) ⇒ `searchIterative`\n * stays a single difficulty-gated pass with **no provider call**, and\n * `deep_recall` is **not** registered (the tool surface stays at the\n * canonical eleven). Reserve it for hard multi-hop / temporal recall -\n * it adds provider latency per pass.\n */\n readonly iterativeRetrieval?: {\n /** Cheap provider used to grade retrieved memories + reformulate. */\n readonly provider: Provider;\n /** Default total-pass cap (clamped to `[1, 5]`). Default 3. */\n readonly maxIterations?: number;\n /** Output-token ceiling per grade call. Default 256. */\n readonly maxTokens?: number;\n };\n /**\n * Opt-in workflow induction (P2-2). When set, `ProceduralMemory.induce(...)`\n * distils a reusable, value-abstracted procedure from a successful agent\n * trajectory and stores it **quarantined** + `provenance: 'induction'`.\n * Omitted (the default) ⇒ `induce(...)` throws\n * {@link ProcedureInductionNotConfiguredError} and the procedural tier\n * stays pure offline CRUD - no provider call.\n */\n readonly procedureInduction?: {\n /** Provider used to abstract trajectory values into a procedure. */\n readonly provider: Provider;\n /** Output-token ceiling per induction call. Default 512. */\n readonly maxTokens?: number;\n };\n /**\n * Promotion-by-demonstrated-success for quarantined induced\n * procedures (MCON-2 part 4). Fully offline - orthogonal to\n * `procedureInduction` (no provider needed). When configured,\n * `procedural.recordOutcome(scope, id, true)` increments the rule's\n * persistent success counter and promotes it into `activate()` once\n * `afterSuccesses` verified reuses accumulate; the injection gate\n * still refuses flagged texts. Omitted ⇒ outcomes are counted but\n * nothing auto-promotes.\n */\n readonly procedurePromotion?: {\n /** Successful demonstrated reuses required before promotion (≥ 1). */\n readonly afterSuccesses: number;\n };\n /**\n * Register the gated `runbook_search` tool (D3) so the model can look\n * up validated procedures by task description (content recall over\n * procedural memory, returning whole runbooks). Fully offline - the\n * default `@graphorin/store-sqlite` adapter serves it from the rules\n * FTS index (migration 028); adapters without the index degrade to an\n * in-memory lexical scan. Default `false` - the tool surface stays at\n * the canonical eleven.\n */\n readonly runbookSearch?: boolean;\n /**\n * Resolver that produces the live {@link SessionScope} for each\n * memory-tool invocation. Defaults to a closure that throws - the\n * agent runtime overrides it in Phase 12.\n */\n readonly resolveScope?: ScopeResolver;\n /**\n * Consolidator configuration. When omitted, empty, or\n * `enabled: false`, the facade installs the Phase 10a no-op\n * placeholder so consumers can still type their interactions without\n * paying the runtime cost. ANY other setting - including offline\n * knobs like `decayCapacity` or `contextualRetrieval` - implicitly\n * enables the production runtime (MST-4); `enabled: false` together\n * with other settings warns once and keeps the placeholder.\n */\n readonly consolidator?: {\n readonly enabled?: boolean;\n readonly triggers?: ReadonlyArray<ConsolidatorTriggerSpec>;\n readonly tier?: ConsolidatorTier;\n readonly phases?: ReadonlyArray<ConsolidatorPhase>;\n readonly ceilings?: Partial<ConsolidatorCeilings>;\n readonly onExceed?: OnBudgetExceed;\n /**\n * USD pricer for phase LLM usage (memory-consolidation-02) - wire\n * to `@graphorin/pricing` so `maxCostPerDay` can actually trip.\n */\n readonly priceUsage?: (usage: { promptTokens: number; completionTokens: number }) => number;\n /** Provider routed to the standard phase when set (MCON-7); falls back to `provider`. */\n readonly cheapProvider?: Provider | null;\n /** Provider routed to the deep + reflection passes when set (MCON-7). */\n readonly deepProvider?: Provider | null;\n readonly cheapModel?: string | null;\n readonly deepModel?: string | null;\n readonly noiseFilters?: ReadonlyArray<'default' | 'minimal' | 'none'>;\n readonly lockWaitMs?: number;\n readonly decayTauDays?: number;\n readonly decayArchiveThreshold?: number;\n /** Capacity-bounded eviction target for the light phase (X-1). Default unbounded. */\n readonly decayCapacity?: number | null;\n /** Weights for the multi-signal salience score (X-1). */\n readonly salienceWeights?: SalienceWeights;\n readonly maxStandardBatchSize?: number;\n readonly maxDeepConflictsPerRun?: number;\n readonly dlqMaxRetries?: number;\n readonly dlqBaseBackoffMs?: number;\n readonly dlqMaxBackoffMs?: number;\n /** Auto-form quarantined episodes from processed slices (P1-2). Per-tier default. */\n readonly formEpisodes?: boolean;\n /** Score episode importance via the consolidator LLM (P1-2). Per-tier default. */\n readonly importanceScoring?: boolean;\n /** Opt in to auto-promotion of injection-clean extraction facts (MCON-2). Default off. */\n readonly autoPromoteExtraction?: boolean;\n /** Run the deep-phase reflection pass synthesizing cited insights (P1-1). Per-tier default. */\n readonly reflection?: boolean;\n /** Accumulated-importance threshold at which reflection fires (P1-1). */\n readonly importanceThreshold?: number;\n /** Upper bound on salient questions reflection asks per pass (P1-1). */\n readonly reflectionMaxQuestions?: number;\n /**\n * Contextual retrieval for standard-phase fact writes (P1-3).\n * `'llm'` opts into one budgeted cheap-model call per write to author\n * a situating prefix (consolidator-only); `'late-chunk'` (default)\n * and `'off'` defer to the write-path mode. Per-tier default.\n */\n readonly contextualRetrieval?: ContextualRetrievalMode;\n /**\n * Maintain the learned-context digest block (D3): after each deep\n * phase, one budgeted LLM call rewrites the reserved\n * `learned_context` working block (previous digest + recent\n * episodes / active insights / procedures), so the assembled system\n * prompt carries a compact standing summary. Default `false` at\n * every tier (Wave-D trial).\n */\n readonly learnedContext?: boolean;\n /** Character bound for the learned-context digest (D3). Default `1200`. */\n readonly learnedContextMaxChars?: number;\n readonly defaultScope?: SessionScope;\n readonly provider?: Provider | null;\n /** Override the wall clock - used by tests. */\n readonly now?: () => number;\n /** Stable id seed - used by tests. */\n readonly randomId?: () => string;\n /** Subscribe to phase-finished events. */\n readonly onPhaseFinished?: PhaseListener;\n };\n /**\n * Conflict pipeline configuration (Phase 10b). Default: enabled,\n * English locale pack, thresholds `0.95 / 0.85 / 0.4`. Pass\n * `{ mode: 'off' }` to bypass the pipeline entirely (logs a one-shot\n * WARN per process per the spec).\n */\n readonly conflictPipeline?: ConflictPipelineOptions;\n /**\n * Context engine configuration (Phase 10d). The engine assembles\n * the layered six-layer system prompt; `memory.compile(scope)`\n * delegates to it for the working blocks + rules + metadata\n * fragments. When omitted, a default engine is created (English\n * locale; `'full'` base mode; no auto-recall; conservative\n * `'public-tls'` provider trust).\n */\n readonly contextEngine?: ContextEngineConfig;\n}\n\n/**\n * The facade returned by {@link createMemory}.\n *\n * @stable\n */\nexport interface Memory {\n readonly working: WorkingMemory;\n readonly session: SessionMemory;\n readonly episodic: EpisodicMemory;\n readonly semantic: SemanticMemory;\n readonly procedural: ProceduralMemory;\n readonly shared: SharedMemory;\n /**\n * Read surface over reflection insights (P1-1). A no-op (returns\n * empty) when the storage adapter does not expose the optional\n * insight surface.\n */\n readonly insights: InsightMemory;\n readonly tools: ReadonlyArray<Tool>;\n readonly consolidator: Consolidator;\n /** The configured conflict pipeline. Surfaced for tests + CLI tooling. */\n readonly conflictPipeline: ConflictPipeline;\n /** The configured context engine (Phase 10d). */\n readonly contextEngine: ContextEngine;\n /** The active embedder, when configured. `null` otherwise. */\n readonly embedder: EmbedderProvider | null;\n /** The canonical id of the active embedder, when configured. */\n embedderId(): string | null;\n /**\n * Compile a system-prompt block bundle. The bundle carries the\n * static fragments per memory tier; the agent runtime consumes\n * the {@link ContextEngine} surface (`memory.contextEngine`)\n * directly for the full six-layer assembly.\n */\n compile(scope: CompileScope, options?: CompileOptions): Promise<MemoryContextBlocks>;\n /** Counter snapshot consumed by Phase 10d's metadata layer. */\n metadata(scope: SessionScope): Promise<MemoryMetadata>;\n}\n\n/**\n * Wire every memory subsystem in one call. Returns the typed\n * `Memory` facade ready to be passed into `createAgent({...})`.\n *\n * @stable\n */\nexport function createMemory(options: CreateMemoryOptions): Memory {\n const tracer = options.tracer ?? NOOP_TRACER;\n const reranker: ReRanker = options.reranker ?? new RRFReranker();\n const resolveScope: ScopeResolver =\n options.resolveScope ??\n (() => {\n throw new TypeError(\n '[graphorin/memory] memory tool invoked without a scope resolver. ' +\n 'Pass `resolveScope` to createMemory({...}) - the agent runtime supplies one in Phase 12.',\n );\n });\n\n let activeEmbedderId: string | null = null;\n if (options.embedder !== undefined) {\n activeEmbedderId = bindEmbedder(options.embedder, options.embeddings);\n }\n const embedder = options.embedder ?? null;\n const embedderIdProvider = (): string | null => activeEmbedderId;\n\n const working = new WorkingMemory({ store: options.store, tracer });\n for (const block of options.workingBlocks ?? []) {\n working.define(block);\n }\n const session = new SessionMemory({ store: options.store, tracer });\n const episodic = new EpisodicMemory({\n store: options.store,\n tracer,\n embedder,\n embedderIdProvider,\n });\n const conflictPipeline = createConflictPipeline(options.conflictPipeline ?? {});\n // P2-3: build the (opt-in) query transformer from the supplied provider.\n // Absent ⇒ `null` ⇒ search stays offline + single-shot.\n const queryTransformer =\n options.queryTransform !== undefined\n ? createProviderQueryTransformer(options.queryTransform.provider, {\n ...(options.queryTransform.maxVariants !== undefined\n ? { maxVariants: options.queryTransform.maxVariants }\n : {}),\n ...(options.queryTransform.maxTokens !== undefined\n ? { maxTokens: options.queryTransform.maxTokens }\n : {}),\n })\n : null;\n // P2-1: build the (opt-in) entity resolver. Requires `graph.entityResolution`\n // *and* a graph-capable adapter; absent ⇒ `null` ⇒ writes carry s/p/o but\n // form no entity links and the write path stays offline + unchanged.\n const graphStore = options.store.graph;\n const entityResolver =\n options.graph?.entityResolution === true && graphStore !== undefined\n ? new EntityResolver({\n store: graphStore,\n embedder,\n embedderId: embedderIdProvider,\n ...(options.graph.provider !== undefined ? { provider: options.graph.provider } : {}),\n config: {\n ...(options.graph.mergeThreshold !== undefined\n ? { mergeThreshold: options.graph.mergeThreshold }\n : {}),\n ...(options.graph.adjudicateThreshold !== undefined\n ? { adjudicateThreshold: options.graph.adjudicateThreshold }\n : {}),\n ...(options.graph.llmAdjudication !== undefined\n ? { llmAdjudication: options.graph.llmAdjudication }\n : {}),\n },\n })\n : null;\n // P2-4: build the (opt-in) retrieval grader. Absent ⇒ `null` ⇒\n // `searchIterative` runs a single difficulty-gated pass (no provider\n // call) and the `deep_recall` tool is not registered.\n const grader =\n options.iterativeRetrieval !== undefined\n ? createProviderRetrievalGrader(options.iterativeRetrieval.provider, {\n ...(options.iterativeRetrieval.maxTokens !== undefined\n ? { maxTokens: options.iterativeRetrieval.maxTokens }\n : {}),\n })\n : null;\n const semantic = new SemanticMemory({\n store: options.store,\n tracer,\n embedder,\n embedderIdProvider,\n reranker,\n conflictPipeline,\n ...(options.contextualRetrieval !== undefined\n ? { contextualRetrieval: options.contextualRetrieval }\n : {}),\n ...(queryTransformer !== null ? { queryTransformer } : {}),\n ...(entityResolver !== null ? { entityResolver } : {}),\n ...(grader !== null ? { grader } : {}),\n ...(options.iterativeRetrieval?.maxIterations !== undefined\n ? { iterativeMaxIterations: options.iterativeRetrieval.maxIterations }\n : {}),\n // C5: the same weights drive eviction salience and rank-time trust.\n ...(options.consolidator?.salienceWeights !== undefined\n ? { trustWeights: options.consolidator.salienceWeights }\n : {}),\n });\n // P2-2: build the (opt-in) workflow inducer. Absent ⇒ `null` ⇒\n // `ProceduralMemory.induce(...)` throws and the tier stays offline CRUD.\n // MCON-15: induction spend is recorded into the consolidator budget -\n // the consolidator is constructed AFTER the inducer, so the callback\n // routes through a slot filled below (placeholder ⇒ no-op).\n let consolidatorForSpend: Consolidator | null = null;\n const inducer =\n options.procedureInduction !== undefined\n ? createProviderWorkflowInducer(options.procedureInduction.provider, {\n ...(options.procedureInduction.maxTokens !== undefined\n ? { maxTokens: options.procedureInduction.maxTokens }\n : {}),\n onUsage: (usage) => {\n consolidatorForSpend?.recordExternalSpend(usage.promptTokens + usage.completionTokens);\n },\n })\n : null;\n const procedural = new ProceduralMemory({\n store: options.store,\n tracer,\n ...(inducer !== null ? { inducer } : {}),\n // MCON-2 part 4: opt-in promotion-by-demonstrated-success.\n ...(options.procedurePromotion?.afterSuccesses !== undefined\n ? { promoteAfterSuccesses: options.procedurePromotion.afterSuccesses }\n : {}),\n });\n const shared = new SharedMemory({ store: options.store, tracer });\n const insights = new InsightMemory({ store: options.store, tracer });\n\n const tools = buildMemoryTools(\n {\n working,\n session,\n episodic,\n semantic,\n procedural,\n shared,\n resolveScope,\n },\n // P2-4: the gated `deep_recall` tool is registered only when a grader\n // is configured - the offline default stays at exactly eleven tools.\n // D3: `runbook_search` is a second gated appendix, opt-in via\n // `runbookSearch: true`.\n {\n includeDeepRecall: grader !== null,\n includeRunbookSearch: options.runbookSearch === true,\n },\n );\n\n const consolidatorOpts = options.consolidator;\n const consolidator: Consolidator = buildConsolidator(\n consolidatorOpts,\n options.store,\n semantic,\n episodic,\n working,\n tracer,\n );\n consolidatorForSpend = consolidator;\n const contextEngineConfig = options.contextEngine ?? {};\n const contextEngine: ContextEngine = createContextEngine(contextEngineConfig);\n const resolved = contextEngine.config();\n const localePack =\n contextEngineConfig.locale === undefined\n ? enLocalePack\n : typeof contextEngineConfig.locale === 'string'\n ? contextEngineConfig.locale === enLocalePack.id\n ? enLocalePack\n : resolveLocalePack({ id: contextEngineConfig.locale })\n : resolveLocalePack(contextEngineConfig.locale);\n\n // The facade's `compile(...)` is the static-fragment surface\n // consumed by callers that do not know the active provider yet\n // (the agent runtime calls `memory.contextEngine.assemble(...)`\n // with full provider context when `autoAssembleContext` is\n // enabled). The privacy filter only fires\n // when the caller explicitly passes `providerAcceptsSensitivity`\n // OR the operator opted into the engine's `privacy` block.\n const privacyOptedIn =\n contextEngineConfig.privacy !== undefined &&\n (contextEngineConfig.privacy.providerAcceptsSensitivity !== undefined ||\n contextEngineConfig.privacy.cloudUploadConsent !== undefined ||\n contextEngineConfig.privacy.providerTrust !== undefined);\n\n async function compile(\n scope: CompileScope,\n compileOptions: CompileOptions = {},\n ): Promise<MemoryContextBlocks> {\n const out: { -readonly [K in keyof MemoryContextBlocks]: MemoryContextBlocks[K] } = {};\n const blocks = await options.store.working.list(scope);\n // Quarantined (e.g. P2-2-induced) procedures are provisional and must not\n // reach the system prompt - `activate()` already excludes them, and\n // compile() (public `@stable`) must agree or a compile()-based prompt\n // builder ingests unvalidated induction procedures (MST-3).\n const rules = (await options.store.procedural.list(scope)).filter(\n (rule) => rule.status !== 'quarantined',\n );\n const shouldFilter = privacyOptedIn || compileOptions.providerAcceptsSensitivity !== undefined;\n let blocksKept: ReadonlyArray<(typeof blocks)[number]> = blocks;\n let rulesKept: ReadonlyArray<(typeof rules)[number]> = rules;\n if (shouldFilter) {\n const filterContext: Parameters<typeof partitionBySensitivity>[1] = {\n providerTrust: resolved.providerTrust,\n cloudUploadConsent: resolved.cloudUploadConsent,\n defaultSensitivity: resolved.defaultSensitivity,\n };\n if (compileOptions.providerAcceptsSensitivity !== undefined) {\n (\n filterContext as {\n providerAcceptsSensitivity?: ReadonlyArray<'public' | 'internal' | 'secret'>;\n }\n ).providerAcceptsSensitivity = compileOptions.providerAcceptsSensitivity;\n }\n blocksKept = partitionBySensitivity(blocks, filterContext).kept;\n rulesKept = partitionBySensitivity(rules, filterContext).kept;\n }\n const blocksXml = renderWorkingBlocksXml(blocksKept);\n if (blocksXml.length > 0) {\n out.workingBlocks = blocksXml;\n }\n if (rulesKept.length > 0) {\n const lines = ['<memory_rules>'];\n for (const rule of rulesKept) {\n lines.push(` <rule priority=\"${rule.priority}\">${escapeXml(rule.text)}</rule>`);\n }\n lines.push('</memory_rules>');\n out.rules = lines.join('\\n');\n }\n if (compileOptions.includeMetadata !== false) {\n const meta = await metadata(scope);\n out.metadata = renderMetadataBlock(meta);\n }\n out.base = composeLayer1(localePack, resolved.memoryBaseMode);\n return Object.freeze(out);\n }\n\n async function metadata(scope: SessionScope): Promise<MemoryMetadata> {\n return gatherMemoryMetadata(scope, {\n store: options.store,\n consolidator,\n embedderId: embedderIdProvider,\n localeId: resolved.localeId,\n });\n }\n\n return Object.freeze({\n working,\n session,\n episodic,\n semantic,\n procedural,\n shared,\n insights,\n tools,\n consolidator,\n conflictPipeline,\n contextEngine,\n embedder,\n embedderId: embedderIdProvider,\n compile,\n metadata,\n });\n}\n\nfunction renderWorkingBlocksXml(\n blocks: ReadonlyArray<{\n readonly label: string;\n readonly value: string;\n readonly description?: string;\n }>,\n): string {\n if (blocks.length === 0) return '';\n const lines = ['<memory_blocks>'];\n for (const block of blocks) {\n const description =\n block.description !== undefined ? ` description=\"${escapeXml(block.description)}\"` : '';\n lines.push(` <block label=\"${escapeXml(block.label)}\"${description}>`);\n lines.push(` ${escapeXml(block.value)}`);\n lines.push(' </block>');\n }\n lines.push('</memory_blocks>');\n return lines.join('\\n');\n}\n\nfunction escapeXml(value: string): string {\n return value\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"');\n}\n\nfunction buildConsolidator(\n opts: CreateMemoryOptions['consolidator'],\n store: CreateMemoryOptions['store'],\n semantic: SemanticMemory,\n episodic: EpisodicMemory,\n working: WorkingMemory,\n tracer: Tracer,\n): Consolidator {\n if (opts === undefined) {\n return createConsolidatorPlaceholder();\n }\n const enabled = shouldEnableConsolidator(opts);\n if (!enabled) {\n return createConsolidatorPlaceholder({\n ...(opts.triggers !== undefined ? { triggers: opts.triggers } : {}),\n ...(opts.tier !== undefined ? { tier: opts.tier } : {}),\n });\n }\n const consolidator = createConsolidator({\n store,\n semantic,\n episodic,\n working,\n tracer,\n ...(opts.provider !== undefined ? { provider: opts.provider } : {}),\n ...(opts.now !== undefined ? { now: opts.now } : {}),\n ...(opts.randomId !== undefined ? { randomId: opts.randomId } : {}),\n ...(opts.triggers !== undefined ? { triggers: opts.triggers } : {}),\n ...(opts.tier !== undefined ? { tier: opts.tier } : {}),\n ...(opts.phases !== undefined ? { phases: opts.phases } : {}),\n ...(opts.ceilings !== undefined ? { ceilings: opts.ceilings } : {}),\n ...(opts.onExceed !== undefined ? { onExceed: opts.onExceed } : {}),\n ...(opts.priceUsage !== undefined ? { priceUsage: opts.priceUsage } : {}),\n ...(opts.cheapProvider !== undefined ? { cheapProvider: opts.cheapProvider } : {}),\n ...(opts.deepProvider !== undefined ? { deepProvider: opts.deepProvider } : {}),\n ...(opts.cheapModel !== undefined ? { cheapModel: opts.cheapModel } : {}),\n ...(opts.deepModel !== undefined ? { deepModel: opts.deepModel } : {}),\n ...(opts.noiseFilters !== undefined ? { noiseFilters: opts.noiseFilters } : {}),\n ...(opts.lockWaitMs !== undefined ? { lockWaitMs: opts.lockWaitMs } : {}),\n ...(opts.decayTauDays !== undefined ? { decayTauDays: opts.decayTauDays } : {}),\n ...(opts.decayArchiveThreshold !== undefined\n ? { decayArchiveThreshold: opts.decayArchiveThreshold }\n : {}),\n ...(opts.decayCapacity !== undefined ? { decayCapacity: opts.decayCapacity } : {}),\n ...(opts.salienceWeights !== undefined ? { salienceWeights: opts.salienceWeights } : {}),\n ...(opts.maxStandardBatchSize !== undefined\n ? { maxStandardBatchSize: opts.maxStandardBatchSize }\n : {}),\n ...(opts.maxDeepConflictsPerRun !== undefined\n ? { maxDeepConflictsPerRun: opts.maxDeepConflictsPerRun }\n : {}),\n ...(opts.dlqMaxRetries !== undefined ? { dlqMaxRetries: opts.dlqMaxRetries } : {}),\n ...(opts.dlqBaseBackoffMs !== undefined ? { dlqBaseBackoffMs: opts.dlqBaseBackoffMs } : {}),\n ...(opts.dlqMaxBackoffMs !== undefined ? { dlqMaxBackoffMs: opts.dlqMaxBackoffMs } : {}),\n ...(opts.formEpisodes !== undefined ? { formEpisodes: opts.formEpisodes } : {}),\n ...(opts.importanceScoring !== undefined ? { importanceScoring: opts.importanceScoring } : {}),\n ...(opts.autoPromoteExtraction !== undefined\n ? { autoPromoteExtraction: opts.autoPromoteExtraction }\n : {}),\n ...(opts.reflection !== undefined ? { reflection: opts.reflection } : {}),\n ...(opts.importanceThreshold !== undefined\n ? { importanceThreshold: opts.importanceThreshold }\n : {}),\n ...(opts.reflectionMaxQuestions !== undefined\n ? { reflectionMaxQuestions: opts.reflectionMaxQuestions }\n : {}),\n ...(opts.contextualRetrieval !== undefined\n ? { contextualRetrieval: opts.contextualRetrieval }\n : {}),\n ...(opts.learnedContext !== undefined ? { learnedContext: opts.learnedContext } : {}),\n ...(opts.learnedContextMaxChars !== undefined\n ? { learnedContextMaxChars: opts.learnedContextMaxChars }\n : {}),\n ...(opts.defaultScope !== undefined ? { defaultScope: opts.defaultScope } : {}),\n });\n if (opts.onPhaseFinished !== undefined) {\n consolidator.onPhaseFinished(opts.onPhaseFinished);\n }\n return consolidator;\n}\n\nlet consolidatorConfigIgnoredWarned = false;\n\n/** @internal - test seam for the one-time disabled-config warning. */\nexport function _resetConsolidatorConfigWarningForTesting(): void {\n consolidatorConfigIgnoredWarned = false;\n}\n\nfunction shouldEnableConsolidator(opts: NonNullable<CreateMemoryOptions['consolidator']>): boolean {\n // MST-4: ANY non-empty consolidator config implicitly enables - the old\n // allow-list silently ignored offline knobs (`decayCapacity`,\n // `formEpisodes`, `reflection`, `contextualRetrieval`, …): the caller\n // got a no-op placeholder while believing the feature was on.\n const keys = Object.keys(opts).filter(\n (k) => k !== 'enabled' && (opts as Record<string, unknown>)[k] !== undefined,\n );\n if (opts.enabled === false) {\n if (keys.length > 0 && !consolidatorConfigIgnoredWarned) {\n consolidatorConfigIgnoredWarned = true;\n process.stderr.write(\n `[graphorin/memory] consolidator config (${keys.join(', ')}) was supplied together with enabled: false - the settings are ignored until the consolidator is enabled.\\n`,\n );\n }\n return false;\n }\n if (opts.enabled === true) return true;\n return keys.length > 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqVA,SAAgB,aAAa,SAAsC;CACjE,MAAM,SAAS,QAAQ,UAAU;CACjC,MAAMA,WAAqB,QAAQ,YAAY,IAAI,aAAa;CAChE,MAAMC,eACJ,QAAQ,uBACD;AACL,QAAM,IAAI,UACR,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AAI,KAAK,wBAAwB,SAC7B,EAAE,qBAAqB,KAAK,qBAAqB,GACjD,EAAE;EACN,GAAI,KAAK,mBAAmB,SAAY,EAAE,gBAAgB,KAAK,gBAAgB,GAAG,EAAE;EACpF,GAAI,KAAK,2BAA2B,SAChC,EAAE,wBAAwB,KAAK,wBAAwB,GACvD,EAAE;EACN,GAAI,KAAK,iBAAiB,SAAY,EAAE,cAAc,KAAK,cAAc,GAAG,EAAE;EAC/E,CAAC;AACF,KAAI,KAAK,oBAAoB,OAC3B,cAAa,gBAAgB,KAAK,gBAAgB;AAEpD,QAAO;;AAGT,IAAI,kCAAkC;;AAGtC,SAAgB,4CAAkD;AAChE,mCAAkC;;AAGpC,SAAS,yBAAyB,MAAiE;CAKjG,MAAM,OAAO,OAAO,KAAK,KAAK,CAAC,QAC5B,MAAM,MAAM,aAAc,KAAiC,OAAO,OACpE;AACD,KAAI,KAAK,YAAY,OAAO;AAC1B,MAAI,KAAK,SAAS,KAAK,CAAC,iCAAiC;AACvD,qCAAkC;AAClC,WAAQ,OAAO,MACb,2CAA2C,KAAK,KAAK,KAAK,CAAC,6GAC5D;;AAEH,SAAO;;AAET,KAAI,KAAK,YAAY,KAAM,QAAO;AAClC,QAAO,KAAK,SAAS"}
|
|
1
|
+
{"version":3,"file":"facade.js","names":["reranker: ReRanker","resolveScope: ScopeResolver","activeEmbedderId: string | null","consolidatorForSpend: Consolidator | null","consolidator: Consolidator","contextEngine: ContextEngine","out: { -readonly [K in keyof MemoryContextBlocks]: MemoryContextBlocks[K] }","blocksKept: ReadonlyArray<(typeof blocks)[number]>","rulesKept: ReadonlyArray<(typeof rules)[number]>","filterContext: Parameters<typeof partitionBySensitivity>[1]","partitionBySensitivity"],"sources":["../src/facade.ts"],"sourcesContent":["/**\n * `createMemory()` - the facade that wires every tier sub-module (the\n * seven-tier system) + the eleven (+1 gated) memory tools + the search\n * reranker + the context engine\n * stubs + the consolidator placeholder.\n *\n * @packageDocumentation\n */\n\nimport type {\n EmbedderProvider,\n MemoryMetadata,\n Provider,\n SessionScope,\n Tracer,\n} from '@graphorin/core';\nimport { NOOP_TRACER } from '@graphorin/core';\nimport { type ConflictPipelineOptions, createConflictPipeline } from './conflict/index.js';\nimport {\n type Consolidator,\n type ConsolidatorCeilings,\n type ConsolidatorPhase,\n type ConsolidatorTier,\n type ConsolidatorTriggerSpec,\n createConsolidator,\n createConsolidatorPlaceholder,\n createProviderWorkflowInducer,\n type OnBudgetExceed,\n type PhaseListener,\n type SalienceWeights,\n} from './consolidator/index.js';\nimport { createContextEngine } from './context-engine/engine.js';\nimport type {\n CompileOptions,\n CompileScope,\n ContextEngine,\n ContextEngineConfig,\n MemoryContextBlocks,\n} from './context-engine/index.js';\nimport { enLocalePack } from './context-engine/locale-packs/index.js';\nimport { resolveLocalePack } from './context-engine/locale-packs/resolver.js';\nimport { gatherMemoryMetadata, renderMetadataBlock } from './context-engine/metadata.js';\nimport { partition as partitionBySensitivity } from './context-engine/privacy-filter.js';\nimport { composeLayer1 } from './context-engine/templates/composer.js';\nimport { type EntityResolutionConfig, EntityResolver } from './graph/entity-resolver.js';\nimport type { ContextualRetrievalMode } from './internal/contextualize.js';\nimport { bindEmbedder } from './internal/embedder-binding.js';\nimport type { EmbeddingMetaRegistryLike, MemoryStoreAdapter } from './internal/storage-adapter.js';\nimport type { Memory } from './memory-interface.js';\nimport { createProviderRetrievalGrader } from './search/iterative.js';\nimport { createProviderQueryTransformer } from './search/query-transform.js';\nimport { RRFReranker } from './search/rrf.js';\nimport type { ReRanker } from './search/types.js';\nimport { EpisodicMemory } from './tiers/episodic-memory.js';\nimport { InsightMemory } from './tiers/insight-memory.js';\nimport { ProceduralMemory } from './tiers/procedural-memory.js';\nimport { SemanticMemory, type SemanticSearchDefaults } from './tiers/semantic-memory.js';\nimport { SessionMemory } from './tiers/session-memory.js';\nimport { SharedMemory } from './tiers/shared-memory.js';\nimport { type BlockDefinition, WorkingMemory } from './tiers/working-memory.js';\nimport { buildMemoryTools, type ScopeResolver } from './tools/index.js';\n\n/**\n * Options accepted by {@link createMemory}.\n *\n * @stable\n */\nexport interface CreateMemoryOptions {\n /** Storage adapter (default: `@graphorin/store-sqlite`'s `MemoryStore`). */\n readonly store: MemoryStoreAdapter;\n /** Embedder registry. The default sqlite store exposes one as `sqlite.embeddings`. */\n readonly embeddings: EmbeddingMetaRegistryLike;\n /** Embedder provider (default: none - vector search is disabled). */\n readonly embedder?: EmbedderProvider;\n /** Pre-declared working blocks (idempotent - re-defining is a no-op). */\n readonly workingBlocks?: ReadonlyArray<BlockDefinition>;\n /**\n * Tracer used for every `memory.*` span. Defaults to the no-op\n * tracer from `@graphorin/core` so unit tests do not need to wire\n * the observability stack.\n */\n readonly tracer?: Tracer;\n /** Override the reranker used by `SemanticMemory.search`. */\n readonly reranker?: ReRanker;\n /**\n * Construction-time retrieval defaults (W-086) merged under every\n * `SemanticMemory.search(...)` call, per-call options winning\n * key-by-key. This is how the advanced retrieval stack (multi-query\n * fan-out, HyDE, graph expansion, entity matching, weighted fusion,\n * decay ranking) reaches the model-facing surfaces - `fact_search`,\n * auto-recall and `deep_recall` all funnel through `search()` and\n * inherit these without custom tools. Deliberately excludes the\n * trust-sensitive predicates (`includeQuarantined`,\n * `includeSuperseded`, `trustWeighting`, `owner`) so configuration\n * cannot silently weaken trust gates. The fan-out switches only take\n * effect when their backing dependency is configured (`queryTransform`\n * for `multiQuery`/`hyde`, `graph` for `expandHops`/`entityMatch`) -\n * and they add provider latency and cost to EVERY recall, including\n * auto-recall, so opt in deliberately.\n */\n readonly searchDefaults?: SemanticSearchDefaults;\n /**\n * Contextual-retrieval mode for the write path (P1-3). `'late-chunk'`\n * (default) prepends a deterministic, offline situating context\n * (entities / timeframe / topics, derived from the fact's own\n * structured fields) to the text that is embedded + FTS-indexed, so a\n * terse fact stays findable; the canonical `text` is preserved. `'off'`\n * indexes the bare text. The `'llm'` enrichment is **not** available on\n * the hot path - it is a consolidator-only opt-in configured via\n * `consolidator: { contextualRetrieval: 'llm' }`.\n */\n readonly contextualRetrieval?: 'off' | 'late-chunk';\n /**\n * Query transformation for retrieval (P2-3, opt-in). When supplied,\n * `SemanticMemory.search(..., { multiQuery })` fans the query into\n * reworded variants (multi-query / RAG-Fusion) and `{ hyde }` adds a\n * hypothetical-answer embedding - both via one cheap LLM call on the\n * given provider, fused through the existing RRF reranker. Omitted (the\n * default) ⇒ search stays **offline + single-shot** and the\n * `multiQuery` / `hyde` search options become silent no-ops. Reserve it\n * for retrieval-heavy recall, not every search (it adds provider\n * latency).\n */\n readonly queryTransform?: {\n /** Cheap provider used to rewrite the query / write the HyDE passage. */\n readonly provider: Provider;\n /** Hard ceiling on reworded variants requested per call. Default 5. */\n readonly maxVariants?: number;\n /** Output-token ceiling per transform call. Default 256. */\n readonly maxTokens?: number;\n };\n /**\n * Relation-graph entity resolution (P2-1). When `entityResolution` is\n * `true` **and** the storage adapter exposes a `graph` surface (the\n * default `@graphorin/store-sqlite` does), `remember(...)` resolves a\n * fact's subject / object to canonical entities and links them, so\n * `search(..., { expandHops: 1 })` can traverse relationships. Omitted\n * (the default) ⇒ facts still carry s/p/o but form no entity links and\n * the write path stays offline + unchanged. Dedup is lexical +\n * embedding (offline, via the configured embedder); LLM adjudication of\n * ambiguous merges is a further opt-in that needs `provider`.\n */\n readonly graph?: EntityResolutionConfig & {\n /** Enable entity resolution + linking on write. Default `false`. */\n readonly entityResolution?: boolean;\n /** Provider for opt-in LLM adjudication of ambiguous merges. */\n readonly provider?: Provider;\n };\n /**\n * Agentic / iterative retrieval (P2-4, opt-in). When supplied,\n * `SemanticMemory.searchIterative(...)` and the gated `deep_recall`\n * tool can grade a retrieved set on the given provider and, for queries\n * judged hard, reformulate + retrieve again (widening to one-hop graph\n * expansion) up to `maxIterations`, abstaining instead of confabulating\n * when memory is insufficient. Omitted (the default) ⇒ `searchIterative`\n * stays a single difficulty-gated pass with **no provider call**, and\n * `deep_recall` is **not** registered (the tool surface stays at the\n * canonical eleven). Reserve it for hard multi-hop / temporal recall -\n * it adds provider latency per pass.\n */\n readonly iterativeRetrieval?: {\n /** Cheap provider used to grade retrieved memories + reformulate. */\n readonly provider: Provider;\n /** Default total-pass cap (clamped to `[1, 5]`). Default 3. */\n readonly maxIterations?: number;\n /** Output-token ceiling per grade call. Default 256. */\n readonly maxTokens?: number;\n /**\n * Default difficulty-gate threshold in `[0, 1]` (W-088). The gate's\n * signal lexicon is **English-only**: on non-English deployments the\n * auto-gate never fires, so either lower this threshold or rely on\n * `forceHard` (`deep_recall` already forces the loop). Omitted ⇒ the\n * built-in `0.5`; per-call `difficultyThreshold` overrides it.\n */\n readonly difficultyThreshold?: number;\n };\n /**\n * Opt-in workflow induction (P2-2). When set, `ProceduralMemory.induce(...)`\n * distils a reusable, value-abstracted procedure from a successful agent\n * trajectory and stores it **quarantined** + `provenance: 'induction'`.\n * Omitted (the default) ⇒ `induce(...)` throws\n * `ProcedureInductionNotConfiguredError` and the procedural tier\n * stays pure offline CRUD - no provider call.\n */\n readonly procedureInduction?: {\n /** Provider used to abstract trajectory values into a procedure. */\n readonly provider: Provider;\n /** Output-token ceiling per induction call. Default 512. */\n readonly maxTokens?: number;\n };\n /**\n * Promotion-by-demonstrated-success for quarantined induced\n * procedures (MCON-2 part 4). Fully offline - orthogonal to\n * `procedureInduction` (no provider needed). When configured,\n * `procedural.recordOutcome(scope, id, true)` increments the rule's\n * persistent success counter and promotes it into `activate()` once\n * `afterSuccesses` verified reuses accumulate; the injection gate\n * still refuses flagged texts. Omitted ⇒ outcomes are counted but\n * nothing auto-promotes.\n */\n readonly procedurePromotion?: {\n /** Successful demonstrated reuses required before promotion (≥ 1). */\n readonly afterSuccesses: number;\n };\n /**\n * Register the gated `runbook_search` tool (D3) so the model can look\n * up validated procedures by task description (content recall over\n * procedural memory, returning whole runbooks). Fully offline - the\n * default `@graphorin/store-sqlite` adapter serves it from the rules\n * FTS index (migration 028); adapters without the index degrade to an\n * in-memory lexical scan. Default `false` - the tool surface stays at\n * the canonical eleven.\n */\n readonly runbookSearch?: boolean;\n /**\n * Resolver that produces the live {@link SessionScope} for each\n * memory-tool invocation. Defaults to a closure that throws - the\n * agent runtime overrides it in Phase 12.\n */\n readonly resolveScope?: ScopeResolver;\n /**\n * Consolidator configuration. When omitted, empty, or\n * `enabled: false`, the facade installs the Phase 10a no-op\n * placeholder so consumers can still type their interactions without\n * paying the runtime cost. ANY other setting - including offline\n * knobs like `decayCapacity` or `contextualRetrieval` - implicitly\n * enables the production runtime (MST-4); `enabled: false` together\n * with other settings warns once and keeps the placeholder.\n */\n readonly consolidator?: {\n readonly enabled?: boolean;\n readonly triggers?: ReadonlyArray<ConsolidatorTriggerSpec>;\n readonly tier?: ConsolidatorTier;\n readonly phases?: ReadonlyArray<ConsolidatorPhase>;\n readonly ceilings?: Partial<ConsolidatorCeilings>;\n readonly onExceed?: OnBudgetExceed;\n /**\n * USD pricer for phase LLM usage (memory-consolidation-02) - wire\n * to `@graphorin/pricing` so `maxCostPerDay` can actually trip.\n */\n readonly priceUsage?: (usage: { promptTokens: number; completionTokens: number }) => number;\n /** Provider routed to the standard phase when set (MCON-7); falls back to `provider`. */\n readonly cheapProvider?: Provider | null;\n /** Provider routed to the deep + reflection passes when set (MCON-7). */\n readonly deepProvider?: Provider | null;\n readonly cheapModel?: string | null;\n readonly deepModel?: string | null;\n readonly noiseFilters?: ReadonlyArray<'default' | 'minimal' | 'none'>;\n readonly lockWaitMs?: number;\n readonly decayTauDays?: number;\n readonly decayArchiveThreshold?: number;\n /** Capacity-bounded eviction target for the light phase (X-1). Default unbounded. */\n readonly decayCapacity?: number | null;\n /** Weights for the multi-signal salience score (X-1). */\n readonly salienceWeights?: SalienceWeights;\n readonly maxStandardBatchSize?: number;\n /**\n * Input transcript budget for one standard-phase slice, in\n * characters (W-081). Over-budget batches are half-split before the\n * provider call; a lone over-budget message is tail-truncated.\n * Per-tier default (60k chars ~ 15k tokens; 120k on `full`).\n */\n readonly maxTranscriptChars?: number;\n readonly maxDeepConflictsPerRun?: number;\n readonly dlqMaxRetries?: number;\n readonly dlqBaseBackoffMs?: number;\n readonly dlqMaxBackoffMs?: number;\n /** Auto-form quarantined episodes from processed slices (P1-2). Per-tier default. */\n readonly formEpisodes?: boolean;\n /** Score episode importance via the consolidator LLM (P1-2). Per-tier default. */\n readonly importanceScoring?: boolean;\n /** Opt in to auto-promotion of injection-clean extraction facts (MCON-2). Default off. */\n readonly autoPromoteExtraction?: boolean;\n /** Run the deep-phase reflection pass synthesizing cited insights (P1-1). Per-tier default. */\n readonly reflection?: boolean;\n /** Accumulated-importance threshold at which reflection fires (P1-1). */\n readonly importanceThreshold?: number;\n /** Upper bound on salient questions reflection asks per pass (P1-1). */\n readonly reflectionMaxQuestions?: number;\n /** Override the quarantined-insight queue cap (W-082). Default 100. */\n readonly reflectionMaxQuarantinedInsights?: number;\n /**\n * Contextual retrieval for standard-phase fact writes (P1-3).\n * `'llm'` opts into one budgeted cheap-model call per write to author\n * a situating prefix (consolidator-only); `'late-chunk'` (default)\n * and `'off'` defer to the write-path mode. Per-tier default.\n */\n readonly contextualRetrieval?: ContextualRetrievalMode;\n /**\n * Maintain the learned-context digest block (D3): after each deep\n * phase, one budgeted LLM call rewrites the reserved\n * `learned_context` working block (previous digest + recent\n * episodes / active insights / procedures), so the assembled system\n * prompt carries a compact standing summary. Default `false` at\n * every tier (Wave-D trial).\n */\n readonly learnedContext?: boolean;\n /** Character bound for the learned-context digest (D3). Default `1200`. */\n readonly learnedContextMaxChars?: number;\n readonly defaultScope?: SessionScope;\n readonly provider?: Provider | null;\n /** Override the wall clock - used by tests. */\n readonly now?: () => number;\n /** Stable id seed - used by tests. */\n readonly randomId?: () => string;\n /** Subscribe to phase-finished events. */\n readonly onPhaseFinished?: PhaseListener;\n };\n /**\n * Conflict pipeline configuration (Phase 10b). Default: enabled,\n * English locale pack, thresholds `0.95 / 0.85 / 0.4`. Pass\n * `{ mode: 'off' }` to bypass the pipeline entirely (logs a one-shot\n * WARN per process per the spec).\n */\n readonly conflictPipeline?: ConflictPipelineOptions;\n /**\n * Context engine configuration (Phase 10d). The engine assembles\n * the layered six-layer system prompt; `memory.compile(scope)`\n * delegates to it for the working blocks + rules + metadata\n * fragments. When omitted, a default engine is created (English\n * locale; `'full'` base mode; no auto-recall; conservative\n * `'public-tls'` provider trust).\n */\n readonly contextEngine?: ContextEngineConfig;\n}\n\n// The `Memory` interface is co-located with `ContextEngine` in\n// memory-interface.ts (issue #22 - the pair is mutually recursive and\n// keeping it here put a type-only cycle into the module graph).\n// Re-exported so `import type { Memory } from './facade.js'` and the\n// public barrel keep working unchanged.\nexport type { Memory } from './memory-interface.js';\n\n/**\n * Wire every memory subsystem in one call. Returns the typed\n * `Memory` facade ready to be passed into `createAgent({...})`.\n *\n * @stable\n */\nexport function createMemory(options: CreateMemoryOptions): Memory {\n const tracer = options.tracer ?? NOOP_TRACER;\n const reranker: ReRanker = options.reranker ?? new RRFReranker();\n const resolveScope: ScopeResolver =\n options.resolveScope ??\n (() => {\n throw new TypeError(\n '[graphorin/memory] memory tool invoked without a scope resolver. ' +\n 'Pass `resolveScope` to createMemory({...}) - the agent runtime supplies one in Phase 12.',\n );\n });\n\n let activeEmbedderId: string | null = null;\n if (options.embedder !== undefined) {\n activeEmbedderId = bindEmbedder(options.embedder, options.embeddings);\n }\n const embedder = options.embedder ?? null;\n const embedderIdProvider = (): string | null => activeEmbedderId;\n\n const working = new WorkingMemory({ store: options.store, tracer });\n for (const block of options.workingBlocks ?? []) {\n working.define(block);\n }\n const session = new SessionMemory({ store: options.store, tracer });\n const episodic = new EpisodicMemory({\n store: options.store,\n tracer,\n embedder,\n embedderIdProvider,\n });\n const conflictPipeline = createConflictPipeline(options.conflictPipeline ?? {});\n // P2-3: build the (opt-in) query transformer from the supplied provider.\n // Absent ⇒ `null` ⇒ search stays offline + single-shot.\n const queryTransformer =\n options.queryTransform !== undefined\n ? createProviderQueryTransformer(options.queryTransform.provider, {\n ...(options.queryTransform.maxVariants !== undefined\n ? { maxVariants: options.queryTransform.maxVariants }\n : {}),\n ...(options.queryTransform.maxTokens !== undefined\n ? { maxTokens: options.queryTransform.maxTokens }\n : {}),\n })\n : null;\n // P2-1: build the (opt-in) entity resolver. Requires `graph.entityResolution`\n // *and* a graph-capable adapter; absent ⇒ `null` ⇒ writes carry s/p/o but\n // form no entity links and the write path stays offline + unchanged.\n const graphStore = options.store.graph;\n const entityResolver =\n options.graph?.entityResolution === true && graphStore !== undefined\n ? new EntityResolver({\n store: graphStore,\n embedder,\n embedderId: embedderIdProvider,\n ...(options.graph.provider !== undefined ? { provider: options.graph.provider } : {}),\n config: {\n ...(options.graph.mergeThreshold !== undefined\n ? { mergeThreshold: options.graph.mergeThreshold }\n : {}),\n ...(options.graph.adjudicateThreshold !== undefined\n ? { adjudicateThreshold: options.graph.adjudicateThreshold }\n : {}),\n ...(options.graph.llmAdjudication !== undefined\n ? { llmAdjudication: options.graph.llmAdjudication }\n : {}),\n },\n })\n : null;\n // P2-4: build the (opt-in) retrieval grader. Absent ⇒ `null` ⇒\n // `searchIterative` runs a single difficulty-gated pass (no provider\n // call) and the `deep_recall` tool is not registered.\n const grader =\n options.iterativeRetrieval !== undefined\n ? createProviderRetrievalGrader(options.iterativeRetrieval.provider, {\n ...(options.iterativeRetrieval.maxTokens !== undefined\n ? { maxTokens: options.iterativeRetrieval.maxTokens }\n : {}),\n })\n : null;\n const semantic = new SemanticMemory({\n store: options.store,\n tracer,\n embedder,\n embedderIdProvider,\n reranker,\n conflictPipeline,\n ...(options.contextualRetrieval !== undefined\n ? { contextualRetrieval: options.contextualRetrieval }\n : {}),\n ...(queryTransformer !== null ? { queryTransformer } : {}),\n ...(entityResolver !== null ? { entityResolver } : {}),\n ...(grader !== null ? { grader } : {}),\n ...(options.iterativeRetrieval?.maxIterations !== undefined\n ? { iterativeMaxIterations: options.iterativeRetrieval.maxIterations }\n : {}),\n ...(options.iterativeRetrieval?.difficultyThreshold !== undefined\n ? { iterativeDifficultyThreshold: options.iterativeRetrieval.difficultyThreshold }\n : {}),\n // C5: the same weights drive eviction salience and rank-time trust.\n ...(options.consolidator?.salienceWeights !== undefined\n ? { trustWeights: options.consolidator.salienceWeights }\n : {}),\n // W-086: construction-time retrieval defaults for every search().\n ...(options.searchDefaults !== undefined ? { searchDefaults: options.searchDefaults } : {}),\n });\n // P2-2: build the (opt-in) workflow inducer. Absent ⇒ `null` ⇒\n // `ProceduralMemory.induce(...)` throws and the tier stays offline CRUD.\n // MCON-15: induction spend is recorded into the consolidator budget -\n // the consolidator is constructed AFTER the inducer, so the callback\n // routes through a slot filled below (placeholder ⇒ no-op).\n let consolidatorForSpend: Consolidator | null = null;\n const inducer =\n options.procedureInduction !== undefined\n ? createProviderWorkflowInducer(options.procedureInduction.provider, {\n ...(options.procedureInduction.maxTokens !== undefined\n ? { maxTokens: options.procedureInduction.maxTokens }\n : {}),\n onUsage: (usage) => {\n consolidatorForSpend?.recordExternalSpend(usage.promptTokens + usage.completionTokens);\n },\n })\n : null;\n const procedural = new ProceduralMemory({\n store: options.store,\n tracer,\n ...(inducer !== null ? { inducer } : {}),\n // MCON-2 part 4: opt-in promotion-by-demonstrated-success.\n ...(options.procedurePromotion?.afterSuccesses !== undefined\n ? { promoteAfterSuccesses: options.procedurePromotion.afterSuccesses }\n : {}),\n });\n const shared = new SharedMemory({ store: options.store, tracer });\n const insights = new InsightMemory({ store: options.store, tracer });\n\n const tools = buildMemoryTools(\n {\n working,\n session,\n episodic,\n semantic,\n procedural,\n shared,\n resolveScope,\n },\n // P2-4: the gated `deep_recall` tool is registered only when a grader\n // is configured - the offline default stays at exactly eleven tools.\n // D3: `runbook_search` is a second gated appendix, opt-in via\n // `runbookSearch: true`.\n {\n includeDeepRecall: grader !== null,\n includeRunbookSearch: options.runbookSearch === true,\n },\n );\n\n const consolidatorOpts = options.consolidator;\n const consolidator: Consolidator = buildConsolidator(\n consolidatorOpts,\n options.store,\n semantic,\n episodic,\n working,\n tracer,\n );\n consolidatorForSpend = consolidator;\n const contextEngineConfig = options.contextEngine ?? {};\n const contextEngine: ContextEngine = createContextEngine(contextEngineConfig);\n const resolved = contextEngine.config();\n const localePack =\n contextEngineConfig.locale === undefined\n ? enLocalePack\n : typeof contextEngineConfig.locale === 'string'\n ? contextEngineConfig.locale === enLocalePack.id\n ? enLocalePack\n : resolveLocalePack({ id: contextEngineConfig.locale })\n : resolveLocalePack(contextEngineConfig.locale);\n\n // The facade's `compile(...)` is the static-fragment surface\n // consumed by callers that do not know the active provider yet\n // (the agent runtime calls `memory.contextEngine.assemble(...)`\n // with full provider context when `autoAssembleContext` is\n // enabled). The privacy filter only fires\n // when the caller explicitly passes `providerAcceptsSensitivity`\n // OR the operator opted into the engine's `privacy` block.\n const privacyOptedIn =\n contextEngineConfig.privacy !== undefined &&\n (contextEngineConfig.privacy.providerAcceptsSensitivity !== undefined ||\n contextEngineConfig.privacy.cloudUploadConsent !== undefined ||\n contextEngineConfig.privacy.providerTrust !== undefined);\n\n async function compile(\n scope: CompileScope,\n compileOptions: CompileOptions = {},\n ): Promise<MemoryContextBlocks> {\n const out: { -readonly [K in keyof MemoryContextBlocks]: MemoryContextBlocks[K] } = {};\n const blocks = await options.store.working.list(scope);\n // Quarantined (e.g. P2-2-induced) procedures are provisional and must not\n // reach the system prompt - `activate()` already excludes them, and\n // compile() (public `@stable`) must agree or a compile()-based prompt\n // builder ingests unvalidated induction procedures (MST-3).\n const rules = (await options.store.procedural.list(scope)).filter(\n (rule) => rule.status !== 'quarantined',\n );\n const shouldFilter = privacyOptedIn || compileOptions.providerAcceptsSensitivity !== undefined;\n let blocksKept: ReadonlyArray<(typeof blocks)[number]> = blocks;\n let rulesKept: ReadonlyArray<(typeof rules)[number]> = rules;\n if (shouldFilter) {\n const filterContext: Parameters<typeof partitionBySensitivity>[1] = {\n providerTrust: resolved.providerTrust,\n cloudUploadConsent: resolved.cloudUploadConsent,\n defaultSensitivity: resolved.defaultSensitivity,\n };\n if (compileOptions.providerAcceptsSensitivity !== undefined) {\n (\n filterContext as {\n providerAcceptsSensitivity?: ReadonlyArray<'public' | 'internal' | 'secret'>;\n }\n ).providerAcceptsSensitivity = compileOptions.providerAcceptsSensitivity;\n }\n blocksKept = partitionBySensitivity(blocks, filterContext).kept;\n rulesKept = partitionBySensitivity(rules, filterContext).kept;\n }\n const blocksXml = renderWorkingBlocksXml(blocksKept);\n if (blocksXml.length > 0) {\n out.workingBlocks = blocksXml;\n }\n if (rulesKept.length > 0) {\n const lines = ['<memory_rules>'];\n for (const rule of rulesKept) {\n lines.push(` <rule priority=\"${rule.priority}\">${escapeXml(rule.text)}</rule>`);\n }\n lines.push('</memory_rules>');\n out.rules = lines.join('\\n');\n }\n if (compileOptions.includeMetadata !== false) {\n const meta = await metadata(scope);\n out.metadata = renderMetadataBlock(meta);\n }\n out.base = composeLayer1(localePack, resolved.memoryBaseMode);\n return Object.freeze(out);\n }\n\n async function metadata(scope: SessionScope): Promise<MemoryMetadata> {\n return gatherMemoryMetadata(scope, {\n store: options.store,\n consolidator,\n embedderId: embedderIdProvider,\n localeId: resolved.localeId,\n });\n }\n\n return Object.freeze({\n working,\n session,\n episodic,\n semantic,\n procedural,\n shared,\n insights,\n tools,\n consolidator,\n conflictPipeline,\n contextEngine,\n embedder,\n embedderId: embedderIdProvider,\n compile,\n metadata,\n });\n}\n\nfunction renderWorkingBlocksXml(\n blocks: ReadonlyArray<{\n readonly label: string;\n readonly value: string;\n readonly description?: string;\n }>,\n): string {\n if (blocks.length === 0) return '';\n const lines = ['<memory_blocks>'];\n for (const block of blocks) {\n const description =\n block.description !== undefined ? ` description=\"${escapeXml(block.description)}\"` : '';\n lines.push(` <block label=\"${escapeXml(block.label)}\"${description}>`);\n lines.push(` ${escapeXml(block.value)}`);\n lines.push(' </block>');\n }\n lines.push('</memory_blocks>');\n return lines.join('\\n');\n}\n\nfunction escapeXml(value: string): string {\n return value\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"');\n}\n\nfunction buildConsolidator(\n opts: CreateMemoryOptions['consolidator'],\n store: CreateMemoryOptions['store'],\n semantic: SemanticMemory,\n episodic: EpisodicMemory,\n working: WorkingMemory,\n tracer: Tracer,\n): Consolidator {\n if (opts === undefined) {\n return createConsolidatorPlaceholder();\n }\n const enabled = shouldEnableConsolidator(opts);\n if (!enabled) {\n return createConsolidatorPlaceholder({\n ...(opts.triggers !== undefined ? { triggers: opts.triggers } : {}),\n ...(opts.tier !== undefined ? { tier: opts.tier } : {}),\n });\n }\n const consolidator = createConsolidator({\n store,\n semantic,\n episodic,\n working,\n tracer,\n ...(opts.provider !== undefined ? { provider: opts.provider } : {}),\n ...(opts.now !== undefined ? { now: opts.now } : {}),\n ...(opts.randomId !== undefined ? { randomId: opts.randomId } : {}),\n ...(opts.triggers !== undefined ? { triggers: opts.triggers } : {}),\n ...(opts.tier !== undefined ? { tier: opts.tier } : {}),\n ...(opts.phases !== undefined ? { phases: opts.phases } : {}),\n ...(opts.ceilings !== undefined ? { ceilings: opts.ceilings } : {}),\n ...(opts.onExceed !== undefined ? { onExceed: opts.onExceed } : {}),\n ...(opts.priceUsage !== undefined ? { priceUsage: opts.priceUsage } : {}),\n ...(opts.cheapProvider !== undefined ? { cheapProvider: opts.cheapProvider } : {}),\n ...(opts.deepProvider !== undefined ? { deepProvider: opts.deepProvider } : {}),\n ...(opts.cheapModel !== undefined ? { cheapModel: opts.cheapModel } : {}),\n ...(opts.deepModel !== undefined ? { deepModel: opts.deepModel } : {}),\n ...(opts.noiseFilters !== undefined ? { noiseFilters: opts.noiseFilters } : {}),\n ...(opts.lockWaitMs !== undefined ? { lockWaitMs: opts.lockWaitMs } : {}),\n ...(opts.decayTauDays !== undefined ? { decayTauDays: opts.decayTauDays } : {}),\n ...(opts.decayArchiveThreshold !== undefined\n ? { decayArchiveThreshold: opts.decayArchiveThreshold }\n : {}),\n ...(opts.decayCapacity !== undefined ? { decayCapacity: opts.decayCapacity } : {}),\n ...(opts.salienceWeights !== undefined ? { salienceWeights: opts.salienceWeights } : {}),\n ...(opts.maxStandardBatchSize !== undefined\n ? { maxStandardBatchSize: opts.maxStandardBatchSize }\n : {}),\n ...(opts.maxTranscriptChars !== undefined\n ? { maxTranscriptChars: opts.maxTranscriptChars }\n : {}),\n ...(opts.maxDeepConflictsPerRun !== undefined\n ? { maxDeepConflictsPerRun: opts.maxDeepConflictsPerRun }\n : {}),\n ...(opts.dlqMaxRetries !== undefined ? { dlqMaxRetries: opts.dlqMaxRetries } : {}),\n ...(opts.dlqBaseBackoffMs !== undefined ? { dlqBaseBackoffMs: opts.dlqBaseBackoffMs } : {}),\n ...(opts.dlqMaxBackoffMs !== undefined ? { dlqMaxBackoffMs: opts.dlqMaxBackoffMs } : {}),\n ...(opts.formEpisodes !== undefined ? { formEpisodes: opts.formEpisodes } : {}),\n ...(opts.importanceScoring !== undefined ? { importanceScoring: opts.importanceScoring } : {}),\n ...(opts.autoPromoteExtraction !== undefined\n ? { autoPromoteExtraction: opts.autoPromoteExtraction }\n : {}),\n ...(opts.reflection !== undefined ? { reflection: opts.reflection } : {}),\n ...(opts.importanceThreshold !== undefined\n ? { importanceThreshold: opts.importanceThreshold }\n : {}),\n ...(opts.reflectionMaxQuestions !== undefined\n ? { reflectionMaxQuestions: opts.reflectionMaxQuestions }\n : {}),\n ...(opts.reflectionMaxQuarantinedInsights !== undefined\n ? { reflectionMaxQuarantinedInsights: opts.reflectionMaxQuarantinedInsights }\n : {}),\n ...(opts.contextualRetrieval !== undefined\n ? { contextualRetrieval: opts.contextualRetrieval }\n : {}),\n ...(opts.learnedContext !== undefined ? { learnedContext: opts.learnedContext } : {}),\n ...(opts.learnedContextMaxChars !== undefined\n ? { learnedContextMaxChars: opts.learnedContextMaxChars }\n : {}),\n ...(opts.defaultScope !== undefined ? { defaultScope: opts.defaultScope } : {}),\n });\n if (opts.onPhaseFinished !== undefined) {\n consolidator.onPhaseFinished(opts.onPhaseFinished);\n }\n return consolidator;\n}\n\nlet consolidatorConfigIgnoredWarned = false;\n\n/** @internal - test seam for the one-time disabled-config warning. */\nexport function _resetConsolidatorConfigWarningForTesting(): void {\n consolidatorConfigIgnoredWarned = false;\n}\n\nfunction shouldEnableConsolidator(opts: NonNullable<CreateMemoryOptions['consolidator']>): boolean {\n // MST-4: ANY non-empty consolidator config implicitly enables - the old\n // allow-list silently ignored offline knobs (`decayCapacity`,\n // `formEpisodes`, `reflection`, `contextualRetrieval`, …): the caller\n // got a no-op placeholder while believing the feature was on.\n const keys = Object.keys(opts).filter(\n (k) => k !== 'enabled' && (opts as Record<string, unknown>)[k] !== undefined,\n );\n if (opts.enabled === false) {\n if (keys.length > 0 && !consolidatorConfigIgnoredWarned) {\n consolidatorConfigIgnoredWarned = true;\n process.stderr.write(\n `[graphorin/memory] consolidator config (${keys.join(', ')}) was supplied together with enabled: false - the settings are ignored until the consolidator is enabled.\\n`,\n );\n }\n return false;\n }\n if (opts.enabled === true) return true;\n return keys.length > 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmVA,SAAgB,aAAa,SAAsC;CACjE,MAAM,SAAS,QAAQ,UAAU;CACjC,MAAMA,WAAqB,QAAQ,YAAY,IAAI,aAAa;CAChE,MAAMC,eACJ,QAAQ,uBACD;AACL,QAAM,IAAI,UACR,4JAED;;CAGL,IAAIC,mBAAkC;AACtC,KAAI,QAAQ,aAAa,OACvB,oBAAmB,aAAa,QAAQ,UAAU,QAAQ,WAAW;CAEvE,MAAM,WAAW,QAAQ,YAAY;CACrC,MAAM,2BAA0C;CAEhD,MAAM,UAAU,IAAI,cAAc;EAAE,OAAO,QAAQ;EAAO;EAAQ,CAAC;AACnE,MAAK,MAAM,SAAS,QAAQ,iBAAiB,EAAE,CAC7C,SAAQ,OAAO,MAAM;CAEvB,MAAM,UAAU,IAAI,cAAc;EAAE,OAAO,QAAQ;EAAO;EAAQ,CAAC;CACnE,MAAM,WAAW,IAAI,eAAe;EAClC,OAAO,QAAQ;EACf;EACA;EACA;EACD,CAAC;CACF,MAAM,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,EAAE;EACpF,GAAI,KAAK,2BAA2B,SAChC,EAAE,wBAAwB,KAAK,wBAAwB,GACvD,EAAE;EACN,GAAI,KAAK,iBAAiB,SAAY,EAAE,cAAc,KAAK,cAAc,GAAG,EAAE;EAC/E,CAAC;AACF,KAAI,KAAK,oBAAoB,OAC3B,cAAa,gBAAgB,KAAK,gBAAgB;AAEpD,QAAO;;AAGT,IAAI,kCAAkC;;AAGtC,SAAgB,4CAAkD;AAChE,mCAAkC;;AAGpC,SAAS,yBAAyB,MAAiE;CAKjG,MAAM,OAAO,OAAO,KAAK,KAAK,CAAC,QAC5B,MAAM,MAAM,aAAc,KAAiC,OAAO,OACpE;AACD,KAAI,KAAK,YAAY,OAAO;AAC1B,MAAI,KAAK,SAAS,KAAK,CAAC,iCAAiC;AACvD,qCAAkC;AAClC,WAAQ,OAAO,MACb,2CAA2C,KAAK,KAAK,KAAK,CAAC,6GAC5D;;AAEH,SAAO;;AAET,KAAI,KAAK,YAAY,KAAM,QAAO;AAClC,QAAO,KAAK,SAAS"}
|
|
@@ -168,7 +168,7 @@ var EntityResolver = class {
|
|
|
168
168
|
const embedder = this.#embedder;
|
|
169
169
|
if (embedder === null || this.#embedderId() === null) return null;
|
|
170
170
|
try {
|
|
171
|
-
const [vector] = await embedder.embed([name]);
|
|
171
|
+
const [vector] = await embedder.embed([name], { ...signal !== void 0 ? { signal } : {} });
|
|
172
172
|
return vector ?? null;
|
|
173
173
|
} catch {
|
|
174
174
|
return null;
|