@functional-systems/memdrive 0.1.1-dev.1 → 0.1.1-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +20 -250
- package/dist/commonjs/chunking.d.ts +1 -2
- package/dist/commonjs/chunking.d.ts.map +1 -1
- package/dist/commonjs/chunking.js +2 -5
- package/dist/commonjs/chunking.js.map +1 -1
- package/dist/commonjs/config.d.ts +17 -0
- package/dist/commonjs/config.d.ts.map +1 -0
- package/dist/commonjs/config.js +116 -0
- package/dist/commonjs/config.js.map +1 -0
- package/dist/commonjs/errors.d.ts +10 -6
- package/dist/commonjs/errors.d.ts.map +1 -1
- package/dist/commonjs/errors.js +25 -5
- package/dist/commonjs/errors.js.map +1 -1
- package/dist/commonjs/index.d.ts +15 -5
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +331 -307
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/records.d.ts +44 -0
- package/dist/commonjs/records.d.ts.map +1 -0
- package/dist/commonjs/records.js +88 -0
- package/dist/commonjs/records.js.map +1 -0
- package/dist/commonjs/search.d.ts +8 -0
- package/dist/commonjs/search.d.ts.map +1 -0
- package/dist/commonjs/search.js +56 -0
- package/dist/commonjs/search.js.map +1 -0
- package/dist/commonjs/types.d.ts +84 -252
- package/dist/commonjs/types.d.ts.map +1 -1
- package/dist/esm/chunking.d.ts +1 -2
- package/dist/esm/chunking.d.ts.map +1 -1
- package/dist/esm/chunking.js +2 -4
- package/dist/esm/chunking.js.map +1 -1
- package/dist/esm/config.d.ts +17 -0
- package/dist/esm/config.d.ts.map +1 -0
- package/dist/esm/config.js +107 -0
- package/dist/esm/config.js.map +1 -0
- package/dist/esm/errors.d.ts +10 -6
- package/dist/esm/errors.d.ts.map +1 -1
- package/dist/esm/errors.js +22 -4
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/index.d.ts +15 -5
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +331 -305
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/records.d.ts +44 -0
- package/dist/esm/records.d.ts.map +1 -0
- package/dist/esm/records.js +77 -0
- package/dist/esm/records.js.map +1 -0
- package/dist/esm/search.d.ts +8 -0
- package/dist/esm/search.d.ts.map +1 -0
- package/dist/esm/search.js +52 -0
- package/dist/esm/search.js.map +1 -0
- package/dist/esm/types.d.ts +84 -252
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +10 -32
- package/src/chunking.ts +2 -3
- package/src/config.ts +121 -0
- package/src/errors.ts +20 -6
- package/src/index.ts +351 -289
- package/src/records.ts +83 -0
- package/src/search.ts +57 -0
- package/src/types.ts +74 -253
- package/dist/commonjs/filter.d.ts +0 -30
- package/dist/commonjs/filter.d.ts.map +0 -1
- package/dist/commonjs/filter.js +0 -224
- package/dist/commonjs/filter.js.map +0 -1
- package/dist/commonjs/storage.d.ts +0 -274
- package/dist/commonjs/storage.d.ts.map +0 -1
- package/dist/commonjs/storage.js +0 -861
- package/dist/commonjs/storage.js.map +0 -1
- package/dist/commonjs/tools/definitions.d.ts +0 -5
- package/dist/commonjs/tools/definitions.d.ts.map +0 -1
- package/dist/commonjs/tools/definitions.js +0 -129
- package/dist/commonjs/tools/definitions.js.map +0 -1
- package/dist/commonjs/tools/index.d.ts +0 -6
- package/dist/commonjs/tools/index.d.ts.map +0 -1
- package/dist/commonjs/tools/index.js +0 -104
- package/dist/commonjs/tools/index.js.map +0 -1
- package/dist/commonjs/tools/types.d.ts +0 -50
- package/dist/commonjs/tools/types.d.ts.map +0 -1
- package/dist/commonjs/tools/types.js +0 -3
- package/dist/commonjs/tools/types.js.map +0 -1
- package/dist/commonjs/values.d.ts +0 -17
- package/dist/commonjs/values.d.ts.map +0 -1
- package/dist/commonjs/values.js +0 -90
- package/dist/commonjs/values.js.map +0 -1
- package/dist/esm/filter.d.ts +0 -30
- package/dist/esm/filter.d.ts.map +0 -1
- package/dist/esm/filter.js +0 -209
- package/dist/esm/filter.js.map +0 -1
- package/dist/esm/storage.d.ts +0 -274
- package/dist/esm/storage.d.ts.map +0 -1
- package/dist/esm/storage.js +0 -845
- package/dist/esm/storage.js.map +0 -1
- package/dist/esm/tools/definitions.d.ts +0 -5
- package/dist/esm/tools/definitions.d.ts.map +0 -1
- package/dist/esm/tools/definitions.js +0 -126
- package/dist/esm/tools/definitions.js.map +0 -1
- package/dist/esm/tools/index.d.ts +0 -6
- package/dist/esm/tools/index.d.ts.map +0 -1
- package/dist/esm/tools/index.js +0 -101
- package/dist/esm/tools/index.js.map +0 -1
- package/dist/esm/tools/types.d.ts +0 -50
- package/dist/esm/tools/types.d.ts.map +0 -1
- package/dist/esm/tools/types.js +0 -2
- package/dist/esm/tools/types.js.map +0 -1
- package/dist/esm/values.d.ts +0 -17
- package/dist/esm/values.d.ts.map +0 -1
- package/dist/esm/values.js +0 -87
- package/dist/esm/values.js.map +0 -1
- package/docs/tools.md +0 -163
- package/src/filter.ts +0 -189
- package/src/storage.ts +0 -765
- package/src/tools/definitions.ts +0 -156
- package/src/tools/index.ts +0 -97
- package/src/tools/types.ts +0 -45
- package/src/values.ts +0 -103
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
- Replace the memory SDK entry points with a file SDK for fresh stores, read-only main, and working forks.
|
|
6
|
+
- Create files in batches and read exact originals by path or stable file ID. Search indexed chunks with hybrid retrieval, optional reranking and verified source ranges.
|
|
7
|
+
- Run LongMemEval against the public file SDK. The file-based corpus and run formats bind each evidence span to its original file and keep prior benchmark results on their original protocol.
|
|
8
|
+
|
|
3
9
|
## 0.1.0
|
|
4
10
|
|
|
5
11
|
First stable release of the standalone MemDrive SDK. The public API and storage
|
package/README.md
CHANGED
|
@@ -1,264 +1,34 @@
|
|
|
1
1
|
# MemDrive
|
|
2
2
|
|
|
3
|
-
TypeScript
|
|
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.
|
|
3
|
+
TypeScript file SDK backed by LambdaDB. MemDrive accepts an initialized LambdaDB client. The application owns connection credentials and transport.
|
|
8
4
|
|
|
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.
|
|
5
|
+
The package is `@functional-systems/memdrive`, licensed under Apache-2.0. It supports ESM, CommonJS, TypeScript, Node.js 20.12+, and browser bundlers.
|
|
12
6
|
|
|
13
|
-
##
|
|
7
|
+
## File stores
|
|
14
8
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
1. [Create a LambdaDB account](https://app.lambdadb.ai/auth/signup), or sign in
|
|
18
|
-
to [LambdaDB Cloud](https://app.lambdadb.ai) if you already have one.
|
|
19
|
-
2. Create a project and choose an AWS region for your data.
|
|
20
|
-
3. Open the project's **API Keys** tab, select **Create key** (or
|
|
21
|
-
**Create your first key**), enter a name, and create the key. Creating a
|
|
22
|
-
project does not automatically issue an API key.
|
|
23
|
-
4. Save the key securely when it appears; the full value is shown only once.
|
|
24
|
-
Copy the project's region-specific **base URL** and **project name** from
|
|
25
|
-
the console as well.
|
|
26
|
-
|
|
27
|
-
In the example below, use the base URL as `baseUrl`, the project name as
|
|
28
|
-
`projectName`, and the API key as `projectApiKey`. Keep the API key out of source
|
|
29
|
-
control and load it from your application's secret configuration. See the
|
|
30
|
-
[LambdaDB setup guide](https://docs.lambdadb.ai/guides/get-started/quickstart)
|
|
31
|
-
for account setup and API key management details.
|
|
32
|
-
|
|
33
|
-
### 2. Install the packages
|
|
34
|
-
|
|
35
|
-
Install this stable release and the LambdaDB client used to initialize it:
|
|
36
|
-
|
|
37
|
-
```sh
|
|
38
|
-
npm install @functional-systems/memdrive@0.1.0 @functional-systems/lambdadb@0.12.0
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
An unqualified install follows the stable `latest` channel. Use `@rc` to follow
|
|
42
|
-
release candidates, `@dev` for development builds, or an exact version for
|
|
43
|
-
reproducibility.
|
|
44
|
-
|
|
45
|
-
### 3. Store and recall a memory
|
|
46
|
-
|
|
47
|
-
Replace the connection placeholders below with your project's values.
|
|
48
|
-
The `create` call sets up the MemDrive collection; no manual collection setup
|
|
49
|
-
is needed in the console.
|
|
9
|
+
Use `@functional-systems/memdrive` to create a text file store and save exact originals on a working fork. These stores use a dedicated layout and require a fresh collection name.
|
|
50
10
|
|
|
51
11
|
```ts
|
|
52
|
-
import {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const drive = await create({
|
|
62
|
-
client, name: 'story_memory',
|
|
63
|
-
description: 'Conversation memories for the example application',
|
|
64
|
-
metadataSchema: {
|
|
65
|
-
role: { type: 'string', description: 'Message author role: user or assistant' },
|
|
66
|
-
tags: { type: 'string[]', description: 'Application-defined topics' },
|
|
67
|
-
},
|
|
68
|
-
textSearch: { analyzers: ['english'] },
|
|
69
|
-
labels: { application: 'example', owner: 'account123' },
|
|
12
|
+
import { MemDrive } from '@functional-systems/memdrive';
|
|
13
|
+
|
|
14
|
+
const main = await MemDrive.create({ client, name: 'workspace' });
|
|
15
|
+
const work = await main.fork({ name: 'research' });
|
|
16
|
+
const file = await work.write({
|
|
17
|
+
op: 'create',
|
|
18
|
+
path: '/notes/context.md',
|
|
19
|
+
content: '# Task context\r\n',
|
|
70
20
|
});
|
|
71
|
-
await drive.remember({ mems: [
|
|
72
|
-
{ id: 'message-1', content: 'The meeting is on Friday.',
|
|
73
|
-
timestamp: '2026-11-13T12:00:00Z', metadata: { role: 'user' } },
|
|
74
|
-
] });
|
|
75
|
-
const { matches, usage } = await drive.recall({ query: 'When is the meeting?' });
|
|
76
|
-
const { mems } = await drive.read({ ids: [...new Set(matches.map(match => match.memId))] });
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Public operations
|
|
80
|
-
|
|
81
|
-
| Operation | Contract |
|
|
82
|
-
| --- | --- |
|
|
83
|
-
| `create(options, {signal}?)` | Creates one collection and opens a handle. Existing names fail. |
|
|
84
|
-
| `open({client, name, branch?, ...}, {signal}?)` | Validates an existing MemDrive; embedding and analyzers come from storage. |
|
|
85
|
-
| `list({client, labels?, limit?, cursor?}, {signal}?)` | Returns `{drives, nextCursor?}` for one native collection page. Default limit 10, maximum 100. |
|
|
86
|
-
| `drive.describe({signal}?)` | Fresh `{name, description?, labels, metadataSchema, embedding, textSearch?}`. |
|
|
87
|
-
| `drive.remember({mems}, {signal}?)` | Appends generated IDs or fully replaces supplied IDs. Returns `{ids}` in input order. |
|
|
88
|
-
| `drive.recall(request, {signal}?)` | Returns `{matches, usage}`; no final answer is generated. Default limit 10. |
|
|
89
|
-
| `drive.recall({requests}, {signal}?)` | Returns `{results}` in input order, including individual error/usage entries. |
|
|
90
|
-
| `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. |
|
|
91
|
-
| `drive.read({ids}, {signal}?)` | Returns full original `{mems}`; absent IDs are omitted. |
|
|
92
|
-
| `drive.list({limit?, cursor?}, {signal}?)` | Returns original `{mems, nextCursor?}` from one committed physical document page. Default limit 100, maximum 1000. |
|
|
93
|
-
| `drive.forget({ids} or {filter}, {signal}?)` | Removes whole Mems and their chunks. Missing IDs are harmless. |
|
|
94
|
-
| `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. |
|
|
95
|
-
| `drive.at({branch})` | Returns a branch-bound data handle with the same data APIs. |
|
|
96
|
-
| `drive.branches.create({name, source:{branch}}, {signal}?)` | Creates a branch. Latest accepted-write inclusion depends on the LambdaDB server contract. |
|
|
97
|
-
| `drive.branches.list({signal}?)`, `.delete(name, {signal}?)` | Lists/deletes branches. The main branch cannot be deleted. |
|
|
98
|
-
| `drive.destroy({signal}?)` | Deletes the collection, including its branches. |
|
|
99
|
-
|
|
100
|
-
Both list APIs may return an empty logical page with `nextCursor`; keep paging
|
|
101
|
-
until the cursor is absent. Document listing is committed-state inventory.
|
|
102
|
-
`read` and `recall` request consistent reads. A write-dependent read starts after
|
|
103
|
-
the caller receives a successful write response. Concurrent writes to the same
|
|
104
|
-
Mem have no ordering guarantee.
|
|
105
|
-
|
|
106
|
-
`metadataSchema` is required at creation; use `{}` when no custom fields are needed.
|
|
107
|
-
Metadata types are `string`, `string[]`, `number`, `boolean`, and `datetime`.
|
|
108
|
-
Drive and metadata-field descriptions are optional strings, up to 255 UTF-16 code units,
|
|
109
|
-
stored in native collection/index descriptions. `configure` preserves omitted
|
|
110
|
-
descriptions; an empty string clears one. Descriptions are returned by `describe`
|
|
111
|
-
and the drive catalog. `describe()` is the schema inspection API; there is no
|
|
112
|
-
separate agent-specific schema response.
|
|
113
|
-
Only declared metadata is accepted. Filters use explicit `and`/`or` arrays and
|
|
114
|
-
leaves such as `{field:'metadata.role', op:'eq', value:'user'}`. Supported leaf
|
|
115
|
-
operators are `eq`, `neq`, `in`, `exists`, `gt`, `gte`, `lt`, `lte`; ranges apply
|
|
116
|
-
to numbers and datetimes. `id` and `timestamp` are also filterable.
|
|
117
21
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
not authorization. The caller verifies its expected ownership before mutations.
|
|
123
|
-
Incompatible stores are rejected by `open` and skipped by the catalog. There is
|
|
124
|
-
no automatic migration or legacy-store deletion. Snapshot retention is not a
|
|
125
|
-
MemDrive option: new collections omit the setting and use LambdaDB's default of
|
|
126
|
-
30 days. Opening an existing drive does not change its native retention setting.
|
|
127
|
-
|
|
128
|
-
## Storage and retrieval
|
|
129
|
-
|
|
130
|
-
Managed stores use native `text-embedding-3-small` embeddings. At creation,
|
|
131
|
-
omitting `embedding` and passing `embedding: { mode: 'managed' }` are equivalent.
|
|
132
|
-
The managed model settings are fixed; `open` recovers them from storage. Supplying
|
|
133
|
-
`textSearch.analyzers` enables hybrid retrieval; omission uses vector retrieval.
|
|
134
|
-
Managed text retrieval uses native Jev reranking by default in both cases.
|
|
135
|
-
`recall` accepts an optional boolean `rerank`, including on each item of a batch:
|
|
136
|
-
|
|
137
|
-
| Embedding configuration | Omitted | `false` | `true` |
|
|
138
|
-
| --- | --- | --- | --- |
|
|
139
|
-
| Managed | Enabled | Disabled | Enabled |
|
|
140
|
-
| External | Disabled | Disabled | Rejected |
|
|
141
|
-
|
|
142
|
-
```js
|
|
143
|
-
await drive.recall({ query: 'When is the meeting?', rerank: false });
|
|
22
|
+
const reopened = await MemDrive.open({ client, name: 'workspace', at: { fork: 'research' } });
|
|
23
|
+
const saved = await reopened.read({ fileId: file.fileId });
|
|
24
|
+
const { hits, reranked } = await reopened.search({ query: 'Task context', limit: 5 });
|
|
25
|
+
// The same file is available through { path: '/notes/context.md' }.
|
|
144
26
|
```
|
|
145
27
|
|
|
146
|
-
|
|
147
|
-
`create`/`open`/`configure` option. Disabling reranking preserves the existing
|
|
148
|
-
KNN `k`, filters and result limit; results retain search order.
|
|
149
|
-
Unsupported combinations fail before database requests.
|
|
150
|
-
|
|
151
|
-
Each `recall` performs one native search request. There is no retrieval `mode`,
|
|
152
|
-
internal model adapter, prompt, evidence-selection step or model loop. A caller
|
|
153
|
-
can issue multiple queries in a batch, inspect the returned matches, call `read`
|
|
154
|
-
for complete originals and search again. Optional text `context` and
|
|
155
|
-
`recentDialogue` still become part of the embedding/rerank query without an internal agent
|
|
156
|
-
call. The caller owns their relevance and size; the native 8 KiB query bound is
|
|
157
|
-
validated without silent truncation. `usage` reports `elapsedMs` and
|
|
158
|
-
`databaseRequests`; MemDrive does not report caller model token usage.
|
|
159
|
-
|
|
160
|
-
Optional `observe` and `record` callbacks expose retrieval diagnostics.
|
|
161
|
-
`observe` emits one `retrieved` event for each successful recall; there is no
|
|
162
|
-
selection event. Use `observe.matches[].memId` for canonical caller IDs;
|
|
163
|
-
`observe.ids` contains internal physical evidence IDs. `record` emits `query`
|
|
164
|
-
and `query_result` events, including bodies and memory text. Batch callbacks
|
|
165
|
-
include `requestIndex`. Callers control whether and where to retain these events.
|
|
166
|
-
|
|
167
|
-
Managed text uses the current 800-code-point splitter, Unicode-aware with UTF-16
|
|
168
|
-
source offsets and no overlap. Short full Mems store `content` once. Long Mems
|
|
169
|
-
store their original in unindexed `memContent` and searchable `content` chunks.
|
|
170
|
-
An overwrite replaces obsolete chunk slots with bodyless documents. Public
|
|
171
|
-
matches identify `kind: 'mem'` or `'chunk'`, `memId`, and the returned text span.
|
|
172
|
-
|
|
173
|
-
For caller-provided embeddings, create with:
|
|
174
|
-
|
|
175
|
-
```js
|
|
176
|
-
embedding: { mode: 'external', dimensions: 768,
|
|
177
|
-
similarity: 'cosine', identity: 'caller-model-v1' }
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
Remember `{id?, embedding, timestamp?, metadata?}` and recall with
|
|
181
|
-
`{queryVector, filter?, excludeIds?, limit?}`. Text, chunking, keyword search,
|
|
182
|
-
and reranking are unavailable for external embeddings. Read/list/matches
|
|
183
|
-
return references and metadata without vectors or source text. The caller owns
|
|
184
|
-
embedding identity compatibility and reconstruction of the local original.
|
|
185
|
-
|
|
186
|
-
Remember packs complete Mem replacements into native requests up to 6,029,312
|
|
187
|
-
JSON bytes. One Mem is never split across write requests. The per-document bound
|
|
188
|
-
is 5 MiB. All replacements are validated before writes; subsequent requests are
|
|
189
|
-
sequential. Failure details distinguish `completedIds`, `uncertainIds`, and
|
|
190
|
-
`notAttemptedIds`. A multi-request remember is not atomic; do not blindly retry
|
|
191
|
-
the entire operation. The SDK does not serialize different writes or retry them.
|
|
192
|
-
|
|
193
|
-
Cancellation is a separate options argument and never enters stored JSON.
|
|
194
|
-
It removes queued requests and propagates to native requests. Cancellation does
|
|
195
|
-
not undo accepted writes.
|
|
196
|
-
Recalls share a default concurrency bound of five across branch views; the
|
|
197
|
-
caller may configure it. Batch request count is not artificially capped by the
|
|
198
|
-
SDK; a hosted MCP wrapper can impose its own exposed tool limit.
|
|
199
|
-
|
|
200
|
-
The storage format is `mems-v0`. MemDrive uses LambdaDB SDK 0.12.0. Build
|
|
201
|
-
artifacts are generated with `npm run build`; browser applications bundle the
|
|
202
|
-
public package entry point with their own build tools.
|
|
203
|
-
|
|
204
|
-
## Metadata distributions
|
|
205
|
-
|
|
206
|
-
Use `describe()` for field declarations and `countValues()` for stored values:
|
|
207
|
-
|
|
208
|
-
```ts
|
|
209
|
-
const { metadataSchema } = await drive.describe();
|
|
210
|
-
const distribution = await drive.countValues({
|
|
211
|
-
fields: ['metadata.role', 'metadata.tags'],
|
|
212
|
-
filter: { field: 'timestamp', op: 'gte', value: '2026-01-01T00:00:00Z' },
|
|
213
|
-
excludeIds: ['message-to-exclude'],
|
|
214
|
-
limit: 10,
|
|
215
|
-
});
|
|
216
|
-
// distribution.values['metadata.role']:
|
|
217
|
-
// { buckets: [{ value: 'user', count: 12 }], hasMore: false }
|
|
218
|
-
// distribution.asOf: ISO 8601 UTC fetch time
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
Countable fields are `id` and declared `string`/`string[]` metadata fields.
|
|
222
|
-
Each request accepts one to five distinct fields, matching the native facet limit. Numeric, boolean and datetime fields can
|
|
223
|
-
filter the population but cannot be aggregated. Counts include each original
|
|
224
|
-
Mem once, regardless of its chunk count; obsolete chunk slots do not contribute.
|
|
225
|
-
An array may place a Mem in multiple buckets, so bucket sums are not the number
|
|
226
|
-
of memories. The active branch, filter and excluded IDs determine the population.
|
|
227
|
-
|
|
228
|
-
Value results are cached for 60 seconds per data handle; schema validation is
|
|
229
|
-
cached for five minutes internally. `describe()` itself remains a fresh lookup.
|
|
230
|
-
SDK mutations invalidate local counts across views of the same drive. Writes
|
|
231
|
-
through another independent handle or client may remain invisible in cached
|
|
232
|
-
counts until expiration. `asOf` is the result fetch time, not a database snapshot
|
|
233
|
-
identifier. `hasMore` is `true` when another bucket is observed, `false` when the
|
|
234
|
-
response is complete, and `null` when the native 100-bucket bound leaves
|
|
235
|
-
completeness unknown.
|
|
236
|
-
|
|
237
|
-
A hosted MCP service can expose these SDK operations and supply tool descriptions
|
|
238
|
-
and protocol handling. The service or calling agent owns orchestration; MemDrive
|
|
239
|
-
has no model-specific tool schemas, short evidence aliases or finish/report tool.
|
|
240
|
-
|
|
241
|
-
## Agent tools
|
|
242
|
-
|
|
243
|
-
Import `createTools` from `@functional-systems/memdrive/tools` to expose portable
|
|
244
|
-
memory operations to a calling agent. The common layer provides JSON Schema input
|
|
245
|
-
and output definitions, descriptions, effect annotations and SDK execution. It
|
|
246
|
-
contains no internal agent loop or MCP server. See [the tool contract](docs/tools.md)
|
|
247
|
-
for the catalog, branch binding, write opt-in, error outcomes and direct/MCP mapping.
|
|
248
|
-
|
|
249
|
-
## Consumers
|
|
28
|
+
`read` returns the original file or `null` when absent. Content can be empty and the SDK preserves whitespace and line endings. Paths are case-sensitive, absolute and slash-separated. Pass an array of up to 100 operations to create files in batches. Pass up to 100 distinct paths in `read({ paths })` to read existing files in request order. An existing path in the same fork rejects creation with `PATH_EXISTS`. Main is read-only and supplies the starting view for creating a fork. Working edits are scoped to that fork. A store can declare scalar metadata fields with `metadataSchema` and carry collection labels. File writes attach optional `metadata` and record the modification time.
|
|
250
29
|
|
|
251
|
-
The
|
|
252
|
-
Those applications and evaluation runners remain outside this SDK repository;
|
|
253
|
-
their existing local copies have not been switched to the standalone package.
|
|
254
|
-
Each caller owns dataset interpretation, recent-context partition, search
|
|
255
|
-
orchestration and final prompt assembly. The standalone API no longer accepts
|
|
256
|
-
`mode` or `agent`; consumers of the earlier prototype must remove those options
|
|
257
|
-
and move any agent loop to the application. SDK unit and package checks do not establish
|
|
258
|
-
benchmark answer quality or live service compatibility.
|
|
30
|
+
Search ranks file chunks with Bayesian lexical and vector retrieval. The store defaults to LambdaDB's `standard` analyzer and OpenAI's managed `text-embedding-3-small` embeddings. Set `textSearch.analyzers` when creating a store to select other supported analyzers. Text is currently split at paragraph, sentence or whitespace boundaries using an 800-code-point cap. Each hit carries the stable file ID, path, metadata and a chunk preview. When the chunk's location is verified against the exact original, the hit also includes a UTF-16 `range` that can be passed to JavaScript's `slice`.
|
|
259
31
|
|
|
260
|
-
|
|
32
|
+
Search enables native reranking by default. Use `rerank: false` for fused order or `rerank: { onFailure: 'returnOriginal' }` to allow native provider fallback. The result's `reranked` flag reports whether reranking was applied. An optional `embeddingQuery` supplies separate semantic context while preserving `query` for lexical matching.
|
|
261
33
|
|
|
262
|
-
|
|
263
|
-
resulting tarball in the consumer project. See [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
264
|
-
for development and [RELEASING.md](RELEASING.md) for the release policy.
|
|
34
|
+
Use one writer per fork across runtimes and LambdaDB client instances. The SDK serializes writes to a fork within one client instance. It confirms the original and chunks with a consistent branch read before returning success. Batch writes can apply in parts. A file whose chunks require multiple requests becomes visible when its original is written after the earlier chunk requests are confirmed. If the request may have been accepted but the SDK cannot confirm it, the error code is `WRITE_UNCONFIRMED`. Its details identify the attempted files and any earlier confirmed files so the caller can inspect the fork. The handle blocks another create at that path until it observes an existing file there. This protection is local to the client instance. A replacement writer must confirm that the earlier request has settled before using that path.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunking.d.ts","sourceRoot":"","sources":["../../src/chunking.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"chunking.d.ts","sourceRoot":"","sources":["../../src/chunking.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,CAAC,CA4B1F"}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CHUNKING_POLICY = void 0;
|
|
4
3
|
exports.chunkSpans = chunkSpans;
|
|
5
4
|
// Exact source partitions: UTF-16 offsets for slice(), a Unicode-code-point cap.
|
|
6
5
|
// English sentence detection is deliberate; other languages are not optimized.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (!Number.isInteger(limit) || limit < 1)
|
|
10
|
-
throw new RangeError('Chunk limit must be a positive integer.');
|
|
6
|
+
function chunkSpans(text) {
|
|
7
|
+
const limit = 800;
|
|
11
8
|
const offsets = [0];
|
|
12
9
|
for (const char of text)
|
|
13
10
|
offsets.push(offsets.at(-1) + char.length);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunking.js","sourceRoot":"","sources":["../../src/chunking.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chunking.js","sourceRoot":"","sources":["../../src/chunking.ts"],"names":[],"mappings":";;AAEA,gCA4BC;AA9BD,iFAAiF;AACjF,+EAA+E;AAC/E,SAAgB,UAAU,CAAC,IAAY;IACnC,MAAM,KAAK,GAAG,GAAG,CAAC;IAClB,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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AM,KAAK,GAAsD,EAAE,CAAC;IACpE,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC;QAC9C,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,KAAK,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAE,CAAC;QAClF,IAAI,GAAG,GAAG,OAAO,CAAC,IAAI,CAAE,CAAC;QACzB,IAAI,IAAI,GAAG,OAAO,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 IndexConfigsUnion } from '@functional-systems/lambdadb/models/indexconfigsunion.js';
|
|
2
|
+
import type { CreateFileStoreOptions, FileStoreDescription, Metadata, MetadataSchema } from './types.js';
|
|
3
|
+
export declare const isObject: (value: unknown) => value is Record<string, unknown>;
|
|
4
|
+
export declare const keysOnly: (value: unknown, keys: string[]) => value is Record<string, unknown>;
|
|
5
|
+
export declare const formatTag = "memdrive.format";
|
|
6
|
+
export declare const format = "files-v0";
|
|
7
|
+
export declare const validDate: (value: unknown) => value is string;
|
|
8
|
+
export declare function metadataValues(value: unknown, schema: MetadataSchema): Metadata | undefined;
|
|
9
|
+
export declare function storeConfiguration(options: CreateFileStoreOptions): {
|
|
10
|
+
indexConfigs: Record<string, IndexConfigsUnion>;
|
|
11
|
+
tags: {
|
|
12
|
+
"memdrive.format": string;
|
|
13
|
+
};
|
|
14
|
+
description: FileStoreDescription;
|
|
15
|
+
};
|
|
16
|
+
export declare function parseStore(collection: unknown, name: string): FileStoreDescription;
|
|
17
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,iBAAiB,EAAE,MAAM,0DAA0D,CAAC;AAC5G,OAAO,KAAK,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGzG,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CACsB,CAAC;AAChG,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,EAAE,MAAM,MAAM,EAAE,KAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CACf,CAAC;AAE3E,eAAO,MAAM,SAAS,oBAAoB,CAAC;AAC3C,eAAO,MAAM,MAAM,aAAa,CAAC;AAcjC,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAE8B,CAAC;AA4BnF,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,GAAG,QAAQ,GAAG,SAAS,CAY3F;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,sBAAsB;;;;;;EAkBjE;AAED,wBAAgB,UAAU,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,oBAAoB,CAgClF"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validDate = exports.format = exports.formatTag = exports.keysOnly = exports.isObject = void 0;
|
|
4
|
+
exports.metadataValues = metadataValues;
|
|
5
|
+
exports.storeConfiguration = storeConfiguration;
|
|
6
|
+
exports.parseStore = parseStore;
|
|
7
|
+
const indexconfigsunion_js_1 = require("@functional-systems/lambdadb/models/indexconfigsunion.js");
|
|
8
|
+
const errors_js_1 = require("./errors.js");
|
|
9
|
+
const isObject = (value) => value !== null && typeof value === 'object'
|
|
10
|
+
&& !Array.isArray(value) && [Object.prototype, null].includes(Object.getPrototypeOf(value));
|
|
11
|
+
exports.isObject = isObject;
|
|
12
|
+
const keysOnly = (value, keys) => (0, exports.isObject)(value) && Object.keys(value).every(key => keys.includes(key));
|
|
13
|
+
exports.keysOnly = keysOnly;
|
|
14
|
+
exports.formatTag = 'memdrive.format';
|
|
15
|
+
exports.format = 'files-v0';
|
|
16
|
+
const managedEmbedding = { mode: 'managed', provider: 'openai', model: 'text-embedding-3-small',
|
|
17
|
+
dimensions: 1536, similarity: 'cosine' };
|
|
18
|
+
const fileIndexes = {
|
|
19
|
+
kind: { type: 'keyword' },
|
|
20
|
+
path: { type: 'keyword' },
|
|
21
|
+
fileName: { type: 'keyword' },
|
|
22
|
+
ancestorPaths: { type: 'keyword' },
|
|
23
|
+
changed: { type: 'boolean' },
|
|
24
|
+
modifiedAt: { type: 'datetime' },
|
|
25
|
+
};
|
|
26
|
+
const indexTypes = { string: 'keyword', number: 'double', boolean: 'boolean', datetime: 'datetime' };
|
|
27
|
+
const supportedAnalyzers = new Set(Object.values(indexconfigsunion_js_1.Analyzer));
|
|
28
|
+
const validDate = (value) => typeof value === 'string'
|
|
29
|
+
&& /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(value)
|
|
30
|
+
&& !Number.isNaN(Date.parse(value)) && new Date(value).toISOString() === value;
|
|
31
|
+
exports.validDate = validDate;
|
|
32
|
+
function labelEntries(value = {}) {
|
|
33
|
+
// Match the native tag restrictions, including Java's definition of whitespace.
|
|
34
|
+
// eslint-disable-next-line no-control-regex
|
|
35
|
+
const blank = /^[\u0009-\u000d\u001c-\u0020\u1680\u2000-\u2006\u2008-\u200a\u2028\u2029\u205f\u3000]*$/u;
|
|
36
|
+
(0, errors_js_1.requireInput)((0, exports.isObject)(value) && Object.keys(value).length <= 4 && Object.entries(value).every(([key, item]) => /^[A-Za-z0-9_.-]{1,63}$/.test(key) && !key.startsWith('memdrive.') && typeof item === 'string'
|
|
37
|
+
&& item.length <= 127 && !/[:#,]/.test(item) && !blank.test(item)), 'Labels must use native-safe names and values. memdrive.* names are reserved.');
|
|
38
|
+
return { ...value };
|
|
39
|
+
}
|
|
40
|
+
function schemaEntries(value = {}) {
|
|
41
|
+
(0, errors_js_1.requireInput)((0, exports.isObject)(value) && Object.entries(value).every(([key, entry]) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(key) && !['id', 'constructor', 'prototype', '__proto__'].includes(key)
|
|
42
|
+
&& (0, exports.keysOnly)(entry, ['type', 'description']) && typeof entry.type === 'string' && Object.hasOwn(indexTypes, entry.type)
|
|
43
|
+
&& (entry.description === undefined || (typeof entry.description === 'string' && entry.description.length <= 255))), 'Metadata schema requires named scalar types and optional field descriptions.');
|
|
44
|
+
return structuredClone(value);
|
|
45
|
+
}
|
|
46
|
+
function textAnalyzers(value = { analyzers: ['standard'] }) {
|
|
47
|
+
(0, errors_js_1.requireInput)((0, exports.keysOnly)(value, ['analyzers']) && Array.isArray(value.analyzers) && value.analyzers.length > 0
|
|
48
|
+
&& new Set(value.analyzers).size === value.analyzers.length && [...value.analyzers].every(item => supportedAnalyzers.has(item)), 'Set a nonempty array of distinct supported text analyzers.');
|
|
49
|
+
return [...value.analyzers];
|
|
50
|
+
}
|
|
51
|
+
function metadataValues(value, schema) {
|
|
52
|
+
if (value === undefined)
|
|
53
|
+
return undefined;
|
|
54
|
+
(0, errors_js_1.requireInput)((0, exports.isObject)(value) && Object.entries(value).every(([key, item]) => {
|
|
55
|
+
if (!Object.hasOwn(schema, key))
|
|
56
|
+
return false;
|
|
57
|
+
switch (schema[key].type) {
|
|
58
|
+
case 'string': return typeof item === 'string' && item.length <= 4096 && !/\p{Surrogate}/u.test(item);
|
|
59
|
+
case 'number': return typeof item === 'number' && Number.isFinite(item);
|
|
60
|
+
case 'boolean': return typeof item === 'boolean';
|
|
61
|
+
case 'datetime': return (0, exports.validDate)(item);
|
|
62
|
+
}
|
|
63
|
+
}), 'Metadata values must match their declared scalar types. Datetimes use ISO UTC with milliseconds.');
|
|
64
|
+
return { ...value };
|
|
65
|
+
}
|
|
66
|
+
function storeConfiguration(options) {
|
|
67
|
+
const name = options.name;
|
|
68
|
+
const metadataSchema = schemaEntries(options.metadataSchema);
|
|
69
|
+
const labels = labelEntries(options.labels);
|
|
70
|
+
const analyzers = textAnalyzers(options.textSearch);
|
|
71
|
+
const indexConfigs = {
|
|
72
|
+
...fileIndexes,
|
|
73
|
+
body: { type: 'text', analyzers },
|
|
74
|
+
content: { type: 'text', analyzers },
|
|
75
|
+
embedding: { type: 'vector', managedEmbedding: true, embedding: {
|
|
76
|
+
provider: managedEmbedding.provider, model: managedEmbedding.model, dimensions: managedEmbedding.dimensions,
|
|
77
|
+
similarity: managedEmbedding.similarity, sourceField: 'content',
|
|
78
|
+
} },
|
|
79
|
+
};
|
|
80
|
+
if (Object.keys(metadataSchema).length)
|
|
81
|
+
indexConfigs.metadata = { type: 'object', objectIndexConfigs: Object.fromEntries(Object.entries(metadataSchema).map(([key, value]) => [key, { ...value, type: indexTypes[value.type] }])) };
|
|
82
|
+
const description = { name, labels, metadataSchema, textSearch: { analyzers }, embedding: { ...managedEmbedding } };
|
|
83
|
+
return { indexConfigs, tags: { ...labels, [exports.formatTag]: exports.format }, description };
|
|
84
|
+
}
|
|
85
|
+
function parseStore(collection, name) {
|
|
86
|
+
try {
|
|
87
|
+
(0, errors_js_1.requireInput)((0, exports.isObject)(collection) && collection.collectionName === name && collection.defaultBranchName === 'main'
|
|
88
|
+
&& (0, exports.isObject)(collection.tags) && collection.tags[exports.formatTag] === exports.format && (0, exports.isObject)(collection.indexConfigs), 'Collection format or main branch is incompatible.');
|
|
89
|
+
const { tags, indexConfigs } = collection;
|
|
90
|
+
const labels = labelEntries(Object.fromEntries(Object.entries(tags).filter(([key]) => key !== exports.formatTag)));
|
|
91
|
+
(0, errors_js_1.requireInput)(Object.entries(fileIndexes).every(([field, config]) => (0, exports.isObject)(indexConfigs[field])
|
|
92
|
+
&& indexConfigs[field].type === config.type), 'Required file indexes are missing.');
|
|
93
|
+
const { embedding, content, body, metadata } = indexConfigs;
|
|
94
|
+
(0, errors_js_1.requireInput)((0, exports.isObject)(embedding) && embedding.type === 'vector' && embedding.managedEmbedding !== false && (0, exports.isObject)(embedding.embedding)
|
|
95
|
+
&& embedding.embedding.provider === managedEmbedding.provider && embedding.embedding.model === managedEmbedding.model
|
|
96
|
+
&& embedding.embedding.dimensions === managedEmbedding.dimensions && embedding.embedding.similarity === managedEmbedding.similarity
|
|
97
|
+
&& embedding.embedding.sourceField === 'content', 'Managed chunk embedding index is incompatible.');
|
|
98
|
+
(0, errors_js_1.requireInput)((0, exports.isObject)(content) && content.type === 'text' && (0, exports.isObject)(body) && body.type === 'text', 'Text indexes are missing.');
|
|
99
|
+
const analyzers = textAnalyzers({ analyzers: content.analyzers ?? ['standard'] });
|
|
100
|
+
(0, errors_js_1.requireInput)(JSON.stringify(analyzers) === JSON.stringify(textAnalyzers({ analyzers: body.analyzers ?? ['standard'] })), 'Original and chunk analyzers must match.');
|
|
101
|
+
let metadataSchema = {};
|
|
102
|
+
if (metadata !== undefined) {
|
|
103
|
+
(0, errors_js_1.requireInput)((0, exports.isObject)(metadata) && metadata.type === 'object' && (0, exports.isObject)(metadata.objectIndexConfigs), 'Metadata index is incompatible.');
|
|
104
|
+
metadataSchema = schemaEntries(Object.fromEntries(Object.entries(metadata.objectIndexConfigs).map(([key, value]) => {
|
|
105
|
+
(0, errors_js_1.requireInput)((0, exports.isObject)(value), 'Invalid metadata field index.');
|
|
106
|
+
return [key, { type: Object.entries(indexTypes).find(([, native]) => native === value.type)?.[0],
|
|
107
|
+
...(value.description === undefined ? {} : { description: value.description }) }];
|
|
108
|
+
})));
|
|
109
|
+
}
|
|
110
|
+
return { name, labels, metadataSchema, textSearch: { analyzers }, embedding: { ...managedEmbedding } };
|
|
111
|
+
}
|
|
112
|
+
catch (cause) {
|
|
113
|
+
throw new errors_js_1.MemDriveError('INCOMPATIBLE_STORE', 'The collection is not a compatible MemDrive file store.', { cause });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":";;;AAsDA,wCAYC;AAED,gDAkBC;AAED,gCAgCC;AAxHD,mGAA4G;AAE5G,2CAA0D;AAEnD,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;OAClH,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;AADnF,QAAA,QAAQ,YAC2E;AACzF,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAE,IAAc,EAAoC,EAAE,CACzF,IAAA,gBAAQ,EAAC,KAAK,CAAC,IAAI,MAAM,CAAC,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C;QACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,EAAE,GAAG,gBAAgB,EAAE,EAAE,CAAC;IAC3G,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,MAAM,IAAI,yBAAa,CAAC,oBAAoB,EAAE,yDAAyD,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACxH,CAAC;AACL,CAAC"}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import type { RequestOptions
|
|
1
|
+
import type { RequestOptions } from './types.js';
|
|
2
2
|
export declare class MemDriveError extends Error {
|
|
3
3
|
code: string;
|
|
4
|
-
details?: Record<string, unknown> | undefined;
|
|
5
|
-
usage?: Usage | undefined;
|
|
4
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
6
5
|
status?: number | undefined;
|
|
7
|
-
constructor(code: string, message: string, { cause, details
|
|
6
|
+
constructor(code: string, message: string, { cause, details }?: {
|
|
8
7
|
cause?: unknown;
|
|
9
8
|
details?: Record<string, unknown> | undefined;
|
|
10
|
-
usage?: Usage | undefined;
|
|
11
9
|
});
|
|
12
10
|
}
|
|
13
11
|
export declare function requireInput(condition: unknown, message: string): asserts condition;
|
|
14
12
|
export declare function operationOptions(options?: RequestOptions): RequestOptions;
|
|
15
13
|
export declare function checkAbort(signal?: AbortSignal): void;
|
|
16
|
-
export declare function
|
|
14
|
+
export declare function databaseError(error: unknown, message: string): MemDriveError;
|
|
15
|
+
export declare function nativeRequest<T>(operation: () => Promise<T>, signal?: AbortSignal): Promise<T>;
|
|
16
|
+
export declare const nativeOptions: (signal?: AbortSignal) => {
|
|
17
|
+
signal?: never;
|
|
18
|
+
} | {
|
|
19
|
+
signal: AbortSignal;
|
|
20
|
+
};
|
|
17
21
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,qBAAa,aAAc,SAAQ,KAAK;IAC5B,IAAI,EAAE,MAAM,CAAC;IACrB,SAAiB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IACvD,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;gBACxB,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,GAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;KAAO;CAMzI;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;AASD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,CAO5E;AAED,wBAAsB,aAAa,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAIpG;AACD,eAAO,MAAM,aAAa,GAAI,SAAS,WAAW;;;;CAA2C,CAAC"}
|
package/dist/commonjs/errors.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MemDriveError = void 0;
|
|
3
|
+
exports.nativeOptions = exports.MemDriveError = void 0;
|
|
4
4
|
exports.requireInput = requireInput;
|
|
5
5
|
exports.operationOptions = operationOptions;
|
|
6
6
|
exports.checkAbort = checkAbort;
|
|
7
|
-
exports.
|
|
7
|
+
exports.databaseError = databaseError;
|
|
8
|
+
exports.nativeRequest = nativeRequest;
|
|
8
9
|
class MemDriveError extends Error {
|
|
9
|
-
constructor(code, message, { cause, details
|
|
10
|
+
constructor(code, message, { cause, details } = {}) {
|
|
10
11
|
super(message, cause === undefined ? undefined : { cause });
|
|
11
12
|
this.name = 'MemDriveError';
|
|
12
13
|
this.code = code;
|
|
13
14
|
if (details !== undefined)
|
|
14
15
|
this.details = details;
|
|
15
|
-
if (usage !== undefined)
|
|
16
|
-
this.usage = usage;
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
exports.MemDriveError = MemDriveError;
|
|
@@ -41,4 +40,25 @@ function abortError(cause, signal) {
|
|
|
41
40
|
return signal?.aborted || error?.name === 'AbortError'
|
|
42
41
|
? new MemDriveError('ABORTED', 'Operation aborted.', { cause }) : cause;
|
|
43
42
|
}
|
|
43
|
+
function databaseError(error, message) {
|
|
44
|
+
if (error instanceof MemDriveError)
|
|
45
|
+
return error;
|
|
46
|
+
const result = new MemDriveError('DATABASE_ERROR', message, { cause: error });
|
|
47
|
+
const remote = error;
|
|
48
|
+
const status = remote?.statusCode ?? remote?.status ?? remote?.httpStatus;
|
|
49
|
+
if (typeof status === 'number' && Number.isInteger(status))
|
|
50
|
+
result.status = status;
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
async function nativeRequest(operation, signal) {
|
|
54
|
+
checkAbort(signal);
|
|
55
|
+
try {
|
|
56
|
+
return await operation();
|
|
57
|
+
}
|
|
58
|
+
catch (cause) {
|
|
59
|
+
throw abortError(cause, signal);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const nativeOptions = (signal) => signal === undefined ? {} : { signal };
|
|
63
|
+
exports.nativeOptions = nativeOptions;
|
|
44
64
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AAcA,oCAEC;AAED,4CAQC;AAED,gCAEC;AASD,sCAOC;AAED,sCAIC;AAlDD,MAAa,aAAc,SAAQ,KAAK;IAIpC,YAAY,IAAY,EAAE,OAAe,EAAE,EAAE,KAAK,EAAE,OAAO,KAAyE,EAAE;QAClI,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;IACtD,CAAC;CACJ;AAVD,sCAUC;AAED,SAAgB,YAAY,CAAC,SAAkB,EAAE,OAAe;IAC5D,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,aAAa,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;AACtE,CAAC;AAED,SAAgB,gBAAgB,CAAC,UAA0B,EAAE;IACzD,YAAY,CAAC,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;WAChF,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,QAAQ,CAAC,EAAE,uCAAuC,CAAC,CAAC;IACrG,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3B,YAAY,CAAC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