mindcache 3.4.3 → 3.4.4
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-DOvDQswy.d.mts} +69 -23
- package/dist/{CloudAdapter-CJS3Sh4f.d.ts → CloudAdapter-DOvDQswy.d.ts} +69 -23
- 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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1105 -731
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1105 -731
- 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
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# MindCache API Reference
|
|
2
|
+
|
|
3
|
+
## Core Types
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
type KeyType = 'text' | 'image' | 'file' | 'json' | 'document';
|
|
7
|
+
type SystemTag = 'SystemPrompt' | 'LLMRead' | 'LLMWrite' | 'ApplyTemplate';
|
|
8
|
+
type AccessLevel = 'user' | 'admin';
|
|
9
|
+
|
|
10
|
+
interface KeyAttributes {
|
|
11
|
+
type: KeyType;
|
|
12
|
+
contentType?: string;
|
|
13
|
+
contentTags: string[];
|
|
14
|
+
systemTags: SystemTag[]; // Requires admin access to modify
|
|
15
|
+
zIndex: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface STMEntry {
|
|
19
|
+
value: unknown;
|
|
20
|
+
attributes: KeyAttributes;
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## MindCache Class
|
|
25
|
+
|
|
26
|
+
### Constructor & Initialization
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
constructor(options?: MindCacheOptions)
|
|
30
|
+
// options: { cloud?: CloudConfig, indexedDB?: IDBConfig, history?: HistoryOptions, ... }
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Core Data & Keys
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
// Get value of a key (resolves templates if processingStack provided)
|
|
37
|
+
get_value(key: string, _processingStack?: Set<string>): any
|
|
38
|
+
|
|
39
|
+
// Set value of a key
|
|
40
|
+
set_value(key: string, value: any, attributes?: Partial<KeyAttributes>): void
|
|
41
|
+
|
|
42
|
+
// Create a new key (throws if exists)
|
|
43
|
+
create_key(key: string, value: any, attributes?: Partial<KeyAttributes>): void
|
|
44
|
+
|
|
45
|
+
// Check if key exists
|
|
46
|
+
has(key: string): boolean
|
|
47
|
+
|
|
48
|
+
// Delete a key
|
|
49
|
+
delete_key(key: string): void
|
|
50
|
+
|
|
51
|
+
// Get attributes for a key
|
|
52
|
+
get_attributes(key: string): KeyAttributes | undefined
|
|
53
|
+
|
|
54
|
+
// Update key attributes (e.g. tags) without changing value
|
|
55
|
+
set_attributes(key: string, attributes: Partial<KeyAttributes>): boolean
|
|
56
|
+
|
|
57
|
+
// Get all keys
|
|
58
|
+
keys(): string[]
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Context Filtering
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
// Set context to filter visible keys (only keys with ALL tags are visible)
|
|
65
|
+
set_context(rules: ContextRules | string[]): void
|
|
66
|
+
|
|
67
|
+
// Get current context rules
|
|
68
|
+
get_context(): ContextRules | null
|
|
69
|
+
|
|
70
|
+
// Reset context (show all keys)
|
|
71
|
+
reset_context(): void
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Tag Management
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
// Content Tags (User controllable)
|
|
78
|
+
addTag(key: string, tag: string): boolean
|
|
79
|
+
removeTag(key: string, tag: string): boolean
|
|
80
|
+
hasTag(key: string, tag: string): boolean
|
|
81
|
+
getTags(key: string): string[]
|
|
82
|
+
getAllTags(): string[]
|
|
83
|
+
getKeysByTag(tag: string): string[]
|
|
84
|
+
|
|
85
|
+
// System Tags (Admin/System only)
|
|
86
|
+
systemAddTag(key: string, tag: SystemTag): boolean
|
|
87
|
+
systemRemoveTag(key: string, tag: SystemTag): boolean
|
|
88
|
+
systemHasTag(key: string, tag: SystemTag): boolean
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Documents & Collaboration
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
// Create/Get a collaborative document (Y.Text backed)
|
|
95
|
+
set_document(key: string, initialText?: string, attributes?: Partial<KeyAttributes>): void
|
|
96
|
+
|
|
97
|
+
// Get Y.Text instance for binding to editors
|
|
98
|
+
get_document(key: string): Y.Text | undefined
|
|
99
|
+
|
|
100
|
+
// Manipulate text
|
|
101
|
+
insert_text(key: string, index: number, text: string): void
|
|
102
|
+
delete_text(key: string, index: number, length: number): void
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Serialization & Files
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
// Export/Import entire state as Markdwon
|
|
109
|
+
toMarkdown(): string
|
|
110
|
+
fromMarkdown(markdown: string, merge: boolean = false): void
|
|
111
|
+
|
|
112
|
+
// File/Image handling
|
|
113
|
+
set_file(key: string, file: File, attributes?: Partial<KeyAttributes>): Promise<void>
|
|
114
|
+
get_data_url(key: string): string | undefined
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### AI Integration
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
// Generate Vercel AI SDK compatible tools for LLM interaction
|
|
121
|
+
create_vercel_ai_tools(): Record<string, any>
|
|
122
|
+
|
|
123
|
+
// Generate system prompt with all visible keys
|
|
124
|
+
get_system_prompt(): string
|
|
125
|
+
|
|
126
|
+
// Execute a tool call
|
|
127
|
+
executeToolCall(toolName: string, value: any): { result: string; key: string } | null
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Subscriptions & Events
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
// Subscribe to changes on specific key
|
|
134
|
+
subscribe(key: string, listener: (value: any) => void): () => void // returns unsubscribe fn
|
|
135
|
+
|
|
136
|
+
// Subscribe to ALL changes
|
|
137
|
+
subscribeToAll(listener: GlobalListener): () => void
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### History (Undo/Redo)
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
undo(key: string): void
|
|
144
|
+
redo(key: string): void
|
|
145
|
+
undoAll(): void // Global undo
|
|
146
|
+
redoAll(): void // Global redo
|
|
147
|
+
getHistory(key: string): HistoryEntry[]
|
|
148
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mindcache",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.4",
|
|
4
4
|
"description": "A TypeScript library for managing short-term memory in AI agents through an LLM-friendly key-value repository",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"files": [
|
|
26
26
|
"dist/**/*",
|
|
27
27
|
"README.md",
|
|
28
|
-
"LICENSE"
|
|
28
|
+
"LICENSE",
|
|
29
|
+
"docs"
|
|
29
30
|
],
|
|
30
31
|
"scripts": {
|
|
31
32
|
"build": "tsup",
|