@functional-systems/memdrive 0.0.0-stage → 0.1.0-dev.5

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.
Files changed (97) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSE +201 -0
  3. package/README.md +229 -2
  4. package/dist/commonjs/chunking.d.ts +7 -0
  5. package/dist/commonjs/chunking.d.ts.map +1 -0
  6. package/dist/commonjs/chunking.js +46 -0
  7. package/dist/commonjs/chunking.js.map +1 -0
  8. package/dist/commonjs/errors.d.ts +17 -0
  9. package/dist/commonjs/errors.d.ts.map +1 -0
  10. package/dist/commonjs/errors.js +44 -0
  11. package/dist/commonjs/errors.js.map +1 -0
  12. package/dist/commonjs/filter.d.ts +30 -0
  13. package/dist/commonjs/filter.d.ts.map +1 -0
  14. package/dist/commonjs/filter.js +224 -0
  15. package/dist/commonjs/filter.js.map +1 -0
  16. package/dist/commonjs/index.d.ts +8 -0
  17. package/dist/commonjs/index.d.ts.map +1 -0
  18. package/dist/commonjs/index.js +343 -0
  19. package/dist/commonjs/index.js.map +1 -0
  20. package/dist/commonjs/package.json +3 -0
  21. package/dist/commonjs/storage.d.ts +274 -0
  22. package/dist/commonjs/storage.d.ts.map +1 -0
  23. package/dist/commonjs/storage.js +861 -0
  24. package/dist/commonjs/storage.js.map +1 -0
  25. package/dist/commonjs/tools/definitions.d.ts +5 -0
  26. package/dist/commonjs/tools/definitions.d.ts.map +1 -0
  27. package/dist/commonjs/tools/definitions.js +129 -0
  28. package/dist/commonjs/tools/definitions.js.map +1 -0
  29. package/dist/commonjs/tools/index.d.ts +6 -0
  30. package/dist/commonjs/tools/index.d.ts.map +1 -0
  31. package/dist/commonjs/tools/index.js +104 -0
  32. package/dist/commonjs/tools/index.js.map +1 -0
  33. package/dist/commonjs/tools/types.d.ts +50 -0
  34. package/dist/commonjs/tools/types.d.ts.map +1 -0
  35. package/dist/commonjs/tools/types.js +3 -0
  36. package/dist/commonjs/tools/types.js.map +1 -0
  37. package/dist/commonjs/types.d.ts +277 -0
  38. package/dist/commonjs/types.d.ts.map +1 -0
  39. package/dist/commonjs/types.js +3 -0
  40. package/dist/commonjs/types.js.map +1 -0
  41. package/dist/commonjs/values.d.ts +17 -0
  42. package/dist/commonjs/values.d.ts.map +1 -0
  43. package/dist/commonjs/values.js +90 -0
  44. package/dist/commonjs/values.js.map +1 -0
  45. package/dist/esm/chunking.d.ts +7 -0
  46. package/dist/esm/chunking.d.ts.map +1 -0
  47. package/dist/esm/chunking.js +42 -0
  48. package/dist/esm/chunking.js.map +1 -0
  49. package/dist/esm/errors.d.ts +17 -0
  50. package/dist/esm/errors.d.ts.map +1 -0
  51. package/dist/esm/errors.js +36 -0
  52. package/dist/esm/errors.js.map +1 -0
  53. package/dist/esm/filter.d.ts +30 -0
  54. package/dist/esm/filter.d.ts.map +1 -0
  55. package/dist/esm/filter.js +209 -0
  56. package/dist/esm/filter.js.map +1 -0
  57. package/dist/esm/index.d.ts +8 -0
  58. package/dist/esm/index.d.ts.map +1 -0
  59. package/dist/esm/index.js +335 -0
  60. package/dist/esm/index.js.map +1 -0
  61. package/dist/esm/package.json +3 -0
  62. package/dist/esm/storage.d.ts +274 -0
  63. package/dist/esm/storage.d.ts.map +1 -0
  64. package/dist/esm/storage.js +845 -0
  65. package/dist/esm/storage.js.map +1 -0
  66. package/dist/esm/tools/definitions.d.ts +5 -0
  67. package/dist/esm/tools/definitions.d.ts.map +1 -0
  68. package/dist/esm/tools/definitions.js +126 -0
  69. package/dist/esm/tools/definitions.js.map +1 -0
  70. package/dist/esm/tools/index.d.ts +6 -0
  71. package/dist/esm/tools/index.d.ts.map +1 -0
  72. package/dist/esm/tools/index.js +101 -0
  73. package/dist/esm/tools/index.js.map +1 -0
  74. package/dist/esm/tools/types.d.ts +50 -0
  75. package/dist/esm/tools/types.d.ts.map +1 -0
  76. package/dist/esm/tools/types.js +2 -0
  77. package/dist/esm/tools/types.js.map +1 -0
  78. package/dist/esm/types.d.ts +277 -0
  79. package/dist/esm/types.d.ts.map +1 -0
  80. package/dist/esm/types.js +2 -0
  81. package/dist/esm/types.js.map +1 -0
  82. package/dist/esm/values.d.ts +17 -0
  83. package/dist/esm/values.d.ts.map +1 -0
  84. package/dist/esm/values.js +87 -0
  85. package/dist/esm/values.js.map +1 -0
  86. package/docs/tools.md +163 -0
  87. package/package.json +100 -4
  88. package/src/chunking.ts +32 -0
  89. package/src/errors.ts +40 -0
  90. package/src/filter.ts +189 -0
  91. package/src/index.ts +323 -0
  92. package/src/storage.ts +765 -0
  93. package/src/tools/definitions.ts +156 -0
  94. package/src/tools/index.ts +97 -0
  95. package/src/tools/types.ts +45 -0
  96. package/src/types.ts +273 -0
  97. package/src/values.ts +103 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 — Unreleased
4
+
5
+ - Extract the MemDrive prototype into a standalone TypeScript SDK backed by LambdaDB 0.12.0.
6
+ - Preserve memory storage, retrieval, source reading, filtering, schema inspection, batch operations and branches.
7
+ - Add ESM, CommonJS and TypeScript distribution checks with a browser-compatible runtime boundary.
8
+ - Establish main-branch development and release conventions. Development publication uses an explicitly dispatched, validated npm `dev` workflow.
9
+ - Remove internal agent orchestration and retrieval modes; callers own repeated searches and evidence selection.
10
+ - Expose branch-aware keyword distributions through `countValues`; retain `describe` as the sole schema inspection API.
11
+ - Add portable memory tools with JSON Schema contracts, effect annotations, branch binding and optional writes under the `tools` export.
12
+ - Add bounded live integration checks, exact-tarball validation and source-linked immutable development versions.
13
+ - Supply the required Bayesian candidate budget when hybrid recall disables reranking.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,230 @@
1
- # Temporary Holding Version
1
+ # MemDrive
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ TypeScript memory SDK backed by LambdaDB. Store original memories, retrieve
4
+ relevant evidence, inspect metadata distributions, and read complete originals.
5
+ Applications and their agents own query planning, repeated searches, evidence
6
+ selection, answer generation and presentation. The SDK accepts an initialized
7
+ LambdaDB client; the caller owns connection credentials and transport.
8
+
9
+ The package is `@functional-systems/memdrive`, licensed under Apache-2.0.
10
+ It builds ESM and CommonJS with TypeScript declarations and supports Node.js
11
+ 20.12+ and browser bundlers. Development packages use the explicit `dev` channel:
12
+
13
+ ```sh
14
+ npm install @functional-systems/memdrive@dev
15
+ ```
16
+
17
+ Development builds may change before a stable release; pin an exact version for
18
+ reproducibility. To build locally, run `npm ci`, `npm run build`, and `npm pack`,
19
+ then install the resulting tarball in the consumer project. See [CONTRIBUTING.md](CONTRIBUTING.md) for development and
20
+ [RELEASING.md](RELEASING.md) for the release policy.
21
+
22
+ ```ts
23
+ import { LambdaDBClient } from '@functional-systems/lambdadb';
24
+ import { create } from '@functional-systems/memdrive';
25
+
26
+ const client = new LambdaDBClient({
27
+ baseUrl: 'https://your-lambdadb-endpoint',
28
+ projectName: 'your-project',
29
+ projectApiKey: 'your-project-api-key',
30
+ });
31
+
32
+ const drive = await create({
33
+ client, name: 'story_memory',
34
+ description: 'Conversation memories for the example application',
35
+ metadataSchema: {
36
+ role: { type: 'string', description: 'Message author role: user or assistant' },
37
+ tags: { type: 'string[]', description: 'Application-defined topics' },
38
+ },
39
+ textSearch: { analyzers: ['english'] },
40
+ labels: { application: 'example', owner: 'account123' },
41
+ });
42
+ await drive.remember({ mems: [
43
+ { id: 'message-1', content: 'The meeting is on Friday.',
44
+ timestamp: '2026-11-13T12:00:00Z', metadata: { role: 'user' } },
45
+ ] });
46
+ const { matches, usage } = await drive.recall({ query: 'When is the meeting?' });
47
+ const { mems } = await drive.read({ ids: [...new Set(matches.map(match => match.memId))] });
48
+ ```
49
+
50
+ ## Public operations
51
+
52
+ | Operation | Contract |
53
+ | --- | --- |
54
+ | `create(options, {signal}?)` | Creates one collection and opens a handle. Existing names fail. |
55
+ | `open({client, name, branch?, ...}, {signal}?)` | Validates an existing MemDrive; embedding and analyzers come from storage. |
56
+ | `list({client, labels?, limit?, cursor?}, {signal}?)` | Returns `{drives, nextCursor?}` for one native collection page. Default limit 10, maximum 100. |
57
+ | `drive.describe({signal}?)` | Fresh `{name, description?, labels, metadataSchema, embedding, textSearch?}`. |
58
+ | `drive.remember({mems}, {signal}?)` | Appends generated IDs or fully replaces supplied IDs. Returns `{ids}` in input order. |
59
+ | `drive.recall(request, {signal}?)` | Returns `{matches, usage}`; no final answer is generated. Default limit 10. |
60
+ | `drive.recall({requests}, {signal}?)` | Returns `{results}` in input order, including individual error/usage entries. |
61
+ | `drive.countValues({fields, filter?, excludeIds?, limit?}, {signal}?)` | Returns keyword value buckets and counts over original memories, with `asOf` and per-field `hasMore`. Default limit 10, maximum 100. |
62
+ | `drive.read({ids}, {signal}?)` | Returns full original `{mems}`; absent IDs are omitted. |
63
+ | `drive.list({limit?, cursor?}, {signal}?)` | Returns original `{mems, nextCursor?}` from one committed physical document page. Default limit 100, maximum 1000. |
64
+ | `drive.forget({ids} or {filter}, {signal}?)` | Removes whole Mems and their chunks. Missing IDs are harmless. |
65
+ | `drive.configure({metadataSchema?, description?}, {signal}?)` | Updates the drive description and/or metadata declaration. A supplied schema must retain all existing fields and their types; additions and field-description changes are allowed. |
66
+ | `drive.at({branch})` | Returns a branch-bound data handle with the same data APIs. |
67
+ | `drive.branches.create({name, source:{branch}}, {signal}?)` | Creates a branch. Latest accepted-write inclusion depends on the LambdaDB server contract. |
68
+ | `drive.branches.list({signal}?)`, `.delete(name, {signal}?)` | Lists/deletes branches. The main branch cannot be deleted. |
69
+ | `drive.destroy({signal}?)` | Deletes the collection, including its branches. |
70
+
71
+ Both list APIs may return an empty logical page with `nextCursor`; keep paging
72
+ until the cursor is absent. Document listing is committed-state inventory.
73
+ `read` and `recall` request consistent reads. A write-dependent read starts after
74
+ the caller receives a successful write response. Concurrent writes to the same
75
+ Mem have no ordering guarantee.
76
+
77
+ `metadataSchema` is required at creation; use `{}` when no custom fields are needed.
78
+ Metadata types are `string`, `string[]`, `number`, `boolean`, and `datetime`.
79
+ Drive and metadata-field descriptions are optional strings, up to 255 UTF-16 code units,
80
+ stored in native collection/index descriptions. `configure` preserves omitted
81
+ descriptions; an empty string clears one. Descriptions are returned by `describe`
82
+ and the drive catalog. `describe()` is the schema inspection API; there is no
83
+ separate agent-specific schema response.
84
+ Only declared metadata is accepted. Filters use explicit `and`/`or` arrays and
85
+ leaves such as `{field:'metadata.role', op:'eq', value:'user'}`. Supported leaf
86
+ operators are `eq`, `neq`, `in`, `exists`, `gt`, `gte`, `lt`, `lte`; ranges apply
87
+ to numbers and datetimes. `id` and `timestamp` are also filterable.
88
+
89
+ Labels are native collection tags, with a total native limit of five. `memory.*`
90
+ is reserved: two internal tags leave three caller labels for managed stores;
91
+ three internal tags leave two for external-vector stores. Over-limit input fails
92
+ before a request is sent. Descriptions do not consume tag slots. Labels aid discovery,
93
+ not authorization. The caller verifies its expected ownership before mutations.
94
+ Incompatible stores are rejected by `open` and skipped by the catalog. There is
95
+ no automatic migration or legacy-store deletion. Snapshot retention is not a
96
+ MemDrive option: new collections omit the setting and use LambdaDB's default of
97
+ 30 days. Opening an existing drive does not change its native retention setting.
98
+
99
+ ## Storage and retrieval
100
+
101
+ Managed stores use native `text-embedding-3-small` embeddings. At creation,
102
+ omitting `embedding` and passing `embedding: { mode: 'managed' }` are equivalent.
103
+ The managed model settings are fixed; `open` recovers them from storage. Supplying
104
+ `textSearch.analyzers` enables hybrid retrieval; omission uses vector retrieval.
105
+ Managed text retrieval uses native Jev reranking by default in both cases.
106
+ `recall` accepts an optional boolean `rerank`, including on each item of a batch:
107
+
108
+ | Embedding configuration | Omitted | `false` | `true` |
109
+ | --- | --- | --- | --- |
110
+ | Managed | Enabled | Disabled | Enabled |
111
+ | External | Disabled | Disabled | Rejected |
112
+
113
+ ```js
114
+ await drive.recall({ query: 'When is the meeting?', rerank: false });
115
+ ```
116
+
117
+ This is a per-request execution option, not a stored setting or a
118
+ `create`/`open`/`configure` option. Disabling reranking preserves the existing
119
+ KNN `k`, filters and result limit; results retain search order.
120
+ Unsupported combinations fail before database requests.
121
+
122
+ Each `recall` performs one native search request. There is no retrieval `mode`,
123
+ internal model adapter, prompt, evidence-selection step or model loop. A caller
124
+ can issue multiple queries in a batch, inspect the returned matches, call `read`
125
+ for complete originals and search again. Optional text `context` and
126
+ `recentDialogue` still become part of the embedding/rerank query without an internal agent
127
+ call. The caller owns their relevance and size; the native 8 KiB query bound is
128
+ validated without silent truncation. `usage` reports `elapsedMs` and
129
+ `databaseRequests`; MemDrive does not report caller model token usage.
130
+
131
+ Optional `observe` and `record` callbacks expose retrieval diagnostics.
132
+ `observe` emits one `retrieved` event for each successful recall; there is no
133
+ selection event. Use `observe.matches[].memId` for canonical caller IDs;
134
+ `observe.ids` contains internal physical evidence IDs. `record` emits `query`
135
+ and `query_result` events, including bodies and memory text. Batch callbacks
136
+ include `requestIndex`. Callers control whether and where to retain these events.
137
+
138
+ Managed text uses the current 800-code-point splitter, Unicode-aware with UTF-16
139
+ source offsets and no overlap. Short full Mems store `content` once. Long Mems
140
+ store their original in unindexed `memContent` and searchable `content` chunks.
141
+ An overwrite replaces obsolete chunk slots with bodyless documents. Public
142
+ matches identify `kind: 'mem'` or `'chunk'`, `memId`, and the returned text span.
143
+
144
+ For caller-provided embeddings, create with:
145
+
146
+ ```js
147
+ embedding: { mode: 'external', dimensions: 768,
148
+ similarity: 'cosine', identity: 'caller-model-v1' }
149
+ ```
150
+
151
+ Remember `{id?, embedding, timestamp?, metadata?}` and recall with
152
+ `{queryVector, filter?, excludeIds?, limit?}`. Text, chunking, keyword search,
153
+ and reranking are unavailable for external embeddings. Read/list/matches
154
+ return references and metadata without vectors or source text. The caller owns
155
+ embedding identity compatibility and reconstruction of the local original.
156
+
157
+ Remember packs complete Mem replacements into native requests up to 6,029,312
158
+ JSON bytes. One Mem is never split across write requests. The per-document bound
159
+ is 5 MiB. All replacements are validated before writes; subsequent requests are
160
+ sequential. Failure details distinguish `completedIds`, `uncertainIds`, and
161
+ `notAttemptedIds`. A multi-request remember is not atomic; do not blindly retry
162
+ the entire operation. The SDK does not serialize different writes or retry them.
163
+
164
+ Cancellation is a separate options argument and never enters stored JSON.
165
+ It removes queued requests and propagates to native requests. Cancellation does
166
+ not undo accepted writes.
167
+ Recalls share a default concurrency bound of five across branch views; the
168
+ caller may configure it. Batch request count is not artificially capped by the
169
+ SDK; a hosted MCP wrapper can impose its own exposed tool limit.
170
+
171
+ The development format stays `mems-v0` until release. Recreate disposable stores
172
+ after incompatible layout changes. MemDrive uses LambdaDB SDK 0.12.0. Build
173
+ artifacts are generated with `npm run build`; browser applications bundle the
174
+ public package entry point with their own build tools.
175
+
176
+ ## Metadata distributions
177
+
178
+ Use `describe()` for field declarations and `countValues()` for stored values:
179
+
180
+ ```ts
181
+ const { metadataSchema } = await drive.describe();
182
+ const distribution = await drive.countValues({
183
+ fields: ['metadata.role', 'metadata.tags'],
184
+ filter: { field: 'timestamp', op: 'gte', value: '2026-01-01T00:00:00Z' },
185
+ excludeIds: ['message-to-exclude'],
186
+ limit: 10,
187
+ });
188
+ // distribution.values['metadata.role']:
189
+ // { buckets: [{ value: 'user', count: 12 }], hasMore: false }
190
+ // distribution.asOf: ISO 8601 UTC fetch time
191
+ ```
192
+
193
+ Countable fields are `id` and declared `string`/`string[]` metadata fields.
194
+ Each request accepts one to five distinct fields, matching the native facet limit. Numeric, boolean and datetime fields can
195
+ filter the population but cannot be aggregated. Counts include each original
196
+ Mem once, regardless of its chunk count; obsolete chunk slots do not contribute.
197
+ An array may place a Mem in multiple buckets, so bucket sums are not the number
198
+ of memories. The active branch, filter and excluded IDs determine the population.
199
+
200
+ Value results are cached for 60 seconds per data handle; schema validation is
201
+ cached for five minutes internally. `describe()` itself remains a fresh lookup.
202
+ SDK mutations invalidate local counts across views of the same drive. Writes
203
+ through another independent handle or client may remain invisible in cached
204
+ counts until expiration. `asOf` is the result fetch time, not a database snapshot
205
+ identifier. `hasMore` is `true` when another bucket is observed, `false` when the
206
+ response is complete, and `null` when the native 100-bucket bound leaves
207
+ completeness unknown.
208
+
209
+ A hosted MCP service can expose these SDK operations and supply tool descriptions
210
+ and protocol handling. The service or calling agent owns orchestration; MemDrive
211
+ has no model-specific tool schemas, short evidence aliases or finish/report tool.
212
+
213
+ ## Agent tools
214
+
215
+ Import `createTools` from `@functional-systems/memdrive/tools` to expose portable
216
+ memory operations to a calling agent. The common layer provides JSON Schema input
217
+ and output definitions, descriptions, effect annotations and SDK execution. It
218
+ contains no internal agent loop or MCP server. See [the tool contract](docs/tools.md)
219
+ for the catalog, branch binding, write opt-in, error outcomes and direct/MCP mapping.
220
+
221
+ ## Consumers
222
+
223
+ The prototype was exercised by BEAM, LongMemEval and SillyMemory integrations.
224
+ Those applications and evaluation runners remain outside this SDK repository;
225
+ their existing local copies have not been switched to the standalone package.
226
+ Each caller owns dataset interpretation, recent-context partition, search
227
+ orchestration and final prompt assembly. The standalone API no longer accepts
228
+ `mode` or `agent`; consumers of the earlier prototype must remove those options
229
+ and move any agent loop to the application. SDK unit and package checks do not establish
230
+ benchmark answer quality or live service compatibility.
@@ -0,0 +1,7 @@
1
+ export declare const CHUNKING_POLICY = "boundary-v1";
2
+ export declare function chunkSpans(text: string, limit?: number): Array<{
3
+ start: number;
4
+ end: number;
5
+ text: string;
6
+ }>;
7
+ //# sourceMappingURL=chunking.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunking.d.ts","sourceRoot":"","sources":["../../src/chunking.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAC7C,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,SAAM,GAAG,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,CAAC,CA4BvG"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CHUNKING_POLICY = void 0;
4
+ exports.chunkSpans = chunkSpans;
5
+ // Exact source partitions: UTF-16 offsets for slice(), a Unicode-code-point cap.
6
+ // English sentence detection is deliberate; other languages are not optimized.
7
+ exports.CHUNKING_POLICY = 'boundary-v1';
8
+ function chunkSpans(text, limit = 800) {
9
+ if (!Number.isInteger(limit) || limit < 1)
10
+ throw new RangeError('Chunk limit must be a positive integer.');
11
+ const offsets = [0];
12
+ for (const char of text)
13
+ offsets.push(offsets.at(-1) + char.length);
14
+ const paragraphs = [...text.matchAll(/\r?\n[\t ]*\r?\n(?:\s*\r?\n)*/gu)].map(m => m.index + m[0].length);
15
+ const sentences = typeof Intl.Segmenter === 'function'
16
+ ? [...new Intl.Segmenter('en', { granularity: 'sentence' }).segment(text)].map(s => s.index + s.segment.length)
17
+ : [...text.matchAll(/[.!?]["'”’)\]]*(?:\s+|$)/gu)].map(m => m.index + m[0].length);
18
+ const words = [...text.matchAll(/\s+/gu)].map(m => m.index + m[0].length);
19
+ const lastBoundary = (boundaries, floor, ceiling) => {
20
+ let low = 0, high = boundaries.length;
21
+ while (low < high) {
22
+ const mid = (low + high) >>> 1;
23
+ if (boundaries[mid] <= ceiling)
24
+ low = mid + 1;
25
+ else
26
+ high = mid;
27
+ }
28
+ return boundaries[low - 1] >= floor ? boundaries[low - 1] : undefined;
29
+ };
30
+ const spans = [];
31
+ for (let point = 0; point < offsets.length - 1;) {
32
+ const last = Math.min(point + limit, offsets.length - 1), start = offsets[point];
33
+ let end = offsets[last];
34
+ if (last < offsets.length - 1) {
35
+ // Avoid tiny fragments caused by an early heading/short sentence.
36
+ const floor = offsets[point + Math.max(1, Math.floor(limit / 2))];
37
+ end = lastBoundary(paragraphs, floor, end) ?? lastBoundary(sentences, floor, end)
38
+ ?? lastBoundary(words, floor, end) ?? end;
39
+ }
40
+ spans.push({ start, end, text: text.slice(start, end) });
41
+ while (offsets[point] < end)
42
+ point++;
43
+ }
44
+ return spans;
45
+ }
46
+ //# sourceMappingURL=chunking.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunking.js","sourceRoot":"","sources":["../../src/chunking.ts"],"names":[],"mappings":";;;AAGA,gCA4BC;AA/BD,iFAAiF;AACjF,+EAA+E;AAClE,QAAA,eAAe,GAAG,aAAa,CAAC;AAC7C,SAAgB,UAAU,CAAC,IAAY,EAAE,KAAK,GAAG,GAAG;IAChD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,yCAAyC,CAAC,CAAC;IAC3G,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;IACpB,KAAK,MAAM,IAAI,IAAI,IAAI;QAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IACrE,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,iCAAiC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACzG,MAAM,SAAS,GAAG,OAAO,IAAI,CAAC,SAAS,KAAK,UAAU;QAClD,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;QAC/G,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,4BAA4B,CAAC,CAAC,CAAC,GAA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O,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,kEAAkE;YAClE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;YACnE,GAAG,GAAG,YAAY,CAAC,UAAU,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,YAAY,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,CAAC;mBAC1E,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,GAAG,CAAC;QAClD,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QACzD,OAAO,OAAO,CAAC,KAAK,CAAE,GAAG,GAAG;YAAE,KAAK,EAAE,CAAC;IAC1C,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { RequestOptions, Usage } from './types.js';
2
+ export declare class MemDriveError extends Error {
3
+ code: string;
4
+ details?: Record<string, unknown> | undefined;
5
+ usage?: Usage | undefined;
6
+ status?: number | undefined;
7
+ constructor(code: string, message: string, { cause, details, usage }?: {
8
+ cause?: unknown;
9
+ details?: Record<string, unknown> | undefined;
10
+ usage?: Usage | undefined;
11
+ });
12
+ }
13
+ export declare function requireInput(condition: unknown, message: string): asserts condition;
14
+ export declare function operationOptions(options?: RequestOptions): RequestOptions;
15
+ export declare function checkAbort(signal?: AbortSignal): void;
16
+ export declare function abortError(cause: unknown, signal?: AbortSignal): unknown;
17
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExD,qBAAa,aAAc,SAAQ,KAAK;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC9C,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;gBACxB,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,GAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,CAAA;KAAO;CAO3K;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAEnF;AAED,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,cAAmB,GAAG,cAAc,CAQ7E;AAED,wBAAgB,UAAU,CAAC,MAAM,CAAC,EAAE,WAAW,QAE9C;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAKxE"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MemDriveError = void 0;
4
+ exports.requireInput = requireInput;
5
+ exports.operationOptions = operationOptions;
6
+ exports.checkAbort = checkAbort;
7
+ exports.abortError = abortError;
8
+ class MemDriveError extends Error {
9
+ constructor(code, message, { cause, details, usage } = {}) {
10
+ super(message, cause === undefined ? undefined : { cause });
11
+ this.name = 'MemDriveError';
12
+ this.code = code;
13
+ if (details !== undefined)
14
+ this.details = details;
15
+ if (usage !== undefined)
16
+ this.usage = usage;
17
+ }
18
+ }
19
+ exports.MemDriveError = MemDriveError;
20
+ function requireInput(condition, message) {
21
+ if (!condition)
22
+ throw new MemDriveError('INVALID_INPUT', message);
23
+ }
24
+ function operationOptions(options = {}) {
25
+ requireInput(options !== null && typeof options === 'object' && !Array.isArray(options)
26
+ && Object.keys(options).every(key => key === 'signal'), 'Operation options accept only signal.');
27
+ const { signal } = options;
28
+ requireInput(signal === undefined || (signal !== null && typeof signal === 'object'
29
+ && typeof signal.aborted === 'boolean' && typeof signal.addEventListener === 'function'
30
+ && typeof signal.removeEventListener === 'function'), 'signal must be an AbortSignal.');
31
+ return { signal };
32
+ }
33
+ function checkAbort(signal) {
34
+ if (signal?.aborted)
35
+ throw new MemDriveError('ABORTED', 'Operation aborted.');
36
+ }
37
+ function abortError(cause, signal) {
38
+ const error = cause;
39
+ if (error?.code === 'ABORTED')
40
+ return cause;
41
+ return signal?.aborted || error?.name === 'AbortError'
42
+ ? new MemDriveError('ABORTED', 'Operation aborted.', { cause }) : cause;
43
+ }
44
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AAgBA,oCAEC;AAED,4CAQC;AAED,gCAEC;AAED,gCAKC;AArCD,MAAa,aAAc,SAAQ,KAAK;IAKpC,YAAY,IAAY,EAAE,OAAe,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,KAAoG,EAAE;QACpK,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,OAAO,KAAK,SAAS;YAAE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAClD,IAAI,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC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CAAC,SAAS,EAAE,oBAAoB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAChF,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { Filter, Metadata, MetadataSchema, MetadataType } from './types.js';
2
+ export declare const isObject: (value: unknown) => value is Record<string, unknown>;
3
+ export declare const matchAll: () => {
4
+ queryString: {
5
+ query: string;
6
+ };
7
+ };
8
+ export declare function dateValue(value: unknown): bigint | undefined;
9
+ export declare function validateDescription(description: unknown): string | undefined;
10
+ export declare function validateMetadataSchema(schema: unknown): MetadataSchema;
11
+ export declare function fieldType(field: unknown, schema: MetadataSchema): MetadataType | undefined;
12
+ export declare function validScalar(value: unknown, type: MetadataType | undefined): boolean;
13
+ export declare function validateFilter(filter: unknown, schema: MetadataSchema): Filter | undefined;
14
+ export interface NativeFilter {
15
+ queryString?: {
16
+ query: string;
17
+ defaultField?: string;
18
+ };
19
+ bool?: NativeFilter[];
20
+ occur?: string | undefined;
21
+ }
22
+ export declare function compileFilter(filter: unknown, schema: MetadataSchema): NativeFilter;
23
+ export declare function buildFilter(filters?: unknown[], excludeIds?: string[], schema?: MetadataSchema): NativeFilter;
24
+ export declare function buildSearchFilter(filters?: unknown[], excludeIds?: string[], seenChunkIds?: string[], schema?: MetadataSchema): NativeFilter;
25
+ export declare function matchesFilter(mem: {
26
+ id: string;
27
+ timestamp?: string | undefined;
28
+ metadata?: Metadata | undefined;
29
+ }, filter: Filter | undefined, schema: MetadataSchema): boolean;
30
+ //# sourceMappingURL=filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAgB,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI/F,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAA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