mindcache 3.5.3 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -4
- package/dist/{CloudAdapter-DK4YecbV.d.mts → CloudAdapter-PLGvGjoA.d.mts} +86 -7
- package/dist/{CloudAdapter-DK4YecbV.d.ts → CloudAdapter-PLGvGjoA.d.ts} +86 -7
- package/dist/cloud/index.d.mts +2 -2
- package/dist/cloud/index.d.ts +2 -2
- package/dist/cloud/index.js +379 -67
- package/dist/cloud/index.js.map +1 -1
- package/dist/cloud/index.mjs +379 -67
- package/dist/cloud/index.mjs.map +1 -1
- package/dist/index.d.mts +417 -19
- package/dist/index.d.ts +417 -19
- package/dist/index.js +1444 -105
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1433 -101
- 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 +379 -67
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +379 -67
- package/dist/server.mjs.map +1 -1
- package/package.json +5 -9
package/README.md
CHANGED
|
@@ -10,13 +10,38 @@ A TypeScript library for managing short-term memory in AI agents through an LLM-
|
|
|
10
10
|
## Quick Start
|
|
11
11
|
|
|
12
12
|
```typescript
|
|
13
|
-
import {
|
|
13
|
+
import { MindCache } from 'mindcache';
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const mc = new MindCache();
|
|
16
|
+
|
|
17
|
+
// Store values with LLM access
|
|
18
|
+
mc.set_value('userName', 'Alice', {
|
|
19
|
+
systemTags: ['SystemPrompt', 'LLMRead', 'LLMWrite']
|
|
20
|
+
});
|
|
17
21
|
|
|
18
22
|
// Generate tools for Vercel AI SDK
|
|
19
|
-
const tools =
|
|
23
|
+
const tools = mc.create_vercel_ai_tools();
|
|
24
|
+
|
|
25
|
+
// Or for other frameworks (OpenAI, Anthropic, LangChain)
|
|
26
|
+
const rawTools = mc.create_tools();
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Custom Types (v3.6+)
|
|
30
|
+
|
|
31
|
+
Define structured schemas for consistent LLM output:
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
// Register a custom type with Markdown schema
|
|
35
|
+
mc.registerType('Contact', `
|
|
36
|
+
#Contact
|
|
37
|
+
* name: full name
|
|
38
|
+
* email: email address
|
|
39
|
+
* phone: phone number
|
|
40
|
+
`);
|
|
41
|
+
|
|
42
|
+
// Assign type to a key
|
|
43
|
+
mc.set_value('contact_alice', JSON.stringify({ name: 'Alice' }));
|
|
44
|
+
mc.setType('contact_alice', 'Contact');
|
|
20
45
|
```
|
|
21
46
|
|
|
22
47
|
See the [root README](../../README.md) for more details.
|
|
@@ -31,6 +31,26 @@ type SystemTag = 'SystemPrompt' | 'LLMRead' | 'LLMWrite' | 'ApplyTemplate';
|
|
|
31
31
|
* Type of value stored in a MindCache key
|
|
32
32
|
*/
|
|
33
33
|
type KeyType = 'text' | 'image' | 'file' | 'json' | 'document';
|
|
34
|
+
/**
|
|
35
|
+
* A field in a custom type definition
|
|
36
|
+
*/
|
|
37
|
+
interface CustomTypeField {
|
|
38
|
+
/** Field name */
|
|
39
|
+
name: string;
|
|
40
|
+
/** Human-readable description of the field */
|
|
41
|
+
description: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A parsed custom type definition
|
|
45
|
+
*/
|
|
46
|
+
interface CustomTypeDefinition {
|
|
47
|
+
/** Type name (e.g., 'Contact') */
|
|
48
|
+
name: string;
|
|
49
|
+
/** Fields that make up this type */
|
|
50
|
+
fields: CustomTypeField[];
|
|
51
|
+
/** Original markdown schema */
|
|
52
|
+
rawSchema: string;
|
|
53
|
+
}
|
|
34
54
|
/**
|
|
35
55
|
* Attributes that can be set on a MindCache key
|
|
36
56
|
*/
|
|
@@ -45,6 +65,8 @@ interface KeyAttributes {
|
|
|
45
65
|
systemTags: SystemTag[];
|
|
46
66
|
/** Z-index for ordering keys (lower values appear first) */
|
|
47
67
|
zIndex: number;
|
|
68
|
+
/** Custom type name (registered via registerType) */
|
|
69
|
+
customType?: string;
|
|
48
70
|
}
|
|
49
71
|
/**
|
|
50
72
|
* Default attributes for new keys
|
|
@@ -171,7 +193,7 @@ declare class MindCache {
|
|
|
171
193
|
rootMap: Y.Map<Y.Map<any>>;
|
|
172
194
|
private listeners;
|
|
173
195
|
private globalListeners;
|
|
174
|
-
readonly version = "3.
|
|
196
|
+
readonly version = "3.6.0";
|
|
175
197
|
normalizeSystemTags(tags: SystemTag[]): SystemTag[];
|
|
176
198
|
private _cloudAdapter;
|
|
177
199
|
private _connectionState;
|
|
@@ -186,6 +208,7 @@ declare class MindCache {
|
|
|
186
208
|
private _history;
|
|
187
209
|
private _historyOptions;
|
|
188
210
|
private _historyEnabled;
|
|
211
|
+
private _typeRegistry;
|
|
189
212
|
constructor(options?: MindCacheOptions);
|
|
190
213
|
private getUndoManager;
|
|
191
214
|
/**
|
|
@@ -422,6 +445,49 @@ declare class MindCache {
|
|
|
422
445
|
* Get all keys with a specific system tag (requires system access).
|
|
423
446
|
*/
|
|
424
447
|
systemGetKeysByTag(tag: SystemTag): string[];
|
|
448
|
+
/**
|
|
449
|
+
* Register a custom type with a markdown schema definition.
|
|
450
|
+
*
|
|
451
|
+
* Schema format:
|
|
452
|
+
* ```
|
|
453
|
+
* #TypeName
|
|
454
|
+
* * fieldName: description of the field
|
|
455
|
+
* * anotherField: description
|
|
456
|
+
* ```
|
|
457
|
+
*
|
|
458
|
+
* @param name - Type name (e.g., 'Contact')
|
|
459
|
+
* @param schema - Markdown schema definition
|
|
460
|
+
* @throws Error if schema format is invalid
|
|
461
|
+
*/
|
|
462
|
+
registerType(name: string, schema: string): void;
|
|
463
|
+
/**
|
|
464
|
+
* Assign a custom type to a key.
|
|
465
|
+
* The key must exist and the type must be registered.
|
|
466
|
+
* Also sets the underlying type to 'json' since custom types are structured JSON data.
|
|
467
|
+
*
|
|
468
|
+
* @param key - Key to assign type to
|
|
469
|
+
* @param typeName - Registered type name
|
|
470
|
+
* @throws Error if key doesn't exist or type is not registered
|
|
471
|
+
*/
|
|
472
|
+
setType(key: string, typeName: string): void;
|
|
473
|
+
/**
|
|
474
|
+
* Get a registered type schema definition.
|
|
475
|
+
*
|
|
476
|
+
* @param typeName - Type name to look up
|
|
477
|
+
* @returns The type definition or undefined if not registered
|
|
478
|
+
*/
|
|
479
|
+
getTypeSchema(typeName: string): CustomTypeDefinition | undefined;
|
|
480
|
+
/**
|
|
481
|
+
* Get all registered type names.
|
|
482
|
+
*/
|
|
483
|
+
getRegisteredTypes(): string[];
|
|
484
|
+
/**
|
|
485
|
+
* Get the custom type assigned to a key.
|
|
486
|
+
*
|
|
487
|
+
* @param key - Key to check
|
|
488
|
+
* @returns Type name or undefined if no custom type assigned
|
|
489
|
+
*/
|
|
490
|
+
getKeyType(key: string): string | undefined;
|
|
425
491
|
/**
|
|
426
492
|
* Helper to get sorted keys (by zIndex).
|
|
427
493
|
* Respects context filtering when set.
|
|
@@ -497,9 +563,26 @@ declare class MindCache {
|
|
|
497
563
|
notifyGlobalListeners(): void;
|
|
498
564
|
sanitizeKeyForTool(key: string): string;
|
|
499
565
|
findKeyFromSanitizedTool(sanitizedKey: string): string | undefined;
|
|
566
|
+
/**
|
|
567
|
+
* Generate framework-agnostic tools with raw JSON Schema.
|
|
568
|
+
* Works with: OpenAI SDK, Anthropic SDK, LangChain, and other frameworks.
|
|
569
|
+
*
|
|
570
|
+
* Tool format:
|
|
571
|
+
* {
|
|
572
|
+
* description: string,
|
|
573
|
+
* parameters: { type: 'object', properties: {...}, required: [...] },
|
|
574
|
+
* execute: async (args) => result
|
|
575
|
+
* }
|
|
576
|
+
*
|
|
577
|
+
* Security: All tools use llm_set_key internally which:
|
|
578
|
+
* - Only modifies VALUES, never attributes/systemTags
|
|
579
|
+
* - Prevents LLMs from escalating privileges
|
|
580
|
+
*/
|
|
581
|
+
create_tools(): Record<string, any>;
|
|
500
582
|
/**
|
|
501
583
|
* Generate Vercel AI SDK compatible tools for writable keys.
|
|
502
|
-
*
|
|
584
|
+
* Wraps parameters with jsonSchema() for AI SDK v5 compatibility.
|
|
585
|
+
* Use this with: generateText(), streamText() from 'ai' package.
|
|
503
586
|
*
|
|
504
587
|
* Security: All tools use llm_set_key internally which:
|
|
505
588
|
* - Only modifies VALUES, never attributes/systemTags
|
|
@@ -592,10 +675,6 @@ declare class CloudAdapter {
|
|
|
592
675
|
private handleOffline;
|
|
593
676
|
private _synced;
|
|
594
677
|
constructor(config: CloudConfig);
|
|
595
|
-
/**
|
|
596
|
-
* Validate configuration and warn about common mistakes
|
|
597
|
-
*/
|
|
598
|
-
private validateConfig;
|
|
599
678
|
/** Browser network status - instantly updated via navigator.onLine */
|
|
600
679
|
get isOnline(): boolean;
|
|
601
680
|
private setupNetworkDetection;
|
|
@@ -616,4 +695,4 @@ declare class CloudAdapter {
|
|
|
616
695
|
private scheduleReconnect;
|
|
617
696
|
}
|
|
618
697
|
|
|
619
|
-
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
|
|
698
|
+
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 CustomTypeDefinition as e, type MindCacheOptions as f, type KeyType as g, type SystemTag as h, type ContextRules as i, type STM as j, type STMEntry as k, type HistoryOptions as l, type MindCacheCloudOptions as m, type MindCacheIndexedDBOptions as n, type CustomTypeField as o, DEFAULT_KEY_ATTRIBUTES as p, SystemTagHelpers as q };
|
|
@@ -31,6 +31,26 @@ type SystemTag = 'SystemPrompt' | 'LLMRead' | 'LLMWrite' | 'ApplyTemplate';
|
|
|
31
31
|
* Type of value stored in a MindCache key
|
|
32
32
|
*/
|
|
33
33
|
type KeyType = 'text' | 'image' | 'file' | 'json' | 'document';
|
|
34
|
+
/**
|
|
35
|
+
* A field in a custom type definition
|
|
36
|
+
*/
|
|
37
|
+
interface CustomTypeField {
|
|
38
|
+
/** Field name */
|
|
39
|
+
name: string;
|
|
40
|
+
/** Human-readable description of the field */
|
|
41
|
+
description: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A parsed custom type definition
|
|
45
|
+
*/
|
|
46
|
+
interface CustomTypeDefinition {
|
|
47
|
+
/** Type name (e.g., 'Contact') */
|
|
48
|
+
name: string;
|
|
49
|
+
/** Fields that make up this type */
|
|
50
|
+
fields: CustomTypeField[];
|
|
51
|
+
/** Original markdown schema */
|
|
52
|
+
rawSchema: string;
|
|
53
|
+
}
|
|
34
54
|
/**
|
|
35
55
|
* Attributes that can be set on a MindCache key
|
|
36
56
|
*/
|
|
@@ -45,6 +65,8 @@ interface KeyAttributes {
|
|
|
45
65
|
systemTags: SystemTag[];
|
|
46
66
|
/** Z-index for ordering keys (lower values appear first) */
|
|
47
67
|
zIndex: number;
|
|
68
|
+
/** Custom type name (registered via registerType) */
|
|
69
|
+
customType?: string;
|
|
48
70
|
}
|
|
49
71
|
/**
|
|
50
72
|
* Default attributes for new keys
|
|
@@ -171,7 +193,7 @@ declare class MindCache {
|
|
|
171
193
|
rootMap: Y.Map<Y.Map<any>>;
|
|
172
194
|
private listeners;
|
|
173
195
|
private globalListeners;
|
|
174
|
-
readonly version = "3.
|
|
196
|
+
readonly version = "3.6.0";
|
|
175
197
|
normalizeSystemTags(tags: SystemTag[]): SystemTag[];
|
|
176
198
|
private _cloudAdapter;
|
|
177
199
|
private _connectionState;
|
|
@@ -186,6 +208,7 @@ declare class MindCache {
|
|
|
186
208
|
private _history;
|
|
187
209
|
private _historyOptions;
|
|
188
210
|
private _historyEnabled;
|
|
211
|
+
private _typeRegistry;
|
|
189
212
|
constructor(options?: MindCacheOptions);
|
|
190
213
|
private getUndoManager;
|
|
191
214
|
/**
|
|
@@ -422,6 +445,49 @@ declare class MindCache {
|
|
|
422
445
|
* Get all keys with a specific system tag (requires system access).
|
|
423
446
|
*/
|
|
424
447
|
systemGetKeysByTag(tag: SystemTag): string[];
|
|
448
|
+
/**
|
|
449
|
+
* Register a custom type with a markdown schema definition.
|
|
450
|
+
*
|
|
451
|
+
* Schema format:
|
|
452
|
+
* ```
|
|
453
|
+
* #TypeName
|
|
454
|
+
* * fieldName: description of the field
|
|
455
|
+
* * anotherField: description
|
|
456
|
+
* ```
|
|
457
|
+
*
|
|
458
|
+
* @param name - Type name (e.g., 'Contact')
|
|
459
|
+
* @param schema - Markdown schema definition
|
|
460
|
+
* @throws Error if schema format is invalid
|
|
461
|
+
*/
|
|
462
|
+
registerType(name: string, schema: string): void;
|
|
463
|
+
/**
|
|
464
|
+
* Assign a custom type to a key.
|
|
465
|
+
* The key must exist and the type must be registered.
|
|
466
|
+
* Also sets the underlying type to 'json' since custom types are structured JSON data.
|
|
467
|
+
*
|
|
468
|
+
* @param key - Key to assign type to
|
|
469
|
+
* @param typeName - Registered type name
|
|
470
|
+
* @throws Error if key doesn't exist or type is not registered
|
|
471
|
+
*/
|
|
472
|
+
setType(key: string, typeName: string): void;
|
|
473
|
+
/**
|
|
474
|
+
* Get a registered type schema definition.
|
|
475
|
+
*
|
|
476
|
+
* @param typeName - Type name to look up
|
|
477
|
+
* @returns The type definition or undefined if not registered
|
|
478
|
+
*/
|
|
479
|
+
getTypeSchema(typeName: string): CustomTypeDefinition | undefined;
|
|
480
|
+
/**
|
|
481
|
+
* Get all registered type names.
|
|
482
|
+
*/
|
|
483
|
+
getRegisteredTypes(): string[];
|
|
484
|
+
/**
|
|
485
|
+
* Get the custom type assigned to a key.
|
|
486
|
+
*
|
|
487
|
+
* @param key - Key to check
|
|
488
|
+
* @returns Type name or undefined if no custom type assigned
|
|
489
|
+
*/
|
|
490
|
+
getKeyType(key: string): string | undefined;
|
|
425
491
|
/**
|
|
426
492
|
* Helper to get sorted keys (by zIndex).
|
|
427
493
|
* Respects context filtering when set.
|
|
@@ -497,9 +563,26 @@ declare class MindCache {
|
|
|
497
563
|
notifyGlobalListeners(): void;
|
|
498
564
|
sanitizeKeyForTool(key: string): string;
|
|
499
565
|
findKeyFromSanitizedTool(sanitizedKey: string): string | undefined;
|
|
566
|
+
/**
|
|
567
|
+
* Generate framework-agnostic tools with raw JSON Schema.
|
|
568
|
+
* Works with: OpenAI SDK, Anthropic SDK, LangChain, and other frameworks.
|
|
569
|
+
*
|
|
570
|
+
* Tool format:
|
|
571
|
+
* {
|
|
572
|
+
* description: string,
|
|
573
|
+
* parameters: { type: 'object', properties: {...}, required: [...] },
|
|
574
|
+
* execute: async (args) => result
|
|
575
|
+
* }
|
|
576
|
+
*
|
|
577
|
+
* Security: All tools use llm_set_key internally which:
|
|
578
|
+
* - Only modifies VALUES, never attributes/systemTags
|
|
579
|
+
* - Prevents LLMs from escalating privileges
|
|
580
|
+
*/
|
|
581
|
+
create_tools(): Record<string, any>;
|
|
500
582
|
/**
|
|
501
583
|
* Generate Vercel AI SDK compatible tools for writable keys.
|
|
502
|
-
*
|
|
584
|
+
* Wraps parameters with jsonSchema() for AI SDK v5 compatibility.
|
|
585
|
+
* Use this with: generateText(), streamText() from 'ai' package.
|
|
503
586
|
*
|
|
504
587
|
* Security: All tools use llm_set_key internally which:
|
|
505
588
|
* - Only modifies VALUES, never attributes/systemTags
|
|
@@ -592,10 +675,6 @@ declare class CloudAdapter {
|
|
|
592
675
|
private handleOffline;
|
|
593
676
|
private _synced;
|
|
594
677
|
constructor(config: CloudConfig);
|
|
595
|
-
/**
|
|
596
|
-
* Validate configuration and warn about common mistakes
|
|
597
|
-
*/
|
|
598
|
-
private validateConfig;
|
|
599
678
|
/** Browser network status - instantly updated via navigator.onLine */
|
|
600
679
|
get isOnline(): boolean;
|
|
601
680
|
private setupNetworkDetection;
|
|
@@ -616,4 +695,4 @@ declare class CloudAdapter {
|
|
|
616
695
|
private scheduleReconnect;
|
|
617
696
|
}
|
|
618
697
|
|
|
619
|
-
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
|
|
698
|
+
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 CustomTypeDefinition as e, type MindCacheOptions as f, type KeyType as g, type SystemTag as h, type ContextRules as i, type STM as j, type STMEntry as k, type HistoryOptions as l, type MindCacheCloudOptions as m, type MindCacheIndexedDBOptions as n, type CustomTypeField as o, DEFAULT_KEY_ATTRIBUTES as p, SystemTagHelpers as q };
|
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-PLGvGjoA.mjs';
|
|
2
|
+
export { d as ClearOperation, c as CloudAdapterEvents, b as ConnectionState, D as DeleteOperation, O as Operation, S as SetOperation } from '../CloudAdapter-PLGvGjoA.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-PLGvGjoA.js';
|
|
2
|
+
export { d as ClearOperation, c as CloudAdapterEvents, b as ConnectionState, D as DeleteOperation, O as Operation, S as SetOperation } from '../CloudAdapter-PLGvGjoA.js';
|
|
3
3
|
import 'yjs';
|
|
4
4
|
|
|
5
5
|
/**
|