@fgv/ts-agent-memory 5.1.0-45 → 5.1.0-46
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/.rush/temp/{bc5b0f2098f7df2a5c498ea77b0de13316349b96.tar.log → 6e1299d1cebb080772163a532c221cd181b54f9f.tar.log} +20 -2
- package/.rush/temp/chunked-rush-logs/ts-agent-memory.build.chunks.jsonl +2 -2
- package/.rush/temp/operation/build/all.log +2 -2
- package/.rush/temp/operation/build/log-chunks.jsonl +2 -2
- package/.rush/temp/operation/build/state.json +1 -1
- package/README.md +79 -4
- package/dist/packlets/retrieve/fragmentSemanticRetriever.js +10 -7
- package/dist/packlets/retrieve/fragmentSemanticRetriever.js.map +1 -1
- package/dist/packlets/store/fileTreeMemoryStore.js +20 -4
- package/dist/packlets/store/fileTreeMemoryStore.js.map +1 -1
- package/dist/packlets/types/writePolicy.js +10 -2
- package/dist/packlets/types/writePolicy.js.map +1 -1
- package/dist/packlets/vector/fragmentConverters.js +41 -0
- package/dist/packlets/vector/fragmentConverters.js.map +1 -0
- package/dist/packlets/vector/inMemoryFragmentCosineIndex.js +17 -9
- package/dist/packlets/vector/inMemoryFragmentCosineIndex.js.map +1 -1
- package/dist/packlets/vector/index.js +1 -0
- package/dist/packlets/vector/index.js.map +1 -1
- package/dist/packlets/vector/vectorIndex.js.map +1 -1
- package/dist/test/unit/store/fileTreeMemoryStore.test.js +64 -0
- package/dist/test/unit/store/fileTreeMemoryStore.test.js.map +1 -1
- package/dist/test/unit/store/indexInjection.test.js +432 -0
- package/dist/test/unit/store/indexInjection.test.js.map +1 -0
- package/dist/test/unit/types/temporalPolicy.test.js +21 -0
- package/dist/test/unit/types/temporalPolicy.test.js.map +1 -1
- package/dist/test/unit/types/writePolicy.test.js +83 -0
- package/dist/test/unit/types/writePolicy.test.js.map +1 -1
- package/dist/test/unit/vector/fragmentConverters.test.js +58 -0
- package/dist/test/unit/vector/fragmentConverters.test.js.map +1 -0
- package/dist/test/unit/vector/inMemoryFragmentCosineIndex.test.js +65 -0
- package/dist/test/unit/vector/inMemoryFragmentCosineIndex.test.js.map +1 -1
- package/dist/ts-agent-memory.d.ts +240 -37
- package/etc/ts-agent-memory.api.md +10 -1
- package/lib/packlets/retrieve/fragmentSemanticRetriever.d.ts +10 -7
- package/lib/packlets/retrieve/fragmentSemanticRetriever.d.ts.map +1 -1
- package/lib/packlets/retrieve/fragmentSemanticRetriever.js +10 -7
- package/lib/packlets/retrieve/fragmentSemanticRetriever.js.map +1 -1
- package/lib/packlets/store/fileTreeMemoryStore.d.ts +65 -3
- package/lib/packlets/store/fileTreeMemoryStore.d.ts.map +1 -1
- package/lib/packlets/store/fileTreeMemoryStore.js +20 -4
- package/lib/packlets/store/fileTreeMemoryStore.js.map +1 -1
- package/lib/packlets/types/writePolicy.d.ts +40 -2
- package/lib/packlets/types/writePolicy.d.ts.map +1 -1
- package/lib/packlets/types/writePolicy.js +10 -2
- package/lib/packlets/types/writePolicy.js.map +1 -1
- package/lib/packlets/vector/fragmentConverters.d.ts +25 -0
- package/lib/packlets/vector/fragmentConverters.d.ts.map +1 -0
- package/lib/packlets/vector/fragmentConverters.js +44 -0
- package/lib/packlets/vector/fragmentConverters.js.map +1 -0
- package/lib/packlets/vector/inMemoryFragmentCosineIndex.d.ts +5 -3
- package/lib/packlets/vector/inMemoryFragmentCosineIndex.d.ts.map +1 -1
- package/lib/packlets/vector/inMemoryFragmentCosineIndex.js +17 -9
- package/lib/packlets/vector/inMemoryFragmentCosineIndex.js.map +1 -1
- package/lib/packlets/vector/index.d.ts +1 -0
- package/lib/packlets/vector/index.d.ts.map +1 -1
- package/lib/packlets/vector/index.js +1 -0
- package/lib/packlets/vector/index.js.map +1 -1
- package/lib/packlets/vector/vectorIndex.d.ts +97 -22
- package/lib/packlets/vector/vectorIndex.d.ts.map +1 -1
- package/lib/packlets/vector/vectorIndex.js.map +1 -1
- package/lib/test/unit/store/fileTreeMemoryStore.test.js +64 -0
- package/lib/test/unit/store/fileTreeMemoryStore.test.js.map +1 -1
- package/lib/test/unit/store/indexInjection.test.d.ts +2 -0
- package/lib/test/unit/store/indexInjection.test.d.ts.map +1 -0
- package/lib/test/unit/store/indexInjection.test.js +434 -0
- package/lib/test/unit/store/indexInjection.test.js.map +1 -0
- package/lib/test/unit/types/temporalPolicy.test.js +21 -0
- package/lib/test/unit/types/temporalPolicy.test.js.map +1 -1
- package/lib/test/unit/types/writePolicy.test.js +83 -0
- package/lib/test/unit/types/writePolicy.test.js.map +1 -1
- package/lib/test/unit/vector/fragmentConverters.test.d.ts +2 -0
- package/lib/test/unit/vector/fragmentConverters.test.d.ts.map +1 -0
- package/lib/test/unit/vector/fragmentConverters.test.js +60 -0
- package/lib/test/unit/vector/fragmentConverters.test.js.map +1 -0
- package/lib/test/unit/vector/inMemoryFragmentCosineIndex.test.js +65 -0
- package/lib/test/unit/vector/inMemoryFragmentCosineIndex.test.js.map +1 -1
- package/package.json +7 -7
- package/rush-logs/ts-agent-memory.build.cache.log +1 -1
- package/rush-logs/ts-agent-memory.build.log +2 -2
- package/src/packlets/retrieve/fragmentSemanticRetriever.ts +10 -7
- package/src/packlets/store/fileTreeMemoryStore.ts +74 -4
- package/src/packlets/types/writePolicy.ts +40 -2
- package/src/packlets/vector/fragmentConverters.ts +55 -0
- package/src/packlets/vector/inMemoryFragmentCosineIndex.ts +35 -8
- package/src/packlets/vector/index.ts +1 -0
- package/src/packlets/vector/vectorIndex.ts +97 -22
- package/src/test/unit/store/fileTreeMemoryStore.test.ts +75 -0
- package/src/test/unit/store/indexInjection.test.ts +550 -0
- package/src/test/unit/types/temporalPolicy.test.ts +28 -0
- package/src/test/unit/types/writePolicy.test.ts +112 -0
- package/src/test/unit/vector/fragmentConverters.test.ts +80 -0
- package/src/test/unit/vector/inMemoryFragmentCosineIndex.test.ts +88 -0
- package/temp/build/lint/_eslint-5eVG3S6w.json +23 -11
- package/temp/build/typescript/ts_8nwakTlr.json +1 -1
- package/temp/ts-agent-memory.api.json +177 -21
- package/temp/ts-agent-memory.api.md +10 -1
|
@@ -1814,6 +1814,43 @@
|
|
|
1814
1814
|
],
|
|
1815
1815
|
"name": "edgeTargetKey"
|
|
1816
1816
|
},
|
|
1817
|
+
{
|
|
1818
|
+
"kind": "Variable",
|
|
1819
|
+
"canonicalReference": "@fgv/ts-agent-memory!embeddedFragmentConverter:var",
|
|
1820
|
+
"docComment": "/**\n * Converter for an {@link IEmbeddedFragment}, and the boundary that enforces the fragment-identifiability invariant: **at least one of `locator` / `fragmentId` must be present.**\n *\n * @remarks\n *\n * The invariant lives here rather than in the type. A conditional-required union (`{ locator; fragmentId? } | { locator?; fragmentId }`) was considered and declined: it costs at every construction site and buys nothing at the read site, where each field reads as `… | undefined` either way. What it must not cost is identifiability — a fragment carrying neither identity cannot be resolved back to anything by a consumer holding the query hit, so it is rejected here.\n *\n * @public\n */\n",
|
|
1821
|
+
"excerptTokens": [
|
|
1822
|
+
{
|
|
1823
|
+
"kind": "Content",
|
|
1824
|
+
"text": "embeddedFragmentConverter: "
|
|
1825
|
+
},
|
|
1826
|
+
{
|
|
1827
|
+
"kind": "Reference",
|
|
1828
|
+
"text": "Converter",
|
|
1829
|
+
"canonicalReference": "@fgv/ts-utils!Converter:interface"
|
|
1830
|
+
},
|
|
1831
|
+
{
|
|
1832
|
+
"kind": "Content",
|
|
1833
|
+
"text": "<"
|
|
1834
|
+
},
|
|
1835
|
+
{
|
|
1836
|
+
"kind": "Reference",
|
|
1837
|
+
"text": "IEmbeddedFragment",
|
|
1838
|
+
"canonicalReference": "@fgv/ts-agent-memory!IEmbeddedFragment:interface"
|
|
1839
|
+
},
|
|
1840
|
+
{
|
|
1841
|
+
"kind": "Content",
|
|
1842
|
+
"text": ">"
|
|
1843
|
+
}
|
|
1844
|
+
],
|
|
1845
|
+
"fileUrlPath": "src/packlets/vector/fragmentConverters.ts",
|
|
1846
|
+
"isReadonly": true,
|
|
1847
|
+
"releaseTag": "Public",
|
|
1848
|
+
"name": "embeddedFragmentConverter",
|
|
1849
|
+
"variableTypeTokenRange": {
|
|
1850
|
+
"startIndex": 1,
|
|
1851
|
+
"endIndex": 5
|
|
1852
|
+
}
|
|
1853
|
+
},
|
|
1817
1854
|
{
|
|
1818
1855
|
"kind": "TypeAlias",
|
|
1819
1856
|
"canonicalReference": "@fgv/ts-agent-memory!EntityId:type",
|
|
@@ -1979,7 +2016,7 @@
|
|
|
1979
2016
|
{
|
|
1980
2017
|
"kind": "Method",
|
|
1981
2018
|
"canonicalReference": "@fgv/ts-agent-memory!FileTreeMemoryStore.create:member(1)",
|
|
1982
|
-
"docComment": "/**\n * Family-convention factory.
|
|
2019
|
+
"docComment": "/**\n * Family-convention factory. Resolves the derived index (the caller's {@link IFileTreeMemoryStoreCreateParams.index | index} when supplied, a fresh {@link MemoryIndex} otherwise) and a default LWW policy, then performs an initial FileTree walk so an existing vault is indexed (and the `seq` counter resumes past the highest persisted `seq`).\n */\n",
|
|
1983
2020
|
"excerptTokens": [
|
|
1984
2021
|
{
|
|
1985
2022
|
"kind": "Content",
|
|
@@ -2672,10 +2709,47 @@
|
|
|
2672
2709
|
"endIndex": 12
|
|
2673
2710
|
}
|
|
2674
2711
|
},
|
|
2712
|
+
{
|
|
2713
|
+
"kind": "Variable",
|
|
2714
|
+
"canonicalReference": "@fgv/ts-agent-memory!fragmentLocatorConverter:var",
|
|
2715
|
+
"docComment": "/**\n * Converter for an {@link IFragmentLocator}. Validates the two offsets only — the span's *meaning* (character / byte / token unit) is the consumer's, and the index never interprets it. Note the span is advisory: see {@link IFragmentLocator}.\n *\n * @public\n */\n",
|
|
2716
|
+
"excerptTokens": [
|
|
2717
|
+
{
|
|
2718
|
+
"kind": "Content",
|
|
2719
|
+
"text": "fragmentLocatorConverter: "
|
|
2720
|
+
},
|
|
2721
|
+
{
|
|
2722
|
+
"kind": "Reference",
|
|
2723
|
+
"text": "Converter",
|
|
2724
|
+
"canonicalReference": "@fgv/ts-utils!Converter:interface"
|
|
2725
|
+
},
|
|
2726
|
+
{
|
|
2727
|
+
"kind": "Content",
|
|
2728
|
+
"text": "<"
|
|
2729
|
+
},
|
|
2730
|
+
{
|
|
2731
|
+
"kind": "Reference",
|
|
2732
|
+
"text": "IFragmentLocator",
|
|
2733
|
+
"canonicalReference": "@fgv/ts-agent-memory!IFragmentLocator:interface"
|
|
2734
|
+
},
|
|
2735
|
+
{
|
|
2736
|
+
"kind": "Content",
|
|
2737
|
+
"text": ">"
|
|
2738
|
+
}
|
|
2739
|
+
],
|
|
2740
|
+
"fileUrlPath": "src/packlets/vector/fragmentConverters.ts",
|
|
2741
|
+
"isReadonly": true,
|
|
2742
|
+
"releaseTag": "Public",
|
|
2743
|
+
"name": "fragmentLocatorConverter",
|
|
2744
|
+
"variableTypeTokenRange": {
|
|
2745
|
+
"startIndex": 1,
|
|
2746
|
+
"endIndex": 5
|
|
2747
|
+
}
|
|
2748
|
+
},
|
|
2675
2749
|
{
|
|
2676
2750
|
"kind": "Class",
|
|
2677
2751
|
"canonicalReference": "@fgv/ts-agent-memory!FragmentSemanticRetriever:class",
|
|
2678
|
-
"docComment": "/**\n * The sub-document semantic-search retriever — the \"discovery\" half of a search-then-read contract. It embeds a fragment query, queries the {@link IFragmentVectorIndex}, and returns the raw per-fragment {@link IVectorQueryHit | hits} (each carrying a record `target` AND
|
|
2752
|
+
"docComment": "/**\n * The sub-document semantic-search retriever — the \"discovery\" half of a search-then-read contract. It embeds a fragment query, queries the {@link IFragmentVectorIndex}, and returns the raw per-fragment {@link IVectorQueryHit | hits} (each carrying a record `target` AND whichever of `locator` / `fragmentId` the stored fragment was indexed with), NOT resolved records: the consumer re-reads each record and resolves the fragment on its own read side. Note the `locator` span is advisory — see {@link IFragmentLocator}; it is not a slice guaranteed to reproduce the fragment's text.\n *\n * @remarks\n *\n * Deliberately NOT an {@link IMemoryRetriever}: memory recall is record-granular and returns records; fragment discovery is fragment-granular and returns fragment identities. Keeping it a distinct surface matches the consumer contract (memory stays record-granular; sub-document knowledge uses a separate fragment index) and avoids overloading the record retriever's return type with identity fields that only make sense here.\n *\n * When no backend is wired, `supportsFragmentRecall` is `false` and any fragment query degrades loudly ({@link FRAGMENT_SEMANTIC_UNWIRED_MESSAGE}) — it NEVER returns a silent empty. A consumer-supplied backend that rejects (throws) is normalized into a `Failure`.\n *\n * @public\n */\n",
|
|
2679
2753
|
"excerptTokens": [
|
|
2680
2754
|
{
|
|
2681
2755
|
"kind": "Content",
|
|
@@ -4641,7 +4715,7 @@
|
|
|
4641
4715
|
{
|
|
4642
4716
|
"kind": "Interface",
|
|
4643
4717
|
"canonicalReference": "@fgv/ts-agent-memory!IEmbeddedFragment:interface",
|
|
4644
|
-
"docComment": "/**\n * One embedded fragment of a record: its in-record {@link IFragmentLocator | span} and
|
|
4718
|
+
"docComment": "/**\n * One embedded fragment of a record: the fragment's vector, plus at least one of the two ways to identify it — its advisory in-record {@link IFragmentLocator | span} and/or an opaque consumer-minted {@link IEmbeddedFragment.fragmentId | fragmentId}. Produced by a {@link FragmentEmbedder} and stored via {@link IFragmentVectorIndex.addFragments}.\n *\n * @remarks\n *\n * Both identity fields are optional **in the type**, but the \"at least one\" requirement is real — a fragment carrying neither is unidentifiable at the read side. It is enforced by {@link embeddedFragmentConverter} (and re-checked by the in-package index implementations) rather than by a conditional-required union (`{ locator; fragmentId? } | { locator?; fragmentId }`), which was considered and declined: the union costs at every construction site and buys nothing at the read site, where each field reads as `… | undefined` either way.\n *\n * @public\n */\n",
|
|
4645
4719
|
"excerptTokens": [
|
|
4646
4720
|
{
|
|
4647
4721
|
"kind": "Content",
|
|
@@ -4653,14 +4727,41 @@
|
|
|
4653
4727
|
"name": "IEmbeddedFragment",
|
|
4654
4728
|
"preserveMemberOrder": false,
|
|
4655
4729
|
"members": [
|
|
4730
|
+
{
|
|
4731
|
+
"kind": "PropertySignature",
|
|
4732
|
+
"canonicalReference": "@fgv/ts-agent-memory!IEmbeddedFragment#fragmentId:member",
|
|
4733
|
+
"docComment": "/**\n * An opaque, consumer-minted identity for this fragment, carried verbatim through the index and returned on the corresponding {@link IVectorQueryHit}. The index **never parses it, never filters on it, and never assigns meaning to it** — it is a bytestring, not part of the query path. It exists so a fragment stays identifiable when its text is not re-derivable from the record body.\n *\n * The guarantee is \"we never parse it\", NOT \"we keep it stable\". Because `addFragments` is whole-record-replace, an updated record re-emits its entire fragment set, so **any stability of a fragment id across re-embeds is the consumer's responsibility**, not the index's.\n */\n",
|
|
4734
|
+
"excerptTokens": [
|
|
4735
|
+
{
|
|
4736
|
+
"kind": "Content",
|
|
4737
|
+
"text": "readonly fragmentId?: "
|
|
4738
|
+
},
|
|
4739
|
+
{
|
|
4740
|
+
"kind": "Content",
|
|
4741
|
+
"text": "string"
|
|
4742
|
+
},
|
|
4743
|
+
{
|
|
4744
|
+
"kind": "Content",
|
|
4745
|
+
"text": ";"
|
|
4746
|
+
}
|
|
4747
|
+
],
|
|
4748
|
+
"isReadonly": true,
|
|
4749
|
+
"isOptional": true,
|
|
4750
|
+
"releaseTag": "Public",
|
|
4751
|
+
"name": "fragmentId",
|
|
4752
|
+
"propertyTypeTokenRange": {
|
|
4753
|
+
"startIndex": 1,
|
|
4754
|
+
"endIndex": 2
|
|
4755
|
+
}
|
|
4756
|
+
},
|
|
4656
4757
|
{
|
|
4657
4758
|
"kind": "PropertySignature",
|
|
4658
4759
|
"canonicalReference": "@fgv/ts-agent-memory!IEmbeddedFragment#locator:member",
|
|
4659
|
-
"docComment": "/**\n * The fragment
|
|
4760
|
+
"docComment": "/**\n * The region of the record body this fragment was derived from, when one can be stated honestly. Advisory — see {@link IFragmentLocator}; it is NOT a slice that reproduces the fragment text. Omit it for a fragment with no honest body span (a rewriting segmenter), in which case `fragmentId` must be supplied.\n */\n",
|
|
4660
4761
|
"excerptTokens": [
|
|
4661
4762
|
{
|
|
4662
4763
|
"kind": "Content",
|
|
4663
|
-
"text": "readonly locator
|
|
4764
|
+
"text": "readonly locator?: "
|
|
4664
4765
|
},
|
|
4665
4766
|
{
|
|
4666
4767
|
"kind": "Reference",
|
|
@@ -4673,7 +4774,7 @@
|
|
|
4673
4774
|
}
|
|
4674
4775
|
],
|
|
4675
4776
|
"isReadonly": true,
|
|
4676
|
-
"isOptional":
|
|
4777
|
+
"isOptional": true,
|
|
4677
4778
|
"releaseTag": "Public",
|
|
4678
4779
|
"name": "locator",
|
|
4679
4780
|
"propertyTypeTokenRange": {
|
|
@@ -4684,7 +4785,7 @@
|
|
|
4684
4785
|
{
|
|
4685
4786
|
"kind": "PropertySignature",
|
|
4686
4787
|
"canonicalReference": "@fgv/ts-agent-memory!IEmbeddedFragment#vector:member",
|
|
4687
|
-
"docComment": "/**\n * The embedding vector for
|
|
4788
|
+
"docComment": "/**\n * The embedding vector for this fragment.\n */\n",
|
|
4688
4789
|
"excerptTokens": [
|
|
4689
4790
|
{
|
|
4690
4791
|
"kind": "Content",
|
|
@@ -5251,6 +5352,34 @@
|
|
|
5251
5352
|
"endIndex": 2
|
|
5252
5353
|
}
|
|
5253
5354
|
},
|
|
5355
|
+
{
|
|
5356
|
+
"kind": "PropertySignature",
|
|
5357
|
+
"canonicalReference": "@fgv/ts-agent-memory!IFileTreeMemoryStoreCreateParams#index:member",
|
|
5358
|
+
"docComment": "/**\n * Optional derived-index implementation. Defaults to a fresh {@link MemoryIndex} — omitting this parameter is byte-identical to the store's behavior before the parameter existed. When supplied, the store uses it for EVERY index operation it performs and never holds a second index, so an injected index is the store's only view of its own records:\n *\n * - `rebuild` — once, from the initial vault walk in `create()`. - `patch` — on every persisted write, delete, version invalidation, and cap-cull eviction. - `entries` — behind {@link IMemoryStore.list | list} / {@link IMemoryStore.listScoped | listScoped}, the keyed temporal reads, the write path's content-hash dedup and write-policy admission cohort, AND the temporal (versioned) write and delete paths, which resolve an entity's version history entirely from the index.\n *\n * That last group is the one to weigh before injecting anything other than a pass-through decorator: an index that filters, reorders, or otherwise reshapes `entries()` changes WRITE semantics, not just what reads return. Concretely, on a versioned kind the store derives an entity's whole version history from `entries()` filtered by scope, and that derivation decides which version a `put` treats as current (so what it dedups against and what it merges its patch over), which prior versions it stamps `invalid_at` on, what the admission cohort is, and which versions a `delete` tombstones. An index that hides a version makes it invisible to all of those — the FileTree still holds it, but the store will not supersede, invalidate, or tombstone it. On flat kinds the same reshaping changes what dedups and what a cap-cull policy evicts. A faithful delegating decorator — the intended use below — has no such effect. Note the store's keyed reads ({@link IMemoryStore.get | get} on a flat kind, and {@link IMemoryStore.getById | getById}) go to the FileTree, not the index; the FileTree remains the source of truth and the index stays a derived view.\n *\n * @remarks\n *\n * **This is an instrumentation seam, NOT a resident-memory fix.** The intended use is wrapping the shipped {@link MemoryIndex} in a decorator that counts and times the calls the store makes — resident bytes by kind, open cost against vault size, where the curve actually bends — so a decision about a partial-read redesign can be driven by measurements instead of estimates.\n *\n * It does NOT lower the store's resident-memory ceiling, and injecting a \"persisted\" or \"lazy\" index will not change that. {@link IMemoryIndex}'s read surface returns whole records by construction: `entries()` yields {@link IIndexedMemoryRecord}s and `byKind` / `byTag` / `byRecency` / `byRank` yield `IMemoryRecord<unknown>` — `{ envelope, body }` pairs with the body materialized. Any implementation satisfying the current contract must therefore be able to produce every body on demand. An injected index changes WHERE records come from; it does not change WHETHER bodies are held. Lowering the ceiling requires a partial-read (id-or-envelope-only) redesign of `IMemoryIndex` itself, which is separate, breaking, design-first work and is deliberately not part of this seam.\n */\n",
|
|
5359
|
+
"excerptTokens": [
|
|
5360
|
+
{
|
|
5361
|
+
"kind": "Content",
|
|
5362
|
+
"text": "readonly index?: "
|
|
5363
|
+
},
|
|
5364
|
+
{
|
|
5365
|
+
"kind": "Reference",
|
|
5366
|
+
"text": "IMemoryIndex",
|
|
5367
|
+
"canonicalReference": "@fgv/ts-agent-memory!IMemoryIndex:interface"
|
|
5368
|
+
},
|
|
5369
|
+
{
|
|
5370
|
+
"kind": "Content",
|
|
5371
|
+
"text": ";"
|
|
5372
|
+
}
|
|
5373
|
+
],
|
|
5374
|
+
"isReadonly": true,
|
|
5375
|
+
"isOptional": true,
|
|
5376
|
+
"releaseTag": "Public",
|
|
5377
|
+
"name": "index",
|
|
5378
|
+
"propertyTypeTokenRange": {
|
|
5379
|
+
"startIndex": 1,
|
|
5380
|
+
"endIndex": 2
|
|
5381
|
+
}
|
|
5382
|
+
},
|
|
5254
5383
|
{
|
|
5255
5384
|
"kind": "PropertySignature",
|
|
5256
5385
|
"canonicalReference": "@fgv/ts-agent-memory!IFileTreeMemoryStoreCreateParams#logger:member",
|
|
@@ -5583,7 +5712,7 @@
|
|
|
5583
5712
|
{
|
|
5584
5713
|
"kind": "Interface",
|
|
5585
5714
|
"canonicalReference": "@fgv/ts-agent-memory!IFragmentLocator:interface",
|
|
5586
|
-
"docComment": "/**\n * A half-open `[start, end)` span into a record's body — the in-record locator a {@link IFragmentVectorIndex}
|
|
5715
|
+
"docComment": "/**\n * A half-open `[start, end)` span into a record's body — the in-record locator a {@link IFragmentVectorIndex} may carry on a fragment. `start` is inclusive, `end` exclusive. The unit (character / byte / token offsets) is the consumer's choice: the index stores the two integers opaquely and never interprets them, so they line up with whatever locator the consumer's own read side uses.\n *\n * @remarks\n *\n * **The span is advisory.** It names the region of the body a fragment was *derived from*; it is NOT a slice guaranteed to reproduce the fragment's text. `body.slice(start, end)` round-trips only under a segmenter that merely chooses boundaries. Under a **rewriting** segmenter — one that turns a span into a curated block, an increasingly common ingestion shape when a model both selects and rewrites — the fragment text is not a substring of the body at all, and the fragmentation is not re-derivable from the body. Treat the span as a pointer for locating context, never as an extraction recipe.\n *\n * A fragment whose provenance cannot honestly be expressed as a body span should omit the locator entirely and carry an {@link IEmbeddedFragment.fragmentId} instead.\n *\n * @public\n */\n",
|
|
5587
5716
|
"excerptTokens": [
|
|
5588
5717
|
{
|
|
5589
5718
|
"kind": "Content",
|
|
@@ -5873,7 +6002,7 @@
|
|
|
5873
6002
|
{
|
|
5874
6003
|
"kind": "Interface",
|
|
5875
6004
|
"canonicalReference": "@fgv/ts-agent-memory!IFragmentVectorIndex:interface",
|
|
5876
|
-
"docComment": "/**\n * The fragment-granular sibling of {@link IVectorIndex}: instead of one vector per record it holds many vectors per record, each tagged with
|
|
6005
|
+
"docComment": "/**\n * The fragment-granular sibling of {@link IVectorIndex}: instead of one vector per record it holds many vectors per record, each tagged with the identity its {@link IEmbeddedFragment} carried, and its `query` returns per-fragment hits carrying that identity back. This is the seam behind sub-document semantic search — the \"discovery\" half of a search-then-read contract, where a hit tells the consumer which record AND which fragment of it to read.\n *\n * @remarks\n *\n * Deliberately NOT `extends IVectorIndex`: an index holding many vectors per record has no well-defined single-vector `add(target, vector)`. It is a parallel contract with three operations — `addFragments`, `remove`, `query` — reusing {@link IVectorQueryHit}, on which both `locator` and `fragmentId` are optional. A fragment hit populates whichever of the two its stored fragment carried; see {@link IVectorQueryHit} for why that is not a discriminator and why fragment-ness is determined by the index queried, not by field presence. Kept distinct from the record-granular index per the consumer contract: memory recall stays record-granular; sub-document knowledge uses a separate fragment index.\n *\n * @public\n */\n",
|
|
5877
6006
|
"excerptTokens": [
|
|
5878
6007
|
{
|
|
5879
6008
|
"kind": "Content",
|
|
@@ -5978,7 +6107,7 @@
|
|
|
5978
6107
|
{
|
|
5979
6108
|
"kind": "MethodSignature",
|
|
5980
6109
|
"canonicalReference": "@fgv/ts-agent-memory!IFragmentVectorIndex#query:member(1)",
|
|
5981
|
-
"docComment": "/**\n * Return the `topK` nearest fragments to `vector`, in descending score order, each hit carrying its record `target`
|
|
6110
|
+
"docComment": "/**\n * Return the `topK` nearest fragments to `vector`, in descending score order, each hit carrying its record `target` plus whichever of `locator` / `fragmentId` the stored fragment was added with. When `maxPerRecord` is supplied, no more than that many fragments of any single record appear in the result — the cap is applied during selection (before the `topK` cut) so one long document cannot crowd out others.\n */\n",
|
|
5982
6111
|
"excerptTokens": [
|
|
5983
6112
|
{
|
|
5984
6113
|
"kind": "Content",
|
|
@@ -7050,7 +7179,7 @@
|
|
|
7050
7179
|
{
|
|
7051
7180
|
"kind": "PropertySignature",
|
|
7052
7181
|
"canonicalReference": "@fgv/ts-agent-memory!IMemoryCapCullPolicyParams#mutableFields:member",
|
|
7053
|
-
"docComment": "/**\n * The fields a merge-patch update may touch (drawn from the record-level mutable vocabulary: `body` / `tags` / `links` / `provenance` / `embeddingRef`). Fields outside this list are immutable.\n */\n",
|
|
7182
|
+
"docComment": "/**\n * The fields a merge-patch update may touch (drawn from the record-level mutable vocabulary: `body` / `tags` / `links` / `provenance` / `embeddingRef`). Fields outside this list are immutable.\n *\n * @remarks\n *\n * This list — unlike {@link KnowledgeLwwPolicy}'s pinned surface — is caller-supplied, so it is what decides which fields get the RFC-7386 guarantees documented on {@link IWritePolicy.applyUpdate}. Declare `provenance` here to get per-key provenance merging and `null` sub-key clearing; omit it and every provenance patch key is inert (dropped before the merge, so the existing value is preserved verbatim and even a whole-block `null` is a silent no-op rather than an error).\n */\n",
|
|
7054
7183
|
"excerptTokens": [
|
|
7055
7184
|
{
|
|
7056
7185
|
"kind": "Content",
|
|
@@ -11962,7 +12091,7 @@
|
|
|
11962
12091
|
{
|
|
11963
12092
|
"kind": "Class",
|
|
11964
12093
|
"canonicalReference": "@fgv/ts-agent-memory!InMemoryFragmentCosineIndex:class",
|
|
11965
|
-
"docComment": "/**\n * The brute-force, in-memory cosine {@link IFragmentVectorIndex} — the fragment-granular sibling of {@link InMemoryCosineIndex}. Stores many `Float32Array`s per record (one per
|
|
12094
|
+
"docComment": "/**\n * The brute-force, in-memory cosine {@link IFragmentVectorIndex} — the fragment-granular sibling of {@link InMemoryCosineIndex}. Stores many `Float32Array`s per record (one per {@link IEmbeddedFragment | fragment}) and answers a query by computing cosine similarity against every stored fragment, returning the top-k fragment hits by descending score. Each hit carries back whichever of {@link IFragmentLocator | locator} / `fragmentId` its fragment was added with; a fragment must carry at least one of the two.\n *\n * @remarks\n *\n * Same regime and same non-goals as {@link InMemoryCosineIndex}: no external dependency, no ANN structure, a linear scan over the stored fragments — the seam ({@link IFragmentVectorIndex}) stays open for a consumer to swap a persistent / ANN backend once N grows. `addFragments` is whole-record-replace, so re-authoring a document never leaves stale fragments behind. The index has a single dimension established by the first fragment added; every subsequent fragment and every `query` vector must match it or fail loudly — a mismatched dimension is an embedder-wiring bug, never a silent zero-similarity result. {@link InMemoryFragmentCosineIndex.rebuild | rebuild} clears the index (and the established dimension), so a re-embed with a different model is supported.\n *\n * The optional `maxPerRecord` cap on `query` is applied **during selection**, before the `topK` cut, so one long document with many strong fragments cannot crowd every other record out of the result.\n *\n * @public\n */\n",
|
|
11966
12095
|
"excerptTokens": [
|
|
11967
12096
|
{
|
|
11968
12097
|
"kind": "Content",
|
|
@@ -12155,7 +12284,7 @@
|
|
|
12155
12284
|
{
|
|
12156
12285
|
"kind": "Method",
|
|
12157
12286
|
"canonicalReference": "@fgv/ts-agent-memory!InMemoryFragmentCosineIndex#query:member(1)",
|
|
12158
|
-
"docComment": "/**\n * Return the `topK` nearest fragments to `vector`, in descending score order, each hit carrying its record `target`
|
|
12287
|
+
"docComment": "/**\n * Return the `topK` nearest fragments to `vector`, in descending score order, each hit carrying its record `target` plus whichever of `locator` / `fragmentId` the stored fragment was added with. When `maxPerRecord` is supplied, no more than that many fragments of any single record appear in the result — the cap is applied during selection (before the `topK` cut) so one long document cannot crowd out others.\n */\n",
|
|
12159
12288
|
"excerptTokens": [
|
|
12160
12289
|
{
|
|
12161
12290
|
"kind": "Content",
|
|
@@ -14040,7 +14169,7 @@
|
|
|
14040
14169
|
{
|
|
14041
14170
|
"kind": "Interface",
|
|
14042
14171
|
"canonicalReference": "@fgv/ts-agent-memory!IVectorQueryHit:interface",
|
|
14043
|
-
"docComment": "/**\n * A single hit returned by {@link IVectorIndex.query} (or {@link IFragmentVectorIndex.query}): the matched record's scope-qualified {@link IEdgeTarget | address} and the backend's similarity score (higher = more similar; the exact scale is backend-defined). Hits are returned in descending score order.\n *\n * @remarks\n *\n * The address is a `(scope, id)` pair, NOT a bare {@link MemoryId} — per-scope codecs (e.g. the medium-term codec's `turn-<n>` stems) legally mint the same stem under different scopes, so a bare id could not disambiguate two records that share a stem. The caller re-resolves the hit against the record index by the same scoped address.\n *\n * `locator`
|
|
14172
|
+
"docComment": "/**\n * A single hit returned by {@link IVectorIndex.query} (or {@link IFragmentVectorIndex.query}): the matched record's scope-qualified {@link IEdgeTarget | address} and the backend's similarity score (higher = more similar; the exact scale is backend-defined). Hits are returned in descending score order.\n *\n * @remarks\n *\n * The address is a `(scope, id)` pair, NOT a bare {@link MemoryId} — per-scope codecs (e.g. the medium-term codec's `turn-<n>` stems) legally mint the same stem under different scopes, so a bare id could not disambiguate two records that share a stem. The caller re-resolves the hit against the record index by the same scoped address.\n *\n * **No single field discriminates a fragment hit from a record-granular hit.** A record hit carries neither `locator` nor `fragmentId`; a fragment hit carries at least one of the two, but not necessarily any particular one — a fragment with a body span but no consumer-minted id, and a fragment with an id but no honest span, are both legal. Testing one field for presence therefore cannot tell you which kind of hit you hold.\n *\n * That \"at least one\" requirement is enforced on the upsert side by {@link embeddedFragmentConverter} — a different boundary from this type — and is deliberately NOT offered here as a discriminator either. A caller keyed off it would be coupled to an invariant this type does not own, and would fail silently if the invariant were ever relaxed.\n *\n * **The robust rule is that fragment-ness is determined by which index produced the hit**: {@link IFragmentVectorIndex.query} returns fragment hits and {@link IVectorIndex.query} returns record hits. The caller chose the index it queried, so it already knows which kind it is holding.\n *\n * Note in particular that an absent `locator` now carries **two** distinct meanings — a record-granular hit, or a fragment with no honest body span (see {@link IFragmentLocator}) — which is precisely why presence-branching is unsafe.\n *\n * @public\n */\n",
|
|
14044
14173
|
"excerptTokens": [
|
|
14045
14174
|
{
|
|
14046
14175
|
"kind": "Content",
|
|
@@ -14052,10 +14181,37 @@
|
|
|
14052
14181
|
"name": "IVectorQueryHit",
|
|
14053
14182
|
"preserveMemberOrder": false,
|
|
14054
14183
|
"members": [
|
|
14184
|
+
{
|
|
14185
|
+
"kind": "PropertySignature",
|
|
14186
|
+
"canonicalReference": "@fgv/ts-agent-memory!IVectorQueryHit#fragmentId:member",
|
|
14187
|
+
"docComment": "/**\n * The opaque identity the producing fragment was stored with, carried back verbatim. Absent on record-granular hits AND on fragment hits stored without one — see the remarks above; do not branch on its presence.\n */\n",
|
|
14188
|
+
"excerptTokens": [
|
|
14189
|
+
{
|
|
14190
|
+
"kind": "Content",
|
|
14191
|
+
"text": "readonly fragmentId?: "
|
|
14192
|
+
},
|
|
14193
|
+
{
|
|
14194
|
+
"kind": "Content",
|
|
14195
|
+
"text": "string"
|
|
14196
|
+
},
|
|
14197
|
+
{
|
|
14198
|
+
"kind": "Content",
|
|
14199
|
+
"text": ";"
|
|
14200
|
+
}
|
|
14201
|
+
],
|
|
14202
|
+
"isReadonly": true,
|
|
14203
|
+
"isOptional": true,
|
|
14204
|
+
"releaseTag": "Public",
|
|
14205
|
+
"name": "fragmentId",
|
|
14206
|
+
"propertyTypeTokenRange": {
|
|
14207
|
+
"startIndex": 1,
|
|
14208
|
+
"endIndex": 2
|
|
14209
|
+
}
|
|
14210
|
+
},
|
|
14055
14211
|
{
|
|
14056
14212
|
"kind": "PropertySignature",
|
|
14057
14213
|
"canonicalReference": "@fgv/ts-agent-memory!IVectorQueryHit#locator:member",
|
|
14058
|
-
"docComment": "/**\n * The
|
|
14214
|
+
"docComment": "/**\n * The advisory in-record span the matched fragment was derived from, when the producing fragment carried one. Absent on record-granular hits AND on fragment hits with no honest span — see the remarks above; do not branch on its presence.\n */\n",
|
|
14059
14215
|
"excerptTokens": [
|
|
14060
14216
|
{
|
|
14061
14217
|
"kind": "Content",
|
|
@@ -14250,7 +14406,7 @@
|
|
|
14250
14406
|
{
|
|
14251
14407
|
"kind": "MethodSignature",
|
|
14252
14408
|
"canonicalReference": "@fgv/ts-agent-memory!IWritePolicy#applyUpdate:member(1)",
|
|
14253
|
-
"docComment": "/**\n * Apply a JSON Merge Patch (RFC-7386) to the mutable fields of an existing record. Called when admission is `accept` AND a record with the same `entityId` already exists (an update, not a first write).\n *\n * @param existing - The current persisted record.\n *\n * @param patch - A partial JSON object in Merge Patch format. `null` deletes the corresponding key; arrays replace wholesale; nested objects deep-merge. Only keys in {@link IWritePolicy.mutableFields} are applied.\n *\n * @returns The updated record (envelope + body).\n */\n",
|
|
14409
|
+
"docComment": "/**\n * Apply a JSON Merge Patch (RFC-7386) to the mutable fields of an existing record. Called when admission is `accept` AND a record with the same `entityId` already exists (an update, not a first write).\n *\n * @remarks\n *\n * **RFC-7386 semantics are the contract here, not an artifact of the shipped policies' merge configuration.** Implementations are expected to honor them, and consumers may rely on them:\n *\n * - **Objects merge per key.** A supplied key overwrites; an omitted key is PRESERVED, not dropped. Patching one key of a nested object (e.g. one field of `provenance`) leaves its siblings intact. - **An explicit `null` on a sub-key clears exactly that sub-key.** This is the sanctioned way to remove a single key from a nested object. - **Arrays replace wholesale** — `tags` / `links` are never element-merged. - **A whole-block `null` that would delete a REQUIRED field is rejected loudly** (`Result.fail`), never silently accepted. `body` / `tags` / `links` / `provenance` are required; `embeddingRef` is optional and a `null` restores it to absent (NOT to `null`), so it stays hash-stable.\n *\n * Which fields these guarantees cover is **policy-dependent**: they apply to the fields the policy declares in {@link IWritePolicy.mutableFields}, and a field outside that list is inert — its patch key is dropped before the merge, so a `null` on it neither clears the value nor raises an error.\n *\n * @param existing - The current persisted record.\n *\n * @param patch - A partial JSON object in Merge Patch format. `null` deletes the corresponding key; arrays replace wholesale; nested objects deep-merge. Only keys in {@link IWritePolicy.mutableFields} are applied.\n *\n * @returns The updated record (envelope + body).\n */\n",
|
|
14254
14410
|
"excerptTokens": [
|
|
14255
14411
|
{
|
|
14256
14412
|
"kind": "Content",
|
|
@@ -14766,7 +14922,7 @@
|
|
|
14766
14922
|
{
|
|
14767
14923
|
"kind": "Class",
|
|
14768
14924
|
"canonicalReference": "@fgv/ts-agent-memory!KnowledgeLwwPolicy:class",
|
|
14769
|
-
"docComment": "/**\n * Last-write-wins write policy for the knowledge kind family. Admission always accepts (no cap, no cull); updates apply an RFC-7386 merge patch restricted to the knowledge mutable surface.\n *\n * @remarks\n *\n * **Merge-surface pin (resolves design-lock §5.3's body-vs-envelope muddle).** The declared `mutableFields` span both axes of a record: `body` is the per-kind body, while `tags` / `links` / `provenance` / `embeddingRef` live on the {@link IMemoryEnvelope}. `applyUpdate` projects exactly those fields — each read from its canonical location — into a single record-level JSON view, runs the merge over that view, then rebuilds a coherent record. The identity and transaction-time envelope fields (`id`, `entityId`, `kind`, `created`, `updated`, `seq`, `contentHash`) are NOT mutable and are preserved verbatim; the store stamps `updated` / `seq` on write.\n *\n * @public\n */\n",
|
|
14925
|
+
"docComment": "/**\n * Last-write-wins write policy for the knowledge kind family. Admission always accepts (no cap, no cull); updates apply an RFC-7386 merge patch restricted to the knowledge mutable surface.\n *\n * @remarks\n *\n * **Merge-surface pin (resolves design-lock §5.3's body-vs-envelope muddle).** The declared `mutableFields` span both axes of a record: `body` is the per-kind body, while `tags` / `links` / `provenance` / `embeddingRef` live on the {@link IMemoryEnvelope}. `applyUpdate` projects exactly those fields — each read from its canonical location — into a single record-level JSON view, runs the merge over that view, then rebuilds a coherent record. The identity and transaction-time envelope fields (`id`, `entityId`, `kind`, `created`, `updated`, `seq`, `contentHash`) are NOT mutable and are preserved verbatim; the store stamps `updated` / `seq` / `contentHash` on write.\n *\n * Because the surface is pinned rather than caller-supplied, the RFC-7386 guarantees documented on {@link IWritePolicy.applyUpdate} apply to every field listed above — in particular to `provenance`, whose keys merge individually, a `null` on any one of which clears that key alone, and a `null` on the whole block of which is rejected loudly (it is a required field). Consumers may depend on this; it is covered by tests.\n *\n * @public\n */\n",
|
|
14770
14926
|
"excerptTokens": [
|
|
14771
14927
|
{
|
|
14772
14928
|
"kind": "Content",
|
|
@@ -14888,7 +15044,7 @@
|
|
|
14888
15044
|
{
|
|
14889
15045
|
"kind": "Method",
|
|
14890
15046
|
"canonicalReference": "@fgv/ts-agent-memory!KnowledgeLwwPolicy#applyUpdate:member(1)",
|
|
14891
|
-
"docComment": "/**\n * Apply a JSON Merge Patch (RFC-7386) to the mutable fields of an existing record. Called when admission is `accept` AND a record with the same `entityId` already exists (an update, not a first write).\n *\n * @param existing - The current persisted record.\n *\n * @param patch - A partial JSON object in Merge Patch format. `null` deletes the corresponding key; arrays replace wholesale; nested objects deep-merge. Only keys in {@link IWritePolicy.mutableFields} are applied.\n *\n * @returns The updated record (envelope + body).\n */\n",
|
|
15047
|
+
"docComment": "/**\n * Apply a JSON Merge Patch (RFC-7386) to the mutable fields of an existing record. Called when admission is `accept` AND a record with the same `entityId` already exists (an update, not a first write).\n *\n * @remarks\n *\n * **RFC-7386 semantics are the contract here, not an artifact of the shipped policies' merge configuration.** Implementations are expected to honor them, and consumers may rely on them:\n *\n * - **Objects merge per key.** A supplied key overwrites; an omitted key is PRESERVED, not dropped. Patching one key of a nested object (e.g. one field of `provenance`) leaves its siblings intact. - **An explicit `null` on a sub-key clears exactly that sub-key.** This is the sanctioned way to remove a single key from a nested object. - **Arrays replace wholesale** — `tags` / `links` are never element-merged. - **A whole-block `null` that would delete a REQUIRED field is rejected loudly** (`Result.fail`), never silently accepted. `body` / `tags` / `links` / `provenance` are required; `embeddingRef` is optional and a `null` restores it to absent (NOT to `null`), so it stays hash-stable.\n *\n * Which fields these guarantees cover is **policy-dependent**: they apply to the fields the policy declares in {@link IWritePolicy.mutableFields}, and a field outside that list is inert — its patch key is dropped before the merge, so a `null` on it neither clears the value nor raises an error.\n *\n * @param existing - The current persisted record.\n *\n * @param patch - A partial JSON object in Merge Patch format. `null` deletes the corresponding key; arrays replace wholesale; nested objects deep-merge. Only keys in {@link IWritePolicy.mutableFields} are applied.\n *\n * @returns The updated record (envelope + body).\n */\n",
|
|
14892
15048
|
"excerptTokens": [
|
|
14893
15049
|
{
|
|
14894
15050
|
"kind": "Content",
|
|
@@ -15052,7 +15208,7 @@
|
|
|
15052
15208
|
{
|
|
15053
15209
|
"kind": "Property",
|
|
15054
15210
|
"canonicalReference": "@fgv/ts-agent-memory!KnowledgeLwwPolicy#mutableFields:member",
|
|
15055
|
-
"docComment": "/**\n * The knowledge mutable surface: the body plus the envelope metadata a consumer may revise without minting a new entity.\n */\n",
|
|
15211
|
+
"docComment": "/**\n * The knowledge mutable surface: the body plus the envelope metadata a consumer may revise without minting a new entity. Pinned, not caller-supplied — see the class remarks for what that guarantees.\n */\n",
|
|
15056
15212
|
"excerptTokens": [
|
|
15057
15213
|
{
|
|
15058
15214
|
"kind": "Content",
|
|
@@ -15883,7 +16039,7 @@
|
|
|
15883
16039
|
{
|
|
15884
16040
|
"kind": "Method",
|
|
15885
16041
|
"canonicalReference": "@fgv/ts-agent-memory!MemoryCapCullPolicy#applyUpdate:member(1)",
|
|
15886
|
-
"docComment": "/**\n * Apply a JSON Merge Patch (RFC-7386) to the mutable fields of an existing record. Called when admission is `accept` AND a record with the same `entityId` already exists (an update, not a first write).\n *\n * @param existing - The current persisted record.\n *\n * @param patch - A partial JSON object in Merge Patch format. `null` deletes the corresponding key; arrays replace wholesale; nested objects deep-merge. Only keys in {@link IWritePolicy.mutableFields} are applied.\n *\n * @returns The updated record (envelope + body).\n */\n",
|
|
16042
|
+
"docComment": "/**\n * Apply a JSON Merge Patch (RFC-7386) to the mutable fields of an existing record. Called when admission is `accept` AND a record with the same `entityId` already exists (an update, not a first write).\n *\n * @remarks\n *\n * **RFC-7386 semantics are the contract here, not an artifact of the shipped policies' merge configuration.** Implementations are expected to honor them, and consumers may rely on them:\n *\n * - **Objects merge per key.** A supplied key overwrites; an omitted key is PRESERVED, not dropped. Patching one key of a nested object (e.g. one field of `provenance`) leaves its siblings intact. - **An explicit `null` on a sub-key clears exactly that sub-key.** This is the sanctioned way to remove a single key from a nested object. - **Arrays replace wholesale** — `tags` / `links` are never element-merged. - **A whole-block `null` that would delete a REQUIRED field is rejected loudly** (`Result.fail`), never silently accepted. `body` / `tags` / `links` / `provenance` are required; `embeddingRef` is optional and a `null` restores it to absent (NOT to `null`), so it stays hash-stable.\n *\n * Which fields these guarantees cover is **policy-dependent**: they apply to the fields the policy declares in {@link IWritePolicy.mutableFields}, and a field outside that list is inert — its patch key is dropped before the merge, so a `null` on it neither clears the value nor raises an error.\n *\n * @param existing - The current persisted record.\n *\n * @param patch - A partial JSON object in Merge Patch format. `null` deletes the corresponding key; arrays replace wholesale; nested objects deep-merge. Only keys in {@link IWritePolicy.mutableFields} are applied.\n *\n * @returns The updated record (envelope + body).\n */\n",
|
|
15887
16043
|
"excerptTokens": [
|
|
15888
16044
|
{
|
|
15889
16045
|
"kind": "Content",
|
|
@@ -20567,7 +20723,7 @@
|
|
|
20567
20723
|
{
|
|
20568
20724
|
"kind": "Method",
|
|
20569
20725
|
"canonicalReference": "@fgv/ts-agent-memory!TemporalVersionedPolicy#applyUpdate:member(1)",
|
|
20570
|
-
"docComment": "/**\n * Apply a JSON Merge Patch (RFC-7386) to the mutable fields of an existing record. Called when admission is `accept` AND a record with the same `entityId` already exists (an update, not a first write).\n *\n * @param existing - The current persisted record.\n *\n * @param patch - A partial JSON object in Merge Patch format. `null` deletes the corresponding key; arrays replace wholesale; nested objects deep-merge. Only keys in {@link IWritePolicy.mutableFields} are applied.\n *\n * @returns The updated record (envelope + body).\n */\n",
|
|
20726
|
+
"docComment": "/**\n * Apply a JSON Merge Patch (RFC-7386) to the mutable fields of an existing record. Called when admission is `accept` AND a record with the same `entityId` already exists (an update, not a first write).\n *\n * @remarks\n *\n * **RFC-7386 semantics are the contract here, not an artifact of the shipped policies' merge configuration.** Implementations are expected to honor them, and consumers may rely on them:\n *\n * - **Objects merge per key.** A supplied key overwrites; an omitted key is PRESERVED, not dropped. Patching one key of a nested object (e.g. one field of `provenance`) leaves its siblings intact. - **An explicit `null` on a sub-key clears exactly that sub-key.** This is the sanctioned way to remove a single key from a nested object. - **Arrays replace wholesale** — `tags` / `links` are never element-merged. - **A whole-block `null` that would delete a REQUIRED field is rejected loudly** (`Result.fail`), never silently accepted. `body` / `tags` / `links` / `provenance` are required; `embeddingRef` is optional and a `null` restores it to absent (NOT to `null`), so it stays hash-stable.\n *\n * Which fields these guarantees cover is **policy-dependent**: they apply to the fields the policy declares in {@link IWritePolicy.mutableFields}, and a field outside that list is inert — its patch key is dropped before the merge, so a `null` on it neither clears the value nor raises an error.\n *\n * @param existing - The current persisted record.\n *\n * @param patch - A partial JSON object in Merge Patch format. `null` deletes the corresponding key; arrays replace wholesale; nested objects deep-merge. Only keys in {@link IWritePolicy.mutableFields} are applied.\n *\n * @returns The updated record (envelope + body).\n */\n",
|
|
20571
20727
|
"excerptTokens": [
|
|
20572
20728
|
{
|
|
20573
20729
|
"kind": "Content",
|
|
@@ -102,6 +102,9 @@ export const edgeTargetConverter: Converter<IEdgeTarget>;
|
|
|
102
102
|
// @public
|
|
103
103
|
export function edgeTargetKey(target: IEdgeTarget): string;
|
|
104
104
|
|
|
105
|
+
// @public
|
|
106
|
+
export const embeddedFragmentConverter: Converter<IEmbeddedFragment>;
|
|
107
|
+
|
|
105
108
|
// @public
|
|
106
109
|
export type EntityId = Brand<string, 'EntityId'>;
|
|
107
110
|
|
|
@@ -130,6 +133,9 @@ export const FRAGMENT_SEMANTIC_UNWIRED_MESSAGE: string;
|
|
|
130
133
|
// @public
|
|
131
134
|
export type FragmentEmbedder = (record: IMemoryRecord<unknown>) => Promise<Result<ReadonlyArray<IEmbeddedFragment>>>;
|
|
132
135
|
|
|
136
|
+
// @public
|
|
137
|
+
export const fragmentLocatorConverter: Converter<IFragmentLocator>;
|
|
138
|
+
|
|
133
139
|
// @public
|
|
134
140
|
export class FragmentSemanticRetriever {
|
|
135
141
|
get capabilities(): IFragmentRetrieverCapabilities;
|
|
@@ -221,7 +227,8 @@ export interface IEdgeTarget {
|
|
|
221
227
|
|
|
222
228
|
// @public
|
|
223
229
|
export interface IEmbeddedFragment {
|
|
224
|
-
readonly
|
|
230
|
+
readonly fragmentId?: string;
|
|
231
|
+
readonly locator?: IFragmentLocator;
|
|
225
232
|
readonly vector: Float32Array;
|
|
226
233
|
}
|
|
227
234
|
|
|
@@ -250,6 +257,7 @@ export interface IFileTreeMemoryStoreCreateParams {
|
|
|
250
257
|
readonly embed?: MemoryEmbedder;
|
|
251
258
|
readonly fragmentEmbedder?: FragmentEmbedder;
|
|
252
259
|
readonly fragmentIndex?: IFragmentVectorIndex;
|
|
260
|
+
readonly index?: IMemoryIndex;
|
|
253
261
|
readonly logger?: Logging.ILogger;
|
|
254
262
|
readonly observers?: ReadonlyArray<IMemoryObserver>;
|
|
255
263
|
readonly onRecordError?: MemoryRecordErrorMode;
|
|
@@ -653,6 +661,7 @@ export interface IVectorIndex {
|
|
|
653
661
|
|
|
654
662
|
// @public
|
|
655
663
|
export interface IVectorQueryHit {
|
|
664
|
+
readonly fragmentId?: string;
|
|
656
665
|
readonly locator?: IFragmentLocator;
|
|
657
666
|
readonly score: number;
|
|
658
667
|
readonly target: IEdgeTarget;
|