@mastra/memory 0.12.0-alpha.3 → 0.12.1-alpha.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/.turbo/turbo-build.log +3 -7
- package/CHANGELOG.md +60 -0
- package/dist/index.cjs +17 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +150 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/processors/index.cjs +2 -0
- package/dist/processors/index.cjs.map +1 -0
- package/dist/processors/index.d.ts +3 -2
- package/dist/processors/index.d.ts.map +1 -0
- package/dist/processors/index.js +2 -0
- package/dist/processors/index.js.map +1 -0
- package/dist/processors/token-limiter.d.ts +31 -0
- package/dist/processors/token-limiter.d.ts.map +1 -0
- package/dist/processors/tool-call-filter.d.ts +20 -0
- package/dist/processors/tool-call-filter.d.ts.map +1 -0
- package/dist/tools/working-memory.d.ts +4 -0
- package/dist/tools/working-memory.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/index.ts +25 -1
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +1 -1
- package/tsup.config.ts +22 -0
- package/dist/_tsup-dts-rollup.d.cts +0 -212
- package/dist/_tsup-dts-rollup.d.ts +0 -212
- package/dist/index.d.cts +0 -2
- package/dist/processors/index.d.cts +0 -2
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import type { CoreMessage } from 'ai';
|
|
2
|
-
import type { CoreMessage as CoreMessage_2 } from '@mastra/core';
|
|
3
|
-
import type { CoreTool } from '@mastra/core';
|
|
4
|
-
import { embedMany } from 'ai';
|
|
5
|
-
import { MastraMemory } from '@mastra/core/memory';
|
|
6
|
-
import type { MastraMessageV1 } from '@mastra/core';
|
|
7
|
-
import type { MastraMessageV2 } from '@mastra/core/agent';
|
|
8
|
-
import type { MemoryConfig } from '@mastra/core/memory';
|
|
9
|
-
import type { MemoryConfig as MemoryConfig_2 } from '@mastra/core';
|
|
10
|
-
import { MemoryProcessor } from '@mastra/core/memory';
|
|
11
|
-
import { MemoryProcessor as MemoryProcessor_2 } from '@mastra/core';
|
|
12
|
-
import type { MemoryProcessorOpts } from '@mastra/core';
|
|
13
|
-
import type { SharedMemoryConfig } from '@mastra/core/memory';
|
|
14
|
-
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
15
|
-
import type { StorageThreadType } from '@mastra/core/memory';
|
|
16
|
-
import type { ThreadSortOptions } from '@mastra/core/storage';
|
|
17
|
-
import type { TiktokenBPE } from 'js-tiktoken/lite';
|
|
18
|
-
import type { UIMessageWithMetadata } from '@mastra/core/agent';
|
|
19
|
-
import type { WorkingMemoryTemplate } from '@mastra/core/memory';
|
|
20
|
-
|
|
21
|
-
export declare const __experimental_updateWorkingMemoryToolVNext: (config: MemoryConfig_2) => CoreTool;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Concrete implementation of MastraMemory that adds support for thread configuration
|
|
25
|
-
* and message injection.
|
|
26
|
-
*/
|
|
27
|
-
export declare class Memory extends MastraMemory {
|
|
28
|
-
constructor(config?: SharedMemoryConfig);
|
|
29
|
-
protected validateThreadIsOwnedByResource(threadId: string, resourceId: string): Promise<void>;
|
|
30
|
-
protected checkStorageFeatureSupport(config: MemoryConfig): void;
|
|
31
|
-
query({ threadId, resourceId, selectBy, threadConfig, }: StorageGetMessagesArg & {
|
|
32
|
-
threadConfig?: MemoryConfig;
|
|
33
|
-
}): Promise<{
|
|
34
|
-
messages: CoreMessage[];
|
|
35
|
-
uiMessages: UIMessageWithMetadata[];
|
|
36
|
-
messagesV2: MastraMessageV2[];
|
|
37
|
-
}>;
|
|
38
|
-
rememberMessages({ threadId, resourceId, vectorMessageSearch, config, }: {
|
|
39
|
-
threadId: string;
|
|
40
|
-
resourceId?: string;
|
|
41
|
-
vectorMessageSearch?: string;
|
|
42
|
-
config?: MemoryConfig;
|
|
43
|
-
}): Promise<{
|
|
44
|
-
messages: MastraMessageV1[];
|
|
45
|
-
messagesV2: MastraMessageV2[];
|
|
46
|
-
}>;
|
|
47
|
-
getThreadById({ threadId }: {
|
|
48
|
-
threadId: string;
|
|
49
|
-
}): Promise<StorageThreadType | null>;
|
|
50
|
-
getThreadsByResourceId({ resourceId, orderBy, sortDirection, }: {
|
|
51
|
-
resourceId: string;
|
|
52
|
-
} & ThreadSortOptions): Promise<StorageThreadType[]>;
|
|
53
|
-
saveThread({ thread }: {
|
|
54
|
-
thread: StorageThreadType;
|
|
55
|
-
memoryConfig?: MemoryConfig;
|
|
56
|
-
}): Promise<StorageThreadType>;
|
|
57
|
-
updateThread({ id, title, metadata, }: {
|
|
58
|
-
id: string;
|
|
59
|
-
title: string;
|
|
60
|
-
metadata: Record<string, unknown>;
|
|
61
|
-
}): Promise<StorageThreadType>;
|
|
62
|
-
deleteThread(threadId: string): Promise<void>;
|
|
63
|
-
updateWorkingMemory({ threadId, resourceId, workingMemory, memoryConfig, }: {
|
|
64
|
-
threadId: string;
|
|
65
|
-
resourceId?: string;
|
|
66
|
-
workingMemory: string;
|
|
67
|
-
memoryConfig?: MemoryConfig;
|
|
68
|
-
}): Promise<void>;
|
|
69
|
-
private updateWorkingMemoryMutexes;
|
|
70
|
-
/**
|
|
71
|
-
* @warning experimental! can be removed or changed at any time
|
|
72
|
-
*/
|
|
73
|
-
__experimental_updateWorkingMemoryVNext({ threadId, resourceId, workingMemory, searchString, memoryConfig, }: {
|
|
74
|
-
threadId: string;
|
|
75
|
-
resourceId?: string;
|
|
76
|
-
workingMemory: string;
|
|
77
|
-
searchString?: string;
|
|
78
|
-
memoryConfig?: MemoryConfig;
|
|
79
|
-
}): Promise<{
|
|
80
|
-
success: boolean;
|
|
81
|
-
reason: string;
|
|
82
|
-
}>;
|
|
83
|
-
protected chunkText(text: string, tokenSize?: number): string[];
|
|
84
|
-
private hasher;
|
|
85
|
-
private embeddingCache;
|
|
86
|
-
private firstEmbed;
|
|
87
|
-
protected embedMessageContent(content: string): Promise<{
|
|
88
|
-
chunks: string[];
|
|
89
|
-
embeddings: Awaited<ReturnType<typeof embedMany>>["embeddings"];
|
|
90
|
-
dimension: number | undefined;
|
|
91
|
-
}>;
|
|
92
|
-
saveMessages(args: {
|
|
93
|
-
messages: (MastraMessageV1 | MastraMessageV2)[] | MastraMessageV1[] | MastraMessageV2[];
|
|
94
|
-
memoryConfig?: MemoryConfig | undefined;
|
|
95
|
-
format?: 'v1';
|
|
96
|
-
}): Promise<MastraMessageV1[]>;
|
|
97
|
-
saveMessages(args: {
|
|
98
|
-
messages: (MastraMessageV1 | MastraMessageV2)[] | MastraMessageV1[] | MastraMessageV2[];
|
|
99
|
-
memoryConfig?: MemoryConfig | undefined;
|
|
100
|
-
format: 'v2';
|
|
101
|
-
}): Promise<MastraMessageV2[]>;
|
|
102
|
-
protected updateMessageToHideWorkingMemory(message: MastraMessageV1): MastraMessageV1 | null;
|
|
103
|
-
protected updateMessageToHideWorkingMemoryV2(message: MastraMessageV2): MastraMessageV2 | null;
|
|
104
|
-
protected parseWorkingMemory(text: string): string | null;
|
|
105
|
-
getWorkingMemory({ threadId, resourceId, memoryConfig, }: {
|
|
106
|
-
threadId: string;
|
|
107
|
-
resourceId?: string;
|
|
108
|
-
memoryConfig?: MemoryConfig;
|
|
109
|
-
}): Promise<string | null>;
|
|
110
|
-
/**
|
|
111
|
-
* Gets the working memory template for the current memory configuration.
|
|
112
|
-
* Supports both ZodObject and JSONSchema7 schemas.
|
|
113
|
-
*
|
|
114
|
-
* @param memoryConfig - The memory configuration containing the working memory settings
|
|
115
|
-
* @returns The working memory template with format and content, or null if working memory is disabled
|
|
116
|
-
*/
|
|
117
|
-
getWorkingMemoryTemplate({ memoryConfig, }: {
|
|
118
|
-
memoryConfig?: MemoryConfig;
|
|
119
|
-
}): Promise<WorkingMemoryTemplate | null>;
|
|
120
|
-
getSystemMessage({ threadId, resourceId, memoryConfig, }: {
|
|
121
|
-
threadId: string;
|
|
122
|
-
resourceId?: string;
|
|
123
|
-
memoryConfig?: MemoryConfig;
|
|
124
|
-
}): Promise<string | null>;
|
|
125
|
-
defaultWorkingMemoryTemplate: string;
|
|
126
|
-
protected getWorkingMemoryToolInstruction({ template, data, }: {
|
|
127
|
-
template: WorkingMemoryTemplate;
|
|
128
|
-
data: string | null;
|
|
129
|
-
}): string;
|
|
130
|
-
protected __experimental_getWorkingMemoryToolInstructionVNext({ template, data, }: {
|
|
131
|
-
template: WorkingMemoryTemplate;
|
|
132
|
-
data: string | null;
|
|
133
|
-
}): string;
|
|
134
|
-
private isVNextWorkingMemoryConfig;
|
|
135
|
-
getTools(config?: MemoryConfig): Record<string, CoreTool>;
|
|
136
|
-
/**
|
|
137
|
-
* Updates the metadata of a list of messages
|
|
138
|
-
* @param messages - The list of messages to update
|
|
139
|
-
* @returns The list of updated messages
|
|
140
|
-
*/
|
|
141
|
-
updateMessages({ messages, }: {
|
|
142
|
-
messages: Partial<MastraMessageV2> & {
|
|
143
|
-
id: string;
|
|
144
|
-
}[];
|
|
145
|
-
}): Promise<MastraMessageV2[]>;
|
|
146
|
-
/**
|
|
147
|
-
* Deletes one or more messages
|
|
148
|
-
* @param input - Must be an array containing either:
|
|
149
|
-
* - Message ID strings
|
|
150
|
-
* - Message objects with 'id' properties
|
|
151
|
-
* @returns Promise that resolves when all messages are deleted
|
|
152
|
-
*/
|
|
153
|
-
deleteMessages(input: MessageDeleteInput): Promise<void>;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export declare type MessageDeleteInput = string[] | {
|
|
157
|
-
id: string;
|
|
158
|
-
}[];
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Limits the total number of tokens in the messages.
|
|
162
|
-
* Uses js-tiktoken with o200k_base encoding by default for accurate token counting with modern models.
|
|
163
|
-
*/
|
|
164
|
-
declare class TokenLimiter extends MemoryProcessor {
|
|
165
|
-
private encoder;
|
|
166
|
-
private maxTokens;
|
|
167
|
-
TOKENS_PER_MESSAGE: number;
|
|
168
|
-
TOKENS_PER_CONVERSATION: number;
|
|
169
|
-
/**
|
|
170
|
-
* Create a token limiter for messages.
|
|
171
|
-
* @param options Either a number (token limit) or a configuration object
|
|
172
|
-
*/
|
|
173
|
-
constructor(options: number | TokenLimiterOptions);
|
|
174
|
-
process(messages: CoreMessage_2[], { systemMessage, memorySystemMessage, newMessages }?: MemoryProcessorOpts): CoreMessage_2[];
|
|
175
|
-
countTokens(message: string | CoreMessage_2): number;
|
|
176
|
-
}
|
|
177
|
-
export { TokenLimiter }
|
|
178
|
-
export { TokenLimiter as TokenLimiter_alias_1 }
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Configuration options for TokenLimiter
|
|
182
|
-
*/
|
|
183
|
-
declare interface TokenLimiterOptions {
|
|
184
|
-
/** Maximum number of tokens to allow */
|
|
185
|
-
limit: number;
|
|
186
|
-
/** Optional encoding to use (defaults to o200k_base which is used by gpt-4o) */
|
|
187
|
-
encoding?: TiktokenBPE;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Filters out tool calls and results from messages.
|
|
192
|
-
* By default (with no arguments), excludes all tool calls and their results.
|
|
193
|
-
* Can be configured to exclude only specific tools by name.
|
|
194
|
-
*/
|
|
195
|
-
declare class ToolCallFilter extends MemoryProcessor_2 {
|
|
196
|
-
private exclude;
|
|
197
|
-
/**
|
|
198
|
-
* Create a filter for tool calls and results.
|
|
199
|
-
* @param options Configuration options
|
|
200
|
-
* @param options.exclude List of specific tool names to exclude. If not provided, all tool calls are excluded.
|
|
201
|
-
*/
|
|
202
|
-
constructor(options?: {
|
|
203
|
-
exclude?: string[];
|
|
204
|
-
});
|
|
205
|
-
process(messages: CoreMessage_2[]): CoreMessage_2[];
|
|
206
|
-
}
|
|
207
|
-
export { ToolCallFilter }
|
|
208
|
-
export { ToolCallFilter as ToolCallFilter_alias_1 }
|
|
209
|
-
|
|
210
|
-
export declare const updateWorkingMemoryTool: (memoryConfig?: MemoryConfig_2) => CoreTool;
|
|
211
|
-
|
|
212
|
-
export { }
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import type { CoreMessage } from 'ai';
|
|
2
|
-
import type { CoreMessage as CoreMessage_2 } from '@mastra/core';
|
|
3
|
-
import type { CoreTool } from '@mastra/core';
|
|
4
|
-
import { embedMany } from 'ai';
|
|
5
|
-
import { MastraMemory } from '@mastra/core/memory';
|
|
6
|
-
import type { MastraMessageV1 } from '@mastra/core';
|
|
7
|
-
import type { MastraMessageV2 } from '@mastra/core/agent';
|
|
8
|
-
import type { MemoryConfig } from '@mastra/core/memory';
|
|
9
|
-
import type { MemoryConfig as MemoryConfig_2 } from '@mastra/core';
|
|
10
|
-
import { MemoryProcessor } from '@mastra/core/memory';
|
|
11
|
-
import { MemoryProcessor as MemoryProcessor_2 } from '@mastra/core';
|
|
12
|
-
import type { MemoryProcessorOpts } from '@mastra/core';
|
|
13
|
-
import type { SharedMemoryConfig } from '@mastra/core/memory';
|
|
14
|
-
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
15
|
-
import type { StorageThreadType } from '@mastra/core/memory';
|
|
16
|
-
import type { ThreadSortOptions } from '@mastra/core/storage';
|
|
17
|
-
import type { TiktokenBPE } from 'js-tiktoken/lite';
|
|
18
|
-
import type { UIMessageWithMetadata } from '@mastra/core/agent';
|
|
19
|
-
import type { WorkingMemoryTemplate } from '@mastra/core/memory';
|
|
20
|
-
|
|
21
|
-
export declare const __experimental_updateWorkingMemoryToolVNext: (config: MemoryConfig_2) => CoreTool;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Concrete implementation of MastraMemory that adds support for thread configuration
|
|
25
|
-
* and message injection.
|
|
26
|
-
*/
|
|
27
|
-
export declare class Memory extends MastraMemory {
|
|
28
|
-
constructor(config?: SharedMemoryConfig);
|
|
29
|
-
protected validateThreadIsOwnedByResource(threadId: string, resourceId: string): Promise<void>;
|
|
30
|
-
protected checkStorageFeatureSupport(config: MemoryConfig): void;
|
|
31
|
-
query({ threadId, resourceId, selectBy, threadConfig, }: StorageGetMessagesArg & {
|
|
32
|
-
threadConfig?: MemoryConfig;
|
|
33
|
-
}): Promise<{
|
|
34
|
-
messages: CoreMessage[];
|
|
35
|
-
uiMessages: UIMessageWithMetadata[];
|
|
36
|
-
messagesV2: MastraMessageV2[];
|
|
37
|
-
}>;
|
|
38
|
-
rememberMessages({ threadId, resourceId, vectorMessageSearch, config, }: {
|
|
39
|
-
threadId: string;
|
|
40
|
-
resourceId?: string;
|
|
41
|
-
vectorMessageSearch?: string;
|
|
42
|
-
config?: MemoryConfig;
|
|
43
|
-
}): Promise<{
|
|
44
|
-
messages: MastraMessageV1[];
|
|
45
|
-
messagesV2: MastraMessageV2[];
|
|
46
|
-
}>;
|
|
47
|
-
getThreadById({ threadId }: {
|
|
48
|
-
threadId: string;
|
|
49
|
-
}): Promise<StorageThreadType | null>;
|
|
50
|
-
getThreadsByResourceId({ resourceId, orderBy, sortDirection, }: {
|
|
51
|
-
resourceId: string;
|
|
52
|
-
} & ThreadSortOptions): Promise<StorageThreadType[]>;
|
|
53
|
-
saveThread({ thread }: {
|
|
54
|
-
thread: StorageThreadType;
|
|
55
|
-
memoryConfig?: MemoryConfig;
|
|
56
|
-
}): Promise<StorageThreadType>;
|
|
57
|
-
updateThread({ id, title, metadata, }: {
|
|
58
|
-
id: string;
|
|
59
|
-
title: string;
|
|
60
|
-
metadata: Record<string, unknown>;
|
|
61
|
-
}): Promise<StorageThreadType>;
|
|
62
|
-
deleteThread(threadId: string): Promise<void>;
|
|
63
|
-
updateWorkingMemory({ threadId, resourceId, workingMemory, memoryConfig, }: {
|
|
64
|
-
threadId: string;
|
|
65
|
-
resourceId?: string;
|
|
66
|
-
workingMemory: string;
|
|
67
|
-
memoryConfig?: MemoryConfig;
|
|
68
|
-
}): Promise<void>;
|
|
69
|
-
private updateWorkingMemoryMutexes;
|
|
70
|
-
/**
|
|
71
|
-
* @warning experimental! can be removed or changed at any time
|
|
72
|
-
*/
|
|
73
|
-
__experimental_updateWorkingMemoryVNext({ threadId, resourceId, workingMemory, searchString, memoryConfig, }: {
|
|
74
|
-
threadId: string;
|
|
75
|
-
resourceId?: string;
|
|
76
|
-
workingMemory: string;
|
|
77
|
-
searchString?: string;
|
|
78
|
-
memoryConfig?: MemoryConfig;
|
|
79
|
-
}): Promise<{
|
|
80
|
-
success: boolean;
|
|
81
|
-
reason: string;
|
|
82
|
-
}>;
|
|
83
|
-
protected chunkText(text: string, tokenSize?: number): string[];
|
|
84
|
-
private hasher;
|
|
85
|
-
private embeddingCache;
|
|
86
|
-
private firstEmbed;
|
|
87
|
-
protected embedMessageContent(content: string): Promise<{
|
|
88
|
-
chunks: string[];
|
|
89
|
-
embeddings: Awaited<ReturnType<typeof embedMany>>["embeddings"];
|
|
90
|
-
dimension: number | undefined;
|
|
91
|
-
}>;
|
|
92
|
-
saveMessages(args: {
|
|
93
|
-
messages: (MastraMessageV1 | MastraMessageV2)[] | MastraMessageV1[] | MastraMessageV2[];
|
|
94
|
-
memoryConfig?: MemoryConfig | undefined;
|
|
95
|
-
format?: 'v1';
|
|
96
|
-
}): Promise<MastraMessageV1[]>;
|
|
97
|
-
saveMessages(args: {
|
|
98
|
-
messages: (MastraMessageV1 | MastraMessageV2)[] | MastraMessageV1[] | MastraMessageV2[];
|
|
99
|
-
memoryConfig?: MemoryConfig | undefined;
|
|
100
|
-
format: 'v2';
|
|
101
|
-
}): Promise<MastraMessageV2[]>;
|
|
102
|
-
protected updateMessageToHideWorkingMemory(message: MastraMessageV1): MastraMessageV1 | null;
|
|
103
|
-
protected updateMessageToHideWorkingMemoryV2(message: MastraMessageV2): MastraMessageV2 | null;
|
|
104
|
-
protected parseWorkingMemory(text: string): string | null;
|
|
105
|
-
getWorkingMemory({ threadId, resourceId, memoryConfig, }: {
|
|
106
|
-
threadId: string;
|
|
107
|
-
resourceId?: string;
|
|
108
|
-
memoryConfig?: MemoryConfig;
|
|
109
|
-
}): Promise<string | null>;
|
|
110
|
-
/**
|
|
111
|
-
* Gets the working memory template for the current memory configuration.
|
|
112
|
-
* Supports both ZodObject and JSONSchema7 schemas.
|
|
113
|
-
*
|
|
114
|
-
* @param memoryConfig - The memory configuration containing the working memory settings
|
|
115
|
-
* @returns The working memory template with format and content, or null if working memory is disabled
|
|
116
|
-
*/
|
|
117
|
-
getWorkingMemoryTemplate({ memoryConfig, }: {
|
|
118
|
-
memoryConfig?: MemoryConfig;
|
|
119
|
-
}): Promise<WorkingMemoryTemplate | null>;
|
|
120
|
-
getSystemMessage({ threadId, resourceId, memoryConfig, }: {
|
|
121
|
-
threadId: string;
|
|
122
|
-
resourceId?: string;
|
|
123
|
-
memoryConfig?: MemoryConfig;
|
|
124
|
-
}): Promise<string | null>;
|
|
125
|
-
defaultWorkingMemoryTemplate: string;
|
|
126
|
-
protected getWorkingMemoryToolInstruction({ template, data, }: {
|
|
127
|
-
template: WorkingMemoryTemplate;
|
|
128
|
-
data: string | null;
|
|
129
|
-
}): string;
|
|
130
|
-
protected __experimental_getWorkingMemoryToolInstructionVNext({ template, data, }: {
|
|
131
|
-
template: WorkingMemoryTemplate;
|
|
132
|
-
data: string | null;
|
|
133
|
-
}): string;
|
|
134
|
-
private isVNextWorkingMemoryConfig;
|
|
135
|
-
getTools(config?: MemoryConfig): Record<string, CoreTool>;
|
|
136
|
-
/**
|
|
137
|
-
* Updates the metadata of a list of messages
|
|
138
|
-
* @param messages - The list of messages to update
|
|
139
|
-
* @returns The list of updated messages
|
|
140
|
-
*/
|
|
141
|
-
updateMessages({ messages, }: {
|
|
142
|
-
messages: Partial<MastraMessageV2> & {
|
|
143
|
-
id: string;
|
|
144
|
-
}[];
|
|
145
|
-
}): Promise<MastraMessageV2[]>;
|
|
146
|
-
/**
|
|
147
|
-
* Deletes one or more messages
|
|
148
|
-
* @param input - Must be an array containing either:
|
|
149
|
-
* - Message ID strings
|
|
150
|
-
* - Message objects with 'id' properties
|
|
151
|
-
* @returns Promise that resolves when all messages are deleted
|
|
152
|
-
*/
|
|
153
|
-
deleteMessages(input: MessageDeleteInput): Promise<void>;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export declare type MessageDeleteInput = string[] | {
|
|
157
|
-
id: string;
|
|
158
|
-
}[];
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Limits the total number of tokens in the messages.
|
|
162
|
-
* Uses js-tiktoken with o200k_base encoding by default for accurate token counting with modern models.
|
|
163
|
-
*/
|
|
164
|
-
declare class TokenLimiter extends MemoryProcessor {
|
|
165
|
-
private encoder;
|
|
166
|
-
private maxTokens;
|
|
167
|
-
TOKENS_PER_MESSAGE: number;
|
|
168
|
-
TOKENS_PER_CONVERSATION: number;
|
|
169
|
-
/**
|
|
170
|
-
* Create a token limiter for messages.
|
|
171
|
-
* @param options Either a number (token limit) or a configuration object
|
|
172
|
-
*/
|
|
173
|
-
constructor(options: number | TokenLimiterOptions);
|
|
174
|
-
process(messages: CoreMessage_2[], { systemMessage, memorySystemMessage, newMessages }?: MemoryProcessorOpts): CoreMessage_2[];
|
|
175
|
-
countTokens(message: string | CoreMessage_2): number;
|
|
176
|
-
}
|
|
177
|
-
export { TokenLimiter }
|
|
178
|
-
export { TokenLimiter as TokenLimiter_alias_1 }
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Configuration options for TokenLimiter
|
|
182
|
-
*/
|
|
183
|
-
declare interface TokenLimiterOptions {
|
|
184
|
-
/** Maximum number of tokens to allow */
|
|
185
|
-
limit: number;
|
|
186
|
-
/** Optional encoding to use (defaults to o200k_base which is used by gpt-4o) */
|
|
187
|
-
encoding?: TiktokenBPE;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Filters out tool calls and results from messages.
|
|
192
|
-
* By default (with no arguments), excludes all tool calls and their results.
|
|
193
|
-
* Can be configured to exclude only specific tools by name.
|
|
194
|
-
*/
|
|
195
|
-
declare class ToolCallFilter extends MemoryProcessor_2 {
|
|
196
|
-
private exclude;
|
|
197
|
-
/**
|
|
198
|
-
* Create a filter for tool calls and results.
|
|
199
|
-
* @param options Configuration options
|
|
200
|
-
* @param options.exclude List of specific tool names to exclude. If not provided, all tool calls are excluded.
|
|
201
|
-
*/
|
|
202
|
-
constructor(options?: {
|
|
203
|
-
exclude?: string[];
|
|
204
|
-
});
|
|
205
|
-
process(messages: CoreMessage_2[]): CoreMessage_2[];
|
|
206
|
-
}
|
|
207
|
-
export { ToolCallFilter }
|
|
208
|
-
export { ToolCallFilter as ToolCallFilter_alias_1 }
|
|
209
|
-
|
|
210
|
-
export declare const updateWorkingMemoryTool: (memoryConfig?: MemoryConfig_2) => CoreTool;
|
|
211
|
-
|
|
212
|
-
export { }
|
package/dist/index.d.cts
DELETED