@voltagent/core 1.2.9 → 1.2.11
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/dist/index.d.mts +28 -8
- package/dist/index.d.ts +28 -8
- package/dist/index.js +48 -48
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -48
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1030,7 +1030,9 @@ interface VectorItem$1 {
|
|
|
1030
1030
|
interface StorageAdapter {
|
|
1031
1031
|
addMessage(message: UIMessage, userId: string, conversationId: string, context?: OperationContext): Promise<void>;
|
|
1032
1032
|
addMessages(messages: UIMessage[], userId: string, conversationId: string, context?: OperationContext): Promise<void>;
|
|
1033
|
-
getMessages(userId: string, conversationId: string, options?: GetMessagesOptions, context?: OperationContext): Promise<UIMessage
|
|
1033
|
+
getMessages(userId: string, conversationId: string, options?: GetMessagesOptions, context?: OperationContext): Promise<UIMessage<{
|
|
1034
|
+
createdAt: Date;
|
|
1035
|
+
}>[]>;
|
|
1034
1036
|
clearMessages(userId: string, conversationId?: string, context?: OperationContext): Promise<void>;
|
|
1035
1037
|
createConversation(input: CreateConversationInput): Promise<Conversation>;
|
|
1036
1038
|
getConversation(id: string): Promise<Conversation | null>;
|
|
@@ -1292,7 +1294,9 @@ declare class Memory {
|
|
|
1292
1294
|
/**
|
|
1293
1295
|
* Get messages from a conversation
|
|
1294
1296
|
*/
|
|
1295
|
-
getMessages(userId: string, conversationId: string, options?: GetMessagesOptions, context?: OperationContext): Promise<UIMessage
|
|
1297
|
+
getMessages(userId: string, conversationId: string, options?: GetMessagesOptions, context?: OperationContext): Promise<UIMessage<{
|
|
1298
|
+
createdAt: Date;
|
|
1299
|
+
}>[]>;
|
|
1296
1300
|
/**
|
|
1297
1301
|
* Save a single message
|
|
1298
1302
|
*/
|
|
@@ -1348,7 +1352,9 @@ declare class Memory {
|
|
|
1348
1352
|
semanticLimit?: number;
|
|
1349
1353
|
semanticThreshold?: number;
|
|
1350
1354
|
mergeStrategy?: "prepend" | "append" | "interleave";
|
|
1351
|
-
}): Promise<UIMessage
|
|
1355
|
+
}): Promise<UIMessage<{
|
|
1356
|
+
createdAt: Date;
|
|
1357
|
+
}>[]>;
|
|
1352
1358
|
/**
|
|
1353
1359
|
* Get messages by their IDs
|
|
1354
1360
|
*/
|
|
@@ -1472,7 +1478,9 @@ declare class Memory {
|
|
|
1472
1478
|
semanticLimit?: number;
|
|
1473
1479
|
semanticThreshold?: number;
|
|
1474
1480
|
mergeStrategy?: "prepend" | "append" | "interleave";
|
|
1475
|
-
}, operationContext?: OperationContext): Promise<UIMessage
|
|
1481
|
+
}, operationContext?: OperationContext): Promise<UIMessage<{
|
|
1482
|
+
createdAt: Date;
|
|
1483
|
+
}>[]>;
|
|
1476
1484
|
/**
|
|
1477
1485
|
* Internal: Set resource ID (agent ID)
|
|
1478
1486
|
*/
|
|
@@ -4831,12 +4839,16 @@ declare class MemoryManager {
|
|
|
4831
4839
|
mergeStrategy?: "prepend" | "append" | "interleave";
|
|
4832
4840
|
traceContext?: AgentTraceContext;
|
|
4833
4841
|
parentMemorySpan?: Span;
|
|
4834
|
-
}): Promise<UIMessage
|
|
4842
|
+
}): Promise<UIMessage<{
|
|
4843
|
+
createdAt: Date;
|
|
4844
|
+
}>[]>;
|
|
4835
4845
|
/**
|
|
4836
4846
|
* Search messages semantically
|
|
4837
4847
|
* PRESERVED FROM ORIGINAL WITH MEMORY V2 INTEGRATION
|
|
4838
4848
|
*/
|
|
4839
|
-
searchMessages(context: OperationContext, _query: string, userId?: string, conversationId?: string, limit?: number): Promise<UIMessage
|
|
4849
|
+
searchMessages(context: OperationContext, _query: string, userId?: string, conversationId?: string, limit?: number): Promise<UIMessage<{
|
|
4850
|
+
createdAt: Date;
|
|
4851
|
+
}>[]>;
|
|
4840
4852
|
/**
|
|
4841
4853
|
* Clear messages from memory
|
|
4842
4854
|
* PRESERVED FROM ORIGINAL WITH MEMORY V2 INTEGRATION
|
|
@@ -4848,7 +4860,9 @@ declare class MemoryManager {
|
|
|
4848
4860
|
* PRESERVED FROM ORIGINAL
|
|
4849
4861
|
*/
|
|
4850
4862
|
prepareConversationContext(context: OperationContext, input: string | UIMessage[], userId?: string, conversationIdParam?: string, contextLimit?: number): Promise<{
|
|
4851
|
-
messages: UIMessage
|
|
4863
|
+
messages: UIMessage<{
|
|
4864
|
+
createdAt: Date;
|
|
4865
|
+
}>[];
|
|
4852
4866
|
conversationId: string;
|
|
4853
4867
|
}>;
|
|
4854
4868
|
/**
|
|
@@ -5142,6 +5156,10 @@ declare class Agent {
|
|
|
5142
5156
|
* Add toolkit instructions
|
|
5143
5157
|
*/
|
|
5144
5158
|
private addToolkitInstructions;
|
|
5159
|
+
/**
|
|
5160
|
+
* Enrich instructions with additional context and modifiers
|
|
5161
|
+
*/
|
|
5162
|
+
private enrichInstructions;
|
|
5145
5163
|
/**
|
|
5146
5164
|
* Prepare agents memory for supervisor
|
|
5147
5165
|
*/
|
|
@@ -9092,7 +9110,9 @@ declare class InMemoryStorageAdapter implements StorageAdapter {
|
|
|
9092
9110
|
/**
|
|
9093
9111
|
* Get messages with optional filtering
|
|
9094
9112
|
*/
|
|
9095
|
-
getMessages(userId: string, conversationId: string, options?: GetMessagesOptions, _context?: OperationContext): Promise<UIMessage
|
|
9113
|
+
getMessages(userId: string, conversationId: string, options?: GetMessagesOptions, _context?: OperationContext): Promise<UIMessage<{
|
|
9114
|
+
createdAt: Date;
|
|
9115
|
+
}>[]>;
|
|
9096
9116
|
saveConversationSteps(steps: ConversationStepRecord[]): Promise<void>;
|
|
9097
9117
|
getConversationSteps(userId: string, conversationId: string, options?: GetConversationStepsOptions): Promise<ConversationStepRecord[]>;
|
|
9098
9118
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1030,7 +1030,9 @@ interface VectorItem$1 {
|
|
|
1030
1030
|
interface StorageAdapter {
|
|
1031
1031
|
addMessage(message: UIMessage, userId: string, conversationId: string, context?: OperationContext): Promise<void>;
|
|
1032
1032
|
addMessages(messages: UIMessage[], userId: string, conversationId: string, context?: OperationContext): Promise<void>;
|
|
1033
|
-
getMessages(userId: string, conversationId: string, options?: GetMessagesOptions, context?: OperationContext): Promise<UIMessage
|
|
1033
|
+
getMessages(userId: string, conversationId: string, options?: GetMessagesOptions, context?: OperationContext): Promise<UIMessage<{
|
|
1034
|
+
createdAt: Date;
|
|
1035
|
+
}>[]>;
|
|
1034
1036
|
clearMessages(userId: string, conversationId?: string, context?: OperationContext): Promise<void>;
|
|
1035
1037
|
createConversation(input: CreateConversationInput): Promise<Conversation>;
|
|
1036
1038
|
getConversation(id: string): Promise<Conversation | null>;
|
|
@@ -1292,7 +1294,9 @@ declare class Memory {
|
|
|
1292
1294
|
/**
|
|
1293
1295
|
* Get messages from a conversation
|
|
1294
1296
|
*/
|
|
1295
|
-
getMessages(userId: string, conversationId: string, options?: GetMessagesOptions, context?: OperationContext): Promise<UIMessage
|
|
1297
|
+
getMessages(userId: string, conversationId: string, options?: GetMessagesOptions, context?: OperationContext): Promise<UIMessage<{
|
|
1298
|
+
createdAt: Date;
|
|
1299
|
+
}>[]>;
|
|
1296
1300
|
/**
|
|
1297
1301
|
* Save a single message
|
|
1298
1302
|
*/
|
|
@@ -1348,7 +1352,9 @@ declare class Memory {
|
|
|
1348
1352
|
semanticLimit?: number;
|
|
1349
1353
|
semanticThreshold?: number;
|
|
1350
1354
|
mergeStrategy?: "prepend" | "append" | "interleave";
|
|
1351
|
-
}): Promise<UIMessage
|
|
1355
|
+
}): Promise<UIMessage<{
|
|
1356
|
+
createdAt: Date;
|
|
1357
|
+
}>[]>;
|
|
1352
1358
|
/**
|
|
1353
1359
|
* Get messages by their IDs
|
|
1354
1360
|
*/
|
|
@@ -1472,7 +1478,9 @@ declare class Memory {
|
|
|
1472
1478
|
semanticLimit?: number;
|
|
1473
1479
|
semanticThreshold?: number;
|
|
1474
1480
|
mergeStrategy?: "prepend" | "append" | "interleave";
|
|
1475
|
-
}, operationContext?: OperationContext): Promise<UIMessage
|
|
1481
|
+
}, operationContext?: OperationContext): Promise<UIMessage<{
|
|
1482
|
+
createdAt: Date;
|
|
1483
|
+
}>[]>;
|
|
1476
1484
|
/**
|
|
1477
1485
|
* Internal: Set resource ID (agent ID)
|
|
1478
1486
|
*/
|
|
@@ -4831,12 +4839,16 @@ declare class MemoryManager {
|
|
|
4831
4839
|
mergeStrategy?: "prepend" | "append" | "interleave";
|
|
4832
4840
|
traceContext?: AgentTraceContext;
|
|
4833
4841
|
parentMemorySpan?: Span;
|
|
4834
|
-
}): Promise<UIMessage
|
|
4842
|
+
}): Promise<UIMessage<{
|
|
4843
|
+
createdAt: Date;
|
|
4844
|
+
}>[]>;
|
|
4835
4845
|
/**
|
|
4836
4846
|
* Search messages semantically
|
|
4837
4847
|
* PRESERVED FROM ORIGINAL WITH MEMORY V2 INTEGRATION
|
|
4838
4848
|
*/
|
|
4839
|
-
searchMessages(context: OperationContext, _query: string, userId?: string, conversationId?: string, limit?: number): Promise<UIMessage
|
|
4849
|
+
searchMessages(context: OperationContext, _query: string, userId?: string, conversationId?: string, limit?: number): Promise<UIMessage<{
|
|
4850
|
+
createdAt: Date;
|
|
4851
|
+
}>[]>;
|
|
4840
4852
|
/**
|
|
4841
4853
|
* Clear messages from memory
|
|
4842
4854
|
* PRESERVED FROM ORIGINAL WITH MEMORY V2 INTEGRATION
|
|
@@ -4848,7 +4860,9 @@ declare class MemoryManager {
|
|
|
4848
4860
|
* PRESERVED FROM ORIGINAL
|
|
4849
4861
|
*/
|
|
4850
4862
|
prepareConversationContext(context: OperationContext, input: string | UIMessage[], userId?: string, conversationIdParam?: string, contextLimit?: number): Promise<{
|
|
4851
|
-
messages: UIMessage
|
|
4863
|
+
messages: UIMessage<{
|
|
4864
|
+
createdAt: Date;
|
|
4865
|
+
}>[];
|
|
4852
4866
|
conversationId: string;
|
|
4853
4867
|
}>;
|
|
4854
4868
|
/**
|
|
@@ -5142,6 +5156,10 @@ declare class Agent {
|
|
|
5142
5156
|
* Add toolkit instructions
|
|
5143
5157
|
*/
|
|
5144
5158
|
private addToolkitInstructions;
|
|
5159
|
+
/**
|
|
5160
|
+
* Enrich instructions with additional context and modifiers
|
|
5161
|
+
*/
|
|
5162
|
+
private enrichInstructions;
|
|
5145
5163
|
/**
|
|
5146
5164
|
* Prepare agents memory for supervisor
|
|
5147
5165
|
*/
|
|
@@ -9092,7 +9110,9 @@ declare class InMemoryStorageAdapter implements StorageAdapter {
|
|
|
9092
9110
|
/**
|
|
9093
9111
|
* Get messages with optional filtering
|
|
9094
9112
|
*/
|
|
9095
|
-
getMessages(userId: string, conversationId: string, options?: GetMessagesOptions, _context?: OperationContext): Promise<UIMessage
|
|
9113
|
+
getMessages(userId: string, conversationId: string, options?: GetMessagesOptions, _context?: OperationContext): Promise<UIMessage<{
|
|
9114
|
+
createdAt: Date;
|
|
9115
|
+
}>[]>;
|
|
9096
9116
|
saveConversationSteps(steps: ConversationStepRecord[]): Promise<void>;
|
|
9097
9117
|
getConversationSteps(userId: string, conversationId: string, options?: GetConversationStepsOptions): Promise<ConversationStepRecord[]>;
|
|
9098
9118
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2717,7 +2717,11 @@ var InMemoryStorageAdapter = class {
|
|
|
2717
2717
|
}
|
|
2718
2718
|
return messages.map((msg) => {
|
|
2719
2719
|
const cloned = (0, import_utils8.deepClone)(msg);
|
|
2720
|
-
const {
|
|
2720
|
+
const { userId: msgUserId, conversationId: msgConvId, ...uiMessage } = cloned;
|
|
2721
|
+
if (!uiMessage.metadata) {
|
|
2722
|
+
uiMessage.metadata = {};
|
|
2723
|
+
}
|
|
2724
|
+
uiMessage.metadata.createdAt = cloned.createdAt;
|
|
2721
2725
|
return uiMessage;
|
|
2722
2726
|
});
|
|
2723
2727
|
}
|
|
@@ -8085,7 +8089,7 @@ var MemoryManager = class {
|
|
|
8085
8089
|
async performSemanticSearch(userId, conversationId, query, limit, semanticLimit, semanticThreshold, mergeStrategy, logger, traceContext, parentMemorySpan) {
|
|
8086
8090
|
if (!this.conversationMemory?.hasVectorSupport?.()) {
|
|
8087
8091
|
logger.debug("Vector support not available, falling back to regular retrieval");
|
|
8088
|
-
return this.conversationMemory?.getMessages(userId, conversationId, { limit }) || [];
|
|
8092
|
+
return await this.conversationMemory?.getMessages(userId, conversationId, { limit }) || [];
|
|
8089
8093
|
}
|
|
8090
8094
|
const embeddingAdapter = this.conversationMemory.getEmbeddingAdapter?.();
|
|
8091
8095
|
const vectorAdapter = this.conversationMemory.getVectorAdapter?.();
|
|
@@ -10390,7 +10394,7 @@ var VoltOpsClient = class {
|
|
|
10390
10394
|
evals;
|
|
10391
10395
|
logger;
|
|
10392
10396
|
get fetchImpl() {
|
|
10393
|
-
return this.options.fetch ?? fetch;
|
|
10397
|
+
return this.options.fetch ?? fetch.bind(globalThis);
|
|
10394
10398
|
}
|
|
10395
10399
|
constructor(options) {
|
|
10396
10400
|
const defaultPromptCache = {
|
|
@@ -18086,37 +18090,51 @@ ${additionalContext}`
|
|
|
18086
18090
|
return messages;
|
|
18087
18091
|
}
|
|
18088
18092
|
if (promptContent.type === "text") {
|
|
18089
|
-
|
|
18090
|
-
content2 = this.
|
|
18091
|
-
|
|
18092
|
-
|
|
18093
|
-
|
|
18094
|
-
|
|
18095
|
-
|
|
18096
|
-
if (retrieverContext) {
|
|
18097
|
-
content2 = `${content2}
|
|
18098
|
-
|
|
18099
|
-
Relevant Context:
|
|
18100
|
-
${retrieverContext}`;
|
|
18101
|
-
}
|
|
18102
|
-
if (workingMemoryContext) {
|
|
18103
|
-
content2 = `${content2}${workingMemoryContext}`;
|
|
18104
|
-
}
|
|
18105
|
-
if (this.subAgentManager.hasSubAgents()) {
|
|
18106
|
-
const agentsMemory = await this.prepareAgentsMemory(oc);
|
|
18107
|
-
content2 = this.subAgentManager.generateSupervisorSystemMessage(
|
|
18108
|
-
content2,
|
|
18109
|
-
agentsMemory,
|
|
18110
|
-
this.supervisorConfig
|
|
18111
|
-
);
|
|
18112
|
-
}
|
|
18093
|
+
const baseContent2 = promptContent.text || "";
|
|
18094
|
+
const content2 = await this.enrichInstructions(
|
|
18095
|
+
baseContent2,
|
|
18096
|
+
retrieverContext,
|
|
18097
|
+
workingMemoryContext,
|
|
18098
|
+
oc
|
|
18099
|
+
);
|
|
18113
18100
|
return {
|
|
18114
18101
|
role: "system",
|
|
18115
18102
|
content: `You are ${this.name}. ${content2}`
|
|
18116
18103
|
};
|
|
18117
18104
|
}
|
|
18118
18105
|
}
|
|
18119
|
-
|
|
18106
|
+
const baseContent = typeof resolvedInstructions === "string" ? resolvedInstructions : "";
|
|
18107
|
+
const content = await this.enrichInstructions(
|
|
18108
|
+
baseContent,
|
|
18109
|
+
retrieverContext,
|
|
18110
|
+
workingMemoryContext,
|
|
18111
|
+
oc
|
|
18112
|
+
);
|
|
18113
|
+
return {
|
|
18114
|
+
role: "system",
|
|
18115
|
+
content: `You are ${this.name}. ${content}`
|
|
18116
|
+
};
|
|
18117
|
+
}
|
|
18118
|
+
/**
|
|
18119
|
+
* Add toolkit instructions
|
|
18120
|
+
*/
|
|
18121
|
+
addToolkitInstructions(baseInstructions) {
|
|
18122
|
+
const toolkits = this.toolManager.getToolkits();
|
|
18123
|
+
let toolInstructions = "";
|
|
18124
|
+
for (const toolkit of toolkits) {
|
|
18125
|
+
if (toolkit.addInstructions && toolkit.instructions) {
|
|
18126
|
+
toolInstructions += `
|
|
18127
|
+
|
|
18128
|
+
${toolkit.instructions}`;
|
|
18129
|
+
}
|
|
18130
|
+
}
|
|
18131
|
+
return baseInstructions + toolInstructions;
|
|
18132
|
+
}
|
|
18133
|
+
/**
|
|
18134
|
+
* Enrich instructions with additional context and modifiers
|
|
18135
|
+
*/
|
|
18136
|
+
async enrichInstructions(baseContent, retrieverContext, workingMemoryContext, oc) {
|
|
18137
|
+
let content = baseContent;
|
|
18120
18138
|
content = this.addToolkitInstructions(content);
|
|
18121
18139
|
if (this.markdown) {
|
|
18122
18140
|
content = `${content}
|
|
@@ -18140,25 +18158,7 @@ ${retrieverContext}`;
|
|
|
18140
18158
|
this.supervisorConfig
|
|
18141
18159
|
);
|
|
18142
18160
|
}
|
|
18143
|
-
return
|
|
18144
|
-
role: "system",
|
|
18145
|
-
content: `You are ${this.name}. ${content}`
|
|
18146
|
-
};
|
|
18147
|
-
}
|
|
18148
|
-
/**
|
|
18149
|
-
* Add toolkit instructions
|
|
18150
|
-
*/
|
|
18151
|
-
addToolkitInstructions(baseInstructions) {
|
|
18152
|
-
const toolkits = this.toolManager.getToolkits();
|
|
18153
|
-
let toolInstructions = "";
|
|
18154
|
-
for (const toolkit of toolkits) {
|
|
18155
|
-
if (toolkit.addInstructions && toolkit.instructions) {
|
|
18156
|
-
toolInstructions += `
|
|
18157
|
-
|
|
18158
|
-
${toolkit.instructions}`;
|
|
18159
|
-
}
|
|
18160
|
-
}
|
|
18161
|
-
return baseInstructions + toolInstructions;
|
|
18161
|
+
return content;
|
|
18162
18162
|
}
|
|
18163
18163
|
/**
|
|
18164
18164
|
* Prepare agents memory for supervisor
|
|
@@ -18201,7 +18201,7 @@ ${toolkit.instructions}`;
|
|
|
18201
18201
|
const retrievedContent = await oc.traceContext.withSpan(retrieverSpan, async () => {
|
|
18202
18202
|
if (!this.retriever) return null;
|
|
18203
18203
|
return await this.retriever.retrieve(retrieverInput, {
|
|
18204
|
-
|
|
18204
|
+
...oc,
|
|
18205
18205
|
logger: retrieverLogger
|
|
18206
18206
|
});
|
|
18207
18207
|
});
|