@cuylabs/agent-memory-filesystem 5.0.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/LICENSE +201 -0
- package/README.md +366 -0
- package/dist/index.d.ts +216 -0
- package/dist/index.js +2048 -0
- package/package.json +61 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { AgentMemoryRecord, AgentMemoryScope, AgentMemoryRememberInput, AgentMemoryRecallInput, AgentMemoryCompactionCommitInput, AgentMemoryTurnEndInput, AgentMemoryProvider, AgentMemoryRecallResult } from '@cuylabs/agent-core/memory';
|
|
2
|
+
import { AgentConfig, Profile, Tool } from '@cuylabs/agent-core';
|
|
3
|
+
|
|
4
|
+
interface MemoryTokenizer {
|
|
5
|
+
normalize(value: string): string;
|
|
6
|
+
tokenize(value: string): string[];
|
|
7
|
+
}
|
|
8
|
+
interface DefaultMemoryTokenizerOptions {
|
|
9
|
+
minTermLength?: number;
|
|
10
|
+
preservePathTerms?: boolean;
|
|
11
|
+
/** Optional caller-owned terms to ignore. No stop words are applied by default. */
|
|
12
|
+
stopWords?: Iterable<string>;
|
|
13
|
+
}
|
|
14
|
+
declare function createDefaultMemoryTokenizer(options?: DefaultMemoryTokenizerOptions): MemoryTokenizer;
|
|
15
|
+
|
|
16
|
+
interface MemoryRecordSearchInput {
|
|
17
|
+
sessionId?: string;
|
|
18
|
+
turnId?: string;
|
|
19
|
+
query?: string;
|
|
20
|
+
limit: number;
|
|
21
|
+
scope?: AgentMemoryScope;
|
|
22
|
+
tags?: string[];
|
|
23
|
+
minScore?: number;
|
|
24
|
+
}
|
|
25
|
+
interface MemorySearchEngine {
|
|
26
|
+
search(records: readonly AgentMemoryRecord[], input: MemoryRecordSearchInput): AgentMemoryRecord[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface AgenticMemoryRecallOptions {
|
|
30
|
+
/**
|
|
31
|
+
* Model used by the private recall worker. Required unless `profile.model`
|
|
32
|
+
* is provided.
|
|
33
|
+
*/
|
|
34
|
+
model?: AgentConfig["model"];
|
|
35
|
+
/**
|
|
36
|
+
* Optional profile using the same shape as agent-core subagent profiles.
|
|
37
|
+
* The profile is applied inside the provider and is never exposed as a
|
|
38
|
+
* foreground tool.
|
|
39
|
+
*/
|
|
40
|
+
profile?: Profile;
|
|
41
|
+
/** Optional extra tools for the private recall worker, usually read-only helpers. */
|
|
42
|
+
tools?: Tool.AnyInfo[];
|
|
43
|
+
/** Optional middleware/policy stack for the private recall worker's tool calls. */
|
|
44
|
+
middleware?: AgentConfig["middleware"];
|
|
45
|
+
/** Optional approval policy for private recall worker tools. */
|
|
46
|
+
approval?: AgentConfig["approval"];
|
|
47
|
+
/** Tool execution mode for the private recall worker. */
|
|
48
|
+
toolExecutionMode?: AgentConfig["toolExecutionMode"];
|
|
49
|
+
/** Recall worker system prompt. `{basePrompt}` works when overridden by a profile. */
|
|
50
|
+
systemPrompt?: string;
|
|
51
|
+
/** Override the user prompt sent to the private recall worker. */
|
|
52
|
+
prompt?: (input: AgentMemoryRecallInput) => string;
|
|
53
|
+
name?: string;
|
|
54
|
+
cwd?: string;
|
|
55
|
+
maxSteps?: number;
|
|
56
|
+
maxOutputTokens?: number;
|
|
57
|
+
temperature?: number;
|
|
58
|
+
contextWindow?: number;
|
|
59
|
+
timeoutMs?: number;
|
|
60
|
+
maxMessages?: number;
|
|
61
|
+
maxMessageChars?: number;
|
|
62
|
+
maxPromptChars?: number;
|
|
63
|
+
maxSummaryChars?: number;
|
|
64
|
+
}
|
|
65
|
+
interface MemoryProviderRecallOptions extends DefaultMemoryTokenizerOptions {
|
|
66
|
+
/**
|
|
67
|
+
* Private recall worker configuration. Automatic recall is agentic-only:
|
|
68
|
+
* when this is omitted, the provider still exposes search/list/get tools but
|
|
69
|
+
* does not install an automatic recall hook.
|
|
70
|
+
*/
|
|
71
|
+
agent?: AgenticMemoryRecallOptions;
|
|
72
|
+
engine?: MemorySearchEngine;
|
|
73
|
+
tokenizer?: MemoryTokenizer;
|
|
74
|
+
minScore?: number;
|
|
75
|
+
snippetContextLines?: number;
|
|
76
|
+
maxSnippetLines?: number;
|
|
77
|
+
}
|
|
78
|
+
interface MemoryDraft {
|
|
79
|
+
content: string;
|
|
80
|
+
title?: string;
|
|
81
|
+
kind?: string;
|
|
82
|
+
scope?: AgentMemoryScope;
|
|
83
|
+
source?: string;
|
|
84
|
+
tags?: string[];
|
|
85
|
+
memoryKey?: string;
|
|
86
|
+
onExisting?: AgentMemoryRememberInput["onExisting"];
|
|
87
|
+
metadata?: Record<string, unknown>;
|
|
88
|
+
}
|
|
89
|
+
type MemoryCaptureResult = MemoryDraft | MemoryDraft[] | undefined | void;
|
|
90
|
+
type MemoryTurnCapture = (input: AgentMemoryTurnEndInput) => Promise<MemoryCaptureResult> | MemoryCaptureResult;
|
|
91
|
+
type MemoryCompactionCapture = (input: AgentMemoryCompactionCommitInput) => Promise<MemoryCaptureResult> | MemoryCaptureResult;
|
|
92
|
+
interface MemoryProviderRememberOptions {
|
|
93
|
+
captureTurn?: MemoryTurnCapture;
|
|
94
|
+
captureBeforeCompactionCommit?: MemoryCompactionCapture;
|
|
95
|
+
}
|
|
96
|
+
interface MemoryProviderOptions {
|
|
97
|
+
id?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Memory root. Relative paths are resolved from each call's `cwd`.
|
|
100
|
+
*
|
|
101
|
+
* Default: `.agent-memory`
|
|
102
|
+
*/
|
|
103
|
+
root?: string;
|
|
104
|
+
recordsDir?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Scope applied when a memory draft/tool call omits `scope`.
|
|
107
|
+
*
|
|
108
|
+
* Default: `project`
|
|
109
|
+
*/
|
|
110
|
+
defaultScope?: AgentMemoryScope;
|
|
111
|
+
recall?: MemoryProviderRecallOptions;
|
|
112
|
+
remember?: MemoryProviderRememberOptions;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
declare function createFilesystemMemoryProvider(options?: MemoryProviderOptions): AgentMemoryProvider;
|
|
116
|
+
declare const createMemoryProvider: typeof createFilesystemMemoryProvider;
|
|
117
|
+
|
|
118
|
+
declare const AGENTIC_MEMORY_CAPTURE_BINDER: unique symbol;
|
|
119
|
+
type AgenticMemoryCaptureInput = {
|
|
120
|
+
kind: "turn";
|
|
121
|
+
input: AgentMemoryTurnEndInput;
|
|
122
|
+
} | {
|
|
123
|
+
kind: "compaction";
|
|
124
|
+
input: AgentMemoryCompactionCommitInput;
|
|
125
|
+
};
|
|
126
|
+
type AgenticMemoryCaptureWriter = (draft: MemoryDraft, input: AgenticMemoryCaptureInput) => Promise<void> | void;
|
|
127
|
+
interface AgenticMemoryCaptureReadInput {
|
|
128
|
+
sessionId?: string;
|
|
129
|
+
turnId?: string;
|
|
130
|
+
cwd: string;
|
|
131
|
+
query?: string;
|
|
132
|
+
limit: number;
|
|
133
|
+
scope?: AgentMemoryScope;
|
|
134
|
+
tags?: string[];
|
|
135
|
+
}
|
|
136
|
+
interface AgenticMemoryCaptureRuntime {
|
|
137
|
+
write: AgenticMemoryCaptureWriter;
|
|
138
|
+
search?: (input: AgenticMemoryCaptureReadInput) => Promise<AgentMemoryRecord[]> | AgentMemoryRecord[];
|
|
139
|
+
list?: (input: AgenticMemoryCaptureReadInput) => Promise<AgentMemoryRecord[]> | AgentMemoryRecord[];
|
|
140
|
+
}
|
|
141
|
+
type AgenticMemoryCaptureFunction = MemoryTurnCapture & MemoryCompactionCapture & {
|
|
142
|
+
[AGENTIC_MEMORY_CAPTURE_BINDER]?: (runtime: AgenticMemoryCaptureRuntime) => MemoryTurnCapture & MemoryCompactionCapture;
|
|
143
|
+
};
|
|
144
|
+
interface AgenticMemoryCaptureOptions {
|
|
145
|
+
/**
|
|
146
|
+
* Model used by the private memory writer. Required unless `profile.model`
|
|
147
|
+
* is set.
|
|
148
|
+
*/
|
|
149
|
+
model?: AgentConfig["model"];
|
|
150
|
+
/**
|
|
151
|
+
* Optional profile using the same shape as agent-core subagent profiles.
|
|
152
|
+
* The profile is applied inside the provider; it is not exposed as a
|
|
153
|
+
* foreground subagent tool.
|
|
154
|
+
*/
|
|
155
|
+
profile?: Profile;
|
|
156
|
+
/** Optional extra tools for the private worker, usually read-only helpers. */
|
|
157
|
+
tools?: Tool.AnyInfo[];
|
|
158
|
+
/** Optional middleware/policy stack for the private worker's tool calls. */
|
|
159
|
+
middleware?: AgentConfig["middleware"];
|
|
160
|
+
/** Optional approval policy for private worker tools. */
|
|
161
|
+
approval?: AgentConfig["approval"];
|
|
162
|
+
/** Tool execution mode for the private worker. */
|
|
163
|
+
toolExecutionMode?: AgentConfig["toolExecutionMode"];
|
|
164
|
+
/** Capture worker system prompt. `{basePrompt}` works when overridden by a profile. */
|
|
165
|
+
systemPrompt?: string;
|
|
166
|
+
/** Override the user prompt sent to the private worker. */
|
|
167
|
+
prompt?: (input: AgenticMemoryCaptureInput) => string;
|
|
168
|
+
/** Override parsing of the worker response into provider memory drafts. */
|
|
169
|
+
parse?: (output: string, input: AgenticMemoryCaptureInput) => MemoryCaptureResult;
|
|
170
|
+
name?: string;
|
|
171
|
+
cwd?: string;
|
|
172
|
+
maxSteps?: number;
|
|
173
|
+
maxOutputTokens?: number;
|
|
174
|
+
temperature?: number;
|
|
175
|
+
contextWindow?: number;
|
|
176
|
+
timeoutMs?: number;
|
|
177
|
+
maxMessages?: number;
|
|
178
|
+
maxMessageChars?: number;
|
|
179
|
+
maxPromptChars?: number;
|
|
180
|
+
}
|
|
181
|
+
declare function createAgenticMemoryCapture(options: AgenticMemoryCaptureOptions): AgenticMemoryCaptureFunction;
|
|
182
|
+
|
|
183
|
+
interface AgenticMemoryRecallRuntime {
|
|
184
|
+
search(input: {
|
|
185
|
+
cwd: string;
|
|
186
|
+
query: string;
|
|
187
|
+
limit: number;
|
|
188
|
+
scope?: AgentMemoryScope;
|
|
189
|
+
tags?: string[];
|
|
190
|
+
}): Promise<AgentMemoryRecord[]> | AgentMemoryRecord[];
|
|
191
|
+
list?(input: {
|
|
192
|
+
cwd: string;
|
|
193
|
+
limit: number;
|
|
194
|
+
scope?: AgentMemoryScope;
|
|
195
|
+
tags?: string[];
|
|
196
|
+
}): Promise<AgentMemoryRecord[]> | AgentMemoryRecord[];
|
|
197
|
+
get(input: {
|
|
198
|
+
cwd: string;
|
|
199
|
+
id: string;
|
|
200
|
+
scope?: AgentMemoryScope;
|
|
201
|
+
}): Promise<AgentMemoryRecord | undefined> | AgentMemoryRecord | undefined;
|
|
202
|
+
}
|
|
203
|
+
declare function runAgenticMemoryRecall(options: {
|
|
204
|
+
input: AgentMemoryRecallInput;
|
|
205
|
+
runtime: AgenticMemoryRecallRuntime;
|
|
206
|
+
recall: AgenticMemoryRecallOptions;
|
|
207
|
+
}): Promise<AgentMemoryRecallResult>;
|
|
208
|
+
|
|
209
|
+
interface FilesystemMemorySearchEngineOptions extends DefaultMemoryTokenizerOptions {
|
|
210
|
+
tokenizer?: MemoryTokenizer;
|
|
211
|
+
snippetContextLines?: number;
|
|
212
|
+
maxSnippetLines?: number;
|
|
213
|
+
}
|
|
214
|
+
declare function createFilesystemMemorySearchEngine(options?: FilesystemMemorySearchEngineOptions): MemorySearchEngine;
|
|
215
|
+
|
|
216
|
+
export { type AgenticMemoryCaptureInput, type AgenticMemoryCaptureOptions, type AgenticMemoryRecallOptions, type AgenticMemoryRecallRuntime, type DefaultMemoryTokenizerOptions, type FilesystemMemorySearchEngineOptions, type MemoryCaptureResult, type MemoryCompactionCapture, type MemoryDraft, type MemoryProviderOptions, type MemoryProviderRecallOptions, type MemoryProviderRememberOptions, type MemorySearchEngine, type MemoryTokenizer, type MemoryTurnCapture, createAgenticMemoryCapture, createDefaultMemoryTokenizer, createFilesystemMemoryProvider, createFilesystemMemorySearchEngine, createMemoryProvider, runAgenticMemoryRecall };
|