mindcache 3.4.3 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/dist/{CloudAdapter-CJS3Sh4f.d.mts → CloudAdapter-CM7nyJaG.d.mts} +85 -25
- package/dist/{CloudAdapter-CJS3Sh4f.d.ts → CloudAdapter-CM7nyJaG.d.ts} +85 -25
- package/dist/cloud/index.d.mts +2 -2
- package/dist/cloud/index.d.ts +2 -2
- package/dist/cloud/index.js +1105 -729
- package/dist/cloud/index.js.map +1 -1
- package/dist/cloud/index.mjs +1105 -729
- package/dist/cloud/index.mjs.map +1 -1
- package/dist/index.d.mts +125 -3
- package/dist/index.d.ts +125 -3
- package/dist/index.js +1527 -832
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1526 -833
- package/dist/index.mjs.map +1 -1
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +1105 -731
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +1105 -731
- package/dist/server.mjs.map +1 -1
- package/docs/mindcache-api.md +148 -0
- package/package.json +3 -2
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# MindCache
|
|
2
|
+
|
|
3
|
+
A TypeScript library for managing short-term memory in AI agents through an LLM-friendly key-value repository.
|
|
4
|
+
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
* **[API Reference](./docs/mindcache-api.md)**: Detailed method signatures and type definitions. Optimized for AI agents (like Cursor, Claude, etc.) to understand the library's capabilities.
|
|
8
|
+
* **[Full Documentation](https://mindcache.dev/llms-full.md)**: Comprehensive guide with examples and deep dives.
|
|
9
|
+
|
|
10
|
+
## Quick Start
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { mindcache } from 'mindcache';
|
|
14
|
+
|
|
15
|
+
// Store values
|
|
16
|
+
mindcache.set_value('userName', 'Alice');
|
|
17
|
+
|
|
18
|
+
// Generate tools for Vercel AI SDK
|
|
19
|
+
const tools = mindcache.get_aisdk_tools();
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
See the [root README](../../README.md) for more details.
|
|
@@ -3,18 +3,30 @@ import * as Y from 'yjs';
|
|
|
3
3
|
/**
|
|
4
4
|
* Access level for MindCache operations
|
|
5
5
|
* - 'user': Can only manage content tags (default)
|
|
6
|
-
* - '
|
|
6
|
+
* - 'admin': Can manage both content tags and system tags
|
|
7
7
|
*/
|
|
8
|
-
type AccessLevel = 'user' | '
|
|
8
|
+
type AccessLevel = 'user' | 'admin';
|
|
9
|
+
/**
|
|
10
|
+
* Context rules for filtering keys by contentTags.
|
|
11
|
+
* When context is set, only keys matching ALL specified tags are visible.
|
|
12
|
+
* Context is client-local and not persisted.
|
|
13
|
+
*/
|
|
14
|
+
interface ContextRules {
|
|
15
|
+
/** Tags that a key must have (AND logic - all tags must match) */
|
|
16
|
+
tags: string[];
|
|
17
|
+
/** Default contentTags added to keys created via create_key() in this context */
|
|
18
|
+
defaultContentTags?: string[];
|
|
19
|
+
/** Default systemTags added to keys created via create_key() in this context */
|
|
20
|
+
defaultSystemTags?: SystemTag[];
|
|
21
|
+
}
|
|
9
22
|
/**
|
|
10
23
|
* Known system tags that control key behavior
|
|
11
24
|
* - 'SystemPrompt': Include in system prompt (visible to LLM context)
|
|
12
25
|
* - 'LLMRead': LLM can read this key via tools
|
|
13
26
|
* - 'LLMWrite': LLM can write to this key via tools
|
|
14
|
-
* - 'protected': Cannot be deleted
|
|
15
27
|
* - 'ApplyTemplate': Process value through template injection
|
|
16
28
|
*/
|
|
17
|
-
type SystemTag = 'SystemPrompt' | 'LLMRead' | 'LLMWrite' | '
|
|
29
|
+
type SystemTag = 'SystemPrompt' | 'LLMRead' | 'LLMWrite' | 'ApplyTemplate';
|
|
18
30
|
/**
|
|
19
31
|
* Type of value stored in a MindCache key
|
|
20
32
|
*/
|
|
@@ -91,8 +103,6 @@ declare const SystemTagHelpers: {
|
|
|
91
103
|
isLLMReadable: (attrs: KeyAttributes) => boolean;
|
|
92
104
|
/** Check if key is included in system prompt */
|
|
93
105
|
isInSystemPrompt: (attrs: KeyAttributes) => boolean;
|
|
94
|
-
/** Check if key is protected from deletion */
|
|
95
|
-
isProtected: (attrs: KeyAttributes) => boolean;
|
|
96
106
|
/** Check if key uses template injection */
|
|
97
107
|
hasTemplateInjection: (attrs: KeyAttributes) => boolean;
|
|
98
108
|
};
|
|
@@ -101,8 +111,8 @@ declare const SystemTagHelpers: {
|
|
|
101
111
|
* Cloud configuration options for MindCache constructor
|
|
102
112
|
*/
|
|
103
113
|
interface MindCacheCloudOptions {
|
|
104
|
-
/** Instance ID to connect to */
|
|
105
|
-
instanceId
|
|
114
|
+
/** Instance ID to connect to (not needed for OAuth - auto-provisioned) */
|
|
115
|
+
instanceId?: string;
|
|
106
116
|
/** Project ID (optional, defaults to 'default') */
|
|
107
117
|
projectId?: string;
|
|
108
118
|
/** API endpoint to fetch WS token (recommended for browser) */
|
|
@@ -113,6 +123,20 @@ interface MindCacheCloudOptions {
|
|
|
113
123
|
apiKey?: string;
|
|
114
124
|
/** WebSocket base URL (defaults to production) */
|
|
115
125
|
baseUrl?: string;
|
|
126
|
+
/**
|
|
127
|
+
* OAuth configuration for browser apps using "Sign in with MindCache"
|
|
128
|
+
* When set, user authentication and instance provisioning is automatic
|
|
129
|
+
*/
|
|
130
|
+
oauth?: {
|
|
131
|
+
/** Client ID from MindCache developer portal */
|
|
132
|
+
clientId: string;
|
|
133
|
+
/** Redirect URI for OAuth callback (defaults to current URL) */
|
|
134
|
+
redirectUri?: string;
|
|
135
|
+
/** Scopes to request (default: ['read', 'write']) */
|
|
136
|
+
scopes?: string[];
|
|
137
|
+
/** Auto-redirect to login if not authenticated (default: false) */
|
|
138
|
+
autoLogin?: boolean;
|
|
139
|
+
};
|
|
116
140
|
}
|
|
117
141
|
interface MindCacheIndexedDBOptions {
|
|
118
142
|
/** Database name (defaults to 'mindcache_db') */
|
|
@@ -134,24 +158,27 @@ interface MindCacheOptions {
|
|
|
134
158
|
indexedDB?: MindCacheIndexedDBOptions;
|
|
135
159
|
/** History tracking options (enabled in IndexedDB and Cloud modes) */
|
|
136
160
|
history?: HistoryOptions;
|
|
137
|
-
/** Access level for tag operations. '
|
|
161
|
+
/** Access level for tag operations. 'admin' allows managing system tags. */
|
|
138
162
|
accessLevel?: AccessLevel;
|
|
139
163
|
/** Optional existing Y.Doc instance (for server-side hydration) */
|
|
140
164
|
doc?: Y.Doc;
|
|
165
|
+
/** Context filtering rules. When set, only keys matching the rules are visible. */
|
|
166
|
+
context?: ContextRules;
|
|
141
167
|
}
|
|
142
168
|
type ConnectionState$1 = 'disconnected' | 'connecting' | 'connected' | 'error';
|
|
143
169
|
declare class MindCache {
|
|
144
170
|
doc: Y.Doc;
|
|
145
|
-
|
|
171
|
+
rootMap: Y.Map<Y.Map<any>>;
|
|
146
172
|
private listeners;
|
|
147
173
|
private globalListeners;
|
|
148
174
|
readonly version = "3.3.2";
|
|
149
|
-
|
|
175
|
+
normalizeSystemTags(tags: SystemTag[]): SystemTag[];
|
|
150
176
|
private _cloudAdapter;
|
|
151
177
|
private _connectionState;
|
|
152
178
|
private _isLoaded;
|
|
153
179
|
private _cloudConfig;
|
|
154
180
|
private _accessLevel;
|
|
181
|
+
private _contextRules;
|
|
155
182
|
private _initPromise;
|
|
156
183
|
private _idbProvider;
|
|
157
184
|
private _undoManagers;
|
|
@@ -206,6 +233,36 @@ declare class MindCache {
|
|
|
206
233
|
restoreToVersion(_versionId: string): boolean;
|
|
207
234
|
get accessLevel(): AccessLevel;
|
|
208
235
|
get hasSystemAccess(): boolean;
|
|
236
|
+
/**
|
|
237
|
+
* Check if context filtering is currently active.
|
|
238
|
+
*/
|
|
239
|
+
get hasContext(): boolean;
|
|
240
|
+
/**
|
|
241
|
+
* Get current context rules, or null if no context is set.
|
|
242
|
+
*/
|
|
243
|
+
get_context(): ContextRules | null;
|
|
244
|
+
/**
|
|
245
|
+
* Set context filtering rules.
|
|
246
|
+
* When context is set, only keys with ALL specified tags are visible.
|
|
247
|
+
*
|
|
248
|
+
* @param rules - Context rules, or array of tags (shorthand for { tags: [...] })
|
|
249
|
+
*/
|
|
250
|
+
set_context(rules: ContextRules | string[]): void;
|
|
251
|
+
/**
|
|
252
|
+
* Clear context filtering. All keys become visible again.
|
|
253
|
+
*/
|
|
254
|
+
reset_context(): void;
|
|
255
|
+
/**
|
|
256
|
+
* Check if a key matches the current context rules.
|
|
257
|
+
* Returns true if no context is set.
|
|
258
|
+
*/
|
|
259
|
+
keyMatchesContext(key: string): boolean;
|
|
260
|
+
/**
|
|
261
|
+
* Create a new key with optional default tags from context.
|
|
262
|
+
*
|
|
263
|
+
* @throws Error if key already exists
|
|
264
|
+
*/
|
|
265
|
+
create_key(key: string, value: any, attributes?: Partial<KeyAttributes>): void;
|
|
209
266
|
private _initCloud;
|
|
210
267
|
private _initYIndexedDB;
|
|
211
268
|
private _initIndexedDB;
|
|
@@ -245,8 +302,9 @@ declare class MindCache {
|
|
|
245
302
|
/**
|
|
246
303
|
* Update only the attributes of a key without modifying the value.
|
|
247
304
|
* Useful for updating tags, permissions etc. on document type keys.
|
|
305
|
+
* @returns true if attributes were updated, false if key doesn't exist or is protected
|
|
248
306
|
*/
|
|
249
|
-
set_attributes(key: string, attributes: Partial<KeyAttributes>):
|
|
307
|
+
set_attributes(key: string, attributes: Partial<KeyAttributes>): boolean;
|
|
250
308
|
set_value(key: string, value: any, attributes?: Partial<KeyAttributes>): void;
|
|
251
309
|
/**
|
|
252
310
|
* LLM-safe method to write a value to a key.
|
|
@@ -283,15 +341,15 @@ declare class MindCache {
|
|
|
283
341
|
*/
|
|
284
342
|
size(): number;
|
|
285
343
|
/**
|
|
286
|
-
* Get all keys in MindCache
|
|
344
|
+
* Get all keys in MindCache.
|
|
287
345
|
*/
|
|
288
346
|
keys(): string[];
|
|
289
347
|
/**
|
|
290
|
-
* Get all values in MindCache
|
|
348
|
+
* Get all values in MindCache.
|
|
291
349
|
*/
|
|
292
350
|
values(): any[];
|
|
293
351
|
/**
|
|
294
|
-
* Get all key-value entries
|
|
352
|
+
* Get all key-value entries.
|
|
295
353
|
*/
|
|
296
354
|
entries(): Array<[string, any]>;
|
|
297
355
|
/**
|
|
@@ -306,7 +364,6 @@ declare class MindCache {
|
|
|
306
364
|
getSTM(): string;
|
|
307
365
|
/**
|
|
308
366
|
* Get the STM as an object with values directly (no attributes).
|
|
309
|
-
* Includes system keys ($date, $time).
|
|
310
367
|
* @deprecated Use getAll() for full STM format
|
|
311
368
|
*/
|
|
312
369
|
getSTMObject(): Record<string, any>;
|
|
@@ -342,7 +399,7 @@ declare class MindCache {
|
|
|
342
399
|
getKeysByTag(tag: string): string[];
|
|
343
400
|
/**
|
|
344
401
|
* Add a system tag to a key (requires system access).
|
|
345
|
-
* System tags: 'SystemPrompt', 'LLMRead', 'LLMWrite', '
|
|
402
|
+
* System tags: 'SystemPrompt', 'LLMRead', 'LLMWrite', 'ApplyTemplate'
|
|
346
403
|
*/
|
|
347
404
|
systemAddTag(key: string, tag: SystemTag): boolean;
|
|
348
405
|
/**
|
|
@@ -367,8 +424,9 @@ declare class MindCache {
|
|
|
367
424
|
systemGetKeysByTag(tag: SystemTag): string[];
|
|
368
425
|
/**
|
|
369
426
|
* Helper to get sorted keys (by zIndex).
|
|
427
|
+
* Respects context filtering when set.
|
|
370
428
|
*/
|
|
371
|
-
|
|
429
|
+
getSortedKeys(): string[];
|
|
372
430
|
/**
|
|
373
431
|
* Serialize to JSON string.
|
|
374
432
|
*/
|
|
@@ -383,8 +441,10 @@ declare class MindCache {
|
|
|
383
441
|
toMarkdown(): string;
|
|
384
442
|
/**
|
|
385
443
|
* Import from Markdown format.
|
|
444
|
+
* @param markdown The markdown string to import
|
|
445
|
+
* @param merge If false (default), clears existing data before importing. If true, merges with existing data.
|
|
386
446
|
*/
|
|
387
|
-
fromMarkdown(markdown: string): void;
|
|
447
|
+
fromMarkdown(markdown: string, merge?: boolean): void;
|
|
388
448
|
/**
|
|
389
449
|
* Set base64 binary data.
|
|
390
450
|
*/
|
|
@@ -426,17 +486,17 @@ declare class MindCache {
|
|
|
426
486
|
*/
|
|
427
487
|
delete_text(key: string, index: number, length: number): void;
|
|
428
488
|
/**
|
|
429
|
-
* Replace all text in a document key
|
|
489
|
+
* Replace all text in a document key.
|
|
430
490
|
* Uses diff-based updates when changes are < diffThreshold (default 80%).
|
|
431
491
|
* This preserves concurrent edits and provides better undo granularity.
|
|
432
492
|
*/
|
|
433
|
-
|
|
493
|
+
_replaceDocumentText(key: string, newText: string, diffThreshold?: number): void;
|
|
434
494
|
subscribe(key: string, listener: Listener): () => void;
|
|
435
495
|
subscribeToAll(listener: GlobalListener): () => void;
|
|
436
496
|
unsubscribeFromAll(listener: GlobalListener): void;
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
497
|
+
notifyGlobalListeners(): void;
|
|
498
|
+
sanitizeKeyForTool(key: string): string;
|
|
499
|
+
findKeyFromSanitizedTool(sanitizedKey: string): string | undefined;
|
|
440
500
|
/**
|
|
441
501
|
* Generate Vercel AI SDK compatible tools for writable keys.
|
|
442
502
|
* For document type keys, generates additional tools: append_, insert_, edit_
|
|
@@ -552,4 +612,4 @@ declare class CloudAdapter {
|
|
|
552
612
|
private scheduleReconnect;
|
|
553
613
|
}
|
|
554
614
|
|
|
555
|
-
export { type AccessLevel as A, type CloudConfig as C, type DeleteOperation as D, type GlobalListener as G, type HistoryEntry as H, type KeyAttributes as K, type Listener as L, MindCache as M, type Operation as O, type SetOperation as S, CloudAdapter as a, type ConnectionState as b, type CloudAdapterEvents as c, type ClearOperation as d, type MindCacheOptions as e, type KeyType as f, type SystemTag as g, type
|
|
615
|
+
export { type AccessLevel as A, type CloudConfig as C, type DeleteOperation as D, type GlobalListener as G, type HistoryEntry as H, type KeyAttributes as K, type Listener as L, MindCache as M, type Operation as O, type SetOperation as S, CloudAdapter as a, type ConnectionState as b, type CloudAdapterEvents as c, type ClearOperation as d, type MindCacheOptions as e, type KeyType as f, type SystemTag as g, type ContextRules as h, type STM as i, type STMEntry as j, type HistoryOptions as k, type MindCacheCloudOptions as l, type MindCacheIndexedDBOptions as m, DEFAULT_KEY_ATTRIBUTES as n, SystemTagHelpers as o };
|
|
@@ -3,18 +3,30 @@ import * as Y from 'yjs';
|
|
|
3
3
|
/**
|
|
4
4
|
* Access level for MindCache operations
|
|
5
5
|
* - 'user': Can only manage content tags (default)
|
|
6
|
-
* - '
|
|
6
|
+
* - 'admin': Can manage both content tags and system tags
|
|
7
7
|
*/
|
|
8
|
-
type AccessLevel = 'user' | '
|
|
8
|
+
type AccessLevel = 'user' | 'admin';
|
|
9
|
+
/**
|
|
10
|
+
* Context rules for filtering keys by contentTags.
|
|
11
|
+
* When context is set, only keys matching ALL specified tags are visible.
|
|
12
|
+
* Context is client-local and not persisted.
|
|
13
|
+
*/
|
|
14
|
+
interface ContextRules {
|
|
15
|
+
/** Tags that a key must have (AND logic - all tags must match) */
|
|
16
|
+
tags: string[];
|
|
17
|
+
/** Default contentTags added to keys created via create_key() in this context */
|
|
18
|
+
defaultContentTags?: string[];
|
|
19
|
+
/** Default systemTags added to keys created via create_key() in this context */
|
|
20
|
+
defaultSystemTags?: SystemTag[];
|
|
21
|
+
}
|
|
9
22
|
/**
|
|
10
23
|
* Known system tags that control key behavior
|
|
11
24
|
* - 'SystemPrompt': Include in system prompt (visible to LLM context)
|
|
12
25
|
* - 'LLMRead': LLM can read this key via tools
|
|
13
26
|
* - 'LLMWrite': LLM can write to this key via tools
|
|
14
|
-
* - 'protected': Cannot be deleted
|
|
15
27
|
* - 'ApplyTemplate': Process value through template injection
|
|
16
28
|
*/
|
|
17
|
-
type SystemTag = 'SystemPrompt' | 'LLMRead' | 'LLMWrite' | '
|
|
29
|
+
type SystemTag = 'SystemPrompt' | 'LLMRead' | 'LLMWrite' | 'ApplyTemplate';
|
|
18
30
|
/**
|
|
19
31
|
* Type of value stored in a MindCache key
|
|
20
32
|
*/
|
|
@@ -91,8 +103,6 @@ declare const SystemTagHelpers: {
|
|
|
91
103
|
isLLMReadable: (attrs: KeyAttributes) => boolean;
|
|
92
104
|
/** Check if key is included in system prompt */
|
|
93
105
|
isInSystemPrompt: (attrs: KeyAttributes) => boolean;
|
|
94
|
-
/** Check if key is protected from deletion */
|
|
95
|
-
isProtected: (attrs: KeyAttributes) => boolean;
|
|
96
106
|
/** Check if key uses template injection */
|
|
97
107
|
hasTemplateInjection: (attrs: KeyAttributes) => boolean;
|
|
98
108
|
};
|
|
@@ -101,8 +111,8 @@ declare const SystemTagHelpers: {
|
|
|
101
111
|
* Cloud configuration options for MindCache constructor
|
|
102
112
|
*/
|
|
103
113
|
interface MindCacheCloudOptions {
|
|
104
|
-
/** Instance ID to connect to */
|
|
105
|
-
instanceId
|
|
114
|
+
/** Instance ID to connect to (not needed for OAuth - auto-provisioned) */
|
|
115
|
+
instanceId?: string;
|
|
106
116
|
/** Project ID (optional, defaults to 'default') */
|
|
107
117
|
projectId?: string;
|
|
108
118
|
/** API endpoint to fetch WS token (recommended for browser) */
|
|
@@ -113,6 +123,20 @@ interface MindCacheCloudOptions {
|
|
|
113
123
|
apiKey?: string;
|
|
114
124
|
/** WebSocket base URL (defaults to production) */
|
|
115
125
|
baseUrl?: string;
|
|
126
|
+
/**
|
|
127
|
+
* OAuth configuration for browser apps using "Sign in with MindCache"
|
|
128
|
+
* When set, user authentication and instance provisioning is automatic
|
|
129
|
+
*/
|
|
130
|
+
oauth?: {
|
|
131
|
+
/** Client ID from MindCache developer portal */
|
|
132
|
+
clientId: string;
|
|
133
|
+
/** Redirect URI for OAuth callback (defaults to current URL) */
|
|
134
|
+
redirectUri?: string;
|
|
135
|
+
/** Scopes to request (default: ['read', 'write']) */
|
|
136
|
+
scopes?: string[];
|
|
137
|
+
/** Auto-redirect to login if not authenticated (default: false) */
|
|
138
|
+
autoLogin?: boolean;
|
|
139
|
+
};
|
|
116
140
|
}
|
|
117
141
|
interface MindCacheIndexedDBOptions {
|
|
118
142
|
/** Database name (defaults to 'mindcache_db') */
|
|
@@ -134,24 +158,27 @@ interface MindCacheOptions {
|
|
|
134
158
|
indexedDB?: MindCacheIndexedDBOptions;
|
|
135
159
|
/** History tracking options (enabled in IndexedDB and Cloud modes) */
|
|
136
160
|
history?: HistoryOptions;
|
|
137
|
-
/** Access level for tag operations. '
|
|
161
|
+
/** Access level for tag operations. 'admin' allows managing system tags. */
|
|
138
162
|
accessLevel?: AccessLevel;
|
|
139
163
|
/** Optional existing Y.Doc instance (for server-side hydration) */
|
|
140
164
|
doc?: Y.Doc;
|
|
165
|
+
/** Context filtering rules. When set, only keys matching the rules are visible. */
|
|
166
|
+
context?: ContextRules;
|
|
141
167
|
}
|
|
142
168
|
type ConnectionState$1 = 'disconnected' | 'connecting' | 'connected' | 'error';
|
|
143
169
|
declare class MindCache {
|
|
144
170
|
doc: Y.Doc;
|
|
145
|
-
|
|
171
|
+
rootMap: Y.Map<Y.Map<any>>;
|
|
146
172
|
private listeners;
|
|
147
173
|
private globalListeners;
|
|
148
174
|
readonly version = "3.3.2";
|
|
149
|
-
|
|
175
|
+
normalizeSystemTags(tags: SystemTag[]): SystemTag[];
|
|
150
176
|
private _cloudAdapter;
|
|
151
177
|
private _connectionState;
|
|
152
178
|
private _isLoaded;
|
|
153
179
|
private _cloudConfig;
|
|
154
180
|
private _accessLevel;
|
|
181
|
+
private _contextRules;
|
|
155
182
|
private _initPromise;
|
|
156
183
|
private _idbProvider;
|
|
157
184
|
private _undoManagers;
|
|
@@ -206,6 +233,36 @@ declare class MindCache {
|
|
|
206
233
|
restoreToVersion(_versionId: string): boolean;
|
|
207
234
|
get accessLevel(): AccessLevel;
|
|
208
235
|
get hasSystemAccess(): boolean;
|
|
236
|
+
/**
|
|
237
|
+
* Check if context filtering is currently active.
|
|
238
|
+
*/
|
|
239
|
+
get hasContext(): boolean;
|
|
240
|
+
/**
|
|
241
|
+
* Get current context rules, or null if no context is set.
|
|
242
|
+
*/
|
|
243
|
+
get_context(): ContextRules | null;
|
|
244
|
+
/**
|
|
245
|
+
* Set context filtering rules.
|
|
246
|
+
* When context is set, only keys with ALL specified tags are visible.
|
|
247
|
+
*
|
|
248
|
+
* @param rules - Context rules, or array of tags (shorthand for { tags: [...] })
|
|
249
|
+
*/
|
|
250
|
+
set_context(rules: ContextRules | string[]): void;
|
|
251
|
+
/**
|
|
252
|
+
* Clear context filtering. All keys become visible again.
|
|
253
|
+
*/
|
|
254
|
+
reset_context(): void;
|
|
255
|
+
/**
|
|
256
|
+
* Check if a key matches the current context rules.
|
|
257
|
+
* Returns true if no context is set.
|
|
258
|
+
*/
|
|
259
|
+
keyMatchesContext(key: string): boolean;
|
|
260
|
+
/**
|
|
261
|
+
* Create a new key with optional default tags from context.
|
|
262
|
+
*
|
|
263
|
+
* @throws Error if key already exists
|
|
264
|
+
*/
|
|
265
|
+
create_key(key: string, value: any, attributes?: Partial<KeyAttributes>): void;
|
|
209
266
|
private _initCloud;
|
|
210
267
|
private _initYIndexedDB;
|
|
211
268
|
private _initIndexedDB;
|
|
@@ -245,8 +302,9 @@ declare class MindCache {
|
|
|
245
302
|
/**
|
|
246
303
|
* Update only the attributes of a key without modifying the value.
|
|
247
304
|
* Useful for updating tags, permissions etc. on document type keys.
|
|
305
|
+
* @returns true if attributes were updated, false if key doesn't exist or is protected
|
|
248
306
|
*/
|
|
249
|
-
set_attributes(key: string, attributes: Partial<KeyAttributes>):
|
|
307
|
+
set_attributes(key: string, attributes: Partial<KeyAttributes>): boolean;
|
|
250
308
|
set_value(key: string, value: any, attributes?: Partial<KeyAttributes>): void;
|
|
251
309
|
/**
|
|
252
310
|
* LLM-safe method to write a value to a key.
|
|
@@ -283,15 +341,15 @@ declare class MindCache {
|
|
|
283
341
|
*/
|
|
284
342
|
size(): number;
|
|
285
343
|
/**
|
|
286
|
-
* Get all keys in MindCache
|
|
344
|
+
* Get all keys in MindCache.
|
|
287
345
|
*/
|
|
288
346
|
keys(): string[];
|
|
289
347
|
/**
|
|
290
|
-
* Get all values in MindCache
|
|
348
|
+
* Get all values in MindCache.
|
|
291
349
|
*/
|
|
292
350
|
values(): any[];
|
|
293
351
|
/**
|
|
294
|
-
* Get all key-value entries
|
|
352
|
+
* Get all key-value entries.
|
|
295
353
|
*/
|
|
296
354
|
entries(): Array<[string, any]>;
|
|
297
355
|
/**
|
|
@@ -306,7 +364,6 @@ declare class MindCache {
|
|
|
306
364
|
getSTM(): string;
|
|
307
365
|
/**
|
|
308
366
|
* Get the STM as an object with values directly (no attributes).
|
|
309
|
-
* Includes system keys ($date, $time).
|
|
310
367
|
* @deprecated Use getAll() for full STM format
|
|
311
368
|
*/
|
|
312
369
|
getSTMObject(): Record<string, any>;
|
|
@@ -342,7 +399,7 @@ declare class MindCache {
|
|
|
342
399
|
getKeysByTag(tag: string): string[];
|
|
343
400
|
/**
|
|
344
401
|
* Add a system tag to a key (requires system access).
|
|
345
|
-
* System tags: 'SystemPrompt', 'LLMRead', 'LLMWrite', '
|
|
402
|
+
* System tags: 'SystemPrompt', 'LLMRead', 'LLMWrite', 'ApplyTemplate'
|
|
346
403
|
*/
|
|
347
404
|
systemAddTag(key: string, tag: SystemTag): boolean;
|
|
348
405
|
/**
|
|
@@ -367,8 +424,9 @@ declare class MindCache {
|
|
|
367
424
|
systemGetKeysByTag(tag: SystemTag): string[];
|
|
368
425
|
/**
|
|
369
426
|
* Helper to get sorted keys (by zIndex).
|
|
427
|
+
* Respects context filtering when set.
|
|
370
428
|
*/
|
|
371
|
-
|
|
429
|
+
getSortedKeys(): string[];
|
|
372
430
|
/**
|
|
373
431
|
* Serialize to JSON string.
|
|
374
432
|
*/
|
|
@@ -383,8 +441,10 @@ declare class MindCache {
|
|
|
383
441
|
toMarkdown(): string;
|
|
384
442
|
/**
|
|
385
443
|
* Import from Markdown format.
|
|
444
|
+
* @param markdown The markdown string to import
|
|
445
|
+
* @param merge If false (default), clears existing data before importing. If true, merges with existing data.
|
|
386
446
|
*/
|
|
387
|
-
fromMarkdown(markdown: string): void;
|
|
447
|
+
fromMarkdown(markdown: string, merge?: boolean): void;
|
|
388
448
|
/**
|
|
389
449
|
* Set base64 binary data.
|
|
390
450
|
*/
|
|
@@ -426,17 +486,17 @@ declare class MindCache {
|
|
|
426
486
|
*/
|
|
427
487
|
delete_text(key: string, index: number, length: number): void;
|
|
428
488
|
/**
|
|
429
|
-
* Replace all text in a document key
|
|
489
|
+
* Replace all text in a document key.
|
|
430
490
|
* Uses diff-based updates when changes are < diffThreshold (default 80%).
|
|
431
491
|
* This preserves concurrent edits and provides better undo granularity.
|
|
432
492
|
*/
|
|
433
|
-
|
|
493
|
+
_replaceDocumentText(key: string, newText: string, diffThreshold?: number): void;
|
|
434
494
|
subscribe(key: string, listener: Listener): () => void;
|
|
435
495
|
subscribeToAll(listener: GlobalListener): () => void;
|
|
436
496
|
unsubscribeFromAll(listener: GlobalListener): void;
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
497
|
+
notifyGlobalListeners(): void;
|
|
498
|
+
sanitizeKeyForTool(key: string): string;
|
|
499
|
+
findKeyFromSanitizedTool(sanitizedKey: string): string | undefined;
|
|
440
500
|
/**
|
|
441
501
|
* Generate Vercel AI SDK compatible tools for writable keys.
|
|
442
502
|
* For document type keys, generates additional tools: append_, insert_, edit_
|
|
@@ -552,4 +612,4 @@ declare class CloudAdapter {
|
|
|
552
612
|
private scheduleReconnect;
|
|
553
613
|
}
|
|
554
614
|
|
|
555
|
-
export { type AccessLevel as A, type CloudConfig as C, type DeleteOperation as D, type GlobalListener as G, type HistoryEntry as H, type KeyAttributes as K, type Listener as L, MindCache as M, type Operation as O, type SetOperation as S, CloudAdapter as a, type ConnectionState as b, type CloudAdapterEvents as c, type ClearOperation as d, type MindCacheOptions as e, type KeyType as f, type SystemTag as g, type
|
|
615
|
+
export { type AccessLevel as A, type CloudConfig as C, type DeleteOperation as D, type GlobalListener as G, type HistoryEntry as H, type KeyAttributes as K, type Listener as L, MindCache as M, type Operation as O, type SetOperation as S, CloudAdapter as a, type ConnectionState as b, type CloudAdapterEvents as c, type ClearOperation as d, type MindCacheOptions as e, type KeyType as f, type SystemTag as g, type ContextRules as h, type STM as i, type STMEntry as j, type HistoryOptions as k, type MindCacheCloudOptions as l, type MindCacheIndexedDBOptions as m, DEFAULT_KEY_ATTRIBUTES as n, SystemTagHelpers as o };
|
package/dist/cloud/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MindCache, C as CloudConfig, a as CloudAdapter } from '../CloudAdapter-
|
|
2
|
-
export { d as ClearOperation, c as CloudAdapterEvents, b as ConnectionState, D as DeleteOperation, O as Operation, S as SetOperation } from '../CloudAdapter-
|
|
1
|
+
import { M as MindCache, C as CloudConfig, a as CloudAdapter } from '../CloudAdapter-CM7nyJaG.mjs';
|
|
2
|
+
export { d as ClearOperation, c as CloudAdapterEvents, b as ConnectionState, D as DeleteOperation, O as Operation, S as SetOperation } from '../CloudAdapter-CM7nyJaG.mjs';
|
|
3
3
|
import 'yjs';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/cloud/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MindCache, C as CloudConfig, a as CloudAdapter } from '../CloudAdapter-
|
|
2
|
-
export { d as ClearOperation, c as CloudAdapterEvents, b as ConnectionState, D as DeleteOperation, O as Operation, S as SetOperation } from '../CloudAdapter-
|
|
1
|
+
import { M as MindCache, C as CloudConfig, a as CloudAdapter } from '../CloudAdapter-CM7nyJaG.js';
|
|
2
|
+
export { d as ClearOperation, c as CloudAdapterEvents, b as ConnectionState, D as DeleteOperation, O as Operation, S as SetOperation } from '../CloudAdapter-CM7nyJaG.js';
|
|
3
3
|
import 'yjs';
|
|
4
4
|
|
|
5
5
|
/**
|