@o-zakstam/voltagent-convex 1.1.1 → 1.1.3
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/client/defineVoltAgentAPI.d.ts +191 -0
- package/dist/client/defineVoltAgentAPI.d.ts.map +1 -0
- package/dist/client/defineVoltAgentAPI.js +318 -0
- package/dist/client/defineVoltAgentAPI.js.map +1 -0
- package/dist/client/index.d.ts +6 -563
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +8 -285
- package/dist/client/index.js.map +1 -1
- package/dist/client/types.d.ts +13 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +8 -0
- package/dist/client/types.js.map +1 -0
- package/dist/component/_generated/api.d.ts +44 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +31 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +352 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +46 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/dist/component/_generated/server.d.ts +121 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +78 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/conversations.d.ts +108 -0
- package/dist/component/conversations.d.ts.map +1 -0
- package/dist/component/conversations.js +278 -0
- package/dist/component/conversations.js.map +1 -0
- package/dist/component/convex.config.d.ts +13 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +21 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/messages.d.ts +235 -0
- package/dist/component/messages.d.ts.map +1 -0
- package/dist/component/messages.js +186 -0
- package/dist/component/messages.js.map +1 -0
- package/dist/component/schema.d.ts +535 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +113 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/component/steps.d.ts +65 -0
- package/dist/component/steps.d.ts.map +1 -0
- package/dist/component/steps.js +120 -0
- package/dist/component/steps.js.map +1 -0
- package/dist/component/validators.d.ts +633 -0
- package/dist/component/validators.d.ts.map +1 -0
- package/dist/component/validators.js +124 -0
- package/dist/component/validators.js.map +1 -0
- package/dist/component/workflows.d.ts +234 -0
- package/dist/component/workflows.d.ts.map +1 -0
- package/dist/component/workflows.js +229 -0
- package/dist/component/workflows.js.map +1 -0
- package/dist/component/workingMemory.d.ts +30 -0
- package/dist/component/workingMemory.d.ts.map +1 -0
- package/dist/component/workingMemory.js +131 -0
- package/dist/component/workingMemory.js.map +1 -0
- package/dist/index.d.ts +7 -318
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -434
- package/dist/index.js.map +1 -1
- package/dist/memory-adapter.d.ts +153 -0
- package/dist/memory-adapter.d.ts.map +1 -0
- package/dist/memory-adapter.js +462 -0
- package/dist/memory-adapter.js.map +1 -0
- package/dist/types.d.ts +167 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +25 -26
- package/src/client/defineVoltAgentAPI.ts +365 -0
- package/src/client/index.ts +8 -0
- package/src/client/types.ts +14 -0
- package/src/component/_generated/api.ts +60 -0
- package/src/component/_generated/component.ts +466 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +156 -0
- package/src/index.ts +24 -0
- package/{dist/index.cjs → src/memory-adapter.ts} +345 -106
- package/src/types.ts +178 -0
- package/dist/client/index.cjs +0 -288
- package/dist/client/index.cjs.map +0 -1
- package/dist/client/index.d.cts +0 -566
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -322
- /package/{convex → src/component}/conversations.ts +0 -0
- /package/{convex → src/component}/convex.config.ts +0 -0
- /package/{convex → src/component}/messages.ts +0 -0
- /package/{convex → src/component}/schema.ts +0 -0
- /package/{convex → src/component}/steps.ts +0 -0
- /package/{convex → src/component}/validators.ts +0 -0
- /package/{convex → src/component}/workflows.ts +0 -0
- /package/{convex → src/component}/workingMemory.ts +0 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Working memory functions for conversation and user-scoped memory
|
|
3
|
+
*/
|
|
4
|
+
import { mutation, query } from "./_generated/server";
|
|
5
|
+
import { v } from "convex/values";
|
|
6
|
+
/**
|
|
7
|
+
* Get working memory content
|
|
8
|
+
*/
|
|
9
|
+
export const get = query({
|
|
10
|
+
args: {
|
|
11
|
+
conversationId: v.optional(v.string()),
|
|
12
|
+
userId: v.optional(v.string()),
|
|
13
|
+
scope: v.string(),
|
|
14
|
+
},
|
|
15
|
+
handler: async (ctx, args) => {
|
|
16
|
+
if (args.scope === "conversation" && args.conversationId) {
|
|
17
|
+
const conversation = await ctx.db
|
|
18
|
+
.query("conversations")
|
|
19
|
+
.withIndex("by_visible_id", (q) => q.eq("visibleId", args.conversationId))
|
|
20
|
+
.first();
|
|
21
|
+
if (!conversation)
|
|
22
|
+
return null;
|
|
23
|
+
return conversation.metadata
|
|
24
|
+
?.workingMemory;
|
|
25
|
+
}
|
|
26
|
+
if (args.scope === "user" && args.userId) {
|
|
27
|
+
const user = await ctx.db
|
|
28
|
+
.query("users")
|
|
29
|
+
.withIndex("by_visible_id", (q) => q.eq("visibleId", args.userId))
|
|
30
|
+
.first();
|
|
31
|
+
if (!user)
|
|
32
|
+
return null;
|
|
33
|
+
return user.metadata?.workingMemory;
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Set working memory content
|
|
40
|
+
*/
|
|
41
|
+
export const set = mutation({
|
|
42
|
+
args: {
|
|
43
|
+
conversationId: v.optional(v.string()),
|
|
44
|
+
userId: v.optional(v.string()),
|
|
45
|
+
content: v.string(),
|
|
46
|
+
scope: v.string(),
|
|
47
|
+
},
|
|
48
|
+
handler: async (ctx, args) => {
|
|
49
|
+
const now = new Date().toISOString();
|
|
50
|
+
if (args.scope === "conversation" && args.conversationId) {
|
|
51
|
+
const conversation = await ctx.db
|
|
52
|
+
.query("conversations")
|
|
53
|
+
.withIndex("by_visible_id", (q) => q.eq("visibleId", args.conversationId))
|
|
54
|
+
.first();
|
|
55
|
+
if (!conversation) {
|
|
56
|
+
throw new Error("Conversation not found");
|
|
57
|
+
}
|
|
58
|
+
const metadata = {
|
|
59
|
+
...(conversation.metadata || {}),
|
|
60
|
+
workingMemory: args.content,
|
|
61
|
+
};
|
|
62
|
+
await ctx.db.patch(conversation._id, { metadata, updatedAt: now });
|
|
63
|
+
return { success: true };
|
|
64
|
+
}
|
|
65
|
+
if (args.scope === "user" && args.userId) {
|
|
66
|
+
const existing = await ctx.db
|
|
67
|
+
.query("users")
|
|
68
|
+
.withIndex("by_visible_id", (q) => q.eq("visibleId", args.userId))
|
|
69
|
+
.first();
|
|
70
|
+
if (existing) {
|
|
71
|
+
const metadata = {
|
|
72
|
+
...(existing.metadata || {}),
|
|
73
|
+
workingMemory: args.content,
|
|
74
|
+
};
|
|
75
|
+
await ctx.db.patch(existing._id, { metadata, updatedAt: now });
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
await ctx.db.insert("users", {
|
|
79
|
+
visibleId: args.userId,
|
|
80
|
+
metadata: { workingMemory: args.content },
|
|
81
|
+
createdAt: now,
|
|
82
|
+
updatedAt: now,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return { success: true };
|
|
86
|
+
}
|
|
87
|
+
return { success: false };
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
/**
|
|
91
|
+
* Delete working memory content
|
|
92
|
+
*/
|
|
93
|
+
export const remove = mutation({
|
|
94
|
+
args: {
|
|
95
|
+
conversationId: v.optional(v.string()),
|
|
96
|
+
userId: v.optional(v.string()),
|
|
97
|
+
scope: v.string(),
|
|
98
|
+
},
|
|
99
|
+
handler: async (ctx, args) => {
|
|
100
|
+
const now = new Date().toISOString();
|
|
101
|
+
if (args.scope === "conversation" && args.conversationId) {
|
|
102
|
+
const conversation = await ctx.db
|
|
103
|
+
.query("conversations")
|
|
104
|
+
.withIndex("by_visible_id", (q) => q.eq("visibleId", args.conversationId))
|
|
105
|
+
.first();
|
|
106
|
+
if (conversation &&
|
|
107
|
+
conversation.metadata?.workingMemory) {
|
|
108
|
+
const metadata = {
|
|
109
|
+
...conversation.metadata,
|
|
110
|
+
};
|
|
111
|
+
delete metadata.workingMemory;
|
|
112
|
+
await ctx.db.patch(conversation._id, { metadata, updatedAt: now });
|
|
113
|
+
}
|
|
114
|
+
return { success: true };
|
|
115
|
+
}
|
|
116
|
+
if (args.scope === "user" && args.userId) {
|
|
117
|
+
const user = await ctx.db
|
|
118
|
+
.query("users")
|
|
119
|
+
.withIndex("by_visible_id", (q) => q.eq("visibleId", args.userId))
|
|
120
|
+
.first();
|
|
121
|
+
if (user && user.metadata?.workingMemory) {
|
|
122
|
+
const metadata = { ...user.metadata };
|
|
123
|
+
delete metadata.workingMemory;
|
|
124
|
+
await ctx.db.patch(user._id, { metadata, updatedAt: now });
|
|
125
|
+
}
|
|
126
|
+
return { success: true };
|
|
127
|
+
}
|
|
128
|
+
return { success: false };
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
//# sourceMappingURL=workingMemory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workingMemory.js","sourceRoot":"","sources":["../../src/component/workingMemory.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC;IACvB,IAAI,EAAE;QACJ,cAAc,EA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AE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;YAC7D,CAAC;YAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC3B,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,322 +1,11 @@
|
|
|
1
|
-
import { StorageAdapter, OperationContext, GetMessagesOptions, ConversationStepRecord, GetConversationStepsOptions, CreateConversationInput, Conversation, ConversationQueryOptions, WorkingMemoryScope, WorkflowStateEntry } from '@voltagent/core';
|
|
2
|
-
import { UIMessage } from 'ai';
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Logger interface for the adapter
|
|
9
|
-
*/
|
|
10
|
-
interface Logger {
|
|
11
|
-
debug: (message: string, ...args: unknown[]) => void;
|
|
12
|
-
info: (message: string, ...args: unknown[]) => void;
|
|
13
|
-
warn: (message: string, ...args: unknown[]) => void;
|
|
14
|
-
error: (message: string, ...args: unknown[]) => void;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Convex client interface - compatible with ConvexHttpClient and ConvexReactClient.
|
|
18
|
-
*
|
|
19
|
-
* This interface is intentionally loose to accommodate different Convex client
|
|
20
|
-
* implementations (ConvexHttpClient, ConvexReactClient) which have slightly
|
|
21
|
-
* different method signatures.
|
|
22
|
-
*/
|
|
23
|
-
interface ConvexClient {
|
|
24
|
-
query: (functionReference: any, ...args: any[]) => Promise<any>;
|
|
25
|
-
mutation: (functionReference: any, ...args: any[]) => Promise<any>;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* The VoltAgent API structure.
|
|
29
|
-
* This matches the wrapper functions exported from the convex/api.ts file.
|
|
30
|
-
*/
|
|
31
|
-
interface VoltAgentApi {
|
|
32
|
-
createConversation: unknown;
|
|
33
|
-
getConversation: unknown;
|
|
34
|
-
getConversations: unknown;
|
|
35
|
-
getConversationsByUserId: unknown;
|
|
36
|
-
queryConversations: unknown;
|
|
37
|
-
updateConversation: unknown;
|
|
38
|
-
deleteConversation: unknown;
|
|
39
|
-
addMessage: unknown;
|
|
40
|
-
addMessages: unknown;
|
|
41
|
-
getMessages: unknown;
|
|
42
|
-
clearMessages: unknown;
|
|
43
|
-
saveConversationSteps: unknown;
|
|
44
|
-
getConversationSteps: unknown;
|
|
45
|
-
getWorkingMemory: unknown;
|
|
46
|
-
setWorkingMemory: unknown;
|
|
47
|
-
deleteWorkingMemory: unknown;
|
|
48
|
-
getWorkflowState: unknown;
|
|
49
|
-
queryWorkflowRuns: unknown;
|
|
50
|
-
setWorkflowState: unknown;
|
|
51
|
-
updateWorkflowState: unknown;
|
|
52
|
-
getSuspendedWorkflowStates: unknown;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Configuration options for ConvexMemoryAdapter
|
|
56
|
-
*/
|
|
57
|
-
interface ConvexMemoryAdapterOptions {
|
|
58
|
-
/**
|
|
59
|
-
* The Convex client instance to use for queries and mutations.
|
|
60
|
-
* Can be a ConvexHttpClient or ConvexReactClient.
|
|
61
|
-
*/
|
|
62
|
-
client: ConvexClient;
|
|
63
|
-
/**
|
|
64
|
-
* Whether to enable debug logging.
|
|
65
|
-
* @default false
|
|
66
|
-
*/
|
|
67
|
-
debug?: boolean;
|
|
68
|
-
/**
|
|
69
|
-
* Custom logger instance.
|
|
70
|
-
* If not provided, a default console logger will be used when debug is enabled.
|
|
71
|
-
*/
|
|
72
|
-
logger?: Logger;
|
|
73
|
-
/**
|
|
74
|
-
* The VoltAgent API from your Convex generated code.
|
|
75
|
-
*
|
|
76
|
-
* After adding the voltagent.ts file to your convex folder that re-exports
|
|
77
|
-
* the wrapper functions, import the api and pass api.voltagent here.
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* ```ts
|
|
81
|
-
* import { api } from "./convex/_generated/api";
|
|
82
|
-
*
|
|
83
|
-
* const adapter = new ConvexMemoryAdapter({
|
|
84
|
-
* client,
|
|
85
|
-
* api: api.voltagent,
|
|
86
|
-
* });
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
api: VoltAgentApi;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Internal representation of a conversation in Convex
|
|
93
|
-
*/
|
|
94
|
-
interface ConvexConversation {
|
|
95
|
-
_id: string;
|
|
96
|
-
visibleId: string;
|
|
97
|
-
resourceId: string;
|
|
98
|
-
userId: string;
|
|
99
|
-
title: string;
|
|
100
|
-
metadata: Record<string, unknown>;
|
|
101
|
-
createdAt: string;
|
|
102
|
-
updatedAt: string;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Internal representation of a message in Convex
|
|
106
|
-
*/
|
|
107
|
-
interface ConvexMessage {
|
|
108
|
-
_id: string;
|
|
109
|
-
visibleId: string;
|
|
110
|
-
conversationId: string;
|
|
111
|
-
userId: string;
|
|
112
|
-
role: string;
|
|
113
|
-
parts: unknown[];
|
|
114
|
-
metadata?: Record<string, unknown>;
|
|
115
|
-
createdAt: string;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Internal representation of a user in Convex
|
|
119
|
-
*/
|
|
120
|
-
interface ConvexUser {
|
|
121
|
-
_id: string;
|
|
122
|
-
visibleId: string;
|
|
123
|
-
metadata?: Record<string, unknown>;
|
|
124
|
-
createdAt: string;
|
|
125
|
-
updatedAt: string;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Internal representation of a workflow state in Convex
|
|
129
|
-
*/
|
|
130
|
-
interface ConvexWorkflowState {
|
|
131
|
-
_id: string;
|
|
132
|
-
visibleId: string;
|
|
133
|
-
workflowId: string;
|
|
134
|
-
workflowName: string;
|
|
135
|
-
status: string;
|
|
136
|
-
input?: unknown;
|
|
137
|
-
context?: unknown;
|
|
138
|
-
suspension?: unknown;
|
|
139
|
-
events?: unknown[];
|
|
140
|
-
output?: unknown;
|
|
141
|
-
cancellation?: unknown;
|
|
142
|
-
userId?: string;
|
|
143
|
-
conversationId?: string;
|
|
144
|
-
metadata?: Record<string, unknown>;
|
|
145
|
-
createdAt: string;
|
|
146
|
-
updatedAt: string;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Internal representation of a conversation step in Convex
|
|
150
|
-
*/
|
|
151
|
-
interface ConvexConversationStep {
|
|
152
|
-
_id: string;
|
|
153
|
-
visibleId: string;
|
|
154
|
-
conversationId: string;
|
|
155
|
-
userId: string;
|
|
156
|
-
agentId: string;
|
|
157
|
-
agentName?: string;
|
|
158
|
-
operationId?: string;
|
|
159
|
-
stepIndex: number;
|
|
160
|
-
type: string;
|
|
161
|
-
role: string;
|
|
162
|
-
content?: string;
|
|
163
|
-
arguments?: Record<string, unknown>;
|
|
164
|
-
result?: Record<string, unknown>;
|
|
165
|
-
usage?: Record<string, unknown>;
|
|
166
|
-
subAgentId?: string;
|
|
167
|
-
subAgentName?: string;
|
|
168
|
-
createdAt: string;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Convex Memory Adapter for VoltAgent
|
|
173
|
-
*
|
|
174
|
-
* A StorageAdapter implementation that persists conversation data
|
|
175
|
-
* to Convex database using the VoltAgent Convex component.
|
|
176
|
-
*/
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Convex Memory Adapter for VoltAgent
|
|
180
|
-
*
|
|
181
|
-
* Implements the StorageAdapter interface to persist conversation history,
|
|
182
|
-
* working memory, and workflow state to a Convex database.
|
|
183
|
-
*
|
|
184
|
-
* @example
|
|
185
|
-
* ```ts
|
|
186
|
-
* import { ConvexHttpClient } from "convex/browser";
|
|
187
|
-
* import { api } from "./convex/_generated/api";
|
|
188
|
-
* import { ConvexMemoryAdapter } from "@voltagent/convex";
|
|
189
|
-
*
|
|
190
|
-
* const client = new ConvexHttpClient(process.env.CONVEX_URL);
|
|
2
|
+
* VoltAgent Convex Storage Adapter
|
|
191
3
|
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
* api: api.voltagent,
|
|
195
|
-
* });
|
|
4
|
+
* A StorageAdapter implementation for VoltAgent that persists
|
|
5
|
+
* conversation data to Convex database using a Convex component.
|
|
196
6
|
*
|
|
197
|
-
*
|
|
198
|
-
* ```
|
|
7
|
+
* @packageDocumentation
|
|
199
8
|
*/
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
private debug;
|
|
204
|
-
private logger;
|
|
205
|
-
constructor(options: ConvexMemoryAdapterOptions);
|
|
206
|
-
/**
|
|
207
|
-
* Log debug messages
|
|
208
|
-
*/
|
|
209
|
-
private log;
|
|
210
|
-
/**
|
|
211
|
-
* Generate a cryptographically secure random ID
|
|
212
|
-
*/
|
|
213
|
-
private generateId;
|
|
214
|
-
/**
|
|
215
|
-
* Add a single message to a conversation
|
|
216
|
-
*/
|
|
217
|
-
addMessage(message: UIMessage, userId: string, conversationId: string, _context?: OperationContext): Promise<void>;
|
|
218
|
-
/**
|
|
219
|
-
* Add multiple messages to a conversation
|
|
220
|
-
*/
|
|
221
|
-
addMessages(messages: UIMessage[], userId: string, conversationId: string, _context?: OperationContext): Promise<void>;
|
|
222
|
-
/**
|
|
223
|
-
* Get messages from a conversation with optional filtering
|
|
224
|
-
*/
|
|
225
|
-
getMessages(userId: string, conversationId: string, options?: GetMessagesOptions, _context?: OperationContext): Promise<UIMessage<{
|
|
226
|
-
createdAt: Date;
|
|
227
|
-
}>[]>;
|
|
228
|
-
/**
|
|
229
|
-
* Clear messages for a user (optionally for a specific conversation)
|
|
230
|
-
*/
|
|
231
|
-
clearMessages(userId: string, conversationId?: string, _context?: OperationContext): Promise<void>;
|
|
232
|
-
/**
|
|
233
|
-
* Save conversation steps for observability
|
|
234
|
-
*/
|
|
235
|
-
saveConversationSteps(steps: ConversationStepRecord[]): Promise<void>;
|
|
236
|
-
/**
|
|
237
|
-
* Get conversation steps for observability
|
|
238
|
-
*/
|
|
239
|
-
getConversationSteps(userId: string, conversationId: string, options?: GetConversationStepsOptions): Promise<ConversationStepRecord[]>;
|
|
240
|
-
/**
|
|
241
|
-
* Create a new conversation
|
|
242
|
-
*/
|
|
243
|
-
createConversation(input: CreateConversationInput): Promise<Conversation>;
|
|
244
|
-
/**
|
|
245
|
-
* Get a conversation by ID
|
|
246
|
-
*/
|
|
247
|
-
getConversation(id: string): Promise<Conversation | null>;
|
|
248
|
-
/**
|
|
249
|
-
* Get conversations by resource ID
|
|
250
|
-
*/
|
|
251
|
-
getConversations(resourceId: string): Promise<Conversation[]>;
|
|
252
|
-
/**
|
|
253
|
-
* Get conversations by user ID with optional query options
|
|
254
|
-
*/
|
|
255
|
-
getConversationsByUserId(userId: string, options?: Omit<ConversationQueryOptions, "userId">): Promise<Conversation[]>;
|
|
256
|
-
/**
|
|
257
|
-
* Query conversations with filters
|
|
258
|
-
*/
|
|
259
|
-
queryConversations(options: ConversationQueryOptions): Promise<Conversation[]>;
|
|
260
|
-
/**
|
|
261
|
-
* Update a conversation
|
|
262
|
-
*/
|
|
263
|
-
updateConversation(id: string, updates: Partial<Omit<Conversation, "id" | "createdAt" | "updatedAt">>): Promise<Conversation>;
|
|
264
|
-
/**
|
|
265
|
-
* Delete a conversation and its associated data
|
|
266
|
-
*/
|
|
267
|
-
deleteConversation(id: string): Promise<void>;
|
|
268
|
-
/**
|
|
269
|
-
* Get working memory content
|
|
270
|
-
*/
|
|
271
|
-
getWorkingMemory(params: {
|
|
272
|
-
conversationId?: string;
|
|
273
|
-
userId?: string;
|
|
274
|
-
scope: WorkingMemoryScope;
|
|
275
|
-
}): Promise<string | null>;
|
|
276
|
-
/**
|
|
277
|
-
* Set working memory content
|
|
278
|
-
*/
|
|
279
|
-
setWorkingMemory(params: {
|
|
280
|
-
conversationId?: string;
|
|
281
|
-
userId?: string;
|
|
282
|
-
content: string;
|
|
283
|
-
scope: WorkingMemoryScope;
|
|
284
|
-
}): Promise<void>;
|
|
285
|
-
/**
|
|
286
|
-
* Delete working memory content
|
|
287
|
-
*/
|
|
288
|
-
deleteWorkingMemory(params: {
|
|
289
|
-
conversationId?: string;
|
|
290
|
-
userId?: string;
|
|
291
|
-
scope: WorkingMemoryScope;
|
|
292
|
-
}): Promise<void>;
|
|
293
|
-
/**
|
|
294
|
-
* Get workflow state by execution ID
|
|
295
|
-
*/
|
|
296
|
-
getWorkflowState(executionId: string): Promise<WorkflowStateEntry | null>;
|
|
297
|
-
/**
|
|
298
|
-
* Query workflow runs with optional filters
|
|
299
|
-
*/
|
|
300
|
-
queryWorkflowRuns(query: {
|
|
301
|
-
workflowId?: string;
|
|
302
|
-
status?: WorkflowStateEntry["status"];
|
|
303
|
-
from?: Date;
|
|
304
|
-
to?: Date;
|
|
305
|
-
limit?: number;
|
|
306
|
-
offset?: number;
|
|
307
|
-
}): Promise<WorkflowStateEntry[]>;
|
|
308
|
-
/**
|
|
309
|
-
* Set workflow state
|
|
310
|
-
*/
|
|
311
|
-
setWorkflowState(executionId: string, state: WorkflowStateEntry): Promise<void>;
|
|
312
|
-
/**
|
|
313
|
-
* Update workflow state
|
|
314
|
-
*/
|
|
315
|
-
updateWorkflowState(executionId: string, updates: Partial<WorkflowStateEntry>): Promise<void>;
|
|
316
|
-
/**
|
|
317
|
-
* Get suspended workflow states for a workflow
|
|
318
|
-
*/
|
|
319
|
-
getSuspendedWorkflowStates(workflowId: string): Promise<WorkflowStateEntry[]>;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
export { type ConvexClient, type ConvexConversation, type ConvexConversationStep, ConvexMemoryAdapter, type ConvexMemoryAdapterOptions, type ConvexMessage, type ConvexUser, type ConvexWorkflowState, type Logger, type VoltAgentApi };
|
|
9
|
+
export { ConvexMemoryAdapter } from "./memory-adapter";
|
|
10
|
+
export type { ConvexMemoryAdapterOptions, ConvexClient, Logger, VoltAgentApi, ConvexConversation, ConvexMessage, ConvexUser, ConvexWorkflowState, ConvexConversationStep, } from "./types";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD,YAAY,EACV,0BAA0B,EAC1B,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,SAAS,CAAC"}
|